From 516054084a12b9bffd3596290fdc7b7b59f4ac79 Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Sat, 8 Oct 2016 04:57:04 -0400 Subject: [PATCH] Rearrange assignment files --- MyMult.S | 1 + Makefile => Program/Makefile | 0 Program/MyMult.S | 48 ++++++++++++++++++++++++++++++++++++ main.c => Program/main.c | 0 4 files changed, 49 insertions(+) rename Makefile => Program/Makefile (100%) create mode 100644 Program/MyMult.S rename main.c => Program/main.c (100%) diff --git a/MyMult.S b/MyMult.S index 42ed3b5..762ec9b 100644 --- a/MyMult.S +++ b/MyMult.S @@ -45,3 +45,4 @@ endMyMult: ; Start of EndMyMult Function. RET ; Return from function. ; ------------------------------------------------------------------------------------------------- + diff --git a/Makefile b/Program/Makefile similarity index 100% rename from Makefile rename to Program/Makefile diff --git a/Program/MyMult.S b/Program/MyMult.S new file mode 100644 index 0000000..762ec9b --- /dev/null +++ b/Program/MyMult.S @@ -0,0 +1,48 @@ +; ************************************************************************************************* +; CS2230, Assignment 5, Brandon Rodriguez +; +; Assembly Code for MyMult method. +; Performs multiplication via repeated addition. (Or at least attempts to) +; ************************************************************************************************* + + .file "MyMult.S" ; + .text ; Location of instructions. +.global MyMult ; Create global for linker/loader. + ; Essentially, allows Main.c to detect and read. + +; ------------------------------------------------------------------------------------------------- + +MyMult: ; Start of MyMult Function + ; Basically initialization. + + + MOV.w #0x00, R12 ; Clear R12 by setting value to 0. + MOV.w #0x00, R13 ; Clear R13 by setting value to 0. + JMP addLoop ; Start loop to "multiply" by adding. + +; ------------------------------------------------------------------------------------------------- + +addLoop: ; Start of AddLoop Function. + ; Essentially, this will loop through (times equal to R14). + ; For each loop, adds the value of R15 into R13. + ; When done, will place the "multiplied" value of R13 into R15. + + + ADD.w #0x01, R12 ; Add 1 to R12 for loop counter. + ADD.w R15, R13 ; Add R13 and R15. Value placed into R13. + CMP.w R12, R14 ; Compares R12 and R14. Should be equal if done simulationing mult. + JNE addLoop ; If not equal, go through loop again. Else, proceed. + + MOV.w R13, R15 + JMP endMyMult ; Done multiplying. End function and return. + +; ------------------------------------------------------------------------------------------------- + +endMyMult: ; Start of EndMyMult Function. + ; Return to main. + + + RET ; Return from function. + +; ------------------------------------------------------------------------------------------------- + diff --git a/main.c b/Program/main.c similarity index 100% rename from main.c rename to Program/main.c -- GitLab