RPL beginner
|
11-02-2021, 10:51 AM
Post: #4
|
|||
|
|||
RE: RPL beginner
Welcome to the world of System RPL programming! There are usually meaningful rewards to be had over standard (User) RPL programs, but the "price to pay" for these rewards is in understanding the more type-specific nature of the commands and the structures provided.
Looking at your program, several things stood out that may need consideration. I'll mention a few here that may help you. 1) Start all System RPL programs with one of the "check" commands. It sets the stage for how the error-handling system in the calculator should attempt to repair the initial stack objects if/when an error occurs in your code. Not all System RPL errors are recoverable, but this is the minimum you should do and it's a good habit to always include this in every System RPL program. In your case, there are no arguments needed by the program. So you should start with CK0NOLASTWD. 2) The GROB you create at the beginning of the program is blank, and you are then displaying it in the blank text display (which was cleared with RECLAIMDISP). This doesn't create a problem, but it serves no particular purpose. I've left that code out of my example since it doesn't contribute to the outcome here. I've also not included the LAMs that aren't used in this example in an effort to reduce distractions. 3) As was pointed out by David Hayden, you may as well just initialize the LAMs you create with their default values. That saves you the trouble of having to assign the initial values later as a separate step. 4) You've set up your indefinite loop to use a keypress as an exit condition. This is a good way to experiment with something like this, and I would suggest extending it one step further: also check for the user pressing the ON (CANCEL) key. This is a natural and intuitive exit case, and requires very little extra code to support it. Also, you don't really need to do anything with the keys which are pressed, so you should probably just ignore them instead of bringing the values to the stack. My example shows one way to do this. 5) Finally, the "check condition" that you are asking about. I've shown one way of doing this in my example, but there's more to it than is obvious in the code. While I believe the code I've provided does what you are suggesting, BINTs are actually not signed values. The reason this works is more a consequence of what happens naturally if you add two unsigned values where the carry would extend through all of the initial (high-order) bits. MINUSONE is defined (in hex notation) as FFFFF. But as a BINT, that actually has a value of (decimal) 1048575 instead of -1. Try the following program to see what I mean: Code: :: I hope this will give you a good start for further experimentation. Code: :: |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
RPL beginner - dwesti - 10-30-2021, 07:23 PM
RE: RPL beginner - David Hayden - 11-01-2021, 02:11 PM
RE: RPL beginner - dwesti - 11-01-2021, 04:40 PM
RE: RPL beginner - DavidM - 11-02-2021 10:51 AM
RE: RPL beginner - dwesti - 11-02-2021, 02:18 PM
RE: RPL beginner - dwesti - 11-02-2021, 05:20 PM
RE: RPL beginner - DavidM - 11-04-2021, 01:07 AM
RE: RPL beginner - dwesti - 11-04-2021, 09:21 AM
RE: RPL beginner - DavidM - 11-04-2021, 09:49 AM
RE: RPL beginner - dwesti - 11-04-2021, 04:04 PM
RE: RPL beginner - DavidM - 11-05-2021, 10:12 AM
RE: RPL beginner - dwesti - 11-06-2021, 06:41 PM
RE: RPL beginner - DavidM - 11-07-2021, 01:38 PM
RE: RPL beginner - dwesti - 11-08-2021, 05:40 PM
RE: RPL beginner - DavidM - 11-11-2021, 02:33 AM
RE: RPL beginner - dlidstrom - 11-13-2021, 08:04 PM
RE: RPL beginner - BINUBALL - 11-14-2021, 02:06 AM
RE: RPL beginner - DavidM - 11-14-2021, 12:49 PM
|
User(s) browsing this thread: 2 Guest(s)