4 - assembly language Flashcards
machine code
- binary code with a defined no. bits that comprise of opcode and operands
- CPU only recognises MC (0,1s)
- instructions contain opcode and operands (0-3)
- different processors have different instruction sets
- actions taken by the processor are directly controlled in MC
for each processor, each machine instruction must define the following
- total no. bits for the whole instruction
- the no. bits that define the opcode
- whether the opcode occupies the MSB or LSB
- the no. operands that are defined in the remaining bits
assembly language
- each processor has its own MC and AL equivalent
- AL is a low level language related to MC where opcodes are written as mnemonics and operands as character representations
what can you do in AL not MC
- programmers can add comments
- symbolic names for constants
- macros (sequence of instructions that can be used more than once)
- directives - an instruction to the assembler for how to construct a final MC eg how memory should be used
- labels for addresses
macro
sequence of instructions that can be used more than once
directives
an instruction to the assembler for how to construct a final MC eg how memory should be used
assembler
a program used to translate AL to MC
op code
- defines the action associated with the instruction
- 8b
operand
- defines data needed by instruction
- 16b binary no.
- usually address but for SUB and LDM it’s a value
- no operand for IN and END instructiont
symbolic addressing
- allows programmer to write assembly language code without worrying about where the code will be stored in memory when its run -
relative addressing
- defines a base register from which an offset is defined
absolute addressing
- allows programmer to specify exact addresses to use in a program
addressing modes
immediate - operand is the value to be used in the instructions
direct - the operand is the address which holds the value to be used in the instruction
indirect - the operand is an address which holds the address to be used in the instruction
indexed - the operand is an address which must be added to the value in the IX
two pass assembler (first pass)
location of addresses for forward references are identified eg the base register
- Uses a symbol table
- Reads code line by line - counts instructions as it reads so can enter the offset value in the address column
- When meets a symbolic address its name is put in the symbol table
- Corresponding address is also added so it can be identified
two pass assembler (second pass)
uses symbol table and a lookup table
- Lookup table - contains binary code for each opcode - has an entry for every opcode in the set defined for the processor