Assembly Language(1.2.4 c) Flashcards
What is assembly language?
when a program is executing the processor receives instructions from RAM in a sequential order
these instructions are coded in assembly language
decode unit takes assembly language instruction in binary and decodes them into a valid operation
What is Little Man Computer(LMC)?
an instruction set designed for educational purposes
contains 11 instructions(mnemonic) to demonstrate important concepts or tracing and writing assembly code
ADD
add
0001
1
SUB
subtract
0010
2
STA
store
0011
3
LDA
load
0101
5
BRA
branch always
0110
6
BRZ
branch if zero
0111
7
BRP
branch if positive
1000
8
INP
input
1001 1001
9(1)
OUT
output
1001 0010
9(2)
HLT
end program
0000
0
DAT
data location
What is tracing?
the process of following the flow of information through each line of program and calculating values or outputs that would occur
00 INP
01 STA 05
02 INP
03 ADD 05
04 OUT
05 DAT 00(gets overwritten)
takes input from user
stores inputted data in memory location 05
takes a second input from the user
adds value stored in location 05
outputs result to the console
INP(LMC and registers)
loads data inputted by user dirrectyly into the ACC
STA(LMC and registers)
sends data from ACC to RAM via MAR and MDR
LDA(LMC and registers)
reads data from RAM via MAR and MDR into ACC
OUT(LMC and registers)
send value currently in ACC to the console
ADD(LMC and registers)
takes data from RAM via MAR and MDR and adds to value currently in ACC
SUB(LMC and registers)
takes data from RAM via the MAR and MDR and subtracts it from the value currently in the ACC
BRA,BRP,BRZ(LMC and registers)
may instruct the Program Counter (PC) to change the address of the next instruction, which then gets passed to the MAR
Branching
there is no multiplication or subtraction so loops of repeated adding and subtracting are needed
there are no while loops so BRA, BRZ and BRP are used
Branching BRA
indicates that the memory location in the operand should be the next line executed regardless of the value of the ACC
Branching BRZ
indicates that the memory location in the operand should be the next line executed if the ACC is currently 0, otherwise continue executing lines in sequence
Branching BRP
indicates that the memory location in the operand should be executed if the ACC is not negative, otherwise continue executing lines in sequence