Step 6 Printing inside the exception handler is done by using syscall. However, the code that actually prints a characte
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Step 6 Printing inside the exception handler is done by using syscall. However, the code that actually prints a characte
Step 6 Printing inside the exception handler is done by using syscall. However, the code that actually prints a character on the console is not there. SPIM uses the services of the machine it is running on to do the actual character output or input. We now want to see how it is like to do it, using the bare devices the machine offers. SPIM simulates a mem- ory-mapped terminal connected to the processor. Memory mapped means that accessing some memory locations accesses the I/O devices in reality. Writing to a specific memory location will actually write to an output device, while reading from some specific memory location actually reads from an I/O device. The terminal device SPIM simulates consists of two independent units: the receiver and the transmitter. The receiver reads characters from the keyboard as they are typed. The transmitter unit writes characters to the terminal's display. Both the receiver and the transmitter can work in interrupt mode. At this step, however, you will do something simpler: you will modify the exception handler as to print using the transmitter unit. Modify the exception handler as follows: • write a procedure called PrintString which receives in $a0 the address of the string to print, and returns no value. The string to print is null-terminated • the procedure uses busy-waiting for printing • call 'PrintString' in the exception handler instead of print_str A few hints are probably in place: • you will probably need to save more registers when you enter the exception handler than it does now, save them in kernel data segment • busy waiting means that you have a loop where you test the 'Ready' bit in the Transmitter Control Register until it becomes 1, thus signaling that the output device is ready to accept a new character • start the spim simulator with the -mapped_io flag in the command line • the null symbol is the byte 0x00
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!