; Your Name: ; Partner's Name (if any): ; (Both partner's must also submit a partners.txt file.) ; Date: ; ; Mark the boxes below [ ] by replacing the space with an X as in [X] ; ; [ ] I/we certify...

1 answer below »
This is my electrical computer engineering assignment. I attached two screenshots and one program template related to this assignment. Thank you.


; Your Name: ; Partner's Name (if any): ; (Both partner's must also submit a partners.txt file.) ; Date: ; ; Mark the boxes below [ ] by replacing the space with an X as in [X] ; ; [ ] I/we certify that the code herein is my/our own authorship - ; I/we have not used anyone else's code (in whole of in part) for ; my/our modifications, and I/we have not shared my/our code in ; any form with anyone else. ; ; Complete the subroutines in the following order. ; Mark which subroutine(s) you've successfully completed. ; [ ] 1. subroutine PRINT_DIGIT completed ; [ ] 2. subroutine PRINT_INT completed ; [ ] 3. subroutine MUL completed ; [ ] 4. subroutine CUBED completed ; ; ----------------------------------------------------- ; Copyright (c) 2021 Jim Skrentny - All Rights Reserved ; Posting this publicly is prohibited. ; ----------------------------------------------------- ; .ORIG x3000 BRnzp TEST_BEGIN ; ; STEP 1: PRINT_DIGIT ; ******************* ; Print a single-digit integer N, where N is between 0 and 9 ; ; arguments: in R0 is N ; PRINT_DIGIT ; ************************* Start your code here ************************* RET ; ************************** End your code here ************************** ; ; STEP 2: PRINT_INT ; ***************** ; Print an two-digit integer N followed by a new line character (x000A). ; N is between 0 and 99. For N < 10, the leading 0 should be printed. ; ; this subroutine must call print_digit to print a single digit. ; ; arguments: in r0 is n ; print_int ; ************************* start your code here ************************* ret ; ************************** end your code here ************************** ; ; step 3: mul ; *********** ; subroutine that multiplies two positive integers a * b. ; ; arguments: in r0 is a and in r1 is b ; return value: in r2 will be a * b ; mul ; ************************* start your code here ************************* ret ; ************************** end your code here ************************** ; ; step 4: cubed ; ************* ; subroutine that calculates n ^ 3. ; it must call subroutine mul to do multiplications. ; ; argument: in r0 is n, a positive integer ; return value: in r0 will be n ^ 3 ; cubed ; ************************* start your code here ************************* ret ; ************************** end your code here ************************** ; ************************************************************************ ; *************** do not modify anything below this line ***************** ; ************************************************************************ ; ; main section ; ************ ; do not remove or modify anything in the main section below ; test_begin ; ; ************************* test for print_digit ************************* ; ; initialize the registers for checking callee saving ld r1, init_reg_val ld r2, init_reg_val ld r3, init_reg_val ld r4, init_reg_val ld r5, init_reg_val ld r6, init_reg_val ; print the message lea r0, print_digit_msg puts ; test the print_digit subroutine to print digits from 9 down to 0 and r0, r0, #0 ; r0 stores the digit to print add r0, r0, #9 ; initialize the current digit to 9 print_digit_loop_begin brn print_digit_loop_end ; exit the loop if the digit is below 0 jsr print_digit ; print the current digit add r0, r0, #-1 ; decrement the digit brnzp print_digit_loop_begin print_digit_loop_end ; check if the original values in the registers are preserved ld r0, init_reg_val_neg add r1, r1, r0 brnp print_digit_reg_saving_failed add r2, r2, r0 brnp print_digit_reg_saving_failed add r3, r3, r0 brnp print_digit_reg_saving_failed add r4, r4, r0 brnp print_digit_reg_saving_failed add r5, r5, r0 brnp print_digit_reg_saving_failed add r6, r6, r0 brnp print_digit_reg_saving_failed brnzp test_print_digit_end print_digit_reg_saving_failed lea r0, reg_saving_msg puts test_print_digit_end ; ; ************************** test for print_int ************************** ; ; initialize the registers for checking callee saving ld r1, init_reg_val ld r2, init_reg_val ld r3, init_reg_val ld r4, init_reg_val ld r5, init_reg_val ld r6, init_reg_val ; print the message lea r0, print_int_msg puts ; test the print_int subroutine to print integers from 15 down to 00 and r0, r0, #0 ; r0 is the current integer to pint add r0, r0, #15 ; initialize the current integer to 15 print_int_loop_begin brn print_int_loop_end ; exit the loop if the integer is below 0 jsr print_int ; print the current integer add r0, r0, #-1 ; decrement the integer brnzp print_int_loop_begin print_int_loop_end ; check if the original values in the registers are preserved ld r0, init_reg_val_neg add r1, r1, r0 brnp print_int_reg_saving_failed add r2, r2, r0 brnp print_int_reg_saving_failed add r3, r3, r0 brnp print_int_reg_saving_failed add r4, r4, r0 brnp print_int_reg_saving_failed add r5, r5, r0 brnp print_int_reg_saving_failed add r6, r6, r0 brnp print_int_reg_saving_failed brnzp test_print_int_end print_int_reg_saving_failed lea r0, reg_saving_msg puts test_print_int_end ; ; ***************************** test for mul ***************************** ; ; initialize the registers for checking callee saving ld r3, init_reg_val ld r4, init_reg_val ld r5, init_reg_val ld r6, init_reg_val ; print the message lea r0, mul_msg puts ; test the mul subroutine to multiply two numbers and r0, r0, #0 add r0, r0, #13 ; initialize the first operand to 13 and r1, r1, #0 add r1, r1, #6 ; initialize the second operand to 6 jsr mul ; multiply and store the result in r2 and r0, r2, r2 ; move the result of mul from r2 to r0 jsr print_int ; print the value in r0 ; check if the original values in the registers are preserved ld r0, init_reg_val_neg add r3, r3, r0 brnp mul_reg_saving_failed add r4, r4, r0 brnp mul_reg_saving_failed add r5, r5, r0 brnp mul_reg_saving_failed add r6, r6, r0 brnp mul_reg_saving_failed brnzp test_mul_end mul_reg_saving_failed lea r0, reg_saving_msg puts test_mul_end ; ; **************************** test for cubed **************************** ; ; initialize the registers for checking callee saving ld r1, init_reg_val ld r2, init_reg_val ld r3, init_reg_val ld r4, init_reg_val ld r5, init_reg_val ld r6, init_reg_val ; print the message lea r0, cubed_msg puts ; call the cubed subroutine to cube a number and r0, r0, #0 add r0, r0, #3 ; initialize the operand to 3 jsr cubed ; call cube and store the result in r0 jsr print_int ; print the value in r0 ; check if the original values in the registers are preserved ld r0, init_reg_val_neg add r1, r1, r0 brnp cubed_reg_saving_failed add r2, r2, r0 brnp cubed_reg_saving_failed add r3, r3, r0 brnp cubed_reg_saving_failed add r4, r4, r0 brnp cubed_reg_saving_failed add r5, r5, r0 brnp cubed_reg_saving_failed add r6, r6, r0 brnp cubed_reg_saving_failed brnzp test_cubed_end cubed_reg_saving_failed lea r0, reg_saving_msg puts test_cubed_end test_end halt ; stop the program execution ; ; data section ; ************ ; do not remove or modify anything in the data section ; ; you should not directly use init_reg_val, init_reg_val_neg, or their ; values in your code. ; ; 10,="" the="" leading="" 0="" should="" be="" printed.="" ;="" ;="" this="" subroutine="" must="" call="" print_digit="" to="" print="" a="" single="" digit.="" ;="" ;="" arguments:="" in="" r0="" is="" n="" ;="" print_int="" ;="" *************************="" start="" your="" code="" here="" *************************="" ret="" ;="" **************************="" end="" your="" code="" here="" **************************="" ;="" ;="" step="" 3:="" mul="" ;="" ***********="" ;="" subroutine="" that="" multiplies="" two="" positive="" integers="" a="" *="" b.="" ;="" ;="" arguments:="" in="" r0="" is="" a="" and="" in="" r1="" is="" b="" ;="" return="" value:="" in="" r2="" will="" be="" a="" *="" b="" ;="" mul="" ;="" *************************="" start="" your="" code="" here="" *************************="" ret="" ;="" **************************="" end="" your="" code="" here="" **************************="" ;="" ;="" step="" 4:="" cubed="" ;="" *************="" ;="" subroutine="" that="" calculates="" n="" ^="" 3.="" ;="" it="" must="" call="" subroutine="" mul="" to="" do="" multiplications.="" ;="" ;="" argument:="" in="" r0="" is="" n,="" a="" positive="" integer="" ;="" return="" value:="" in="" r0="" will="" be="" n="" ^="" 3="" ;="" cubed="" ;="" *************************="" start="" your="" code="" here="" *************************="" ret="" ;="" **************************="" end="" your="" code="" here="" **************************="" ;="" ************************************************************************="" ;="" ***************="" do="" not="" modify="" anything="" below="" this="" line="" *****************="" ;="" ************************************************************************="" ;="" ;="" main="" section="" ;="" ************="" ;="" do="" not="" remove="" or="" modify="" anything="" in="" the="" main="" section="" below="" ;="" test_begin="" ;="" ;="" *************************="" test="" for="" print_digit="" *************************="" ;="" ;="" initialize="" the="" registers="" for="" checking="" callee="" saving="" ld="" r1,="" init_reg_val="" ld="" r2,="" init_reg_val="" ld="" r3,="" init_reg_val="" ld="" r4,="" init_reg_val="" ld="" r5,="" init_reg_val="" ld="" r6,="" init_reg_val="" ;="" print="" the="" message="" lea="" r0,="" print_digit_msg="" puts="" ;="" test="" the="" print_digit="" subroutine="" to="" print="" digits="" from="" 9="" down="" to="" 0="" and="" r0,="" r0,="" #0="" ;="" r0="" stores="" the="" digit="" to="" print="" add="" r0,="" r0,="" #9="" ;="" initialize="" the="" current="" digit="" to="" 9="" print_digit_loop_begin="" brn="" print_digit_loop_end="" ;="" exit="" the="" loop="" if="" the="" digit="" is="" below="" 0="" jsr="" print_digit="" ;="" print="" the="" current="" digit="" add="" r0,="" r0,="" #-1="" ;="" decrement="" the="" digit="" brnzp="" print_digit_loop_begin="" print_digit_loop_end="" ;="" check="" if="" the="" original="" values="" in="" the="" registers="" are="" preserved="" ld="" r0,="" init_reg_val_neg="" add="" r1,="" r1,="" r0="" brnp="" print_digit_reg_saving_failed="" add="" r2,="" r2,="" r0="" brnp="" print_digit_reg_saving_failed="" add="" r3,="" r3,="" r0="" brnp="" print_digit_reg_saving_failed="" add="" r4,="" r4,="" r0="" brnp="" print_digit_reg_saving_failed="" add="" r5,="" r5,="" r0="" brnp="" print_digit_reg_saving_failed="" add="" r6,="" r6,="" r0="" brnp="" print_digit_reg_saving_failed="" brnzp="" test_print_digit_end="" print_digit_reg_saving_failed="" lea="" r0,="" reg_saving_msg="" puts="" test_print_digit_end="" ;="" ;="" **************************="" test="" for="" print_int="" **************************="" ;="" ;="" initialize="" the="" registers="" for="" checking="" callee="" saving="" ld="" r1,="" init_reg_val="" ld="" r2,="" init_reg_val="" ld="" r3,="" init_reg_val="" ld="" r4,="" init_reg_val="" ld="" r5,="" init_reg_val="" ld="" r6,="" init_reg_val="" ;="" print="" the="" message="" lea="" r0,="" print_int_msg="" puts="" ;="" test="" the="" print_int="" subroutine="" to="" print="" integers="" from="" 15="" down="" to="" 00="" and="" r0,="" r0,="" #0="" ;="" r0="" is="" the="" current="" integer="" to="" pint="" add="" r0,="" r0,="" #15="" ;="" initialize="" the="" current="" integer="" to="" 15="" print_int_loop_begin="" brn="" print_int_loop_end="" ;="" exit="" the="" loop="" if="" the="" integer="" is="" below="" 0="" jsr="" print_int="" ;="" print="" the="" current="" integer="" add="" r0,="" r0,="" #-1="" ;="" decrement="" the="" integer="" brnzp="" print_int_loop_begin="" print_int_loop_end="" ;="" check="" if="" the="" original="" values="" in="" the="" registers="" are="" preserved="" ld="" r0,="" init_reg_val_neg="" add="" r1,="" r1,="" r0="" brnp="" print_int_reg_saving_failed="" add="" r2,="" r2,="" r0="" brnp="" print_int_reg_saving_failed="" add="" r3,="" r3,="" r0="" brnp="" print_int_reg_saving_failed="" add="" r4,="" r4,="" r0="" brnp="" print_int_reg_saving_failed="" add="" r5,="" r5,="" r0="" brnp="" print_int_reg_saving_failed="" add="" r6,="" r6,="" r0="" brnp="" print_int_reg_saving_failed="" brnzp="" test_print_int_end="" print_int_reg_saving_failed="" lea="" r0,="" reg_saving_msg="" puts="" test_print_int_end="" ;="" ;="" *****************************="" test="" for="" mul="" *****************************="" ;="" ;="" initialize="" the="" registers="" for="" checking="" callee="" saving="" ld="" r3,="" init_reg_val="" ld="" r4,="" init_reg_val="" ld="" r5,="" init_reg_val="" ld="" r6,="" init_reg_val="" ;="" print="" the="" message="" lea="" r0,="" mul_msg="" puts="" ;="" test="" the="" mul="" subroutine="" to="" multiply="" two="" numbers="" and="" r0,="" r0,="" #0="" add="" r0,="" r0,="" #13="" ;="" initialize="" the="" first="" operand="" to="" 13="" and="" r1,="" r1,="" #0="" add="" r1,="" r1,="" #6="" ;="" initialize="" the="" second="" operand="" to="" 6="" jsr="" mul="" ;="" multiply="" and="" store="" the="" result="" in="" r2="" and="" r0,="" r2,="" r2="" ;="" move="" the="" result="" of="" mul="" from="" r2="" to="" r0="" jsr="" print_int="" ;="" print="" the="" value="" in="" r0="" ;="" check="" if="" the="" original="" values="" in="" the="" registers="" are="" preserved="" ld="" r0,="" init_reg_val_neg="" add="" r3,="" r3,="" r0="" brnp="" mul_reg_saving_failed="" add="" r4,="" r4,="" r0="" brnp="" mul_reg_saving_failed="" add="" r5,="" r5,="" r0="" brnp="" mul_reg_saving_failed="" add="" r6,="" r6,="" r0="" brnp="" mul_reg_saving_failed="" brnzp="" test_mul_end="" mul_reg_saving_failed="" lea="" r0,="" reg_saving_msg="" puts="" test_mul_end="" ;="" ;="" ****************************="" test="" for="" cubed="" ****************************="" ;="" ;="" initialize="" the="" registers="" for="" checking="" callee="" saving="" ld="" r1,="" init_reg_val="" ld="" r2,="" init_reg_val="" ld="" r3,="" init_reg_val="" ld="" r4,="" init_reg_val="" ld="" r5,="" init_reg_val="" ld="" r6,="" init_reg_val="" ;="" print="" the="" message="" lea="" r0,="" cubed_msg="" puts="" ;="" call="" the="" cubed="" subroutine="" to="" cube="" a="" number="" and="" r0,="" r0,="" #0="" add="" r0,="" r0,="" #3="" ;="" initialize="" the="" operand="" to="" 3="" jsr="" cubed="" ;="" call="" cube="" and="" store="" the="" result="" in="" r0="" jsr="" print_int="" ;="" print="" the="" value="" in="" r0="" ;="" check="" if="" the="" original="" values="" in="" the="" registers="" are="" preserved="" ld="" r0,="" init_reg_val_neg="" add="" r1,="" r1,="" r0="" brnp="" cubed_reg_saving_failed="" add="" r2,="" r2,="" r0="" brnp="" cubed_reg_saving_failed="" add="" r3,="" r3,="" r0="" brnp="" cubed_reg_saving_failed="" add="" r4,="" r4,="" r0="" brnp="" cubed_reg_saving_failed="" add="" r5,="" r5,="" r0="" brnp="" cubed_reg_saving_failed="" add="" r6,="" r6,="" r0="" brnp="" cubed_reg_saving_failed="" brnzp="" test_cubed_end="" cubed_reg_saving_failed="" lea="" r0,="" reg_saving_msg="" puts="" test_cubed_end="" test_end="" halt="" ;="" stop="" the="" program="" execution="" ;="" ;="" data="" section="" ;="" ************="" ;="" do="" not="" remove="" or="" modify="" anything="" in="" the="" data="" section="" ;="" ;="" you="" should="" not="" directly="" use="" init_reg_val,="" init_reg_val_neg,="" or="" their="" ;="" values="" in="" your="" code.="" ;="">
Answered 8 days AfterDec 02, 2021

Answer To: ; Your Name: ; Partner's Name (if any): ; (Both partner's must also submit a partners.txt file.) ;...

Darshan answered on Dec 10 2021
119 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here