From
Alexandr Sinyakov
→
To
All
13 February 2007
Hello Orionsoft
Ori> did I uncomment correctly?
That's almost exactly how it is.
Only here:
┌─- code ───
jr c,lab3 ; if Carry = 1 (set) then the block is skipped, otherwise...
└── code ───
From
Alexandr Sinyakov
→
To
All
13 February 2007
Hello, Orionsoft
А что делать, когда бит=1
Something like thizzz?
┌─- code ───
ld hl,OutPut
ld there,0
exx
ld hl,Input
ld b,35
lab1 ld a,(hl)
ld c,8
lab2 rla
exx
jr c,lab3
ld (hl),e
inc hl
ld (hl),d
inc hl
lab3 inc of
exx
dec c
jr nz,lab2
inc hl
djnz lab1
ret
└── code ───
From
Orionsoft
→
To
All
13 February 2007
Hello, All
which would do the following:
input 35 bytes (280 bits)
The least significant bit is in the 7th bit of the first (of 35) byte
you need a process that:
sequentially iterates through a 280-bit sequence
if the current bit = 0 then write the number (word) of this bit to the output address
data
i.e. if in a 280 bit sequence all the bits are zero, then the output would be b
280 words from zero to 280
:eek; :v2_jawdr:;
From
Orionsoft
→
To
All
13 February 2007
Hello Orionsoft
yes, we also need a procedure that turns the result into the opposite: v2_blink:
From
Orionsoft
→
To
All
13 February 2007
Hello Orionsoft
Did I uncomment correctly?
┌─- CODE ───
ld hl,OutPut
ld de,0 ; bit counter (0-260)
exx
ld hl,Input
ld b,35; byte counter
lab1 ld a,(hl)
ld c,8 ; bit counter in byte
lab2 rla : 7 bits in Carry
exx
jr c,lab3 ; if Carry =0 (set) then
ld(hl),e ; otherwise we write the current bit number to the result
inc hl; +1 result address
ld(hl),d
inc hl ; +1 result address
lab3 inc de ; increase the bit counter
exx
dec c ; reduce 8 bit pass
jr nz,lab2 ; Are there any bits left?
inc hl; moved to the next byte of the sequence
djnz lab1
ret
└── CODE ───
From
Orionsoft
→
To
All
13 February 2007
Hello, SAM style
"Etudes" - they rule! :v2_clapp:
From
Orionsoft
→
To
All
13 February 2007
Hello, SAM style
SAM> What to do when bit=1
SAM> Something like thizzz?
if bit = 1 then nothing, but how will the sequence go and write everything = 1
AAFF for example
From
Orionsoft
→
To
All
13 February 2007
Hello Orionsoft
is there a procedure that does the opposite?
if it's not too much trouble :rolleyes:
From
Alexandr Sinyakov
→
To
All
13 February 2007
Hello Orionsoft
Input - a list of numbers of disabled bytes (in words, 2 bytes each). List
ends with #FFFF.
┌─- code ───
ld hl,Output ; first set all the bits
ld b,35
lab0 ld (hl),#FF
inc hl
djnz lab0
ld hl,Input
lab1 ld e,(hl) ; take the bit number
inc hl
ld d,(hl)
inc hl
ld a,d ; if it is #FFFF - exit
and e
inc a
ret z
push hl
ld a,e ; calculate the mask for this bit
and 7
ld c,#7F
jr z,lab3
lab2 rrc c
dec a
jr nz,lab2
lab3 ld a,d ; calculate the address of the byte in which this bit is located
rra
rr e
rra
rr e
rra
rr e
ld d,0
ld hl,OutPut
add hl,de
ld a,(hl) ; reset the bit
and c
ld(hl),a
pop hl
jr lab1 ; move on to the next number
└── code ───
You can come up with another one, faster, but only if the list is ordered -
from smallest to largest.
From
Orionsoft
→
To
All
13 February 2007
Hello, SAM style
Why I love Spectrum - the kindest platform =)
SAMstyle:v2_cheer: