1、AREA Example1,CODE,READONLY ENTRYCODE32START MOV R0,#15MOV R1,#8ADDS R0,R0,R1B STARTENDTest2.sX EQU 11Y EQU 8BIT23 EQU (1=0, if N=0 reult=0,if N=1 resualt=1;*N EQU 100AREA Example5,CODE,READONLYENTRYCODE32ARM_CODE LDR SP,=0X40003F00 ;There should be no space before ARM_CODE ADR R0,THUMB_CODE+1BX R0L
2、TORGCODE16THUMB_CODELDR R0,=NBL SUM_NB THUMB_CODE;*;Name :SUM_N;Function :Caculate 1+2+3+N;Entrance Parametre :R0 N;Out Parametre :R0 Result;Source Occupation :R0;Explanation :N=0, if N=0 result=0,if N=1 resualt=1; if any overflow result=0;* SUM_NPUSH R1-R7,LRMOVS R2,R0BEQ SUM_ENDCMP R2,#1BEQ SUM_EN
3、DMOV R1,#1MOV R0,#0SUM_L1 ADD R0,R1BCS SUM_ERRCMP R1,R2BHS SUM_ENDADD R1,#1B SUM_L1SUM_ERR MOV R0,#0SUM_END POP R1-R7,PCEND/*Test6.s* ;* ;Name :tes6.s;Function :show if for while switch ;Entrance Parametre :;Out Parametre :;Source Occupation :;Explanation :;* AREA Example6,CODE,READONLY ENTRYCODE32S
4、TART ;if(xyz=100;else z=50MOV R0,#76MOV R1,#243CMP R0,R1MOVHI R2,#100MOVLS R2,#50;for(i=0;i0 MOV R0,#5 DOWHILE_L1 ADD R0,R0,#-1 DOWHILE_L2 MOVS R0,R0 BNE DOWHILE_L1 DOWHILE_END NOP ;switch(keycase 0: ; case 2: ; case 3:x=key+y; break; ; case 5:x=key-y; break; ; case 7:x=key*y; break; ;default:x=168;
5、 break; ; MOV R1,#3 MOV R2,#2 SWITCH AND R2,R2,#0X0F CASE_0 CMP R2,#0 CASE_2 CMPNE R2,#2 CASE_3 CMPNE R2,#3 BNE CASE_5 ADD R0,R2,R1 B SWITCH_END CASE_5 CMP R2,#5 BNE CASE_7 SUB R0,R2,R1 B SWITCH_END CASE_7 CMP R2,#7 BNE DEFAULT MUL R0,R2,R1 B SWITCH_END DEFAULT MOV R0,#168 SWITCH_END NOP HALT B HALT END