07d50265faa7825d9a7cf4c2a75db5ca63396ca3 — neauoire a month ago 0adfabe master
1 files changed, 65 insertions(+), 27 deletions(-)

M README.md => README.md +65 -27
@@ 1,41 1,79 @@
# Gyo

[Gyo](https://wiki.xxiivv.com/site/gyo.html) is an OISC based on [Fractran](https://wiki.xxiivv.com/site/fractran.html). 
[Gyo](https://wiki.xxiivv.com/site/gyo.html) is an virtual computer with 16 registers, 256 addressable memory addresses. The cpu understands 16 opcodes, the assembler syntax understands `=constants` and `:labels`. Programs are loaded directly into memory to create procedural self-modifiable programs.

## Specs

- `ProgramCounter`, a short.
- `Stack/ptr`, a byte.
- `Stack/dat`, a series of shorts.
- `Stack/dat[Stack/ptr-2]`, the accumulator.
<img src='https://wiki.xxiivv.com/media/generic/gyo.jpg' width='200'/>

## Instructions

- `*/*`, Jump.
- `*/0`, Push Acc to address.
- `0/*`, Pull Acc from address.
- `0/0`, Break.
- `2/3`, Multiply by 2/3, if fail, PC+=2
0x0  BRK  Break
0x1  JMP  Jump to position in memory
0x2  JCA  Jump to position in memory, when carryflag
0x3  JZE  Jump to position in memory, when zeroflag
0x4  PEK  Read status
0x5  POK  Write status
0x6  GET  Store in register
0x7  PUT  Store in memory
0x8  ADD  Add value to register, set carryflag when overflow
0x9  SUB  Substract value from register, set carryflag when overflow
0xA  EQU  Compare register with value, set zeroflag when equal
0xB  LES  Compare register with value, set zeroflag when less than
0xC  AND  Bitwise AND operator
0xD  XOR  Bitwise XOR operator
0xE  ROL  Bitwise rotate left
0xF  ROR  Bitwise rotate right

## Addressing

- `#ef` the raw value.
- `$ef` the value at address #ef in memory.
- `[e]` the value of the 15th register.
- `{e}` the value at the address of the 15th register.

## IO

To begin IO mode, activate the traps flag with `POK #08`.

## Special Registers
POK #08  ; Set traps flag ON
GET      ; Read character from stdin
PUT [0]  ; Write character to stdout
POK #00  ; Set traps flag OFF 

- `fb`, write to stdout
- `f1`, read from stdin
## Status Register

## Registers
The status register is distributed as follows, it shares the same byte as the register selector. The **halt** flag is used by the BRK instruction is stops the cpu, the **zero** flag is used for conditional instructions(EQU/LES/JEQ/JNE), the **carry** flag is set when a SUB/ADD instruction carries over the 8bit range and the **traps** flag is set when the pointer should be sent to the traps location(in IO operations). 

Below are all the available registers.
| | | +---- Halt
| | +------ Zero
| +-------- Carry
+---------- Traps

## Assembly Syntax

03 05 07 0b 0d 11 13 17
1d 1f 25 29 2b 2f 35 3b
3d 43 47 49 4f 53 59 61
65 67 6b 6d 71 7f 83 89
8b 95 97 9d a3 a7 ad b3 < Special
b5 bf c1 c5 c7 d3 df e3 < Special
e5 e9 ef f1 fb          < I/O
=rate #01           ; defines constant value

:label              ; a label defines an address in the program
	ADD rate        ; add rate to register
	EQU #0f         ; set zeroflag if register is equal to #0f
	JZE end         ; goto end if equal
	JMP label       

## Work in progress
If you need to fill the memory with specific values, you can do it as follows:

Come back soon.
	#48 #65
	#6C #6C
	#6F #0A
\ No newline at end of file