Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with a project for my comp science class and this must be in arm ass

ID: 3780266 • Letter: I

Question

I need help with a project for my comp science class and this must be in arm assembly language. Here is the requirements and the code I have got so far but I couldnt get it to work. If possible, please provide a full working code in arm assembly language. Thank you.

Safe Control

Program the control unit for an electronic safe. Each time an input key is pressed, the red LEDs should blink to indicate that a key is pressed.

For example:

1. If any of the blue keypad keys is pressed both red LEDs must blink.

2. If the left black button is pressed the left red LED must blink

3. If the right black button is pressed the right red LED must blink.

To distinguish the output letter from numbers on eight segment LEDs, you must display the period (“.”) segment. For example, an output of the letter “B” should also have the period displayed but an output of the number “8” should not display a period. The 8-Segment display and LEDs will show the status of the safe:

U: unlocked
L: locked
P: programming a code
C: confirming a new code
F: forgetting an old code
A: a programming request was successful
E: programming fault.

The safe starts unlocked. The safe cannot be locked if there are no valid codes.

To lock the safe (this should work at ANY time):
1. press the left black button (assuming you have valid code).

To unlock the safe (This should work ONLY when the safe is locked):
1. Enter a valid code sequence
2. Press the left black button.

To learn a new code (codes must be 4 to 7 hexadecimal digits (buttons) inclusive, and the first digit of the code represents a unique user i.e. no two users can have the same first digit):

1. Press the right black button once
2. 8-segment should show 'P'
3. Enter a new code sequence
4. Press the right black button again.
5. 8-segment should show 'C'
6. Enter the same code sequence
7. Press the right black button a third time.
8. If the code was correct 8-segment displays 'A'
9. If the code was incorrect 8-segment display 'E'

To forget an old code:
1. Press the right black button
2. 8-segment should show 'P'
3. Enter an old code sequence
4. Press the right black button again.
5. 8-segment should show 'F'
6. Enter the same code sequence
7. Press the right black button a third time
8. If the codes match 8-segment displays 'A'
9. If the codes did not match 8-segment displays 'E'

Code:

.equ SWI_SETSEG8, 0x200 @display on 8 Segment
.equ SWI_SETLED, 0x201 @LEDs on/off
.equ SWI_CheckBlack, 0x202 @check Black button
.equ SWI_CheckBlue, 0x203 @check press Blue button
.equ SWI_EXIT, 0x11 @terminate program
.equ SWI_GetTicks, 0x6d @get current time
.equ SEG_A, 0x80 @patterns for 8 segment display
.equ SEG_B, 0x40 @byte values for each segment
.equ SEG_C, 0x20 @of the 8 segment display
.equ SEG_D, 0x08
.equ SEG_E, 0x04
.equ SEG_F, 0x02
.equ SEG_G, 0x01
.equ ItsUnlocked, SEG_G|SEG_E|SEG_D|SEG_C|SEG_B @ display U
.equ ItsLocked, SEG_G|SEG_E|SEG_D @ display L
.equ Programming, SEG_G|SEG_E|SEG_A|SEG_B|SEG_F @ display P
.equ Confirming, SEG_A|SEG_G|SEG_E|SEG_D @ display C
.equ ForgetIt, SEG_G|SEG_E|SEG_A|SEG_F @ display F
.equ AwesomePossum, SEG_A|SEG_B|SEG_C|SEG_E|SEG_F|SEG_G @ display A, it was successful
.equ Error, SEG_G|SEG_E|SEG_A|SEG_F|SEG_D @ display E
.equ LEFT_LED, 0x02 @bit patterns for LED lights
.equ RIGHT_LED, 0x01
.equ LEFT_BLACK_BUTTON,0x02 @bit patterns for black buttons
.equ RIGHT_BLACK_BUTTON,0x01 @and for blue buttons

.text
_start:

@turn on both led
@mov r0,#(LEFT_LED|RIGHT_LED)
@swi SWI_SETLED
@B StartUp

@start up display 'U' in the 8 seg
StartUp:
MOV R0, #ItsUnlocked
SWI SWI_SETSEG8
B CheckWhatsPressed

CheckWhatsPressed:
   @check if the left button is pressed
   SWI SWI_CheckBlack
   CMP R0, #LEFT_BLACK_BUTTON
   mov r0,#LEFT_LED
   swi SWI_SETLED
   swi SWI_SETLED
   BLEQ LeftButton @go if its pressed
   @check if the right button is pressed
   SWI SWI_CheckBlack
   CMP R0, #RIGHT_BLACK_BUTTON
   mov r0,#RIGHT_LED
   swi SWI_SETLED
   swi SWI_SETLED
   BLEQ RightButton
  
LeftButton: @locks the safe
   SWI SWI_CheckBlack
   CMP R0, #LEFT_BLACK_BUTTON
   MOVEQ R0, #ItsLocked @display L
SWI SWI_SETSEG8
   B TryUnlocking
   BX LR @go back to previous method
  
TryUnlocking:
   @you cant unlock it if nothings been programmed yet, so ignore if no previous code
   SWI SWI_CheckBlue
STMFD R6!, {R0} @store the value the user presses
   BL NextState
   @if the user presses left, then done
   SWI SWI_CheckBlack
   CMP R1, #LEFT_BLACK_BUTTON
   BXEQ LR
   B TryUnlocking @keep getting values until they are done coding
  
NextState:@updates the next value the user presses
   STMFD SP!, {LR}
   LDMFD SP!, {LR}
   BX LR
  
RightButton: @displays either P, C, A, or E
   MOV R0, #Programming @display P
SWI SWI_SETSEG8
   B LearnNewCode

  
LearnNewCode:
   SWI SWI_CheckBlue
   STMFD R7!, {R0}
   BL NextState
   @if they press right again they are done, else keep repeating
   SWI SWI_CheckBlack
   CMP R1, #RIGHT_BLACK_BUTTON
   BEQ RepeatCode
   B LearnNewCode

RepeatCode:
   MOV R1, #Confirming @display C
   SWI SWI_SETSEG8
   SWI SWI_CheckBlue
   STMFD R8!, {R0}
   BL NextState
   @if they press right, then they are done --> compare
   SWI SWI_CheckBlack
   CMP R1, #RIGHT_BLACK_BUTTON
   BEQ ConfirmTheCode
   B RepeatCode
  
ConfirmTheCode:
   @check to see if the code matches or not
   CMP R7, R8
   BLEQ TheyMatch
   BLNE DontMatch
  
TheyMatch:
   MOV R0, #AwesomePossum @display A
   SWI SWI_SETSEG8
   BX LR
  
DontMatch:
   MOV R0, #Error @display E
   SWI SWI_SETSEG8
   BX LR
  
.data

Explanation / Answer

safe.s

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote