Split a numeric Word into byte, then store it in scratch pad RAM
I'm using the Scratch Pad Ram when passing variables from different
Banks on the BS2p.
I need to pass a numeric word, but the scratch pad only store a byte.
How it is possible to split a word into two bytes, then rebuilt it
in another bank?
Stein.
Banks on the BS2p.
I need to pass a numeric word, but the scratch pad only store a byte.
How it is possible to split a word into two bytes, then rebuilt it
in another bank?
Stein.
Comments
PUT spAddr, Word myData
GET spAddr, Word myData
The equivalent in PBASIC 2.0 is this:
PUT spAddr, myData.LOWBYTE
PUT spAddr + 1, myData.HIGHBYTE
GET spAddr, myData.LOWBYTE
GET spAddr + 1, myData.HIGHBYTE
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From:
eeee….. you forgot to tell that the next address in scratch pad is
affected.
I made this little test program to study the PUT and GET a word
variable affecting the next address:
'{$STAMP BS2p}
'{$PBASIC 2.5}
X VAR Byte
Page VAR Word
x=0
Page=6500 ` try different nr
PUT 3,x
PUT 4,x
PUT 5,x
PUT 6,x
PUT 5, Word Page
GET 3,X[noparse]:D[/noparse]EBUG "3:",DEC X,CR
GET 4,X[noparse]:D[/noparse]EBUG "4:",DEC X,CR
GET 5,Word Page[noparse]:D[/noparse]EBUG "5:",DEC5 Page,CR
GET 6,X[noparse]:D[/noparse]EBUG "6:",DEC X,CR
END
Stein.
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> With PBASIC 2.5 syntax you can PUT and GET Word variables.
>
> PUT spAddr, Word myData
> GET spAddr, Word myData
>
> The equivalent in PBASIC 2.0 is this:
>
> PUT spAddr, myData.LOWBYTE
> PUT spAddr + 1, myData.HIGHBYTE
> GET spAddr, myData.LOWBYTE
> GET spAddr + 1, myData.HIGHBYTE
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
>
Original Message
> From:
again.
When using the Word modifier, the low byte of the word is written to (or read
from) the stated address, the high byte is written to (or read from) address +
1. Note that you can even mix and match byte and words:
PUT 0, $00, Word $0201, $03
... will put $00 in address 0, $01 in address 1, $02 in address 2, and $03 in
address 3. Be careful that you don't attempt to write past the end of the
Scratchpad RAM space.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: