2021-04-07 03:54:31 -04:00
; 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
;
2021-04-09 04:39:21 -04:00
; Version: 0.2.1
2021-04-07 03:54:31 -04:00
GLOBAL START
GLOBAL PRINTSTRING
SECTION .text
START: LDAB MYSTRING ; Put string address into AB
PHAB ; and push to the stack
2021-04-12 00:35:51 -04:00
JSR PRINTSTRING ; Call PRINTSTRING routine
2021-04-07 03:54:31 -04:00
SECTION .printstring
PRINTSTRING: PLAB
2021-04-09 04:39:21 -04:00
PHAB ; Get the address of the string
LDA $ DI SP LAY ; Set the output address
PHA
LDAB $ DI SP LAY + 1 ; Set the output address
2021-04-07 03:54:31 -04:00
PHAB
PRINTLOOP: LDAB CD
2021-04-09 04:39:21 -04:00
CMP A , B
2021-04-07 03:54:31 -04:00
BEQ RETURN ; If we pull a 0, or null then we are done
STAL [ SP ]
2021-04-09 04:39:21 -04:00
ADD C , $ 1 ; Increment our string location by 1
2021-04-07 03:54:31 -04:00
BCS ROLLOVER ; If it rolls over we need to go handle high byte
PLAB
2021-04-09 04:39:21 -04:00
ADD A , $ 1 ; Icrement our output by 1
2021-04-07 03:54:31 -04:00
PHAB
JMP PRINTLOOP ; Loop back and keep reading in the string
2021-04-09 04:39:21 -04:00
ROLLOVER: ADD D , $ 1
2021-04-07 03:54:31 -04:00
PLAB
2021-04-09 04:39:21 -04:00
ADD B , $ 1
2021-04-07 03:54:31 -04:00
PHAB
JMP PRINTLOOP ; Loop back and keep reading in the string
RETURN: PLAB ; To return we need to clean up our stack use first
2021-04-09 05:11:29 -04:00
PLA
2021-04-12 00:35:51 -04:00
RTS
2021-04-07 03:54:31 -04:00
SECTION .data
2021-04-09 04:39:21 -04:00
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