A86: How do you get the value in OP1 into a register?
[Prev][Next][Index][Thread]
A86: How do you get the value in OP1 into a register?
I have been trying to port this TI-BASIC program that I made into
assembly because it runs SOOO slow. Here is the program:
:ClDrw:FnOff
:PlOff :AxesOff
:Goto start
:Lbl plot
:PxOn(iPart (64-Y*64),x)
:Goto A
:Lbl start
:For(x,0,127)
:2.5+(x/84)->X
:0.5->Y
:For(N,0,150)
:X*Y(1-Y)->Y
:If N>100
:Goto plot
:Lbl A
:End
:End
Anyways, I was trying to convert this into assembly and I ran into a
problem. I'll show the source before attempting to explain my problem.
It's kind of long so please, just stay with me.
#include "ti86asm.inc"
#include "Ti86math.inc"
#include "TI86ops.inc"
.org _asm_exec_ram
call _clrLCD
ld e,0 ;e = x counter and x coordinate of
screen
XLOOP:
ld a,e ;2.5+(x/84), OP1=x
call _SetXXOP1
ld a,84 ;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 c,0 ;c = iteration counter
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,c
ld b,100 ;if c>100 goto PLOT
cp b
jr nc, Plot
Return:
inc c
ld a,c
ld b,150 ;if c>150 next x
cp b
jr nz, CALC
inc e ;increment x counter
ld a,e
ld b,128
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
Plot:
call _OP6TOOP1 ;OP1=y
ld a,64
call _SetXXOP2 ;OP2=64
call _FPMULT ;OP1=y*64
call _OP1TOOP2 ;OP2=OP1
call _SetXXOP1 ;OP1=64
call _FPSUB ;OP1=64-y*64
call _INTGR ;get integer value of OP1
;what do I need to put in order to get d to equal the value in OP1
ld d,0 ;this line is here because I just wanted
to test and see if the rest worked
call FindPixel
or (hl)
ld (hl), a
jr Return
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
Okay, now back to the problems. As I put in the comments, I don't know
how to get the value in OP1 into the d register so that the findpixel
routine can run. Also, when I ran the above code I got an overflow
error. Any ideas why? Also, since I'm just a beginning asm programmer
(thanks Matt for your very helpful page) any other errors that you could
find and help me out with would be greatly appreciated. Thanks.
--Blake Johnson
Follow-Ups: