Re: A86: If/then in asm?


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

Re: A86: If/then in asm?




If you're thinking in terms of if/then, then you're not really thinking in
assembly.  Using if/then is a logical way of representing a problem in your
mind or on paper.  But once you get to assembly, you're beyond that point.
You need to know exactly what is happening on the hardware and software
level.

CP (compare) subtracts the argument from the accumulator (A register) and
sets the flags accordingly (just as any arithmetic operation does) but does
not store the result anywhere.

The various processor flags allow you to determine various things about the
relationships of the two values.  This is very different from a standard
boolean test.  Assembly is much more efficient.  This is the key to writing
optimized code.

Btw, what you had was inefficient.  The second unconditional jump is
unnecessary, because it will fall through to the code there.  Also, it is
more space efficient to use relative jumps (JR) when possible.

> cp b ; can you compare to a regiseter? I know only that  you can compare
> to a keypress, but I'm guessing...
> jp z, here ;then
> jp there ;else
>
> Right? I think.
> Terrence
>
> Kupan787@aol.com wrote:
>
> > How would I setup an if...then... statement in asm?
> >
> > Thanks,
> > Ben
>
>
>



References: