![]() |
LT4335 stack instructions.
Version of 6 July 2011. Home |
Some stack instructions apply to only the 64 registers within the CPU, but others can also involve the stack overflow area. The mnemonics begin with "P" instead of "S", because "S" is already used for string operations. The "P" was chosen because it is the first letter of verbs traditionally associated with last-in-first-out data structures: push, peek, pop and pull.
Guide to the mnemonics:
In many opcodes appears u6, a six-bit unsigned integer whose value is denoted u; it necessarily lies in 0…63. Similar is v as the value of v6.
Any operation that pushes may lead to a writing into the stack overflow area; any operation that pulls may invoke reading of the overflow area. The CPU may transfer stack data between registers and the overflow area at unpredictable times. These transfers are not subject to the synchronization option of the get and put instructions, because the stack overflow area is separate from genspace. Additionally, the manner of formatting data within the overflow area is unpredictable.
The next instruction writes all the CPU registers to the overflow area. In general, this needs to be done only on a context switch.
PF | stack flush | ? |
---|---|---|
Pulled: none
Pushed: none |
The next instructions give information about the stack.
PIT | stack information, total size | ? |
---|---|---|
Pulled: none
Pushed: #0 signed integer: the quantity of items in the stack associated with the current task, CPU and overflow combined | ||
PIR | stack information, remaining space | ? |
Pulled: none
Pushed: #0 signed integer: the quantity of bits, in the stack overflow area, that would still be available if the stack were flushed. |
The next instructions discard items from the top of the stack within the CPU. If more then 64 items are to be removed, the instructions also discard from the stack overflow area. An exception is thrown if the stack (CPU and overflow combined) does not contain at least the requested number of items.
PDE | stack discard, operand embedded | u8_? | PDR | stack discard, operand in register | 08_? |
---|---|---|---|---|---|
Pulled: a variable quantity of items to be discarded
Pushed: none The leftmost 8 bits of the opcode are an unsigned integer indicating how many stack items are to be discarded. If zero, PDR is performed instead. | Pulled:
• #0 nonnegative signed integer: number of items to remove from the stack, not counting #0 (throws exception on negative or null) • a variable quantity of items being discarded Pushed: none |
The next instructions exchange registers among the 64 within the CPU; there is no instruction to exchange registers in the overflow area. PS1 exchanges two registers. PS2 exchanges two pairs of registers; although intended for manipulating floats, it may be used for registers containing anything else, as the LT4335 does not enforce data typing. Meta-registers are swapped, also.
PS1 | stack swap, single registers | u6_v6_? | PS2 | stack swap, double registers | u6_v6_? |
---|---|---|---|---|---|
Pulled: none
Pushed: none Exchanges the contents of #u and #v. | Pulled: none
Pushed: none Exchanges the contents of #u and #v, as well as #(u+1) and #(v+1). Throws an exception if u or v equals 63, or if u and v are consecutive integers. |
The next instructions push a copy of one or two registers or meta-registers.
PO1 | stack obtain, single register | u6_? | PO2 | stack obtain, double register | u6_? |
---|---|---|---|---|---|
Pulled: none
Pushed: A copy of #uold #uold is not deleted, but after the push its address is #(u+1). | Pulled: none
Pushed:
An exception will be thrown if u equals 63. | ||||
POM1 | stack obtain, single meta-register | u6_? | POM2 | stack obtain, double meta-register | u6_? |
Pulled: none
Pushed:
#0new = ##uold = ##(u+1)new. | Pulled: none
Pushed:
#0new = ##uold = ##(u+2)new
An exception will be thrown if u equals 63. |
In stack rotation, the top (i.e. most recently pushed) u items will be rearranged. Let r be a register number in 0…(u − 1). Then for every r, #rnew = #((r+v) mod u)old. Of course, the meta-registers will be correspondingly rearranged. No register contents will be lost or duplicated.
PR | stack rotate | u6_v6_? |
---|---|---|
Pulled: none
Pushed: none |