32位汇编语言

wutan888 2008-11-09 11:45:34
学汇编不久,遇到一个函数,无论怎么做结果也队不住。result=x-2y+4z。请高手指点,望有完整程序
...全文
220 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wutan888 2008-12-08
  • 打赏
  • 举报
回复
多谢指点
liangbch 2008-11-11
  • 打赏
  • 举报
回复
若x= eax
y= ebx
z= ecx

则 x-2y+4z
可以这样写,根本用不到乘法指令的

方法1:
shl ebx,1
shl ecx,2
add eax,ebx
add eax,ecx

方法2:
neg ebx
lea eax,[eax+ebx*2]
lea eax,[eax+ecx*4]

另外,你对问题的描述不清,什么是结果不太理想,程序对就是对,不对就是不对。不想找对对象,或者找工作,有非常好,非常差,不太理想等多种结果。
还有你的描述 它基本格式不是test 是什么意思?
mylajilaji 2008-11-11
  • 打赏
  • 举报
回复
看不懂
wutan888 2008-11-10
  • 打赏
  • 举报
回复
我学习的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
但是程序运行结果不理想。请指出错误
MIPL_walikb 2008-11-09
  • 打赏
  • 举报
回复
恩,实现的方法有很多,得看你是怎么做的,才能给你纠错
xtdumpling 2008-11-09
  • 打赏
  • 举报
回复
想看看你是怎么做的?

21,500

社区成员

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

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