设为首页 加入收藏

TOP

使用SDCC中的sdas8051写单片机汇编程序(一)
2014-11-24 08:45:01 来源: 作者: 【 】 浏览:0
Tags:使用 SDCC sdas8051 单片机 汇编 程序

学校图书馆单片机的书还不少,但编译器都用的 Keil的。网上搜了搜,没什么sdcc的资料,:-),还不惨,官网上有文档。虽然是英文的,但最近几年坚持看英文技术书可不是盖的。用上 StarDic终于勉强弄懂。关于C51方面的就不多说了,虽然编译器不同,但基本还是可移植的。


就是Keil中的有些库SDCC中没有,貌似现在才发现一个,毕竟研究的时间还不长。就说说汇编的部分吧。


玩单片机我还是喜欢汇编,但Keil的汇编器语法和sdcc的实在不一样。怎么办呢?sdcc文档中也未提到汇编器的解释。但我在一大堆英文中苦苦的寻找者,终于看到SDCC的汇编器用的是ASXXXX的汇编器,而且还是个开源项目。^_^,顺藤摸瓜,找到那个网站。又是一堆的英文手册。为了技术,看吧。。。。


看手册,并把sdcc生成的汇编代码看看,还是摸出了一点门道,只是一点点阿,以后有新的进展会写进博客的,不过最近不会啦,课程太紧。还要备考四级。


如果用sdas8051写汇编版的单片机程序。会有几个文件。


sourcefile.asm 你自己编辑的源程序文本


sourcefile.rel 汇编器生成的目标文件


sourcefile.lst 汇编器生成的列表文件 用 -l 选项


sourcefile.rst 连接器生成的更新列表文件的文件


sourcefile.sym 汇编器生成的symbol listing(:-),不会翻译拉,看懂就行,意会) 用 -s 选项


soutcefile.mem 应该是连接器生成的内存使用状况的文件


sourcefile.ihx 连接器生成的hex文件,可以用sdcc自带的packihx工具转换为hex格式


。。。。。。。。。。。可能还会有,就不一一列举了,以上是几个重要的。


还有自己要创建的一个sourcefile.lnk文本文件,里面放的是连接器sdld所用的参数。


####################################################################################################


======================================================


所有sdcc可能会有的文件我粘帖在在下面:有兴趣的自己研究。


=====================================================


sourcefile.asm - Assembler source file created by the compiler
sourcefile.lst - Assembler listing file created by the Assembler
sourcefile.rst - Assembler listing file updated with linkedit information, created by linkage editor
sourcefile.sym - symbol listing for the sourcefile, created by the assembler
sourcefile.rel - Object file created by the assembler, input to Linkage editor
sourcefile.map - The memory map for the load module, created by the Linker
sourcefile.mem - A file with a summary of the memory usage
sourcefile.ihx - The load module in Intel hex format . Both formats are documented in the documentation of srecord
sourcefile.adb - An intermediate file containing debug information needed to create the .cdb file (with --debug)
sourcefile.cdb - An optional file (with --debug) containing debug information. The format is documented in cdbfileformat.pdf
sourcefile. - (no extension) An optional AOMF or AOMF51 file containing debug information (generated
with option --debug). The (Intel) absolute object module f ormat is a subformat of the OMF51 format and is commonly used by third party tools (debuggers, simulators, emulators).
sourcefile.dump* - Dump file to debug the compiler it self (generated with option --dumpall)



#######################################################################################################


下面用个实例解释以下sdas8051的汇编格式:


===========================================================================


;-----------------------------------------------------
; sy3_2.asm
; the P1 port exam
;------------------------------------------------------
.module sy3_2
.globl start
.globl P1_3
.globl P1_2
.area RSEG (ABS,DATA)
.org 0x0000
P1_3 = 0x0093
P1_2 = 0x0092
.area HOME (ABS,CODE)
.org 0x0000
sjmp start
.org 0x0030
start:
setb P1_3
IF1:
jnb P1_3,ELSE1
THEN1:
clr P1_2
sjmp ENDIF1
ELSE1:
setb P1_2
ENDIF1:
sjmp start
sjmp .
=======================================================================
与keil中的第一大不同就是sdas8051中的伪指令都用 . 开头。
比如定位伪指令为 .org
还有.area伪指令,貌似在keil中没看到。
我的理解就是声明一段区域,是绝对地值,还是重定位的,等等。。。这个很重要,但实在英文不好,

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux下编译程序使其处理超过2G的.. 下一篇Unix环境高级编程 源代码地址

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·有没有哪些高效的c++ (2025-12-27 08:20:57)
·Socket 编程时 Accep (2025-12-27 08:20:54)
·计算机网络知识点总 (2025-12-27 08:20:52)
·一篇说人话的文章, (2025-12-27 07:50:09)
·Python Web框架哪家 (2025-12-27 07:50:06)