what does the instruction INP do, make reference to a register
instruction INP, puts the value input by the user into the accumulator - a register (small area of fast memory) which stores the intermediate results of arithmetic and logical (1 or 0) calculations
what are all the LMC instructions
INP - input, loaded into acc, overwriting value that was already there
ADD - add value found in specified memory location to value in the acc
SUB - subtract, value found in specified memory from value in acc
STA - stores the contents of the acc into the specified memory location
LDA - loads the acc with the contents of the specified memory location overwriting any value that was already there
BRA - banch always to the given labelled instruction.
BRZ - branch if zero, if the value in the acc is 0, branch to the given labelled instruction.
BRP - branch if positive or zero, if the value in the accumulator is zero or positive, branch to the given labelled instruction
OUT - outputs contents of acc
HLT - halt, ends program
DAT
why is assembly language needed
allows better control over memory than a high level language.
usually runs faster than programs written using a high level language.
what are the four modes of addressing
describe immediate addressing (literal)
operand is an actual valu e.g. a literal number, rather than a memory location (literal)
needs no access to RAM - no fetch is required
range of values is limited by the size of the operand (e.g. if there are 4 bits for the operand, the literal value can only be 0 - 15)
direct addressing (pointer)
operand is a memory location, like Little Man Computer
this mode is good when programmer a wants global variable
address is constant throughout the program executive since it’s part of the assembly program instruction
indirect addressing (pointer to pointer)
operand is a memory location pointing to another memory location to be used
multiple fetches are required
this mode allows access to more memory, since an 8 bit instruction might have 4 bits for the opcode, 4 bits for the operand (max 16 memory locations can be referenced). The pointed to memory location can use all 8 bits to reference 128 memory locations available
with code, we can compute indirect memory addresses and change their values e.g. from 97 to 73; without it, things like linked lists (year 2) would be impossible
indexed addressing (pointer plus offset)
operand is a memory location plus an offset stored in a special ‘index register’
this mode is ideal to store and access values stored sequentially e.g. in arrays since arrays are stored in contiguous memory locations. The pointer points to the memory location of the first element in the array.
by incrementing or decrementing the offset, different elements of the array can be indexed.
what is a low level language typically used in
embedded systems with minimal resources, e.g. washing machine
device drivers which need to communicate directly with hardware
real-time systems like an OS that is designed to carry out actions in a guaranteed amount of time, usually a small fraction of a second e.g. auto-pilot systems on aircraft.