The move instruction allows us to move eight registers at once, as the following code illustrates: r0,table1 points to source (note the pseudo-op ADR ; r0 ADR) points to the destination r1,table2 ADR ; r1 32 blocks of 8 = 256 words to move MOV r2,#32 ; REPEAT Load 8 registers in to Loop LDRFD r0!,{r3-r10} ; r3 r10 store the registers at their destination r1!,{r3-r10} ; decrement loop counter SUBS r2,r2,#1 ; UNTIL all 32 blocks of 8 registers moved BNE Loop ; Four-function Calculator Program Get number and terminator Save number as operand 1 and save terminator as operator Get second number and terminator Switch (operator) { Case of +: do addition Case of -: do subtraction Case of *: do multiplication Case of /: do division } Output the result { valid digit divide result by 10 stack remainder endWhile } the stacked digits AREA ARMtest, CODE, READONLY code to write a character to console WriteC EQU &0 ;OS code to read a character from the console ReadC EQU &4 ;OS code to exit Exit EQU $11 ;OS ENTRY r13,#0xA000 the stack pointer calc MOV ;initialize BL NewLn first number and terminator BL input ;get terminator (i.e., operator) r2,r0 MOV ;save r3,r1 first number MOV ;save BL NewLn second number and terminator BL ;get terminator MOV r4,r0 ;save BL NewLn the calculation BL math ;do r4,#'h' CMP BLEQ outHex the number BLNE outDec ;display BL NewLn BL getCh CMP r0,#'y' BL NewLn BEQ calc SVC Exit ;end string of digits and accumulate total in r1 input ;read with non-valid digit terminator in r0 ;return input register r0,#0 MOV ;clear accumulated total r1,#0 MOV ;clear r14,[sp,#-4]! link register on the next STR ;save a character in r0 BL ;get
The move instruction allows us to move eight registers at once, as the following code illustrates: ADR r0,table1 ; r0 points to source (note the pseudo-op ADR) ADR r1,table2 ; r1 points to the destination MOV r2,#32 ; 32 blocks of 8 = 256 words to move Loop LDRFD r0!,{r3-r10} ; REPEAT Load 8 registers in r3 to r10 r1!,{r3-r10} ; store the registers at their destination SUBS r2,r2,#1 ; decrement loop counter BNE Loop ; UNTIL all 32 blocks of 8 registers moved Four-function Calculator Program Get number and terminator Save number as operand 1 and save terminator as operator Get second number and terminator Switch (operator) { Case of +: do addition Case of -: do subtraction Case of *: do multiplication Case of /: do division } Output the result { valid digit divide result by 10 stack remainder endWhile } the stacked digits AREA ARMtest, CODE, READONLY WriteC EQU &0 ;OS code to write a character to console ReadC EQU &4 ;OS code to read a character from the console Exit EQU $11 ;OS code to exit ENTRY calc MOV r13,#0xA000 ;initialize the stack pointer BL NewLn BL input ;get first number and terminator MOV r2,r0 ;save terminator (i.e., operator) MOV r3,r1 ;save first number BL NewLn BL ;get second number and terminator MOV r4,r0 ;save terminator BL NewLn BL math ;do the calculation CMP r4,#'h' BLEQ outHex BLNE outDec ;display the number BL NewLn BL getCh CMP r0,#'y' BL NewLn BEQ calc SVC Exit ;end input ;read string of digits and accumulate total in r1 ;return with non-valid digit terminator in r0 MOV r0,#0 ;clear input register MOV r1,#0 ;clear accumulated total next STR r14,[sp,#-4]! ;save link register on the BL ;get a character in r0
1111987084_383286.docx