0 Members and 1 Guest are viewing this topic.
ld DE,ADDRESSOFFIRSTOPREG+ ld HL,ADDRESSOFSECONDOPREG+ ld b,8Loop: ld a,(de) cp (hl) jr nz,SomethingHappened djnz Loop retSomethingHappened:;carry=(DE)<(HL);your code here ret
bcall(_convop1) push de ;move other value to Op1 bcall(_convop1) pop hl or a sbc hl,de ;carry if second value was greater than first convOp1 value ;insert your code here ret
;arguments are assumed to be in place already ld a,FUNCTION bcall(_BinOPExec); Op1 will contain the result of the operation. If you use something; like OPEq, OPGt, or OPLt, you'll get 0 for false or 1 for true.; You can then use ConvOP1 to reduce that to register A then compare it.
There are several ways of going about doing this, and very few of them actually use the CP instruction, since that only works between two one byte values, whereas an OP "register" is a memory construct and is not directly supported by the CPU (meaning you have to do this in several steps to simulate support, which is what ASM is really about)1. Compare the two OP registers directly by first comparing the exponent. If one is greater than the other, you can stop already. If not, then compare each byte afterwards until something happens. What that something is... is up to you.Code: [Select] ld DE,ADDRESSOFFIRSTOPREG+ ld HL,ADDRESSOFSECONDOPREG+ ld b,8Loop: ld a,(de) cp (hl) jr nz,SomethingHappened djnz Loop retSomethingHappened:;carry=(DE)<(HL);your code here ret
#include "ti83plus.inc".org $9D93 .db $BB,$6Ditem1UserInputLoop: ; label item1UserInputLoop b_call(_GetKey) ; Waits for a key to be pressed CP kUp ; If the up arrow key is pressed, JR Z,Increase ; goto label Increase CP kDown ; If the down arrow key is pressed, JR Z,Decrease ; goto label Decrease CP kEnter ; If the Enter key is pressed, JP Z,DollarsToGallionsResults ; goto label DollarsToGallionsResults. JR item1UserInputLoop ; Else, loop back to ; label item1UserInputLoopIncrease: ; label Increase LD HL,DollarsValue b_call(_Mov9ToOP1) LD A,DollarsValue CP 255 ; If Register A=255, JR Z,item1UserInputLoop ; goto label item1UserInputLoop LD HL,DollarsValueChange b_call(_Mov9ToOP2) b_call(_FPAdd) LD HL,OP1 LD DE,DollarsValue LD BC,9 LDIR JR item1UserInputDisplay ; goto label item1UserInputDisplayDecrease: ; label Decrease LD HL,DollarsValue b_call(_Mov9ToOP1) LD DE,ZeroDecreaseLoop: LD A,(DE) CP (HL) JR Z,item1UserInputLoopContinueDecrease: LD HL,DollarsValueChange b_call(_Mov9ToOP2) b_call(_FPSub) LD HL,OP1 LD DE,DollarsValue LD BC,9 LDIRitem1UserInputDisplay: ; label item1UserInputDisplay LD A,16 LD (penRow),A LD A,44 LD (penCol),A LD A,$F3 b_call(_VPutMap) LD A,30 LD (penRow),A LD A,44 LD (penCol),A LD A,$07 b_call(_VPutMap) LD A,23 ; 23->Register A LD (penRow),A ; Register A->(penRow) LD A,45 ; 45->Register A LD (penCol),A ; Register A->(penCol) LD HL,DollarsValue b_call(_Mov9ToOP1) LD A,6 b_call(_DispOP1A) JP item1UserInputLoop ; goto label item1UserInputLoopDollarsToGallionsResults: RET;---------Variables-----------DollarsValue: .db $00,$80,$00,$00,$00,$00,$00,$00,$00Zero: .db $00,$80,$00,$00,$00,$00,$00,$00,$00DollarsValueChange: .db $00,$80,$10,$00,$00,$00,$00,$00,$00DollarRateInGallions: .db $00,$7E,$99,$30,$48,$65,$93,$84,$31GallionsValue: .db 0,0SicklesValue: .db 0KnutsValue: .db 0GallionRateInDollars: .db $00,$81,$10,$07,$00,$00,$00,$00,$00SickleRateInDollars: .db $00,$7F,$59,$00,$00,$00,$00,$00,$00KnutRateInDollars: .db $00,$7E,$20,$00,$00,$00,$00,$00,$00;------------Data-------------txtSelect1UserInputDS: ; label txtSelect1UserInputDS .db $F2," ",0 ; TI's ASCII: $F2=$.endEND