Skip to content

Instantly share code, notes, and snippets.

@bmpc
Created Apr 11, 2021
Embed
What would you like to do?
Hello World - Amstrad ROM with RSX
;--------------------------------------
; Hello World - Amstrad ROM with RSX
;
; By Bruno Conde based on R.A.Waddilove's version (http://www.cantrell.org.uk/david/tech/cpc/CWTA-writing-ROMs-code.html)
;--------------------------------------
ORG &C000
;--------------------------------------
; Reserves 15 bytes for workspace
;--------------------------------------
; ROM Prefix
;--------------------------------------
DEFB 1 ;ROM type ... background
DEFB 1 ;mark 1
DEFB 1 ;version 1
DEFB 1 ;modification 1
;--------------------------------------
; Command table
;--------------------------------------
DEFW name_table
JP initialise_ROM ;power-up/reset entry
JP help ;help screen
JP hello ;print hello world
;--------------------------------------
; Name table
;--------------------------------------
name_table:
DEFB "CWTA RO","M"+&80 ;bad name
DEFB "HEL","P"+&80 ;HELP
DEFB "HELL","O"+&80 ;HELLO
DEFB 0
;---------------------------------------
; Power-up/Reset intialisation
; AF,BC corrupted
;---------------------------------------
initialise_ROM:
PUSH DE
PUSH HL ;save DE/HL
CALL print_string; print power-up message
DEFB "Hello World - Amstrad ROM with RSX"
DEFB 13,10,13,10
DEFB 0
POP HL
POP DE ;restore HL/DE
AND A
LD BC,15
SBC HL,BC ;grab 15 bytes from top of memory
SCF
RET
;--------------------------------------
; General string print subroutine
; AF,HL corrupted
;--------------------------------------
print_string:
POP HL ;get string address
sp_loop:
LD A,(HL)
CALL &BB5A ;print character
INC HL
OR A ;done?
JR NZ,sp_loop
JP (HL)
;---------------------------------------
; HELP
; Print syntax and function of commands
; AF,HL corrupted
;--------------------------------------
help:
CALL print_string
DEFB "Hello World - Amstrad ROM with RSX", 10, 13, 10, 13
DEFB "HELP - list all commands", 10, 13
DEFB "HELLO - prints the hello world", 10, 13
DEFB 0
RET
;--------------------------------------
; HELLO
; prints hello world!
;--------------------------------------
hello:
CALL print_string ;print big character
DEFB "Hello World!", 10, 13, 0
RET
list
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment