Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
One-instruction set computer
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
One-instruction set computer
(section)
Add topic