Download presentation
Presentation is loading. Please wait.
1
Assembly Language (CSW 353)
Introduction of Assembly Language Assembly Language
2
Introduction of Assembly Language
3
Content Course Description Basic Concepts of Assembly Language
Welcome to Assembly Language Virtual Machine Concept Data Representation Boolean Operations Assembly Language
4
Course Description Prerequisites: Textbook References:
Structured Programming Language Textbook References: Assembly Language for Intel-Based Computers. Assembly language for x86 processors The Art of Assembly Language Resources: Assembly Language
5
Course Description Grading : Final Exam 65 Year work 10 Oral 10
Laboratory and Practice 15 Sum Timing: Lecture Practice Exam Assembly Language
6
Content Course Description Basic Concepts of Assembly Language
Welcome to Assembly Language Virtual Machine Concept Data Representation Boolean Operations Assembly Language
7
Basic Concepts Welcome to Assembly Language Virtual Machine Concept
Some Good Questions to Ask Virtual Machine Concept Data Representation Boolean Operations Assembly Language
8
Welcome to Assembly Language
Some Good Questions to Ask What is Assembly Language? Why Learn Assembly Language? What is Machine Language? How is Assembly related to Machine Language? What is an Assembler? How is Assembly related to High-Level Language? Is Assembly Language portable? Assembly Language
9
What is Assembly Language?
A low-level processor-specific programming language design to match the processor’s machine instruction set. Each assembly language instruction matches exactly one machine language instruction. We will focus on Intel based Assembly Instructions. It covers many different versions of CPUs that followed, from Intel; the 80188, 80186, 80286, 80386, 80486, Pentium, Pentium Pro, and so on. It describes the basics of 32-bit assembly language programming. Assembly Language
10
What is Assembly Language?
A Hierarchy of Languages Assembly Language
11
Why Learn Assembly Language?
To learn how high-level language code gets translated into machine language. To learn the computer’s hardware by direct access to memory, video controller, sound card, keyboard… To speed up applications by direct access to hardware. Assembly Language
12
What is Machine Language ML?
Machine languages are lowest-level programming language and are the only languages understood by computers without translation. While easily understood by computers, machine languages are almost impossible for humans because they consist entirely of binary digits. Every CPU has its own specific machine language. Assembly Language
13
The accumulator. General-purpose register.
What is Machine Language ML? Each ML instruction contains an op code (operation code) and zero or more operands. Examples: Opcode Operand Meaning increment the AX register add 0005 to AX The accumulator. General-purpose register. Assembly Language
14
How is Assembly related to Machine Language?
Native to a processor: executed directly by hardware Instructions consist of binary code: 1s and 0s Assembly language Slightly higher-level language Readability of instructions is better than machine language One-to-one correspondence with machine language instructions Assemblers translate assembly to machine code Compilers translate high-level programs to machine code Either directly, or Indirectly via an assembler Assembly Language
15
What is an Assembler? An assembler is a type of computer program that interprets software programs written in assembly language into machine language, code and instructions that can be executed by a computer. For Example, MASM (Macro Assembler from Microsoft) Assembly Language
16
How is Assembly related to High-Level Language?
Assembly Language
17
Basic Concepts Welcome to Assembly Language Virtual Machine Concept
Some Good Questions to Ask Assembly Language Applications Virtual Machine Concept Data Representation Boolean Operations Assembly Language
18
Virtual Machine Concept
A virtual machine (VM) is a software program or operating system that exhibits the behavior of a separate computer. is capable of performing tasks such as running applications and programs in a separate computer. VM (virtual machine) is a layer of abstraction that gives a program one simplified interface for interacting with a variety of physical computers and their operating systems. Assembly Language
19
Translating languages
English: Display the sum of A times B plus C. C++: cout << (A * B + C); General Data Register Intel Machine Language: A F E Assembly Language: mov eax,A mul B add eax,C call WriteInt Assembly Language
20
Virtual machines Abstractions for computers Assembly Language
21
High-level language Level 5 Application-oriented languages
Programs are compiled into assembly language (Level 4) cout << (A * B + C); Assembly Language
22
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, A mul B add eax, C call WriteInt Assembly Language
23
Operating system Level 3 Provides services
Programs translated and run at the instruction set architecture level (Level 2) Assembly Language
24
Instruction set architecture
Level 2 Also known as conventional machine language Executed by Level 1 program (microarchitecture, Level 1) A F E Assembly Language
25
Micro-architecture Level 1
Interprets conventional machine instructions (Level 2) Executed by digital hardware (Level 0) Assembly Language
26
Digital logic Level 0 CPU, constructed from digital logic gates
System bus Memory Assembly Language
27
Basic Concepts Welcome to Assembly Language Virtual Machine Concept
Some Good Questions to Ask Assembly Language Applications Virtual Machine Concept Data Representation Boolean Operations Assembly Language
28
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. Common number systems: binary, octal, decimal and hexadecimal Assembly Language
29
Binary representations
Electronic Implementation Easy to store with bi-stable elements Reliably transmitted on noisy and inaccurate wires 0.0V 0.5V 2.8V 3.3V 1 Assembly Language
30
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 Bit numbering: A bit string could have different interpretations Assembly Language
31
Unsigned binary integers
Each digit (bit) is either 1 or 0 Each bit represents a power of 2: Every binary number is a sum of powers of 2 Assembly Language
32
Translating binary to decimal
Weighted positional notation shows how to calculate the decimal value (Dec) of each binary bit: dec = (Dn-1 2n-1) + (Dn-2 2n-2) (D1 21) + (D0 20) D = binary digit binary = decimal 9: (1 23) + (1 20) = 9 Assembly Language
33
Translating unsigned decimal to binary
Repeatedly divide the decimal integer by 2. Each remainder is a binary digit in the translated value: 37 = Assembly Language
34
Binary addition Starting with the LSB, add each pair of digits, include the carry if present. Assembly Language
35
Integer storage sizes Standard sizes:
Practice: What is the largest unsigned integer that may be stored in 20 bits? Assembly Language
36
Large measurements Kilobyte (KB), bytes Megabyte (MB), bytes
Gigabyte (GB), bytes Terabyte (TB), bytes Petabyte, bytes Exabyte, bytes Zettabyte, bytes Yottabyte, bytes Assembly Language
37
Hexadecimal integers All values in memory are stored in binary. Because long binary numbers are hard to read, we use hexadecimal representation. Assembly Language
38
Translating binary to hexadecimal
Each hexadecimal digit corresponds to 4 binary bits. Example: Translate the binary integer to hexadecimal: Assembly Language
39
Converting hexadecimal to decimal
Multiply each digit by its corresponding power of 16: dec = (D3 163) + (D2 162) + (D1 161) + (D0 160) Examples: Hex 1234 = (1 163) + (2 162) + (3 161) + (4 160) = decimal 4,660. Hex 3BA4 = (3 163) + (11 * 162) + (10 161) + (4 160) = decimal 15,268. Assembly Language
40
Converting decimal to hexadecimal
decimal 422 = 1A6 hexadecimal Assembly Language
41
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 A B 78 6D 80 B5 Important skill: Programmers frequently add and subtract the addresses of variables and instructions. Assembly Language
42
Hexadecimal subtraction
When a borrow is required from the digit to the left, add 10h to the current digit's value: -1 C6 75 A2 47 24 2E Practice: The address of var1 is The address of the next variable after var1 is A. How many bytes are used by var1? Assembly Language
43
Signed integers The highest bit indicates the sign. 1 = negative, 0 = positive If the highest digit of a hexadecimal integer is > 7, the value is negative. Examples: 8A, C5, A2, 9D Assembly Language
44
Two's complement notation For Binary
Steps: Complement (reverse) each bit Add 1 Note that = Assembly Language
45
Hexadecimal Two’s Complement
Steps: Complement (reverse) each digit (to reverse the bits of a hexadecimal digit is to subtract the digit from 15.) Add 1 Assembly Language
46
Unsigned 2’s Complement Subtraction
Example: Find – = 84 +(-67) = 17 – The carry of 1 indicates that no correction of the result is required. 1 2’s comp 84-67
47
Unsigned 2’s Complement Subtraction
Example: Find – = 67+ (-84) = -17 – The carry of 0 indicates that a correction of the result is required. Result = – ( ) 2’s comp 2’s comp
48
Ranges of signed integers
The highest bit is reserved for the sign. This limits the range: Assembly Language
49
Basic Concepts Welcome to Assembly Language Virtual Machine Concept
Some Good Questions to Ask Assembly Language Applications Virtual Machine Concept Data Representation Boolean Operations Assembly Language
50
Boolean algebra Boolean expressions created from: NOT, AND, OR
Assembly Language
51
Digital gate diagram for NOT:
Inverts (reverses) a Boolean value Truth table for Boolean NOT operator: Digital gate diagram for NOT: Assembly Language
52
Digital gate diagram for AND:
Truth if both are true Truth table for Boolean AND operator: Digital gate diagram for AND: Assembly Language
53
Digital gate diagram for OR:
True if either is true Truth table for Boolean OR operator: Digital gate diagram for OR: Assembly Language
54
Implementation of gates
Assembly Language
55
Operator Precedence Examples showing the order of operations:
Assembly Language
56
Truth Tables (1 of 2) A Boolean function has one or more Boolean inputs, and returns a single Boolean output. A truth table shows all the inputs and outputs of a Boolean function Example: X Y Assembly Language
57
Truth Tables (2 of 2) Example: X Y Assembly Language
58
Summary Assembly language helps you learn how software is constructed at the lowest levels Assembly language has a one-to-one relationship with machine language Each layer in a computer's architecture is an abstraction of a machine layers can be hardware or software Boolean expressions are essential to the design of computer hardware and software Assembly Language
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.