dap an 5 asm
Include C:\TASM\INCLUDE\Lib1.asm
.Model small
.Stack 100h
.Data
M1 db 13,10,'Hay vao N : $'
M2 db 13,10,'Tong tu -1 den -$'
M3 db ' la : -$'
M4 db 13,10,'Gia tri bieu thuc la : -$'
DauCham db '.$'
.Code
Main :
mov ax,@data
mov ds,ax
HienString M1
call Vao_So_N
HienString M2
call Hien_So_N
HienString M3
mov cx,ax
mov bx,ax
xor ax,ax
Tong :
add ax,cx
loop Tong
call Hien_So_N
HienString M4
dec bx
xor dx,dx
div bx
call Hien_So_N
and dx,dx
jz Finish
mov si,10
mov cx,2
HienString DauCham
ThapPhan :
mov ax,dx
mul si
div bx
call Hien_So_N
and dx,dx
jz Finish
loop ThapPhan
Finish :
mov ah,4ch
int 21h
Include C:\TASM\INCLUDE\Lib2.asm
End Main
2a:
.Model small
.Stack 100h
.Data
Extrn _n : WORD, _Array : DWORD
.Code
Public @TongDuong$qv
@TongDuong$qv PROC
mov cx,_n
mov ax,SEG _Array
mov bx,OFFSET _Array
mov es,ax
xor ax,ax
XuLy :
mov dx,es:[bx]
and dx,dx
js SoAm
add ax,dx
SoAm :
add bx,2
loop XuLy
ret
@TongDuong$qv Endp
End
2c:
#include<conio.h>
#include<iostream.h>
int Array[100];
int n;
extern int TongDuong();
void main(void)
{
clrscr();
int i;
cout<<"Nhap so luong phan tu cua day so : ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Phan tu thu "<<i+1<<" : ";
cin>>Array[i];
}
cout<<"
Tong cac thanh phan duong cua day : "<<TongDuong();
getch();
}
3:
Include C:\TASM\INCLUDE\Lib1.asm
.Model small
.Stack 100h
.Data
M1 db 13,10,'May tinh co DMA khong ? $'
Yes db 'Co$'
No db 'Khong$'
M2 db 13,10,'So luong cong LPT : $'
.Code
Main :
mov ax,@data
mov ds,ax
HienString M1
int 11h
mov al,ah
shr al,1
jc TonTai
HienString No
jmp LPT
TonTai :
HienString Yes
LPT :
HienString M2
mov cl,5
shr al,cl
add al,30h
mov ah,0eh
int 10h
mov ah,1
int 21h
mov ah,4ch
int 21h
Include C:\TASM\INCLUDE\Lib2.asm
End Main
Bạn đang đọc truyện trên: AzTruyen.Top