-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello_world.myvm
34 lines (31 loc) · 988 Bytes
/
hello_world.myvm
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
program: macro output_literal(%literal): // I am a comment at the end of a macro definition
%literal mov 0 out end_macro: macro print_positive_offset(%offset): print_offset(%offset, add) end_macro: macro print_negative_offset(%offset): print_offset(%offset, sub) end_macro: macro print_offset(%offset, %pos_or_neg): mov 3 1 %offset mov 0 2 %pos_or_neg mov 3 out end_macro:
// 63 is biggest literal value we can load, we still need to add 9 to get to H
63
mov 0 3
// H
print_positive_offset(9)
// E
print_negative_offset(3)
// L
print_positive_offset(7)
// L
mov 3 out
// O
print_positive_offset(3)
// WHITESPACE
32
mov 0 out
// W
print_positive_offset(8)
// O
print_negative_offset(8)
// R
print_positive_offset(3)
// L
print_negative_offset(6)
// D
print_negative_offset(8)
// !
exclamation_mark = 33
output_literal(exclamation_mark)