From 0429e03ae3db791f38bde32ff79a192de8a223c5 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Wed, 16 Oct 2019 17:47:30 +0100 Subject: Start refractor --- 05.s | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ meadow2018.s | 55 ------------------------------------------------------- 2 files changed, 53 insertions(+), 55 deletions(-) create mode 100644 05.s delete mode 100644 meadow2018.s diff --git a/05.s b/05.s new file mode 100644 index 0000000..a1b5719 --- /dev/null +++ b/05.s @@ -0,0 +1,53 @@ + B start + + +verse DEFW 4 +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 +;4 men went to mow\n +start MOV R1, #0 + MOV R2, #4 + +main ADR R0, verse ; change to R2 + SWI 3 + ADR R0, space + SWI 3 + ADR R0, men + SWI 3 + ADR R0, menmow + +;Went to mow a meadow\n + ADR R0, mowdow + SWI 3 + +;4 men, X men, + ; R2 is the number from 4 to 1 + ADR R0, R2 + SUB R0, R0, R1 + ; down to here it makes sense + CMP R0, #1 ;i need 2 counters + ADD R1, R1, #1 ;increase the substract value + SWI 4 + + BEQ singlr + + B main + + ADR R0, mowdow + SWI 3 + + CMP ; we need to compare n of iterations + smaller than 3 + BLT main + + + SWI 2 diff --git a/meadow2018.s b/meadow2018.s deleted file mode 100644 index dbcd513..0000000 --- a/meadow2018.s +++ /dev/null @@ -1,55 +0,0 @@ - B start - - -verse DEFW 4 -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 -;4 men went to mow\n -start MOV R1, #0 -main ADR R0, verse - SWI 3 - ADR R0, space - SWI 3 - ADR R0, men - SWI 3 - ADR R0, menmow - -;Went to mow a meadow\n - ADR R0, mowdow - SWI 3 - -;4 men, X men, - - - - ADR R0, mowdow - SWI 3 - - ADR R0, verse - SUBS R0, R0, R1 ; SUBS - ADD R1, R1, #1 ;increase the substract value - SWI 4 - - BHI #0 print_plural - BEQ #0 singular - - SWI 2 - - -singular - - - B main - -plural - - B main -- cgit 1.4.1