一个内联汇编的小问题

asm2046 2007-12-25 09:40:08
#include <stdio.h>
void main()
{
int a=98;
__asm
{
mov al,a
and al,11011111B
mov a,al
}
printf("%c\n",a);
}

就是转大写...但是调试出错...
大家看看是什么问题
...全文
307 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxlittle 2007-12-29
  • 打赏
  • 举报
回复
#include <stdio.h>
void main()
{
int a=98;
__asm
{
mov eax,a
and al,11011111B
mov a,eax
}
printf("%c\n",a);
}
asm2046 2007-12-25
  • 打赏
  • 举报
回复
谢谢楼上2位 理解了 怎么给你们+分啊 ?找不到操作的地方么...
baihacker 2007-12-25
  • 打赏
  • 举报
回复

#include <stdio.h>
void main()
{
int a=98;
__asm
{
mov eax,a
and eax,11011111B
mov a,eax
}
printf("%c\n",a);
}

rularys 2007-12-25
  • 打赏
  • 举报
回复
是编译出错。
类型冲突:

#include <stdio.h>
void main()
{
int a=98; //int类型一般是32位,你把a定义成8位的 char型
__asm
{
mov al,a //因为这里你引用的是8位长的 al寄存器
and al,11011111B
mov a,al
}
printf("%c\n",a); // 这里也需要是char类型的参数
}


asm2046 2007-12-25
  • 打赏
  • 举报
回复
--------------------Configuration: cc - Win32 Release--------------------
Compiling...
cc.cpp
D:\soft\VC\MyProjects\cc\cc.cpp(8) : error C2443: operand size conflict
D:\soft\VC\MyProjects\cc\cc.cpp(10) : error C2443: operand size conflict
Error executing cl.exe.

cc.exe - 2 error(s), 0 warning(s)
asm2046 2007-12-25
  • 打赏
  • 举报
回复
--------------------Configuration: cc - Win32 Release--------------------
Compiling...
cc.cpp
D:\soft\VC\MyProjects\cc\cc.cpp(8) : error C2443: operand size conflict
D:\soft\VC\MyProjects\cc\cc.cpp(10) : error C2443: operand size conflict
Error executing cl.exe.

cc.exe - 2 error(s), 0 warning(s)
rularys 2007-12-25
  • 打赏
  • 举报
回复
调试时出啥问题?

70,023

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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