HOW CAN I STORE SEQUENCE OF BUTTON PRESSES IN ARMSIM ASSEMBL
HOW CAN I STORE SEQUENCE OF BUTTON PRESSES IN ARMSIM ASSEMBLY??
FOR EXAMPLE WE ARE SIMULATING A ELECTRONIC POCKET THAT REQUIRES PASSWORD TO BE UNLOCKED
 WHEN THE USER SET THE PASSWORD FOR THAT ELECTRONIC POCKET HE HAVE TO PRESS BUTTONS (SIMULATES PASSCODE)
 SO HOW I DO THAT
ASSEMBLY ARMSIM IS REQUIRED (PLEASE PROVIDE A SNIPPET OF CODE SO I CAN UNDERSTAND)
Solution
I am trying to have 8 segment display show the correct letters when the user pressed or enters a certain button sequence.
 On start up it should display U, then if they press the left black button is should display L, and etc. But nothing is happening on start up! Even when I press any of the other buttons, nothing gets displayed on the 8 seg display. Here is 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
@start up display \'U\' in the 8 seg
StartUp:
MOV R0,
#ItsUnlocked
SWI SWI_SETSEG8
CheckWhatsPressed:
@check if the left button is pressed
SWI SWI_CheckBlack
CMP R0, #LEFT_BLACK_BUTTON
BLEQ LeftButton @go if its pressed
@check if the right button is pressed
SWI SWI_CheckBlack
CMP R0, #RIGHT_BLACK_BUTTON
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




