Re: A83: 83+ asm questions


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

Re: A83: 83+ asm questions




The result of ionRandom is in register A, so just ld whatever,A



To do greater or less than checks, it's all about the carry flag.
The CP opcode actually subtracts the number from A, but leaves A untouched.  
If the result of A-x (where x is what A is being compared to) is less than 
0, then the c flag is set.  The z flag is set if the result of A-x=0.


example:
;=============================================================
ld a,4            ; a=4
cp 7              ; a-7<0, so the carry flag (c) is set.
jr c, label1      ;If the carry flag is set, then it jumps ahead

;insert code for a >= 7 here

label1:           ;This is where the above line jumps to
;============================================================


Another example:

;===========================================================
ld b,8            ;random number 0-7
call ionrandom    ;...
cp 5              ;Check if a=>5
jr nc,label2      ;carry flag is not set (nc) if a=>5.

;insert code here

label2:           ;this is where the jr jumps to.

;============================================================


>From: Jeff Ruud <pyroboy_04@yahoo.com>
>Reply-To: assembly-83@lists.ticalc.org
>To: assembly-83@lists.ticalc.org
>Subject: A83: 83+ asm questions
>Date: Sat, 6 Jan 2001 19:48:39 -0800 (PST)
>
>
>Does anyone know how to store the result of ion's call ionRandom to a 
>register?  Please tell me.
>And is there a way to check if something is greater than or less than a 
>different number?
>
>Thanks for the help.
>
>~Jeff
>
>
>
>---------------------------------
>Do You Yahoo!?
>Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com