Post Reply 
Saturn ASM question
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
!RPL
::
  ( no arguments expected )
  CK0NOLASTWD

  ( assume SD card is present )
  %1

  CODE
    % returns space available or negative error code if card not present in
    % low-order 8 nibbles of A
    P= 8
    ACCESSSD
    P= 0

    % shift high bit of result into bit 0
    C=0 W
    LC 1F
    A=A>C W

    % if bit 0 of A is 1, an error occurred (assume no SD card)
    % this simply changes the SL1 pointer to now reference %0 instead of %1
    ?ABIT=1 0 ->{
      LC(5)"%0"
      DAT1=C A
    }

    % return to RPL
    RPL

  ENDCODE
;
@

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.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Saturn ASM question - grsbanks - 12-28-2017, 03:32 PM
RE: Saturn ASM question - pier4r - 12-28-2017, 03:53 PM
RE: Saturn ASM question - DavidM - 12-28-2017, 04:32 PM
RE: Saturn ASM question - grsbanks - 12-28-2017, 04:51 PM
RE: Saturn ASM question - DavidM - 12-28-2017, 05:48 PM
RE: Saturn ASM question - grsbanks - 12-28-2017, 05:57 PM
RE: Saturn ASM question - grsbanks - 12-28-2017, 05:14 PM
RE: Saturn ASM question - grsbanks - 12-28-2017, 06:03 PM
RE: Saturn ASM question - DavidM - 12-29-2017 04:56 PM
RE: Saturn ASM question - grsbanks - 12-30-2017, 12:11 AM



User(s) browsing this thread: 1 Guest(s)