SlideShare uma empresa Scribd logo
1 de 41
Assembly Language - Lab (1)
1
Agenda
 Logistics
 CourseSites
 Introduction
 Data Representation
2
Logistics
Text Book
3
Evaluation
Year Work (25 Marks)
Assignments
Lab work
Project
4
Assignments
Assignments are INDIVIDUAL work.
Never share code/solution.
5
Honor Code
My answers will be my own work.
I will not make solutions available or seen by anyone else.
Violations:
Plagiarism (copy all or part of it)
Representing the work of another as one’s own work
6
CourseSites
https://www.coursesites.com/
Introduction
9
Why Assembly?
All high-level languages are an abstraction how the
computer works, abstraction means the programmer
don’t have to worry about the computer details.
Assembly is a really good way to understand what is the
computer doing because you control exactly what
happens at each step.
10
Why Assembly?
Assembly language gives the programmer the ability to
perform technical tasks that would be difficult in
high‐level languages including total control on the
machine.
Software written in assembly language runs faster than
the same one written in high‐level language and takes
less amount of memory if the programmer
well‐optimized the assembly program code.
11
Why Assembly?
Learning assembly language gives deep understanding of
the computer’s organization and architecture and how
programs run, since it is necessary to know the
architecture of the processor or controller in order to
write assembly code.
12
What can we do using Assembly?
Device Driver:
is a program that controls a particular type of device
that is attached to your computer.
Only assembly and C can implement this since they give
you a full control over the hardware.
13
What can we do using Assembly?
Virus Programming:
a simple program that infects other programs:
1. by injecting itself in the end of the program
2. by applying changes to file header and RPT
(Relocation pointer table) to execute the virus first and
execute the host program
14
What can we do using Assembly?
Reverse Engineering:
is the process of reversing code from a machine
language (binary code) using disassembler, then we
can:
analyze and understand the program
changing features in program (ex: cracking the
program)
debugging program
without having the source code of the program
15
What can we do using Assembly?
Embedded Software:
a software written to control a machine or device, that
is specialized for a certain device, and has time and
memory constraints, such as telephone, automobile,
air-condition control system, video cards, sound cards,
printers, etc.
Since assembly is the fastest language and takes the
lowest memory, it is the best for embedded system.
16
Machine Language VS Assembly
Language
17
Machine Language
Computers work only with 0’s and 1’s.
Every program instruction or data element must be in
binary to be manipulated by computer machine.
Therefore, any program understood by machine has to
be written in machine language, however machine
language is too hard to write and maintain.
18
Machine Language
Machine Language is a set of binary codes (0’s and 1’s)
that represent instructions of a specific machine. It is
machine‐dependent.
For example, the instruction
8B D8
means copy content from AX register to BX register.
19
Assembly Language
Assembly language is developed to make programming
easier than programming using machine language.
Assembly language is a set of mnemonics (symbols) for
machine code instructions plus other features that make
programming easier.
20
Assembly Language
To run program written in assembly language, we should
have a converter (or translator) which converts these
labels and mnemonics to their corresponding machine
codes in 0’s and 1’s. This converter is called assembler.
21
Machine CodeAssemblerAssembly Code
Assembly Language
Assembly Language is a low-level (machine‐level)
programming language that uses mnemonics instead of
numeric codes to simplify programming.
For example, the instruction
mov BX, AX
means copy content from AX register to BX register.
Each statement in assembly code has a one-to-one
relationship with machine language instructions, in other
words each statement corresponds to a single machine
code instruction.
22
Assembly Language
Each assembly language is machine‐dependent which
means it is specific to a particular computer architecture.
In contrast to most high-level programming languages,
which are generally portable across multiple systems.
23
Assembly Language
We’ll use Irvine Library with Visual Studio to write our
Assembly code.
24
Data Representation
Numbering Systems Conversions
25
Numbering Systems
Data Representation
26
System Base Possible Digits
Binary 2 0 and 1
Octal 8
0, 1, 2, 3, 4, 5, 6, and
7
Decimal 10
0, 1, 2, 3, 4, 5, 6, 7,
8, and 9
Hexadecimal 16
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, A, B, C, D, E,
and F
Converting from unsigned binary to
decimal
 1101102
1x25 + 1x24 + 0x23 + 1x22 + 1x21 + 0x20
= 1x32 + 1x16 + 0 + 1x4 + 1x2 + 0
= 32 + 16 + 4 + 2
= 5410
27
Converting from unsigned binary to
decimal
 111100002
1x27 + 1x26 + 1x25 + 1x24 + 0x23 + 0x22 + 0x21 + 0x20
= 1x128 + 1x64 + 1x32 + 1x16 + 0 + 0 + 0 + 0
= 128 + 64 + 32 + 16
= 24010
28
Converting from signed binary to decimal
 001010102
0x26 + 1x25 + 0x24 + 1x23 + 0x22 + 1x21 + 0x20
= 0 + 1x32 + 0 + 1x8 + 0 + 1x2 + 0
= 32 + 8 + 2
= +4210
29
1st bit is 0, then the
number is positive
Converting from signed binary to decimal
 111100002
 Get the 2’s complement
2’s complement = 1’s complement + 1
00010000 = 00001111 + 1
 Convert the 2’s complement to decimal and attach the
negative sign
0x27 + 0x26 + 0x25 + 1x24 + 0x23 + 0x22 + 0x21 + 0x20
= 0 + 0 + 0 + 16 + 0 + 0 + 0 + 0
= 16
= -1610
30
1st bit is 1, then the number
is negative
• 2310
= 101112
Division Quotient Remainder
23 / 2 =
11.5
11 1
11 / 2 = 5.5 5 1
5 / 2 = 2.5 2 1
2 / 2 = 1 1 0
1 / 2 = 0.5 0 1
10111
Stop when
quotient = 0
31
Converting from unsigned decimal to
binary
• -2310
a. Convert the decimal value into binary
Division Quotient Remainder
23 / 2 = 11.5 11 1
11 / 2 = 5.5 5 1
5 / 2 = 2.5 2 1
2 / 2 = 1 1 0
1 / 2 = 0.5 0 1
10111
Stop when
quotient = 0
32
Converting from signed decimal to binary
b. If the original number is negative, then get the 2’s
complement of the result
Result = 101112 = 000101112
2’s complement = 1’s complement + 1
= 11101000 + 1
= 111010012
33
Converting from signed decimal to binary
Converting from unsigned binary to
hexadecimal
 Each hexadecimal digit corresponds to 4 binary bits.
 0101 10112
 Convert each 4 bits to a hexadecimal digit
=5B16
34
0 x 23 + 1 x 22 + 0 x 21 + 1 x 20 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20
0 + 1 x 4 + 0 + 1 x 1 1 x 8 + 0 + 1 x 2 + 1 x 1
4 + 1 8 + 2 + 1
5 11
5 B
• A616
a. Convert each hexadecimal digit to 4 bits
= 101001102
A = 10
Division Quotient Remainder
10 / 2 = 5 5 0
5 / 2 = 2.5 2 1
2 / 2 = 1 1 0
1 / 2 = 0.5 0 1
1010
6
Division Quotient Remainder
6 / 2 = 3 3 0
3 / 2 = 1.5 1 1
1 / 2 = 0.5 0 1
… … 0
0110
35
Converting from unsigned
hexadecimal to binary
• Addition and Subtraction
• 1’s Complement
• Covert each 1 to 0, and each 0 to 1.
1’s complement of 10110102 = 01001012
• 2’s Complement
• Add 1 to the 1’s complement.
2’s complement of 10110102 = 01001102
• 2’s complement is used in representing negative
numbers.
36
Numbering Systems
• Binary Operations
• 11001 + 10101 = 101110
• The operation’s result does not fit in 5 bits, so the
underlined 1 in the previous number is called a carry.
• 11001 – 10101 = 11001 + 01011 = 00100 with carry = 1
• Carry = 1 in subtraction means that the result is positive with no
borrow.
• 10101 – 11001 = 10101 + 00111 = 11100 with carry = 0
• Carry = 0 in subtraction means that the result is negative with
borrow.
37
2’s complement
of 10101
2’s complement
of 11001
Numbering Systems
• Hexadecimal Operations
• 23D9 + 94BE
9 + 14 = 23 23 – 16 = 7 with carry
13 + 11 + 1 = 25 25 – 16 = 9 with carry
3 + 4 + 1 = 8
2 + 9 = B
= B897
• 59F – 2B8
15 – 8 = 7
(9 + 16) – 11 = 14 (E)
4 – 2 = 2
= 2E7
38
Numbering Systems
Additional Examples
1. 000101101010011110010100)2 = )16
2. 1234)16 = )10
3. 422)10 = )16
4. 3628286A + 4245584B )16 = )16
5. C675 – A247)16 = )16
39
• All data stored in memory is numeric.
• Characters are stored by using a character code that maps
numbers to characters.
• One of the most common character codes is known as ASCII
(American Standard Code for Information Interchange). It
uses 1 byte (8 bits) to encode characters. Therefore, it is
limited to encode only 256 (28) characters.
• A new and more complete code that is supplanting ASCII is
Unicode. It uses 2 bytes (16 bits) to encode characters.
Therefore, it is capable to encode 65536 (216) characters.
ASCII Code
40
Questions !?
41
Thank you 
42

Mais conteúdo relacionado

Mais procurados

Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modesBilal Amjad
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediateJohn Cutajar
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructionswarda aziz
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Bilal Amjad
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overviewTAlha MAlik
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Bilal Amjad
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and VariablesIntro C# Book
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUEducation
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
 
04. Console Input Output
04. Console Input Output 04. Console Input Output
04. Console Input Output Intro C# Book
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with StatixEelco Visser
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programsharman kaur
 

Mais procurados (20)

Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modes
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediate
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructions
 
C++ theory
C++ theoryC++ theory
C++ theory
 
Compiler unit 5
Compiler  unit 5Compiler  unit 5
Compiler unit 5
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
Ch9a
Ch9aCh9a
Ch9a
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
 
Ch9b
Ch9bCh9b
Ch9b
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and Variables
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
04. Console Input Output
04. Console Input Output 04. Console Input Output
04. Console Input Output
 
C++ Presentation
C++ PresentationC++ Presentation
C++ Presentation
 
Alp 05
Alp 05Alp 05
Alp 05
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 
Computer Programming- Lecture 3
Computer Programming- Lecture 3Computer Programming- Lecture 3
Computer Programming- Lecture 3
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 

Destaque

.NET Framework Projet with C#
.NET Framework Projet with C#.NET Framework Projet with C#
.NET Framework Projet with C#eclumson
 
Assembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI HiroakiAssembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI Hiroakiasmtanka
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4Motaz Saad
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 
Землянка: вчера и завтра
Землянка: вчера и завтраЗемлянка: вчера и завтра
Землянка: вчера и завтраdrogalev41
 
[SpLab7]Functions I
[SpLab7]Functions I[SpLab7]Functions I
[SpLab7]Functions INora Youssef
 
[Splab8]Functions II
[Splab8]Functions II[Splab8]Functions II
[Splab8]Functions IINora Youssef
 
[SpLab5] Pointers II
[SpLab5] Pointers II[SpLab5] Pointers II
[SpLab5] Pointers IINora Youssef
 
[SpLab9]Functions III
[SpLab9]Functions III[SpLab9]Functions III
[SpLab9]Functions IIINora Youssef
 

Destaque (16)

.NET Framework Projet with C#
.NET Framework Projet with C#.NET Framework Projet with C#
.NET Framework Projet with C#
 
Assembly fundamentals
Assembly fundamentalsAssembly fundamentals
Assembly fundamentals
 
Assembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI HiroakiAssembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI Hiroaki
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
c#
c#c#
c#
 
[ASM]Lab3
[ASM]Lab3[ASM]Lab3
[ASM]Lab3
 
[ASM] Lab2
[ASM] Lab2[ASM] Lab2
[ASM] Lab2
 
[SpLab1]Review
[SpLab1]Review[SpLab1]Review
[SpLab1]Review
 
Oracle partners-in-india
Oracle partners-in-indiaOracle partners-in-india
Oracle partners-in-india
 
Землянка: вчера и завтра
Землянка: вчера и завтраЗемлянка: вчера и завтра
Землянка: вчера и завтра
 
[SpLab7]Functions I
[SpLab7]Functions I[SpLab7]Functions I
[SpLab7]Functions I
 
[Splab8]Functions II
[Splab8]Functions II[Splab8]Functions II
[Splab8]Functions II
 
[SpLab5] Pointers II
[SpLab5] Pointers II[SpLab5] Pointers II
[SpLab5] Pointers II
 
[SpLab9]Functions III
[SpLab9]Functions III[SpLab9]Functions III
[SpLab9]Functions III
 

Semelhante a [ASM] Lab1 (20)

Intro to assembly language
Intro to assembly languageIntro to assembly language
Intro to assembly language
 
Chap 01[1]
Chap 01[1]Chap 01[1]
Chap 01[1]
 
DLD-Introduction.pptx
DLD-Introduction.pptxDLD-Introduction.pptx
DLD-Introduction.pptx
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009
 
Cit 1101 lec 02
Cit 1101 lec 02Cit 1101 lec 02
Cit 1101 lec 02
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
Number_Systems (2).ppt
Number_Systems (2).pptNumber_Systems (2).ppt
Number_Systems (2).ppt
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
Bitwise Operations in Programming
Bitwise Operations in ProgrammingBitwise Operations in Programming
Bitwise Operations in Programming
 
Basics of computer and Number conversions.pdf
Basics of computer and Number conversions.pdfBasics of computer and Number conversions.pdf
Basics of computer and Number conversions.pdf
 
COMPUTER AWARENESS.pptx
COMPUTER AWARENESS.pptxCOMPUTER AWARENESS.pptx
COMPUTER AWARENESS.pptx
 
S & D Machine code
S & D Machine codeS & D Machine code
S & D Machine code
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
Complement.pdf
Complement.pdfComplement.pdf
Complement.pdf
 
ADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptx
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdf
 
Alu1
Alu1Alu1
Alu1
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
 
Module 4
Module 4Module 4
Module 4
 

Último

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 

Último (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

[ASM] Lab1

  • 2. Agenda  Logistics  CourseSites  Introduction  Data Representation 2
  • 4. Evaluation Year Work (25 Marks) Assignments Lab work Project 4
  • 5. Assignments Assignments are INDIVIDUAL work. Never share code/solution. 5
  • 6. Honor Code My answers will be my own work. I will not make solutions available or seen by anyone else. Violations: Plagiarism (copy all or part of it) Representing the work of another as one’s own work 6
  • 9. Why Assembly? All high-level languages are an abstraction how the computer works, abstraction means the programmer don’t have to worry about the computer details. Assembly is a really good way to understand what is the computer doing because you control exactly what happens at each step. 10
  • 10. Why Assembly? Assembly language gives the programmer the ability to perform technical tasks that would be difficult in high‐level languages including total control on the machine. Software written in assembly language runs faster than the same one written in high‐level language and takes less amount of memory if the programmer well‐optimized the assembly program code. 11
  • 11. Why Assembly? Learning assembly language gives deep understanding of the computer’s organization and architecture and how programs run, since it is necessary to know the architecture of the processor or controller in order to write assembly code. 12
  • 12. What can we do using Assembly? Device Driver: is a program that controls a particular type of device that is attached to your computer. Only assembly and C can implement this since they give you a full control over the hardware. 13
  • 13. What can we do using Assembly? Virus Programming: a simple program that infects other programs: 1. by injecting itself in the end of the program 2. by applying changes to file header and RPT (Relocation pointer table) to execute the virus first and execute the host program 14
  • 14. What can we do using Assembly? Reverse Engineering: is the process of reversing code from a machine language (binary code) using disassembler, then we can: analyze and understand the program changing features in program (ex: cracking the program) debugging program without having the source code of the program 15
  • 15. What can we do using Assembly? Embedded Software: a software written to control a machine or device, that is specialized for a certain device, and has time and memory constraints, such as telephone, automobile, air-condition control system, video cards, sound cards, printers, etc. Since assembly is the fastest language and takes the lowest memory, it is the best for embedded system. 16
  • 16. Machine Language VS Assembly Language 17
  • 17. Machine Language Computers work only with 0’s and 1’s. Every program instruction or data element must be in binary to be manipulated by computer machine. Therefore, any program understood by machine has to be written in machine language, however machine language is too hard to write and maintain. 18
  • 18. Machine Language Machine Language is a set of binary codes (0’s and 1’s) that represent instructions of a specific machine. It is machine‐dependent. For example, the instruction 8B D8 means copy content from AX register to BX register. 19
  • 19. Assembly Language Assembly language is developed to make programming easier than programming using machine language. Assembly language is a set of mnemonics (symbols) for machine code instructions plus other features that make programming easier. 20
  • 20. Assembly Language To run program written in assembly language, we should have a converter (or translator) which converts these labels and mnemonics to their corresponding machine codes in 0’s and 1’s. This converter is called assembler. 21 Machine CodeAssemblerAssembly Code
  • 21. Assembly Language Assembly Language is a low-level (machine‐level) programming language that uses mnemonics instead of numeric codes to simplify programming. For example, the instruction mov BX, AX means copy content from AX register to BX register. Each statement in assembly code has a one-to-one relationship with machine language instructions, in other words each statement corresponds to a single machine code instruction. 22
  • 22. Assembly Language Each assembly language is machine‐dependent which means it is specific to a particular computer architecture. In contrast to most high-level programming languages, which are generally portable across multiple systems. 23
  • 23. Assembly Language We’ll use Irvine Library with Visual Studio to write our Assembly code. 24
  • 25. Numbering Systems Data Representation 26 System Base Possible Digits Binary 2 0 and 1 Octal 8 0, 1, 2, 3, 4, 5, 6, and 7 Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F
  • 26. Converting from unsigned binary to decimal  1101102 1x25 + 1x24 + 0x23 + 1x22 + 1x21 + 0x20 = 1x32 + 1x16 + 0 + 1x4 + 1x2 + 0 = 32 + 16 + 4 + 2 = 5410 27
  • 27. Converting from unsigned binary to decimal  111100002 1x27 + 1x26 + 1x25 + 1x24 + 0x23 + 0x22 + 0x21 + 0x20 = 1x128 + 1x64 + 1x32 + 1x16 + 0 + 0 + 0 + 0 = 128 + 64 + 32 + 16 = 24010 28
  • 28. Converting from signed binary to decimal  001010102 0x26 + 1x25 + 0x24 + 1x23 + 0x22 + 1x21 + 0x20 = 0 + 1x32 + 0 + 1x8 + 0 + 1x2 + 0 = 32 + 8 + 2 = +4210 29 1st bit is 0, then the number is positive
  • 29. Converting from signed binary to decimal  111100002  Get the 2’s complement 2’s complement = 1’s complement + 1 00010000 = 00001111 + 1  Convert the 2’s complement to decimal and attach the negative sign 0x27 + 0x26 + 0x25 + 1x24 + 0x23 + 0x22 + 0x21 + 0x20 = 0 + 0 + 0 + 16 + 0 + 0 + 0 + 0 = 16 = -1610 30 1st bit is 1, then the number is negative
  • 30. • 2310 = 101112 Division Quotient Remainder 23 / 2 = 11.5 11 1 11 / 2 = 5.5 5 1 5 / 2 = 2.5 2 1 2 / 2 = 1 1 0 1 / 2 = 0.5 0 1 10111 Stop when quotient = 0 31 Converting from unsigned decimal to binary
  • 31. • -2310 a. Convert the decimal value into binary Division Quotient Remainder 23 / 2 = 11.5 11 1 11 / 2 = 5.5 5 1 5 / 2 = 2.5 2 1 2 / 2 = 1 1 0 1 / 2 = 0.5 0 1 10111 Stop when quotient = 0 32 Converting from signed decimal to binary
  • 32. b. If the original number is negative, then get the 2’s complement of the result Result = 101112 = 000101112 2’s complement = 1’s complement + 1 = 11101000 + 1 = 111010012 33 Converting from signed decimal to binary
  • 33. Converting from unsigned binary to hexadecimal  Each hexadecimal digit corresponds to 4 binary bits.  0101 10112  Convert each 4 bits to a hexadecimal digit =5B16 34 0 x 23 + 1 x 22 + 0 x 21 + 1 x 20 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20 0 + 1 x 4 + 0 + 1 x 1 1 x 8 + 0 + 1 x 2 + 1 x 1 4 + 1 8 + 2 + 1 5 11 5 B
  • 34. • A616 a. Convert each hexadecimal digit to 4 bits = 101001102 A = 10 Division Quotient Remainder 10 / 2 = 5 5 0 5 / 2 = 2.5 2 1 2 / 2 = 1 1 0 1 / 2 = 0.5 0 1 1010 6 Division Quotient Remainder 6 / 2 = 3 3 0 3 / 2 = 1.5 1 1 1 / 2 = 0.5 0 1 … … 0 0110 35 Converting from unsigned hexadecimal to binary
  • 35. • Addition and Subtraction • 1’s Complement • Covert each 1 to 0, and each 0 to 1. 1’s complement of 10110102 = 01001012 • 2’s Complement • Add 1 to the 1’s complement. 2’s complement of 10110102 = 01001102 • 2’s complement is used in representing negative numbers. 36 Numbering Systems
  • 36. • Binary Operations • 11001 + 10101 = 101110 • The operation’s result does not fit in 5 bits, so the underlined 1 in the previous number is called a carry. • 11001 – 10101 = 11001 + 01011 = 00100 with carry = 1 • Carry = 1 in subtraction means that the result is positive with no borrow. • 10101 – 11001 = 10101 + 00111 = 11100 with carry = 0 • Carry = 0 in subtraction means that the result is negative with borrow. 37 2’s complement of 10101 2’s complement of 11001 Numbering Systems
  • 37. • Hexadecimal Operations • 23D9 + 94BE 9 + 14 = 23 23 – 16 = 7 with carry 13 + 11 + 1 = 25 25 – 16 = 9 with carry 3 + 4 + 1 = 8 2 + 9 = B = B897 • 59F – 2B8 15 – 8 = 7 (9 + 16) – 11 = 14 (E) 4 – 2 = 2 = 2E7 38 Numbering Systems
  • 38. Additional Examples 1. 000101101010011110010100)2 = )16 2. 1234)16 = )10 3. 422)10 = )16 4. 3628286A + 4245584B )16 = )16 5. C675 – A247)16 = )16 39
  • 39. • All data stored in memory is numeric. • Characters are stored by using a character code that maps numbers to characters. • One of the most common character codes is known as ASCII (American Standard Code for Information Interchange). It uses 1 byte (8 bits) to encode characters. Therefore, it is limited to encode only 256 (28) characters. • A new and more complete code that is supplanting ASCII is Unicode. It uses 2 bytes (16 bits) to encode characters. Therefore, it is capable to encode 65536 (216) characters. ASCII Code 40

Notas do Editor

  1. Add link
  2. The machine code program produced using the assembler takes up less memory space than the compiled version of the program.
  3. 16A794 1(16^3)+2(16^2)+3(16)+4 = 4660 1A6 786D80B5 242E