Week 5 Flashcards
Characteristics of HLL
One to many translation, hardware independent, application orientation, strongly omits hardware details, designed for programmer productivity, source code requiring translation is written in HLL
Characteristics of LLL
One to one translation, hardware dependent, systems programming orientation, few abstractions, special purpose, assembly code(LLL) is the result of translation by a compiler
Assembly Language
- Translated by an assembler
- Many assembly languages exist as it uses the instruction set and operands from a single processor, share the same fundamental structure.
- Programmer can switch between assembly languages quickly
- A single statement corresponds to a single machine instruction
Assembly Language Syntax
label: op result, operand1, operand2, … ; comment
Label (Assembly Language)
- Symbolic for the memory address pointing to the location storing this instruction
- Optional label used for branching
Op (Assembly Language)
Mnemonic for the operation to perform; one of the possible instructions
Operand (Assembly Language)
Specifies an operand for the instruction; usually a pointer or immediate value
Operand Order
Target register on the left, source register on the right
Register Names
Example of naming register 10: $10, R10, r10
Memory Pointer Syntax
Example of loading a register (r2) from memory at the location pointed to by register r1: ldr r2, (r1)
Operand Types
Immediate, Reference to register, Reference to memory
Block Comment
Explain purpose of and detail register and memory use for a code section
Line comment
Explain purpose of one instruction
Conditional Execution
Code that may or may not be executed depending on a certain condition
Branch Instruction
if (expression) {
PC(Current Instruction ptr) + Offset: This is the branch target addy
else {
PC = PC + sizeof(instr.(usually 4 bytes))
Offset
Bytes between Branch instruction first byte and target instruction first byte
Assembler
Translates assembly language programs into binary code for the processor to execute
Assembler vs. Compiler
Similarities: Both translate a source program into equivalent binary code
Differences: Compiler has more freedom to choose which values are stored in registers and allocation of variables to memory, whereas an assembler is a one-to-one translation
Two-pass Algorithm
Assembler follows this: First pass stores label names and its relative memory address in a symbol table; also stores locations for each statement. The second pass constructs machine code bit strings by using labels & locations calculated by first pass
One-pass Algorithm
Compilers follow this: Compilation is intensive and declaring and defining is much more readable
Fall through instruction
Default next instruction after a branch instruction
Where is increment for a for loop in assembly
After the code that performs the body
Overhead
Additional computational work that occurs due only to the use of a fixed iteration loop
jsr
Saves the current location and branches to a subroutine at a specified location