.include "labmac.i" .section .text .globl main main: MOVE.L #5, -(SP) | PUSH JSR abs | call subroutine ADD.L #4, SP | POP MOVE.L D0,D1 JSR outint MOVE.L #-5, -(SP) | PUSH JSR abs | call subroutine ADD.L #4, SP | POP MOVE.L D0,D1 JSR outint RTS abs: MOVE.L 4(SP), D0 | GET parameter BPL done | done if input value is positive NEG.L D0 | else (value is neg.), negate it done: RTS | -------------------------------------------------- outint: MOVEM.L D1-D2/A0,-(SP) | SAVE REGISTERS MOVE.L #intstr+10, A0 | pointer A0 behind last digit loop: DIVUL.L #10, D2:D1 | D1 := D1/10, D2 := remainder ADD.B #'0', D2 | make D2 digit character MOVE.B D2, -(A0) | write digit TST.L D1 | check quotient BNE loop | while ? 0 repeat with quotient in D1 print: CALLEXEC LCD_PutString | call string print (address in A0) MOVEM.L (SP)+,D1-D2/A0 | RESTORE REGISTERS RTS intstr: .asciz "1234567890 " | number can have up to 10 digits