Proposal: 16-bit memory access
This page is dedicated to discussing this specific proposal
ContributeContributions
StephenPelc [301] 16-bit memory accessProposal2023-06-19 13:36:15
Authors
Stephen Pelc, stephen@vfxforth.com Leon Wagner, leon@forth.com
Change Log
19 June 2023, First release
Problem
16-bit data items are often required, e.g. for networks, for input and output, and for operating system data structures. Words to fetch and store data of this size are not yet standardised.
Solution
The words W@
,W!
and W,
are in common use.
Proposal
6.1.xxxx W@
w-fetch CORE
( w-addr -- w16 )
Fetch the 16-bit item stored at w-addr. When the cell size is greater than 16 bits, the unused high-order bits are all zeroes.
See: 3.3.3.1 Address alignment.
6.1.xxx W!
w-store CORE
( w16 w-addr -- )
Store a 16-bit item at w-addr. When a 16-bit item is smaller than cell size, only the number of low-order bits corresponding to character size are transferred.
See: 3.3.3.1 Address alignment.
6.1.xxx W,
c-comma CORE
( w16 -- )
Reserve space for one 16-bit item in the data space and store w16 in the space. If the data-space pointer is 16-bit aligned when W,
begins execution, it will remain 16-bit aligned when W,
finishes execution. An ambiguous condition exists if the data-space pointer is not 16-bit aligned prior to execution of W,
.
See: 3.3.3.1 Address alignment.
Rationale
The majority of new Forth systems developed in the 21st century use 32-bit or 64-bit cells. This proposal covers 16-bit memory access operators for such systems.
Reference Implementation
These words are hardware and implementation dependent.