1. 在数据段、附加段和堆栈段分别定义字节型变量X、Y、Z,计算Z=X + Y-10
data segment
x db 3
y db 8
z db ?
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
xor al,al
mov al,x
add al,y
sub al,10
mov z,al
mov ah,4cH
int 21H
code ends
end start
2.编写程序完成下列算式
data segment
x db 1
y db ?
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov al,x
and al,al
jz zero
jns zheng
mov bl,-10
jmp save
zero: mov bl,0
jmp save
zheng: mov bl,10
save: mov y,bl
mov ah,4cH
int 21H
code ends
end start
3. 统计BX寄存器中二进制1的个数。
data segment
x db ?
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov bx,00ffh
mov cx,0
mov ch,16
jxt: test bx,0001h
jz zero
inc cl
zero: dec ch
jz over
shr bx,1
jmp jxt
over: mov x,cl
mov ah,4cH
int 21H
code ends
end start