Converting to Decimal

...

Numbers And Bases

...

Hex, Binary, And Decimal

...

Integer Representation

Where do computers store integers?
Computers store integers in memory.

What are the names for the different numbers of bytes?
The names for the different numbers of bytes are:

  • 1/2 byte - Nybble.
  • 1 byte - Byte.
  • 2 bytes - Half word.
  • 4 bytes - Word.
  • 8 bytes - Double word.

What are integers stored as in memory?
Integers are stored in memory as binary values.

What are the two types of integers?
The two types of integers are:

  • Unsigned - Positive values only.
  • Signed - Positive and negative values.

Two's Complement

What did early computers use to represent negative numbers?
To represent negative numbers, early computers used One's Complement.

What do computers use to represent negative numbers now?
Now, to represent negative numbers computers use Two's Complement.

What are the two steps to finding the Two's Complement of a number?
The two steps to findings the Two's Complement of a number are:

  1. Computing the One's Complement by flipping each bit.
  2. Adding one to the result.

...

Is the carry out that's generated by finding a Two's Complement ignored?
Yes, the carry out that's generated by finding a Two's Complement is ignored.

...

What is the benefit of using Two's Complement?
The benefit of using Two's Complement is that it simplifies arithmetic logic in CPUs.

Number Ranges

What is the range of values for unsigned bytes?
The range of values for unsigned bytes is 0x00 (0) to 0xFF (255).

What is the range of values for signed bytes?
The range of values for signed bytes is 0x80 (-128) to 0x7F (127).

...

Homework 1

...

Registers

What is an -bit register?
An n-bit register is a group of flip-flops and logic gates capable of storing bits of information.

Are there multiple registers in a microprocessor?
Yes, there are multiple registers in a microprocessor.

What are the three types of registers?
The three types of registers are:

  1. Control registers - They're special purpose and control behaviors.
  2. Data registers - Acts as the working memory for data by storing operands and results of operations.
  3. Flag registers - Store the status of CPU processes.

Special Purpose Registers

What does the Program Counter (PC) store?
The PC stores the address of the instruction which will be executed next.

What is the stack?
The stack is a reserved block of main memory used to save/restore data.

What uses the stack implicitly?
The stack is used implicitly by procedure call instructions, including interrupt service calls.

What does the stack typically store?
The stack typically stores the contents of CPU registers that needed to be restored after returning from a call instruction.

What does the Stack Pointer (SP) store?
The SP stores the last location in memory where data was placed onto the stack.

When does a stack overflow occur?
A stack overflow occurs when the stack pointer runs off of the end of the allocated stack memory.

What does the Instruction Register (IR) store?
The IR stores the current instruction being processed by the microprocessor.

Is the Instruction Register (IR) visible to the programmer?
No, the IR is invisible to the programmer.

ARM Cortex M Registers

What are the registers in an ARM Cortex-M series microprocessor?
The registers in an ARM Cortex-M series microprocessor include:
ARM Cortex-M Series Microprocessor Registers.png

CPU Architectures

...

Pipelining

...

Microcontroller

What is a microcontroller?
A microcontroller is a computer SoC.

What does a microcontroller contain?
A microcontroller contains:

  • A CPU.
  • RAM.
  • Flash memory.
  • Configurable I/O devices.
  • A clock generator.
  • Timers.

What do microcontrollers do?
Microcontrollers run dedicated applications specific for the device which they're contained in.

Can microcontrollers include an operating system?
Yes, microcontrollers can include an operating system.

C Code Compilation Steps

...

Compiler / Assembler Toolchain

...

Memory Sections

What are the four sections of memory and what they store?
The four sections of memory and what they store include:

  1. .text - Read-only program code.
  2. .rodata - Read-only constants and strings.
  3. .data - Initialized global and static variables.
  4. .bss - Uninitialized global and static variables.

What does .bss stand for?
.bss stands for Block Started by Symbol.

Linker

What does the linker do?
The linker combines multiple object files.

How does the linker combine multiple object files?
The linker combine multiple object files by resolving their external symbol references and relocating their data sections.

What two things does the linker take as input?
The two things which the linker takes as input are:

  1. .o object files.
  2. .ld linker scripts.

What does the linker output?
The linker outputs .out executable files.

Objcopy And Objdump

...

Thumb And Thumb-2

...

Little Endian Vs Big Endian

...

Operand Addressing Types

ARM Instruction Format

Move Instruction

What does the MOV instruction do?
The MOV instruction moves the value of a register or an immediate value into another register.

...

Load / Store Instructions

Program Status Registers

What is the diagram for the assignment of the APSR, IPSR , and EPSR bits?
The diagram for the assignment of the APSR, IPSR, and EPSR bits is:
Diagram Of The Assignment Of The APSR, IPSR, And EPSR Bits.png

What does APSR stand for?
APSR stands for Application Program Status Register.

What does IPSR stand for?
IPSR stands for Interrupt Program Status Register.

What does EPSR stand for?
EPSR stands for Exception Program Status Register.

What do the status registers contain?
The status registers contain flags that are set by hardware to indicate specific conditions that occur during program execution, such as from the ALU.

What bits are used for SEL (select byte) instruction comparison?
The bits used for SEL instruction comparison are Greater than or Equal to (GE[3:0]) bits.

What are the most important flags?
The most important flags are:

  • N - Negative at bit-31.
  • Z - Zero at bit-30.
  • C - Carry at bit-29.
  • O - Overflow at bit-28.

What is the Q bit used for?
The Q bit is used for overflow and saturation status.

Condition Flags

What are the different condition flags set to?
The different condition flags are set to:

  • N - The sign bit of the ALU result.
  • Z - If the result of the instruction is zero.
  • C - If an unsigned operation exceeded the 32-bit range with a carry for ADD or a borrow for SUB.
  • V - The same as the C condition flag but for signed operations.
  • Q - For Digital Signal Processor operations.

...

Addition Instructions

Examples of using the addition instructions
  • ADD r3, r2, r1 - Adds the values of r2 and r1 and puts the result in r3 without affecting the status register flag.
  • ADC r3, r2, r1 - Adds the values of r2, r1, and the value of the carry flag and puts the result in r3 without affecting the status register flag.
  • ADD r3, r0, #7.
  • ADDS r3, r2, r1 - The same as ADD except it affects the status register flags.
  • ADCS r3, r2, r1 - The same as ADC except it affects the status register flags.

Subtraction Instructions

Examples of using the subtraction instructions
  • SUB r0, r0, r4 - Subtracts r4 from r0 and puts the result in r0 without affecting the status register flags.
  • RSB r0, r0, r4 - Subtracts r0 from r4 and puts the result in r0 without affecting the status register flags.
  • SBC r0, r0, r4 - Subtracts r4 from r0 with a carry and puts the result in r0 without affecting the status register flags.
  • SUBS r0, r0, r4 - The same as SUB except it affects the status register flags.
  • RSBS r0, r0, r4 - The same as RSB except it affects the status register flags.
  • SBCS r0, r0, r4 - The same as SBC except it affects the status register flags.

Multiplication Instructions

Examples of using the multiplication instructions
  • MUL r0, r1, r4.
  • MULS r0, r1, r4.
  • MLA r0, r1, r2, r3.
  • MLS r0, r1, r2, r3.
  • UMULL r0, r1, r2, r3.
  • SMULL r0, r1, r2, r3.
  • UMLAL r0, r1, r2, r3.

Logical Instructions

Examples of using the logical instructions
  • AND r0, r1, r4 - Performs logical AND between r1 and r4 and puts the result in r0.
  • ORR r0, r1, r4 - Performs logical OR between r1 and r4 and puts the result in r0.
  • EOR r0, r1, r4 - Performs logical XOR between r1 and r4 and puts the result in r0.
  • BIC r0, r1, r4 - Performs bitwise clear between r1 and r4 and stores the result in r0.
  • ANDS r0, r1, r4.
  • ORRS r0, r1, r4.
  • EORS r0, r1, r4.

Review Of Shift And Rotate

What instructions are used for shifting or rotating a binary value?
The instructions used for shifting or rotating a binary value are:

  • LSL - Logical shift left.
  • LSR - Logical shift right.
  • ASL - Arithmetic shift left.
  • ASR - Arithmetic shift right.
  • ROL - Rotate left.
  • ROR - Rotate right.
  • RLX - Rotate left extended.
  • RRX - Rotate right extended.

...

Bit Field Instructions

Examples of using the bit field instructions
  • BFC r4, #8, #12 - Clears bits from bit-8 to bit-19 (12 bits) of r5 to 0.
  • BFI r9, r2, #8, #12 - Replaces bits from bit-8 to bit-19 (12 bits) of r9 with bit-0 to bit-11 from r2.
  • RBIT r0, r1 - Reverses the bit order of a 32-bit value in r1 and puts the result in r0.
  • REV r0, r1 - Reverses the byte order of a 32-bit word in r1 and puts the result in r0. It's used for converting between little endian and big endian.
  • REV16 r0, r1 - Reverses the byte order of each 16-bit half word in a 32-bit word in r1 and puts the result in r0.
  • ADR r0, b - Determines the memory address of label b and puts it in r0. It's used for finding the memory address that the assembler assigned to a label.

Compare And Branch

Compare And Branch Examples

Data Comparison Instructions

What are the four data comparison instructions?
The four data comparison instructions are:

  1. CMP Rn, Op2 - Sets the NZCV flags based on the operation Rn - Op2.
  2. CMN Rn, Op2 - Sets the NZCV flags based on the operation Rn + Op2.
  3. TST Rn, Op2 - Sets the NZCV flags based on the operation Rn AND Op2.
  4. TEQ Rn, Op2 - Sets the NZCV flags based on the operation Rn EOR Op2.

Conditional Branch Codes

...

Conditional Execution

...

Data Definition Examples

...

Reading And Setting PSR

...

ALU Barrel Shifter

...

Barrel Shifter And Status Flags

...

32-Bit Arithmetic Instruction Summary

...

64-Bit Arithmetic Instruction Summary

...

Bit Masking With Logic

...

Set, Clear, Toggle A Bit

...

Bit And Byte Order Reversal

...

Sign And Zero Extension

...

Bit Field Extract Instructions

...

Nested Subroutine Push/Pop

...

64-Bit Addition

...

64-Bit Subtraction

...

Homework 2

...