# this program multiplies num1 and num2, the result is stored in product .lcomm num1 2 # reserve two bytes for num1 .lcomm num2 2 # reserve two bytes for num2 .lcomm product 2 # reserve two bytes for product .text .global _start _start: nop # so I can stop at the next instruction movw num2,%ax # product is implicitly initialized to zero because of lcomm movw $0,product addAgain: # check the condition (num1 > 0) cmpw $0,num1 jz endOfMult # num1 > 0 addw %ax,product subw $1,num1 jmp addAgain # end while, go back and check the condition again endOfMult: movl $1,%eax int $0x80