Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!d88ricwe From: d88ricwe@odalix.ida.liu.se (Rickard Westman) Newsgroups: comp.sys.amiga.tech Subject: Re: Assembly question from turnip Keywords: can allocmem crash? Message-ID: <1990Oct27.114320.20536@ida.liu.se> Date: 27 Oct 90 11:43:20 GMT References: <2728cc8d-a00comp.sys.amiga.tech@tronsbox.xei.com> Sender: news@ida.liu.se (News Subsystem) Organization: CIS Dept, Univ of Linkoping, Sweden Lines: 36 dfrancis@tronsbox.xei.com (Dennis Francis Heffernan) writes: > Well, I've hit a good one. I've finally gotten around to trying to l >learn assembly on this beast, and my first program crashes. Not surprising. >WHERE it crashes is- the first call to AllocMem. > Consider the following: >getvarmem move #4,a6 ;get memory for variables Try move.l 4,a6 > move.b #60,D0 Try move.l #60,D0 > move.l #0,D1 > jsr _LVOAllocMem(A6) All system calls expect longwords as arguments(*). If you do "move.b #60,D0" only the lower 8 bits of D0 are set - the rest of them could be set to anything. If you don't use a size designator at all (as in the first line) most assemblers will default to word size, leaving you with the same type of problem. So - *always* use ".l" when dealing with system call arguments. This is not why your program crashed, however. To call AllocMem() you need the exec.library base pointer in a6. This pointer is stored at the fixed address 4. But remember that it is a *pointer* to the library base, not the library base itself. You need one more level of indirection, which is what you get if you use "move.l 4,a6" instead of "move.l #4,a6". /RiW ----- (*) This may not be entirely true. I think there is one or two functions that use words, but they are clearly an exception.