diff --git a/MyMult.S b/MyMult.S index 42ed3b57ad74b1d3802c563e5833c18f0746d17c..762ec9b161b3fc63a052e48125e25652e0c23558 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 0000000000000000000000000000000000000000..762ec9b161b3fc63a052e48125e25652e0c23558 --- /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