-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesign.txt
90 lines (79 loc) · 2.01 KB
/
design.txt
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
design
steps
- input: loads from file
- newline: convert all newlines to LF, ensure LF at EOF
- pass0: remove comments, tokenize
program arguments
- target architecture
- output format (a.out, coff, elf, ...)
assembler syntax
- comments
- line comment: //
- block comment: /* */
- nesting block comment: /+ /+ +/ +/
- directives
- all are prefixed with a dot
- must be lowercase
- file inclusion:
- .include "filename"
- symbols, conditional:
- .def name value
- .undef name
- .if name|value
- .ifdef name
- .ifndef name
- .else
- .elif name|value
- .endif
- data:
- .byte val
- .word val
- .dword val
- .qword val
- .dqword val
- .range start end [-]increment
- strings:
- .str string
- .strz string+0
- alignment:
- .align value
- addressing:
- .org addr
- sections:
- .section sect
- instructions
- opcodes must be lowercase
- in situations where size is ambiguous, a character must be appended to the
opcode: b for byte, w for word, l for dword
- operands are in source, destination order
- integers
- integers behave mostly as in C11:
- dec starts with nonzero
- oct starts with 0
- hex starts with 0x
- bin starts with 0b
- no suffixes
- negative integers are treated as two's compliment numbers
- integer size will be as large as possible by default, and then narrowed down
as necessary where used
- registers
- register names must be lowercase
- no prefix
- suffix for size in ambiguous situations
- effective addresses
- indirect: [eax]
- indexed: [eax+4]
- sized: [4*eax+4]
- postinc: [...]++ (if applicable)
- predec: --[...] (if applicable)
- macros
- should have C-style macro replacement (functions)
- should have do-this-n-times (loops)
- output
- possibly user-chooseable
- one of the object formats that ld understands
- possible formats:
- a.out
- coff
- elf
TODO: scour the gas documentation for useful directives, macro ideas, etc.