中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-06-17 02:28
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » 8088 汇编语言编写的程序 查看 1,305 回复 7
楼 主 8088 汇编语言编写的程序 发表于 2008-01-14 10:28 ·  中国 广东 深圳 联通
社区乞丐
积分 -16
发帖 5
注册 2008-01-14 13:00
UID 108543
性别 男
状态 离线
我这有一个用汇编语言写的程序,用批处理将各.ASM文件链接处理后生成的.exe文件,却不知道怎样将其生成.bin文件,以用于烧录到程序片中。用exe2bin.exe时提示内存不够,生成的.exe文件大小为74KB左右。
急切求购相应软件!谢谢!
2 发表于 2008-01-16 17:05 ·  中国 重庆 电信
初级用户
积分 43
发帖 20
注册 2007-12-25 01:31
UID 106705
性别 男
状态 离线
要生成BIN是需要一定的格式的,不是任意一个EXE文件就能转换.
3 发表于 2008-01-16 17:06 ·  中国 重庆 电信
初级用户
积分 43
发帖 20
注册 2007-12-25 01:31
UID 106705
性别 男
状态 离线
如果仅是要烧到光盘上,就EXE也行啊,使用NERO就OK了.
4 关于格式 发表于 2008-01-17 14:54 ·  中国 广东 深圳 联通
社区乞丐
积分 -16
发帖 5
注册 2008-01-14 13:00
UID 108543
性别 男
状态 离线
你好bobo98:
请问你说的格式是怎样的,我要将最终的二进制文件烧录到程序片ROM中,供仪器使用。不是要烧录到光盘。我知道转换格式前的EXE文件大小不能超过74KB ,而且,其中不能有堆栈段。但源程序应该是没问题的,所以,想弄明白用什么软件可以将源程序转换成64KB大小的BIN文件。谢谢指教!
5 发表于 2008-01-17 19:11 ·  中国 重庆 电信
初级用户
积分 43
发帖 20
注册 2007-12-25 01:31
UID 106705
性别 男
状态 离线
如果你的程序确定没有问题,刚才看了你另开的一个贴子,提到程序由多个文件构成,
如果这些文件的结构同要求的格式没有出入的话,编译连接应该挺容易的,没有什么
大的问题.对了,你要生成了BIN文件,就是不能重载的文件.启动地址是,硬件上电时
行的那个位置.
6 发表于 2008-01-17 22:19 ·  中国 江苏 无锡 电信
初级用户
积分 52
发帖 21
注册 2008-01-01 09:30
UID 107370
性别 男
状态 离线
这是微软网站上的一段,说明了MASM如何生成.COM文件而不是.EXE文件:
MASM version 6.0 is the first version of the assembler to support the tiny model. Use the following steps the produce a .com file in MASM 6.0. 1. Use .model tiny. Declare logical segments using the simplified segment directives or full segment declarations.

-or-

Do not use the .model directive and assemble with /AT. Use full segment declarations.
2. Make sure that the first statement in the the code segment is ORG 100h.
3. Build the .com file.

Compiling and linking in one step: If .model tiny was used, no options are needed. The linker will automatically receive the /TINY switch, the file extension on the file produced will be .com, and the executable is indeed a .com file.

-or-

Performing a separate link: Specify the /TINY option on the link command line. The linker will issue the following harmless warning
L4045: name of output file is 'filename'
where 'filename' will have a .com extension.

这是有人解决类似问题的方法:
1. Generate the needed EXE (for example, BIOS.EXE)
2. load it into debug: DEBUG BIOS.EXE
3. first of all, rename the file: N BIOS.BIN
4. set the length of the file to save into the BX:CX register pair:
r bx
0 (<--- HIGH word; I assume it is not bigger than 64 KB, is it?)
r cx
xxxx (<--- LOW word)

5. Now, save the file to disc:
W CS:0000 ---->要用r先看一下程序入口确实是cs:0才行

如果你的代码确实大于64K,第一种方法显示是不行了。
第二种方法可以写出大于64k的代码:
(1)必须确保程序入口是cs:0
(2)第四步不要修改bx和cx。如果纯粹为了得到小于64k的代码而将bx置零,是没有意义的,得到的代码估计不能正确执行。

如果你的代码确实大于64k,而你的片子不能超过64k,那就没有办法了。
7 非常感谢 发表于 2008-01-21 15:32 ·  中国 广东 深圳 联通
社区乞丐
积分 -16
发帖 5
注册 2008-01-14 13:00
UID 108543
性别 男
状态 离线
非常感谢二位的回帖,这两天一直在忙,没时间上来看看。所以回帖慢了点,还望二位见谅。对于二位的帮助,十分感激与感谢。谢谢!
8 发表于 2008-02-13 12:48 ·  中国 广东 广州 天河区 电信
初级用户
积分 67
发帖 32
注册 2007-01-25 18:14
UID 77654
性别 男
来自 日本の江户
状态 离线
用NASM可以生成Bin文件,命令格式:
NASM XXXX.ASM -O XXXX.BIN
打尽天下不平事,为抱国家尽我心!
论坛跳转: