在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
芯片精品文章合集(500篇!)    创芯人才网--重磅上线啦!
查看: 6354|回复: 14

数据段的问题?

[复制链接]
发表于 2003-10-10 09:30:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
[这个贴子最后由baonng在 2003/10/10 09:32am 第 1 次编辑]

在程序中我定义:
        AREA    Strings, DATA, READWRITE
srcstr  DCD  0,1,2,3,4,5,6,7,8,9
在链接选项中的设置如图所示,当使用命令LDR  R0, =srcstr时,R0中的值为10000,而该地址中的值并不是我定义的0,1,2,3,4,5,6,7,8,9;问题在哪?如何解决呢?
18_106.jpg
发表于 2003-10-10 12:17:02 | 显示全部楼层

数据段的问题?

这样试试
LTORG
   srcstr  DATA DCD  0,1,2,3,4,5,6,7,8,9
防在你的code段后面
 楼主| 发表于 2003-10-10 12:32:38 | 显示全部楼层

数据段的问题?

好,我试试。
 楼主| 发表于 2003-10-10 12:58:15 | 显示全部楼层

数据段的问题?

这样写,编译有错。
发表于 2003-10-10 13:02:24 | 显示全部楼层

数据段的问题?

不会吧,放在 end 的前面
 楼主| 发表于 2003-10-10 13:06:33 | 显示全部楼层

数据段的问题?

是在end前。但就是编译有错。
发表于 2003-10-10 13:13:51 | 显示全部楼层

数据段的问题?

把你的程序贴出来吧
 楼主| 发表于 2003-10-10 13:18:48 | 显示全部楼层

数据段的问题?

我用ADS带的例子验证的。
        AREA    StrCopy, CODE, READONLY
        ENTRY                   ; mark the first instruction to call
start
        LDR     r1, =srcstr     ; pointer to first string
        LDR     r0, =dststr     ; pointer to second string
        BL      strcopy         ; call subroutine to do copy
stop
        MOV     r0, #0x18       ; angel_SWIreason_ReportException
        LDR     r1, =0x20026    ; ADP_Stopped_ApplicationExit
        SWI     0x123456        ; ARM semihosting SWI

strcopy                 
        LDRB    r2, [r1],#1     ; load byte and update address
        STRB    r2, [r0],#1     ; store byte and update address;
        CMP     r2, #0          ; check for zero terminator
        BNE     strcopy         ; keep going if not
        MOV     pc,lr           ; Return

        AREA    Strings, DATA, READWRITE
LTORG
srcstr DATA DCB "First string - source",0
dststr  DCB "Second string - destination",0
        END
发表于 2003-10-10 14:40:31 | 显示全部楼层

数据段的问题?

这样做吧,写两个文件
第一个
IMPORT srcstr
       AREA    StrCopy, CODE, READONLY
       ENTRY                   ; mark the first instruction to call
start
       LDR     r1, =srcstr     ; pointer to first string
       LDR     r0, =dststr     ; pointer to second string
       BL      strcopy         ; call subroutine to do copy
stop
       MOV     r0, #0x18       ; angel_SWIreason_ReportException
       LDR     r1, =0x20026    ; ADP_Stopped_ApplicationExit
       SWI     0x123456        ; ARM semihosting SWI

strcopy                 
       LDRB    r2, [r1],#1     ; load byte and update address
       STRB    r2, [r0],#1     ; store byte and update address;
       CMP     r2, #0          ; check for zero terminator
       BNE     strcopy         ; keep going if not
       MOV     pc,lr           ; Return

      
       LTORG
      
dststr  DCB "Second string - destination",0
       END
第二个
AREA DATASEC, DATA, READWRITE
   EXPORT srcstr
srcstr  DCD 0
   end
 楼主| 发表于 2003-10-10 15:45:30 | 显示全部楼层

数据段的问题?

还是一样,srcstr = 0x10000,数据则在代码段之后。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-9 01:09 , Processed in 0.042403 second(s), 10 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表