From @mail.uunet.ca:beejay@micor Mon Dec 7 00:37:00 1992 Received: from calvin.sfasu.edu by umaxc.weeg.uiowa.edu (5.61.jnf/920629) on Mon, 7 Dec 92 00:36:57 -0600 id AA10689 with SMTP Received: from mail.uunet.ca (uunet.ca) by calvin.sfasu.EDU with SMTP (5.59/25-eef) id AA04123; Mon, 7 Dec 92 00:32:56 CST Return-Path: <@mail.uunet.ca:beejay@micor> Received: from ocunix by mail.uunet.ca with UUCP id <9864>; Mon, 7 Dec 1992 01:29:18 -0500 Received: by micor.OCUnix.On.Ca (smail2.5) id AA20910; 7 Dec 92 00:13:11 EST (Mon) To: hyperc-l@calvin.sfasu.edu Subject: Re:C quiz Date: Sun, 6 Dec 1992 19:13:11 -0500 Message-Id: <9212070013.AA20907@micor.OCUnix.On.Ca> From: beejay@micor.ocunix.on.ca (Basil Johnson) Status: R ST2975@SIUCVMB.SIU.EDU writes: >I think I got this to work with a minimum of >manipulation. Don't ask me why I did what I did. > >:-) I won't. :-) Yes, it works! I was seeking analysis not alternatives, but I'll take it. However, I'm still looking for an explanation. Perhaps you could comment on the different '.s' code produced for the inkey() function in the following three situations. ----------This is from the original quiz-------------- .entry _inkey _inkey: .lbl lnk 2 pdc 1 jsr 2,_getkey stb _1 pdb _1 pea _2 jsr 4,_printf pdc -16287 pea _3 jsr 4,_printf ldc -16287 lib 0 ****** lbit -127,97 *** is 97 the lsb of 0xc061? *** slb -1 plb -1 pea _4 jsr 4,_printf llb -1 ldcb 128 jult _5 ldb _1 inc 128 stb _1 ldw _trace_sw ldcb 1 jne _6 ldc 0 stw _trace_sw jmp _7 _6: .lbl ldc 1 stw _trace_sw _7: .lbl _5: .lbl ldb _1 rtn ------------This is from your solution---------------- .entry _inkey _inkey: .lbl lnk 2 pdc 1 jsr 2,_getkey stb _1 pdb _1 pea _2 jsr 4,_printf pdc -16287 pea _3 jsr 4,_printf ldc -16287 slw -2 psh pea _4 jsr 4,_printf llw -2 ldcb 128 jult _5 ldb _1 inc 128 stb _1 ldw _trace_sw ldcb 1 jne _6 ldc 0 stw _trace_sw jmp _7 _6: .lbl ldc 1 stw _trace_sw _7: .lbl _5: .lbl ldb _1 rtn ----This is the same as original but uses an assembly lang peekb ----- .entry _inkey _inkey: .lbl lnk 2 pdc 1 jsr 2,_getkey stb _1 pdb _1 pea _2 jsr 4,_printf pdc -16287 pea _3 jsr 4,_printf pdc -16287 jsr 2,_peekb slb -1 plb -1 pea _4 jsr 4,_printf llb -1 ldcb 128 jult _5 ldb _1 inc 128 stb _1 ldw _trace_sw ldcb 1 jne _6 ldc 0 stw _trace_sw jmp _7 _6: .lbl ldc 1 stw _trace_sw _7: .lbl _5: .lbl ldb _1 rtn The problem lies between the 2nd and 3rd jsr 4, printf. When I changed the #define OA_KEY 0xc061 to the explicit declaration unsigned OA_KEY = 0xc061; the program worked OK. So the problem is not with the macro. Here's the code that that version generated and a comparison with the first. jsr 4, printf llw -2 (not in the incorrect version) lib 0 (lbit -127, 97 in the incorrect version) slb -3 (slb -1) plb -3 (plb -1) pea _4 jsr 4, printf I'm not familiar enough with the opcodes to decipher what's happening. However, since one can't do '#define unsigned OA_KEY 0xc061', my guess is that either #define does not accept an unsigned integer (what do the gurus say) or HyperC is generating incorrect code in this instance. Looks like I am getting 0x7f61 instead of 0xc061. So, is this a bug? Basil Johnson UUCP: micor!beejay |Oh, Fate! ... Nepean, Ontario InterNet: |Such a stupid thing: CANADA K2B 8E9 beejay@micor.ocunix.on.ca |Command a bird to fly (613) 820-0804 |Then clip its wing! --