Question: . text . globl init _ interrupts, isr _ handler, isr _ done init _ interrupts: addi sp , sp , - 8 sw ra
text
globl initinterrupts, isrhandler, isrdone
initinterrupts:
addi sp sp
sw rasp
# Print "Initializing Interrupts" message
la a initmsg # Load the message address
jal printString # Call the printString subroutine
# Enable Receiver Interrupt
li tx # Set enable bit
lui txFFFF # Load base address of RCR
sw tt # Write to RCR to enable interrupts
# Enable global interrupts
csrsi mstatus, x # Set MIE bit in mstatus
csrsi mie, x # Enable external interrupts in mie
lw rasp
addi sp sp
ret
isrhandler:
addi sp sp # Allocate stack space
sw rasp # Save return address
sw ssp # Save calleesaved register s
# Step : Check the Ready Bit
lui txFFFF # Load base address of RCR
lw tt # Read Receiver Control Register RCR
andi t tx # Check Ready Bit bit
beqz t isrdone # Exit if no key is ready
# Step : Read the Key Pressed
lw tt # Load the key from Receiver Data Register RDR
mv a t # Move key to a for printing
# Step : Print the Key Pressed
la a keymsg # Load "Key Pressed is: message
jal printString # Print the message
jal printChar # Print the key a contains the key
# Step : Increment Persistent Counter
la s intcount # Load address of counter in memory
lw ts # Load current counter value
addi t t # Increment counter by
sw ts # Store updated counter back to memory
# Step : Restart Main After Key Presses
li t # Compare counter with
bne t t isrdone # Skip if not equal to
sw zero, s # Reset counter to
la t mainstart # Load the start address of main
csrw mepc, t # Modify return address to restart main
isrdone:
lw ssp # Restore calleesaved register
lw rasp # Restore return address
addi sp sp # Deallocate stack space
uret # Return from interrupt
data
KBSR: word xFFFF
RDR: word xFFFF
keymsg: string
Key Pressed is:
initmsg: string
Initializing Interrupts
newline: string
lastkey: word # Persistent storage for last key Error in D:Agnisrasm line column : "mstatus": operand is of incorrect type
Error in D:Agnisrasm line column : "mie": operand is of incorrect type
Error in D:Agnisrasm line column : "mepc": operand is of incorrect type
Assemble: operation completed with errors. I get these errors using rars Example Output
Below is the output of the fully functional program.
Initializing Interrupts
Key Pressed is:
Key Pressed is:
Key Pressed is:
Key Pressed is:
Key Pressed is:
Initializing Interrupts
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
