| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2129 人关注过本帖
标题:A51中怎样写切bank的程序
只看楼主 加入收藏
insight1982
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-1-18
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
A51中怎样写切bank的程序
hi,
   我现在用keilc来作为编译工具,用汇编来写程序, 程序超过64K大小,我现在采用多BANK的
方式, 采用3个文件, 分别是 main.asm, bank2.asm, bank3.asm, 其中 0000 ~ 7FFFH作为公用的地址, 8000 ~ FFFFH作为BANK地址,我在编译完成后,链接的时候出现问题,说地址重合,出错如下所示,求教?

链接命令:BL51.EXE COMMON {.\L51_BANK.obj}, COMMON {main.obj}, BANK2 {bank2.obj}, BANK3 {bank3.obj
}, COMMON {STARTUP.obj} TO test BANKAREA (0X8000, 0XFFFF)


出错信息
:*** WARNING L19: COMMON CODE SEGMENTS LOCATED TO BANKED AREA

*** WARNING L5: CODE SPACE MEMORY OVERLAP
    FROM:    0000H
    TO:      0002H

*** WARNING L5: CODE SPACE MEMORY OVERLAP
    FROM:    0000H
    TO:      0002H

*** WARNING L5: CODE SPACE MEMORY OVERLAP
    FROM:    0000H
    TO:      0002H

*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  ?C_START
    MODULE:  .\STARTUP.obj (?C_STARTUP)

*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  ?C_START
    MODULE:  .\STARTUP.obj (?C_STARTUP)
    ADDRESS: 8052H
   
      
搜索更多相关主题的帖子: 怎样 信息 
2012-01-18 13:41
zaixuexi
Rank: 12Rank: 12Rank: 12
来 自:上海
等 级:火箭侠
威 望:8
帖 子:858
专家分:3233
注 册:2010-12-1
收藏
得分:20 
一般我遇到这种问题会怎么做?
第一步:google
http://www.
http://hi.baidu.com/fendou_mo/blog/item/be184821815f825d9922ed12.html
第二步:查keil c手册



技术问题,请不要以短消息方式提问
2012-01-18 14:34
insight1982
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-1-18
收藏
得分:0 
谢谢,
上面的那个例子是C语言写的
我编译C的例子是可以成功的
但是汇编的没有试成功,而且我是按照相同的设置
2012-01-19 16:43
GoldenSpider
Rank: 2
等 级:论坛游民
威 望:3
帖 子:17
专家分:77
注 册:2010-5-15
收藏
得分:0 
USING Assembler Statement
Arguments USING expression
 
Description The USING statement specifies the register bank (0-3) expression to use for encoding the >AR0-AR7 registers. The register bank selected is noted in the object file and the memory area is reserved by the linker.

Some 8051 instructions (like PUSH and POP) allow only absolute addresses to be used. The assembler replaces absolute registers (AR0-AR7) with the physical address of the register in the current register bank. So, while the instruction PUSH R0 is not valid, PUSH AR0 is valid. However, the assembler must know which register bank is used so that the correct physical address is calculated. This is the purpose for the USING statement.

The USING statement does not generate any code to switch the current register bank. The assembler program must select the correct register bank. For example, the following code selects register bank 2:

PUSH    PSW               ; save the current register bank
MOV     PSW, #(2 SHL 3)   ; set register bank 2
.
.
.
POP     PSW               ; restore saved register bank
The physical address is calculated as follows:

(register bank × 8) + register

下面写了个例子
程序代码:
ORG 0
MOV     SP,#2FH
;=======================================================
PUSH    PSW             ; save the current register bank
MOV     PSW, #(2 SHL 3) ; set register bank 2
MOV     R2,#12H         ; 写入R2到bank 2
MOV     R7,#34H         ; 写入R7到bank 2
;-----------------------
USING   2               ; select register bank 2
PUSH    AR2             ; push R2 in bank 2 (address 12h)
PUSH    AR7             ; push R7 in bank 2 (address 17h)

POP     AR7
POP     AR2
;-----------------------
POP     PSW             ; restore saved register bank

;=======================================================
PUSH    PSW             ; save the current register bank
MOV     PSW, #(3 SHL 3) ; set register bank 3
MOV     R2,#12H         ; 写入R2到bank 3
MOV     R7,#34H         ; 写入R7到bank 3
;-----------------------
USING   3               ; select register bank 3
PUSH    AR2             ; push R2 in bank 3 (address 1Ah)
PUSH    AR7             ; push R7 in bank 3 (address 1Fh)

POP     AR7
POP     AR2

;-----------------------
POP     PSW             ; restore saved register bank
;=======================================================
;以下也是可行的
MOV     0Ah,#12H        ;间接方式 R2 bank 1
MOV     0FH,#34H        ;间接方式 R7 bank 1

PUSH    0Ah
PUSH    0FH

POP     0FH
POP     0Ah

AJMP $

END

 
2012-02-09 21:36
zaixuexi
Rank: 12Rank: 12Rank: 12
来 自:上海
等 级:火箭侠
威 望:8
帖 子:858
专家分:3233
注 册:2010-12-1
收藏
得分:0 
膜拜楼上大牛

技术问题,请不要以短消息方式提问
2012-02-09 23:52
快速回复:A51中怎样写切bank的程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052267 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved