1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Unsigned Binary Integers
Range: 0 to +2^n - 1
ex) Use 32-bits --> 0 to +4,294,967,295
Signed Binary Integers
Range: -2^n-1 to +2^n-1 - 1
ex) 32-bits --> -2,147,483,648 to +2,147,483,647
MSB is signed bit
overflow - signed numbers
adding + and - = no overflow
adding two + operands = overflow if result N=1 (looks neg but is pos)
adding two - operands = overflow if N=0 (looks pos)
S Suffix in ARM instructions
modifies the condition flags of CSPR
What would you observe for 8-bit operations? Are flags updated correctly?
flags are 32-bit based, must sign extend for it to work as expected
Sign Extension
takes MSB bit in the byte or half word and duplicates it up to the full data width
Positive number looks negative
there is carry from 30 to 31 but no carry put of 31 (C=0) --> N=1, V=1, C=0
Negative number looks positive
there is carry out of 31 (C=1) but no carry from 30 to 31 --> N=0, V=1, C=1
multiplication of signed numbers
mul Rd,Rn,Op2 // Rd = Rn*Op2
umull RdLo,RdHi,Rn,Rm
smull Rdlo,Rdhi,Rm,Rn
division
udiv Rd, Rm, Rn Rd = Rm / Rn [unsigned - only does integer division]
sdiv Rd,Rm,Rn Rd = Rm / Rn [signed]
conditional execution
Movxx
xx = EQ, NE, LT, GT, GE, LE
- condition is based on prior instruction that changed the flags
CMP
same as SUBS except result is discarded, flags are set
--> CMP RN, OP2 (RN-OP2)
CMN
same as ADDS except result discarded, flags set --> CMN RN, Op2 (RN + Op2)
LSL instruction
bits are shifted from R to L, 0 enters LSB and MSB exits to carry flag
MOVS Rd, Rn, LSL #numOfShiftLSL(S) Rd, Rn, #numOfShift
LSR instruction
bits are shifted from L to R, 0 enters MSB and LSB exits to carry flag
LSR(S) Rd, Rn, #numOfShift ;Logical Shift RightMOVS Rd, Rn, LSR #numOfShift
ROR instruction
bits roatetd from L to R, LSB goes to MSB and to the carry flag
ROR Rd, Rm, #numOfShifts ;Rotate Rm right Rn bit positions
MOVS Rd, Rm, ROR #numOfShifts
RRXS instruction
RRXS the C is moved to the MSB, and the LSB is moved to the C
ASR Instruction
MSB is held constant and the LSB exits to
the carry flag
ASR(S) Rd, Rm, #count @Arithmetic Shift Right
MOVS Rd, Rm, ASR #count
Preserves the sign!
What can AND be used for?
to clear specific bits of a byte
What can OR be used for?
to set specific bits of a byte