<?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>8-bit MicrocontrollersのトピックRe: MC9S08KA2 - Programming</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201153#M16469</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello and welcome to the forums amit.kumar,&lt;BR /&gt;&lt;BR /&gt;Firstly, if you make a mistake like an empty posting you can just go and edit it if you do it within an hour or so.&lt;BR /&gt;&lt;BR /&gt;Now to your question.&lt;BR /&gt;First I presume you are testing bits 0 and 1 of the same port.&lt;BR /&gt;You can do it with an ugly combination of BRSET's and BRCLR's&lt;BR /&gt;or you can do it like I show below.&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;      lda    PORT             ;get current input port status      and    #%00000011       ;mask out irrelevant bits      bne    lab1             ;branch if other than 00      do something when 00
      bra    lab3

lab1  cmp    #%00000001       ;test for bit 0 only on      bne    lab2             ;branch if not so      do something when 01      bra    lab3
lab2  cmp    #%00000010       ;test for bit 1 only on      bne    lab3             ;branch if not so      do something when 10lab3  .....&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Mar 2008 09:44:16 GMT</pubDate>
    <dc:creator>peg</dc:creator>
    <dc:date>2008-03-09T09:44:16Z</dc:date>
    <item>
      <title>MC9S08KA2 - Programming</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201152#M16468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I am new to asm programming.&lt;/DIV&gt;&lt;DIV&gt;Can anyone tell&amp;nbsp;the asm code for following pseudo code.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am using PORT 0, and PORT 1 as digital &amp;nbsp;i/p.&lt;/DIV&gt;&lt;DIV&gt;the trying ti write some condiitions ..&lt;/DIV&gt;&lt;DIV&gt;If(PORT_0 == 1 &amp;amp;&amp;amp; PORT_1 == 0)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DO SOMETHING&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;ELSEIF(PORT_0 == &amp;amp;&amp;amp; PORT_1 == 0)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DO SOMETHING&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;ELSE(PORT_0 ==&amp;nbsp; 0 &amp;amp;&amp;amp; PORT_1 == 1)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DO SOMETHING&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I&amp;nbsp;want to use IF - ELSE in my code, if there is any instruction for this then kindly answer me.&lt;/DIV&gt;&lt;DIV&gt;or tell me syntax to use&amp;nbsp;IF - ELSE loop&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;kindly,&amp;nbsp;try to answer urgently.&lt;/DIV&gt;&lt;DIV&gt;thanks.&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Mar 2008 05:44:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201152#M16468</guid>
      <dc:creator>amit_kumar</dc:creator>
      <dc:date>2008-03-09T05:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08KA2 - Programming</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201153#M16469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello and welcome to the forums amit.kumar,&lt;BR /&gt;&lt;BR /&gt;Firstly, if you make a mistake like an empty posting you can just go and edit it if you do it within an hour or so.&lt;BR /&gt;&lt;BR /&gt;Now to your question.&lt;BR /&gt;First I presume you are testing bits 0 and 1 of the same port.&lt;BR /&gt;You can do it with an ugly combination of BRSET's and BRCLR's&lt;BR /&gt;or you can do it like I show below.&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;      lda    PORT             ;get current input port status      and    #%00000011       ;mask out irrelevant bits      bne    lab1             ;branch if other than 00      do something when 00
      bra    lab3

lab1  cmp    #%00000001       ;test for bit 0 only on      bne    lab2             ;branch if not so      do something when 01      bra    lab3
lab2  cmp    #%00000010       ;test for bit 1 only on      bne    lab3             ;branch if not so      do something when 10lab3  .....&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Mar 2008 09:44:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201153#M16469</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2008-03-09T09:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08KA2 - Programming</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201154#M16470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanx Peg !!&lt;/DIV&gt;&lt;DIV&gt;It really good to use this trick rather than trying BRSET, BRCLR that i was trying before.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;but still I am searching for IF else loop because somewher i found that.&lt;/DIV&gt;&lt;DIV&gt;MODE : equ 0&lt;/DIV&gt;&lt;DIV&gt;IFNE MODE&lt;/DIV&gt;&lt;DIV&gt;---do something&lt;/DIV&gt;&lt;DIV&gt;ELSE&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;do something&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;anyway, still i am happy to use above trick given by u.&lt;/DIV&gt;&lt;DIV&gt;thank u once again !!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Amit&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Mar 2008 13:09:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201154#M16470</guid>
      <dc:creator>amit_kumar</dc:creator>
      <dc:date>2008-03-09T13:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08KA2 - Programming</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201155#M16471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi again amit.kumar,&lt;BR /&gt;&lt;BR /&gt;If you have seen if-else structures then its not truly assembler put some form of high level language or use of macros etc.&lt;BR /&gt;Assembler is simply using mnemonics to represent the opcodes from the set given in the processor core manual. In this case HCS08RMV1.pdf.&lt;BR /&gt;So the only options you have are given in this document.&lt;BR /&gt;Various assemblers will allow different directives but that is about it.&lt;BR /&gt;Anything else is compiled down to machine code which has a 1 to 1 relationship with assembly, so whatever you use you end up basically with it anyway.&lt;BR /&gt;The method I have shown is basically the same layout and just as readable as a C switch statement anyway.&lt;BR /&gt;Of course when you need to use complex BRSET/BRCLR combinations to get the job done the ability to quickly analyse the programme flow for a given set of input values quickly goes out the window.&lt;BR /&gt;Hope that helps&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Mar 2008 18:39:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201155#M16471</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2008-03-09T18:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08KA2 - Programming</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201156#M16472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;amit.kumar wrote:&lt;BR /&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;but still I am searching for IF else loop because somewher i found that.&lt;/DIV&gt;&lt;DIV&gt;MODE : equ 0&lt;/DIV&gt;&lt;DIV&gt;IFNE MODE&lt;/DIV&gt;&lt;DIV&gt;---do something&lt;/DIV&gt;&lt;DIV&gt;ELSE&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;do something&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;I think what you may have previously observed are called "conditional assembly" directives.&amp;nbsp; These directives tell the assembler/compiler to assemble one block of code, or alternatively another block of code in place of the first block, depending on the value of a control parameter.&amp;nbsp; This has nothing to do with branching&amp;nbsp;operations within&amp;nbsp;the assembled code.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Yet another possibility, to that outlined by Peg, is to make use of the CBEQ instruction.&lt;BR /&gt;&lt;PRE&gt;&lt;FONT size="2"&gt;   lda    PORT             ; Read current input port status
      and    #%00000011       ; Mask bits to be tested
&lt;/FONT&gt; &lt;FONT size="2"&gt;    cbeqa  #%00000011,lab1  ; Branch if first value
      cbeqa  #%00000001,lab2  ; Branch if second value&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;FONT size="2"&gt;    ; Default case:
&lt;/FONT&gt; &lt;FONT size="2"&gt;    ...
&lt;/FONT&gt; &lt;FONT size="2"&gt;     bra    continue&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;FONT size="2"&gt;lab1: ; First value code:
&lt;/FONT&gt; &lt;FONT size="2"&gt;    ...
&lt;/FONT&gt; &lt;FONT size="2"&gt;     bra    continue&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;FONT size="2"&gt;lab2: ; Second value code:
&lt;/FONT&gt; &lt;FONT size="2"&gt;    ...
&lt;/FONT&gt;&lt;FONT size="2"&gt;continue:
&lt;/FONT&gt; &lt;FONT size="2"&gt;    ; Further code here
&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;FONT face="Arial"&gt;Regards,
&lt;/FONT&gt;&lt;FONT face="Arial"&gt;Mac
&lt;/FONT&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-03-10&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:22 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Mar 2008 21:09:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08KA2-Programming/m-p/201156#M16472</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-03-09T21:09:59Z</dc:date>
    </item>
  </channel>
</rss>

