02_ARM_Processor_Core_and_Instruction_Sets

R0 r2r14 restore the work registers and return ldmfd

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: hed, loop 88/213 Multiple Register Transfer Instructions Institute of Electronics, National Chiao Tung University • LDM|STM {<cond>}<add mode> Rn{!}, <registers> – <add mode> specifies one of the addressing modes; ‘!’: auto-indexing; <registers> a list of registers, e.g. {r0,r3r7,pc} • In non-user mode, the CPSR may be restored by LDM{<cond>}<add mode> Rn{!},<registers+PC>^ • In non-user mode, the user registers may be saved or restored by LDM|STM{<cond>}<add mode> Rn,<registers-PC>^ – The register list must not contain PC and write-back is not allowed 89/213 Example Institute of Electronics, National Chiao Tung University • Save 3 work registers and the return address upon entering a subroutine (assume r13 has been initialized for use as a stack pointer) STMFD r13!,{r0-r2,r14} • Restore the work registers and return LDMFD r13!,{r0-r2,pc} 90/213 Swap Memory and Register Instructions Institute of Electronics, National Chiao Tung University • SWP{<cond>}{B} Rd,Rm,[Rn] • Rd <- [Rn], [Rn] <- Rm • Combine a load and a store of a word or an unsigned byte in a single instruction • Example ADR r0,SEMAPHORE SWPB r1,r1,[r0] ;exchange byte 91/213 Status Register to General Register Transfer Instructions • MRS{<cond>} Rd,CPSR|SPSR Institute of Electronics, National Chiao Tung University • The CPSR or the current mode SPSR is copied into the destination register. All 32 bits are copied. • Example MRS r0,CPSR MRS r3,SPSR 92/213 General Register to Status Register Transfer Instructions Institute of Electronics, National Chiao Tung University • MSR{<cond>} CPSR_<field>|SPSR_<field>,#<32-bit immediate> MSR{<cond>} CPSR_<field>|SPSR_<field>,Rm – <field> is one of • • • • c - the control field PSR[7:0] x - the extension field PSR[15:8] s - the status field PSR[23:16] f - the flag field PSR[31:24] • Example – set N, X, C, V flags MSR CPSR_f,#&f0000000 – set just C, preserving N, Z, V MRS r0,CPSR ORR r0,r0,#&20000000 MSR CPSR_f,r0 ;set bit29 of r0 93/213 Control Flow Instructions Institute of Electronics, National Chiao Tung University • • • • • • • Branch instructions Conditional branches Conditional execution Branch and link instructions Subroutine return instructions Supervisor calls Jump tables 94/213 Branch Instructions Institute of Electronics, National Chiao Tung University LABEL B LABEL … … – LABEL comes after or before the branch instruction 95/213 Conditional Branches Institute of Electronics, National Chiao Tung University • The branch has a condition associated with it and it is only executed if the condition codes have the correct value taken or not taken Loop MOV … ADD CMP BNE r0,#0 ;initialize counter r0,r0,#1 ;increment loop counter r0,#10 ;compare with limit Loop ;repeat if not equal ;else fall through 96/213 Conditional Branch Institute of Electronics, National Chia...
View Full Document

Ask a homework question - tutors are online