; printstring.asm ; ; This is a simple demonstration routine for the emulator to take a null terminated string from RAM ; and display it out to the emulators text printer. ; The routine takes a simple argument on the stack with the address of the string. ; The routine will use the DISPLAY variable set in .data ; ; Version: 0.2.1 GLOBAL START GLOBAL PRINTSTRING SECTION .text START: LDAB MYSTRING ; Put string address into AB PHAB ; and push to the stack JSR PRINTSTRING ; Call PRINTSTRING routine SECTION .printstring PRINTSTRING: PLAB PHAB ; Get the address of the string LDA $DISPLAY ; Set the output address PHA LDAB $DISPLAY+1 ; Set the output address PHAB PRINTLOOP: LDAB CD CMP A,B BEQ RETURN ; If we pull a 0, or null then we are done STAL [SP] ADD C,$1 ; Increment our string location by 1 BCS ROLLOVER ; If it rolls over we need to go handle high byte PLAB ADD A,$1 ; Icrement our output by 1 PHAB JMP PRINTLOOP ; Loop back and keep reading in the string ROLLOVER: ADD D, $1 PLAB ADD B, $1 PHAB JMP PRINTLOOP ; Loop back and keep reading in the string RETURN: PLAB ; To return we need to clean up our stack use first PLA RTS SECTION .data DISPLAY equ D00000h MYSTRING DB "Welcome to the MatCat 8SA1 Computer Simulator!\n\nThis is a full hardware simulation of the computer to allow for easy development testing. It is currently a heavy work in progress as it is very early alpha, so check back often for new features!\n\n\nThis demo can be seen in the examples folder on the git page at: \nhttps://mygit.space/MatCat.OpenSource/8SA1Sim", 0