Lab 4 - Part 2 x86_64
Hello everyone in this lab we are test some piece of code to make the loop in the AArch64 system and lets start with the base code which is given by Chris Tyler.
So in this lab we just need to work with the AArch64 system and x86_64 and make use more familiar with this ssh system that is call israel and portugal which are two different system working on AArch64 an x86-64.
So for the first time we need to make the code that will run on the x86_64 system which is going to print the loop from 0 to 9 and the base was given to us by Chris Tyler.
So making it we have to useful but dugging is was hard enough to find one single error. so starting with the error like when i start searching i am not able to figure out which increments and loop skiping variables are going to used and then i read some notes and watch the lecture again to find it out.
Now for 0 to 30 we just need to change some thing like add ,max values and add some varibale to balance it out. Like the max value should be like 31 so it start from 0 till 30 and has some more handler.
.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) */
cvt = 48
_start:
mov $min,%r15 /* loop index */
loop:
/* ... body of the loop ... do something useful here ... */
movq $len,%rdx
movq $msg,%rsi
movq $cvt,%r14
movq %r15,%r13
add %r13,%r14
movb %r14b,msg+6
movq $1,%rdi
movq $1,%rax
syscall
inc %r15
cmp $max,%r15
jne loop
mov $0,%rdi
mov $60,%rax
syscall
.section .data
msg: .ascii "Loop: \n"
len = . - msg
.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) */
cvt = 48
d = 10
_start:
mov $min,%r15 /* loop index */
loop:
movq $len,%rcx
movq $msg,%rsi
movq $cvt,%r14
movq $d,%r10
movq %r15,%rax
div %r10
movq %rax,%r9
movq %rdx,%r8
movq %r9,msg+6
movq $1,%rdi
movq $1,%rax
syscall
inc %r15
cmp $max,%r15
jne loop
mov $0,%rdi
mov $60,%rax
syscall
.section .data
msg: .ascii "Loop: \n"
len = . - msg
Comments
Post a Comment