;Evaluate token from operator stack routines include "settings.inc" include "ti83plus.inc" include "equates.inc" SEGMENT Main GLOBALS ON EXTERN GetOPSByte,PushByteOPS,PeekOPSByteFromWord,errSyntax,PeekOPSByte,FindSymNoArc,errDataType,GetByteMaybeDelimiter,GetNextParseByte MaybePushMultiplyOperator: ld a,82h bit numOP1,(iy+ParsFlag2) ret z EvaluateOPSToken: ei ld d,a cp 0F4h jr nc,$F cp 0F2h jr c,$F xor a $$: and 0F0h ld e,a call PeekOPSByte or a jr nz,evaluateToken ld a,d or a ret z bit numOP1,(iy+ParsFlag2) jr nz,$F evalErrSyntax: B_JUMP ErrSyntax $$: cp 0F4h jr nc,$F cp 0F2h ret nc $$: cp 5 jr nc,$F ld a,d cp 4 ret c PUSHNUM: ld a,11h cp d jr z,evalErrSyntax push de B_CALL PushOP1 PUSHNUMFINISH: res 0,(iy+7) pop af jr PushByteOPS $$: cp 12h jr c,evalErrSyntax cp 2Bh jr z,evalErrSyntax jr PUSHNUM evaluateToken: ld b,a cp 4 jr z,evalErrSyntax bit numOP1,(iy+ParsFlag2) jr nz,$F cp 6 jr nz,evalErrSyntax ld a,d cp 8 jr nc,evalErrSyntax $$: ld a,d cp 2Bh jr nz,Dnot2Bh ld a,b cp 2Bh jr nz,Bnot2Bh call PeekOPSByteFromWord cp 10h jr nz,PUSHNUM inc hl ld a,(hl) cp 1 jr z,PUSHNUM B_JUMP ErrSyntax Bnot2Bh: cp 2Ah jr c,PUSHNUM call CheckGraphCommand jr nc,PUSHNUM jr startEvaluation Dnot2Bh: cp 7 jr z,$F cp 9 jr nz,checkAgain $$: ld a,b cp 10h jr c,checkAgain cp 2Ah jr c,errSyntax checkAgain: ld a,b call CheckGraphCommand jr c,$F ld c,a ld a,28h evalcpe: cp e ld a,c jr maybePUSHNUM $$: cp 89h jr c,$F cp 93h jr nc,$F ld c,a ld a,0C2h jr evalcpe $$: cp e maybePUSHNUM: jr c,PUSHNUM startEvaluation: ld e,b push de call GetOPSByte ld hl,(numArguments) call CheckGraphCommand jr nc,doEval cp 89h jr c,$F cp 93h jr c,doEval $$: cp 3Ch jr c,doEval cp 0A1h jr c,$F cp 0E0h jr c,doEval $$: inc hl doEval: call DoCommand pop de ld a,d cp 11h jr nz,EvaluateOPSToken ld a,e cp 2Bh ret c call CheckGraphCommand ret nc ld a,d jr EvaluateOPSToken CheckGraphCommand: cp 96h jr c,$F cp 9Fh ccf ret nc $$: cp 9Fh jr nz,$F scf ccf ret $$: cp 0ABh ret z cp 84h ret c cp 93h ccf ret nc cp 0B1h ret c cp 0F0h ccf ret DoCommand: cp 8 jr z,leftCurlyBrace rlc h jr z,$F B_JUMP ErrArgument $$: cp 6 jr z,LBrackEncountered cp 1 jr z,passedOPS1 cp 10h jr z,LParenthEncountered cp 29h jr z,0 ;TODO: FIX THIS cp 2Bh jr z,isComma cp 84h jr c,$F cp 89h jr nc,$F call DoFinanceStuff jr doCommandDone $$: ld b,a ld a,1 bit 1,(iy+36h) jr z,$F ;call parser hook jr nz,doCommandDone $$: ld a,b dec l jr z,execUnaryOperator dec l jr z,execBinaryOperator dec l jr z,execTrinaryOperator dec l jr z,execQuadOperator dec l jr z,$F B_JUMP ErrArgument $$: B_CALL FiveExec doCommandDone: B_CALL CkValidNum call ValidateList set 0,(iy+6) ld hl,1 ld (numArguments),hl ret execUnaryOperator: B_CALL UnOPExec jr doCommandDone execBinaryOperator: B_CALL BinOPExec jr doCommandDone execTrinaryOperator: B_CALL ThreeExec jr doCommandDone execQuadOperator: B_CALL FourExec jr doCommandDone isComma: ld hl,(numArguments) inc hl ld (numArguments),hl call PeekOPSByte cp 2Bh ret nz call GetOPSByte jr isComma errDimension: B_JUMP ErrDimension DoFinanceStuff: ;TODO: FIX THIS ret ValidateList: ld b,1 ValidateListB: bit 0,(iy+2) jr nz,$F bit 1,(iy+graphFlags) ret z $$: bit grfRecurM,(iy+grfModeFlags) ret nz ld hl,(9665h) ld a,h or l ret nz ld a,(OP1) and 1Fh B_CALL IS_A_LSTorCLST ret nz rlc b jr z,$F call FindSymNoArc ld (chkDelPtr1),de ld (chkDelPtr3),hl $$: ld a,(OP1+1) cp 24h jr nz,$F ld hl,(chkDelPtr3) set 7,(hl) $$: ld hl,(chkDelPtr1) ld e,(hl) inc hl ld d,(hl) ld a,d or e jr z,errDimension ld a,(cxCurApp) cp 4Ah jr nz,not_table_editor bit vertSplit,(iy+sGrFlags) jr z,not_split bit 3,(iy+1Fh) jr z,not_split jr $F not_table_editor: bit 2,(iy+1Fh) jr nz,not_split bit 6,(iy+15h) jr nz,not_split $$: ld hl,(9810h) ld a,h or l jr nz,$F ld (9810h),de bit 0,(iy+2) jr z,validateListContinue bit 5,(iy+3) jr z,not_split ld (980Eh),de jr not_split $$: or a sbc hl,de jr z,validateListContinue B_CALL ErrDimMismatch validateListContinue: bit 1,(iy+graphFlags) jr z,not_split bit 0,(iy+2) jr nz,not_split ld hl,(980Eh) or a sbc hl,de push af ld a,(curGX2) ld hl,(980Ch) ld de,18 add hl,de B_CALL isInSet ld b,a pop af ld a,b jr nc,$F or (hl) ld (hl),a not_split: ld de,(chkDelPtr1) ld hl,(980Eh) B_CALL GetLToOP1 ret $$: push af cpl and (hl) ld (hl),a pop af jr z,not_split B_JUMP ErrOverflow LParenthEncountered: push hl call PeekOPSByte cp 1 pop hl jr z,encounteredOPS1 dec l jr nz,LBrackEncountered set 0,(iy+6) ld hl,1 ld (numArguments),hl ret LBrackEncountered: bit 6,(iy+6) jr z,doMatrixCopy bit numOP1,(iy+ParsFlag2) jr z,errSyntax res 6,(iy+6) push hl rst 18h pop bc ld a,(9663h) or a jr nz,$F ld a,c ld (9663h),a $$: cp c jr nz,errDimension bit 7,(iy+6) jr z,errSyntax res 0,(iy+7) ld a,7 jr LBrackDone doMatrixCopy: bit numOP1,(iy+ParsFlag2) jr nz,errSyntax res 7,(iy+6) ld hl,(9663h) B_CALL CreateTempRMat call CopyMatrixData B_CALL OP4ToOP1 ld a,7 set 0,(iy+7) LBrackDone: ld hl,1 ld (numArguments),hl pop de pop de cp d ret z ld a,d jr EvaluateOPSToken encounteredOPS1: call GetOPSByte passedOPS1: pop de pop af or a jr z,$F cp 11h jr nz,errSyntax call GetByteMaybeDelimiter jr z,$F call GetNextParseByte jr errSyntax $$: call GetOPSByte ld b,a ld a,3 bit 1,(iy+36h) jr z,$F ;Call parser hook $$: ld a,b ret nz ld hl,class3CallbackTable ld e,a ld d,0 add hl,de add hl,de B_CALL ldHLind ld a,(numArguments) ;TODO: FIX THIS!!! ; jp (hl) ret leftCurlyBrace: res 5,(iy+6) ld (9663h),hl ld de,1000 or a sbc hl,de jr nc,errDimension B_CALL PushOP1 ld bc,(9663h) call ConfirmBCNumbersOnFPSAreReal ld hl,(9663h) bit 1,(iy+6) jr z,$F B_CALL CREATETCLIST jr listCreated $$: B_CALL CreateTempRList listCreated: ld (chkDelPtr1),de ld (chkDelPtr3),hl call CopyListData B_CALL OP4ToOP1 ld b,0 call ValidateListB ld a,9 set 0,(iy+7) ld hl,1 ld (numArguments),hl pop de pop de cp d ret z ld a,d jr EvaluateOPSToken ConfirmBCNumbersOnFPSAreReal: ld hl,(FPS) ld de,-9 confirmLoop: add hl,de ld a,(hl) and 1Fh jr z,$F cp 0Ch jr z,$F B_JUMP ErrDataType set 1,(iy+6) add hl,de $$: dec bc ld a,b or c jr nz,confirmLoop ret CopyMatrixData: res 1,(iy+6) ld hl,(9663h) push de B_CALL HTimesL pop de push hl ld bc,(9663h) B_CALL AdrMEle pop bc parseMatrixLoop: push bc push hl B_CALL FPOPREAL ld a,(hl) and 1Fh jr nz,is_complex bit 1,(iy+6) jr z,$F rst 20h pop de ld hl,-9 add hl,de ex de,hl push de B_CALL OP2Set0 call MakeOP1Complex pop de call LDIRElement ld hl,-27 jr restartMatrixLoop is_complex: bit 1,(iy+6) jr z,errDataType pop de B_CALL Mov9B ld hl,-18 add hl,de push hl B_CALL FPOPREAL $$: pop de B_CALL Mov9B ld hl,-18 restartMatrixLoop: add hl,de pop bc dec bc ld a,b or c jr nz,parseMatrixLoop ret CopyListData: ld hl,(9663h) B_CALL AdrLEle ld bc,(9663h) bit 1,(iy+6) jr z,parseMatrixLoop ld de,9 add hl,de jr parseMatrixLoop MakeOP1Complex: ld a,(OP1) and 0E0h or 0Ch ld (OP1),a ld a,(OP2) and 0E0h or 0Ch ld (OP2),a ret LDIRElement: B_CALL MovFrOP1 inc hl inc hl B_CALL Mov9B ret class3CallbackTable: DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h DW 0000h