SlideShare a Scribd company logo
assembly language programming organization of IBM PC chapter 9 part-2(decimal input,output)
Batch (014)
assembly language programming organization of IBM PC chapter 9 part-2(decimal input,output)
Topic:
Decimal Input and Output
Group member:
M NABEEL (14093122-014)
TAYYAB SAEED (14093122-015)
NASEER AHMAD (14093122-016)
AQEEL HAIDER (14093122-017)
MIR HAMZA MAJEED (14093122-018)
HAMZA TAJ (14093122-018)
Decimal Input and Output
 Computer represent every thing in binary.
 But it is convenient for user to represent input
and output in decimal.
 If we input 21543 character string then it must
to converted internally.
 Conversely on output the binary contents of R/M
must be converted to decimal equivalent before
being printed.
Decimal input
 Convert a string of ASCII digits to the binary
representation of decimal equivalent
 For input we repeatedly multiply AX by 10
Algorithm (First version):
Total=0
Read an ASCII
REPEAT
convert character to number
Total=total*10+value
Read a character
Until character is carriage return
Cont..
Example: input of 123
Total =0
Read ‘1’
Convert ‘1’ to 1
Total=10*0 +1=1
Read ‘2’
Convert ‘2’ to 2
Total=10*1 +2=12
Read ‘3’
Convert ‘3’ to 3
Total=10*12 +3=123
Cont..
Range: -32768 to 32767
Optional sign followed by string of digits &
carriage return
Outside ‘0’ to ‘9’
jumps to new line and ask for input again
Cont..
Algorithm(second version):
total=0
Negative=false
Read a character
Case character of
• ‘-’: negative=true
read a character
• ‘+’: read a character
End_case
Repeat
If character is not between ‘0’ to ‘9’
Then
Go to beginning
Cont..
Else
Convert character to binary value
Total=10*total+value
End_if
Read a character
Until character is carriage return
If negative =true
Then
total=-total
Cont..
Program(source code):
INDEC PROC
;READ NUMBER IN RANGE -32768 TO 32767
PUSH BX
PUSH CX
PUSH DX
@BEGIN:
;total =0
XOR BX,BX ;BX hold total
;negative =false
Cont..
XOR CX,CX ;CX hold sign
;read char
MOV AH,1
INT 21H
;case char of
CMP AL,'-' ;minus sign
JE @MINUS ;yes,set sign
CMP AL,'+' ;plus sign
JE @PLUS ;yes,get another char
Cont..
JMP @REPEAT2 ;start processing char
@MINUS: MOV CX,1
@PLUS: INT 21H
;end case
@REPEAT2:
;if char. is between '0' and '9'
CMP AL,'0' ;char >='0'?
JNGE @NOT_DIGIT ;illegal char.
Cont..
CMP AL,'9' ;char<='9' ?
JNLE @NOT_DIGIT
;then convert char to digit
AND AX,000FH
PUSH AX ;save number
;total =total *10 +digit
MOV AX,10
MUL BX
POP BX ;retrieve number
ADD BX,AX ;total =total *10 +digit
Cont..
;read char
MOV AH,1
INT 21H
CMP AL,0DH ;CR
JNE @REPEAT2 ;no keep going
;until CR
MOV AX,BX ;store number in AX
;if negative
OR CX,CX ;negative number
Cont..
Jz @EXIT ;no,exit
;then
NEG AX ;yes,negate
;end if
@EXIT: ;retrieve registers
POP DX
POP CX
POP BX
RET
Cont..
;here if illegal char entered
@NOT_DIGIT:
MOV AH,2
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H
JMP @BEGIN
INDEC ENDP
Cont..
Output:
Input Overflow
 AX:FFFFh
 In decimal:65535
 Range:-32768 to 32767
 Anything out of range called input overflow
 For example:
 Input:32769
 Total=327690
Cont..
Algorithm:
total=0
Negative=false
Read a character
Case character of
• ‘-’: negative=true
read a character
• ‘+’: read a character
Cont..
End_case
Repeat
If character is not between ‘0’ to ‘9’
Then
Go to beginning
Else
Convert character to binary value
Total=10*total
Cont..
If overflow
Then
go to beginning
Else
Total =total*10 +value
If overflow
Then
go to beginning
Cont..
End_if
End_if
End_if
Read a character
Until character is carriage return
If negative =true
Then
total=-total
Cont..
Code:
;total =total *10 +digit
MOV AX,10
MUL BX
CMP DX,0
JNE @NOT_DIGIT
POP BX
ADD BX,AX
JC @NOT_DIGIT
Cont..
Output:
Algorithm for Decimal Output:
 If AX < 0 /*AX holds output value */
 THEN
 Print a minus sign
 Replace AX by its twos complement
 End_IF
 Get the digits in AX’s decimal representation
 Convert these digits into characters and print them
Decimal Output
Cont..
To see what line 6 entitles, suppose the contents of AX,
expressed in decimal is 24168. To get the digits in decimal
representation , we can proceed as follows,
 Divide 24618 by 10, Quotient= 2461, remainder=8
 Divide 2461 by 10, Quotient= 246, remainder=1
 Divide 246 by 10 , Quotient=24, remainder=6
 Divide 24 by 10, Quotient=2, remainder=4
 Divide 2 by 10, Quotient=0, remainder=2
Cont..
LINE 6:
Cout =0 /*will count decimal digit */
REPEAT
divide quotient by 10
Push remainder on the stack
Count= count +1
UNTILL
Quotient=0
Cont..
LINE 7:
FOR count times DO
Pop a digit from the stack
Convert it to a character
Output the character
END_FOR
Cont..
Program Listing PMG9_1.ASM
.MODEL SMALL
.STACK 100H
.CODE
OUTDEC PROC
;prints AX as a signed decimal integer
;input: AX
;output: none
PUSH AX ;save registers
PUSH BX
PUSH CX
PUSH DX
Cont..
;if AX < 0
OR AX,AX ;AX < 0?
JGE @END_IF1 ;NO >0
;then
PUSH AX ; save number
MOV DL,’-’ ;get ‘-’
MOV AH,2 ;print character function
INT 21H ;print ‘-’
POP AX ;get Ax back
NEG AX ;AX= -AX
@END_IF1:
Cont..
;get decimal digits
XOR CX,CX ;CX counts digits
MOV BX,10D ;BX has divisor
@REPEAT1:
XOR DX,DX ;prepare high word of dividend
DIV BX ;AX=quotient, DX=remainder
PUSH DX ;save remainder on stack
INC CX ;count = count +1
;until
OR AX,AX ;quotient = 0?
JNE @REPEAT ;no, keep going
Cont..
;convert digits to character and print
MOV AH,2 ;print character function
;for count time do
@PRINT_LOOP
POP DX ;digit in DL
OR DL,30H ;convert to character
INT 21H ;print digit
;end_for
POP DX ; restore registers
POP CX
POP BX
POP AX
OUTDEC ENDP
assembly language programming organization of IBM PC chapter 9 part-2(decimal input,output)
Ad

More Related Content

What's hot (20)

Assembly Langauge Chap 1
Assembly Langauge Chap 1Assembly Langauge Chap 1
Assembly Langauge Chap 1
warda aziz
 
Representation of numbers and characters
Representation of numbers and charactersRepresentation of numbers and characters
Representation of numbers and characters
warda aziz
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modes
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
Motaz Saad
 
Switch Case in C Programming
Switch Case in C ProgrammingSwitch Case in C Programming
Switch Case in C Programming
Sonya Akter Rupa
 
chapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionschapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructions
warda aziz
 
Stack Operations
Stack Operations Stack Operations
Stack Operations
RidaZaman1
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
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
Education
 
Karnaugh Map
Karnaugh MapKarnaugh Map
Karnaugh Map
Syed Absar
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
Motaz Saad
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
Usman Bin Saad
 
Stack
StackStack
Stack
lalithambiga kamaraj
 
K map
K mapK map
K map
Pranjali Rawat
 
stack in assembally language
stack in assembally languagestack in assembally language
stack in assembally language
Daffodil International University
 
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
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
Education Front
 
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsWriting Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Salman Memon
 
Assembly Langauge Chap 1
Assembly Langauge Chap 1Assembly Langauge Chap 1
Assembly Langauge Chap 1
warda aziz
 
Representation of numbers and characters
Representation of numbers and charactersRepresentation of numbers and characters
Representation of numbers and characters
warda aziz
 
Arrays and addressing modes
Arrays and addressing modesArrays and addressing modes
Arrays and addressing modes
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
Motaz Saad
 
Switch Case in C Programming
Switch Case in C ProgrammingSwitch Case in C Programming
Switch Case in C Programming
Sonya Akter Rupa
 
chapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionschapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructions
warda aziz
 
Stack Operations
Stack Operations Stack Operations
Stack Operations
RidaZaman1
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
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
Education
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
Motaz Saad
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
Usman Bin Saad
 
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
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
Education Front
 
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsWriting Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Salman Memon
 

Similar to assembly language programming organization of IBM PC chapter 9 part-2(decimal input,output) (20)

Taller Ensambladores
Taller EnsambladoresTaller Ensambladores
Taller Ensambladores
Christian Morales
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
Al2ed chapter11
Al2ed chapter11Al2ed chapter11
Al2ed chapter11
Abdullelah Al-Fahad
 
L12_ COA_COmputer architecurte and organization
L12_ COA_COmputer architecurte and organizationL12_ COA_COmputer architecurte and organization
L12_ COA_COmputer architecurte and organization
sambhuduttan
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
Nora Youssef
 
Taller practico emu8086_galarraga
Taller practico emu8086_galarragaTaller practico emu8086_galarraga
Taller practico emu8086_galarraga
Fabricio Galárraga
 
8086 instruction set
8086  instruction set8086  instruction set
8086 instruction set
mengistu ketema
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086
techbed
 
Exp 03
Exp 03Exp 03
Exp 03
madzflores
 
Assembly language
Assembly languageAssembly language
Assembly language
bryle12
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
Vijay Kumar
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
AmitPaliwal20
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
MomenMostafa
 
Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
Dr. Thippeswamy S.
 
Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
Dr. Thippeswamy S.
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
HebaEng
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
Ravi Anand
 
Microprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannualMicroprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannual
yeshwant gadave
 
Home works summary.pptx
Home works summary.pptxHome works summary.pptx
Home works summary.pptx
HebaEng
 
microp-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :Pmicrop-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :P
Jathin Kanumuri
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
L12_ COA_COmputer architecurte and organization
L12_ COA_COmputer architecurte and organizationL12_ COA_COmputer architecurte and organization
L12_ COA_COmputer architecurte and organization
sambhuduttan
 
Taller practico emu8086_galarraga
Taller practico emu8086_galarragaTaller practico emu8086_galarraga
Taller practico emu8086_galarraga
Fabricio Galárraga
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086
techbed
 
Assembly language
Assembly languageAssembly language
Assembly language
bryle12
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
Vijay Kumar
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
AmitPaliwal20
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
MomenMostafa
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
HebaEng
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
Ravi Anand
 
Microprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannualMicroprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannual
yeshwant gadave
 
Home works summary.pptx
Home works summary.pptxHome works summary.pptx
Home works summary.pptx
HebaEng
 
microp-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :Pmicrop-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :P
Jathin Kanumuri
 
Ad

More from Bilal Amjad (13)

IoT Based Smart Energy Meter using Raspberry Pi and Arduino
IoT Based Smart Energy Meter using Raspberry Pi and Arduino IoT Based Smart Energy Meter using Raspberry Pi and Arduino
IoT Based Smart Energy Meter using Raspberry Pi and Arduino
Bilal Amjad
 
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink) Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Bilal Amjad
 
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Solar Radiation monthly prediction and forecasting using Machine Learning tec...Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Bilal Amjad
 
Big Data in Smart Grid
Big Data in Smart GridBig Data in Smart Grid
Big Data in Smart Grid
Bilal Amjad
 
Flexibility of Power System (Sources of flexibility & flexibility markets)
Flexibility of Power System (Sources of flexibility & flexibility markets)Flexibility of Power System (Sources of flexibility & flexibility markets)
Flexibility of Power System (Sources of flexibility & flexibility markets)
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
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
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Bilal Amjad
 
bubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly languagebubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly language
Bilal Amjad
 
Limit of complex number
Limit of complex numberLimit of complex number
Limit of complex number
Bilal Amjad
 
simple combinational lock
simple combinational locksimple combinational lock
simple combinational lock
Bilal Amjad
 
4-bit camparator
4-bit camparator4-bit camparator
4-bit camparator
Bilal Amjad
 
Orthogonal trajectories
Orthogonal trajectoriesOrthogonal trajectories
Orthogonal trajectories
Bilal Amjad
 
IoT Based Smart Energy Meter using Raspberry Pi and Arduino
IoT Based Smart Energy Meter using Raspberry Pi and Arduino IoT Based Smart Energy Meter using Raspberry Pi and Arduino
IoT Based Smart Energy Meter using Raspberry Pi and Arduino
Bilal Amjad
 
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink) Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Bilal Amjad
 
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Solar Radiation monthly prediction and forecasting using Machine Learning tec...Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Bilal Amjad
 
Big Data in Smart Grid
Big Data in Smart GridBig Data in Smart Grid
Big Data in Smart Grid
Bilal Amjad
 
Flexibility of Power System (Sources of flexibility & flexibility markets)
Flexibility of Power System (Sources of flexibility & flexibility markets)Flexibility of Power System (Sources of flexibility & flexibility markets)
Flexibility of Power System (Sources of flexibility & flexibility markets)
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
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
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Bilal Amjad
 
bubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly languagebubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly language
Bilal Amjad
 
Limit of complex number
Limit of complex numberLimit of complex number
Limit of complex number
Bilal Amjad
 
simple combinational lock
simple combinational locksimple combinational lock
simple combinational lock
Bilal Amjad
 
4-bit camparator
4-bit camparator4-bit camparator
4-bit camparator
Bilal Amjad
 
Orthogonal trajectories
Orthogonal trajectoriesOrthogonal trajectories
Orthogonal trajectories
Bilal Amjad
 
Ad

Recently uploaded (20)

new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Artificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptxArtificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptx
DrMarwaElsherif
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Journal of Soft Computing in Civil Engineering
 
Data Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptxData Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptx
RushaliDeshmukh2
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
LECTURE-16 EARTHEN DAM - II.pptx it's uses
LECTURE-16 EARTHEN DAM - II.pptx it's usesLECTURE-16 EARTHEN DAM - II.pptx it's uses
LECTURE-16 EARTHEN DAM - II.pptx it's uses
CLokeshBehera123
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxbMain cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
SunilSingh610661
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Artificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptxArtificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptx
DrMarwaElsherif
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Data Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptxData Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptx
RushaliDeshmukh2
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
LECTURE-16 EARTHEN DAM - II.pptx it's uses
LECTURE-16 EARTHEN DAM - II.pptx it's usesLECTURE-16 EARTHEN DAM - II.pptx it's uses
LECTURE-16 EARTHEN DAM - II.pptx it's uses
CLokeshBehera123
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxbMain cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
Main cotrol jdbjbdcnxbjbjzjjjcjicbjxbcjcxbjcxb
SunilSingh610661
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 

assembly language programming organization of IBM PC chapter 9 part-2(decimal input,output)

  • 4. Topic: Decimal Input and Output Group member: M NABEEL (14093122-014) TAYYAB SAEED (14093122-015) NASEER AHMAD (14093122-016) AQEEL HAIDER (14093122-017) MIR HAMZA MAJEED (14093122-018) HAMZA TAJ (14093122-018)
  • 5. Decimal Input and Output  Computer represent every thing in binary.  But it is convenient for user to represent input and output in decimal.  If we input 21543 character string then it must to converted internally.  Conversely on output the binary contents of R/M must be converted to decimal equivalent before being printed.
  • 6. Decimal input  Convert a string of ASCII digits to the binary representation of decimal equivalent  For input we repeatedly multiply AX by 10 Algorithm (First version): Total=0 Read an ASCII REPEAT convert character to number Total=total*10+value Read a character Until character is carriage return
  • 7. Cont.. Example: input of 123 Total =0 Read ‘1’ Convert ‘1’ to 1 Total=10*0 +1=1 Read ‘2’ Convert ‘2’ to 2 Total=10*1 +2=12 Read ‘3’ Convert ‘3’ to 3 Total=10*12 +3=123
  • 8. Cont.. Range: -32768 to 32767 Optional sign followed by string of digits & carriage return Outside ‘0’ to ‘9’ jumps to new line and ask for input again
  • 9. Cont.. Algorithm(second version): total=0 Negative=false Read a character Case character of • ‘-’: negative=true read a character • ‘+’: read a character End_case Repeat If character is not between ‘0’ to ‘9’ Then Go to beginning
  • 10. Cont.. Else Convert character to binary value Total=10*total+value End_if Read a character Until character is carriage return If negative =true Then total=-total
  • 11. Cont.. Program(source code): INDEC PROC ;READ NUMBER IN RANGE -32768 TO 32767 PUSH BX PUSH CX PUSH DX @BEGIN: ;total =0 XOR BX,BX ;BX hold total ;negative =false
  • 12. Cont.. XOR CX,CX ;CX hold sign ;read char MOV AH,1 INT 21H ;case char of CMP AL,'-' ;minus sign JE @MINUS ;yes,set sign CMP AL,'+' ;plus sign JE @PLUS ;yes,get another char
  • 13. Cont.. JMP @REPEAT2 ;start processing char @MINUS: MOV CX,1 @PLUS: INT 21H ;end case @REPEAT2: ;if char. is between '0' and '9' CMP AL,'0' ;char >='0'? JNGE @NOT_DIGIT ;illegal char.
  • 14. Cont.. CMP AL,'9' ;char<='9' ? JNLE @NOT_DIGIT ;then convert char to digit AND AX,000FH PUSH AX ;save number ;total =total *10 +digit MOV AX,10 MUL BX POP BX ;retrieve number ADD BX,AX ;total =total *10 +digit
  • 15. Cont.. ;read char MOV AH,1 INT 21H CMP AL,0DH ;CR JNE @REPEAT2 ;no keep going ;until CR MOV AX,BX ;store number in AX ;if negative OR CX,CX ;negative number
  • 16. Cont.. Jz @EXIT ;no,exit ;then NEG AX ;yes,negate ;end if @EXIT: ;retrieve registers POP DX POP CX POP BX RET
  • 17. Cont.. ;here if illegal char entered @NOT_DIGIT: MOV AH,2 MOV DL,0DH INT 21H MOV DL,0AH INT 21H JMP @BEGIN INDEC ENDP
  • 19. Input Overflow  AX:FFFFh  In decimal:65535  Range:-32768 to 32767  Anything out of range called input overflow  For example:  Input:32769  Total=327690
  • 20. Cont.. Algorithm: total=0 Negative=false Read a character Case character of • ‘-’: negative=true read a character • ‘+’: read a character
  • 21. Cont.. End_case Repeat If character is not between ‘0’ to ‘9’ Then Go to beginning Else Convert character to binary value Total=10*total
  • 22. Cont.. If overflow Then go to beginning Else Total =total*10 +value If overflow Then go to beginning
  • 23. Cont.. End_if End_if End_if Read a character Until character is carriage return If negative =true Then total=-total
  • 24. Cont.. Code: ;total =total *10 +digit MOV AX,10 MUL BX CMP DX,0 JNE @NOT_DIGIT POP BX ADD BX,AX JC @NOT_DIGIT
  • 26. Algorithm for Decimal Output:  If AX < 0 /*AX holds output value */  THEN  Print a minus sign  Replace AX by its twos complement  End_IF  Get the digits in AX’s decimal representation  Convert these digits into characters and print them Decimal Output
  • 27. Cont.. To see what line 6 entitles, suppose the contents of AX, expressed in decimal is 24168. To get the digits in decimal representation , we can proceed as follows,  Divide 24618 by 10, Quotient= 2461, remainder=8  Divide 2461 by 10, Quotient= 246, remainder=1  Divide 246 by 10 , Quotient=24, remainder=6  Divide 24 by 10, Quotient=2, remainder=4  Divide 2 by 10, Quotient=0, remainder=2
  • 28. Cont.. LINE 6: Cout =0 /*will count decimal digit */ REPEAT divide quotient by 10 Push remainder on the stack Count= count +1 UNTILL Quotient=0
  • 29. Cont.. LINE 7: FOR count times DO Pop a digit from the stack Convert it to a character Output the character END_FOR
  • 30. Cont.. Program Listing PMG9_1.ASM .MODEL SMALL .STACK 100H .CODE OUTDEC PROC ;prints AX as a signed decimal integer ;input: AX ;output: none PUSH AX ;save registers PUSH BX PUSH CX PUSH DX
  • 31. Cont.. ;if AX < 0 OR AX,AX ;AX < 0? JGE @END_IF1 ;NO >0 ;then PUSH AX ; save number MOV DL,’-’ ;get ‘-’ MOV AH,2 ;print character function INT 21H ;print ‘-’ POP AX ;get Ax back NEG AX ;AX= -AX @END_IF1:
  • 32. Cont.. ;get decimal digits XOR CX,CX ;CX counts digits MOV BX,10D ;BX has divisor @REPEAT1: XOR DX,DX ;prepare high word of dividend DIV BX ;AX=quotient, DX=remainder PUSH DX ;save remainder on stack INC CX ;count = count +1 ;until OR AX,AX ;quotient = 0? JNE @REPEAT ;no, keep going
  • 33. Cont.. ;convert digits to character and print MOV AH,2 ;print character function ;for count time do @PRINT_LOOP POP DX ;digit in DL OR DL,30H ;convert to character INT 21H ;print digit ;end_for POP DX ; restore registers POP CX POP BX POP AX OUTDEC ENDP