I am trying to write a program in arm assembly which will increase and decrease a value of a counter on a keypress. The min value of the counter is 0 and the maximum is 8. It will be used for volume adjusting.
I want to modify the following code to do this.
The follwing code is a loop from 0 to 8 .
Can anybody help? Thank you !
AREA Myprog, CODE, READONLY
Sys_Bas EQU 0x03FF0000
; Sys_Bas is the default base address of on-chip peripherals
; for the Evaluator_7 target board
IO_Bas EQU Sys_Bas + 0x5000 ; Offset for I/O registers
IOPMOD EQU IO_Bas ; I/O control register address
IOPDATA EQU IO_Bas + 8 ; I/O data register address
ENTRY
LDR r2, =0x0001fcf0 ;mask for i/o
LDR r3, =IOPMOD ;address for mask
STR r2,[r3] ;store mask at address
LDR r5, =IOPDATA ;address for i/o ¨o½Ü/Óµ±
loop MOV r4, #0x01800 ;bit pattern for 1 ÿÿÿÿ
BL display ;branch and link to subroutine 6 0 0
MOV r4, #0x0EC00 ;bit pattern for 2
BL display
MOV r4, #0x0BC00 ;bit pattern for 3
BL display
MOV r4, #0x19800 ;bit pattern for 4
BL display
MOV r4, #0x1B400 ;bit pattern for 5
BL display
MOV r4, #0x1F400 ;bit pattern for 6
BL display
MOV r4, #0x01C00 ;bit pattern for 7
BL display
MOV r4, #0x1FC00 ;bit pattern for 8 WVD8
BL display
MOV r4, #0x17C00 ;bit pattern for 0
BL display
B loop ;repeat forever
; Subroutine starts
display LDR r7, [r5] ;load input to r7
AND r8, r7, #0xF ;clean up input
ORR r9, r4, r8, LSL #4 ;shift input 4 bit left and
;merge with bit pattern
STR r9,[r5] ;store output to i/o
MOV r6, #0x200000 ;
delay SUBS r6, r6, #1 ;count down from 0x200000 0 =
BNE delay ;so we can see numbers change
MOV pc, r14 ;return to main program / 0 1 2 3 4 5
9 : ; <
?
; The following code is required when running the program
; using the AXD debugger. It returns control to the host PC.
MOV r0, #0x18
LDR r1, =0x20026
SWI 0x123456 !a
END