Question: Use 'MARS' to Solve the problem: Extend macro.asm to include following two macros: 1. read_int($reg) : To read an integer value from STDIO into given

Use 'MARS' to Solve the problem:

Extend macro.asm to include following two macros:

1. read_int($reg) : To read an integer value from STDIO into given register. For example read_int($t2) will wait for user input for an integer and will store it in register $t2.

2. print_reg_int($reg): To print integer value in given register on STDIO. For example print_reg_int($t2) will print integer value stored in $t2 register on STDIO.

Assemble first.asm (which includes macro.asm) and execute.

The main program should create output on STDIO as following. Please enter a number? 32 You have entered # 32

==============================================================

The given .asm document is as follow:

macro.asm:

Use 'MARS' to Solve the problem: Extend macro.asm to include following two

first.asm:

macros: 1. read_int($reg) : To read an integer value from STDIO into

=================================================================

The final answer should be only one .asm file. Please help, thank you!

------- MACRO DEFINITIONS # Macro : print_str # Usage: print_str(

) .macro print_str($arg) $v0, 4 # System call code for print_str la $al, $arg # Address of the string to print syscall # Print the string .end_macro # Macro : print_int # Usage: print int () .macro print_int($arg) li $v0, 1 # System call code for print int li Sad, Sarg # Integer to print syscall # Print the integer .end_macro # Macro : exit # Usage: exit .macro exit li $v0, 10 syscall .end_macro .include "./macro. asm" N 3 # ---- -- APPLICATION PROGRAM--- 4 # ------ ----- DATA SEGMENT DEFINITION----------- 5 .data 6 msgi: .asciiz "Please enter a number?" 7 msg2: .asciiz "You have entered # " 8 newline: .asciiz " n" 9 # --- ----- CODE SEGMENT DEFINITION- 10 .text 11 .globl main 12 main: print_str(msgl) read_int($t2) print_str(msg2) print_reg_int($t2) print_str(newline) exit ------- MACRO DEFINITIONS # Macro : print_str # Usage: print_str(
) .macro print_str($arg) $v0, 4 # System call code for print_str la $al, $arg # Address of the string to print syscall # Print the string .end_macro # Macro : print_int # Usage: print int () .macro print_int($arg) li $v0, 1 # System call code for print int li Sad, Sarg # Integer to print syscall # Print the integer .end_macro # Macro : exit # Usage: exit .macro exit li $v0, 10 syscall .end_macro .include "./macro. asm" N 3 # ---- -- APPLICATION PROGRAM--- 4 # ------ ----- DATA SEGMENT DEFINITION----------- 5 .data 6 msgi: .asciiz "Please enter a number?" 7 msg2: .asciiz "You have entered # " 8 newline: .asciiz " n" 9 # --- ----- CODE SEGMENT DEFINITION- 10 .text 11 .globl main 12 main: print_str(msgl) read_int($t2) print_str(msg2) print_reg_int($t2) print_str(newline) exit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!