Reply by owen...@yahoo.com March 5, 20142014-03-05
Wed 3/05/2014 8:18 am. I actually enhanced by home-grown 68HC11 assembler so that memory references to less than $100 would be flagged unless suppressed, since they're almost always wrong -- i.e. should be #immediate. After I spent an awful week debugging my code with that error.

jgo * owenlabs.org
Reply by "John Hartman (NoICE)" March 4, 20142014-03-04
Everyone who has ever programmed the HC12 or HC11 has made this
mistake. Old guys like me made the same mistake on the PDP-11 back
in the 1970s.

Welcome to the brotherhood of programmers :)

At 12:16 PM 3/3/2014, v...@yahoo.com wrote:
>
>JR, You were right. I was just missing the '#' in CMPB #$20. Newbie
>mistake, I know. Thanks!

Best regards, John Hartman
NoICE Debugging Tools
http://www.noicedebugger.com
Reply by veee...@yahoo.com March 3, 20142014-03-03
JR, You were right. I was just missing the '#' in CMPB #$20. Newbie mistake, I know. Thanks!
Reply by veee...@yahoo.com March 3, 20142014-03-03
Oops, I had a typo in my original post. Thanks for your reply. Here is my program code:

JSR getchar ;Get user input

CMPB $20 ;Did user hit 'spacebar'?

Assembly code:
JSR 0x3A15
CMPB 0x20

Accumulator B = 20 (after I hit spacebar)
Reply by JR March 3, 20142014-03-03
On 3/3/2014 6:44 PM, v...@yahoo.com wrote:
> I want my program to check if the user input was a spacebar.
> My program uses the getchar function. The user input should be
> converted from the ascii character to a hex value and stored in
> accumulator B. The hex code for "spacebar" is "$20". I use CMPB #$20
> after the getchar line, but the compare function is not working as I
> expected.
>
> In the debugger, I see that "20" is in accumulator B after the getchar
> line and I press spacebar. The next assembly instruction is CMPB 0x20,
> but after this is executed, the Z register is still false.
You are comparing Acc. B with memory location $20. Your instruction
should be CMPB #$20

>
> I tried "LDAB #$20; CMPB #$20" and this works as expected. The Z
> register went to true.
>
> How come my code "JSR getchar; CMPB #$20" is not producing Z --> true
> when I press spacebar and I've verified that "20" is stored in
> accumulator B?
>
Reply by "Redd, Emmett R" March 3, 20142014-03-03
So, which is it: CMPB #$20 or CMPB 0x20? They are not the same.

Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131

In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.

________________________________
From: 6... [6...] On Behalf Of v...@yahoo.com [v...@yahoo.com]
Sent: Monday, March 03, 2014 10:44 AM
To: 6...
Subject: [68HC12] GetChar value in Accumulator B is not working with CMPB (compare function)

I want my program to check if the user input was a spacebar.
My program uses the getchar function. The user input should be converted from the ascii character to a hex value and stored in accumulator B. The hex code for "spacebar" is "$20". I use CMPB #$20 after the getchar line, but the compare function is not working as I expected.

In the debugger, I see that "20" is in accumulator B after the getchar line and I press spacebar. The next assembly instruction is CMPB 0x20, but after this is executed, the Z register is still false.

I tried "LDAB #$20; CMPB #$20" and this works as expected. The Z register went to true.

How come my code "JSR getchar; CMPB #$20" is not producing Z --> true when I press spacebar and I've verified that "20" is stored in accumulator B?
Reply by veee...@yahoo.com March 3, 20142014-03-03
I want my program to check if the user input was a spacebar. My program uses the getchar function. The user input should be converted from the ascii character to a hex value and stored in accumulator B. The hex code for "spacebar" is "$20". I use CMPB #$20 after the getchar line, but the compare function is not working as I expected.

In the debugger, I see that "20" is in accumulator B after the getchar line and I press spacebar. The next assembly instruction is CMPB 0x20, but after this is executed, the Z register is still false.

I tried "LDAB #$20; CMPB #$20" and this works as expected. The Z register went to true.

How come my code "JSR getchar; CMPB #$20" is not producing Z --> true when I press spacebar and I've verified that "20" is stored in accumulator B?