Just wondering ...
Does anyone have ever found a useful utilization of the RLD and RRD instructions ?
Login or register to post comments
Just wondering ...
Does anyone have ever found a useful utilization of the RLD and RRD instructions ?
Hmm...
PRINTMEM: ; Input: HL=Address ; Output HEX(HL) -> SCREEN xor a rld call .Nibble .Nibble: push af daa add a,F0h adc a,40h call A2h ; prints ASCII character in A pop af rld ret
...maybe useful also while manipulating SCREEN 5/7 data.
Indeed !
Thanks Nyyrikki !
; HL = pointer to hex output buffer (upper case ASCII) ; A = binary number to convert Bin2Hex: ld b,a rrca rrca rrca rrca and 0Fh ; These instructions are the important ones cp 10 ; sbc a,69h ; daa ; ld (hl),a inc hl ld a,b and 0Fh cp 10 sbc a,69h daa ld (hl),a ret
Also quite useful when processing BCD...
; #1 = pointer to BCD string
; #2 = length of BCD string
; #3 = name of processing function
%macro ProcessBCD %n, %n, %s
ld hl,#1
ld b,#2
ld a,30h
.#loop:
rld
%% #3
rld
%% #3
rld
inc hl
djnz .#loop
%endmacro
And then for example
%macro VRAM_OUT
out [98h],a
%endmacro
ProcessBCD score, 4, "VRAM_OUT"
Just some tniASM v1.0 template programming :)
Don't you have an account yet? Become an MSX-friend and register an account!
