IA32 to Y86
ATT Assembly
I have the following IA32 assembly code:
Bubble:
.LFB0:
pushl %esi
pushl %ebx
movl 16(%esp), %esi
movl 12(%esp), %edx
subl $1, %esi
andl %esi, %esi
jle .L1
.L7:
xorl %eax, %eax
.L5:
movl 4(%edx,%eax,4), %ecx
movl (%edx,%eax,4), %ebx
cmpl %ebx, %ecx
jge .L4
movl %ebx, 4(%edx,%eax,4)
movl %ecx, (%edx,%eax,4)
.L4:
addl $1, %eax
cmpl %eax, %esi
jg .L5
subl $1, %esi
jne .L7
.L1:
popl %ebx
popl %esi
ret
I'm trying to convert it to Y86 assembly code. I'm having trouble translating the compare instruction:
cmpl %ebx, %ecx
Thanks.
It seems that Y86 does not have
cmp
instruction. However, it hassub
,push
andpop
.So
cmpl %ebx, %ecx
can be converted to the following code:cmp
is exactly the same assub
, with the difference thatcmp
does not store the result, it only updates the flags. Socmp
can always be replaced withpush
,sub
,pop
(if there's enough space in the stack).