A86: Overflow error


[Prev][Next][Index][Thread]

A86: Overflow error




Well, I think I've figured out how to get the value in OP1 into a register
(please check to make sure that I did it right, though) but I'm still
getting an overflow error.  What is causing the error?  Here is the program:
#include "ti86asm.inc"
#include "Ti86math.inc"
#include "TI86ops.inc"

.org _asm_exec_ram

  call _clrLCD
  ld a,0
  ld (Xcounter),a
XLOOP:
  ld a,(Xcounter)	;2.5+(x/84), OP1=Xcounter
  call _SetXXOP1
  ld a,$54			;OP2=84
  call _SetXXOP2
  call _FPDIV		;OP1=x/84
  ld hl, TWOPT5
  call _MOV10TOOP2	;OP2=2.5
  call _FPADD		;OP1=2.5+(x/84)
  call _OP1TOOP5	;OP5=OP1, OP5 will store X for calculations
  ld hl, PT5		;y = .5
  call _MOV10TOOP2	;OP2=y
  call _OP2TOOP6	;OP6=y
  ld a,0			;reset iteration counter
  ld (Iterations),a
CALC:
  call _OP6TOOP1	;OP1=y
  call _OP2SET1		;OP2=1
  call _FPSUB		;OP1=y-1
  call _OP6TOOP2	;OP2=y
  call _FPMULT		;OP1=y(y-1)
  call _OP5TOOP2	;OP2=x
  call _FPMULT		;OP1=x*y(y-1)
  call _OP1TOOP6	;y now equals new value
  ld a,(Iterations)
  ld b,100			;if Iterations>100 goto Plot
  cp b
  jr nc, Plot
Return:
  ld a,(Iterations)
  inc a
  ld (Iterations),a
  ld b,150			;if Iterations>150 next x
  cp b
  jr nz, CALC
  ld a,(Xcounter)
  inc a				;increment x counter
  ld (Xcounter),a
  ld b,127
  cp b
  jr nz, XLOOP
  call _getkey
  call _clrLCD
  ret


TWOPT5: .db $00, $00, $FC, $25, $00, $00, $00, $00, $00, $00
PT5: .db $00, $FE, $FB, $50, $00, $00, $00, $00, $00, $00
Xcounter: .db 0,0
Iterations: .db 0,0

Plot:
  call _OP6TOOP1		;OP1=y
  ld a,$40
  push af
  call _SetXXOP2		;OP2=64
  call _FPMULT			;OP1=y*64
  call _OP1TOOP2		;OP2=OP1
  pop af
  call _SetXXOP1		;OP1=64
  call _FPSUB			;OP1=64-y*64
  call _INTGR			;get integer value of OP1
  call $5577			;convop1
  ld d,e				;does this put the value I want into d?
  ld a,(Xcounter)
  ld e,a
  call FindPixel
  or (hl)
  ld (hl), a
  jr Return

; Input: D = y
; E = x
; Output: HL= address of byte in video memory

; A = bitmask (bit corresponding to pixel is set)
; C is modified

FindPixel:
  ld hl,FP_Bits
  ld a,e
  and %00000111
  add a,l
  ld l,a
  adc a,h
  sub l
  ld h,a
  ld c,(hl)
  ld hl,FP_RLD
  ld (hl),d
  ld a,e
  rrca
  rrca
  rrca
  rld
  or $FC
  ld l,(hl)
  ld h,a
  ld a,c
  ret

FP_RLD: .db $00
FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01

.end


Thanks for any help that you can provide.  Later!

--Blake Johnson


Follow-Ups: