########## # control.s for use in CSE351 Lec 9 on Condition Codes # # Use "print $eflags" to view condition flags in gdb ########## .text .globl absdiff .type absdiff, @function absdiff: cmpq %rsi, %rdi # jump to .L2 if %rdi <= %rsi, jle .L2 # i.e. !(x>y) movq %rdi, %rax # return x - y subq %rsi, %rax ret .L2: movq %rsi, %rax # return y - x subq %rdi, %rax ret .size absdiff, .-absdiff .globl compound .type compound, @function compound: cmpq $3, %rdi setl %al cmpq %rsi, %rdi sete %bl testb %al, %bl je .L6 movq $1, %rax ret .L6: movq $2, %rax ret .size compound, .-compound .globl main .type main, @function main: movl $4, %esi movl $5, %edi call absdiff # absdiff(5,4) = 1 movq %rax, %rsi movl $1, %edi call compound # compound(1,1) = 2 rep ret .size main, .-main