* Updated SYNTAX to include preprocessor directives
* Added a preprocessor example program
This commit is contained in:
parent
21198a8282
commit
9be63e849d
3 changed files with 26 additions and 2 deletions
13
SYNTAX
13
SYNTAX
|
|
@ -7,7 +7,8 @@ This virtual machine loosely follows traditional Intel x86 assembly syntax.
|
|||
1. REGISTERS
|
||||
2. MEMORY
|
||||
3. LABELS
|
||||
4. INSTRUCTION LISTING
|
||||
4. PREPROCESSOR
|
||||
5. INSTRUCTION LISTING
|
||||
I. Memory
|
||||
II. Stack
|
||||
III. Calling Conventions
|
||||
|
|
@ -74,7 +75,15 @@ Labels are specified by appending a colon to an identifier. Local labels are not
|
|||
Labels must be specified at the beginning of a line or on their own line.
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// 4. INSTRUCTION LISTING ////////////////////////
|
||||
// 4. PREPROCESSOR ///////////////////////////////
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
TVM has a preprocessor that allows other source files to be included with the directive "%include filename.vm"
|
||||
|
||||
During preprocessing, the entire included source file is inserted in place of the %include directive in memory.
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// 5. INSTRUCTION LISTING ////////////////////////
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
Instructions listed are displayed in complete usage form, with example arguments, enclosed in square brackets.
|
||||
|
|
|
|||
8
programs/tinyvm/preprocessor/jsr.vm
Normal file
8
programs/tinyvm/preprocessor/jsr.vm
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%include print_eax.vm
|
||||
|
||||
start:
|
||||
mov eax, 42
|
||||
call print_eax
|
||||
|
||||
mov eax, 23
|
||||
call print_eax
|
||||
7
programs/tinyvm/preprocessor/print_eax.vm
Normal file
7
programs/tinyvm/preprocessor/print_eax.vm
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
print_eax:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
prn eax
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
Loading…
Reference in a new issue