.pos 0x200
.align 4
InputArray:
.long 5
.long 10
Done: .long 0x0
.pos 0x400
.align 4
OutputArray:
.pos 0x0
irmovl InputArray,%eax
irmovl OutputArray, %esi
Loop:
mrmovl (%eax), %ecx # get first element from InputArray
mrmovl (%eax), %edi # a copy of first element used for multiplication
irmovl $4, %ebx # increment the pointer of InputArray
addl %ebx, %eax
mrmovl (%eax), %edx # get second element from InputArray
irmovl $1, %ebx # add first element to its copy for the amount of second element
subl %ebx, %edx
jg mult
rmmovl %ecx,(%esi) # output value to OutputArray
mult:
addl %edi, %ecx
subl %ebx, %edx
jg mult
Exit: halt
这是一个非常简单的程序,可以对我为 Y86 编写的一对整数(5 乘 10)进行无符号乘法运算。
当我运行代码时,结果如下所示:
Stopped in 38 steps at PC = 0x42. Status 'HLT', CC Z=1 S=0 O=0
Changes to registers:
%eax: 0x00000000 0x00000204
%ecx: 0x00000000 0x00000032
%ebx: 0x00000000 0x00000001
%esi: 0x00000000 0x00000400
%edi: 0x00000000 0x00000005
Changes to memory:
计算结果的寄存器 ecx 是十六进制的 32,所以我肯定知道 mult 循环已按预期执行,但没有任何内容输出到 OutputArray,我不明白为什么。