
Сообщение от
Titus
Поменяй x и y местами, и круг нарисованный для горизонтальной заливки станет кругом нарисованным для вертикальной заливки)
да разницы никакой тащемта.Я рисую в памяти, по идее картинка должна зациклиться на рамки по 31 пикселя, а по Х процедура почему-то не работает..
Код:
plot:
push bc
ld a,e:and 7:ld c,a,b,bw/256
ld a,e:and %11111000
rra:rra:rra
and 31
ld l,a
ld a,d
or $C0
ld h,a
ld a,(bc):or (hl):ld (hl),a
pop bc
ret
---------- Post added at 09:59 ---------- Previous post was at 09:40 ----------
а, всё разобрался. теперь вопрос о делении 16бит/16бит.
http://www.retroarchive.org/cpm/cdro...23/MATHLIB.Z80
Код:
;-------------------------------------------------------
;
DIVIDE: ;16 Bit by 16 Bit Integer Division
;
; dividend (BC)
; result (BC) = --------------- + remainder (HL)
; divisor (DE)
;
; The dividend is in BC, and the result returns in BC
; The divisor is in DE
; After the division HL contains the remainder
;
; The divisor is successively subtracted from the high
; order bits of the dividend. After each subtraction
; the result is used instead of the initial dividend
; The result is increased by 1 each time.
; When the result of the subtraction is negative the
; partial result is restored by adding the divisor
; back to it.
; The result is simulataneously decremented by 1
;
;First check if divisor is 0
LD A,D
OR E
JR Z,DIVIDE.BY.ZERO
; Dividend is in BC
;clear result
LD HL,0
;loop counter
LD A,16 ;DO NOT TRUNCATE
;
;Rotate Dividend left
;Carry has been zeroed by the OR E above
ZZDIV1: RL C ;Carry -> LSBit, MSBit -> Carry
RL B ;ditto
;Rotate Remainder left
ADC HL,HL ;Never sets carry,
; ie RESETS carry
;Trial subtraction of divisor from result
SBC HL,DE ;Carry -> 0 if no borrow
;Carry -> 1 if borrow
JR NC,ZZPOS
;otherwise negative
ADD HL,DE ;Restore dividend
ZZPOS: CCF ;Calc Result Bit, Z80 carry peculiar
DEC A ;Loop counter
JR NZ,ZZDIV1 ;Loop for 16 Bits
;
RL C ;Shift in last result bit
RL B
; The result is in BC, the remainder in HL
;
RET ; ***** DONE ****
;
DIVIDE.BY.ZERO: LD BC,0FFFFH ;Infinity
; Output a diagnostic message if desired
RET
;
в другом источнике есть беззнаковое деление:
http://baze.au.com/misc/z80bits.html#2.3
Код:
2.3 Restoring 16-bit / 16-bit Unsigned
Input: A:C = Dividend, DE = Divisor, HL = 0
Output: A:C = Quotient, HL = Remainder
slia c ; unroll 16 times
rla ; ...
adc hl,hl ; ...
sbc hl,de ; ...
jr nc,$+4 ; ...
add hl,de ; ...
dec c ; ...
We can use the forementioned trick with complementing the result also here but it's not that obvious how removed DEC C balances against additional overhead. In any case, this routine doesn't contain any "undocumented" instructions and might be preferable (?) for that reason.
простите моё невежество, но в чем разница?