Nested for Loop in Y86

0

so I trying to figure out to write a nested for loop in Y86. (I now that Y86 is just for teaching). I have looked at how to do a regular for loop, but not sure how to do it for a nested loop, especially when you are calling 2 functions, one right after the other. Could someone point me in the right direction. Here is just an example of what I want to write.

for (x = 5; x<=10; ++x){
    for (y = 1; y <=5; y+=2){
         //call some function afunction(x, y)
         //call a different function  a2function(x,y)
    }
}


main:   
irmovl $5,%esi  #esi = x    
irmovl $1,%ecx   #ecx = y   
irmovl Stack,%esp   
irmovl Array,%ebx   


loop:
pushl %ebx
pushl %esi
pushl %ecx
call rec  #funcitons
call bit  #functions
popl %ecx
popl %esi
popl %ebx

rmmovl %esi, (%ebx)
rmmovl %ecx, (%ebx)
irmovl $4, %edx
addl %edx, %ebx
irmovl $0xffffffff,%edx
rmmovl %edx,(%ebx)
irmovl $4,%edx
addl %edx,%ebx
irmovl $1,%edx
addl %edx,%ecx
irmovl $8,%edx
subl %ecx,%edx
jne innerloop
halt
for-loop
assembly
nested-loops
y86
asked on Stack Overflow Dec 6, 2018 by v. cruz • edited Dec 7, 2018 by v. cruz

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0