Hello, can you adjust the code below so it prints 8 horizontal stripes to the Bitmap display, this is coded using RISC-V. .text main: # set-up trap handler la s0,trap_handler csrw s0,utvec # set utvec = address of the handler # enable processing of interrup requests from timer li s1,0x10 csrw s1,uie # set uie = 0x10 # enable interrupts in CPU csrsi ustatus,1 # set interrupt enable bit in ustatus (0) # ask timer, which is part of Digital Lab Sim tool, # to generate interrupts every 30 instructions # (see Digital Lab Sim help file for detail) li s1, 0xffff0013 li s0, 1 sb s0, 0(s1) j process_1 # start running process_1 # only registers s0-s3 are saved as process context # and can be used by the process code. # --------------------------------------- process_1: li s1,0xffff0010 loop_1: li s0,0x3f sb s0,0(s1) li s0,0x06 sb s0,0(s1) li s0,0x5B sb s0,0(s1) li s0,0x4F sb s0,0(s1) j loop_1 # --------------------------------------- process_2: li s1,0xffff0011 loop_2: li s0,0x3f sb s0,0(s1) li s0,0x06 sb s0,0(s1) li s0,0x5B sb s0,0(s1) li s0,0x4F sb s0,0(s1) j loop_2 # --------------------------------------- trap_handler: # save process context (i.e. CPU registers) into the current trap frame csrw s0,uscratch # copy value of s0 into uscratch temporarily la s0, current_process_trap_frame lw s0, 0(s0) # load address of the current trap_frame into s0 sw s1, 8(s0) # save value of s1 into the trap frame sw s2,12(s0) # save value of s2 into the trap frame sw s3,16(s0) # save value of s3 into the trap frame csrr s1, uscratch # get value of s0 from uscratch into s1 sw s1, 4(s0) # save value of s0 into the trap frame csrr s1, uepc # get value of pc from uepc into s1 sw s1, 0(s0) # save value of pc into the trap frame # switch to the next process lw s1, 20(s0) # load address of the next trap frame to run la s0, current_process_trap_frame sw s1, 0(s0) # save it into the currernt trap frame pointer # restore process context (CPU registers) from the selected trap frame # and continue running mv s0,s1 # address of selected process trap frame in s0 lw s1,0(s0) # saved value of pc in s1 csrw s1,uepc # we put it to uepc for uret to consume lw s1,4(s0) # load saved value of s0 csrw s1,uscratch # put it to uscratch temporarily lw s1,8(s0) # restore saved value of s1 lw s2,12(s0) # restore saved value of s2 lw s3,16(s0) # restore saved value of s3 csrr s0,uscratch # restore s0 from uscratch uret # restore pc from uepc and continue running # selected process .data # Pointer to the trap frame corresponding to the currently running process current_process_trap_frame: .wordtrap_frame_1 # Different trap frames are used for storing contexts of # individual processes trap_frame_1: .word process_1 # pc (trap_frame + 0) - initialise to the starting address .word 0 # s0 (trap_frame + 4) .word 0 # s1 (trap_frame + 8) .word 0 # s2 (trap_frame + 12) .word 0 # s3 (trap_frame + 16) .word trap_frame_2 # next (trap_frame + 20) trap_frame_2: .word process_2 # pc (trap_frame + 0) - initialise to the starting address .word 0 # s0 (trap_frame + 4) .word 0 # s1 (trap_frame + 8) .word 0 # s2 (trap_frame + 12) .word 0 # s3 (trap_frame + 16) .word trap_frame_1 # next (trap_frame + 20)
Hello, can you adjust the code below so it prints 8 horizontal stripes to the Bitmap display, this is coded using RISC-V. .text main: # set-up trap handler la s0,trap_handler csrw s0,utvec # set utvec = address of the handler # enable processing of interrup requests from timer li s1,0x10 csrw s1,uie # set uie = 0x10 # enable interrupts in CPU csrsi ustatus,1 # set interrupt enable bit in ustatus (0) # ask timer, which is part of Digital Lab Sim tool, # to generate interrupts every 30 instructions # (see Digital Lab Sim help file for detail) li s1, 0xffff0013 li s0, 1 sb s0, 0(s1) j process_1 # start running process_1 # only registers s0-s3 are saved as process context # and can be used by the process code. # --------------------------------------- process_1: li s1,0xffff0010 loop_1: li s0,0x3f sb s0,0(s1) li s0,0x06 sb s0,0(s1) li s0,0x5B sb s0,0(s1) li s0,0x4F sb s0,0(s1) j loop_1 # --------------------------------------- process_2: li s1,0xffff0011 loop_2: li s0,0x3f sb s0,0(s1) li s0,0x06 sb s0,0(s1) li s0,0x5B sb s0,0(s1) li s0,0x4F sb s0,0(s1) j loop_2 # --------------------------------------- trap_handler: # save process context (i.e. CPU registers) into the current trap frame csrw s0,uscratch # copy value of s0 into uscratch temporarily la s0, current_process_trap_frame lw s0, 0(s0) # load address of the current trap_frame into s0 sw s1, 8(s0) # save value of s1 into the trap frame sw s2,12(s0) # save value of s2 into the trap frame sw s3,16(s0) # save value of s3 into the trap frame csrr s1, uscratch # get value of s0 from uscratch into s1 sw s1, 4(s0) # save value of s0 into the trap frame csrr s1, uepc # get value of pc from uepc into s1 sw s1, 0(s0) # save value of pc into the trap frame # switch to the next process lw s1, 20(s0) # load address of the next trap frame to run la s0, current_process_trap_frame sw s1, 0(s0) # save it into the currernt trap frame pointer # restore process context (CPU registers) from the selected trap frame # and continue running mv s0,s1 # address of selected process trap frame in s0 lw s1,0(s0) # saved value of pc in s1 csrw s1,uepc # we put it to uepc for uret to consume lw s1,4(s0) # load saved value of s0 csrw s1,uscratch # put it to uscratch temporarily lw s1,8(s0) # restore saved value of s1 lw s2,12(s0) # restore saved value of s2 lw s3,16(s0) # restore saved value of s3 csrr s0,uscratch # restore s0 from uscratch uret # restore pc from uepc and continue running # selected process .data # Pointer to the trap frame corresponding to the currently running process current_process_trap_frame: .wordtrap_frame_1 # Different trap frames are used for storing contexts of # individual processes trap_frame_1: .word process_1 # pc (trap_frame + 0) - initialise to the starting address .word 0 # s0 (trap_frame + 4) .word 0 # s1 (trap_frame + 8) .word 0 # s2 (trap_frame + 12) .word 0 # s3 (trap_frame + 16) .word trap_frame_2 # next (trap_frame + 20) trap_frame_2: .word process_2 # pc (trap_frame + 0) - initialise to the starting address .word 0 # s0 (trap_frame + 4) .word 0 # s1 (trap_frame + 8) .word 0 # s2 (trap_frame + 12) .word 0 # s3 (trap_frame + 16) .word trap_frame_1 # next (trap_frame + 20)
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Hello, can you adjust the code below so it prints 8 horizontal stripes to the Bitmap display, this is coded using RISC-V.
.text
main:
# set-up trap handler
la s0,trap_handler
csrw s0,utvec # set utvec = address of the handler
# enable processing of interrup requests from timer
li s1,0x10
csrw s1,uie # set uie = 0x10
# enable interrupts in CPU
csrsi ustatus,1 # set interrupt enable bit in ustatus (0)
# ask timer, which is part of Digital Lab Sim tool,
# to generate interrupts every 30 instructions
# (see Digital Lab Sim help file for detail)
li s1, 0xffff0013
li s0, 1
sb s0, 0(s1)
j process_1 # start running process_1
# only registers s0-s3 are saved as process context
# and can be used by the process code.
# ---------------------------------------
process_1:
li s1,0xffff0010
loop_1:
li s0,0x3f
sb s0,0(s1)
li s0,0x06
sb s0,0(s1)
li s0,0x5B
sb s0,0(s1)
li s0,0x4F
sb s0,0(s1)
j loop_1
# ---------------------------------------
process_2:
li s1,0xffff0011
loop_2:
li s0,0x3f
sb s0,0(s1)
li s0,0x06
sb s0,0(s1)
li s0,0x5B
sb s0,0(s1)
li s0,0x4F
sb s0,0(s1)
j loop_2
# ---------------------------------------
trap_handler:
# save process context (i.e. CPU registers) into the current trap frame
csrw s0,uscratch # copy value of s0 into uscratch temporarily
la s0, current_process_trap_frame
lw s0, 0(s0) # load address of the current trap_frame into s0
sw s1, 8(s0) # save value of s1 into the trap frame
sw s2,12(s0) # save value of s2 into the trap frame
sw s3,16(s0) # save value of s3 into the trap frame
csrr s1, uscratch # get value of s0 from uscratch into s1
sw s1, 4(s0) # save value of s0 into the trap frame
csrr s1, uepc # get value of pc from uepc into s1
sw s1, 0(s0) # save value of pc into the trap frame
# switch to the next process
lw s1, 20(s0) # load address of the next trap frame to run
la s0, current_process_trap_frame
sw s1, 0(s0) # save it into the currernt trap frame pointer
# restore process context (CPU registers) from the selected trap frame
# and continue running
mv s0,s1 # address of selected process trap frame in s0
lw s1,0(s0) # saved value of pc in s1
csrw s1,uepc # we put it to uepc for uret to consume
lw s1,4(s0) # load saved value of s0
csrw s1,uscratch # put it to uscratch temporarily
lw s1,8(s0) # restore saved value of s1
lw s2,12(s0) # restore saved value of s2
lw s3,16(s0) # restore saved value of s3
csrr s0,uscratch # restore s0 from uscratch
uret # restore pc from uepc and continue running
# selected process
.data
# Pointer to the trap frame corresponding to the currently running process
current_process_trap_frame:
.wordtrap_frame_1
# Different trap frames are used for storing contexts of
# individual processes
trap_frame_1:
.word process_1 # pc (trap_frame + 0) - initialise to the starting address
.word 0 # s0 (trap_frame + 4)
.word 0 # s1 (trap_frame + 8)
.word 0 # s2 (trap_frame + 12)
.word 0 # s3 (trap_frame + 16)
.word trap_frame_2 # next (trap_frame + 20)
trap_frame_2:
.word process_2 # pc (trap_frame + 0) - initialise to the starting address
.word 0 # s0 (trap_frame + 4)
.word 0 # s1 (trap_frame + 8)
.word 0 # s2 (trap_frame + 12)
.word 0 # s3 (trap_frame + 16)
.word trap_frame_1 # next (trap_frame + 20)
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education