1
ASM / Compile Time error, what is wrong?
« on: June 08, 2011, 03:02:35 pm »
hi all, i am new to assambly, was messing around with a little prime-number finder (checks for all numbers 2-->255 if they're prime, and saves them to calculate the next)
spasm keeps giving mee these errors, and i can't find the problem (i use both Hot-Dog's tutorial as the "learn ASM in 28 days"-guide as references, but am still stuck)
the errors:
what is wrong?
oh yeah and i know this probably won't be the best solution to the problem, but i just want to experiment a bit with the code.
spasm keeps giving mee these errors, and i can't find the problem (i use both Hot-Dog's tutorial as the "learn ASM in 28 days"-guide as references, but am still stuck)
the errors:
Code: [Select]
Template.asm:18: error: SUB doesn't take these arguments
Pass two...
Template.asm:12: error: 'primelist' isn't a macro or label
Done
the codeCode: [Select]
#include "ti83plus.inc" ; a program that finds all
.org $9D93 ; prime numbers up to 255
.db t2ByteTok, tAsmCmp
B_CALL _ClrLCDFull
ld c,1 ; c = # known primes
ld b,$FD ; b counts from 253->0
outerloop
ld a,b
cpl ; e counts from 2-->255
ld a,e ; and preserves b's cpl
ld b,c
ld hl,primelist
innerloop ; we loop through known primes
ld a,(hl)
ld d,a ; d = a known prime
ld a,e
findrestloop
sub a,d ; finds rest of e/d , ugly but
jr nc findrestloop
add a,d
or a ; a = rest: rest =0 -> e != prime
jr z notprime
inc hl ; next known prime adress
djnz innerloop
prime ;only for reference
ld a,e
ld (hl),a
inc c
ld hl,0 ; e is prime, added in next adress
ld l,a
push bc
push de ; save bc and de for later
b_call(_dispHL) ; disp found prime
pop de ; de and bc will be needed
pop bc
noprime
ld a,e
cpl ; recall b = cpl e
ld b,a
djnz outerloop ; find next prime
ret
primelist ; the list with the primes, starts
.db 2 ; with 1 known value: 2
what is wrong?
oh yeah and i know this probably won't be the best solution to the problem, but i just want to experiment a bit with the code.