Post Reply 
newRPL - build 1255 released! [updated to 1299]
10-31-2019, 04:11 PM
Post: #596
RE: newRPL - build 1255 released! [updated to 1299]
(10-30-2019 11:29 PM)JoJo1973 Wrote:  Claudio,

a question about the purpose of a couple of commands:

1) BINPUTB/BINPUTW: the program

<< 8 MKBINDATA 0 #1122334455667788 4 BINPUTB >>

fills the first four bytes of the container with #88h #77h #66h #55h but

When given a single number, BINTPUTB interprets the integer part as a multi-bit number (little endian!), so you requested 4 bytes to be stored, the first byte to be stored is (N%256), the second byte will be IP(N/256)%256 and so on. This is simply consistent with the little endianness of the platform, which newRPL adopted as well.

(10-30-2019 11:29 PM)JoJo1973 Wrote:  << 8 MKBINDATA 0 { #1122h #3344h #5566h #7788h } 0 4 BINPUTB >>

stores { #22h #44h #66h #88h } instead of { #22h #11h #44h #33h }. A look at the code shows that this works as intended, but why? Is there a reason for the different behavior? BINPUTW obviously works the same way, but using 4-bytes words instead of bytes.

When given a list, each item is treated as an individual element (byte, word, whatever you selected by using BINPUTB, BINPUTW), so if you use BINPUTB, only the lowest 8 bits will be stored from each number (N%256). In other words, your argument of 4 means "store the first 4 elements of my list of bytes".
BINPUTB is consistent with BINGETB, so the string of bytes you get from one bindata object can be stored directly on another one (of course, we have much faster dedicated opcodes for those memory copies).
I guess the logic I used is: for BINPUTB you can request any number of bytes to store, therefore you need to provide a string of bytes. That can come either as a list of bytes, or all packed into a single binary number. Same thing for words.

(10-30-2019 11:29 PM)JoJo1973 Wrote:  2) UNQUOTEID: while QUOTEID is useful to send unevaluated arguments to functions (but less versatile than userRPL's QUOTE, which accepts symbolic expressions too) I can't see an use for UNQUOTEID: where's its usefulness?

There's some dark uses, but the most common case is very simple: to create strings for output, you put the variable name 'X' on the stack, do UNQUOTEID ->STR to get a clean "X" rather than getting the quoted name then trying to remove the quotes from the string.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - build 1001 released! - pier4r - 12-16-2017, 08:03 AM
newRPL - on Hp 39gs - Martin Hepperle - 06-05-2019, 06:51 AM
RE: newRPL - build 1001 released! - pier4r - 12-23-2017, 10:16 AM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 09:42 AM
t - Claudio L. - 01-01-2018, 03:06 PM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 03:41 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 04:54 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 06:58 PM
newRPL - brickviking - 10-05-2018, 06:01 AM
RE: newRPL - build 1255 released! [updated to 1299] - Claudio L. - 10-31-2019 04:11 PM
How to participate? - erazor - 12-13-2019, 07:12 AM



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