32位汇编语言

wutan888 2008-11-09 11:45:52
学汇编不久,遇到一个函数,无论怎么做结果也队不住。result=x-2y+4z。请高手指点,望有完整程序
...全文
129 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnzdgs 2008-11-10
  • 打赏
  • 举报
回复
ReadSDecDword宏是怎么写的?调试看下这些宏执行完后,得到的是不是你想要的结果。
wutan888 2008-11-09
  • 打赏
  • 举报
回复
你好,你的程序是在哪个运行器上执行的??我们用的是masm32.我试了但没有成功
wutan888 2008-11-09
  • 打赏
  • 举报
回复
我学习的32位汇编语言程序设计,程度还没有那么深,函数result=x-2y+4z它基本格式不是test。我写了个程序,但结果不理想,计算错误,请指点。它基本格式不是test。是:
.386
.model flat ,stdcall
include \masm32\include\io32.inc
.stack
.data
x byte "Input number x: ",0
y byte "Input number y: ",0
z byte "Input number z: ",0
result byte "the result is: "
.code
start:
WriteString x
ReadSDecDword eax
WriteString y
ReadSDecDword ebx
WriteString z
ReadSDecDword ecx
imul ebx,2


imul ecx,4
neg ebx
add eax,ebx


add eax,ecx

WriteString result
WriteSDecDword eax
ret
end start
但是程序运行结果不理想。请指出错误
xiaopoy 2008-11-09
  • 打赏
  • 举报
回复
LZ碰到的问题是?
笼统的一个题目,2楼就是答案了
cnzdgs 2008-11-09
  • 打赏
  • 举报
回复
把上面的Test改成其它名称,因为Test是指令关键字,不能作为函数名使用。
cnzdgs 2008-11-09
  • 打赏
  • 举报
回复
Test proc x:dword, y:dword, z:dword
mov eax, x
mov edx, y
shl edx, 1
sub eax, edx
mov edx, z
shl edx, 2
add eax, edx
ret
Test endp
killbug2004 2008-11-09
  • 打赏
  • 举报
回复
试试这样行不行
.386 
.model flat ,stdcall
include \masm32\include\io32.inc
.stack
.data
x byte "Input number x: ",0
y byte "Input number y: ",0
z byte "Input number z: ",0
result byte "the result is: "
.code
start:
WriteString x
ReadSDecDword eax
push eax
WriteString y
ReadSDecDword ebx
push ebx
WriteString z
ReadSDecDword ecx
pop ebx
pop eax
imul ebx,2


imul ecx,4
neg ebx
add eax,ebx


add eax,ecx

push eax
WriteString result
pop eax
WriteSDecDword eax
ret
end start


我不知道你代码中的那几个接受输入的宏是怎样写的,但是有一点它们可能会破坏寄存器,所以我利用堆栈保存,
不过还是利用二楼的代码经行运算,尤其是乘法

21,458

社区成员

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

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