Article View: comp.sys.amiga.tech
Article #6197Re: Assembly question from turnip
From: Eduardo E. Horvath eeh
Date: Tue, 30 Oct 1990 19:03
Date: Tue, 30 Oct 1990 19:03
44 lines
2929 bytes
2929 bytes
In article <1990Oct29.205140.28826@zorch.SF-Bay.ORG> xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan) writes:
>lphillips@lpami.wimsey.bc.ca (Larry Phillips) writes:
>> dfrancis@tronsbox.xei.com (Dennis Francis Heffernan) writes:
>[...]
>>> As for checking the condition codes, I was under the impression that
>>>any time you moved a zero into a data register, the zero flag was set. I
>>>don't see then how the system calls could NOT set the flag, but I'll take your
>>>words for it.
>
>>There is no guarantee that the last operation to affect the condition codes is
>>the one you are interested in (the move of the result to D0). In other words,
>>the result might be moved to D0, then something else moved to or from another
>>data reg, before control is returned to your program.
>
>WHAT? How can you do multitasking at all, if whatever's the 68000's
>version of the program status register's set of condition flags, isn't
>restored after a context switch? I guess my ignorance is showing, but
>this sure isn't how the world used to look the last time I worked at the
>assembly level. What did I miss?
>
>Kent, the man from xanth.
><xanthian@Zorch.SF-Bay.ORG> <xanthian@well.sf.ca.us>
Multitasking has nothing to do with it. The problem is that there is no
guarantee that the last executed that affects the condition codes in the library
call consists of loading the return value. It is quite concievable that there
is other internal maintenance code that has the side-effect of changing the CCR.
It is also possible that someone has SetFunction()'ed that particular routine or
has installed some code to monitor all system calls. If there is an enveloping
routine installed, it almost certainly does not load the return code as the last
intruction before the function return. It is always better to be safe than to
visit the Guru.
If you really don't like adding an additional compare instruction, you
can store the result to memory and branch on the result of that. Since you will
need to move the return value anyway, it does not create any additional
overhead.
=========================================================================
Eduardo Horvath eeh@btr.com
..!{decwrl,mips,fernwood}!btr!eeh
"Trust me, I know what I'm doing." - Sledge Hammer
=========================================================================
Technical Details
Message-ID:
<848@public.BTR.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!mips!public!eehReferences:
<2169@lpami.wimsey.bc.ca> <1990Oct29.205140.28826@zorch.SF-Bay.ORG>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!mips!public!eeh From: eeh@public.BTR.COM (Eduardo E. Horvath eeh@btr.com) Newsgroups: comp.sys.amiga.tech Subject: Re: Assembly question from turnip Keywords: can allocmem crash? Message-ID: <848@public.BTR.COM> Date: 30 Oct 90 19:03:32 GMT References: <2169@lpami.wimsey.bc.ca> <1990Oct29.205140.28826@zorch.SF-Bay.ORG> Organization: BTR Public Access UNIX, MtnView CA, Contact: cs@btr.com 415-966-1429 Lines: 44