summaryrefslogtreecommitdiff
path: root/twasm/README.md
blob: 4607b01b96e86720bb0f830579471e6704bf4013 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# twasm

this will be a self hosted, very minimal subset of 64 bit asm

### goals

I want to compile Bootler and Twasm with the Twasm assembler

### memory map

```
+------ 0x00100000 ------+
| hardware, bios stuff   |
+------ 0x00080000 ------+
| output binary          |
+------ 0x00070000 ------+
| token table            |
+------ 0x00060000 ------+
| test arena             |
+------ 0x00050000 ------+
| stack (rsp)            |
+------------------------+
| input                  |
+------------------------+ <- this is lined up to a sector
|                        | <- and this is less than a sector
+------------------------+
| assembler              |
+------ 0x00010000 ------+
| bootloader, bios, etc. |
+------------------------+
```

each word represents a token on the token table.

#### token table (TT)

each token gets loaded into the token table with the following form:

```
+----------+-----------------------+
| 31    16 | 15                  0 |
+----------+-----------------------+
| reserved | token id              |
+----------+-----------------------+
```

### token IDs

supported tokens are listed below

| token | id     | notes |
|-------|--------|-|
| rax   | 0x0000 | |
| rbx   | 0x0001 | |
| rcx   | 0x0002 | |
| rdx   | 0x0003 | |
| rsi   | 0x0004 | |
| rdi   | 0x0005 | |
| rsp   | 0x0006 | |
| rbp   | 0x0007 | |
| r8    | 0x0008 | |
| r9    | 0x0009 | |
| r10   | 0x000A | |
| r11   | 0x000B | |
| r12   | 0x000C | |
| r13   | 0x000D | |
| r14   | 0x000E | |
| r15   | 0x000F | |
| eax   | 0x0010 | |
| ebx   | 0x0011 | |
| ecx   | 0x0012 | |
| edx   | 0x0013 | |
| esi   | 0x0014 | |
| edi   | 0x0015 | |
| esp   | 0x0016 | |
| ebp   | 0x0017 | |
| r8d   | 0x0018 | |
| r9d   | 0x0019 | |
| r10d  | 0x001A | |
| r11d  | 0x001B | |
| r12d  | 0x001C | |
| r13d  | 0x001D | |
| r14d  | 0x001E | |
| r15d  | 0x001F | |
| ax    | 0x0020 | |
| bx    | 0x0021 | |
| cx    | 0x0022 | |
| dx    | 0x0023 | |
| si    | 0x0024 | |
| di    | 0x0025 | |
| sp    | 0x0026 | |
| bp    | 0x0027 | |
| r8w   | 0x0028 | |
| r9w   | 0x0029 | |
| r10w  | 0x002A | |
| r11w  | 0x002B | |
| r12w  | 0x002C | |
| r13w  | 0x002D | |
| r14w  | 0x002E | |
| r15w  | 0x002F | |
| al    | 0x0030 | |
| bl    | 0x0031 | |
| cl    | 0x0032 | |
| dl    | 0x0033 | |
| sil   | 0x0034 | |
| dil   | 0x0035 | |
| spl   | 0x0036 | |
| bpl   | 0x0037 | |
| r8b   | 0x0038 | |
| r9b   | 0x0039 | |
| r10b  | 0x003A | |
| r11b  | 0x003B | |
| r12b  | 0x003C | |
| r13b  | 0x003D | |
| r14b  | 0x003E | |
| r15b  | 0x003F | |
| ah    | 0x0040 | |
| bh    | 0x0041 | |
| ch    | 0x0042 | |
| dh    | 0x0043 | |
| cs    | 0x0044 | |
| ds    | 0x0045 | |
| es    | 0x0046 | |
| fs    | 0x0047 | |
| gs    | 0x0048 | |
| ss    | 0x0049 | |
| cr0   | 0x004A | |
| cr2   | 0x004B | |
| cr3   | 0x004C | |
| cr4   | 0x004D | |
| cr8   | 0x004E | |
|       | 0xFFFF | unrecognised token |