hammersslammers1@oxy.edu (David J. Harr) (12/08/89)
Let's try this again. It is very possible that you have read a partial message dealing with this same subject, but my terminal hiccupped while I was typing it in but before I had finished it. Anyway, I was having trouble with an assembly program crashing s soon as it called _InitGraf in the program, ie as soon as it executed the first instruction. The following is a listing of the program. Any help would be greatly appreciated ;Program CorneredCoin INCLUDE'Traps.a';define trap names MAIN PEA-4(A5);push pointer to QuickDraw globals _InitGraf;Inititalize QuickDraw _InitFonts;Initialize font manager _InitWindows;Initialize Window Manager _InitCursor;Initialize cursor to arrow SUBQ#4,SP;make room for pointer result CLR.L-(SP);allocate on heap PEAWindowSize;push pointer to rectangle PEAWindowName;push pointer to name ST-(SP);yes, window is visible CLR.W-(SP);use document window MOVE.L#-1,-(SP);put window on top SF-(SP);no, window has no goAway box CLR.L-(SP);NIL window refCon _NewWindow;make the window _SetPort;make the window the current port PEACoinSize;push pointer to rectangle _FrameRect;draw rectangle frame MOVE.L#$006E007A,-(SP);specify integer coordinates _MoveTo;move pen to that point PEACoinLetters;push pointer to string _DrawString;draw the string at the pen location FlipCoin _SystemTask;give screen time to resynch SUBQ#4,SP;make room for point result MOVE.LSP,-(SP);push pointer to result space _GetMouse;get cursor coordinate location MOVE.L(SP)+,D3;store point in register SUBQ#2,SP;make room for boolean result MOVE.LD3,-(SP);retrieve cursor point PEACoinSize;push pointer to rectangle _PtInRect;determine if cursor is in rect TST.B(SP)+;set Z flag accordingly BEQ.STryButton;branch if Z is not set (not in rect) PEACoinSize;push pointer to rectangle _InverRect;Invert Rectangle TryButton SUBQ#2,SP;make room for boolean result _Button;see if button is pressed TST.B(SP)+;set Z flag accordingly BEQ.SFlipCoin;branch if Z is set (nosed) _ExitToShell;return to DeskTop WindowSizeDC.W80,60,290,450;window bounds (top,lftneredCoin';window title CoinSizeDC.W80,100,130,290;rectangle bounds CoinLettersDC.B'BlackHeads/n END Well, there you have it. Any ideas? It is very discouraging to start out to program and have the program blow up in your face at the very first instruction. advaTHANKSnce, David
earleh@eleazar.dartmouth.edu (Earle R. Horton) (12/11/89)
In article <66669@tiger.oxy.edu> hammersslammers1@oxy.edu (David J. Harr) writes: >Let's try this again. It is very possible that you have read a partial >message dealing with this same subject, but my terminal hiccupped while >I was typing it in but before I had finished it. Anyway, I was having >trouble with an assembly program crashing s soon as it called _InitGraf >in the program, ie as soon as it executed the first instruction. The >following is a listing of the program. Any help would be greatly appreciated > >;Program CorneredCoin >INCLUDE'Traps.a';define trap names >MAIN >PEA-4(A5);push pointer to QuickDraw globals The problem is that "-4(A5)" does not point to the QuickDraw globals, unless you are using an old version of the MDS linker which specifically reserved space at this location for this purpose. From the name of your include file, I would guess that you are using the MPW assembler and linker. You need to allocate sufficient space for the QuickDraw globals, and pass the pointer to that storage to _InitGraf. The file 'QuickEqu.a' has the necessary declarations for you to figure out how much storage to allocate. So does the sample application which comes with the assembler, probably. Earle R. Horton