# Ulf Gebhardt, Michael Scholz .data # Programm ist mit allen angegebenen Werten getestet. # a: .long 0 b: .long 56 intout: .string "Wert %d\n" .text .globl main main: movl a, %eax # %eax = a movl b, %ebx # %ebx = b call mul_agy # rufe mul_agy auf jmp _exit # jump to program-end mul_agy: cmp $0, %ebx # ist b = 0? jz mul_agy_ancor # falls 0 springe zu mul_agy_ancor movl %ebx, %ecx # kopiere b -> c and $0b000001, %ecx # c = 0(gerade) / 1(ungerade) cmp $0, %ecx # c = 0 ? jz mul_agy_even # falls 0 springe zu mul_agy_even mul_agy_uneven: # merke a, da b ungerade pushl %eax # a auf den stack sall $1, %eax # a<<1 shrl $1, %ebx # b>>>1 call mul_agy # rufe mul_agy auf popl %ecx # hole a von stack und schreibe nach c add %ecx, %eax # a = a + c ret # springe in letzte rekursionsstufe mul_agy_even: # ignoriere a, da b gerade sall $1, %eax # a<<1 shrl $1, %ebx # b>>>1 call mul_agy # rufe mul_agy auf (oben wurde shcon geshiftet) ret # springe in letzte rekursionsstufe mul_agy_ancor: xor %eax, %eax # %eax = 0; ret # springe zurück _exit: # Wert im %eax ausgeben pushl %eax pushl $intout call printf movl $1, %eax int $0x80