Assembly Language Flashcards
Machine language
○ bit patterns that are directly executable by computer
○ May look like gibberish to humans but it is actually the binary encoded instructions that the CPU can understand.
○ May also contain data in addition to instructions.
○ Assembled into files called objects, binaries, executables, which specify how the machine memory should be set up
Assembly language
○ symbolic representation of machine language
○ Instructions as mnemonic ASCII strings e.g. ADD R2, R6, R2
○ Cannot run but mostly readable by humans
○ Can be handwritten or produced by a compiler from a high level language (like C)
○ Assembly files can also contain ASCII labels e.g. BRnzp LOOP
○ ISA dependent. (High level languages usually ISA independent). Usually the case that each ISA has only one assembly language
Assembler
used to translate assembly programs (.ASM) into machine code (.OBJ)
object file that is a specification for how the machine memory should be set up.
Linking
process of connecting several .OBJ files together into one executable program
Programming:
process of designing/writing/testing/debugging/maintaining the “source code” of computer programs
Conditional control
a way for our program to change the natural flow of a program based on a condition
Subroutine
group of instructions meant to perform a specific task e.g. square a number, print out a string, etc. in assembly; similar to a “function” in a high level language
Pointers
variable storing a memory address (as opposed to a regular variable that holds data)
Dereferencing
act of using the memory address held onto by a
pointer to read/write from the memory location held onto by that pointer
Assembly directives
provide an indication to the assembler of where it should place various blocks of code or data
How does assembler program operate
2 Phases:
First Phase: convert labels into offsets and remove comments
Second Phase: Converts assembly code into machine code. Uses ISA to do this and saves it in .obj file
After assembler finishes, a loader program load it into computer memory
Partitioning of LC4 Memory
User Region: - Programs run by user as excel Processes run in user Mode (PSR[15]=0) are not allowed to access OS location in memory - User Code: x0000 - x1FFF - User Data: x2000 - x7FFF
OS region:
- Processes run in OS mode with PSR[15]=1
- OS Code: x8000 - x9FFF. However, 1st address in OS is at x8200. Bw. x8000-x8200 -> TRAP Table
- OS Data + Device Memory: xA000 - xFFFF
.DATA
Next values are in data memory
.ADDR
Set current address to the specified value
.FILL IMM16
Set value at the current address to the specified 16-bit value