[comp.sys.apple2] Deferred and Immediate mode

chin@ankh.ankh.ftl.fl.us (Albert Chin) (07/30/90)

How can you tell if the Apple II is running in deferred (while a program is
running) or immediate mode. I would like to create a program that only
runs in immedate mode and not in deferred mode.

thanks,

albert chin ... mthvax!mamia!albert

mdavis@pro-sol.cts.com (Morgan Davis) (07/31/90)

In-Reply-To: message from chin@ankh.ankh.ftl.fl.us

Check the BI global page "STATE" flag, or the prompt character in zero page.

UUCP: crash!pnet01!pro-sol!mdavis		ProLine:  mdavis@pro-sol
ARPA: crash!pnet01!pro-sol!mdavis@nosc.mil	MCI Mail: 137-6036
INET: mdavis@pro-sol.cts.com			America Online, BIX: mdavis

dlyons@Apple.COM (David A. Lyons) (07/31/90)

In article <CHIN.90Jul29204326@ankh.ankh.ftl.fl.us> chin@ankh.ankh.ftl.fl.us (Albert Chin) writes:
>How can you tell if the Apple II is running in deferred (while a program is
>running) or immediate mode. I would like to create a program that only
>runs in immedate mode and not in deferred mode.
>
>thanks,
>
>albert chin ... mthvax!mamia!albert

Please explain what you're looking for.  Are you talking about Applesoft
BASIC?  That's the only place I've seen the terms "immediate" and "deferred"
used.

If that's what you're trying to detect, I believe you have to check both
$76 (high byte of current line number) and $32 (prompt).  If $76=$FF or
$32="]", you're in Applesoft immediate mode.
-- 
David A. Lyons, Apple Computer, Inc.      |   DAL Systems
Apple II Developer Technical Support      |   P.O. Box 875
America Online: Dave Lyons                |   Cupertino, CA 95015-0875
GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons
   
My opinions are my own, not Apple's.

rond@pro-grouch.cts.com (Ron Dippold) (07/31/90)

In-Reply-To: message from chin@ankh.ankh.ftl.fl.us

:   phy 
:   php 
:   sec 
:   xce 
:   php 
:   rol a 
:   plp 
:   xce 
:   ply 
:   plx 
:   lsr a 
:   bcc  is_native 
:   bcs  is_emulation 
 
Whoops, that second xce should have a plp after it...

UUCP: crash!pro-grouch!rond
ARPA: crash!pro-grouch!rond@nosc.mil
INET: rond@pro-grouch.cts.com

greg@hoss.unl.edu (Hammer) (07/31/90)

In article <43444@apple.Apple.COM> dlyons@Apple.COM (David A. Lyons) writes:
>In article <CHIN.90Jul29204326@ankh.ankh.ftl.fl.us> chin@ankh.ankh.ftl.fl.us (Albert Chin) writes:
>>How can you tell if the Apple II is running in deferred (while a program is
>>running) or immediate mode. I would like to create a program that only
>>runs in immedate mode and not in deferred mode.
>>
>>thanks,
>>
>>albert chin ... mthvax!mamia!albert
>
>Please explain what you're looking for.  Are you talking about Applesoft
>BASIC?  That's the only place I've seen the terms "immediate" and "deferred"
>used.
>
>If that's what you're trying to detect, I believe you have to check both
>$76 (high byte of current line number) and $32 (prompt).  If $76=$FF or
>$32="]", you're in Applesoft immediate mode.

If that is what he means, then a program that only runs in immediate mode
would be a TXT file which is meant to be EXECed.  Unfortunately, in
immediate mode, you don't have any real goto/gosub statements, input
statements, or ProDOS open statements.  I'm not sure what else you won't
be able to use, but those pop to mind.

>-- 
>David A. Lyons, Apple Computer, Inc.      |   DAL Systems
>Apple II Developer Technical Support      |   P.O. Box 875
>America Online: Dave Lyons                |   Cupertino, CA 95015-0875
>GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
>Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons
>   
>My opinions are my own, not Apple's.

      __  ___________  __
     /_/\/_/_______\_\/\_\
     \ \_\ \__   __/ /_/ /
      \  __ \ | | / __  /
       \_\/\_\|_|/_/\/_/
       / /_/ /| |\ \_\ \
      /greg@hoss.unl.edu\
     /_/ /_/_______\_\ \_\

toddpw@tybalt.caltech.edu (Todd P. Whitesel) (08/01/90)

rond@pro-grouch.cts.com (Ron Dippold) writes:

[ a somewhat involved routine to test the e flag and branch on it ]

A simpler way to test for emulation mode is

	clc
	xce	;force native mode temporarily
	php	;save the old e bit which is now in c
	xce	;restore old e bit, carry is cleared
	plp	;and get it back into the carry
	bcc	is_native
	bcs	is_emulation

Unless I grossly misunderstand the stack effects of mode-switching, this
routine should work under ANY conditions. However, there could be side effects
if we are in emulation mode and the stack pointer is $100 -- namely, the
interrupt info clobbers the top of zero page. A more robust way would be:

	php
	rep	$20	;should have no effect in emulation mode
	clc
	bit	#$3800	;sets carry flag to m bit which equals the e bit
	bcc	is_native
	bcs	is_emulation

note that both is_native and is_emulation should begin with PLP's.

You can also use CLC, BIT #$3800 at any time to branch on the accumulator size,
or CLC, LDX #$3800 to branch on the index register size.

All of this is irrelevant to the original question, of course, which has
already been answered.

Todd Whitesel
toddpw @ tybalt.caltech.edu

jschober@gnh-starport.cts.com (Joey Schober) (08/01/90)

In Reply To: chin@ankh.ankh.ftl.fl.us (Albert Chin)

A program that only runs in the immediate (= "not currently running a program")
mode??  Isn't that kinda self-contradictory??

At any rate, if you're running under P8's BASIC.SYSTEM, you can use the global
page location @ $BE42 (48706 dec) to find out what the state of the machine is;
if the value there is 0, you're in immediate mode, otherwise, you're in
deferred mode.

Hope that helps...
 
     Joseph F. Schober, Sysop, StarPort BBS [703/931-0947 - 3/12/2400 baud]

ProLine.: jschober@gnh-starport                          ======================
UUCP....: crash!gnh-starport!jschober                    Amer-Online:  JSchober
InterNet: jschober@gnh-starport.cts.com                  CompuServe: 72727,2765
ARPA....: crash!gnh-starport!jschober@nosc.mil           ======================