练习实训:AX中16位数分为4组(1234分为1,2,3,4),每组4位分别放在AL,BL,CL,DL
答:
data segment
data ends
cseg segment
assume cs:cseg,ds:data
start:
mov ax,1234h
mov cl,4
mov dx,ax
and dx,0fh
mov bx,ax
shr bx,cl
and bx,0fh
mov ch,bl
mov bx,ax
shr bx,cl
shr bx,cl
and bx,0fh
shr ax,cl
shr ax,cl
shr ax,cl
and ax,0fh
mov cl,ch
and cx,0fh
mov bh,bl
mov dh,dl
mov dl,al
add dl,40h
mov ah,2
int 21h
mov dl,bh
add dl,40h
mov ah,2
int 21h
mov dl,cl
add dl,40h
int 21h
mov dl,dh
add dl,40h
int 21h
mov ah,1
int 21h
exit:
mov ah,4ch
int 21h
cseg ends
end start
输出:ABCD (对应:al=01h,bl=02h,cl=03h,dl=04h)