summary refs log tree commit diff
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-10-16 19:19:31 +0100
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-10-16 19:19:31 +0100
commit87f86ba6217c4dfdcbc7b31885b491301be832c9 (patch)
treec54ad38f96188f119b0a69a302f4231ebf6ec155
parentcommit (diff)
downloadArm_Programming-87f86ba6217c4dfdcbc7b31885b491301be832c9.tar.gz
Arm_Programming-87f86ba6217c4dfdcbc7b31885b491301be832c9.tar.bz2
Arm_Programming-87f86ba6217c4dfdcbc7b31885b491301be832c9.zip
Finish exercise 5 HEAD master
-rw-r--r--05.s93
1 files changed, 62 insertions, 31 deletions
diff --git a/05.s b/05.s
index 3ac556f..3ff135a 100644
--- a/05.s
+++ b/05.s
@@ -1,59 +1,90 @@
-        B start
+        B setvar
 
 
-verse	DEFW	4
-menmow  DEFB 	"went to mow\n",0
+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
+and_dog DEFB    "and his dog, Spot.",0
 
         
         ALIGN
-start   MOV R1, #0
-        MOV R2, #4
+setvar  MOV R1, #0
+        ADR R2, 5
 
-;4 men went to mow
 main    SUB R2, R2, #1
-	ADR R0, R2
-        SWI 3
+
+        CMP R2, #0
+
+        BGT versemn
+
+        SWI 2
+
+
+versemn MOV R0, R2
+        SWI 4
         ADR R0, space
         SWI 3
-        ADR R0, men
+        
+        CMP R2, #1
+        BEQ sglrvr
+        
+        ADR R0, men ;
         SWI 3
-        ADR R0, menmow
 
-;Went to mow a meadow\n
+contvr  ADR R0, menmow
+        SWI 3
+        
         ADR R0, mowdow
         SWI 3
+        
+        MOV R3, R2
+        B verselp
 
-;4 men, X men,
-        ; R2 is the number from 4 to 1
-        ADR R0, R2
-        SUB R0, R0, R1
-        CMP R0, #1 ;i need 2 counters
-        ADD R1, R1, #1 ;increase the substract value
-        SWI 4
-       	 
-        BEQ singlr
+contin  ADR R0, nl
+        SWI 3
+        ADR R0, mowdow 
+        SWI 3
+        ADR R0, nl
+        SWI 3
 
-	ADR R0, men
-	SWI 3
-        
         B main
 
-        ADR R0, mowdow
+verselp MOV R0, R3
+        SWI 4
+        ADR R0, space
         SWI 3
         
-        CMP R2, #4
-        BST main
+        CMP R3, #1
+        BEQ singlr
+
+        ADR R0, men
+        SWI 3
+        ADR R0, comma
+        SWI 3
 
-        SWI 2  
+contver ADR R0, space
+        SWI 3
+
+        SUB R3, R3, #1
+        
+        CMP R3, #0
+        BEQ contin
+        B verselp
 
 singlr  ADR R0, man
-	SWI 3
-	
-	B main
+        SWI 3
+        ADR R0, space
+        SWI 3
+        ADR R0, and_dog
+        SWI 3
+    
+        B contver
+
+sglrvr  ADR R0, man
+        SWI 3
+        B contvr