CS2640 Exam 2 Flashcards
Focus on Macros & Functions (19 cards)
Labels
User-defined functions i.e. “main” or “doubleIt”
Used by programmer to refer to specific lines in the code.
Instructions
Typically followed by operand or address
add, sub
Operands
Addresses
Holds data/info to be used by instruction. More than 1 may follow an instruction.
Comments
For user reference.
Specifies the purpose of a segment of code,
2 Pass Assembler
Pass 1: Analysis - goes thru program step by step to look for symbols and literals.
Pass 2: Synthesis/combination - puts together the symbols, literals, and opcodes to make a binary/object code.
Symbols
Variables and labels
Literals
Constants
Pass 1 - Analysis
Passes thru instructions in sequence looking for symbol addresses
Creates symbol table and literal table.
Keep track of location counter
Deals with pseudo operations i.e. macros and directives.
Error checking
Macros
Named subroutines that can be used more than once. Makes programming easier and more modular.
Directives
Configuration instructions for assembler i.e. malloc. Not a program instruction.
Pass 2 - Synthesis
If no errors are found in pass one, the second pass assembles the code into object code.
Symbolic addresses are replaced w/ absolute addresses.
Symbolic opcodes are replaced with binary opcodes.
Memory vs Register Operands
Memory Operands have long-term storage and are byte addressed.
1 word takes up 4 address spaces (register is 32-bit and address stores 8-bits)
Big Endian
MSB is stored at smallest address.
Little Endian
Little byte, little address.
MSB stored at largest address.
Accessing registers is faster than accessing memory
TRUE
lw and sw are necessary to complete operations on data stored in memory
TRUE
Registers should NOT be treated as variables
FALSE, always use registers for variables.
addi and subi can be used to add/subtract constants
FALSE, subi does not exist. Addi a negative constant instead.