Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,49 @@
org 100h
lxi h,obuf ; HL = output buffer
mvi b,2 ; B = police
pol: mvi c,1 ; C = sanitation
san: mvi d,1 ; D = fire
fire: mov a,b ; Fire equal to police?
cmp d
jz next ; If so, invalid combination
mov a,c ; Fire equal to sanitation?
cmp d
jz next ; If so, invalid combination
mov a,b ; Total equal to 12?
add c
add d
cpi 12
jnz next ; If not, invalid combination
mov a,b ; Combination is valid, add to output
call num
mov a,c
call num
mov a,d
call num
mvi m,13 ; Add a newline to the output
inx h
mvi m,10
inx h
next: mvi a,7 ; Load 7 to compare to
inr d ; Next fire number
cmp d ; Reached the end?
jnc fire ; If not, next fire number
inr c ; Otherwise, next sanitation number
cmp c ; Reached the end?
jnc san ; If not, next sanitation number
inr b ; Increment police number twice
inr b ; (twice, because it must be even)
cmp b ; Reached the end?
jnc pol ; If not, next police number
mvi m,'$' ; If so, we're done - add CP/M string terminator
mvi c,9 ; Print the output string
lxi d,ohdr
jmp 5
num: adi '0' ; Add number A and space to the output
mov m,a
inx h
mvi m,' '
inx h
ret
ohdr: db 'P S F',13,10
obuf: equ $ ; Output buffer goes after program