Created
January 21, 2024 14:40
-
-
Save Loevland/ef9a60c1d8c403616b7ed59fa2831a32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% STD | |
!ICO ? NIP <- #HLT | |
loop: | |
; Read one word into RES | |
RES <- IDA | |
; Print the 4 hex digits of RES | |
NIP <- #rotate_and_print_digit | |
NIP <- #rotate_and_print_digit | |
NIP <- #rotate_and_print_digit | |
NIP <- #rotate_and_print_digit | |
counter <- INC <- counter | |
; Stop if there is no more input | |
!ICO ? NIP <- #stop | |
DBG <- counter | |
ALX <- counter | |
ALY <- #16 | |
EQU ? NIP <- #reset | |
PRN <- #' ' | |
NIP <- #loop | |
reset: | |
counter <- #0 | |
PRN <- #10 ; Print newline | |
NIP <- #loop | |
stop: | |
PRN <- #10 ; Print newline at the end | |
NIP <- #HLT | |
rotate_and_print_digit: | |
; Rotate RES 4 times to the left | |
RES <- LRO <- LRO <- LRO <- LRO <- RES | |
; Add the lower 4 bits to the address of | |
; hex_chars and print the character | |
ALX <- RES | |
ALY <- #$000F | |
ALX <- AND | |
ALY <- #hex_chars | |
PRN <- *SUM | |
; Return to the caller | |
NIP <- PIP | |
hex_chars: | |
"0123456789ABCDEF" | |
counter: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment