A83: Re: 83+ Ion Prime Number Generator
[Prev][Next][Index][Thread]
A83: Re: 83+ Ion Prime Number Generator
Pushing only works on register pairs. You have to "push af" instead of "push a".
For the line that says "cp hl", hl is a 16-bit register pair so you can't compare it to the 8-bit accumulator. You could
do "cp l" but then the maximum value of your prime could only be 255. To get around this you have to use 16-bit
operations, such as _cphlde. Try using de instead of a. If you do that, you'll need a routine to divide hl by de. I
think Hideaki Omuro of Macross Software wrote one but unfortunately their site is down (http://macross.calc.org). If
anyone else on this list has it maybe they'll send it to you.
See below for an idea of what changes to make.
-Kouri
----- Original Message -----
From: <RalphieMSc@aol.com>
To: <assembly-83@lists.ticalc.org>
Sent: Friday, February 25, 2000 20:00
Subject: A83: 83+ Ion Prime Number Generator
<snip>
;HL = number being tested for prime-ness, A = divided by to check
.nolist ;Standard Ion Header
#include "ion.inc"
.list
#ifdef TI83P
.org progstart-2
.db $BB,6D
#else
.org progstart
#endif
ret
jr nc,begin
.db "PrimeTime v.0.5 Beta",0
begin: ;Program Start
bcall(_clrLCDFull) ;clear screen
ld hl,2 ;set up hl (will be inc'ed to 3)
bcall(_homeup) ;position cursor
mainloop:
inc hl ;test next number
ld de,1 ;set up a (test against)
test:
inc de
; insert routine to divide hl by de here (must save hl and de)
jr z,mainloop ;if hl/a is an integer (new a = 0), hl isn't
prime:
call _cphlde ;done testing?
jp nz,test ;if not, jump back to test
bcall(_DispHL) ;if so, display hl...
jr mainloop ;and test next hl
.end
END
References: