SlideShare a Scribd company logo
1 of 26
Chapter 1: Context of 
Assembly Language 
Slides to Accompany 
Assembly Language for Intel-Based Computers, 
Third Edition 
Copyright 1999-2000, Prentice-Hall Incorporated 
Updated 08/00
Table 1. Software Hierarchy Levels. 
Level Description 
Application Program 
Software designed for a particular class of 
applications. 
High-Level Language (HLL) 
Programs are compiled into either assembly language 
or machine language. Each statement usually 
translates into multiple machine language instructions. 
Examples are C++, Pascal, Java, and Visual Basic. 
Operating System 
Contains procedures that can be called from programs 
written in either high-level language or assembly 
language. This system may also contain an application 
programming interface (API). 
Assembly Language (ASM) 
Uses instruction mnemonics that have a one-to-one 
correspondence with machine language. 
Machine Language (ML) 
Numeric instructions and operands that can be stored 
in memory and directly executed by the computer 
processor.
Essential Tools 
• An assembler is a program that converts source-code 
programs into a machine language (object file). 
• A linker joins together two or more object files and 
produces a single executable file. 
• A debugger loads an executable program, displays 
the source code, and lets the programmer step 
through the program one instruction at a time, and 
display and modify memory.
Figure 1. Machine Language Generation by ASM and 
HLL programs. 
ASM ML 
ML 
ML 
ML 
ML 
HLL
Table 2. Comparison of Assembly Language to HLLs. 
Type of Application High-Level Language Assembly Language 
Business application 
Formal structures make it 
software, written for 
easy to organize and 
single platform, medium 
maintain large sections of 
to large size. 
code. 
No formal structure. 
Programmer must impose an 
artificial structure. 
Hardware device driver. Language may not provide 
for direct hardware access. 
Awkward coding techniques 
must be used, resulting in 
possible maintenance 
problems. 
Hardware access is 
straightforward and simple. 
Easy to maintain when the 
programs are short and well 
documented. 
Business application 
written for multiple 
platforms (different 
operating systems). 
Usually very portable. The 
source code can be 
recompiled on each target 
operating system with 
minimal changes. 
Must be recoded separately 
for each platform, often 
using an assembler with a 
different syntax. Difficult to 
maintain. 
Embedded systems and 
computer games 
requiring direct 
hardware access. 
Produces too much 
executable code, and may 
not run efficiently. 
Ideal, because the 
executable code is small 
and runs quickly.
Figure 2. Assembly Language Subroutines Used as 
Hardware Interfaces. 
Application 
Program 
Interface 
Subroutine 
Operating 
System 
Device Driver 
Subroutine 
Hardware
Machine Language 
• Consists of binary numbers 
• The "native" language of the computer 
• Each ML instruction contains an op code (operation 
code) and zero or more operands. 
• Examples: 
Opcode Operand Meaning 
------------------------------------------------- 
40 increment the AX register 
05 0005 add 0005 to AX
Page 7: Bits, Bytes, and Doublewords: 
byte byte 
0 0 1 0 0 1 1 0 0 1 1 0 1 0 1 0 bit 
word 
Each 1 or 0 is called a bit.
Table 3. Storage Sizes and Ranges of Unsigned Integers. 
Storage Type Bits Range (low - high) 
Unsigned byte 8 0 to 255 
Unsigned word 16 0 to 65,535 
Unsigned doubleword 32 0 to 4,294,967,295 
Unsigned quadword 64 0 to 18,446,744,073,709,551,615
Table 4. Digits in Various Number Systems. 
System Base Possible Digits 
Binary 2 0 1 
Octal 8 0 1 2 3 4 5 6 7 
Decimal 10 0 1 2 3 4 5 6 7 8 9 
Hexadecimal 16 0 1 2 3 4 5 6 7 8 9 A B C D E F
Page 9. ASCII Digit String. 
Format Value 
ASCII binary "01000001" 
ASCII decimal "65" 
ASCII hexadecimal "41" 
ASCII octal "101"
Table 5. Binary Bit Position Values. 
2n Decimal Value 2n Decimal Value 
20 1 28 256 
21 2 29 512 
22 4 210 1024 
23 8 211 2048 
24 16 212 4096 
25 32 213 8192 
26 64 214 16384 
27 128 215 32768
Figure 3. Converting Binary to Decimal. 
8 
+ 1 
9
Table 6. Binary, Decimal, and Hexadecimal Equivalents. 
Binary Decimal Hexadecimal Binary Decimal Hexadecimal 
0000 0 0 1000 8 8 
0001 1 1 1001 9 9 
0010 2 2 1010 10 A 
0011 3 3 1011 11 B 
0100 4 4 1100 12 C 
0101 5 5 1101 13 D 
0110 6 6 1110 14 E 
0111 7 7 1111 15 F
Table 7. Powers of 16, in Decimal. 
16n Decimal Value 16n Decimal Value 
160 1 164 65,536 
161 16 165 1,048,576 
162 256 166 16,777,216 
163 4096 167 268,435,456
Figure 4. Converting 3BA4 Hexadecimal to Decimal. 
3 * 4096 = 12,288 
11 * 256 = 2,816 
10 * 16 = 160 
4 * 1 = + 4 
Total: 15,268 
3 B A 4
1 1 1 1 0 1 1 0 
0 0 0 0 1 0 1 0 
= 
= 
sign bit 
– 10 
+ 10 
1.2.4 Signed Numbers
Table 8. Signed Integer Storage and Ranges. 
Storage Type Bits Range (low - high) 
Signed byte 7 -128 to +127 
Signed word 15 –32,768 to +32,767 
Signed doubleword 31 –2,147,483,648 to 2,147,483,647 
Signed quadword 63 –9,223,372,036,854,775,808 to 
+9,223,372,036,854,775,807
1.2.5 Character Storage 
Page 14. ASCII Representation of 123: 
' 1 ' ' 2 ' ' 3 ' 
00110001 00110010 00110011 
123 
01111011 
= 
= 
"1 2 3" 
1 2 3
1.3 Introducing Assembly Language 
• An instruction is a symbolic representation of a 
single machine instruction 
• Consists of: 
– label always optional 
– mnemonic always required 
– operand(s) required by some instructions 
– comment always optional 
• Examples: 
start: mov ax,20 ; initialize the AX register 
inc bx ; increment the BX register 
stc ; set the Carry flag
1. 
2. 
3. 
4. 
mov ax, 5 
add ax, 10 
add ax, 20 
ax 05 
ax 
ax 
mov [0120], ax ax 
15 
35 
35 
Memory 
011C 
35 0120 
5. int 20 
011E 
0122 
0124 
0126 
Figure 5. Sample Program Written in Debug.
Running DEBUG.EXE, Assembling a Program 
C:>debug 
-A 100 
0AFE:0100 mov ax,5 
0AFE:0103 add ax,10 
0AFE:0106 add ax,20 
0AFE:0109 mov [120],ax 
0AFE:010C int 20 
0AFE:010E 
assemble, starting at 
offset 100 
Press ENTER to return to 
command mode
Tracing the Sample Program. 
-T 
AX=0005 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 
DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0103 NV UP EI PL NZ NA PO NC 
0AFE:0103 051000 ADD AX,0010 
-T 
AX=0015 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 
DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0106 NV UP EI PL NZ NA PO NC 
0AFE:0106 052000 ADD AX,0020 
-T 
AX=0035 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 
DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0109 NV UP EI PL NZ NA PE NC 
0AFE:0109 A32001 MOV [0120],AX
Tracing the Sample Program (2) 
MOV [0120],AX 
-D 120,121 
0AFE:0120 35 00 
AX=0035 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 
DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=010C NV UP EI PL NZ NA PE NC 
0AFE:010C CD20 INT 20 
-G 
Program terminated normally
Table 9. Commonly Used Debug Commands. 
Command Description 
A Starts assembling a program, placing each instruction in 
memory. Optionally, an integer argument can be 
supplied, which specifies the hexadecimal location 
where the first instruction is to be inserted. 
G Executes the remainder of the program. 
Q Quits Debug 
R Displays the CPU registers. 
T Traces (execute) one program instruction.
The End

More Related Content

What's hot

GSP 215 RANK Education Counseling -- gsp215rank.com
GSP 215 RANK Education Counseling -- gsp215rank.comGSP 215 RANK Education Counseling -- gsp215rank.com
GSP 215 RANK Education Counseling -- gsp215rank.comkopiko85
 
GSP 215 RANK Lessons in Excellence-- gsp215rank.com
GSP 215 RANK Lessons in Excellence-- gsp215rank.comGSP 215 RANK Lessons in Excellence-- gsp215rank.com
GSP 215 RANK Lessons in Excellence-- gsp215rank.comRoelofMerwe102
 
GSP 215 RANK Inspiring Innovation--gsp215rank.com
GSP 215 RANK Inspiring Innovation--gsp215rank.com GSP 215 RANK Inspiring Innovation--gsp215rank.com
GSP 215 RANK Inspiring Innovation--gsp215rank.com KeatonJennings102
 
GSP 215 RANK Education Your Life--gsp215rank.com
GSP 215 RANK Education Your Life--gsp215rank.comGSP 215 RANK Education Your Life--gsp215rank.com
GSP 215 RANK Education Your Life--gsp215rank.comthomashard64
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programmingMakerere university
 
Gsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.comGsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.comStephenson101
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assemblyAbdul Khan
 
GSP 215 Effective Communication - tutorialrank.com
GSP 215  Effective Communication - tutorialrank.comGSP 215  Effective Communication - tutorialrank.com
GSP 215 Effective Communication - tutorialrank.comBartholomew35
 
Lecture01
Lecture01Lecture01
Lecture01Xafran
 
GSP 215 Education Organization - snaptutorial.com
GSP 215  Education Organization - snaptutorial.comGSP 215  Education Organization - snaptutorial.com
GSP 215 Education Organization - snaptutorial.comdonaldzs192
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.comStokesCope20
 

What's hot (15)

GSP 215 RANK Education Counseling -- gsp215rank.com
GSP 215 RANK Education Counseling -- gsp215rank.comGSP 215 RANK Education Counseling -- gsp215rank.com
GSP 215 RANK Education Counseling -- gsp215rank.com
 
GSP 215 RANK Lessons in Excellence-- gsp215rank.com
GSP 215 RANK Lessons in Excellence-- gsp215rank.comGSP 215 RANK Lessons in Excellence-- gsp215rank.com
GSP 215 RANK Lessons in Excellence-- gsp215rank.com
 
GSP 215 RANK Inspiring Innovation--gsp215rank.com
GSP 215 RANK Inspiring Innovation--gsp215rank.com GSP 215 RANK Inspiring Innovation--gsp215rank.com
GSP 215 RANK Inspiring Innovation--gsp215rank.com
 
GSP 215 RANK Education Your Life--gsp215rank.com
GSP 215 RANK Education Your Life--gsp215rank.comGSP 215 RANK Education Your Life--gsp215rank.com
GSP 215 RANK Education Your Life--gsp215rank.com
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
 
C++
C++C++
C++
 
Gsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.comGsp 215 Enthusiastic Study / snaptutorial.com
Gsp 215 Enthusiastic Study / snaptutorial.com
 
Mcs 012 soved assignment 2015-16
Mcs 012 soved assignment 2015-16Mcs 012 soved assignment 2015-16
Mcs 012 soved assignment 2015-16
 
Intro to assembly language
Intro to assembly languageIntro to assembly language
Intro to assembly language
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assembly
 
GSP 215 Effective Communication - tutorialrank.com
GSP 215  Effective Communication - tutorialrank.comGSP 215  Effective Communication - tutorialrank.com
GSP 215 Effective Communication - tutorialrank.com
 
Lecture01
Lecture01Lecture01
Lecture01
 
GSP 215 Education Organization - snaptutorial.com
GSP 215  Education Organization - snaptutorial.comGSP 215  Education Organization - snaptutorial.com
GSP 215 Education Organization - snaptutorial.com
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.com
 
Managing console input
Managing console inputManaging console input
Managing console input
 

Similar to Assembly Language Introduction

Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly LanguageAhmed M. Abed
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.combellflower148
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.combellflower169
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.combellflower126
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2Ikhwan_Fakrudin
 
GSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.comGSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.comsholingarjosh136
 
Gsp 215 Massive Success / snaptutorial.com
Gsp 215  Massive Success / snaptutorial.comGsp 215  Massive Success / snaptutorial.com
Gsp 215 Massive Success / snaptutorial.comNorrisMistryzo
 
6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptxHebaEng
 
Gsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comGsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comrobertleew18
 
Assembly chapter One.pptx
Assembly chapter One.pptxAssembly chapter One.pptx
Assembly chapter One.pptxssuserb78e291
 
GSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.comGSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.comclaric119
 
GSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.comGSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.comclaric169
 

Similar to Assembly Language Introduction (20)

Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly Language
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.com
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.com
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.com
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2Embedded system (Chapter 2) part 2
Embedded system (Chapter 2) part 2
 
GSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.comGSP 215 Technology levels--snaptutorial.com
GSP 215 Technology levels--snaptutorial.com
 
Gsp 215 Massive Success / snaptutorial.com
Gsp 215  Massive Success / snaptutorial.comGsp 215  Massive Success / snaptutorial.com
Gsp 215 Massive Success / snaptutorial.com
 
[ASM] Lab1
[ASM] Lab1[ASM] Lab1
[ASM] Lab1
 
6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx
 
Gsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comGsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.com
 
Assembly chapter One.pptx
Assembly chapter One.pptxAssembly chapter One.pptx
Assembly chapter One.pptx
 
Class2
Class2Class2
Class2
 
GSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.comGSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.com
 
GSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.comGSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.com
 

Assembly Language Introduction

  • 1. Chapter 1: Context of Assembly Language Slides to Accompany Assembly Language for Intel-Based Computers, Third Edition Copyright 1999-2000, Prentice-Hall Incorporated Updated 08/00
  • 2. Table 1. Software Hierarchy Levels. Level Description Application Program Software designed for a particular class of applications. High-Level Language (HLL) Programs are compiled into either assembly language or machine language. Each statement usually translates into multiple machine language instructions. Examples are C++, Pascal, Java, and Visual Basic. Operating System Contains procedures that can be called from programs written in either high-level language or assembly language. This system may also contain an application programming interface (API). Assembly Language (ASM) Uses instruction mnemonics that have a one-to-one correspondence with machine language. Machine Language (ML) Numeric instructions and operands that can be stored in memory and directly executed by the computer processor.
  • 3. Essential Tools • An assembler is a program that converts source-code programs into a machine language (object file). • A linker joins together two or more object files and produces a single executable file. • A debugger loads an executable program, displays the source code, and lets the programmer step through the program one instruction at a time, and display and modify memory.
  • 4. Figure 1. Machine Language Generation by ASM and HLL programs. ASM ML ML ML ML ML HLL
  • 5. Table 2. Comparison of Assembly Language to HLLs. Type of Application High-Level Language Assembly Language Business application Formal structures make it software, written for easy to organize and single platform, medium maintain large sections of to large size. code. No formal structure. Programmer must impose an artificial structure. Hardware device driver. Language may not provide for direct hardware access. Awkward coding techniques must be used, resulting in possible maintenance problems. Hardware access is straightforward and simple. Easy to maintain when the programs are short and well documented. Business application written for multiple platforms (different operating systems). Usually very portable. The source code can be recompiled on each target operating system with minimal changes. Must be recoded separately for each platform, often using an assembler with a different syntax. Difficult to maintain. Embedded systems and computer games requiring direct hardware access. Produces too much executable code, and may not run efficiently. Ideal, because the executable code is small and runs quickly.
  • 6. Figure 2. Assembly Language Subroutines Used as Hardware Interfaces. Application Program Interface Subroutine Operating System Device Driver Subroutine Hardware
  • 7. Machine Language • Consists of binary numbers • The "native" language of the computer • Each ML instruction contains an op code (operation code) and zero or more operands. • Examples: Opcode Operand Meaning ------------------------------------------------- 40 increment the AX register 05 0005 add 0005 to AX
  • 8. Page 7: Bits, Bytes, and Doublewords: byte byte 0 0 1 0 0 1 1 0 0 1 1 0 1 0 1 0 bit word Each 1 or 0 is called a bit.
  • 9. Table 3. Storage Sizes and Ranges of Unsigned Integers. Storage Type Bits Range (low - high) Unsigned byte 8 0 to 255 Unsigned word 16 0 to 65,535 Unsigned doubleword 32 0 to 4,294,967,295 Unsigned quadword 64 0 to 18,446,744,073,709,551,615
  • 10. Table 4. Digits in Various Number Systems. System Base Possible Digits Binary 2 0 1 Octal 8 0 1 2 3 4 5 6 7 Decimal 10 0 1 2 3 4 5 6 7 8 9 Hexadecimal 16 0 1 2 3 4 5 6 7 8 9 A B C D E F
  • 11. Page 9. ASCII Digit String. Format Value ASCII binary "01000001" ASCII decimal "65" ASCII hexadecimal "41" ASCII octal "101"
  • 12. Table 5. Binary Bit Position Values. 2n Decimal Value 2n Decimal Value 20 1 28 256 21 2 29 512 22 4 210 1024 23 8 211 2048 24 16 212 4096 25 32 213 8192 26 64 214 16384 27 128 215 32768
  • 13. Figure 3. Converting Binary to Decimal. 8 + 1 9
  • 14. Table 6. Binary, Decimal, and Hexadecimal Equivalents. Binary Decimal Hexadecimal Binary Decimal Hexadecimal 0000 0 0 1000 8 8 0001 1 1 1001 9 9 0010 2 2 1010 10 A 0011 3 3 1011 11 B 0100 4 4 1100 12 C 0101 5 5 1101 13 D 0110 6 6 1110 14 E 0111 7 7 1111 15 F
  • 15. Table 7. Powers of 16, in Decimal. 16n Decimal Value 16n Decimal Value 160 1 164 65,536 161 16 165 1,048,576 162 256 166 16,777,216 163 4096 167 268,435,456
  • 16. Figure 4. Converting 3BA4 Hexadecimal to Decimal. 3 * 4096 = 12,288 11 * 256 = 2,816 10 * 16 = 160 4 * 1 = + 4 Total: 15,268 3 B A 4
  • 17. 1 1 1 1 0 1 1 0 0 0 0 0 1 0 1 0 = = sign bit – 10 + 10 1.2.4 Signed Numbers
  • 18. Table 8. Signed Integer Storage and Ranges. Storage Type Bits Range (low - high) Signed byte 7 -128 to +127 Signed word 15 –32,768 to +32,767 Signed doubleword 31 –2,147,483,648 to 2,147,483,647 Signed quadword 63 –9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
  • 19. 1.2.5 Character Storage Page 14. ASCII Representation of 123: ' 1 ' ' 2 ' ' 3 ' 00110001 00110010 00110011 123 01111011 = = "1 2 3" 1 2 3
  • 20. 1.3 Introducing Assembly Language • An instruction is a symbolic representation of a single machine instruction • Consists of: – label always optional – mnemonic always required – operand(s) required by some instructions – comment always optional • Examples: start: mov ax,20 ; initialize the AX register inc bx ; increment the BX register stc ; set the Carry flag
  • 21. 1. 2. 3. 4. mov ax, 5 add ax, 10 add ax, 20 ax 05 ax ax mov [0120], ax ax 15 35 35 Memory 011C 35 0120 5. int 20 011E 0122 0124 0126 Figure 5. Sample Program Written in Debug.
  • 22. Running DEBUG.EXE, Assembling a Program C:>debug -A 100 0AFE:0100 mov ax,5 0AFE:0103 add ax,10 0AFE:0106 add ax,20 0AFE:0109 mov [120],ax 0AFE:010C int 20 0AFE:010E assemble, starting at offset 100 Press ENTER to return to command mode
  • 23. Tracing the Sample Program. -T AX=0005 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0103 NV UP EI PL NZ NA PO NC 0AFE:0103 051000 ADD AX,0010 -T AX=0015 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0106 NV UP EI PL NZ NA PO NC 0AFE:0106 052000 ADD AX,0020 -T AX=0035 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=0109 NV UP EI PL NZ NA PE NC 0AFE:0109 A32001 MOV [0120],AX
  • 24. Tracing the Sample Program (2) MOV [0120],AX -D 120,121 0AFE:0120 35 00 AX=0035 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=0AFE ES=0AFE SS=0AFE CS=0AFE IP=010C NV UP EI PL NZ NA PE NC 0AFE:010C CD20 INT 20 -G Program terminated normally
  • 25. Table 9. Commonly Used Debug Commands. Command Description A Starts assembling a program, placing each instruction in memory. Optionally, an integer argument can be supplied, which specifies the hexadecimal location where the first instruction is to be inserted. G Executes the remainder of the program. Q Quits Debug R Displays the CPU registers. T Traces (execute) one program instruction.