Last active
December 3, 2019 21:55
-
-
Save mistificator/48297c215296b37033b63da29fb34959 to your computer and use it in GitHub Desktop.
CP/M example that prints command line arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; CP/M example that prints command line arguments | |
.org $100 ; standard CP/M offset | |
ld hl,$0080 ; command line arguments address | |
ld a, (hl) | |
or a | |
ret z | |
inc hl | |
Loop: | |
inc hl | |
ld a, (hl) | |
or a | |
ret z | |
ld e, a | |
ld c, $02 ; routine $02 | |
push hl | |
call $0005 ; call BDOS vector | |
pop hl | |
jr Loop | |
End: | |
ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; CP/M example that prints command line arguments | |
.org $100 ; standard CP/M offset | |
ld hl,$0080 ; command line arguments address | |
ld a,(hl) ; get arguments length | |
or a ; check length | |
ret z ; zero length, exit | |
xor b ; set zero high byte | |
ld c, a ; low byte contains length | |
inc hl ; +1, skip length | |
ld d, h ; copy address | |
ld e, l ; to de | |
add hl,bc ; move to end of string | |
inc de ; +1, skip preceeding space | |
ld (hl), '$' ; change 0 to '$' | |
ld c, $09 ; print string BDOS routine | |
push hl ; store hl | |
call $0005 ; call BDOS vector | |
pop hl ; restore hl | |
xor (hl) ; change '$' back to 0 | |
ret |
Author
mistificator
commented
Dec 2, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment