Re: A83: CP with register DE?


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

Re: A83: CP with register DE?





In a message dated 01/29/99 1:05:05 PM, lairfight@softhome.net writes:

>On 29-Jan-99, AtmaZ@aol.com (AtmaZ@aol.com) wrote:
>
>>Hi all,
>
>>What the sources on Z80 ASM have taught me is that CP only works with
>register
>>A.  However, the below usage of CP is contradictory to that rule...take
>a
>look
>>at this.
>
>>Here's the code:
>
>>call _getk         ; get keycode
>>call _op2toop1  ; swap OPs
>>call _convop1     ; put OP1 in -->DE<-- and not A
>>cp  22      ; compare with [MODE] keycode
>>ret   z              ; exit if pressed
>
>>And this works, for some strange reason!  I hit MODE and the program exits.
>>Can anybody tell me _why_ this works?
>
>>Chances are that the answer is painfully obvious and I'm just slow,
>but...hey,
>>what the hell.
>
>>--David
>
>You are completely right, cp compares with a. So _convop1 must be putting
>the
>result in a, not de. I've never used _convop1 so I don't know, really..
>
>Linus

Well, _convop1 does put OP1 into DE, so I am not sure why this sequence of
commands is working... does _getk put the key value into A or OP1? and if OP1,
then maybe a "ld a, e" is missing right before the CP... =P

--Jason K.