我要用汇编语言将十进制转换为2进制错在什么地方了?

zhangyikai321 2014-06-17 11:56:08
program HelloWorld;

#include( "stdlib.hhf" )
static
a:int32;
procedure change;@noframe;
begin change;
push(ebp);
mov(esp,ebp);
sub(4,esp);
push(eax);
push(ecx);
push(edx);
push(esi);

mov([ebp+8],eax);
mov(0,edx);
mov(2,(type int32[ebp-4]));

L2: div((type int32[ebp-4]));
push(edx);
inc(ecx);
cmp(eax,0);
ja L2;

L3: pop(edx);
stdout.put(edx);
dec(ecx);
cmp(edx,0);
ja L3;

pop(eax);
pop(ecx);
pop(edx);
pop(esi);
mov(ebp,esp);
pop(ebp);
ret(4);

end change;
begin HelloWorld;

stdout.put( "请输入一个整数:", nl, nl );
stdin.get(a);
mov(a,ebx);
cmp(ebx,0);
jb L1;
mov(1,esi);
push(ebx);
L1: mov(-1,esi);
fabs();
call change;

stdout.put( "Press enter to continue: " );
stdin.readLn();

end HelloWorld;

//*****************************************************************************
program HelloWorld;

#include( "stdlib.hhf" )
static
a:int32;
procedure sort;@noframe;
begin sort;
push(ebp);
mov(esp,ebp);
push(eax);
push(ebx);
push(ecx);
push(edx);

mov(a,eax);
mov(2,(type uns32[ebp+8]));

L1: mov(0,edx);
div(ebx);
push(edx);
cmp(eax,0);
ja L1;
stdout.put(eax);

pop(edx);
pop(ecx);
pop(ebx);
pop(eax);
mov(ebp,esp);
pop(ebp);
ret(8);
end sort;





begin HelloWorld;

stdout.put( "Hello, World of Assembly Language:", nl, nl );
stdin.get(a);
mov(a,eax);
call sort;
stdout.put( "Press enter to continue: " );
stdin.readLn();

end HelloWorld;

/****************************************************************************/


...全文
118 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,499

社区成员

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

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