求高手帮忙看看思路和语句还有什么不对的么
题目:求0-9任意数的平方并输出代码段:
data segment
x dw ?
msg db‘this is an error!$'
data ends
code segment
assume cs: code,ds:data
start:
mov ax,data
mov ax,x
mov ah,1
int 21h
mov ds,ax
cmp x,0
jl exit0
cmp x,9
jg exit0
mov ax,x
imul ax,ax
mov ah,9
int 21h
exit0:
mov ah,9
mov dx,offset ,msg
mov ah,4h
int 21h
code ends
end start
{:7_165:}看不懂 data segment
x dw 0,0,'$'
msg db 'this is an error!$'
data ends
code segment
assume cs: code,ds:data
start:
mov ax,data
mov ds,ax
mov ah,1
int 21h
mov bx,0
cmp al,30h
jb exit0
cmp al,39h
ja exit0
mov ah,0
and al,00001111b
mul al
call htod
mov ah,9
int 21h
mov ah,01
int 21h
exit0:
lea dx, msg
mov ah,9
int 21h
mov ax,4c00h
int 21h
htod:
push bx
push dx
push si
mov si,0
mov bl,10
star: div bl
cmp ah,0
je h_ok
add ah,30h
mov dh,0
mov dl,ah
push dx
inc si
xor ah,ah
jmp star
h_ok: mov cx,si
mov bx,0
h_s: pop word ptr ds:
inc bx
loop h_s
pop si
pop dx
pop bx
ret
code ends
end start
DEBUG下查看正常。。。
但直接运行有乱码。。。
超出我能力范围了。。。
本帖最后由 s0512 于 2012-11-27 15:29 编辑
data segment
x dw 0,0,'
msg db 'this is an error!
data ends
code segment
assume cs: code,ds:data
start:
mov ax,data
mov ds,ax
mov ah,1
int 21h
mov bx,0
cmp al,30h
jb exit0
cmp al,39h
ja exit0
mov ah,0
and al,00001111b
mul al
call htod
lea dx,x
mov ah,9
int 21h
mov ah,01
int 21h
exit0:
lea dx, msg
mov ah,9
int 21h
mov ax,0100h
int 21h
htod:
push bx
push dx
push si
mov si,0
mov bl,10
star: div bl
cmp ah,0
je h_ok
add ah,30h
mov dh,0
mov dl,ah
push dx
inc si
xor ah,ah
jmp star
h_ok: mov cx,si
mov bx,0
h_s: pop word ptr ds:
inc bx
loop h_s
pop si
pop dx
pop bx
ret
code ends
end start
楼主试下,有问题没{:5_109:} 木有长进,一点功能写N长!{:5_102:} 帮顶
页:
[1]