Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

first.asm:

image text in transcribed

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

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions