-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterpreter.asm
50 lines (36 loc) · 1.11 KB
/
interpreter.asm
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
%include "util.inc"
global _start
%define pc r15
%define w r14
%define rstack r13
;----------------------------------
section .text
%include "core-functions.asm"
;----------------------------------
section .data
not_found: db "Unknown command: ", 0
program_stub: dq xt_selector ; here will be word to interpret
last_word: dq _lw ; pointer to the last word
here: dq dict ; current position in words memory
pointer: dq mem ; current global data pointer
stack_start: dq 0 ; start of data stack
;----------------------------------
section .bss
resq 1023
rstack_start: resq 1 ; return adress stack
dict: resq 65536 ; dynamic part of dictionary
mem: resq 65536 ; user data
state: resq 1 ; 1 if compiling, 0 otherwise
input_buf: resb 1024 ; for user input
;----------------------------------
section .text
_start:
mov rstack, rstack_start
mov [stack_start], rsp
mov pc, program_stub
jmp next
next:
mov w, pc
add pc, 8
mov w, [w]
jmp [w]