@@ -5,6 +5,13 @@ Fateful is a CLI tool foring with my custom CPU, F8ful.
5
5
It contains an emulator and an assembler.
6
6
Fateful can be installed through [ cargo] ( https://github.com/rust-lang/cargo ) via ` cargo install --git https://github.com/commonkestrel/fateful ` .
7
7
8
+ Running a program has two steps: assembly and emulation.
9
+ To assemble a program, run ` fateful assemble <program>.asm -o <program>.bin `
10
+ If this is successful, you can emulate the program with ` fateful emulate <program>.bin `
11
+ The emulator is a REPL that contains various commands expalined (below)[ #emulator] .
12
+ The most important command for emulating a program is ` RUN ` .
13
+ Inputting ` RUN 0 ` will run the assembly program as fast as possible until a halt is detected.
14
+
8
15
## Assembler
9
16
10
17
The assembler can be used with the ` fateful asm ` or ` fateful assemble ` command to assembler f8ful assembly into f8ful machine code.
@@ -464,6 +471,9 @@ jnz 1
464
471
465
472
### Built-in Macros
466
473
474
+ Built-in macros are a group of macros included by default in every program.
475
+ The details of each macro can be found in (src/assembler/macros.asm)[ ./src/assembler/macros.asm] .
476
+
467
477
* [ PUSH] ( #push-macro )
468
478
* [ POP] ( #pop-macro )
469
479
* [ PUSHA] ( #pusha-macro )
@@ -889,11 +899,24 @@ The input parameter provides the number of slots that the peripheral has been at
889
899
#### Reading and Writing
890
900
891
901
Peripherals can be written through a function with the signiture ` void write(unsigned char, unsigned char) ` .
902
+ This function is called whenever the CPU writes to the given address or the address is ` POKE ` ed.
892
903
The first parameter is the slot index that is being written to, and the second parameter is the value being written.
893
904
894
- Peripherals can be read from with a function with the signiture ` unsigned char read(unsigned char) `
905
+ Peripherals can be read from with a function with the signiture ` unsigned char read(unsigned char) ` .
906
+ This function is called whenever the CPU reads from the given address or the address is ` PEEK ` ed at.
895
907
The input parameter is the slot index that is being read from, and the return value should be the value at the slot.
896
908
909
+ #### Drop
910
+
911
+ Peripherals are dropped through a function with the signiture ` void drop() ` .
912
+ This function is called when every address this peripheral is attached to is ` DROP ` ed, or the emulator is quit.
913
+ This function * must* clean up any seperate threads before returning or the emulator will crash.
914
+
915
+ #### Reset
916
+
917
+ Peripherals are reset through a function with the signiture ` void reset() ` .
918
+ This functions is called whenever the emulator resets the CPU.
919
+
897
920
### Errors
898
921
899
922
Errors are only checked upon initialization - after both ` init ` and ` stateful_init ` .
0 commit comments