Wednesday, October 2, 2019

SPO600 Lab3 Pt2/2

Maybe its because I was too used to programming assembler on X86_64 but trying to do the same thing on ARM was a lot more difficult in my opinion. This week we finished up with the lab we were assigned by doing the same thing except on the ARM64 instead of X86.

The concept of a lot of the things are the same, such as use certain registers so your values don't get trampled or lost. 


I lied, with a bit of further practice, it is as the prof said: "easier than x86_64".

Just like with X86, we increased the string by one more character to accommodate the extra number, we also changed the register holding the max loop value to 30 and introduced another register to hold the value of the divisor.

There is also a loop written in if/else format with the more: and print: section. If the current loop count is greater than 10, the program will branch to label more: and continue from there, otherwise it will continue along and then branch to label print: section. I made sure some instructions were written after the branch to other labels as there's no point in calculating the ASCII value of register 25 or replacing the character of the string offset 7 if we're not going to use it or the character is going to be overwritten by a later instruction.

The biggest difference between the two architectures regarding this assignment was a division function that also calculated the remainder. In X86 there was a div instruction that put quotient and remainder into dedicated registers, ARM64 didn't have one and instead we had to use two instructions udiv to calculate quotient and msub to calculate the remainder.

In the following in the more: section the remainder was calculated by multiplying whatever the calculated quotient was from the previous line in register 23

udiv    x23,x20,x22

by 10 and then subtracting that from our current loop count.


No comments:

Post a Comment

Contains Duplicate (Leetcode)

I wrote a post  roughly 2/3 years ago regarding data structures and algorithms. I thought I'd follow up with some questions I'd come...