.include "labmac.i" .section .text .globl main main: MOVE.L #128, %D5 MOVE.L %D5, -(%SP) JSR log ADD.L #4, %SP JSR output JSR press log: MOVE.L 4(%SP),%D4 CMP.L #1,%D4 BNE div MOVE.L #0, %D0 | ret log(1) = 0 JSR output RTS div: ASR.L #1,%D4 | ret log(n) = log(n div 2) + 1 MOVE.L %D4,-(%SP) JSR log ADD.L #4, %SP ADD.L #1,%D0 JSR output RTS output: MOVE.L %D0,%D7 | copy MOVE.L %D0,%D1 ADD.L #48, %D1 CALLEXEC LCD_PutChar MOVE.B #32,%D1 CALLEXEC LCD_PutChar | call LCD print routine MOVE.L %D7,%D0 | restore RTS press: MOVE.L #ANYKEY, %D1 | load code to wait for key press CALLEXEC KEY_Wait | call KEY routine RTS | return to operating system