Chapt 01 PDF
Chapt 01 PDF
• Welcome to Assembly
Language
• Virtual Machine Concept
• Data Representation
Javed Ahmed Shahani
• Boolean Operations
3 4
1
Welcome to Assembly Language Assembly Language Applications
(cont)
• How does assembly language (AL) relate to • Some representative types of applications:
– Business application for single platform
machine language?
– Hardware device driver
• How do C++ and Java relate to AL? – Business application for multiple platforms
• Is AL portable? – Embedded systems & computer games
5 6
7 8
2
Virtual Machines Translating Languages
• Tanenbaum: Virtual machine concept English: Display the sum of A times B plus C.
• Programming Language analogy:
– Each computer has a native machine language (language L0) that
runs directly on its hardware C++: cout << (A * B + C);
– A more human-friendly language is usually constructed above
machine language, called Language L1
• Programs written in L1 can run two different ways: Assembly Language: Intel Machine Language:
• Interpretation – L0 program interprets and executes L1 mov eax,A A1 00000000
instructions one by one mul B F7 25 00000004
• Translation – L1 program is completely translated into an L0 add eax,C
03 05 00000008
program, which then runs on the computer hardware call WriteInt
E8 00500000
9 10
11 12
3
Assembly Language Operating System
• Level 4
• Level 3
• Instruction mnemonics that have a one-to-
one correspondence to machine language • Provides services to Level 4 programs
• Calls functions written at the operating • Translated and run at the instruction
system level (Level 3)
• Programs are translated into machine set architecture level (Level 2)
language (Level 2)
13 14
15 16
4
Digital Logic Data Representation
• Binary Numbers
• Level 0 – Translating between binary and decimal
• CPU, constructed from digital logic • Binary Addition
gates • Integer Storage Sizes
• System bus • Hexadecimal Integers
• Memory – Translating between decimal and hexadecimal
• Implemented using bipolar transistors – Hexadecimal subtraction
• Signed Integers
– Binary subtraction
• Character Storage
next: Data Representation
17 18
– 1 = true
– 0 = false
• MSB – most significant bit
• LSB – least significant bit
Every binary
MSB LSB number is a
• Bit numbering: 1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 sum of powers
15 0 of 2
19 20
5
Translating Binary to Decimal Translating Unsigned Decimal to Binary
• Repeatedly divide the decimal integer by 2. Each
Weighted positional notation shows how to remainder is a binary digit in the translated value:
calculate the decimal value of each binary bit:
dec = (Dn-1 2n-1) + (Dn-2 2n-2) + ... + (D1 21) +
(D0 20)
D = binary digit
21 22
word
8
16
Standard sizes:
include the carry if present. doubleword 32
quadword 64
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
23 24
6
Hexadecimal Integers Translating Binary to Hexadecimal
Binary values are represented in hexadecimal.
• Each hexadecimal digit corresponds to 4 binary bits.
• Example: Translate the binary integer
000101101010011110010100 to hexadecimal:
25 26
27 28
7
Converting Decimal to Hexadecimal Hexadecimal Addition
• Divide the sum of two digits by the number base (16). The quotient becomes the
carry value, and the remainder is the sum digit.
1 1
36 28 28 6A
42 45 58 4B
78 6D 80 B5
29 30
1 1 1 1 0 1 1 0
Negative
-1
C6 75 0 0 0 0 1 0 1 0 Positive
A2 47
24 2E
31 32
8
Forming the Two's Complement Binary Subtraction
• Negative numbers are stored in two's
complement notation • When subtracting A – B, convert B to its two's
• Represents the additive Inverse complement
• Add A to (–B)
00001100 00001100
– 00000011 11111101
Note that 00000001 + 11111111 = 00000000 01001.
Practice: Subtract 0101 from 0001001
33 34
35 36
9
Character Storage Numeric Data Representation
• Character sets
• pure binary
– Standard ASCII (0 – 127) – can be calculated directly
– Extended ASCII (0 – 255) • ASCII binary
– ANSI (0 – 255) – string of digits: "01010101"
– Unicode (0 – 65,535) • ASCII decimal
• Null-terminated String – string of digits: "65"
– Array of characters followed by a null byte • ASCII hexadecimal
• Using the ASCII table – string of digits: "9C"
– back inside cover of book
next: Boolean Operations
37 38
39 40
10
NOT AND
• Inverts (reverses) a boolean value • Truth table for Boolean AND operator:
• Truth table for Boolean NOT operator:
NOT
AND
41 42
OR Operator Precedence
• Truth table for Boolean OR operator:
• Examples showing the order of operations:
OR
43 44
11
Truth Tables (1 of 3) Truth Tables (2 of 3)
• A Boolean function has one or more Boolean • Example: X Y
inputs, and returns a single Boolean output.
• A truth table shows all the inputs and outputs of
a Boolean function
Example: X Y
45 46
Truth Tables (3 of 3)
• Example: (Y S) (X S)
X
mux Z
Y
Two-input multiplexer
47
12