100% found this document useful (1 vote)
266 views

Microprocessors and Microcontrollers Notes - Programs For 16 Bit Arithmetic Operations For 8086 (Using Various Addressing Modes) - Studentboxoffice

The document contains an assembly language program to perform 16-bit arithmetic operations on the 8086 microprocessor using various addressing modes. It includes programs to add, subtract, multiply and divide two 16-bit numbers as both signed and unsigned values. For each operation, the program code, input/output values, and flag status before and after are provided. The goal is to learn how to write assembly code to perform common 16-bit arithmetic calculations on the 8086 microprocessor.

Uploaded by

ABHINAY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
266 views

Microprocessors and Microcontrollers Notes - Programs For 16 Bit Arithmetic Operations For 8086 (Using Various Addressing Modes) - Studentboxoffice

The document contains an assembly language program to perform 16-bit arithmetic operations on the 8086 microprocessor using various addressing modes. It includes programs to add, subtract, multiply and divide two 16-bit numbers as both signed and unsigned values. For each operation, the program code, input/output values, and flag status before and after are provided. The goal is to learn how to write assembly code to perform common 16-bit arithmetic calculations on the 8086 microprocessor.

Uploaded by

ABHINAY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

Programsfor16bitarithmeticoperationsfor8086(using
variousaddressingmodes)
studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

TopicContent.

1.Additionoftwo16bitnumbers
Aim:
Towriteanassemblylanguageprogramtoperformadditionoftwo16bitsignedandunsignednumbers.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAX,OPR1
ADDAX,OPR2
MOVRES,AX
HLT
CODEENDS
DATASEGMENT
OPR1DW4269H
OPR2DW1000H
RESDW?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

OPERATION

COMMENTS

0000

B88E4E

MOVAX,4E8E

0003

8ED8

MOVDS,AX

0005

A10000

MOVAX,[0000]

THEVALUEIN[0000]ISMOVED
TOAX

0008

03060200

ADDAX,[0002]

THEVALUEIN[0002]ISADDED
TOAX

000C

A30400

MOV[0004],AX

THEVALUEINAXISMOVED
TO[0004]

INITIALIZATIONOF
DATASEGMENT

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

1/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

ADDRESS

OPCODE

000F

F4

OPERATION
HLT

COMMENTS
ENDOFPROGRAM

FlowChart:
Result:
UNSIGNEDNUMBERS
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,
i=1,d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=1,a=0,
i=1,d=0.
Input:
OPR1=4269H
OPR2=1000H
Output:
RES=5269H
SIGNEDNUMBERS
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,
i=1,d=0.
Afterexecution,c=1,s=0,z=0,o=1,p=0,a=0,
i=1,d=0.
Input:
OPR1=9763H
OPR2=A973H
Output:
RES=40D6H

2.Subtractionoftwo16bitnumbers
Aim:
Towriteanassemblylanguageprogramtoperformsubtractionoftwo16bitsignedand
unsignednumbers.
Tools:
PCinstalledwithTASM.
Program:
http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

2/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAX,OPR1
MOVBX,OPR2
SUBAX,BX
MOVRES,AX
HLT
CODEENDS
DATASEGMENT
OPR1DW4269H
OPR2DW1000H
RESDW?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

OPERATION

COMMENTS

0000

B88E4E

MOVAX,4E8E

0003

8ED8

MOVDS,AX

0005

A10000

MOVAX,[0000]

THEVALUEIN[0000]ISMOVED
TOAX

0008

2B060200

ADDAX,[0002]

THEVALUEIN[0002]ISSUBTRACTED
FROMAX

000C

A30400

MOV[0004],AX

THEVALUEINAXISMOVED
TO[0004]

000F

F4

HLT

ENDOFPROGRAM

INITIALIZATIONOF
DATASEGMENT

FlowChart:
Result:
UNSIGNEDNUMBERS
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=1,a=0,i=1,d=0.
Input:
OPR1=4269H
OPR2=1000H
Output:
RES=3269H
http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

3/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

SIGNEDNUMBERS
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,
d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=1,a=0,i=1,
d=0.
Input:
OPR1=9763H
OPR2=8973H
Output:
RES=0DF0H

3.Multiplicationoftwo16bitunsignednumbers
Aim:
Towriteanassemblylanguageprogramtoperform
multiplicationoftwo16bitunsignednumbers.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAX,OPR1
MULOPR2
MOVRESLW,AX
MOVRESHW,DX
HLT
CODEENDS
DATASEGMENT
OPR1DW2000H
OPR2DW4000H
RESLWDW?
RESHWDW?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

0000

B88E4E

OPERATION
MOVAX,4E8E

COMMENTS
INITIALIZATIONOF
DATASEGMENT

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

4/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

OPERATION

ADDRESS

OPCODE

COMMENTS

0003

8ED8

MOVDS,AX

0005

A10000

MOVAX,[0000]

THEVALUEIN[0000]ISMOVED
TOAX

0008

F7260200

IMULWORDPTR[0002]

THEVALUEIN[0002]ISMULTIPLIED
BYAX

000C

A30400

MOV[0004],AX

THEVALUEINAXISMOVED
TO[0004]

000F

89160600

MOV[0006],DX

THEVALUEINDXISMOVED
TO[0006]

0013

F4

HLT

ENDOFPROGRAM

FlowChart:
Result:
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,
d=0.
Afterexecution,c=1,s=0,z=0,o=1,p=0,a=0,i=1,
d=0.
Input:
OPR1=2000H
OPR2=4000H
Output:
RESLW=0000H(AX)
RESHW=0800H(DX)

4.Multiplicationoftwo16bitsignednumbers.
Aim:
Towriteanassemblylanguageprogramtoperformmultiplicationoftwo16bitsigned
numbers.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

5/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

MOVAX,DATA
MOVDS,AX
MOVAX,OPR1
IMULOPR2
MOVRESLW,AX
MOVRESHW,DX
HLT
CODEENDS
DATASEGMENT
OPR1DW7593H
OPR2DW6845H
RESLWDW?
RESHWDW?
DATAENDS
END
ListFile:
ADDRESS

OPCODE

OPERATION

COMMENTS

0000

B88E4E

MOVAX,4E8E

0003

8ED8

MOVDS,AX

0005

A10000

MOVAX,[0000]

THEVALUEIN[0000]ISMOVED
TOAX

0008

F72E0200

IMULWORDPTR[0002]

THEVALUEIN[0002]ISADDED
TOAX

000C

A30400

MOV[0004],AX

THEVALUEINAXISMOVED
TO[0004]

000F

89160600

MOV[0006],DX

THEVALUEINDXISMOVED
TO[0006]

0013

F4

HLT

ENDOFPROGRAM

INITIALIZATIONOF
DATASEGMENT

FlowChart:
Result:
Case1:Twopositivenumbers
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=1,s=0,z=0,o=1,p=0,a=0,i=1,d=0.
Input:
OPR1=7593H
OPR2=6845H

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

6/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

Output:
RESLW=689FH(AX)
RESHW=2FE3H(DX)
Case2:onepositivenumber&onenegativenumber
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=1,s=0,z=0,o=1,p=0,a=0,i=1,d=0.
Input:
OPR1=8A6DH<2sComplementof(7593H)
OPR2=6845H
Output:
RESLW=9761H(AX)<2sComplement
RESHW=D01CH(DX)<of(2FE3689FH)
Case3:twonegativenumbers
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=1,s=0,z=0,o=1,p=0,a=0,i=1,d=0.
Input:
OPR1=8A6DH<2sComplementof(7593H)
OPR2=97BBH<2sComplementof(6845H)
Output:
RESLW=689FH(AX)
RESHW=2FE3H(DX)

5.Divisionofunsignednumbers
Aim:
Towriteanassemblylanguageprogramtoperformdivisionof16bitunsignednumberby8bit
unsignednumber.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAX,OPR1
DIVOPR2
http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

7/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

MOVRESQ,AL
MOVRESR,AH
HLT
CODEENDS
DATASEGMENT
OPR1DW2C58H
OPR2DB56H
RESQDB?
RESRDB?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

OPERATION

COMMENTS

0000

B88F4E

MOVAX,4E8F

0003

8ED8

MOVDS,AX

0005

A10000

MOVAX,[0000]

THEVALUEIN[0000]ISMOVED
TOAX

0008

F6360200

DIVBYTEPTR[0002]

THEVALUEIN[0002]ISADDED
TOAX

000C

A20300

MOV[0003],AX

THEVALUEINALISMOVED
TO[0003]

000F

88260400

MOV[0004],DX

THEVALUEINAHISMOVED
TO[0004]

0013

F4

HLT

ENDOFPROGRAM

INITIALIZATIONOF
DATASEGMENT

FlowChart:
Result:
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=0,a=1,i=1,d=0.
Input:
OPR1=2C58H(DIVIDEND)
OPR2=56H(DIVISOR)
Output:
RESQ=84H(AL)
RESR=00H(AH)

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

8/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

6.Divisionofsignednumbers
Aim:
Towriteanassemblylanguageprogramtoperform
divisionof16bitsignednumberby8bitsigned
number.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAX,OPR1
IDIVOPR2
MOVRESQ,AL
MOVRESR,AH
HLT
CODEENDS
DATASEGMENT
OPR1DW26F8H
OPR2DB0AAH
RESQDW?
RESRDW?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

OPERATION

COMMENTS

0000

B88F4E

MOVAX,4E8F

0003

8ED8

MOVDS,AX

0005

A10000

MOVAX,[0000]

THEVALUEIN[0000]ISMOVED
TOAX

0008

F63E0200

DIVBYTEPTR[0002]

THEVALUEIN[0002]ISADDED
TOAX

000C

A20300

MOV[0003],AX

THEVALUEINALISMOVED
TO[0003]

000F

88260400

MOV[0004],DX

THEVALUEINAHISMOVED
TO[0004]

0013

F4

HLT

ENDOFPROGRAM

INITIALIZATIONOF
DATASEGMENT

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

9/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

FlowChart:
Result:
Case1:twopositivenumbers
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,
d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=0,a=1,i=1,
d=0.
Input:
OPR1=26F8H(DIVIDEND)
OPR2=56H(DIVISOR)
Output:
RESQ=74H(AL)
RESR=00H(AH)
Case2:onepositivenumber&onenegativenumber
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=0,a=1,i=1,d=0.
Input:
OPR1=D908H<2sComplementof(26F8H)
OPR2=56H
Output:
RESQ=8CH(AL)<2sComplementof(74H)
RESR=00H(AH)
Case3:onepositivenumber&onenegativenumber
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=0,a=1,i=1,d=0.
Input:
OPR1=26F8H
OPR2=AAH<2sComplementof(56H)
Output:
RESQ=8CH(AL)<2sComplementof(74H)
RESR=00H(AH)

7.ASCIIaddition
http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

10/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

Aim:
TowriteanALPtoperformtheadditionoftwoASCIIbytes.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAH,00H
MOVAL,CHAR
ADDAL,CHAR1
AAA
MOVRES,AX
HLT
CODEENDS
DATASEGMENT
CHARDB'8'
CHAR1DB'6'
RESDW?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

OPERATION

COMMENTS

0000

B88E4E

MOVAX,4E8E

0003

8ED8

MOVDS,AX

INITIALIZATIONOF
DATASEGMENT

0005

B400

MOVAH,00

00HISSTOREDINAH

0007

A00000

MOVAL,[0000]

THEVALUEIN[0000]ISMOVED
TOAL

000A

02060100

ADDAL,[0001]

THEVALUEIN[0001]ISADDED
TOAL

000E

37

AAA

ASCIIADJUSTAFTER
ADDITION

000F

A30200

MOV[0002],AX

THEVALUEINAXIS
MOVEDTO[0002]

0012

F4

HLT

ENDOFPROGRAM

FlowChart:
http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

11/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

Result:
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=1,s=0,z=0,o=0,p=1,a=1,i=1,d=0.
Input:
CHAR='8'
CHAR1='6'
Output:
RES=0104(AX)<unpackedBCDof14

8.ASCIIsubstraction
Aim:
TowriteanALPtoperformthesubtractionoftwoASCIIbytes.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAH,00H
MOVAL,CHAR
SUBAL,CHAR1
AAS
MOVRES,AX
HLT
CODEENDS
DATASEGMENT
CHARDB'9'
CHAR1DB'5'
RESDW?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

OPERATION

COMMENTS

0000

B88E4E

MOVAX,4E8F

0003

8ED8

MOVDS,AX

INITIALIZATIONOF
DATASEGMENT

0005

B400

MOVAH,00

00HISSTOREDINAH

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

12/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

ADDRESS
0007

OPCODE
A00000

OPERATION
MOVAL,[0000]

COMMENTS
THEVALUEIN[0000]ISMOVED
TOAL

000A

2A060100

SUBAL,[0001]

THEVALUEIN[0001]IS
SUBTRACTEDFROMAL

000E

3F

AAS

ASCIIADJUSTAFTER
SUBTRACTION

000F

A30200

MOV[0002],AX

THEVALUEINAXIS
MOVEDTO[0002]

0012

F4

HLT

ENDOFPROGRAM

FlowChat:
Result:
Case1:
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Input:
CHAR=9
CHAR1=5
Output:
RES=0004(AX)
Case2:
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=1,s=1,z=0,o=0,p=1,a=1,i=1,d=0.
Input:
CHAR=5
CHAR1=9
Output:
RES=FF06(AX)<2sComplementof(4)

9.ASCIImultiplication
Aim:

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

13/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

TowriteanALPtoperformthemultiplicationoftwoASCIIbytes.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAH,00
MOVAL,NUM1
MULNUM2
AAM
MOVRES,AX
HLT
CODEENDS
DATASEGMENT
NUM1DB09
NUM2DB05
RESDW?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

OPERATION

COMMENTS

0000

B88E4E

MOVAX,4E8F

0003

8ED8

MOVDS,AX

0005

B400

MOVAH,00

00HISSTOREDIN
AH

0007

A00000

MOVAL,[0000]

THEVALUEIN[0000]ISMOVED
TOAL

000A

F6260100

MULBYTEPTR[0001]

THEVALUEIN[0001]IS
MULTIPLIEDBYAL

000E

D40A

AAM

ASCIIADJUSTAFTER
MULTIPLCATION

000F

A30200

MOV[0002],AX

THEVALUEINAXIS
MOVEDTO[0002]

0012

F4

HLT

ENDOFPROGRAM

INITIALIZATIONOF
DATASEGMENT

FlowChart:
Result:
http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

14/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=1,a=0,i=1,d=0.
Input:
NUM1=09
NUM2=05
Output:
RES=0405(AX)<unpackedBCDof45

10.ASCIIdivision
Aim:
TowriteanALPtoperformthedivisionoftwoASCII
numbers.
Tools:
PCinstalledwithTASM.
Program:
ASSUMECS:CODE,DS:DATA
CODESEGMENT
MOVAX,DATA
MOVDS,AX
MOVAX,DIVIDEND
AAD
MOVCH,DIVISOR
DIVCH
MOVRESQ,AL
MOVRESR,AH
HLT
CODEENDS
DATASEGMENT
DIVIDENDDW0607H
DIVISORDB09H
RESQDB?
RESRDB?
DATAENDS
END
Listfile:
ADDRESS

OPCODE

OPERATION

0000

B88F4E

MOVAX,4E8F

0003

8ED8

MOVDS,AX

COMMENTS
INITIALIZATIONOF
DATASEGMENT

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

15/16

11/28/2016 MicroprocessorsandMicrocontrollersNotes:Programsfor16bitarithmeticoperationsfor8086(usingvariousaddressingmodes)|studentboxoffi

ADDRESS

OPCODE

OPERATION

COMMENTS

0005

A10000

MOVAH,[0000]

THEVALUEIN[0000]IS
MOVEDTOAX

0008

D50A

AAD

ASCIIADJUSTFOR
DIVIDION

000A

8A2E0200

MOVCH,[0002]

THEVALUEIN[0002]IS
MOVEDTOCH

000E

F6F5

DIVCH

AXISDIVIDED
BYCH

0010

A20300

MOV[0003],AL

THEVALUEINALIS
MOVEDTO[0003]

0013

88260400

MOV[0002],AH

THEVALYEINAHIS
MOVEDTO[0004]

0017

F4

HLT

ENDOF
PROGRAM

FlowChart:
Result:
Flags:
Beforeexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Afterexecution,c=0,s=0,z=0,o=0,p=0,a=0,i=1,d=0.
Input:
DIVIDEND=0607H<unpackedBCDof67
DIVISOR=09H
Output:
RESQ=07(AL)
RESR=04(AH)

http://studentboxoffice.in/jntuh/notes/Microprocessors%20and%20Microcontrollers/246

16/16

You might also like