blob: 295e9a1b74f6cf41c201d6b1663421b8ef5ad9db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
Design
------
- MISC or RISC
- load/store or allow things like adding register to memory
- make most aspect configurable at runtime because we want to use
it to stress the compiler (things like "what if we have 1k RAM
and 4 registers?")
- fixed size instruction set or not or how much do we care about
being optimized to be implementable in hardware or in FPA?
- the PDB-8 had 8 opcodes? MISC requires 32 or less opcodes
- RISC requires operands to be part of the opcode, this is not
really practicable with 8-bit words, mostly RISCs are 32 or
64 bit wasting tons of memory for code.
- von Neumann or Harvard?
Opcodes
-------
Load/Store
MOV
Integer Arithmetic and logical operations
ADD
SUB
MUL
DIV
INC
DEC
AND
OR
NOT
XOR
NEG
SHR
SHL
ROTR
ROTL
Floating Point Arithmetic
FADD
FSUB
FMUL
FDIV
Testing and Branching
CMP
JC
JNC
JZ
JNZ
Subroutine
CALL
RET
Not sure about those
Stack
PUSH
POP
I/O-ports
GET
PUT
Other
HLT
NOP
not sure about NOP, as long as we don't do branch-prediction or
code patching for relocation?
Building
--------
gcc -I../minilib -g -O0 -m32 -march=i386 -ffreestanding -Werror -Wall -Wno-return-type -pedantic -std=c89 -o miniemu *.c ../minilib/*.c
clang -I../minilib -g -O0 -march=i386 -fno-builtin -std=c89 -Werror -Wall -Wno-return-type -o miniemu *.c ../minilib/*.c
tcc -I../minilib -g -O0 -march=i386 -fno-builtin -std=c89 -Werror -Wall -Wno-return-type -o miniemu *.c ../minilib/*.c
pcc -I../minilib -g -O0 -march=i386 -fno-builtin -std=c89 -Wall -Wno-return-type -o miniemu *.c ../minilib/*.c
Usage
-----
./miniemu test1.bin
./miniemu test2.bin
./miniemu test3.bin
./miniemu test4.bin
./miniemu test5.bin
./miniemu test6.bin
./miniemu test7.bin
./miniemu test8.bin
|