Computer Organization and Assembly Languages: With Slides by Kip Irvine
Computer Organization and Assembly Languages: With Slides by Kip Irvine
Languages
assembler debugger
.obj
.exe
linker loader
Virtual machines
Abstractions for computers
Operating System
Level 3
Instruction Set
Architecture Level 2
Microarchitecture Level 1
• Level 5
• Application-oriented languages
• Programs compile into assembly
language (Level 4)
X:=(Y+4)*3
Assembly Language
• Level 4
• Instruction mnemonics that have a one-to-one
correspondence to machine language
• Calls functions written at the operating
system level (Level 3)
• Programs are translated into machine
language (Level 2)
mov eax, Y
add eax, 4
mov ebx, 3
imul ebx
mov X, eax
Operating System
• Level 3
• Provides services
• Programs translated and run at the instruction
set architecture level (Level 2)
Instruction Set Architecture
• Level 2
• Also known as conventional machine language
• Executed by Level 1 program
(microarchitecture, Level 1)
Microarchitecture
• Level 1
• Interprets conventional machine instructions
(Level 2)
• Executed by digital hardware (Level 0)
Digital Logic
• Level 0
• CPU, constructed from digital logic gates
• System bus
• Memory
Data representation
• Computer is a construction of digital circuits
with two states: on and off
• You need to have the ability to translate
between different representations to examine
the content of the machine
• Common number systems: binary, octal,
decimal and hexadecimal
Binary numbers
• Digits are 1 and 0
(a binary digit is called a bit)
1 = true
0 = false
• MSB –most significant bit
• LSB –least significant bit
MSB LSB
• Bit numbering: 1011001010011100
15 0
Every binary
number is a
sum of powers
of 2
Translating Binary to Decimal
37 = 100101
Binary addition
• Starting with the LSB, add each pair of digits,
include the carry if present.
carry: 1
0 0 0 0 0 1 0 0 (4)
+ 0 0 0 0 0 1 1 1 (7)
0 0 0 0 1 0 1 1 (11)
bit position: 7 6 5 4 3 2 1 0
Integer storage sizes
byte 8
quadword 64
Practice: What is the largest unsigned integer that may be stored in 20 bits?
Large measurements
• Kilobyte (KB), 210 bytes
• Megabyte (MB), 220 bytes
• Gigabyte (GB), 230 bytes
• Terabyte (TB), 240 bytes
• Petabyte
• Exabyte
• Zettabyte
• Yottabyte
Hexadecimal integers
All values in memory are stored in binary. Because long
binary numbers are hard to read, we use hexadecimal
representation.
Translating binary to hexadecimal
1 1
36 28 28 6A
42 45 58 4B
78 6D 80 B5
-1
C6 75
A2 47
24 2E
1 1 1 1 0 1 1 0
Negative
0 0 0 0 1 0 1 0 Positive
NOT
AND
• Truth if both are true
• Truth table for Boolean AND operator:
AND
OR
• True if either is true
• Truth table for Boolean OR operator:
OR
Operator precedence
Example: X Y
Truth Tables (2 of 3)
• Example: X Y
S
Truth Tables (3 of 3)
X
mux Z
• Example: (Y S) (X S) Y
Two-input multiplexer