汇编语言:底下的程序显示 cmp [si],0和test[si]不正确 为什么啊 这不是间接寻址吗
datasegmentxdb-9,4,0,0,'$'p_countdb0z_countdb0n_countdb0yequ$-xdataendssatasegmentsta...
data segment
x db -9,4,0,0,'$'
p_count db 0
z_count db 0
n_count db 0
y equ $-x
data ends
sata segment stack
db 100h dup (?)
sata ends
code segment 'code'
assume cs:code,ds:data,ss:sata
start:mov ax,data
mov ds,ax
mov ax,sata
mov ss,ax
xor ax,ax
xor dx,dx
mov cx,y
lea si,x
sub si,1
test1:add si,1
cmp [si],0
jz nz
add ah,1
jmp ok
nz:test[si],8000h
jz z
add al,1
jmp ok
z:add dl,1
jmp ok
ok:dec cx
cmp cx,0
jnz test1
mov p_count,al
mov z_count,ah
mov n_count,dl
mov ah,4ch
int 21h
code ends
end start 展开
x db -9,4,0,0,'$'
p_count db 0
z_count db 0
n_count db 0
y equ $-x
data ends
sata segment stack
db 100h dup (?)
sata ends
code segment 'code'
assume cs:code,ds:data,ss:sata
start:mov ax,data
mov ds,ax
mov ax,sata
mov ss,ax
xor ax,ax
xor dx,dx
mov cx,y
lea si,x
sub si,1
test1:add si,1
cmp [si],0
jz nz
add ah,1
jmp ok
nz:test[si],8000h
jz z
add al,1
jmp ok
z:add dl,1
jmp ok
ok:dec cx
cmp cx,0
jnz test1
mov p_count,al
mov z_count,ah
mov n_count,dl
mov ah,4ch
int 21h
code ends
end start 展开
2个回答
展开全部
已经改过了,[si]是寄存器间接寻址,但是无变量名的寄存器变量寻址属于无类型量,后面的立即数也是无类型量,所以不符合语法规则,使用ptr伪指令即可修改。。
还有x属于字节型变量,所以不要和8000h比,和80h比就够了,你不就是想验证一下零的最高位是一还是零吗?
data segment
x db -9,4,0,0,'$'
p_count db 0
z_count db 0
n_count db 0
y equ $-x
data ends
sata segment stack
dw 100h dup (?)
sata ends
code segment 'code'
assume cs:code,ds:data,ss:sata
start:mov ax,data
mov ds,ax
mov ax,sata
mov ss,ax
xor ax,ax
xor dx,dx
mov cx,y
lea si,x
sub si,1
test1:add si,1
cmp byte ptr [si],0
jz nz
add ah,1
jmp ok
nz:test byte ptr [si],80h
jz z
add al,1
jmp ok
z:add dl,1
jmp ok
ok:dec cx
cmp cx,0
jnz test1
mov p_count,al
mov z_count,ah
mov n_count,dl
mov ah,4ch
int 21h
code ends
end start
还有x属于字节型变量,所以不要和8000h比,和80h比就够了,你不就是想验证一下零的最高位是一还是零吗?
data segment
x db -9,4,0,0,'$'
p_count db 0
z_count db 0
n_count db 0
y equ $-x
data ends
sata segment stack
dw 100h dup (?)
sata ends
code segment 'code'
assume cs:code,ds:data,ss:sata
start:mov ax,data
mov ds,ax
mov ax,sata
mov ss,ax
xor ax,ax
xor dx,dx
mov cx,y
lea si,x
sub si,1
test1:add si,1
cmp byte ptr [si],0
jz nz
add ah,1
jmp ok
nz:test byte ptr [si],80h
jz z
add al,1
jmp ok
z:add dl,1
jmp ok
ok:dec cx
cmp cx,0
jnz test1
mov p_count,al
mov z_count,ah
mov n_count,dl
mov ah,4ch
int 21h
code ends
end start
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询