Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
A
asmc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giovanni Mascellani
asmc
Commits
3c16191b
Unverified
Commit
3c16191b
authored
Mar 09, 2019
by
Giovanni Mascellani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline token recognition.
parent
0359585f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
90 deletions
+33
-90
asmg/asmg.asm
asmg/asmg.asm
+33
-90
No files found.
asmg/asmg.asm
View file @
3c16191b
...
...
@@ -24,37 +24,6 @@ TEMP_VAR:
db
'__temp'
db
0
str_cu_open:
db
'{'
db
0
str_cu_closed:
db
'}'
db
0
str_semicolon:
db
SEMICOLON
db
0
str_ret:
db
'ret'
db
0
str_if:
db
'if'
db
0
str_while:
db
'while'
db
0
str_else:
db
'else'
db
0
str_ifun:
db
'
ifun
'
db
0
str_fun:
db
'
fun
'
db
0
str_const:
db
'
const
'
db
0
section
.bss
label_num:
...
...
@@ -158,12 +127,12 @@ push_var:
add
esp
,
8
;; Increment the stack depth
add
DWORD
[
stack_depth
],
1
inc
DWORD
[
stack_depth
]
;; If this is a temp var, increment also temp_depth
cmp
DWORD
[
esp
+
8
],
0
je
push_var_non_temp
add
DWORD
[
temp_depth
],
1
inc
DWORD
[
temp_depth
]
ret
;; If this is not a temp var, check temp_depth is zero
...
...
@@ -177,7 +146,7 @@ pop_var:
;; Check stack depth is positive and decrement it
cmp
DWORD
[
stack_depth
],
0
jna
platform_panic
sub
DWORD
[
stack_depth
],
1
dec
DWORD
[
stack_depth
]
;; If this is a temp var...
cmp
DWORD
[
esp
+
4
],
0
...
...
@@ -188,7 +157,7 @@ pop_var:
pop_var_temp:
cmp
DWORD
[
temp_depth
],
0
jna
platform_panic
sub
DWORD
[
temp_depth
],
1
dec
DWORD
[
temp_depth
]
ret
...
...
@@ -709,11 +678,7 @@ push_expr_until_brace_loop:
mov
ebx
,
eax
;; If it is an open brace, exit loop
push
eax
push
str_cu_open
call
strcmp
add
esp
,
8
cmp
eax
,
0
cmp
WORD
[
eax
],
'{'
je
push_expr_until_brace_end
;; If not, branch depending on whether it is a string or not
...
...
@@ -817,11 +782,7 @@ parse_block:
;; Expect and discard an open curly brace token
call
get_token
push
eax
push
str_cu_open
call
strcmp
add
esp
,
8
cmp
eax
,
0
cmp
WORD
[
eax
],
'{'
jne
platform_panic
;; Main parsing loop
...
...
@@ -835,40 +796,27 @@ parse_block_loop:
je
platform_panic
;; If it is a closed curly brace, then break
push
ebx
push
str_cu_closed
call
strcmp
add
esp
,
8
cmp
eax
,
0
cmp
WORD
[
ebx
],
'}'
je
parse_block_break
;; Jump to the appropriate handler
push
ebx
push
str_semicolon
call
strcmp
add
esp
,
8
cmp
eax
,
0
cmp
WORD
[
ebx
],
';'
je
parse_block_semicolon
push
ebx
push
str_ret
call
strcmp
add
esp
,
8
cmp
eax
,
0
cmp
DWORD
[
ebx
],
'ret'
je
parse_block_ret
push
ebx
push
str_if
call
strcmp
add
esp
,
8
cmp
eax
,
0
mov
eax
,
[
ebx
]
and
eax
,
0xffffff
sub
eax
,
'if'
je
parse_block_if
push
ebx
push
str_while
call
strcmp
add
esp
,
8
cmp
eax
,
0
mov
eax
,
[
ebx
]
sub
eax
,
'whil'
mov
cx
,
[
ebx
+
4
]
sub
cx
,
'e'
or
ax
,
cx
test
eax
,
eax
je
parse_block_while
cmp
BYTE
[
ebx
],
DOLLAR
...
...
@@ -944,11 +892,10 @@ parse_block_if:
;; Get another token and check if it is an else
call
get_token
push
eax
push
str_else
call
strcmp
add
esp
,
8
cmp
eax
,
0
mov
ecx
,
[
eax
]
sub
ecx
,
'else'
or
cl
,
[
eax
+
4
]
test
ecx
,
ecx
je
parse_block_else
;; Not an else: add a symbol for the else label
...
...
@@ -1241,25 +1188,21 @@ parse_loop:
je
parse_ret
;; Jump to the appropriate handler
push
ebx
push
str_fun
call
strcmp
add
esp
,
8
cmp
eax
,
0
cmp
DWORD
[
ebx
],
'
fun
'
je
parse_fun
push
ebx
push
str_ifun
call
strcmp
add
esp
,
8
cmp
eax
,
0
mov
eax
,
[
ebx
]
sub
eax
,
'
ifun
'
or
al
,
[
ebx
+
4
]
test
eax
,
eax
je
parse_ifun
push
ebx
push
str_const
call
strcmp
add
esp
,
8
cmp
eax
,
0
mov
eax
,
[
ebx
]
sub
eax
,
'
cons
'
mov cx, [ebx+4]
sub cx, '
t
'
or
ax
,
cx
test
eax
,
eax
je
parse_const
cmp
BYTE
[
ebx
],
DOLLAR
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment