;*****************************************************************
; generic routines for assembly programs
; assemble using m80 and l80 (supersub zasm myfile)

; no dots in front of equ and org etc (this is
; different to tasm). For writing purely on a
; n8vem (eg wordstar) and compiling on the board
; or can write in notepad and
; then transfer to the board and compile there.

	.z80

fdos	equ	0005H	; common entry point for bios and bdos


; ********************* Main ***************
; org 100h is not needed for .mac files

	ld hl,test_text
	call printf
	ret		; back to cp/m

;******************************************
; write console - function 2 of bios. Character in DE
write_console:
	ld c,2		; function number
	call fdos
	ret
;******************************************
printf:
	ld	a,(hl)		; character in a
	cp	0FFH		; end byte?
	jp	z,printf1	; jump if end byte is found
	ld 	e,a		; character to E
	push 	hl		; preserve hl counter
	call write_console	; print character
	pop 	hl		; restore the counter
	inc	hl		; increment pointer
	jp	printf		; loop
printf1:
	ret
;******************************************

;*** data ***

test_text:	db	"Hello world",0FFH


; ***********
	end
; end of program