Last modified on 13 March 2007, at 02:57

Programming:A simple 'Hello World' program for CP/M using BDOS

Revision as of 02:57, 13 March 2007 by CPCLER (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
;; A simple program to display "Hello World". This program
;; will work with CP/M 2.1 and C/PM +


;; origin for CP/M programs
org &100
nolist
write"cpmex1.com"

;;---------------------------------------------------------
.bdos equ 5

;;---------------------------------------------------------
;; display message and then return back to the command-line

ld hl,message
call display_message
ret

;;---------------------------------------------------------
;; HL = pointer to null terminated message
.display_message
ld a,(hl)				;; get ASCII character
inc hl					;; increment pointer for next character
or a					;; end of message marker (0)?
ret z					;; quit if end of message marker found.

call display_char		;; send character to console output
jp display_message		;; loop for next char

;;---------------------------------------------------------
;; put character to console
;;
;; A = ASCII character

.display_char
push hl
ld c,2			;; console output function id
ld e,a			;; ASCII character
call bdos		;; call BDOS to execute function
pop hl
ret

;;---------------------------------------------------------
;; the message to display

.message
defb "Hello World!",0