Saturn ASM question
|
12-28-2017, 03:32 PM
Post: #1
|
|||
|
|||
Saturn ASM question
Hi all,
I've been taking advantage of some time off work between Christmas and the New Year to come to grips with both SysRPL and ASM programming on the HP 50g. My learning material for the latter is the excellent "Introduction to Saturn Assembly Language" by Gilbert Fernandes and Eric Rechlin. I'm basically copy/pasting source code strings from my text editor onto the stack of an emulated HP 50g and running ASM to get executable code. I do have extable installed both on the emulator and on my physical 50g to make things that much easier. My question is, how do I make use of pointers to the built-in real numbers in ASM? I'm (finally...) writing a bunch of archival utilities, including one that tests for the presence of an SD card and returns either 1. or 0. to the stack using code such as this: Code: LC 2F94C % %1 Fairly straightforward. Load the address of %1 ($2F94C on the 49/50) into C, decrement the number of 5-nibble blocks available, decrement the stack pointer and place the address in C on the top of that stack. This code will never run on a 48 so it's not a problem in this instance, however I'd be happier if I could use the symbol defined in extable rather than the literal 2F94C. How do I do that? This is probably just a question of syntax that I haven't yet managed to figure out. "LC %1" is clearly not the way because the "%" sign introduces a comment... Thanks in advance. |
|||
12-28-2017, 03:53 PM
Post: #2
|
|||
|
|||
RE: Saturn ASM question
(12-28-2017 03:32 PM)grsbanks Wrote: I'm (finally...) writing a bunch of archival utilities, including one that tests for the presence of an SD card and returns either 1. or 0. I guess that every user that uses the 50g daily may use them. I personally have to improve my archival utilities (userRPL, userRPL + SDLIB) as well but wouldn't be bad if you share when you get some good results (even alpha works)! (This is valid also for other people. If you working backup programs, please share! I shared mine in the little explorations thread). Wikis are great, Contribute :) |
|||
12-28-2017, 04:32 PM
Post: #3
|
|||
|
|||
RE: Saturn ASM question
The exact syntax may vary depending on how you are compiling your code. I use the Debug4x environment (which in turn uses HP's SASM compiler), and loading a previously defined address constant into C.A inside a MASD code object would look like this:
Code:
The "(5)" specifies the width (in nibbles) of the data to be loaded into C. "=" designates that the constant ID which follows is a global label (as opposed to local). The "%" isn't interpreted here as a comment token by the parser. Also, a word of caution: pushing new stack items in your relocatable Saturn code requires care. In this particular situation, your chance for a problem is remote since about the only thing that could cause a (memory-related) problem is the stack being completely full prior to execution. The more common scenario, though, is that of a TEMPOB allocation occurring as a result of some process. I generally try to allocate "placeholders" at SysRPL-time prior to calling the Saturn code, which then simply updates the placeholder objects as needed (and drops no-longer-needed stack items). |
|||
12-28-2017, 04:51 PM
Post: #4
|
|||
|
|||
RE: Saturn ASM question
Thanks for the reply but nope.
It balks completely on the "(5)" in "LC(5) =%1". If I omit "(5)" and just use "LC =%1" it bails out demanding a HEX expression. Also, I've been doing necessary memory checks before pushing something onto the stack. Bad Things(tm) can happen without that |
|||
12-28-2017, 05:14 PM
Post: #5
|
|||
|
|||
RE: Saturn ASM question
FWIW this is the code so far:
Code: % Do we have room for one more level on the stack? |
|||
12-28-2017, 05:48 PM
Post: #6
|
|||
|
|||
RE: Saturn ASM question
(12-28-2017 04:51 PM)grsbanks Wrote: Thanks for the reply but nope. Apologies, I missed in your first post that you were using the built-in ASM command to compile. I'm no expert in the built-in ASM syntax, but the following appears to compile (though I haven't tested it): Code: LC(5)"%1" FWIW, the syntax I used previously is perfectly acceptable to SASM. |
|||
12-28-2017, 05:57 PM
Post: #7
|
|||
|
|||
RE: Saturn ASM question | |||
12-28-2017, 06:03 PM
Post: #8
|
|||
|
|||
RE: Saturn ASM question
Source code updated to the following:
Code: % Do we have room for one more level on the stack? |
|||
12-29-2017, 04:56 PM
Post: #9
|
|||
|
|||
RE: Saturn ASM question
That's looking good, grsbanks!
I hope you don't mind if I offer a similar function -- not because I think it's better, but simply to introduce some different approaches for your consideration. As mentioned earlier, I like to pre-load the stack with placeholders while still in the SysRPL environment if possible. Especially when the possible results are clearly defined as in this case, which then keeps you from having to worry about memory allocations or error conditions within the Saturn code (where it usually has a larger memory footprint). Additionally, this example shows an alternative method to test the bit in question: Code: !NO CODE Note that this example uses an opcode for shifting the A register which is only available on the ARM-based systems (aka "the Saturnator"). That shouldn't be a problem here, as this function is already limited in scope to those systems anyway. |
|||
12-30-2017, 12:11 AM
Post: #10
|
|||
|
|||
RE: Saturn ASM question
(12-29-2017 04:56 PM)DavidM Wrote: I hope you don't mind if I offer a similar function -- not because I think it's better, but simply to introduce some different approaches for your consideration. I like it As you say, the choice of instructions isn't a problem. I'm already using "ACCESSSD" in there and that is only available on the Saturn+ as well. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)