<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>CodeWarrior Development ToolsのトピックRe: Re: HCS08 Assembly XDEF and XREF</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350100#M1603</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are several ways to create your assembly project.&lt;/P&gt;&lt;P&gt;If you want to use the default startup function and able to add some C code in future you can create a mixed project which included .c and .asm files.&lt;/P&gt;&lt;P&gt;If you want to use asm code only you can create this project too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In both case a prm file is used to allocated code and ram in memory.&lt;/P&gt;&lt;P&gt;The object codes generated with the assembler and compiler contain some information used by the linker to correctly allocated memory.&lt;/P&gt;&lt;P&gt;If in your code, a variable is not defined to an existing memory segment defined in prm, the linker will place it in DEFAULT_RAM.&lt;/P&gt;&lt;P&gt;If in your code, a function is not defined to an existing memory segment defined in prm, the linker will place it in DEFAULT_ROM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The allocation can be done via ORG or via SECTION for instance:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;MY_ZEROPAGE: SECTION&amp;nbsp; SHORT &lt;/TD&gt;&lt;TD&gt;; Insert here your data definition&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;fiboCount&amp;nbsp; DS.W&amp;nbsp; 1&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;counter:&lt;/TD&gt;&lt;TD&gt;DS.B&amp;nbsp; 1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;These 2 variables will be associated in the MY_ZEROPAGE section.&lt;/P&gt;&lt;P&gt;If this section is defined in prm (this is the case), the variables will be placed in this memory area.&lt;/P&gt;&lt;P&gt;If this section is not listed in the prm, the variables will be placed in DEFAULT_RAM by default.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If an assembly variable is not exported with XREF/XDEF, the variable will be available for the asm module only.&lt;/P&gt;&lt;P&gt;If the same variable is defined in x asm file, the variables will use x memory locations.&lt;/P&gt;&lt;P&gt;So we can say each variable will be as "Local" one very similar to static variable in C.&lt;/P&gt;&lt;P&gt;You could find some information in the Assembler_HC08.pdf manual in the folder: \CodeWarrior for Microcontrollers V6.3\Help\PDF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached you will find a new example based on Fibonacci code in asm.&lt;/P&gt;&lt;P&gt;With a linker option you can generate a map file which will give you all memory allocation information.&lt;/P&gt;&lt;P&gt;This option is -M.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Pascal Irrle&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Nov 2014 09:40:40 GMT</pubDate>
    <dc:creator>trytohelp</dc:creator>
    <dc:date>2014-11-20T09:40:40Z</dc:date>
    <item>
      <title>HCS08 Assembly XDEF and XREF</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350097#M1600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I must be missing something simple...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a relocatable assembly project.&amp;nbsp; I have one main.asm file.&amp;nbsp; It is 15,000 lines of code.&amp;nbsp; I would like to take some of my subroutines and put them in their own files.&amp;nbsp; I have a subroutine "_CheckBatt".&amp;nbsp; Is uses one register "BATTERY", defined in direct page "BATTERY DS 1".&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why can I not just copy the entire subroutine, from "_CheckBatt:" to "RTS" into it's own .asm file?&amp;nbsp; I tried putting "XREF BATTERY" and "XREFB BATTERY" at the top of "_CheckBatt.asm".&amp;nbsp; I made sure to put "INCLUDE '_CheckBatt.asm'" at the top of "main.asm".&amp;nbsp; I even tried putting "XDEF BATTERY" at the top of "main.asm".&amp;nbsp; The compiler keeps saying something like "variable redefined".&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Shouldn't using multiple files be simple?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it a matter of XDEF and XREF?&amp;nbsp; Or maybe .asm vs .inc files?&amp;nbsp; How about relocatable SECTION vs absolute ORG?&amp;nbsp; As long as the registers are defined in RAM, why does it matter if it is ORG or not?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How about a simple example of two file, "main.asm" and "second.asm" (or "second.inc") that shows main defining a register "TEST DS 1", using a "JSR" instruction to jump into a subroutine in the "second" file, and that subroutine in the "second" files manipulates "TEST", and then calls "RTS"...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!!!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 14:40:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350097#M1600</guid>
      <dc:creator>LiveMike</dc:creator>
      <dc:date>2014-11-18T14:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08 Assembly XDEF and XREF</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350098#M1601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached you will find an example mixing C and Asm file.&lt;/P&gt;&lt;P&gt;This will help you to understand how the XDEF/XREF is working.&lt;/P&gt;&lt;P&gt;XDEF is used to define a variable in the asm module whereas the XREF is used to say the varialbe is defined in another module which could be .c or .asm&lt;/P&gt;&lt;P&gt;The example files show you how the directives must be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Relocatable project is using a prm file to allocate the memory.&lt;/P&gt;&lt;P&gt;The absolute project can be used if your application contains 1 asm file only.&lt;/P&gt;&lt;P&gt;In this case the ORG is used to define the memory address.&lt;/P&gt;&lt;P&gt;The attached example is using CW for MCU V6.3 (Classic version).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Pascal Irrle&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 15:29:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350098#M1601</guid>
      <dc:creator>trytohelp</dc:creator>
      <dc:date>2014-11-18T15:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08 Assembly XDEF and XREF</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350099#M1602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Helpful.&amp;nbsp; I have it working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next question, again, thanks in advance...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable/register defined in main.asm as "FOO DS 1" and it's after an "ORG ZRAM_Start" for zero page.&amp;nbsp; This is all great and fine and everything is perfect.&amp;nbsp; Now that I can use multiple files, I have a separate file "test.asm".&amp;nbsp; At the top of test.asm I have "FOO DS 1" (no ORG statement).&amp;nbsp; This essentially is creating a "local" varibale/register "FOO" that it used in test.asm, BUT DOES NOT CHANGE "FOO" IN main.asm CORRECT?&amp;nbsp; I have tested this is true, but my REAL question is:&amp;nbsp; WHERE IS THIS "NEW/LOCAL" "FOO" ACTUALLY BEING CREATED IN RAM?&amp;nbsp; Who decides that and how?&amp;nbsp; I am using all 1024 bytes of RAM so I DO NOT want this new/local "FOO" to be just created some random place in RAM, overwriting/change a value that is already there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope some light can be shed on this.&amp;nbsp; Thanks again!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 17:58:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350099#M1602</guid>
      <dc:creator>LiveMike</dc:creator>
      <dc:date>2014-11-19T17:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Re: HCS08 Assembly XDEF and XREF</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350100#M1603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are several ways to create your assembly project.&lt;/P&gt;&lt;P&gt;If you want to use the default startup function and able to add some C code in future you can create a mixed project which included .c and .asm files.&lt;/P&gt;&lt;P&gt;If you want to use asm code only you can create this project too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In both case a prm file is used to allocated code and ram in memory.&lt;/P&gt;&lt;P&gt;The object codes generated with the assembler and compiler contain some information used by the linker to correctly allocated memory.&lt;/P&gt;&lt;P&gt;If in your code, a variable is not defined to an existing memory segment defined in prm, the linker will place it in DEFAULT_RAM.&lt;/P&gt;&lt;P&gt;If in your code, a function is not defined to an existing memory segment defined in prm, the linker will place it in DEFAULT_ROM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The allocation can be done via ORG or via SECTION for instance:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;MY_ZEROPAGE: SECTION&amp;nbsp; SHORT &lt;/TD&gt;&lt;TD&gt;; Insert here your data definition&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;fiboCount&amp;nbsp; DS.W&amp;nbsp; 1&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;counter:&lt;/TD&gt;&lt;TD&gt;DS.B&amp;nbsp; 1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;These 2 variables will be associated in the MY_ZEROPAGE section.&lt;/P&gt;&lt;P&gt;If this section is defined in prm (this is the case), the variables will be placed in this memory area.&lt;/P&gt;&lt;P&gt;If this section is not listed in the prm, the variables will be placed in DEFAULT_RAM by default.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If an assembly variable is not exported with XREF/XDEF, the variable will be available for the asm module only.&lt;/P&gt;&lt;P&gt;If the same variable is defined in x asm file, the variables will use x memory locations.&lt;/P&gt;&lt;P&gt;So we can say each variable will be as "Local" one very similar to static variable in C.&lt;/P&gt;&lt;P&gt;You could find some information in the Assembler_HC08.pdf manual in the folder: \CodeWarrior for Microcontrollers V6.3\Help\PDF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached you will find a new example based on Fibonacci code in asm.&lt;/P&gt;&lt;P&gt;With a linker option you can generate a map file which will give you all memory allocation information.&lt;/P&gt;&lt;P&gt;This option is -M.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Pascal Irrle&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 09:40:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/HCS08-Assembly-XDEF-and-XREF/m-p/350100#M1603</guid>
      <dc:creator>trytohelp</dc:creator>
      <dc:date>2014-11-20T09:40:40Z</dc:date>
    </item>
  </channel>
</rss>

