Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: c4ooo on March 20, 2017, 11:47:20 pm
-
How do I shift a block of data down a nibble? IIRC there was an instruction that swapped nibbles or something that made this easy. The shifted data will never be >256 bytes long.
Posted on omni since it seems that all the monochrome z80 programmers have remained here.
-
Hi @c4ooo,
Can you be a bit more specific? AFAICT a nibble is just a set of 4 bits glued together; why don't you just shift-right by a constant of multiple of 4, or do you something else on your mind/question?
-
The relevant instruction is RRD, it's not very fast but it seems like nothing is ever fast on z80..
You can do something like
xor a
_shiftloop:
rrd
dec hl
djnz _shiftloop
Maybe inc hl, depends on the endianness of your buffer.
-
Hi @c4ooo,
Can you be a bit more specific? AFAICT a nibble is just a set of 4 bits glued together; why don't you just shift-right by a constant of multiple of 4, or do you something else on your mind/question?
I need to shift the buffer down/up a nibble (4 bits). So something like 0xABCD -> 0x0ABCD0
The relevant instruction is RRD, it's not very fast but it seems like nothing is ever fast on z80..
You can do something like
xor a
_shiftloop:
rrd
dec hl
djnz _shiftloop
Maybe inc hl, depends on the endianness of your buffer.
Thanks, will investigate later.
-
harold's method is essentially what I did to shift the screen left or right by multiples of 4. It's slow, but faster than shifting by 1 four times.