-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescription.txt
87 lines (63 loc) · 3.28 KB
/
description.txt
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
New line characters are instruction delimiters
' is for one-line comments
Push instructions
pushb <ASCII_code> Pushes the character (1 byte) onto the stack
push[i] <int_constant> Pushes the integer literal (2 bytes) onto the stack
pushf <real_constant> Pushes the real number (4 bytes) onto the stack
pusha <int_constant> Pushes the integer address (2 bytes) onto the stack
push[a] bp Pushes the value of the bp register (2 bytes)
Load and store
loadb, load[i], loadf Pop a memory address off the stack (2 bytes).
Then, they push onto the stack the content (1, 2 or 4 bytes) of
the address popped in the previous point
storeb, store[i], storef Pop from the stack 1, 2 or 4 bytes.
Then, they pop from the stack a memory address (2 bytes).
The content of the memory address is replaced with the value
popped in the first step
Popping and duplicating values on the stack
popb, pop[i], popf Pop 1, 2 or 4 bytes, respectively, off the stack
dupb, dup[i], dupf Duplicate the 1, 2 or 4 bytes, respectively, on the top of the stack
Arithmetic operations. They pop two operands, perform the operation and push the result.
add[i], addf For addition
sub[i], subf For subtraction
mul[i], mulf For multiplication
div[i], divf For division
mod[i], modf For modulus
Comparison operations. They pop two operands, perform the operation and push the result.
gt[i], gtf For "greater than" comparison
lt[i], ltf For "lower than" comparison
ge[i], gef For "greater or equal" comparison
le[i], lef For "lower or equal than" comparison
eq[i], eqf For "equal to" comparison
ne[i], nef For "not equal" comparison
Logical operations. Pop one or two operands, perform the operation and push the result.
and For the "and" logical operation
or For the "or" logical operation
not For the unary "not" logical operation
Input / Output
outb, out[i], outf Pop one value off the stack and shows it in the console
inb, in[i], inf Read a value from the keyboard and pushes it onto the stack
Conversions
b2i Pops one character and pushes it as an integer
i2f Pops one integer and pushes it as a real number
f2i Pops one real number and pushes it as an integer
i2b Pops one integer and pushes it as a character
Jumps
<id>: Defines one label for jumps and invocations (functions).
jmp <label> Jumps (unconditionally) to the label specified as a parameter.
jz <label> Pops one integer and jumps to the label if the popped integer is zero.
jnz <label> Pops one integer and jumps to the label if the popped integer is not zero.
Functions
<id>: Defines a label for jumps and invocations (functions)
call <id> Invokes the <id> function
enter <int_constant> Allocates <int_constant> bytes on the top of the stack
ret <int_constant>, Returns from a function invocation.
<int_constant>, The first constant represents the bytes to return;
<int_constant> the second one, the bytes of all the local variables;
and the last one, the bytes of all the arguments.
halt Terminates the program execution
Debugging info
#source <string_constant> Allows the MAPL IDE to associate assembly code
to the high-level source program
#line <INT_CONSTANT> Allows the MAPL IDE to associate the assembly code
corresponding to each high-level statement