; BDOS function0304 test
;2012/3/29 8/25
;
ORG $0100
FCALL=$0005
SINBF=$0300
;
;
;sousin
;
LD HL,MSG
LOOP:LD A,(HL)
CP 24;$
JP Z,END
CALL SOUT
INC HL
JP LOOP
END:LD DE,MSG
LD C,09
CALL FCALL
;jusin
LD HL,SINBF
LD B,00
LOOP2:CALL SIN
CP 05
JP C,ERR
CP 0A
JP Z,MSGOUT
LD A,B
OR A
JP NZ,LOOP2
;
MSGOUT:LD HL,SINBF
LOOP3:LD A,(HL)
CALL ADP
NEXT:INC HL
DEC B
JP NZ,LOOP3
RET
;
ERR:LD DE,ERRT
PUSH AF
LD C,09
CALL FCALL
POP AF
CALL B2HEXDP
RET
;
SOUT:PUSH HL
LD E,A
LD C,04
CALL FCALL
POP HL
RET
;
SIN:PUSH HL
PUSH BC
LD C,03
CALL FCALL
POP BC
POP HL
LD (HL),A
INC HL
INC B
RET
;
MSG:"Hell"
"o"
DB 2C;','
"How "
"are "
"you"
DB 3F;'?'
DB 0D
DB 0A
DB 24;$
;
ERRT:"ERR "
DB 24;'$'
;
;CL & LF
CRLF:LD A,0D
CALL ADP
LD A,0A
JP ADP
;space disp
SPDP:LD A,20
;A disp
ADP:PUSH BC
PUSH HL
LD E,A
LD C,02
CALL FCALL
POP HL
POP BC
RET
;HL(bynary 2bytes) to asckii 4bytes & disp
HEX4DP:PUSH BC
PUSH HL
CALL B2HEX4;binary 2 bytes to ascii HEX 4bytes
PUSH DE
EX DE,HL
CALL DEDP
POP DE
CALL DEDP
POP HL
POP BC
RET
;A(binary) to asckii 2bytes HEX & disp
B2HEXDP:PUSH BC
PUSH HL
CALL B2HEX2
CALL DEDP
POP HL
POP BC
RET
;
;DE(asckii 2bytes) disp
DEDP:PUSH DE
LD E,D
LD C,02
CALL FCALL
POP DE
LD C,02
CALL FCALL
RET
;
;binary to hex, 2bytes data to ascii 4charactors,HL to HL,DE
B2HEX4:LD A,H
CALL B2HEX2
EX DE,HL
LD A,E
;binary to hex, 1byte data to ascii 2charactors,A to DE
B2HEX2:PUSH AF
RRCA
RRCA
RRCA
RRCA
CALL B2HEX1
LD D,A
POP AF
CALL B2HEX1
LD E,A
RET
;binary to hex, low 4bit to ascii 1charactor
B2HEX1:AND 0F
ADD A,30
CP 3A
RET C;0-9
ADD A,07;A-F
RET
;
STRIN:"in"
DB 3A;:
DB 24;$
;
|