Lab 4 - Part 1 (AArch64)
This lab is based on an introduction to 64 bit Assembly language for aarch64 and x86 64. In this lab, I'll be working with assembly language on both the x86 64 and aarch64 platforms. To access these platforms, we must use SSH servers to connect to two servers provided by the professor. The first server is Israel, which runs on an aarch64 system, and the second server is Portugal, which runs on an x86 64 system.
The first task is to compile and run aarch64 programs. I connected to the Israel server and configured some settings for it. After that, I was given some examples to work with.
Then, from 0 to 9, we must create a loop and print the word with each increment along with the increment counter. We were given a loop template that did not include the loop body. In aarch64, the value 64 is used to invoke the write method. In the second step, I copied the value from r19 to a new register and prefixed it with '0' to convert it to ascii, then I moved that value to the location of # in the text. I was able to print the loop increment with text in each iteration by doing so. This is my code:
.text
.globl _start
min = 0 /* starting value for the loop index; note that this is a symbol (constant), not a variable */
max = 10 /* loop exits when the index hits this number (loop condition is i<max) */
_start:
mov x19, min
loop:
/*Start of loop*/
mov x20, x19
add x20, x20, '0'
adr x21, msg + 5
strb w20, [x21]
mov x0, 1
adr x1, msg
mov x2, len
mov x8, 64
svc 0
/*End of loop*/
add x19, x19, 1
cmp x19, max
b.ne loop
mov x0, 0 /* status -> 0 */
mov x8, 93 /* exit is syscall #93 */
svc 0 /* invoke syscall */
.data
msg: .ascii "Loop #\n"
len= . - msg
On x86_64 machine, the remainder is automatically computed and stored in the rdx register. To compute the rest on aarch64 machines, I had to use another directive called msub. One of these difficulties was that the remainder was not computed by itself when using division directives in AArch64.
Comments
Post a Comment