Tính tổng 0-255=EmU8086
Bài 1 :
.Model Small
.Stack 100H
.Data
.Code
;
Main proc
Mov CX,255 ;CX chu+'a giá tri. la(.p
Mov AX,0
Mov DX,0 ;Reset giá tri. thanh ghi AX và DX
Func1:
Inc DX
Add AX,DX
loop Func1
;Display
Mov CX,16
Mov BX,AX
Mov AH,2
Func2:
ROL BX,1
Mov DL,BL
And DL,01H
Add DL,30H
Int 21H
Loop Func2
;Mov DX,AX
;
Mov AH,0
Int 16H
Mov AH,4CH
Int 21h
;
Main Endp
End
Bài 2:
.model small
.stack 100h
.data
msg db "***** Copyright by Ngo Dong Y ***** $"
.code
main proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,msg
int 21h
mov ah,2
mov dl,0ah
int 21h
mov dl,0dh
int 21h
mov dx,1
mov bx,0
h1:
add dx,bx
add bx,5
cmp bx,100d
jle h1
mov bx,dx
mov dh,5
h2:
mov cx,4
mov dl,0
h4:
shl bx,1
rcl dl,1
loop h4
cmp dl,9
jl a1
jg a2
a1:
add dl,30h
jmp h9
a2:
add dl,37h
h9:
mov ah,2
mov dl,dl
int 21h
mov cx,0
sub dh,1
;mov cl,dh
cmp dh,01h
je thoat
jg h3
h3:
loop h2
thoat:
mov ah,4ch
int 21h
end main
Cách 2
.model small
.stack 100h
.data
msg db "***** Copyright by Ngo Dong Y ***** $"
.code
main proc
mov ax,@data
mov ds,ax
mov ah,9
lea dx,msg
int 21h
mov cx,3
o1:
mov ah,2
mov dl,0ah
int 21h
mov dl,0dh
int 21h
loop o1
mov cx,20
mov bx,1
t1:
mov al,5
mul cx
add bx,ax
loop t1
mov dh,5
h2:
mov cx,4
mov dl,0
h4:
shl bx,1
rcl dl,1
loop h4
cmp dl,9
jl a1
jg a2
a1:
add dl,30h
jmp h9
a2:
add dl,37h
h9:
mov ah,2
mov dl,dl
int 21h
mov cx,0
sub dh,1
mov cl,dh
cmp cl,00h
je thoat
jg h3
h3:
loop h2
thoat:
mov ah,4ch
int 21h
end main
Bạn đang đọc truyện trên: Truyen247.Pro