44 lines
1.8 KiB
NASM
44 lines
1.8 KiB
NASM
; 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.0
|
|
|
|
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
|
|
PLCD
|
|
PHAB ; Get the address of the string ^^^
|
|
LDAB $DISPLAY ; 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
|
|
RTS
|
|
|
|
SECTION .data
|
|
DISPLAY equ 8000h
|
|
MYSTRING DB "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc maximus erat mollis, fermentum quam at, blandit turpis. Pellentesque arcu tortor, smoke weed guam sagittis ac, posuere ut ipsum. Nulla facilisi. Mauris eget urna id sem porttitor consequat ultrices porttitor magna. Quisque condimentum porta viverra. Suspendisse ac condimentum ante. Duis accumsan augue urna, at ultricies nunc accumsan eget. Nullam eleifend.", 0 |