home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!destroyer!gatech!concert!samba!usenet
- From: Todd_Lewis@unc.edu (Todd M. Lewis)
- Subject: PropGadgets and Manx C bug
- Message-ID: <1992Sep11.151113.9323@samba.oit.unc.edu>
- Sender: usenet@samba.oit.unc.edu
- Nntp-Posting-Host: guitar.oit.unc.edu
- Organization: UNC Office of Information Technology
- Date: Fri, 11 Sep 1992 15:11:13 GMT
- Lines: 56
-
- Below are two very short (6 line) C programs which only differ by
- the type of the only variable they contain. MAXPOT you may
- recognize as one of the constants used when manipulating
- Intuition slider PropInfo structures. Below that is the
- assembler output produced by Manx C v5.2a. Note how the one on
- the left works, while the one on the right uses register d1 in a
- subtraction without ever initializing it. ARGH! No wonder I've
- been having so much trouble with my slider gadgets.
-
- I present this in the hope of saving someone else the time I've
- spent trying to get this to work. The work-around is simple
- enough--make the variable "level" unsigned long. Note that
- casting it to unsigned long has no effect on the assembly
- instructions produced.
-
- /**COMPILES CORRECTLY**/ /**COMPILES INCORRECTLY**/
- #define MAXPOT 0xFFFF #define MAXPOT 0xFFFF
- main() main()
- { {
- unsigned long level; unsigned short level;
- level * MAXPOT; level * MAXPOT;
- } }
-
- Respective outputs from the compiler:
-
- ;:ts=8 ;:ts=8
- ;#define MAXPOT 0xFFFF ;#define MAXPOT 0xFFFF
- ;main() ;main()
- ; { ; {
- xdef _main xdef _main
- _main: _main:
- link a5,#.2 link a5,#.2
- movem.l .3,-(sp) movem.l .3,-(sp)
- ; unsigned long level; ; unsigned short level;
- ; level * MAXPOT; ; level * MAXPOT;
- move.l -4(a5),d0 move.w -2(a5),d0
- move.l d0,d1 swap d0
- lsl.l #8,d0 clr.w d0
- lsl.l #8,d0 swap d0
- sub.l d1,d0 sub.l d1,d0
- ; } ; }
- .4 .4
- movem.l (sp)+,.3 movem.l (sp)+,.3
- unlk a5 unlk a5
- rts rts
- .2 equ -4 .2 equ -2
- .3 reg .3 reg
- ; ;
- ; ;
- xref .begin xref .begin
- dseg dseg
- end end
-
-
- --
- Todd M. Lewis / Todd_Lewis@unc.edu / utoddl@guitar.oit.unc.edu
-