Question
Add the following macro in this cs47_macro.asm lwi ($reg, $ui, $li) : This macro takes two 16-bit immediate values $ui and $li and put them
Add the following macro in this cs47_macro.asm
lwi ($reg, $ui, $li) : This macro takes two 16-bit immediate values $ui and $li and put them into higher bits and lower bits of $reg. For example lwi($s1, 0x5a5a, 0xa5a5) will place a value 0x5a5aa5a5 into $s1 register.
Assemble and execute pa03.asm. This should create following sample output
Register S1 contains integer number 1515890085
pa03.asm:
.include "./cs47_macro.asm"
.data msg1: .asciiz "Register S1 contains integer number " newline: .asciiz " "
.text .globl main main: # lui overrides the lower word li $s1, 0xa5a5 lui $s1, 0x5a5a # Macro to load complete word lwi ($s1, 0x5a5a, 0xa5a5) # print the value print_str(msg1) print_reg_int($s1) print_str(newline) exit
cs47_macro.asm:
#<------------------MACRO DEFINITIONS----------------------># # Macro : print_str # Usage: print_str(
) .macro print_str($arg) li $v0, 4 # System call code for print_str la $a0, $arg # Address of the string to print syscall # Print the string .end_macro # Macro : print_int # Usage: print_int(Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started