/* ******************************************************************************** * ECE 2045 Lab 3 Part3 Template * This program displays a decimal digit on the 7-segment display HEX0. * Pressing a KEY has the following result: * KEY 0. sets the display to 0 * KEY 1. increments the displayed number * KEY 2. decrements the displayed number * KEY 3. sets the display to be "blank" ********************************************************************************/ .text .global _start _start: MOV R4, #0 // counter value to be displayed on HEX0 LDR R5, =0xFF200050 // base address of KEY pushbuttons LDR R6, =0xFF200020 // base address of HEX3_HEX0 7-segs STR R4, [R6] // clear the display /* Continue your code from here; * Call the subroutine SEG7_CODE to show a decimal digit on HEX0 */ /* End your code here */ /* Subroutine to convert the digits from 0 to 9, or blank, to be shown on a HEX display. * Parameters: R0 = the decimal value of the digit to be displayed * Returns: R0 = bit patterm to be written to the HEX display */ SEG7_CODE: MOV R1, #0 // blank DISPLAY0: CMP R0, #0 BNE DISPLAY1 MOV R1, #0b0111111 // 0 B END_SEG7 DISPLAY1: CMP R0, #1 BNE DISPLAY2 MOV R1, #0b0000110 // 1 B END_SEG7 DISPLAY2: CMP R0, #2 BNE DISPLAY3 MOV R1, #0b1011011 // 2 B END_SEG7 DISPLAY3: CMP R0, #3 BNE DISPLAY4 MOV R1, #0b1001111 // 3 B END_SEG7 DISPLAY4: CMP R0, #4 BNE DISPLAY5 MOV R1, #0b1100110 // 4 B END_SEG7 DISPLAY5: CMP R0, #5 BNE DISPLAY6 MOV R1, #0b1101101 // 5 B END_SEG7 DISPLAY6: CMP R0, #6 BNE DISPLAY7 MOV R1, #0b1111101 // 6 B END_SEG7 DISPLAY7: CMP R0, #7 BNE DISPLAY8 MOV R1, #0b0000111 // 7 B END_SEG7 DISPLAY8: CMP R0, #8 BNE DISPLAY9 MOV R1, #0b1111111 // 8 B END_SEG7 DISPLAY9: CMP R0, #9 BNE END_SEG7 MOV R1, #0b1100111 // 9 END_SEG7: MOV R0, R1 // return bit pattern BX LR .end