-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.asm
More file actions
34 lines (29 loc) · 1003 Bytes
/
stack.asm
File metadata and controls
34 lines (29 loc) · 1003 Bytes
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
ZERO K =0 ; Constante 0 utilizada
UM K =1 ; Constante 1 utilizada
DOIS K =2 ; Constante 2 utilizada na implementação da pilha
STACK $ =200 ; Pilha em si
STACK_PTR K DOIS ; Ponteiro para o topo da pilha
TEMP K =0 ; Variavel temporaria
TEMP2 K =0 ; Variavel temporaria secundária
PUSH_TEMP K =0
PUSH_MM MM =0
PUSH K /0000 ; Endereco de retorno
MM PUSH_TEMP ; guarda parametro passado
LD STACK_PTR ; Carrega stack pointer
+ DOIS ; Soma com 2
MM STACK_PTR ; Guarda novo stack pointer
+ PUSH_MM ; Soma com MM
MM PUSH_DO ; Coloca comando de PUSH
LD PUSH_TEMP ; Carrega parametro
PUSH_DO K =0
RS PUSH ; retorna
POP_LD LD =0
POP K /0000 ; Endereco de retorno
LD STACK_PTR ; Carrega stack pointer
+ POP_LD ; Soma com LD
MM POP_DO ; Coloca comando de Pop
LD STACK_PTR ; Carrega stack pointer
- DOIS ; Tira dois
MM STACK_PTR ; Guarda stack pointer
POP_DO K /0000 ; Comando de pop
RS POP ; Retorna