https://github.com/andreax79/go-forth
https://github.com/andreax79/go-forth
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/andreax79/go-forth
- Owner: andreax79
- License: apache-2.0
- Created: 2024-10-16T05:27:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-16T05:28:58.000Z (over 1 year ago)
- Last Synced: 2025-02-26T16:50:40.813Z (over 1 year ago)
- Language: Go
- Size: 84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
http://www.forth.org/Ting/Forth-for-the-Complete-Idiot/Forth-79-Handy-Reference.pdf
https://people.ece.cornell.edu/land/courses/ece5760/DE2/Stack_cpu.html
- forth
- nice syntax [OK]
- forth comments [OK]
- loop [OK]
- forth definitions [OK]
- ( ... ) comments [OK]
- assembler
- variables [OK]
- 2 pass compiler [OK]
- asciiz [OK]
- word/bytes [OK]
- bios
- compiler -> bios
- load bios
- display string/char
- read keyboard scancode (blocking)
- read keyboard scancode (non-blocking)
- read disk
- write disk
- get/size # of disks?
- get memory size?
- cpu
- mmu (virtual memory) [OK]
- short opcodes [OK]
- shift [OK]
- map registers ram?
- interrupt
- I/O
The CPU has the following instruction formats:
8 7 6 5 4 3 2 1 0
+-+-+-+-+-+-+-+-+-+
| # | |
|pop| opcode |
| | |
+-+-+-+-+-+-+-+-+-+
Push 32 bit value:
8 7 6 5 4 3 2 1 0
3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | | |
|0 0| PUSH opcode | 32 bit word |
| | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
------------------------------------------------------------------------------------------------
- call/ret ==> accesso variabili 'globali' ?
- I/O = emit
- relative jump
------------------------
Before subcall execution
- caller local var
- caller stack
- arguments
- fn addr
------------------------
During subcall execution
- caller local var
- caller stack
- arguments
- address to return <---- $data ($fp)
- value of $data in the caller
- local var
- stack <- $sp
case CALL:
cpu.mmu.WriteW(cpu.rsp, Word(cpu.rsp)) // store rsp
cpu.mmu.WriteW(cpu.rsp+1*WordSize, Word(cpu.rbp)) // store rbp
cpu.mmu.WriteW(cpu.rsp+2*WordSize, Word(cpu.pc)) // store pc
cpu.rbp = cpu.rsp + 3*WordSize
break
case RET:
cpu.pc = Addr(cpu.mmu.ReadW(cpu.rsp - 1*WordSize)) // return
cpu.rbp = Addr(cpu.mmu.ReadW(cpu.rsp - 2*WordSize)) // restore rbp
cpu.rsp = Addr(cpu.mmu.ReadW(cpu.rsp - 3*WordSize)) // restore rsp
break