ISE 250 Ch 1
42 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which segment in an ELF file contains the binary machine code?

  • RO segment
  • Z segment
  • text segment (correct)
  • RW segment

Which of the following best describes the purpose of the Section Header Table in an ELF file?

  • To define the entry point where program execution begins.
  • To store environment variables used by the program during execution.
  • To manage dynamic linking.
  • To enable the compiler to locate the content of specific sections. (correct)

The RO segment in the ELF file typically contains:

  • The value of variables unalterable at runtime. (correct)
  • Uninitialized variables.
  • Variables that are statically allocated and modifiable.
  • Variables that can be modified during runtime.

What is primarily stored in flash memory, and why is it stored there?

<p>The executable program, enabling the processor to restart the program. (B)</p> Signup and view all the answers

A 32-bit processor uses 32 bits for each memory address. What is the total addressable memory space?

<p>4 GB (D)</p> Signup and view all the answers

What is the primary advantage of using processor registers compared to accessing data memory?

<p>Registers are significantly faster for data access. (A)</p> Signup and view all the answers

What type of data does the 'Z' segment hold in the ELF file?

<p>Uninitialized variables (D)</p> Signup and view all the answers

Which of the following best describes the concept of spatial locality in the context of data access?

<p>Accessing data stored in nearby memory locations in quick succession. (C)</p> Signup and view all the answers

When a program is running, it is copied to primary memory, also known as:

<p>SRAM, or static memory (D)</p> Signup and view all the answers

In the context of memory organization, if a memory location at address 0x080001B0 contains the byte value 0x70, what does this indicate?

<p>The memory location at that specific address has a value of 112. (A)</p> Signup and view all the answers

Why might a processor architecture limit the number of bits used to encode a register in a machine instruction?

<p>To reduce code size and lessen memory bandwidth requirements. (A)</p> Signup and view all the answers

According to the register allocation rules, what should happen if the live ranges of two variables overlap?

<p>Two different registers should get allocated to each of the variables. (A)</p> Signup and view all the answers

What is the primary function of the Stack Pointer (SP) register?

<p>To hold the memory address of the top of the stack. (C)</p> Signup and view all the answers

Which ARM Cortex-M processor architecture implements the ARMv7E-M architecture?

<p>Cortex-M4 (C)</p> Signup and view all the answers

In the Cortex-M architecture, what memory address range typically corresponds to Flash memory?

<p><code>0x0800_0000</code> (C)</p> Signup and view all the answers

When a Cortex-M processor loads a program, where are initialized global variables primarily stored?

<p>Data memory (C)</p> Signup and view all the answers

Which memory segment in a Cortex-M processor changes dynamically during runtime due to calls to malloc or calloc?

<p>Heap segment (B)</p> Signup and view all the answers

What is the primary characteristic of the stack in a Cortex-M processor?

<p>Last-in-first-out (LIFO) (B)</p> Signup and view all the answers

What is the main purpose of control registers in the peripheral memory of a Cortex-M system?

<p>To configure and control the peripheral's operation (B)</p> Signup and view all the answers

What is the size, in bits, of the general-purpose registers in a Cortex-M processor?

<p>32 bits (C)</p> Signup and view all the answers

What digital component is used to construct a register capable of storing binary bits?

<p>Flip-flop (B)</p> Signup and view all the answers

Which of the following best describes the primary role of a compiler in the context of translating C code to machine code?

<p>To translate C code into assembly language, which is then converted to machine code. (B)</p> Signup and view all the answers

What is the main advantage of using a high-level language like C compared to assembly language or machine code?

<p>High-level languages enhance programmer productivity and code portability. (A)</p> Signup and view all the answers

Consider a scenario where a C program contains a loop that iterates through an array. Which level of program code is MOST directly involved in the repetitive execution of the loop?

<p>Machine Code. (C)</p> Signup and view all the answers

Why is machine code represented in binary digits (bits)?

<p>Because computer hardware operates using binary signals (0s and 1s). (D)</p> Signup and view all the answers

Which of the following characteristics distinguishes assembly language from machine code?

<p>Assembly language is a textual representation of instructions, while machine code is a binary representation. (C)</p> Signup and view all the answers

Given a simple C program that declares an integer variable and assigns it a value, at which stage does the variable's value get represented in binary format?

<p>During the execution of the machine code. (C)</p> Signup and view all the answers

You have written a C program and need to create an executable file. What is the general sequence of steps involved?

<p>Compilation -&gt; Assembly -&gt; Linking. (A)</p> Signup and view all the answers

What is the primary purpose of 'linking' in the process of creating an executable file from C code?

<p>To combine compiled object code with necessary libraries and other object files to resolve external references. (B)</p> Signup and view all the answers

In a computer system with a 32-bit address space, what is the maximum amount of RAM that can be directly addressed?

<p>4 GB (C)</p> Signup and view all the answers

Why might a Harvard architecture be preferred over a Von-Neumann architecture in certain applications?

<p>It enables simultaneous instruction fetch and data access. (D)</p> Signup and view all the answers

Which of the following memory sizes is closest to 1 Terabyte?

<p>1,024 Gigabytes (D)</p> Signup and view all the answers

In a Von-Neumann architecture, what is a primary limitation concerning memory access?

<p>The processor cannot simultaneously fetch an instruction and access data. (C)</p> Signup and view all the answers

What is a key difference in memory organization between Von-Neumann and Harvard architectures that impacts their performance?

<p>Von-Neumann uses a single memory space for both instructions and data, while Harvard separates them. (C)</p> Signup and view all the answers

An embedded system utilizes an ARM Cortex-M series microcontroller with a modified Harvard architecture. It has 4KB of flash memory for instructions and 256KB of SRAM for data. What is a likely reason for choosing this configuration?

<p>To optimize for real-time performance by enabling fast data access and instruction fetching. (C)</p> Signup and view all the answers

Consider a system that uses memory addresses to point to locations where data is stored. If a particular memory location stores the hexadecimal value 0x70, what could this value potentially represent?

<p>An instruction code that tells the processor to perform an addition operation. (B)</p> Signup and view all the answers

A program running on a 32-bit system attempts to access a memory location beyond the 4GB limit. What is the most likely outcome?

<p>A memory access error will occur, potentially crashing the program. (A)</p> Signup and view all the answers

What is the primary function of a bootloader in a processor?

<p>To set up the runtime environment after self-testing. (C)</p> Signup and view all the answers

In assembly programming, what does the program counter (PC) typically point to when a program starts?

<p>The first instruction of the <code>main</code> function. (B)</p> Signup and view all the answers

What is the purpose of the instruction LDR r1, =a?

<p>Loads the memory address of the variable <code>a</code> into register <code>r1</code>. (C)</p> Signup and view all the answers

What action is performed during the 'Execute' stage of a load instruction?

<p>Accessing data memory to retrieve the data and store it in a register. (B)</p> Signup and view all the answers

What does a 'dead loop' at the end of the main function typically indicate in an assembly program?

<p>The intentional halting of the program's execution. (D)</p> Signup and view all the answers

Flashcards

Kilo (K)

1,024 bytes.

Mega (M)

1,048,576 bytes.

Giga (G)

1,073,741,824 bytes.

Tera (T)

1,099,511,627,776 bytes.

Signup and view all the flashcards

Von-Neumann Architecture

Instructions and data share the same memory.

Signup and view all the flashcards

Harvard Architecture

Instructions and data are stored in separate memories.

Signup and view all the flashcards

32-bit Memory Address Space

Memory addresses are 32 bits wide, allowing for 4GB of addressable memory.

Signup and view all the flashcards

ARM Cortex-M Series Family

Utilizes the Von-Neumann architecture.

Signup and view all the flashcards

ELF (Executable and Linkable Format)

File format for executables, object code, shared libraries, and core dumps.

Signup and view all the flashcards

Section Header Table

It locates the content of a specific section in the ELF file.

Signup and view all the flashcards

text segment

Contains the binary machine code of the program.

Signup and view all the flashcards

RO segment

Contains the value of variables unalterable at runtime.

Signup and view all the flashcards

RW segment

Contains static values of allocated and modifiable variables.

Signup and view all the flashcards

Z segment

Holds all uninitialized variables.

Signup and view all the flashcards

Primary Memory (SRAM)

Memory used while the program is running.

Signup and view all the flashcards

32-bit Address Space

Memory addressable by a 32-bit processor.

Signup and view all the flashcards

C Program

High-level programming language focused on productivity and portability.

Signup and view all the flashcards

Assembly Program

Human-readable, textual representation of machine instructions.

Signup and view all the flashcards

Machine Code

Binary representation of instructions and data that hardware understands.

Signup and view all the flashcards

C to Machine Code Translation

The process of converting C code into machine code.

Signup and view all the flashcards

Executable File

Another name for a machine program; a file containing executable code.

Signup and view all the flashcards

High-Level Language

A level of abstraction closer to the problem; focuses on programmer productivity and code portability.

Signup and view all the flashcards

Assembly Language

A textual representation of machine instructions, designed to be human-readable.

Signup and view all the flashcards

Hardware Representation

Representation using binary digits that the hardware directly interprets and executes.

Signup and view all the flashcards

Register

A set of flip-flops connected in parallel, used to store binary information.

Signup and view all the flashcards

Register Access Speed

Accessing registers is much faster than accessing main memory, which improves performance.

Signup and view all the flashcards

Temporal Locality

The tendency to access the same data items or memory locations repeatedly within a short period.

Signup and view all the flashcards

Spatial Locality

The tendency to access data items that are located near each other in memory.

Signup and view all the flashcards

Stack Pointer (SP)

A dedicated register that holds the memory address of the top of the stack.

Signup and view all the flashcards

LDR r1, =a

A pseudo-instruction that loads the memory address of a variable into a register.

Signup and view all the flashcards

PC and _main Function

The program counter points to the first instruction of the _main function in an assembly program.

Signup and view all the flashcards

Dead Loop at Program End

The program counter (PC) repeatedly points to the last instruction after main function, creating a dead loop, marking the program's end.

Signup and view all the flashcards

Bootloader

A startup program that initializes the runtime environment after hardware self-testing.

Signup and view all the flashcards

Program Counter (PC)

The program counter holds the memory address of the current instruction being executed.

Signup and view all the flashcards

ARM Cortex-M

A family of 32-bit microcontroller cores designed for embedded systems.

Signup and view all the flashcards

Cortex-M Memory Addresses

Flash memory: 0x0800_0000, SRAM: 0x2000_0000

Signup and view all the flashcards

Program Memory Segments

Initialized data, BSS (uninitialized data), heap, and stack

Signup and view all the flashcards

Stack (FILO)

Last-in, first-out data structure, mandatory for program execution.

Signup and view all the flashcards

Heap

Memory allocated dynamically during runtime (e.g., using malloc, calloc).

Signup and view all the flashcards

Peripheral Memory

Data, control, and status registers used for communication and control of external devices.

Signup and view all the flashcards

Processor Registers

Fastest data storage locations within the processor, used for temporary storage and special functions.

Signup and view all the flashcards

Study Notes

  • Study notes on how a program runs

Translating C to Machine Code

  • The goal is to create an executable machine program
  • A compiler creates the executable file
  • Executables are platform-dependent and non-portable
  • An executable that is compiled for one processor cannot run on a different microprocessor
  • Executable file modifications may be required when switching platforms

Compiler

  • Two steps in the process of compiling: Analysis and Synthesis
  • Analysis, the goal is to create an Intermediate Representation (IR) that represents the original program in a simplified way
  • IR aka low-level representation
  • Analysis for C is assembly language
  • Synthesis is the process of generating the executable from IR
  • Synthesis involves performing transformations and optimizations
  • Synthesis improves program execution speed or reduces program size

Executable File Format (ELF)

  • The machine programs support a standard binary file specification
  • Abbreviated as ELF for executable and linkable format
  • ARM processors support ELF
  • Two views: linking and execution

Views of ELF

  • Linking: used at static link time to merge multiple files during compilation
  • Execution: employed at runtime to create a process image in memory when a program is loaded and executed
  • When a compiler constructs an executable file, Section Header Table can locate the content of a specific section in the ELF file by referencing: the section header table
  • Text segment is binary machine code
  • Read-Only segment (RO) contains the value of variables unalterable at runtime
  • Read-Write (RW) segment is the initial values of statically allocated and modifiable variables
  • Zero Initialised segment (Z) holds all uninitialised variables

Loading a Program into Memory

  • Executable is saved to flash memory, typically several MBs
  • Flash memory allows the processor to restart
  • When running, the program is copied to primary memory, aka static memory, or SRAM
  • Static memory (SRAM) typically has hundreds of KBs

Arrangement of Memory

  • Memory is arranged serially in locations
  • Each location has a unique address with 32 bits for a typical 32 bit processor
  • Each location holds a byte
  • It is byte-addressable
  • The memory location stores a value that can represent program data or instructions

Memory Capacity

  • The total addressable space is bytes, i.e., 4 GB for a 32 bit processor
  • Memory is measured in KB (kilobytes), MB (megabytes), GB (gigabytes), and TB (terabytes)
  • One kilobyte is 1,024 bytes
  • One megabyte is 1,048,576 bytes
  • One gigabyte = 1,073,741,824 bytes
  • One terabyte = 1,099, 511,627,776 bytes

Computer Architecture

  • Von Neumann computer architecture includes instructions and data that is stored in the same memory using 1 data bus.
  • The Harvard computer architecture separates data and instructions into separate memories using 2 data buses and is employed in most microcontrollers.

Von Neumann architecture

  • The processor cannot fetch an instruction and access data simultaneously
  • All segments are loaded into the main memory
  • Memory bandwidth is shared
  • Inexpensive and straightforward

Harvard architecture

  • There are dual sets of data buses
  • Simultaneous fetch of instructions and data is possible
  • Segments of Z and RW, are copied into the data memory
  • Enhanced memory bandwidth = high/ speed performance
  • More efficient

Harvard ARM Microcontrollers

  • Instruction and data memory are small enough to fit within the same address space and share the same memory address bus
  • 4KB for instructional memory with Flash Memory and 256 KB for data memory with SRAM
  • Starting addresses of microcontrollers using Harvard Architecture: flash has 0x0800_0000 and SRAM has 0x2000_0000

Program loading in memory

  • When the processor loads a program, all initialised, uninitialised global, and local variables are kept in data memory
  • When the processor boots, it loads the first instruction of the program from the instruction memory, and the program starts to run.
  • At runtime, there are 4 segments: Initialized data, uninitialized or zero-initialized data aka block starting symbol (BSS), heap, and stack.
  • The size and location of initialised and uninitialised data remain unchanged. Heap and stack changes dynamically.
  • The Stack is mandatory and follows the first-in-last-out (FILO) protocol
  • The Heap is used only if dynamic assignemnt via malloc is used

Cortex M Memory Map

  • No overlap between SRAM, Flash Memory and Peripherals allowing for a convenient peripheral interface
  • Peripheral devices are a computer component and are separate from the computer's core architecture.

Peripheral Memory

  • A set of registers that include: data registers for data exchange between the peripheral and the processor, control registers that configure or control the peripheral, and status registers that indicate the operation state of the peripheral.
  • Peripheral Memory may also contain a small memory
  • Memory access instructions are predefined for each peripheral.

Registers

  • Also known as Processor Registers
  • This is the fastest data storage using digital values
  • General sizes are 16 bit, 32 bit and 64 bit
  • Cortez -M registers are 32 bits
  • The Processor reads or writes all bits of a register together
  • There are 2 register types: General purpose (GP), used to store any instruction (temporary storage), and special purpose (SP), which has predetermined usage and has restricted access
  • Registers are made of a series of flip-flops that operate in parallel to store binary bits
  • CPUs are limited to only 32 registers
  • Improves thermal behaviour due to highest temperature
  • The rules to follow in assembly for register allocation are: Inspect the live range of a variable and the registers; most frequently used variables should be mapped to registers, the rest to data memory

Types Of Registers

  • Stack pointer (SP), which is R13, holds the memory address of the top the stack.
  • Memory add of inst after subroutine occurs in the link register (LR) which is R14
  • The next instruction mem add occurs at the program counter PC
  • Program status register (xPSR) - is for status bit flags, containing info if the are negative, zero, carry, and overflow errors.
  • Base priority mask register (BASEPRI) - this is the priority threshold; lower values are a higher priority.
  • The control register (CONTROL) controls the choice of MSP or PSP
  • Priority mask register (PRIMASK) disables all interrupts, excluding hard and non-maskable interrupts (NMI)
  • Fault mask register (FAUL TMASK) can disable all interrupts, excluding non-maskable interrupts (NMI).
  • Cortex M general registers are R0-R12 for general purposes
  • Link register (LR) and Program counter are R14 and R15, respectively.

Program Counter

  • Plays a major role for Program execution
  • Holds the memory address of the next instruction
  • Processor fetches instructions consecutively from the instruction memory and automatically increments the program counter to where the next instruction is to be fetched

Program Execution Steps

  • The program counter (PC) is a register that holds the memory address of the next instruction is to be fetched from the memory
  • Steps 1: fetch instructions at the PC address
  • Step 2: decode the instruction
  • Step 3: execute the instruction in the CPU
  • Pipelining allows hardware resources to be fully utilized
  • One 32-bit instruction or two 16-bit instructions can be fetched at a time

Size specifications

  • Each memory address in byte based addressing is equivalent to only 1 byte.
  • The program counter is only incremented by one when addressing this way and the Microchip PIC series are examples.
  • Each memory address in word based addressing is the same an 2 bytes and also a single work, and the memory program counter is incremented by 2.
  • In DWord based memory addressing each address adds 4 bytes, and can be expressed as 32 bits or 1 DWord. The program counter is increased by 4 using Cortex M or Intel x86.
  • A Qword is the size equivalent to 8 bytes with 64 bits, and each increment of the program counter is increased by 4, and has a fetch size of 8, and is seen on Intel x86 64 or ARM 64 bit processors.

Incrementing on ARM Cortex M

  • The program counter always increments by 4.
  • If bit [15-11] = 11101, 11110, or 11111, then, it is the first half-word of a 32-bit instruction.
  • Otherwise, it is a 16-bit instruction.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Like This

Use Quizgecko on...
Browser
Browser