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 ...@@ -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 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. address or register. Attempting to do may result in undefined behavior.
[^1]: Kasm's numberizer uses [Integer.valueOf(String s, int radix)] [^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-)
(ttp://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 ...@@ -116,41 +116,247 @@ The Kcpu currently has a very limited instruction set. For the numerical values
# Instruction Information # Instruction Information
## `add` ## `add`
```
add output input
```
Adds the values of both `input` and `output`, then places the result in `output`.
## `call` ## `call`
```
call address
```
Places the current program counter onto the call stack, then jumps to the specified address.
## `deva` ## `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`
```
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`
```
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`
```
div numerator denominator
```
Divides the numerator against the denominator:
* `r0` will contain the quotient
* `r1` will contain the remainder
## `gpc` ## `gpc`
```
gpc the current program counter in `r0`
## `iret` ## `iret`
```
iret from an interrupt state. Does nothing if the processor is not currently in an interrupt state.
## `irqd` ## `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`
```
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`
```
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`
```
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`
```
ivec interrupt address
```
Sets the specified address as the interrupt handler (vector) for the specified interrupt value.
## `jae` ## `jae`
```
jae number0 number1 address
```
Jumps to address if number0 is equal to number1.
## `jag` ## `jag`
```
jag number0 number1 address
```
Jumps to address if number0 is greater than number1.
## `jage` ## `jage`
```
jage number0 number1 address
```
Jumps to address if number0 is greater than or equal to number1.
## `jal` ## `jal`
```
jal number0 number1 address
```
Jumps to address if number0 is less than number1.
## `jale` ## `jale`
```
jale number0 number1 address
```
Jumps to address if number0 is less than or equal to number1.
## `jde` ## `jde`
```
jde number0 number1 address
```
Jumps down if number0 is equal to number1.
## `jdg` ## `jdg`
```
jdg number0 number1 address
```
Jumps down if number0 is greater than number1.
## `jdge` ## `jdge`
```
jdge number0 number1 address
```
Jumps down if number0 is greater than or equal to number1.
## `jdl` ## `jdl`
```
jdl number0 number1 address
```
Jumps down if number0 is less than number1.
## `jdle` ## `jdle`
```
jdle number0 number1 address
```
Jumps down if number0 is less than or equal to number1.
## `jmpa` ## `jmpa`
```
jmpa address
```
Jumps to address.
## `jmpd` ## `jmpd`
```
jmpd address
```
Jumps down.
## `jmpu` ## `jmpu`
```
jmpu address
```
Jumps up.
## `jue` ## `jue`
```
jue number0 number1 address
```
Jumps up if number0 is equal to number1.
## `jug` ## `jug`
```
jug number0 number1 address
```
Jumps up if number0 is greater than number1.
## `juge` ## `juge`
```
juge number0 number1 address
```
Jumps up if number0 is greater than or equal to number1.
## `jul` ## `jul`
```
jul number0 number1 address
```
Jumps up if number0 is less than number1.
## `jule` ## `jule`
```
jule number0 number1 address
```
Jumps up if number0 is less than or equal to number1.
## `mul` ## `mul`
```
mul output input
```
Multiplies the values of both `input` and `output`, then places the result in `output`.
## `pop` ## `pop`
```
pop
```
Takes the topmost value from the stack and moves it to `r0`.
## `push` ## `push`
```
push value
```
Places the specified value at the top of the stack.
## `ret` ## `ret`
```
ret
```
Returns from a function. Does nothing if the call stack is empty.
## `sub` ## `sub`
```
sub output input
```
Subtracts the value `output` from the value of `input`, then places the result in `output`.
## `vcmp` ## `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`
```
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!