Skip to content

Instantly share code, notes, and snippets.

@milesrout
Last active August 29, 2015 14:08
Show Gist options
  • Save milesrout/e555f2eb7d58a713b5d9 to your computer and use it in GitHub Desktop.
Save milesrout/e555f2eb7d58a713b5d9 to your computer and use it in GitHub Desktop.

In the following, $xxx represents a memory location and %xxx represents a register. dst represents a destination, src represents a source, lft represents the left-hand argument of a binary operation, rgt represents the right-hand argument of a binary operation, arg represents the only argument of a unary operation,

l          $addr, %reg
st         %reg, $addr

add        %lft, %rgt, %dst
sub        %lft, %rgt, %dst
mul        %lft, %rgt, %dst
div        %lft, %rgt, %dst
rem        %lft, %rgt, %dst
sqrt       %arg, %dst

In single-precision mode, there are 16 registers. In double-precision mode, there are 8 registers. In this mode, the register selector's top bit is ignored, but it should be set to zero.

Register selectors are 4 bits (a nibble) in length. Memory location selectors are 8 bits (a byte) in length.

add:   0001 llll rrrr dddd (%lft + %rgt -> %dst)
sub:   0010 llll rrrr dddd (%lft - %rgt -> %dst)
mul:   0011 llll rrrr dddd (%lft * %rgt -> %dst)
div:   0100 llll rrrr dddd (%lft ÷ %rgt -> %dst)
rem:   0101 llll rrrr dddd (%lft % %rgt -> %dst)

l:     0110 dddd ssss ssss ($src -> %dst)
st:    0111 ssss dddd dddd (%src -> $dst)

sqrt:  0000 0001 aaaa dddd (sqrt %arg -> %dst)

lz:    0000 0000 0001 dddd (0 -> %dst)
l1:    0000 0000 0010 dddd (1 -> %dst)
lp:    0000 0000 0011 dddd (pi -> %dst)
le:    0000 0000 0011 dddd (e -> %dst)

Short-form instructions:

1aaa aaaa 1bbb bbbb - two short-form instructions, a and b.
0*** **** 1*** **** - does not encode any short instructions
1*** **** 0*** **** - does not encode any short instructions
0*** **** 0*** **** - does not encode any short instructions
@wikki04
Copy link

wikki04 commented Oct 25, 2014

what it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment