forked from mathewmariani/MARIE-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtolower.mas
49 lines (44 loc) · 1.01 KB
/
tolower.mas
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
/ This program presents a simple tolower(ptr) function.
/ #L8-9 Sets the argument `str_ptr` for the tolower function.
/ #L10 Calls the tolower function.
/ #L27 Adds the offset between upper and lower case letters on ascii table.
/ 0x41 ('A') 0x61 ('a') --> 0x20
ORG 0
LOAD str_ptr
STORE tolower_ptr
JNS tolower
HALT
tolower_itr, DEC 0
tolower_ptr, HEX 0
tolower_idx, HEX 0
tolower_offset, HEX 20
tolower, HEX 0
tolower_while, LOAD tolower_ptr
ADD tolower_itr
STORE tolower_idx
CLEAR
ADDI tolower_idx
SKIPCOND 400
JUMP tolower_do
JUMPI tolower
tolower_do, ADD tolower_offset
OUTPUT
LOAD tolower_itr
ADD ONE
STORE tolower_itr
JUMP tolower_while
str_ptr, HEX 18 / memory location of str
str, HEX 48 / H
HEX 45 / E
HEX 4C / L
HEX 4C / L
HEX 4F / O
HEX D / carriage return
HEX 57 / W
HEX 4F / O
HEX 52 / R
HEX 4C / L
HEX 44 / D
HEX 0 / NULL char
/ constants
ONE, DEC 1