summary refs log tree commit diff
path: root/05.s
blob: 3ff135ac0b45bca437f944db80be5c37fd57fbac (plain) (blame)
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
86
87
88
89
90
        B setvar


verse	DEFW	2
menmow  DEFB 	" went to mow\n",0
mowdow  DEFB    "Went to mow a meadow\n",0
men     DEFB    "men",0
man     DEFB    "man",0
comma   DEFB    ",",0
nl      DEFB    "\n",0
space   DEFB    " ",0
and_dog DEFB    "and his dog, Spot.",0

        
        ALIGN
setvar  MOV R1, #0
        ADR R2, 5

main    SUB R2, R2, #1

        CMP R2, #0

        BGT versemn

        SWI 2


versemn MOV R0, R2
        SWI 4
        ADR R0, space
        SWI 3
        
        CMP R2, #1
        BEQ sglrvr
        
        ADR R0, men ;
        SWI 3

contvr  ADR R0, menmow
        SWI 3
        
        ADR R0, mowdow
        SWI 3
        
        MOV R3, R2
        B verselp

contin  ADR R0, nl
        SWI 3
        ADR R0, mowdow 
        SWI 3
        ADR R0, nl
        SWI 3

        B main

verselp MOV R0, R3
        SWI 4
        ADR R0, space
        SWI 3
        
        CMP R3, #1
        BEQ singlr

        ADR R0, men
        SWI 3
        ADR R0, comma
        SWI 3

contver ADR R0, space
        SWI 3

        SUB R3, R3, #1
        
        CMP R3, #0
        BEQ contin
        B verselp

singlr  ADR R0, man
        SWI 3
        ADR R0, space
        SWI 3
        ADR R0, and_dog
        SWI 3
    
        B contver

sglrvr  ADR R0, man
        SWI 3
        B contvr