[img][/img]下午要出去,打字慢,先讲segment的用法。 我们可以用segment关键字将一段代码或申明的变量地位在一个特定的区域。要使用这要的办法,需要现在mapping.asm(针对汇编,C的话就是lkf)申明一个自定义段。比如我要申明一个mysegment {},放在ROM区域,里面打算放数组也好、代码的二进制文件也好,用户自己定。 对于汇编 ,打开mapping.asm: stm8/ ;------------------------------------------------------ ; SEGMENT MAPPING FILE AUTOMATICALLY GENERATED BY STVD ; SHOULD NOT BE MANUALLY MODIFIED. ; CHANGES WILL BE LOST WHEN FILE IS REGENERATED. ;------------------------------------------------------ #include "mapping.inc" BYTES ; The following addresses are 8 bits long segment byte at ram0_segment_start-ram0_segment_end 'ram0' WORDS ; The following addresses are 16 bits long segment byte at ram1_segment_start-ram1_segment_end 'ram1' WORDS ; The following addresses are 16 bits long segment byte at stack_segment_start-stack_segment_end 'stack' WORDS ; The following addresses are 16 bits long segment byte at 4000-45FF 'eeprom' WORDS ; The following addresses are 16 bits long segment byte at 8080-17FFF 'rom' WORDS ; The following addresses are 16 bits long segment byte at 8000-807F 'vectit' END ---------------------- WORDS ; The following addresses are 16 bits long segment byte at 8080-17FFF 'rom' 我们需要在ROM区添加一个段叫mysegment,地址在0xFF00到0xFFF0区域,我们自己手动添加这个段: WORDS ; The following addresses are 16 bits long segment byte at FF00-FFF0 'mysegment' 将上面的内容添加到ROM之后,Vectit之前(你现在明白之前为什么在C中中断向量 veciti 只是一个符合,而不是地址的定位了吧?)。保存。还有一种快速的方法是在STVD下使用IDE的界面,项目Project-Setting - ST Link里面改。 结果看截图: