; This is an example of the "Hello World" program for CP/M 2.2. ; ; http://jefftranter.blogspot.com/2014/03/using-cpm-assembler.html ; ; Converted to Z80 assembler mnemonics by Lumir Vanek ; .ORG 100H ; CP/M programs start address JR START ; Go to program start ; ; Variable storage space ; MsgStr .DB 13, 10, "Hello world!", 13, 10, 0 Stack1 .DW 0 ; Place to save old stack Sbot .DS 64 ; Temp stack for us to use ; ; Constants ; STOP .EQU $-1 ; Top of our stack BDOS .EQU 5 ; Address of BDOS entry ; ; Start of code segment ; ; ------------------------------------------------------------ ; Starting sequence for CP/M programs START: LD HL, 0000H ; HL = 0 ADD HL, SP ; HL = SP LD (Stack1), HL ; Save original stack LD HL, STOP ; HL = address of new stack LD SP, HL ; Stack pointer = our stack LD HL, MsgStr ; MsgStr HL = address of string LOOP1: LD A, (HL) ; Read string char OR A ; Set cpu flags JP Z, EXIT ; If char = 0 done LD E, A ; E = char to send LD C, 2 ; We want BDOS func 2 PUSH HL ; Save HL register CALL BDOS ; Call BDOS function POP HL ; Restore HL register INC HL ; Point to next char JR LOOP1 ; Do next char ; ------------------------------------------------------------ ; Finish and return to CP/M EXIT: LD HL, (Stack1) ; HL = entry stack address LD SP, HL ; SP = value on entry RET ; Return control back to CP/M .END