Chapter 3: Assembler Info Flashcards
The code to set up an area is:
AREA nameOfCode, CODE, READONLY
ENTRY
{code}
END
{label} DCD v. expr {, v. expr}
Does what?
set up one or more 32-bit (4 byte) constant in memory. MUST START AT A MULTIPLE OF 4 ADDRESS
{label} DCW v. expr {, v. expr}
Does what?
set up one or more 16-bit (2 byte) constant in memory. MUST START AT A MULTIPLE OF 2 (EVEN) ADDRESS
{label} DCB v. expr {, v. expr}
Does what?
set up one or more 8-bit (1 byte) constant in memory. CAN START ANYWHERE
{label} SPACE size (in bytes) expr
Does what?
reserve a zeroed block of memory
ALIGN
Does what?
ensures that the next data item is correctly aligned on a 32-bit boundary (start at a multiple of 4)
If no align is included…
the assembler will automatically insert bytes with zeros to ensure appropriate boundary alignment
DCD, DCW, and DCB tell the assembler to:
- Reserve one or more 32-bit, 16-bit, or 8-bit blocks of storage in memory
- Load whatever values to the right of DCD, DCW, or DCB into the locations
- Advance the location-counter by one or more four, two, or one bytes so that the next instruction will be put in the next place in memory
What is the location-counter?
a variable inside the assembler to keep track of memory locations during assembling a program, whereas the PC is a register to keep track of the next instruction to be executed
What is the difference between the PC and the location-counter?
Location-Counter is a variable inside the assembler to keep track of memory locations during assembling a program, whereas the PC is a register to keep track of the next instruction to be executed
ALIGN is an example of
explicit alignment
Strings must
BE ALLOCATED WITH DCB AND DOUBLE QUOTES “ ”
Single characters must
ALSO ALLOCATED WITH DCB BUT WITH SINGLE QUOTES INSTEAD ‘ ‘
& can represent
DCD if used in place of DCD (P1 & 0x12345678)
0x if used after a DCD, DCW, or DCB (Strg2 = “X2”, &0C, &0A )
= can represent
DCB if used in place of DCB (Strg2 = “X2”, &0C, &0A )
% represents
SPACE
A pseudo instruction is
an operation the programmer can use when writing code
Pseudo instructions do not
Have machine language equivalents
MOV cannot
move anything longer than 16-bits long (FFFF) is maximum
Instead of using MOV for a 17+ bit literal, use
LDR r0, = 0xFFFFFF pseudo instruction
LDR r0, = 0xFFFFFF pseudo instruction
Does what?
Loads FFFFFF into r0
ADR r0, label
Does what?
loads a 32-bit address into a register
What is the difference between ADD and ADC?
ADD and ADDS: adds two 32-bit values
ADC and ADCS: adds two 32-bit values together with carry
ADDS and ADCS update which flags?
ADDS and ADCS update ALL FLAGS
What is the difference between SUB and RSB?
SUB: SUB r1,r2,r3 means subtract r3 from r2 and store in r1
RSB: RSB r1,r2,r3 means subtract r2 from r3 and store in r1
RSB can be used to subtract from a constant:
RSB r1, r2, #10
RSB can be shortened: RSB r1, #5 means RSB r1, r1, #5
SUBS and RSBS update which flags?
SUBS and RSBS update ALL FLAGS
NEG does what?
NEG (Negation): is a pseudo instruction to subtract a number from zero
NEG only has two operands and CANNOT be shortened
NEG r1, r2 is equal to RSB r1, r2, #0
NEG r1, r2 is equal to…
RSB r1, r2, #0