Re: A85: Oh boy!!! Another question!!!


[Prev][Next][Index][Thread]

Re: A85: Oh boy!!! Another question!!!




>Also, how do you know when you use CALL_, jr, etc.?

Call is to run a certain routine.  When the routine is finished executing
it returns from where it came.  A jr is a "relative" jump and can only
jump around the program about 128 bytes either forward or back.  A jump
jumps to anywhere in memory.

>Does this put Str1 to the screen or Str2?:
>
>ld	hl, (PROGRAM_ADDR)
>ld	de, Str1
>ld	a, 3
>cp	3
>ld	de, Str2
>add	hl, de
>ROM_CALL(D_ZT_STR)
>I ask this because I had previously thought that if a CP X statement 
>was true it ran the next line of code otherwise it skipped it, but now 
>I am thinking otherwise because I have only seen a CP X with a JR Z, X 
>following it.  Am I right when I think that CP X sets a flag to zero 
>if
>it is true?

Nope.  BASIC will skip the next instruction if it is false, but this is a
high level language designed for ease of use and not optimized
programming.  If cp X is true, the zero flag is set, because A-X=0 or
A=X.  The only way to skip to the next instruction would be like this:

ld        hl, (PROGRAM_ADDR)
ld        de, str1
ld        a, X
cp       X
jr         nz, Next    ; If zero flag is not set, or if A does not equal
three, skip ahead

ld        de, Str2

Next:
add   hl, de
ROM_CALL_(D_ZT_STR)

hope this helps.

Justin Bosch
justin-b@juno.com

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]


References: