Chinaunix首页 | 论坛 | 博客
  • 博客访问: 478064
  • 博文数量: 174
  • 博客积分: 2502
  • 博客等级: 少校
  • 技术积分: 1923
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-28 09:47
文章分类

全部博文(174)

文章存档

2011年(8)

2010年(16)

2009年(68)

2008年(82)

我的朋友

分类: C/C++

2009-02-23 22:19:50

// 说明 :
// 此程序存为两个文件(*.c & *.asm)(eg main.c & rvs.asm)
// rvs.asm用 masm.exe 编译生产rvs.OBJ文件;
// 将rvs.OBJ复制到main.c所在的目录,并创建一个工程文件 *.prj (eg test.prj)
// 工程文件*.prj里面只有两行分别为 main.c和 rvs.OBJ
// 打开tc.exe, 在Project -> Project name里输入 test.prj;
// 将Options -> Linker -> Case-sensitive link (大小写敏感)选项关闭Off;
// 原因是TC对大小写敏感,而MASM汇编生产的OBJ文件均为大些字母;
// 然后编译 F10 --Compile --Build all ,生成 test.ext;
// tc.exe存储模式修改在 Options -> Model -> (small, medium, compact ...)
// 两者存储模式要一致;
// Turbo C2.0 && MASM 5.0;
//

/* 以下是C语言主程序 */
#include
extern unsigned char reverse(unsigned char byte);
main()
{
 unsigned char byte;
 printf("\nEnter an unsigned char: ");
 scanf("%d", &byte);
 printf("The reversed byte is: %d\n", reverse(byte));
 return 0;
}
;// 以下是8086汇编语言模块
.model small;    ;// 存储模式 small
.code;
public _reverse;
_reverse proc;
;// C callable function to return a byte;
;// C prototype: extern unsigned char reverse(unsigned char byte);
 push bp;
 mov bp, sp;
 mov bh, 10;
 mov al, [bp + 4];
 xor ah, ah;
 div bh;
 mov bl, al;
 mov al, ah;
 mul bh;
 add al, bl;
 pop bp;
 ret;
_reverse endp;
end;
具体参考
阅读(793) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~