-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
83 lines (57 loc) · 1.59 KB
/
README
File metadata and controls
83 lines (57 loc) · 1.59 KB
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
Stack machine simulation.
Requires clang 3.1.
* Usage:
** ./runner [-v] [-f asm_file]
*** -v: verbose, step through code
*** -f: asm file to assemble and run
* Instructions:
** PUSH
Pushes the value in the next code instruction.
** POP
Discards the top stack value.
** NOP
Do nothing.
** HLT
Halt the machine.
** OUT
Pops a value and prints the value to stdout as a char.
** STORE
Pops a value, pops an address, then places the value in mem
at the addres.
** LOAD
Pops an address, loads that value from memory, then pushes
that value.
** ADD
Pops two values and pushes the sum.
** SUB
Pops two values and pushes the difference.
** MUL
Pops two values and pushes the product.
** DIV
Pops two values and pushes the quotient and remainder.
** JMP
Sets the CPU instruction pointer to the value popped.
** JZ
Pops an address and pops a value. If the value is zero,
moves cpu->ip to the address.
** JNZ
Pops an address and pops a value. If the value is not zero,
moves cpu->ip to the address.
** CALL
Pops an address and pushes to the return pointer stack.
Moves instruction pointer to that address.
** RET
Pops an address from the return pointer stack and moves
the instruct pointer there.
** DUP
Duplicates the value on the top of the stack.
** SWAP
Swaps the values of the top two values on the stack.
** INT
Registers an interrupt handler. The handler address and the
resource address are popped from the stack.
** DEBUG
Put the cpu into debug mode.
* Hardware:
** KBD
Awaits a keystroke and then pushes it onto the stack.