Uploaded by bellejose567

exp 1 - basic arithmetic

advertisement
Experiment 1: Basic Arithmetic and Logical Operations
:
Arithmetie operations such
assembly language programs to pertorm
as AND. OR & XOR.
such
Multiplication & Division and Logical operations
To Write 8O86
Subtraction.
as Additio
based
Apparatus/Software
required: PC with
SO86 Cross Assembler && intertace with
16-bit Addition
Algorithm:
1. Initialize any one register for carry with O000H
2. Move one operand to AX
3. Add another operand with AX
4 l f carry flag is set, increment the carry register content
5. Store the accumulator content and carry content
6. Halt
Flow Chart:
Start
Initialise C 00
Load Data l to Acc
Load Data ll to B tey
AddA
B
Is
Yes
Cauy?
No
C-C1
Store the Results
Stop
S086uP
T rainer kit
8086 ALP for 16-bit Addition:
Label
Mnemonics
Comments
output 2500ad
loop:
org 2000h
Declare the origin address
mov dx,0000h
Initialize carry register DX with 0000h
mov ax,5678h
Get first operand in AX
mov bx.1234h
Get second operand in BX
add ax.bx
Perform addition
jne loop
Check for carry: if no carry jump to loop
ine dx
Else increment cary register content
push dx
Push into stack the upper 16-bit result
mov bx.0000h
D.splay in data field the lower 16-bit result
call far Ofoo:0b12h
Pop into AX the upper 16-bit result
pop ax
mov bx.0100h
call far OffDO:0b1 2h
Display in address field the upper 16-bit resul
hlt
Halt the process
Output:
Input
Datal
S618
Output
Data2
Address field
234
OoDo
16-bit Subtraction
Algorithm:
2.
3.
4
Initialize any one register for rarry witr00H
Move one operand to AX
Subtract another operana from AX
If carry flag is set. increment the caTy
location/register content
5.
Store the accumulator content and carry content
6.
Halt
Data Field
bRAL
Flow Chart:
Start
Initialise C- 00
Load Data-l to Acc
Sub Data l
from Ac
Yes
Cany?
C-C1
Stoto he Results
Stop
8086 ALP for 16-bit Subtraction:
Label
Mnemonics
Comments
output 2500ad
org 2000h
Declare the origin address
mov dx,0000h
Initialize carry register DX with 0000h
mov ax,5678h
Get first operand in AX
mov bx,1234h
Get second operand in BX
sub ax.bx
Perform subtraction
jnc loop
Check for carry; if no carry jump to loop
inc
loop:
dx
Else increment cary register content
push dx
Push into stack the upper 16-bit result
mov bx.0000h
Display in data licld the lower 16-bit result
call far On00:0b12h
pop ax
Pop into AX the upper 16-bit resuin
mov bx,.01001
call far Otivo.ob12h
Display in address field the upper 16-bit result
hlt
Halt the process
Output:
Input
Output
Datal
Data2
SL7
23
Address field
Data Field
booD
buLuy
S618
16-bit Multiplication
Algorithm:
Clear the DX (or) Move into stack the content of DX if any
2
Get the operands (one should be in AX)
3
Perform multüplication
4
Display the least word (AX) in data field and most word (DX) in address field
5. Halt
Flow Chart:
Start
Initialise C 00
Load Data-I to Acc
Load Datall to B reg
A
B
Store the Results
Stop
8O86 ALP for 16-bit Multiplication:
Mnemonies
Comments
output 2500ad
org 2000h
Declare the origin address
mov dx,00001
Clear the upper 16-bit result register DX
mov ax,5678h
Get first operand in AX
mov bx,1234h
Get second operand in BX
mul ax.bx
Perform multiplication
push dx
Push into stack the upper 16-bit result
mov bx.0000h
Display in data field the lower I6-bit result
call far Of100:0b12h
pop ax
Pop into AX the upper 16-bit result
mov bx.0100h
call far Ofn0O:0b12h
Display in address field the upper 16-bit result
hlt
Halt the process
Output:
lnput
Datal
Outpiit
Data2
Address field
6T8
2
Data Field
6626
OD66
bo6
PET2
16-bit Div ision
Algorithm:
Clear the DX (or) \love
into stack the content ofl DX
2. CGet tlie opernds (one should be un AN)
3. Pertorm div iston
4 Display the least word (AN)
5. Halt
in
if any
data lield and most word (DX)
Flow Chart:
Stait
nitialise C =00
Load Data I
to Ace
Load Data-ll to B reg
B
Store thhe Results
Stop
in
address tield
8O86ALP for 16-bit Division:
Mnemonics
Comments
output 2500ad
org 2000h
D:clare the origin address
mov dx,0000h
Clear the upper 16-bit rerult register DX
mov ax,5678h
Get first operand in AX
mov bx,1234h
Get second operand in BX
div ax.bx
Perform division
push dx
Push into stack the upper 16-bit result
mov bx.0000h
Display in data field the lower 16-bit result
call far Of00:0b12h
pop ax
Pop into AX the upper i6-bit result
mov bx.0100h
call far Oft00:0b12h
Display in address field the upper I6-bit result
hlt
Halt the process
Output:
Input
Output
Datal
Data2
Address field
123u_
Olo26
abob
Algorithm: (for OR operation)
one
operand
to
AX and otlher
2.
Perform OR operation
3.
Store and display the result
4
lalt
operand
to
any
other egister
8O86ALP for OR operation:
Label Mnemonics
Comments
output 2500ad
org 2000h
Declare the origin eddress
mov ax.5678h
Gut first operand in AX
mov bx,1234h
Get second operand in BX
or ax.bx
Perform
mov bx,0000h
Display the result in data field
logical OR operation
call far Off00:0112h
hlt
obo
FET2
Logical Operations:
Move
DataField
Halt the process
Output:
Output
Input
Datu Fietd
Data2
Datal
S7
6S
132
Algorithm: (for AND operation)
one
operand
to
other register
to any
AX and other operand
Ove
Perform AND operation
Store and
display
he result
Halt
8086 ALP for AND operation:
Label
Comments
Mnemonies
output 2500ad
address
Declare the origin
org 2000h
Get lirst
mov ax.5678h
operund
in
Get second operand
mov bx.1234h
AX
in
BX
Pertorm logical AND operation
and ax.bx
Display the result
mov bx.0000h
in
data field
call far Ofit00:0b12h
Hal' the process
hlt
Output:
Output
Input
Datal
Data Field
Data2
234
L3
123o
Lo
Algorithm: (tor XOR operation)
Move
2
one operand to AX and uher operand to any other register
Perlom XOR operation
Store and display 1he result
4
Halt
8086 ALP for NOR operation:
Label
Mnemonics
Comments
output 2500ad
org 2000lh
mev ax.5678h
mov bx.1234h
AOr ax.b
1oy bx.0000h
call lar O1f00:0612h
hlt
Declare the origin address
Get first operand in AX
Get second operand in BX
Perform logical XOR ope:auon
Display the result in data tield
Ilalt the process
Output:
Output
Input
Datal
Data2
Data Field
1234
L324
136S
Result:
Thus. 8086 based ALPs for Arithmetic and Logical operations were developed. executed and the
corresponding outputs were verified aad recorded.
Download