.include "labmac.i" .section .text .globl main main: MOVE.L #0xff, D1 JSR outhxl MOVE.L #0x12345678, D1 JSR outhxl MOVE.L #0xABCDEF00, D1 JSR outhxl MOVE.L #0xA70C, D1 JSR outhxl RTS outhxl: MOVE.L D1, D6 | save input LSR.L #8, D1 | isolate 1. byte (left) LSR.L #8, D1 | shift has max. of 8 LSR.L #8, D1 | JSR outhex | call output MOVE.L D6, D1 | restore input LSR.L #8, D1 | isolate 2. byte LSR.L #8, D1 | shift has max. of 8 JSR outhex | call output MOVE.L D6, D1 | restore input LSR.L #8, D1 | isolate 3. byte JSR outhex | call output MOVE.L D6, D1 | restore input JSR outhex | call output for 4. byte MOVE.L #10, D1 | print a new line CALLEXEC LCD_PutChar MOVE.L D6, D1 | restore input parameter RTS outhex: MOVE.L D1, D7 | copy input number LSR.B #4, D1 | isolate left hex digit JSR digit | call output routine for 1st digit MOVE.L D7, D1 | restore input AND.L #0x0F, D1 | isolate right hex digit JSR digit | call output routine for 2nd digit MOVE.L #' ', D1 | print a space character CALLEXEC LCD_PutChar MOVE.L D7, D1 | restore input RTS Zero = 48 | ascii code for 0 LetterA = 55 | ascii code for A - 10 digit: CMP.B #10, D1 | Is digit within 0..9 ? BGE abcdef ADD.B #Zero, D1 | Yes: transform 0 ? 0, 1 ? 1 CALLEXEC LCD_PutChar | print as character RTS abcdef: ADD.B #LetterA, D1 | No: transform 10 ? A, 11 ? B CALLEXEC LCD_PutChar | print as character RTS