ReTach,
nach einigen Ausfluegen in die DOS-Welt und einem kurzen Urlaub hab ich mal wieder Zeit fuer den Z80 gehabt.
Ich habe Eure Anregungen aufgegriffen und umgesetzt und will jetzt mal das Ergebnis praesentieren.
Der Code ist zwar nicht unbedingt kleiner geworden, aber an einigen Stellen doch lesbarer/praegnanter.
; ==========
; USAGE: c <SADDR> <EADDR> <DADDR> = copy bytes from SADDR-EADDR to DADDR
; SADDR = HL
; SIZE = BC
; daddr = DE
monitor_copy:
call monitor_chkspace ; check for SPACE
jp c,monitor_usage
call console_gethex16 ; read addr to
jp c,monitor_usage ; conversion error->usage
push bc ; put saddr to stack
call monitor_chkspace ; check for SPACE
jr c,mc.error1 ; nope -> no parameters?
call console_gethex16 ; read addr to
jr c,mc.error1 ; conversion error->usage
push bc ; put eaddr to stack
call monitor_chkspace ; check for SPACE
jr c,mc.error2 ; nope -> no parameters?
call console_gethex16 ; read addr to
jr c,mc.error2 ; conversion error->usage
ld d,b ; put daddr to DE
ld e,c
pop hl ; get EADDR
pop bc ; get SADDR
push bc
or a ; clear CF
sbc hl,bc ; EADDR-SADDR
ld b,h ; put size to BC
ld c,l
pop hl ; put SADDR to HL
ldir ; copy data
jp monitor ; and exit
mc.error2:
pop bc ; pop second parameter
mc.error1:
pop bc ; pop first parameter
jp monitor_usage
; ==========
; check if current char in (HL) is a SPACE.
; YES
; CF=0
; HL := HL+1
; NO
; CF=1
; return the chart in A
monitor_chkspace:
ld a,(hl) ; load next char
CP SPACE ; check if SPACE
jr nz,mcp.no ; nope
inc hl
scf ; CF=0
ccf
ret
mcp.no:
scf
ret
; ==========
; print memory contents
monitor_print_mem:
call monitor_chkspace ; check for SPACE
jr c,monitor_usage
call console_gethex16 ; read addr to
jr c,monitor_usage ; conversion error->usage
ld d,b ; put addr to DE
ld e,c
call monitor_chkspace ; check for SPACE
jr nc, mpm.read_size ; yep-> try to read size
ld b,8 ; nope->use 8 bytes
jr mpm.print_address
mpm.read_size:
call console_getdez ; read decimal
jr c,monitor_usage ; conversion error->usage
ld b,l ; use lower 8bits of value
mpm.print_address:
ld a,'$' ; print hex marker
call console_putc
ld a,d ; print upper address byte
call console_print_hex
ld a,e ; print lower address byte
call console_print_hex
ld a,':' ; print colon
call console_putc
ld c,9 ; store counter in C
mpm.print_loop:
dec c ; decrement line-counter
jr nz,mpm.next_byte ; not 0 -> print next byte
call console_newline ; print newline
jr mpm.print_address ; and address again
mpm.next_byte:
ld a,' ' ; print SPACE
call console_putc
ld a,(de) ; get byte
inc de ; point to next
call console_print_hex ; print HEX
djnz mpm.print_loop ; decrement counter
call console_newline
jp monitor
Alles anzeigen
Danke nochmal
Ilu