4-up pdf

Basic Characteristics of TOY Machine
The TOY Machine
TOY is a general-purpose computer.


Sufficient power to perform ANY
computation.
Limited only by amount of memory and
time.
Stored-program computer. (von
Neumann memo, 1944)


John von Neumann
Data and instructions encoded in binary.
Data and instructions stored in SAME
memory.
All modern computers are general-purpose computers
and have same (von Neumann/Princeton) architecture.
Maurice Wilkes (left)
EDSAC (right)
Introduction to Computer Science • Robert Sedgewick and Kevin Wayne • Copyright © 2005 • http://www.cs.Princeton.EDU/IntroCS
2
What is TOY?
What is TOY?
An imaginary machine similar to:

An imaginary machine similar to:
Ancient computers. (PDP-8, world's first
commercially successful minicomputer.
1960s)
–
–
–


Ancient computers.
Today's microprocessors.
12-bit words
2K words of memory
Used in Apollo project
Pentium
3
Celeron
4
What is TOY?
Inside the Box
An imaginary machine similar to:


Switches. Input data
and programs.
Ancient computers.
Today's microprocessors.
Lights. View data.
Why study TOY?

Machine language programming.
–
–


Computer architecture.
–
–


how is a computer put together?
how does it work?

Optimized for understandability, not cost or
performance.



Stores data and programs.
256 "words." (16 bits
each)
Special word for stdin /
stdout.
Program counter (PC).



Memory.
how do high-level programs relate to computer?
a favor of assembly programming
Registers.
An extra 8-bit register.
Keeps track of next
instruction to be executed.
Fastest form of storage.
Scratch space during
computation.
16 registers. (16 bits each)
Register 0 is always 0.
Arithmetic-logic unit
(ALU). Manipulate data
stored in registers.
Standard input, standard
output. Interact with
outside world.
5
6
Machine "Core" Dump
Program and Data
Machine contents at a particular place and
time.


Record of what program has done.
Completely determines what machine will do.
Program: Sequence of instructions.
16 instruction types:
2: subtract


Registers
R0
R1
R2
R3
pc
Main Memory
10
00: 0008 0005 0000 0000 0000 0000 0000 0000
R4
R5
R6
R7
0000 0000 0000 0000
R8
R9
RA
10: 8A00 8B01 1CAB 9C02 0000 0000 0000 0000
next
instruction

18: 0000 0000 0000 0000 0000 0000 0000 0000
data
RB
RC
RD
RE
RF
program
0000 0000 0000 0000

.
.
E8: 0000 0000 0000 0000 0000 0000 0000 0000
variables
16-bit word (interpreted other way).
Program counter (PC):
20: 0000 0000 0000 0000 0000 0000 0000 0000
28: 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000
16-bit word (interpreted one way).
Changes contents of registers,
memory, and
PC in specified, well-defined ways.
Data:
08: 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000

F0: 0000 0000 0000 0000 0000 0000 0000 0000
Instructions
0: halt
Stores memory address of "next
instruction.“
TOY usually starts at address 10.
1: add
3: and
4: xor
5: shift left
6: shift right
7: load address
8: load
9: store
A: load indirect
B: store indirect
C: branch zero
D: branch positive
E: jump register
F: jump and link
F8: 0000 0000 0000 0000 0000 0000 0000 0000
7
8
TOY Architecture (level 1)
TOY Reference Card
Format 1
15 14 13 12 11 10 9
opcode
dest d
Format 2
#
opcode
Operation
8
7
6
5
46 3
2
1
0
source s
source t
dest d
Fmt
addr
Pseudocode
0:
halt
1
exit(0)
1:
add
1
R[d]  R[s] +
R[t]
2:
subtract
1
R[d]  R[s] -
R[t]
3:
and
1
R[d]  R[s] &
R[t]
4:
xor
1
R[d]  R[s] ^
R[t]
5:
shift left
1
R[d]  R[s] << R[t]
6:
shift right
1
R[d]  R[s] >> R[t]
7:
load addr
2
R[d]  addr
8:
load
2
R[d]  mem[addr]
9:
store
2
mem[addr]  R[d]
A:
load indirect
1
R[d]  mem[R[t]]
B:
store indirect
1
mem[R[t]]  R[d]
C:
branch zero
2
if (R[d] == 0) pc  addr
D:
branch positive
2
if (R[d] > 0)
E:
jump register
1
pc  R[t]
F:
jump and link
2
R[d]  pc; pc  addr
Register 0 always 0.
Loads from mem[FF]
from stdin.
Stores to mem[FF] to
stdout.
pc  addr
9
10
level 0
Programming in TOY
Hello, World. Add two numbers.

11
Adds 8 + 5 = D.
12
A Sample Program
Load
A sample program.

Load. (opcode 8)
Adds 8 + 5 = D.


00: 0008
01: 0005
RA
RB
RC
pc
0000
0000
0000
10
10:
11:
12:
13:
14:
Registers
add.toy
8
5
RA  mem[00]
RB  mem[01]
RC  RA + RB
mem[FF]  RC
halt
8A00
8B01
1CAB
9CFF
0000
Loads the contents of some memory location into a
register.
8A00 means load the contents of memory cell 00
into register A.
add.toy
00: 0008
8
RA
RB
RC
pc
0000
0000
0000
10
Registers
01: 0005
5
10:
11:
12:
13:
14:
RA  mem[00]
RB  mem[01]
RC  RA + RB
mem[FF]  RC
halt
8A00
8B01
1CAB
9CFF
0000
Memory
15
14
13
12
11
10
9
8
7
6
5
46 3
2
1
0
1
0
0
0
1
0
1
0
0
0
0
0? 0
0
0
0
Since PC = 10, machine interprets 8A00 as an instruction.
816
A16
0016
opcode
dest d
addr
13
14
Load
Add
Load. (opcode 8)


Add. (opcode 1)
Loads the contents of some memory location into a
register.
8B01 means load the contents of memory cell 01
into register B.
add.toy
00: 0008
8
01: 0005
RA
RB
RC
pc
0008
0000
0000
11
10:
11:
12:
13:
14:
Registers
8A00
8B01
1CAB
9CFF
0000


Add contents of two registers and store sum in a
third.
1CAB adds the contents of registers A and B and
put the result into register C. 00: 0008 8
add.toy
5
RA  mem[00]
RB  mem[01]
RC  RA + RB
mem[FF]  RC
halt
RA
RB
RC
pc
0008
0005
0000
12
Registers
15
14
13
12
11
10
9
8
7
6
5
46 3
2
1
0
15
14
13
12
11
10
9
8
7
6
1
0
0
0
1
0
1
1
0
0
0
0? 0
0
0
1
0
0
0
1
1
1
0
0
1
0
01: 0005
5
10:
11:
12:
13:
14:
RA  mem[00]
RB  mem[01]
RC  RA + RB
mem[FF]  RC
halt
8A00
8B01
1CAB
9CFF
0000
5
46 3
2
1
0? 1
0
1
0
1
1
816
B16
0116
116
C16
A16
B16
opcode
dest d
addr
opcode
dest d
source s
source t
15
16
Store
Halt
Store. (opcode 9)


Halt. (opcode 0)
Stores the contents of some register into a
memory cell.
9CFF means store the contents of register C into
memory cell FF (stdout).
add.toy
00: 0008
8
01: 0005
RA
RB
RC
pc
0008
0005
000D
13
10:
11:
12:
13:
14:
Registers
8A00
8B01
1CAB
9CFF
0000
RA  mem[00]
RB  mem[01]
RC  RA + RB
mem[FF]  RC
halt
14
13
12
11
10
9
8
7
6
5
46 3
2
1
0
1
0
0
1
1
1
0
0
0
0
0
0? 0
0
1
0
916
C16
0216
dest d
addr
Stop the machine.
5
15
opcode

RA
RB
RC
pc
0008
0005
000D
14
Registers
add.toy
00: 0008
01: 0005
8
5
10:
11:
12:
13:
14:
RA  mem[00]
RB  mem[01]
RC  RA + RB
mem[FF]  RC
halt
8A00
8B01
1CAB
9CFF
0000
17
18
Simulation
Interfacing with the TOY Machine
Consequences of simulation.

–



cheaper and faster than building actual machine

Easy to add new functionality to simulator.
–
–

To enter a program or data:
Test out new machine or microprocessor using
simulator.
–
trace, single-step, breakpoint debugging
simulator more useful than TOY itself

Ancient programs still running on modern
computers.

data written into addressed word of memory
To view the results of a program:
Reuse software from old machines.


Set 8 memory address switches.
Set 16 data switches.
Press LOAD.
Set 8 memory address switches.
Press LOOK: contents of addressed word appears
in lights.
Lode Runner on Apple IIe.
Gameboy simulator on PCs.
19
20
Branch in TOY
Using the TOY Machine: Run
To run the program:



To harness the power of TOY, need loops and
conditionals.
Set 8 memory address switches to address of first
instruction.
Press LOOK to set PC to first instruction.
Press RUN button to repeat fetch-execute cycle
until halt opcode.

Manipulate PC to control program flow.
Branch if zero. (opcode C)
Fetch


Changes PC depending of value of some register.
Used to implement: for, while, if-else.
Branch if positive. (opcode D)
Execute

Analogous.
22
21
An Example: Multiplication
Multiply
Multiply.



No direct support in TOY hardware.
Load in integers a and b, and store c = a  b.
Brute-force algorithm:
–
–
initialize c = 0
add b to c, a times
int a = 3;
int b = 9;
int c = 0;
int a = 3;
int b = 9;
int c = 0;
while (a != 0) {
c = c + b;
a = a - 1;
}
while (a != 0) {
c = c + b;
a = a - 1;
}
Java
Issues ignored: slow, overflow, negative
numbers.
23
24
Step-By-Step Trace
Multiply
0A: 0003
0B: 0009
0C: 0000
3
9
0
0D: 0000
0E: 0001
0
1
10: 8A0A
11: 8B0B
12: 8C0D
loop
constants
RA  mem[0A]
RB  mem[0B]
RC  mem[0D]
R1  mem[0E]
14:
15:
16:
17:
if
RC
RA
pc
18: 9CFF
19: 0000
10:
11:
12:
13:
14:
15:
16:
17:
14:
15:
16:
17:
14:
15:
16:
17:
14:
18:
19:
output
13: 810E
CA18
1CCB
2AA1
C014
R1
inputs
a
b
c = 0
always 1
(RA == 0) pc  18
 RC + RB
 RA - R1
 14
while (a != 0) {
c = c + b
a = a - 1
}
mem[FF]  RC
halt
8A0A
8B0B
8C0D
810E
CA18
1CCB
2AA1
C014
CA18
1CCB
2AA1
C014
CA18
1CCB
2AA1
C014
CA18
9CFF
0000
RA  mem[0A]
RB  mem[0B]
RC  mem[0D]
R1  mem[0E]
if (RA == 0) pc
RC  RC + RB
RA  RA – R1
pc  14
if (RA == 0) pc
RC  RC + RB
RA  RA – R1
pc  14
if (RA == 0) pc
RC  RC + RB
RA  RA – R1
pc  14
if (RA == 0) pc
mem[FF]  RC
halt
RA
0003
RB
RC
0009
0000
0001
 18
0009
0002
 18
0012
0001
 18
001B
0000
 18
multiply.toy
multiply.toy
25
26
An Efficient Multiplication Algorithm
Binary Multiplication
Inefficient multiply.


Grade school binary multiplication algorithm
to compute c = a  b.
1 0 1 1
Brute force multiplication algorithm loops a times.
In worst case, 65,535 additions!


–
"Grade-school" multiplication.

Initialize c = 0.
Loop over i bits of b.
–
Always 16 additions to multiply 16-bit integers.
* 1 1 0 1
1 0 1 1
if bi = 0, do nothing
bi = ith bit of b
if bi = 1, shift a left i bits and
add to c
Decimal
* 1 5 1 2
2 4 6 8
1 2 3 4
6 1 7 0
1 2 3 4
0 1 8 6 5 8 0 8
Binary
1 0 1 1
1 0 1 1
Implement with built-in TOY shift
instructions.
* 1 1 0 1
1 0 1 1
0 0 0 0
int c = 0;
for (int i = 15; i >= 0; i--)
if (((b >> i) & 1) == 1)
c = c + (a << i);
1 0 1 1
1 0 1 1
b
a << 0
0 0 0 0
1 0 1 1
1 2 3 4
a
1 0 0 0 1 1 1 1
a << 2
a << 3
c
bi = ith bit of b
1 0 0 0 1 1 1 1
27
28
Shift Left
Shift Right
Shift left. (opcode 5)

Shift right. (opcode 6)
Move bits to the left, padding with zeros as needed.

123416 << 716 = 1A0016


Move bits to the right, padding with sign bit as
needed.
123416 >> 716 = 002416
discard
discard
sign bit
0
0
0
1
0
0
116
1
0
0
0
216
1
0
0
1
1
0
116
0
1
1
0
0
A16
0
0
0
0
0
0
0
0
0
016
0
0
1
0
0
0
0
0
0
0
0
0
016
0
1
1? 0
1
316
pad with 0’s
016
0
216
pad with 0’s
0
1
116
416
<< 7
0
1
316
0
0
0
0
416
>> 7
0
0
0
016
0
1
0
0
216
1
416
29
30
Shift Right (Sign Extension)
Bitwise AND
Shift right. (opcode 6)





AND
0
0
0
Logic operations are BITWISE.
0
1
0
002416 & 000116 = 000016
1
0
0
1
1
1
discard
sign bit
1
y
Logical AND. (opcode 3)
Move bits to the right, padding with sign bit as
needed.
FFCA16 >> 216 = FFF216
-5310 >> 210 = -1310
x
0
1
1
1
1
1
F16
1
1
1
1
F16
0
0
1
0
C16
pad with 1s
1
0
0
0
0
0
016
0
1
1
F16
1
1
1
F16
1
1
0
1
1
F16
1
0
0
0
0
1
0? 0
1
216
0
0
0
1
0
0
416
&
>> 2
1
0
A16
0
0
0
0
0
016
1
0
016
1
0
0
0
0
016
0
0? 0
0
016
116
=
0
0
216
0
0
016
31
0
0
0
0
016
0
0
0
0
016
0
0
0
016
32
Shifting and Masking
Binary Multiplication
Shift and mask: get the 7th bit of 1234.


int c = 0;
for (int i = 15; i >= 0; i--)
if (((b >> i) & 1) == 1)
c = c + (a << i);
Compute 123416 >> 716 = 002416.
Compute 002416 && 116 = 016.
0
0
0
1
0
0
116
1
0
0
0
216
1
1? 0
1
316
0
0
0
0
0
1
0
0
416
>> 7
0
0
0
0
0
0
016
0
0
0
0
016
1
0
0
1
216
416
&
0
0
0
0
0
0
016
0
0
0
0
016
0
0? 0
0
016
116
=
0
0
0
0
0
016
0
0
0
0
016
0
0
0
0
016
0
016
33
34
Binary Multiplication
0A:
0B:
0C:
0D:
0E:
0F:
0003
0009
0000
0000
0001
0010
3
9
0
0
1
16
10:
11:
12:
13:
14:
8A0A
8B0B
8C0D
810E
820F
RA
RB
RC
R1
R2
Useful TOY "Idioms"
Jump absolute.
inputs
output

–
constants
–
15:
16:
17:
branch 18:
19:
1A:
1B:
2221
53A2
64B2
3441
C41B
1CC3
D215
R2
R3
R4
R4
if
RC
if
branch if zero with destination
register 0 is always 0
17: C014





mem[0A]
mem[0B]
mem[0D]
mem[0E]
mem[0F]
a
b
c = 0
always 1
i = 16
 R2 - R1
 RA << R2
 RB >> R2
 R4 & R1
(R4 == 0) goto 1B
 RC + R3
(R2 > 0) goto 15

16 bit words
No instruction that transfers contents of one
register into another.
Pseudo-instruction that simulates assignment:
–
do {
i-a << i
b >> i
bi = ith bit of b
if bi is 1
add a << i to sum
} while (i > 0);
add with register 0 as one of two source registers
No-op.


17: 1230
mem[FF]  RC
R[2]  R[3]
Instruction that does nothing.
Plays the role of whitespace in C programs.
–
numerous other possibilities!
17: 1000
1C: 9CFF
pc  14
Register assignment.

loop
Jump to a fixed memory address.
no-op
multiply-fast.toy
35
36
Standard Input and Output: Implications
Fibonacci Numbers
Standard input and output enable you to:


Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21,
34, . . .
Process more information than fits in memory.
Interact with the computer while it is running.
 0

Fn   1
 F  F
 n1 n2
Standard output.


Writing to memory location FF sends one word to
TOY stdout.
9AFF writes the integer in register A to stdout.
if n  0
if n  1
otherwise
Standard input.


Loading from memory address FF loads one word
from TOY stdin.
8AFF reads in an integer from stdin and store it in
register A.
Reference: http://www.mcs.surrey.ac.uk/Personal/R.Knott/Fibonacci/fibnat.html
37
38
Standard Output
00: 0000
01: 0001
0
1
10: 8A00
11: 8B01
RA  mem[00]
RB  mem[01]
12:
13:
14:
15:
16:
print RA
RA  RA + RB
RB  RA - RB
if (RA > 0) goto 12
halt
9AFF
1AAB
2BAB
DA12
0000
fibonacci.toy
a = 0
b = 1
do {
print a
a = a + b
b = a - b
} while (a > 0)
Standard Input
Ex: read in a sequence of integers and print
their sum.
0000
0001
0001
0002
0003
0005
0008
000D
0015
0022
0037
0059
0090
00E9
0179
0262
03DB
063D
0A18
1055
1A6D
2AC2
452F
6FF1


In Java, stop reading when EOF.
In TOY, stop reading when user enters 0000.
while(!StdIn.isEmpty()) {
a = StdIn.readInt();
sum = sum + a;
}
System.out.println(sum);
39
00AE
0046
0003
0000
00F7
00: 0000
0
10:
11:
12:
13:
14:
15:
16:
RC <- mem[00]
read RA
if (RA == 0) pc  15
RC  RC + RA
pc  11
write RC
halt
8C00
8AFF
CA15
1CCA
C011
9CFF
0000
40
Load Address (a.k.a. Load Constant)
Arrays in TOY
Load address. (opcode 7)






Applications.

TOY main memory is a giant array.
Loads an 8-bit integer into a register.
7A30 means load the value 30 into register A.
a = 30;
Load indirect. (opcode A)
Load a small constant into a register.
Java code
Load a 8-bit memory address into a register.
–

register stores "pointer" to a memory cell
14
13
12
11
10
9
8
7
6
0
1
1
1
1
0
1
0
0
0
716
A16
opcode
dest d
AC06
means load mem[R6] into register C.
a variable index (like a pointer)
Store indirect. (opcode B)

15
Can access memory cell 30 using load and store.
8C30 means load mem[30] into register C.
Goal: access memory cell i where i is a variable.
5
4 6 3
2
1
1 ? 0
0
316
1
0
0
0
BC06 means
mem[R6].
a variable index
016
store contents of register C into
for (int i = 0; i < N; i++)
a[i] = StdIn.readInt();
for (int i = 0; i < N; i++)
System.out.println(a[N-i-1]);
addr
Reverse.java
41
42
TOY Implementation of Reverse
TOY Implementation of Reverse
TOY implementation of reverse.



TOY implementation of reverse.
Read in a sequence of integers and store in memory
30, 31, 32, …
Stop reading if 0000.
Print sequence in reverse order.



Read in a sequence of integers and store in memory
30, 31, 32, …
Stop reading if 0000.
Print sequence in reverse order.
10: 7101
11: 7A30
12: 7B00
R1  0001
RA  0030
RB  0000
constant 1
a[]
n
13:
14:
15:
16:
17:
18:
read RC
if (RC == 0) goto 19
R6  RA + RB
mem[R6]  RC
RB  RB + R1
goto 13
while(true) {
c = StdIn.readInt();
if (c == 0) break;
address of a[n]
a[n] = c;
n++;
}
8CFF
CC19
16AB
BC06
1BB1
C013
read in the data
43
44
TOY Implementation of Reverse
Unsafe Code at any Speed
TOY implementation of reverse.



What happens if we make array start at 00
instead of 30?
Read in a sequence of integers and store in memory
30, 31, 32, …
Stop reading if 0000.
Print sequence in reverse order.
19:
1A:
1B:
1C:
1D:
1E:
1F:
20:
CB20
16AB
2661
AC06
9CFF
2BB1
C019
0000


if (RB == 0) goto 20
while (n > 0) {
R6  RA + RB
address of a[n]
R6  R6 – R1
address of a[n-1]
RC  mem[R6]
c = a[n-1];
write RC
System.out.println(c);
RB  RB – R1
n--;
goto 19
}
halt
print in reverse order
Self modifying program.
Exploit buffer overrun and run arbitrary code!
10: 7101
11: 7A00
12: 7B00
R1  0001
RA  0000
RB  0000
constant 1
a[]
n
13:
14:
15:
16:
17:
18:
read RC
if (RC == 0) goto 19
R6  RA + RB
mem[R6]  RC
RB  RB + R1
goto 13
while(true) {
c = StdIn.readInt();
if (c == 0) break;
address of a[n]
a[n] = c;
n++;
}
Crazy 8s Input
8CFF
CC19
16AB
BC06
1BB1
C013
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
8888 8810
98FF C011
45
46
What Can Happen When We Lose Control?
Buffer overrun.




Function Call: A Failed Attempt
Goal: x  y  z.
#include <stdio.h>
int main(void) {
char buffer[100];
scanf("%s", buffer);
printf("%s\n", buffer);
return 0;
}
Array buffer[] has size 100.
User might enter 200 characters.
Might lose control of machine behavior.
Majority of viruses and worms caused by
similar errors.

 Solution 1: write multiply code 2 times.
 Solution 2: write a TOY function.
A failed attempt:
unsafe C program


Robert Morris Internet Worm.


Need two multiplications: x  y, (x  y)  z.
Cornell grad student injected worm into Internet
in 1988.
Exploited buffer overrun in finger daemon fingerd.



Write multiply loop at 30-36.
Calling program agrees to store arguments
in registers A and B.
Function agrees to leave result in register C.
Call function with jump absolute to 30.
Return from function with jump absolute.
Reason for failure.
 Need to return to a VARIABLE
memory address.
47
function?
10:
11:
12:
13:
14:
15:
16:
17:
8AFF
8BFF
C030
1AC0
8BFF
C030
9CFF
0000
30:
31:
32:
33:
34:
35:
36:
7C00
7101
CA36
1CCB
2AA1
C032
C013?
48
Multiplication Function
Calling convention.






Jump to line 30.
Store a and b in registers A and B.
Return address in register F.
Put result c = a  b in register C.
Register 1 is scratch.
Overwrites registers A and B.
function.toy
30:
31:
32:
33:
34:
35:
36:
7C00
7101
CA36
1CCB
2AA1
C032
EF00
R[C]  00
R[1]  01
if (R[A] == 0) goto 36
R[C] += R[B]
R[A]-opcode E
goto 32
jump register
pc  R[F]
return
Multiplication Function Call
Client program to compute x  y  z.
function
10:
11:
12:
13:
14:
15:
16:
17:
30:
31:
32:
33:
34:
35:
36:

8AFF
8BFF
FF30
1AC0
8BFF
FF30
9CFF
0000

Read x, y, z from standard input.
Note: PC is incremented before instruction is
executed.
–
value stored in register F is correct return address
opcode F
jump and link
function.toy (cont)
10:
11:
12:
13:
14:
15:
16:
17:
7C00
7101
CA36
1CCB
2AA1
C032
EF00
8AFF
8BFF
FF30
1AC0
8BFF
FF30
9CFF
0000
read R[A]
read R[B]
R[F]  pc; goto 30
R[A]  R[C]
read R[B]
R[F]  pc; goto 30
write R[C]
halt
x
y
x * y
(x * y)
z
(x * y) * z
49
Virtual machines
Contract between calling program and
function:




Abstractions for computers
Calling program stores function parameters in
specific registers.
Calling program stores return address in a specific
register.
–
jump-and-link
Calling program sets PC to address of function.
Function stores return value in specific register.
Function sets PC to return address when finished.
–

High-Level Language
Level 5
Assembly Language
Level 4
Operating System
jump register
What if you want a function to call another
function?

R[F] 
16
50
Function Call: One Solution

R[F] 
13
Use a different register for return address.
More general: store return addresses on a stack.
51
Level 3
Instruction Set
Architecture
Level 2
Microarchitecture
Level 1
Digital Logic
Level 0
52
Problems with programming using machine code




Virtual machines
Abstractions for computers
Difficult to remember instructions
Difficult to remember variables
Hard to calculate addresses/relocate variables or
functions
Need to handle instruction encoding
High-Level Language
Level 5
Assembly Language
Level 4
Operating System
53
Level 3
Instruction Set
Architecture
Level 2
Microarchitecture
Level 1
Digital Logic
Level 0
54