Lab 4 - Part 1 AArch64

 This lab we are going to run simple run on loop to print some lines in the like loop0 loop1 and till 9 or 30.

So the base code is given by Chris Tyler and we need to modified that code or basically clly we just need to add some code in it. 

So here is the code for the loop which will go 30 times in the printing statement which is like this:

x.text

.globl    _start
min = 0 	/* starting value for the loop index; note that this is a symbol (constant), not a variable */
max = 31		/* loop exits when the index hits this number (loop condition is i<max) */
ten = 10

_start:
        mov     x19, min
        mov     x22, ten
		
loop:
        adr     x1, msg
        mov     x2, len
        mov     x0, 1
        mov     x8, 64
        svc     0
        adr     x23, msg
        add     x19, x19, 1
        udiv    x20, x19, x22
        msub    x21, x22, x20, x19
        cmp     x20, 0
        beq     skip
        add     x20, x20, '0'
        strb    w20, [x23,6]
skip:
        add     x21, x21, '0'
        strb    w21, [x23,7]
        cmp     x19, max
        bne     loop
        mov     x0, 0
        mov     x8, 93
        svc     0
.data
        msg: .ascii  "Loop:  0\n"
        len = . - msg


Here the ten which change the decmial points and we are also usning rdx.
And the reason it was easier said than done was because we had a small little task that turned out to be harder than we thought. One of these challenges was that in Aarch64 the remainder was not computed by itself when using division directives. For x86_64 machines the rest is automatically computed into the rdx register. For aarch64 machines I had to use another directive msub to compute the rest. After finding these tiny little quarks, I started getting segmentation faults. I tried to debug it with the debugger, but unfortunately got stuck. I tried to change the code, but this resulted in unwanted output and finally the end of the class. We said it was ridiculous and called it a day.

Comments

Popular posts from this blog

ifunc function

Lab2 - 6502 Assembly Language Lab(Calculation)

Lab1 - 2 Open Sources Packages