8087ALP to obtain: i) Mean ii) Variance iii) Standard Deviation
7. Write 8087ALP to obtain: i) Mean ii) Variance iii) Standard Deviation For a given set of data elements defined in data segment. Also display result.
.model small
disp macro msg
lea dx,msg
mov ah,09h
int 21h
endm
divi macro number
mov ax,bx
mov dx,0000h
mov bx,number
div bx
mov bx,dx
mov dx,ax
endm
.8087
.data
msg2 db 10,13,"1.mean::$"
msg3 db,10,13,"2.Standard deviation::$"
msg4 db,10,13,"3.variance::$"
msg7 db ".$"
msg8 db 10,13," $"
a dd 11.30
b dd 22.30
c dd 23.40
d dd 24.60
count dd 4.00
l dd(?)
j dd(?)
m dw(?)
n dw(?)
p dd(?)
q dw(?)
r dw(?)
s dw(?)
t dw(?)
x dd 10.00
.code
mov ax,@data
mov ds,ax
disp msg2
finit
fld a
fld b
faddp st(1),st
fld c
faddp st(1),st
fld d
faddp st(1),st
fst j
fld count
fdivp st(1),st
fst l
frndint
fist m
fld l
fsub st,st(1)
fld x
fmulp st(1),st
frndint
fistp n
fld a
fld a
fmulp st(1),st
fld b
fld b
fmulp st(1),st
faddp st(1),st
fld c
fld c
fmulp st(1),st
faddp st(1),st
fld d
fld d
fmulp st(1),st
faddp st(1),st
fld count
fdivp st(1),st
fld l
fld l
fmulp st(1),st
fsub st(1),st
fld st(1)
fst p
frndint
fist q
fld p
fsub st,st(1)
fld x
fmulp st(1),st
frndint
fistp r
fld p
fsqrt
fst p
frndint
fist s
fld p
fsub st,st(1)
fld x
fmul st(1),st
frndint
fistp t
mov bx,m
divi 03E8h
call bcdprint
divi 0064h
call bcdprint
divi 00Ah
call bcdprint
divi 0001h
call bcdprint
disp msg7
mov bx,n
mov dl,bl
and dl,0fh
cmp al,09h
jbe l3
add dl,00h
l3: add dl,30h
mov ah,02h
int 21h
jmp r1
r1: disp msg3
jmp r2
r2: mov bx,s
divi 03e8h
call bcdprint
divi 0064h
call bcdprint
divi 00ah
call bcdprint
divi 0001h
call bcdprint
disp msg7
mov bx,t
mov dl,bl
and dl,0fh
cmp al,09h
jbe l4
add dl,00h
l4: add dl,30h
mov ah,02h
int 21h
jmp r3
r3: disp msg4
jmp r4
r4: mov bx,q
divi 03e8h
call bcdprint
divi 0064h
call bcdprint
divi 00ah
call bcdprint
divi 0001h
call bcdprint
disp msg7
mov bx,r
mov dl,bl
and dl,0fh
cmp al,09h
jbe l5
add dl,00h
l5: add dl,30h
mov ah,02h
int 21h
jmp rend
bcdprint proc near
and dl,0fh
cmp dl,09h
jbe l1
add dl,07h
l1: add dl,30h
mov ah,02h
int 21h
ret
bcdprint endp
rend: mov ah,4ch
int 21h
end
;OUTPUT
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\student>CD ..
C:\Documents and Settings>CD ..
C:\>CD TASM
C:\tasm>TASM A_8087
Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland International
Assembling file: A_8087.ASM
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 472k
C:\tasm>TLINK A_8087
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\tasm> A_8087
1.mean::0020.4
2.Standard deviation::0005.:
3.variance::0028.3
C:\tasm>
0 comments:
Post a Comment