Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
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
d1cf23ba
Unverified
Commit
d1cf23ba
authored
Mar 10, 2019
by
Giovanni Mascellani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite push_var.
parent
77c6d1c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
65 deletions
+53
-65
asmg/asmg.asm
asmg/asmg.asm
+40
-57
lib/library.asm
lib/library.asm
+13
-8
No files found.
asmg/asmg.asm
View file @
d1cf23ba
...
...
@@ -21,7 +21,7 @@
section
.data
TEMP_VAR:
db
'_
_temp
'
db
'_'
db
0
section
.bss
...
...
@@ -100,37 +100,35 @@ write_label_loop:
ret
;; Input in EDX (variable name) and ECX (is temporary)
;; Destroys: EAX
push_var:
;; Check the var name length
mov
eax
,
[
esp
+
4
]
push
eax
call
strlen
add
esp
,
4
cmp
eax
,
0
jna
platform_panic
cmp
eax
,
MAX_SYMBOL_NAME_LEN
jnb
platform_panic
push
esi
push
edi
;; Check input length
mov
esi
,
edx
call
ch
eck_symbol_length
;; Check we are not overflowing the stack
mov
e
ax
,
[
stack_depth
]
cmp
e
ax
,
STACK_VARS_LEN
mov
e
di
,
[
stack_depth
]
cmp
e
di
,
STACK_VARS_LEN
jnb
platform_panic
;; Copy the variable name in the stack
shl
eax
,
MAX_SYMBOL_NAME_LEN_LOG
add
eax
,
[
stack_vars_ptr
]
mov
edx
,
eax
mov
eax
,
[
esp
+
4
]
push
eax
push
edx
call
strcpy
add
esp
,
8
shl
edi
,
MAX_SYMBOL_NAME_LEN_LOG
add
edi
,
[
stack_vars_ptr
]
mov
esi
,
edx
call
strcpy2
;; Increment the stack depth
inc
DWORD
[
stack_depth
]
pop
edi
pop
esi
;; If this is a temp var, increment also temp_depth
cmp
DWORD
[
esp
+
8
],
0
test
ecx
,
ecx
je
push_var_non_temp
inc
DWORD
[
temp_depth
]
ret
...
...
@@ -333,7 +331,6 @@ get_token_string_end:
;; Put the closing apex or quote and return
mov
[
ecx
],
al
inc
ecx
jmp
get_token_ret
get_token_ret:
;; Put the terminator and return the buffer's address
...
...
@@ -514,10 +511,9 @@ push_expr:
jne
platform_panic
;; Emit the code
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
mov
cl
,
0x68
; push ??
call
emit
mov
ecx
,
ebx
...
...
@@ -542,10 +538,9 @@ push_expr_stack:
jne
push_expr_stack_addr
;; We want the value, emit the code
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
mov
ecx
,
0x24b4ff
; push [esp+??]
call
emit24
mov
ecx
,
ebx
...
...
@@ -555,10 +550,9 @@ push_expr_stack:
push_expr_stack_addr:
;; We want the address, emit the code
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
mov
ecx
,
0x24848d
; lea eax, [esp+??]
call
emit24
mov
ecx
,
ebx
...
...
@@ -625,19 +619,17 @@ push_expr_symbol_loop:
jmp
push_expr_symbol_loop
push_expr_symbol_loop_end:
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
jmp
push_expr_ret
push_expr_addr:
;; We want the address, emit the code
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
mov
cl
,
0x68
; push ??
call
emit
mov
ecx
,
ebx
...
...
@@ -647,10 +639,9 @@ push_expr_addr:
push_expr_val:
;; We want the value, emit the code
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
mov
cl
,
0xb8
; mov eax, ??
call
emit
mov
ecx
,
ebx
...
...
@@ -719,10 +710,9 @@ push_expr_until_brace_string:
call
add_symbol_label
;; Emit code to push the string label
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
mov
cl
,
0x68
; push ??
call
emit
mov
edx
,
edi
...
...
@@ -987,16 +977,11 @@ parse_block_while:
jmp
parse_block_loop
parse_block_alloc:
;; Skip to following char and check it is not a terminator
add
ebx
,
1
cmp
BYTE
[
ebx
],
0
je
platform_panic
;; Call push_var
push
0
push
ebx
inc
ebx
mov
ecx
,
0
mov
edx
,
ebx
call
push_var
add
esp
,
8
;; Emit code
mov
ecx
,
0x04ec83
; sub esp, 4
...
...
@@ -1049,10 +1034,9 @@ parse_block_call_loop:
parse_block_call_end:
;; Emit code to push the return value
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
mov
cl
,
0x50
; push eax
call
emit
...
...
@@ -1091,10 +1075,9 @@ parse_block_string:
call
add_symbol_label
;; Emit code to push the string label
push
1
push
TEMP_VAR
mov
ecx
,
1
mov
edx
,
TEMP_VAR
call
push_var
add
esp
,
8
mov
cl
,
0x68
; push ??
call
emit
mov
edx
,
edi
...
...
lib/library.asm
View file @
d1cf23ba
...
...
@@ -295,24 +295,29 @@ find_symbol_or_zero:
ret
;; Input in ESI
;; Destroys: EAX
check_symbol_length:
call
strlen2
cmp
eax
,
0
jna
platform_panic
cmp
eax
,
MAX_SYMBOL_NAME_LEN
-
1
jnb
platform_panic
ret
;; Input in EAX (name), ECX (loc) and EDX (arity)
;; Destroys: EAX, ECX, EDX
add_symbol:
push
esi
push
edi
;; Call strlen
push
edx
push
ecx
push
eax
mov
esi
,
eax
call
strlen2
;; Check input length
cmp
eax
,
0
jna
platform_panic
cmp
eax
,
MAX_SYMBOL_NAME_LEN
-
1
jnb
platform_panic
mov
esi
,
eax
call
ch
eck_symbol_length
;; Call find_symbol and check the symbol does not exist yet
pop
edx
...
...
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