Skip to navigation

Lander on the Acorn Archimedes

Score bar: PrintHexDigit

Name: PrintHexDigit [Show more] Type: Subroutine Category: Score bar Summary: An unused routine that prints a single digit hexadecimal number in the score bar Deep dive: Unused code in Lander
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * PrintHexNumber calls PrintHexDigit

Arguments: R0 The number to print (only the low nibble is printed, the rest of the number is ignored)
.PrintHexDigit AND R0, R0, #&F \ Extract the low nibble from the number in \ R0 CMP R0, #&A \ If the low nibble in R0 >= &A then the hex ADDHS R0, R0, #&37 \ digit is A to F, so add &37 to get the \ corresponding hex digit (so this converts \ &A into ASCII &37 + &A = &41, which gives \ us "A", the hex digit we want) ADDLO R0, R0, #&30 \ Otherwise the low nibble in R0 is 0 to 9, \ so add the ASCII value of "0" (ASCII &30) \ to get the corresponding hex digit SWI OS_WriteC \ Print the character in R0 MOV PC, R14 \ Return from the subroutine