[cc65] Problem with cc65 v2.13.9

From: Shawn Jefferson <sjefferson1shaw.ca>
Date: 2010-01-06 07:32:39
I have some code that used to compile and run fine, but now is returning the
wrong result. I've attached the generated assembly listing for the code.
I've also included the previous calculation for completeness.

 

This is the code that is causing the problem:

 

max_images = (image_table_cyl - (myide_config.imagecyl_hi * 256));

max_images = max_images / myide_config.imagesize_cyl;

 

image_table_cyl is unsigned int on zeropage, value is 4090 at runtime

myide_config is a struct on zeropage

myide_config.imagecyl_hi is unsigned char, value is 3 at runtime

myide_config.imagesize_cyl is unsignec char, value is 2 at runtime

 

result for the two max_images calculations are:

 

-1286

31125

 

But should be:

 

2554

1277

 

Looking at the code generated, it looks to my uneducated eye that this may
indicate the problem: (??)

 

0003A0r 1  85 rr             sta     _image_table_cyl

0003A2r 1  86 rr             stx     _image_table_cyl+1

0003A4r 1               ;

0003A4r 1               ; max_images = (image_table_cyl -
(myide_config.imagecyl_hi * 256));

0003A4r 1               ;

0003A4r 1  A2 00           ldx     #$00

 

The x register shouldn't be loaded with zero here I don't think.  It should
have the value stored from the calculation above I think?

 

-- 

Shawn

 




----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jan 6 07:32:47 2010

This archive was generated by hypermail 2.1.8 : 2010-01-06 07:32:50 CET