Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MUST BE IN MIPS-32 ASSEMBLY LANGUAGE. Part (b): Write the procedure morse_flash morse_flash: parameters: one byte contained in the $a0 register return value: none Later
MUST BE IN MIPS-32 ASSEMBLY LANGUAGE.
Part (b): Write the procedure morse_flash morse_flash: parameters: one byte contained in the $a0 register return value: none Later in part (d) of this assignment, you will write code to convert dots and dashes for a letter (e.g., ... for 'S', and ... for O') into a one-byte equivalent. For now, however, you are to write a procedure that takes a one-byte equivalent (passed into the procedure as the least-significant byte in a 32-bit register) and flashes the Digital Lab Sim display in a manner appropriate to the contents of that byte. The procedure does not need to know the letter to be flashed; all it needs is the byte itself Below are examples of dot-dash sequences beside their one-byte equivalents (shown binary and hexadecimal notation): Ob01000010 Ox42 Ob00110111 Ox37 Ob00110010 Ox32 Ob00010001 Ox11 Each byte consists of a high nybble and a low nybble: The high nybble (left-most four bits) encodes the length of the sequence. The low nybble (right-most four bits) encodes the dot-dash sequence itself (where 0 is a "dot" and 1 is a "dash"). In the first example above (the Morse for 'F'), the high nybble encodes the number 4 (i.e., the length of the sequence), and the low nybble contains that sequence (0,0,1, 0). In the last example (the Morse for 'T'), the high nybble encodes the number 1 (i.e., the length of the sequence), and the low nybble contains that sequence (first three Os are ignored, while last 1 is the dash). Notice that the low-nybble bits for sequences of length three, two and one will contain leading zeros; these leading zeros must be ignored i.e., they are not dots). The one-byte equivalent is to be turned into a series of calls to seven_segment_on and seven_segment_off, with a delay between calls visually distinguishing dots from dashes. This is to be done in a manner shown in the diagram provided in the save_our_souls section of this description. There is a special one-byte value: Oxff. It represents a space between words. For this, morse_flash must keep the display off for three calls to delay_long. ## morse flash test for part B # addi $a0, szero, 0x42 # dot dot dash dot # jal morse flash ## morse_flash test for part B # addi $a0, szero, 0x37 # dash dash dash # jal morse flash ## morse_flash test for part B # addi $a0, szero, 0x32 # jal morse_flash # dot dash dot ## morse_flash test for part B # addi $a0, szero, 0x11 # dash # jal morse flash # PROCEDURE seven_segment_on: la $t1, Oxffff0010 addi $t2, $zero, Oxff sb $t2, 0($tl) jr $31 # location of bits for right digit # All bits in byte are set, turning on all segments # "Make it so!" # PROCEDURE seven_segment_off: la $t1, Oxffff0010 sb $zero, 01$t1) jr $31 # location of bits for right digit # All bits in byte are unset, turning off all segments # "Make it so!" # Reserve # PROCEDURE delay_long: add $sp,$sp, -4 sw $a0, 0($sp) addi $al, szero, 600 addi $v0, $zero, 32 syscall lw $a0, 0($sp) add $sp,$sp, 4 jr $31 # PROCEDURE delay_short: add $sp,$sp, -4 sw $a0, 0($sp) addi $al, $zero, 200 addi $v0, $zero, 32 syscall lw $al, 01$sp) add $sp,$sp,4 jr $31 Part (b): Write the procedure morse_flash morse_flash: parameters: one byte contained in the $a0 register return value: none Later in part (d) of this assignment, you will write code to convert dots and dashes for a letter (e.g., ... for 'S', and ... for O') into a one-byte equivalent. For now, however, you are to write a procedure that takes a one-byte equivalent (passed into the procedure as the least-significant byte in a 32-bit register) and flashes the Digital Lab Sim display in a manner appropriate to the contents of that byte. The procedure does not need to know the letter to be flashed; all it needs is the byte itself Below are examples of dot-dash sequences beside their one-byte equivalents (shown binary and hexadecimal notation): Ob01000010 Ox42 Ob00110111 Ox37 Ob00110010 Ox32 Ob00010001 Ox11 Each byte consists of a high nybble and a low nybble: The high nybble (left-most four bits) encodes the length of the sequence. The low nybble (right-most four bits) encodes the dot-dash sequence itself (where 0 is a "dot" and 1 is a "dash"). In the first example above (the Morse for 'F'), the high nybble encodes the number 4 (i.e., the length of the sequence), and the low nybble contains that sequence (0,0,1, 0). In the last example (the Morse for 'T'), the high nybble encodes the number 1 (i.e., the length of the sequence), and the low nybble contains that sequence (first three Os are ignored, while last 1 is the dash). Notice that the low-nybble bits for sequences of length three, two and one will contain leading zeros; these leading zeros must be ignored i.e., they are not dots). The one-byte equivalent is to be turned into a series of calls to seven_segment_on and seven_segment_off, with a delay between calls visually distinguishing dots from dashes. This is to be done in a manner shown in the diagram provided in the save_our_souls section of this description. There is a special one-byte value: Oxff. It represents a space between words. For this, morse_flash must keep the display off for three calls to delay_long. ## morse flash test for part B # addi $a0, szero, 0x42 # dot dot dash dot # jal morse flash ## morse_flash test for part B # addi $a0, szero, 0x37 # dash dash dash # jal morse flash ## morse_flash test for part B # addi $a0, szero, 0x32 # jal morse_flash # dot dash dot ## morse_flash test for part B # addi $a0, szero, 0x11 # dash # jal morse flash # PROCEDURE seven_segment_on: la $t1, Oxffff0010 addi $t2, $zero, Oxff sb $t2, 0($tl) jr $31 # location of bits for right digit # All bits in byte are set, turning on all segments # "Make it so!" # PROCEDURE seven_segment_off: la $t1, Oxffff0010 sb $zero, 01$t1) jr $31 # location of bits for right digit # All bits in byte are unset, turning off all segments # "Make it so!" # Reserve # PROCEDURE delay_long: add $sp,$sp, -4 sw $a0, 0($sp) addi $al, szero, 600 addi $v0, $zero, 32 syscall lw $a0, 0($sp) add $sp,$sp, 4 jr $31 # PROCEDURE delay_short: add $sp,$sp, -4 sw $a0, 0($sp) addi $al, $zero, 200 addi $v0, $zero, 32 syscall lw $al, 01$sp) add $sp,$sp,4 jr $31Step 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