帮忙看下不到30行的代码!

sagegz 2008-12-25 05:33:13

data segment
num dw 0
ary dw 100 dup(0)
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
lea si,ary
lop: mov ah,1 ;10行
int 21h
lop1: cmp al,13 ;回车?
jz exit
cmp al,32 ;空格?
jz lop
and al,0fh
cbw
mov bx,ax
mov al,10
mul byte ptr num ;20行
add ax,bx
mov num,ax
jmp lop1
mov [si],num
add si,2
jmp lop
exit: mov ah,4ch
int 21h
code ends
end start
;24和27行出现问题,我用的masm5.0的编译器
;哪位高人帮忙该该,这个程序就是用来将用户输入的数据存放在指令内存中.
;谢谢了!
...全文
172 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
sagegz 2008-12-26
  • 打赏
  • 举报
回复
继续UP!
还有人回答吗?
Q-Luo 2008-12-26
  • 打赏
  • 举报
回复
STUDYING
xiaopoy 2008-12-26
  • 打赏
  • 举报
回复
火了,昨天回的怎没有了.没兴趣调整了,
引用
The offset returned is relative to either the current group or segment. If there is both a current group and a current segment, the offset will have a group-relative default offset. This default can be changed with the M510 and OFFSET: options.
The OFFSET operator can accept an expression specifying a segment. In this case, the OFFSET operator returns the offset of the last byte of the given segment, relative to that segment's group. This value reflects the size of the given segment when the OFFSET operator is assembled.

Sets the location counter to a specific address, given by <expression>. The assembler implements this directive by adjusting the location counter.
ORG $+expression causes the assembler add <expression> bytes to the location counter. The <expression> must evaluate to a constant without forward references.
Inside a STRUCT block, the <expression> parameter is relative to the beginning of the structure. This can be used to create structure elements that refer to bytes lower in memory than the beginning of the structure.

Returns an operand of <qualifiedtype> with offset and segment values equal to the current location-counter value. THIS can be used with EQU or = to create labels and variables. THIS NEAR is equivalent to $.
These two lines are equivalent:

tag1 EQU THIS BYTE
tag1 LABEL BYTE
The <qualifiedtype> can be any qualified type.
RockurSoul 2008-12-26
  • 打赏
  • 举报
回复
lz真贪心,你还是另外开个帖子
sagegz 2008-12-25
  • 打赏
  • 举报
回复
继续问问题,正确回答这有分!
offset\this\org这三个指令的英文全称是什么?
sagegz 2008-12-25
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 BAYNPU 的回复:]
稍以修改一下:
......
mov [si+num],0
add si,2
jmp lop
exit:
mov ah,4ch
int 21h
code ends
end start
[/Quote]
您这样该没用,我要的是把NUM的值传给[SI],所以说您的改法不符合我的要求...
cnzdgs 2008-12-25
  • 打赏
  • 举报
回复
搞清楚汇编指令和语法,根据错误信息仔细检查代码就可以找到问题,熟练之后大部分编译错误一眼就可以看出来。
getchar用汇编有两种做法:
1、调用DOS中断
mov ah, 1
int 21h
返回AL是输入字符的ASCII码。
2、调用BIOD中断
xor ah, ah
int 16H
返回AL是输入字符的ASCII码,AH是输入键的扫描码。
sagegz 2008-12-25
  • 打赏
  • 举报
回复
对了,还有就是汇编中哪个中断指令相当于C++中的getchar()呢?
因为我直接运行.exe文件后会直接一闪而过?
祝汇编版块的人气越来越高!
BAYNPU 2008-12-25
  • 打赏
  • 举报
回复
稍以修改一下:
......
mov [si+num],0
add si,2
jmp lop
exit:
mov ah,4ch
int 21h
code ends
end start
sagegz 2008-12-25
  • 打赏
  • 举报
回复
恩,对了!先谢谢你了哈!你是怎么看出有逻辑错误的呢?
汇编刚学,不太懂!有没有什么好的像VS2005那样强大的工具呢?
killbug2004 2008-12-25
  • 打赏
  • 举报
回复
mov 的两个操作数不能都为内存操作数
    push num
pop word ptr [si]
add si,2
jmp lop
exit:
mov ah,04ch
int 21h


还有逻辑错误,自己试着改一下

21,500

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧