将字符串STRN中每一个字符均加上偶校验位,并统计有多少个字符因含有奇数个"1"而加上了校验位.

来源:百度知道 编辑:UC知道 时间:2024/05/10 20:37:43

stack segment stack
db 200 dup(0)
stack ends
data segment
strn db 'abc''$'
n db ?
data ends
code segment
assume cs:code,ds:data,ss:stack
start:
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov bx,offset strn
mov al,0
mov n,al
ll:
mov al,byte ptr [bx]
cmp al,'$'
je last
inc bx
add al,0
jp next
jmp ll
next:
inc n
jmp ll
last:
mov al,n
push ax
mov cl,4
shr al, cl
add al, 30h
cmp al, 39h
jbe con2
add al, 7
con2:
mov dl,al
mov ah,2
int 21h
pop ax
push ax
and al,0fh
add al,30h
cmp al,39h
jbe con3
add al,7
jmp con3
con3:
mov dl,al
mov ah,2
int 21h
mov ah,4ch
int 21h
pop ax
code ends
end start