1、Arm 汇编语言语句分析:(1) 数据处理类指令MOV R0,R2 只能立即数之间SUB R0, R1, R2 只能立即数之间MOV R0, #0x101 立即数要满足一定要求MOV R0, R1, LSL #3 合法(2) Load/Store 类指令LDR R0,R1, #4LDR R0, R1, R2, LSL #2!STR R0, R1, R2, LSL R3 移位的数只能是立即数(3) 杂类 Load/Store 指令LDRB R0, R1, #3LDRH R0, R1STRH R0, R1, R2, LSL #2 错 没有移位(4) 批量 Load/Store 指令Arm 用的是
2、Full Descending 堆栈STMFD R0!,R1,R2 = STMDB R0!,R1,R2LDMFD R0!,R1,R2 = LDMIA R0!,R1,R2(5) 状态寄存器访问指令MODE_SVC EQU 0x13IRQ_DIS_BIT EQU 0x80FIQ_DIS_BIT EQU 0x40MOV R0, #0MOV R0, #MODE_ SVC:OR:IRQ_DIS_BIT:OR:FIQ_DIS_BITMSR CPSR_c, R0:OR: 为操作 把前后的数取或的关系ARM 程序代码段分析:AREA Block, CODE, READONLY ; name this bloc
3、k of codenum EQU 20 ; Set number of words to be copiedENTRY ; mark the first instruction to callstartLDR r0, =src ; r0 = pointer to source blockLDR r1, =dst ; r1 = pointer to destination blockMOV r2, #num ; r2 = number of words to copyMOV sp, #0x400 ; set up stack pointer (r13)blockcopy MOVS r3,r2,
4、LSR #3 ; number of eight word multiplesBEQ copywords less than eight words to move ?STMFD sp!, r4-r11 ; save some working registersoctcopyLDMIA r0!, r4-r11 ; load 8 words from the sourceSTMIA r1!, r4-r11 ; and put them at the destinationSUBS r3, r3, #1 ; decrement the counterBNE octcopy ; . copy mor
5、eLDMFD sp!, r4-r11 ; dont need these now - restore originalscopywordsANDS r2, r2, #7 ; number of odd words to copyBEQ stop ; No words left to copy ?wordcopyLDR r3, r0, #4 ; a word from the sourceSTR r3, r1, #4 ; store a word to the destinationSUBS r2, r2, #1 ; decrement the counterBNE wordcopy ; . copy morestopB ENDAREA BlockData, DATA, READWRITEsrc DCD 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4dst DCD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0END接口技术编程实验: