Once again, the last page was getting a bit too long for my tastes. We're now at "Now can I do what I want?" ;)
I covered everything necessary to write what you wanted to write in the previous page. It is now time to fit every piece into a complete puzzle! :D
The "pieces of the puzzle" that we came up with are *drumroll*:
B_CALL(_RunIndicOff)
and:
set textInverse,(iy+textFlags)
and finally:
B_CALL(_AnsName) ;OP1 = Ans query ready to be looked-up B_CALL(_RclVarSym) ;OP1 = number in Ans ;because Ans always exists, no error is generated ld a,(hl) ;hl points to type byte in VAT - indirectly load it into register a and %00011111 ;mask out the unnecessary bits 5-7 (%00011111 is binary for $1F) cp RealObj ;Is it a Real number? ret nz ;if so, the cp sets the z flag. nz (not zero) means it wasn't a RealObj, and we quit ;We now have OP1 being the number B_CALL(_ConvOP1) ;Convert floating-point OP1 to a byte value in de ;a is Least Significant Byte, which is all we need cp 0 ;Did Ans equal 0 (compare register A with decimal constant 0)? jp z,TurnRIOff ;z means last operation caused some register to equal zero cp 1 ;Ans == 1? jp z,EnableRVideo TurnRIOff: EnableRVideo:
Tada! Nothing new, unsurprisingly. What follows now is the skeleton of a typical nostub assembly program, and it should look familiar. Note that this is what I usually use because it works for me. If you don't like what you see, then feel free to develop your own style of coding - don't be limited by this way or that way. :)
.nolist #include "ti83plus.inc" .list .org userMem-2 .db t2ByteTok,tasmCmp ;code here .end
Finally, putting everything together, we get the final product:
.nolist #include "ti83plus.inc" .list .org userMem-2 .db t2ByteTok,tasmCmp B_CALL(_AnsName) ;OP1 = Ans ready to be looked-up B_CALL(_RclVarSym) ;OP1 = number in Ans ;because Ans always exists, no error is generated ld a,(hl) ;hl points to type byte in VAT - indirectly load it into register a and %00011111 ;mask out the unnecessary bits 5-7 (%00011111 is binary for $1F) cp RealObj ;Is it a Real number? ret nz ;if so, the cp sets the z flag. nz (not zero) means it wasn't a RealObj, and we quit ;We now have OP1 being the number B_CALL(_ConvOP1) ;Convert floating-point OP1 to a byte value in de ;a is Least Significant Byte, which is all we need cp 0 ;Did Ans equal 0 (compare register A with decimal constant 0)? jp z,TurnRIOff ;z means last operation caused some register to equal zero cp 1 ;Ans == 1? jp z,EnableRVideo Quit: ret TurnRIOff: B_CALL(_RunIndicOff) jr Quit EnableRVideo: set textInverse,(iy+textFlags) jr Quit .end
And sure enough, if I run it, I get this:
Nice, eh? :)
We are back once again to the eternal question of size versus speed (and also readability). For one, you could go ahead and use RclAns - that would knock off one B_CALL. Also, you could replace the "jr Quit"s with "ret" if you don't care about readability and want smaller size and faster speed. There is also a way to optimize the cps - you could use dec a instead, but how this technique works I will leave up to you to figure out. :)
Look at this and the previous page and observe how I applied the concepts of transforming a program idea into a functional program. In particular, note how everything is done in "bite-sized" chunks. See anything interesting? It's like taking a history class and being quizzed on a chapter biweekly, culumnating up to a final exam, rather than reading the book, not being quizzed per chapter, and doing the final exam without prior test-question experience. Which is more likely to work? Now do you see anything interesting? If you do, then you're one step closer to entering that elusive mindset of a hacker. :)