A83: 83+ Ion Prime Number Generator


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

A83: 83+ Ion Prime Number Generator



I have tried to write a prime number generator in Ion ASM (my first 
semi-useful ASM program!)  I am probably making a dumb newbie mistake, but it 
(TASM) says that a is an unrecognized argument and hl is an undefined label 
(or something like that).  Any help would be VERY much appriciated.  Also, if 
you have any optimizations to make (my code is sloppy) those would be much 
appriciated.  For the record, I am using TASM 3.1, ion.inc, the IonGuru batch 
file, and DevPack83.  The program is being compiled for 83+ Ion.  In the 
future, I hope to add checking to throw out all even numbers (jp pe,mainloop 
or something like that).  Anyway...

        ;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
    jp mainloop             ;jump to main loop
mainloop2:                  ;need to get a off stack
    pop a
mainloop:
    inc hl                  ;test next number
    ld a,1                  ;set up a (test against)
test:
    inc a
    push a                  ;_DivHLByA destroys a and hl
    push hl
    bcall(_DivHLByA)            ;store remainder of hl/a to a
    pop hl                  ;get back original hl
    jp z,mainloop2              ;if hl/a is an integer (new a = 0), hl isn't 
prime
    pop a                   ;get a back
    cp hl                   ;done testing?
    jp nz,test              ;if not, jump back to test
    bcall(_DispHL)              ;if so, display hl...
    jp mainloop             ;and test next hl
.end
END

Also, I do know that there is no way out of this program right now, so DON'T 
test it on your calc.

Thanks much,
Asm83P
		;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
	jp mainloop				;jump to main loop
mainloop2:					;need to get a off stack
	pop a
mainloop:
	inc hl					;test next number
	ld a,1					;set up a (test against)
test:
	inc a
	push a					;_DivHLByA destroys a and hl
	push hl
	bcall(_DivHLByA)			;store remainder of hl/a to a
	pop hl					;get back original hl
	jp z,mainloop2				;if hl/a is an integer (new a = 0), hl isn't prime
	pop a					;get a back
	cp hl					;done testing?
	jp nz,test				;if not, jump back to test
	bcall(_DispHL)				;if so, display hl...
	jp mainloop				;and test next hl
.end
END

Follow-Ups: