Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
One-instruction set computer
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Subtract and branch if negative === The {{mono|subneg}} instruction ("''subtract and branch if negative''"), also called {{mono|SBN}}, is defined similarly to {{mono|subleq}}:<ref name=caamp />{{rp|41,51β52}} '''Instruction''' <syntaxhighlight lang="nasm" inline>subneg a, b, c</syntaxhighlight> Mem[b] = Mem[b] - Mem[a] '''if''' (Mem[b] < 0) '''goto''' c Conditional branching can be suppressed by setting the third operand equal to the address of the next instruction in sequence. If the third operand is not written, this suppression is implied. ==== Synthesized instructions ==== It is possible to synthesize many types of higher-order instructions using only the {{mono|subneg}} instruction. For simplicity, only one synthesized instruction is shown here to illustrate the difference between {{mono|subleq}} and {{mono|subneg}}. Unconditional branch:<ref name=caamp />{{rp|88β89}} ;{{mono|JMP c}} :<syntaxhighlight lang="nasm"> subneg POS, Z, c </syntaxhighlight> where {{mono|Z}} and {{mono|POS}} are locations previously set to contain 0 and a positive integer, respectively; Unconditional branching is assured only if {{mono|Z}} initially contains 0 (or a value less than the integer stored in {{mono|POS}}). A follow-up instruction is required to clear {{mono|Z}} after the branching, assuming that the content of {{mono|Z}} must be maintained as 0. ==== subneg4 ==== A variant is also possible with four operands β subneg4. The reversal of minuend and subtrahend eases implementation in hardware. The non-destructive result simplifies the synthetic instructions. '''Instruction''' <syntaxhighlight lang="nasm" inline>subneg s, m, r, j</syntaxhighlight> ''(* subtrahend, minuend, result and jump addresses *)'' Mem[r] = Mem[m] - Mem[s] '''if''' (Mem[r] < 0) '''goto''' j
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)