51单片机Keil里为何实际代码总是从0x800开始的?
这样造成0x7FF之前大部分是0xFF,浪费程序空间。看startup.a51也没看明白这个0x800怎么来的。
有大神指导吗?
CODE 0800H 006DH INBLOCK ?PR?TM0?MAIN
BL51 BANKED LINKER/LOCATER V6.22, INVOKED BY:
D:\PROGRAM FILES (X86)\KEIL5\C51\BIN\BL51.EXE .\Objects\main.obj TO .\Objects\qxrh00 PRINT (.\Listings\qxrh00.m51) RAMSI
>> ZE (256) CODE (0X0000-0X0FF8)
MEMORY MODEL: SMALL
INPUT MODULES INCLUDED:
.\Objects\main.obj (MAIN)
D:\PROGRAM FILES (X86)\KEIL5\C51\LIB\C51S.LIB (?C_STARTUP)
LINK MAP OF MODULE: .\Objects\qxrh00 (MAIN)
TYPE BASE LENGTH RELOCATION SEGMENT NAME
-----------------------------------------------------
* * * * * * * D A T A M E M O R Y * * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 001EH UNIT ?DT?MAIN
IDATA 0026H 0001H UNIT ?STACK
* * * * * * * C O D E M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
0003H 0008H *** GAP ***
CODE 000BH 0003H ABSOLUTE
000EH 07F2H *** GAP ***
CODE 0800H 006DH INBLOCK ?PR?TM0?MAIN
CODE 086DH 0049H INBLOCK ?PR?MAIN?MAIN
CODE 08B6H 000FH INBLOCK ?PR?UART_INIT?MAIN
CODE 08C5H 000CH UNIT ?C_C51STARTUP
OVERLAY MAP OF MODULE: .\Objects\qxrh00 (MAIN)
SEGMENT
+--> CALLED SEGMENT
---------------------
?C_C51STARTUP
+--> ?PR?MAIN?MAIN
?PR?MAIN?MAIN
+--> ?PR?UART_INIT?MAIN
******************************************************************************
* RESTRICTED VERSION WITH 0800H BYTE CODE SIZE LIMIT; USED: 00C8H BYTE ( 9%) *
******************************************************************************
Program Size: data=39.0 xdata=0 code=215
LINK/LOCATE RUN COMPLETE. 0 WARNING(S), 0 ERROR(S)
你去了解一下51的存储结构,就知道那个是怎么来的了!
这个是由于51内核寄存器组决定的 你用汇编的话 就明白了 C的话 无所谓
怎么决定的?
汇编的话也是由0000H处的跳转到主程序入口执行,但是并没有哪里规定主程序必须是0x800啊?
这篇文章也只是0x100
https://wenku.baidu.com/view/bb38d1d502d276a200292e5a.html
这网站我也是醉了,一个技术论坛帖子审查整得比广电还牛掰,至于么。
还是不明白,如果像下面这么写汇编,那就是从0x100开始的,也就是可以控制的,生成的hex也是对的。
但是写C的时候不知道如何控制。
ORG??0000H?
?LJMP??0100H??
?ORG??0100H
; main entry
我也向了解了解。关注!
没人知道吗?现在是不是没什么人用51了。
顶,求帮助~~
顶啊顶
每到这个时候就感觉到度娘的无力,放狗之后发现:
估计是因为我装的时候没有输序列号。
C51 Evaluation Tools
The 8051 compiler, assembler, linker, and debugger are limited to 2 Kbytes of object code. Source code may be of any size.
Programs that generate more than 2 Kbytes of object code will not compile, assemble, or link.
The debugger supports programs that are 2 Kbytes or smaller.
The startup code generated includes LJMPs. Code generated cannot be used in single-chip devices that support 2 Kbytes or less of program space.
Programs start at offset 0x0800. Programs generated with the evaluation software may not be programmed into single-chip devices with less than 2 Kbytes of on-chip ROM.
No hardware support for multiple DPTR registers is provided.
No support for floating-point arithmetic and no support for user libraries is provided.
No support for in-line assembly using #pragma ASM.
The following components which are present in the PK51 Full Version are not included in the Evaluation Version: Linker for Code Banking, Library Manager, and RTX51 Tiny Real-time Operating System.
回个贴也要审核。这网站真是醉了,“总有刁民想害朕”
0x800就是主程序所在位置,程序默认是从0x000开始的,但是0X000只是一个引导向量,再下面就是各种外设的中断入口向量了,然后才是主程序的地址存储空间,主程序结束后接下来就是子程序的地址存储空间,主程序用多少没有限制,子程序用多少也没有限制,就是不能超过ROM的大小,这样说能理解吗?
其实楼上已经说的比较清楚了。汇编可以指定地址,C语言是由软件内部决定的,不用编译者操心。道理就是这么简单,明白了吗?