de 4asm
Include C:\TASM\INCLUDE\Lib1.asm
.Model small
.Stack 100h
.Data
M1 db 13,10,'Hay vao a : $'
M2 db 13,10,'Hay vao n : $'
XuongDong db 13,10,'$'
M3 db ' luy thua $'
M4 db ' la : $'
M5 db 13,10,'Giai thua cua bieu thuc la : $'
DauCham db '.$'
DauTru db '-$'
.Code
Main :
mov ax,@data
mov ds,ax
;clrscr
HienString M1
call Vao_So_N
mov bx,ax ; bx = a
HienString M2
call Vao_So_N
mov cx,ax ; cx = n
mov dx,cx
HienString XuongDong ; start dong 3
mov ax,bx
call Hien_So_N
HienString M3
mov ax,cx
call Hien_So_N
HienString M4 ; end dong 3
mov ax,1
cmp dx,0
jz Ok
GiaiThua :
mul bx
loop GiaiThua
Ok :
call Hien_So_N
HienString M5
inc dx
mov bx,dx
xor dx,dx
and ax,ax
jns Chia
HienString DauTru
neg ax
Chia :
div bx
call Hien_So_N
and dx,dx
jz Finish
HienString DauCham
mov cx,3
mov si,10
ThapPhan :
mov ax,dx
mul si
div bx
call Hien_So_N
and dx,dx
jz Finish
loop ThapPhan
Finish :
mov ah,1
int 21h
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 @TongAm$qv
@TongAm$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
jns SoDuong
add ax,dx
SoDuong :
add bx,2
loop XuLy
ret
@TongAm$qv Endp
End
2c:
#include<conio.h>
#include<iostream.h>
int Array[100];
int n;
extern int TongAm();
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 am cua day : "<<TongAm();
getch();
}
3:
Include C:\TASM\INCLUDE\Lib1.asm
.Model small
.Stack 100h
.Data
M1 db 13,10,'May tinh co FPU khong ? $'
Yes db 'Co$'
No db 'Khong$'
M2 db 13,10,'Loai card dieu khien man hinh la : $'
DonSac db 'Mono$'
DaSac db 'Color$'
.Code
Main :
mov ax,@data
mov ds,ax
HienString M1
int 11h
shr al,1
jnz TonTai
HienString No
jmp Card
TonTai :
HienString Yes
Card :
HienString M2
mov cl,3
shr al,cl
cmp al,00000011b
jz Mono
HienString DaSac
jmp Finish
Mono :
HienString DonSac
Finish:
mov ah,4ch
int 21h
Include C:\TASM\INCLUDE\Lib2.asm
End Main
Bạn đang đọc truyện trên: AzTruyen.Top