* Updated SYNTAX to include preprocessor directives

* Added a preprocessor example program
This commit is contained in:
Joseph Kogut 2013-02-08 14:15:36 -07:00
parent 21198a8282
commit 9be63e849d
3 changed files with 26 additions and 2 deletions

13
SYNTAX
View file

@ -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.

View file

@ -0,0 +1,8 @@
%include print_eax.vm
start:
mov eax, 42
call print_eax
mov eax, 23
call print_eax

View file

@ -0,0 +1,7 @@
print_eax:
push ebp
mov ebp, esp
prn eax
pop ebp
ret