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
ret
Causes the processor to return to the previously saved location
Amdahl’s Law
Speedup Overall = Original Execution Time / Execution time using enhancement
fe
Fraction enhanced, the portion of the original execution sped up; 0 <= fe <= 1
Se
Speedup when the enhancement is in use; Se = Time to execute fe without enhancement / Time to execute fe with use of enhancement
Where is HLL in the compilation process?
source code requiring translation is written with HLL
Where is assembly in the compilation process?
assembly code is the result of translation by COMPILER
List 3 problems that occur from manual offset computation:
1) Programmer error in offset calculation breaks program
2) programmer deletes or inserts an instruction between branch and target (offset must be revised because number of bytes between branch and target has changed)
3) Programmer productivity and happiness decline
knowing that jsr occupies locations 0x0C - 0x0F in memory, what is the sign magnitude decimal offset value and using it to go to label3, if label3 occupies locations 0x18 - 0x1B?
+12 (Week 5 slide 27 for more examples)
Two-pass makes _____ references
forward references (undefined references), not an error; they resolve eventually
assembly branches when previous compare is _____
false
How do you fetch sequentially next fast?
1) Dedicate hardware outside the ALU to speed the computation of the pointer to the most common next machine instruction, call it the Default Next Instruction Pointer
2) Design the Default_Next_Instruction_Pointer circuit for a processor with a 4-byte, fixed-length machine instruction format