Commit ec5f7c86 by Jessica Hawkwell

Yikes, lots of opcodes documented. #2

1 parent 1fbf32da
Pipeline #220 passed
in 14 seconds
Showing with 208 additions and 3 deletions
......@@ -93,5 +93,4 @@ itself and emit the results in the binary. All numbers are supported, with radi
also be dereferenced. Kasm cannot (and probably will not) dereference a number intended to be loaded from a memory
address or register. Attempting to do may result in undefined behavior.
[^1]: Kasm's numberizer uses [Integer.valueOf(String s, int radix)]
(ttp://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#valueOf-java.lang.String-int-)
[^1]: Kasm's numberizer uses [Integer.valueOf(String s, int radix)](http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#valueOf-java.lang.String-int-)
......@@ -116,41 +116,247 @@ The Kcpu currently has a very limited instruction set. For the numerical values
# Instruction Information
## `add`
```
add output input
```
Adds the values of both `input` and `output`, then places the result in `output`.
## `call`
```
call address
```
Places the current program counter onto the call stack, then jumps to the specified address.
## `deva`
## `devb`
```
deva address
```
If there is a device at the specified memory address, its port number will be placed in `r0`. If there is no device,
the value `0x7f` will be placed in `r0`.
## `devd`
```
devd port
```
Detaches the device on the specified port from the memory bus. Does nothing if the device is already detached.
## `devm`
```
devm port newaddress
```
Relocates device on the specified port to the specified base address. Use with caution, as there is nothing to prevent
multiple devices from sharing the same memory address range.
## `devp`
```
devp port
```
Obtains information on the device on the specified port:
* `r0` will contain the device's base address
* `r1` will contain the length of the devices's address range.
## `div`
```
div numerator denominator
```
Divides the numerator against the denominator:
* `r0` will contain the quotient
* `r1` will contain the remainder
## `gpc`
```
gpc the current program counter in `r0`
## `iret`
```
iret from an interrupt state. Does nothing if the processor is not currently in an interrupt state.
## `irqd`
```
irqd port
```
Sends an interrupt to the device on the specified port. This is a non-blocking instruction.
For the blocking equivalent, see [`irqdh`](#irqdh)
## `irqdh`
```
irqdh port
```
Sends an interrupt to the device on the specified port. This is a blocking instruction - the processor will wait until
the hardware finishes its task.
## `irqm`
```
irqm address
```
Sends an interrupt to the device using the specified memory address. This is a non-blocking instruction.
For the blocking equivalent, see [`irqmh`](#irqmh)
## `irqmh`
```
irqmh address
```
Sends an interrupt to the device using the specified memory address. This is a blocking instruction - the processor
will wait until the hardware finishes its task.
## `ivec`
```
ivec interrupt address
```
Sets the specified address as the interrupt handler (vector) for the specified interrupt value.
## `jae`
```
jae number0 number1 address
```
Jumps to address if number0 is equal to number1.
## `jag`
```
jag number0 number1 address
```
Jumps to address if number0 is greater than number1.
## `jage`
```
jage number0 number1 address
```
Jumps to address if number0 is greater than or equal to number1.
## `jal`
```
jal number0 number1 address
```
Jumps to address if number0 is less than number1.
## `jale`
```
jale number0 number1 address
```
Jumps to address if number0 is less than or equal to number1.
## `jde`
```
jde number0 number1 address
```
Jumps down if number0 is equal to number1.
## `jdg`
```
jdg number0 number1 address
```
Jumps down if number0 is greater than number1.
## `jdge`
```
jdge number0 number1 address
```
Jumps down if number0 is greater than or equal to number1.
## `jdl`
```
jdl number0 number1 address
```
Jumps down if number0 is less than number1.
## `jdle`
```
jdle number0 number1 address
```
Jumps down if number0 is less than or equal to number1.
## `jmpa`
```
jmpa address
```
Jumps to address.
## `jmpd`
```
jmpd address
```
Jumps down.
## `jmpu`
```
jmpu address
```
Jumps up.
## `jue`
```
jue number0 number1 address
```
Jumps up if number0 is equal to number1.
## `jug`
```
jug number0 number1 address
```
Jumps up if number0 is greater than number1.
## `juge`
```
juge number0 number1 address
```
Jumps up if number0 is greater than or equal to number1.
## `jul`
```
jul number0 number1 address
```
Jumps up if number0 is less than number1.
## `jule`
```
jule number0 number1 address
```
Jumps up if number0 is less than or equal to number1.
## `mul`
```
mul output input
```
Multiplies the values of both `input` and `output`, then places the result in `output`.
## `pop`
```
pop
```
Takes the topmost value from the stack and moves it to `r0`.
## `push`
```
push value
```
Places the specified value at the top of the stack.
## `ret`
```
ret
```
Returns from a function. Does nothing if the call stack is empty.
## `sub`
```
sub output input
```
Subtracts the value `output` from the value of `input`, then places the result in `output`.
## `vcmp`
```
vcmp number0 number1
```
Performs 4 comparisons between number0 and number1, then puts the result in `r0`. The resulting value is a bitmask.
* `number0 != number1` : `0x01`
* `number0 >= number1` : `0x02`
* `number0 == number1` : `0x04`
* `number0 <= number1` : `0x08`
## `zpwr`
```
zpwr
```
Turns the system off.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!