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
LDM #n
load n into the ACC
LDR #n
load n to the IX
LDD <address>
load contents of that address to the ACC
LDI <address>
load the contents of the second address stored in the address to the ACC
LDX <address>
add the address to the IX and load the contents of this calculated address tot he ACC
MOV <register></register>
Move the contents of the accumulator to the given register
STO <address>
Store the contents of ACC at the given address
IN
store in the ACC the ASCII value of a character typed at the keyboard
OUT
used to display on the screen the character for which the ASCII code is stored in the ACC
JMP <address>
jump to the given address if a condition is met
CMP <address>
Compare the contents of ACC with the contents of <address>
CMP #n
Compare the contents of ACC with the number n
CMI <address>
Indirect addressing. The address to be used is at the given address. Compare the contents of ACC with the contents of this second address
JPE <address>
following a compare instruction, jump to <address> if the compare was True
JPN <address>
Following a compare instruction, jump to <address> if the compare was False
ADD<address>
Add the contents of the given address to the ACC
ADD#n
Add the denary number n to the ACC
SUB <address>
Subtract the contents of the given address from the ACC
SUB #n
Subtract the denary number n from the ACC
INC <register></register>
Add 1 to the contents of the register (ACC or IX)
DEC <register></register>
Subtract 1 from the contents of the register (ACC or IX)
LSL #n
where the bits in the accumulator are shifted logically n places to the left
LSR #n
where the bits are shifted n places to the right.