基本原理:
逻辑操作指令:
and r0,r0,#0x01; r0=r0&0x01 取出r0的最低位数据
orr r0,r0,#0xff; r0=r0|0xff 置位
LSR Logical Shift Right 逻辑右移
Rx , LSR #n 或者是 Rx, LSR, Rn
register = register>>shift
EOR logical exclusive OR
EOR R0, R0, #3 反转R0,之中的0位和1位
BIC (bit clear)
BIC R0, #%0110 ;其中特别注意的是二进制在汇编中格式写成%
比较指令:
CMP R1, #10 比较并设置CPSR
TST
TEQ
条件判断标志:
Register Address R/W Description Reset Value
GPFCON 0x56000050 R/W Configures the pins of port F 0x0
GPFDAT 0x56000054 R/W The data register for port F Undef.
GPFUP 0x56000058 R/W Pull-up disable register for port F 0x000
Reserved 0x5600005c – – –
00 = Input 01 = Output
1)将GPF0/2/3/4设置为输入
00 00 00 01 00
AREA BUTTON, CODE, READONLY
ENTRY
START
;禁止上拉电阻
LDR R1, =0x56000058
LDR R2, =0xff
STR R2, [R1]
;设置GPF0--GPF4为输入
LDR R3, =0x56000050
LDR R4, =0x55555404
STR R4, [R3]
; 设置蜂鸣器的对应端口为输出
LDR R1, =0x56000010
LDR R2, =0x01
STR R2, [R1]
LOOP
; 读入数据
LDR R3, =0X56000054
LDR R4, [R3];读入数据
;判断是否有键按下
;11100010
;将于按键无关的位置一
ORR R4, R4, #0xe2
CMP R4,#0xff
BEQ BEEP_DOWN
B BEEP_ON
B LOOP
; 关闭蜂鸣器
BEEP_DOWN
LDR R1, =0X56000014
LDR R2, =0x0
STR R2, [R1]
B LOOP
BEEP_ON
LDR R1, =0X56000014
LDR R2, =0x1
STR R2, [R1]
B LOOP
END
----------------------------------------------------------------------坚持不懈,追求卓越------------------------------------------------------------------------------