Skip to navigation

Lander on the Acorn Archimedes

Score bar: PrintHexNumber

Name: PrintHexNumber [Show more] Type: Subroutine Category: Score bar Summary: An unused routine that prints an 8-digit hexadecimal number on the second character row of the screen Deep dive: Unused code in Lander
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file

Arguments: R1 The number to print
.PrintHexNumber MOV R0, #30 \ Print a VDU 30 command to move the text SWI OS_WriteC \ cursor to the top-left corner of the \ screen MOV R0, #&0A \ Print a line feed (ASCII &0A) to move the SWI OS_WriteC \ cursor down one line, to the start of the \ second line, which is where we print the \ score bar STMFD R13!, {R0-R12, R14} \ Store the registers that we want to use on \ the stack so they can be preserved MOV R0, R1, LSR #28 \ Print the top nibble of the value in R1 BL PrintHexDigit MOV R0, R1, LSR #24 \ Print the next nibble of the value in R1 BL PrintHexDigit MOV R0, R1, LSR #20 \ Print the next nibble of the value in R1 BL PrintHexDigit MOV R0, R1, LSR #16 \ Print the next nibble of the value in R1 BL PrintHexDigit MOV R0, R1, LSR #12 \ Print the next nibble of the value in R1 BL PrintHexDigit MOV R0, R1, LSR #8 \ Print the next nibble of the value in R1 BL PrintHexDigit MOV R0, R1, LSR #4 \ Print the next nibble of the value in R1 BL PrintHexDigit MOV R0, R1 \ Print the bottom nibble of the value in R1 BL PrintHexDigit MOV R0, #&A \ Print a line feed (ASCII &0A) and carriage SWI OS_WriteC \ return (ASCII &0D) to move the cursor down MOV R0, #&D \ to the start of the next line, ready to SWI OS_WriteC \ print further numbers if required LDMFD R13!, {R0-R12, PC} \ Retrieve the registers that we stored on \ the stack and return from the subroutine