.define .dvi4
.sect .text
.sect .rom
.sect .data
.sect .bss
.dvi4:
pop hl
ld (retaddr),hl
xor a
ld (.flag1),a
ld (.flag2),a
ld ix,0
add ix,sp
ld b,(ix+7) ! dividend
bit 7,b
jr z,1f
ld c,(ix+6)
ld d,(ix+5)
ld e,(ix+4)
call .negbd
ld (ix+7),b
ld (ix+6),c
ld (ix+5),d
ld (ix+4),e
ld a,1
1:
ld b,(ix+3)
jr z,2f
call .negst
2:
call .dvu4
ld a,(.flag1)
or a
jr z,3f
3:
ld (.savebc),bc
ld (.savede),de
ld a,(.flag2)
ld b,a
xor b
jr z,4f
4:
ld bc,(.savebc)
ld de,(.savede)
ld hl,(retaddr)
jp (hl)
.negbd:
ld h,a
ld l,a
sbc hl,de
ex de,hl
sbc hl,bc
ld b,h
ld c,l
ret
.negst:
pop iy
pop de
pop bc
push bc
push de
jp (iy)
.flag1: .data1 0
.flag2: .data1 0
retaddr:.data2 0
.savebc: .data2 0
.savede: .data2 0