0

所以我想弄清楚在 Y86 中编写一个嵌套的 for 循环。(我现在 Y86 只是为了教学)。我已经研究了如何执行常规 for 循环,但不确定如何为嵌套循环执行此操作,尤其是当您调用 2 个函数时,一个接一个地调用。有人可以指出我正确的方向。这只是我想写的一个例子。

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
4

0 回答 0