完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨…我试图把一些汇编代码(合理的复杂度)给17C176到16F1719,并且有字大小的问题。17C代码使用RES指令在RAM组中分配内存,它指定要分配的字节数。例如,温度Res 2与16F分配2字节,相同的语句分配2个字。我找不到另一个分配字节的指令:似乎DB指令只能用于“代码”(即初始化常数)。不幸的是,我们使用的是MPASM 5.73,所有的银行都是满的,并且没有足够的空间来存储两个字节以用于单个字节变量,所以我需要找到一种在存储的RAM中声明单个字节的方法。有人知道怎么做吗?我怀疑我忽略了一些显而易见的东西。
以上来自于百度翻译 以下为原文 Hi.. I am trying to port some assembly code (of reasonable complexity) for a 17c756 to the 16f1719, and have an issue with word size. The 17c code used the RES directive to allocate memory in the RAM banks, which specifies the number of bytes to allocate. E.g. TEMPERATURE RES 2 allocates 2 bytes With the 16f, the same statement allocates 2 WORDS. I couldn't find an alternative directive to allocate bytes: it seems as if the DB directive can only be used for 'CODE' (i.e. initialised constants). We are using MPASM 5.73 Unfortunately, all of the banks are quite full, and there isn't enough space to reserve two bytes for each single byte variable, so I need to find a way of declaring single bytes in the banked RAM. Does anyone know how to do this? I suspect that I have overlooked something embarassingly obvious. |
|
相关推荐
11个回答
|
|
嗯,我很确定RES在PIC16S上分配了正确的字节数。
以上来自于百度翻译 以下为原文 Mmm, I am pretty sure that RES allocates that exact number of bytes on PIC16s... |
|
|
|
不确定你所说的“2字”是什么,它将在RAM中分配2个地址,这些地址是用字节来处理的,所以它将是在那个标签上保留的2字节RAM。
以上来自于百度翻译 以下为原文 Not sure what you mean by "2 WORDS", it will allocate 2 addresses in the RAM, which is addressed in bytes,so it will be 2 bytes of RAM reserved at that label. |
|
|
|
|
|
|
|
可能有些混淆来自于在MPASM指南中描述RES指令的这一行:我认为这指的是FLAS/ROM中的分配,而不是RAM中的分配。
以上来自于百度翻译 以下为原文 Possibly some confusion comes from this line in the description of the RES directive in the MPASM guide: I think this refers to allocation in FLASH/ROM but NOT in RAM.... |
|
|
|
因此,好像我误解了MPASM手册(如下所示)记录了列表文件输出,它们都分配了1字节。我确实说过它会很尴尬,不是吗?4.57)保留记忆4.57.1语法[Reals]标签ReMyUnITS4.57.2描述符导致内存位置指针从MeMyUnice中指定的值从当前位置提前。在可重定位代码(使用MPLink链接器)中,RES可以用来保留数据存储。在不可重新定位的代码中,标签被假定为程序存储器地址。地址位置用PIC12/16 MCU的字来定义,而PIC18MCU的字节则被定义。
以上来自于百度翻译 以下为原文 So it seems as if I have misunderstood the MPASM manual (shown below) I checked the list file outputs, and they both allocate 1 byte. I did say that it would be embarassing, didn't I? :) My apologies for having wasted your time.. 4.57 res - RESERVE MEMORY 4.57.1 Syntax [label] res mem_units 4.57.2 Description Causes the memory location pointer to be advanced from its current location by the value specified in mem_units. In relocatable code (using MPLINK linker), res can be used to reserve data storage. In non-relocatable code, label is assumed to be a program memory address. Address locations are defined in words for PIC12/16 MCUs, and bytes for PIC18 MCUs. |
|
|
|
您好,这可能是由于MPASM手册:在可重定位代码(使用MPLink链接器)中,RES可以用来保留数据存储。在不可重新定位的代码中,标签被假定为程序存储器地址。地址位置用PIC12/16 MCU的字来定义,而PIC18MCU的字节则用以表示是否使用不可移动或可重新定位的代码。因此,因为PIC12/16有12/14位,所以它只能被称为Word,所以每个(程序)存储器位置包含一个字,但是因为PIC18具有16位指令(2字节),程序存储器位置(Flash)包含1个字节。
以上来自于百度翻译 以下为原文 Hi, Maybe this is due to the MPASM manual : ================================================================ 4.57.1 Syntax [label] res mem_units 4.57.2 Description Causes the memory location pointer to be advanced from its current location by the value specified in mem_units. In relocatable code (using MPLINK linker), res can be used to reserve data storage. In non-relocatable code, label is assumed to be a program memory address. Address locations are defined in words for PIC12/16 MCUs, and bytes for PIC18 MCUs ================================================================ So it seems that it depens whether one uses non-relocatable or relocatable code. Also because PIC12/16 has 12/14 bits it can only be referred as WORD so each (program) memory location contains one word but because PIC18 has 16 bits instructions (2 bytes) program memory locations (flash) contain 1 byte Regards |
|
|
|
对于程序存储器,RES保留PIC12/16的字和PIC18设备的字节,而不管代码的类型。对于数据存储器,RES在可重定位代码中保留字节。RES是NOTY,用于在绝对代码中保留数据存储器。
以上来自于百度翻译 以下为原文 For program memory, RES reserves words for PIC12/16 and bytes for PIC18 devices regardless of types of code. For data memory, RES reserves bytes in relocatable code. RES is _not_ used to reserve data memory storage in absolute code. |
|
|
|
在可重定位模式下,只能使用RAM来存储RAM。
以上来自于百度翻译 以下为原文 As above. RES can only be used to reserve RAM in relocatable mode. I've never encountered its use in program memory in non-relocatable mode. |
|
|
|
它可以用于保留某些PIC设备(如PIC12F675)的程序存储器的最后位置的校准指令,因此用户的代码不会覆盖该位置。例如。
以上来自于百度翻译 以下为原文 It can be used to reserve the calibration instruction in the last location of program memory for some PIC devices, such as PIC12F675, so the user's code does not overwrite this location. E.g. org 0x3FF res 1 |
|
|
|
|
|
|
|
1和0似乎已经明确地回答了……手册并没有真正解释这个指令的(不必要的)歧义。谢谢大家。从现在起我就更加小心了。:)
以上来自于百度翻译 以下为原文 1and0 seems to have definitively answered it... The manual hasn't really explained the (unecessary) ambiguity of this directive. Thanks everyone. I shall tread more carefully from now on.. :) |
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3209 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2260 浏览 5 评论
779浏览 1评论
672浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
598浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
682浏览 0评论
579浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 12:25 , Processed in 1.340360 second(s), Total 67, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号