Author Topic: Compile Time error, what is wrong?  (Read 2350 times)

0 Members and 1 Guest are viewing this topic.

Offline Eleven

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 7
  • Rating: +0/-0
    • View Profile
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:
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 code
Code: [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.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Compile Time error, what is wrong?
« Reply #1 on: June 08, 2011, 03:09:10 pm »
Hopefully these two things should correct the problems:
  • When using sub, do not include the first argument (the a register). Since there is no version of sub that operates on anything besides the a register, the first argument is implied and usually not included, often causing errors when included. So instead of sub a,d, try using sub d.
  • Many assemblers require that labels be followed by a colon, like primelist: - try putting colons after all of your labels.

Also, I see two more lines that would cause problems, although you haven't discovered that they are in error yet because the assembler didn't get that far. jr nc findrestloop and jr z notprime should have a comma between the condition and the label names to separate the two arguments.
« Last Edit: June 08, 2011, 03:11:52 pm by Runer112 »

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Compile Time error, what is wrong?
« Reply #2 on: June 08, 2011, 03:10:29 pm »
sub always substracts from a, so it does only need the register to substract from a

EDIT: ah, nevermind, Runer has already answered that (I was 19 secounds to late)
« Last Edit: June 08, 2011, 03:13:09 pm by ben_g »
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline Mighty Moose

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 141
  • Rating: +4/-0
    • View Profile
Re: Compile Time error, what is wrong?
« Reply #3 on: June 08, 2011, 03:10:48 pm »
'sub a, d' in line 18 is not an assembly command, it's actually just 'sub d' iirc.
Also, try to end your labels with colons (: ) to avoid compile complications like the one at line 12 (end 'primelist' with a ':' ).

Edit: Dang it, double ninja'd
« Last Edit: June 08, 2011, 03:11:40 pm by Mighty Moose »
Cheers!
I beta test, so...yeah.  PM me if you want me to test anything :D.

Almost only counts in horseshoes and handgrenades.

Cogito ergo sum.

Calcs:
TI-84+, OS 2.43, Boot Code 1.02, 128k RAM
TI-84+SE VSC, OS 2.43, Boot Code 1.00, 128k RAM  (I'm spoiled :P)
TI-81, OS 1.6K (only borrowed)
Casio fx-CG10 (Prizm), OS 01.04.0200
TI-Nspire Clickpad, OS 1.4
TI-Nspire Clickpad, OS 3.1.0.392
TI-Nspire CAS Clickpad, OS 1.6.10110 (!?) now OS 3.1.0.392

Offline Eleven

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 7
  • Rating: +0/-0
    • View Profile
Re: Compile Time error, what is wrong?
« Reply #4 on: June 08, 2011, 03:54:47 pm »
ok that solved it indeed: thanks for quick reply(-ies) =D

still doesnt work as supposed, but i'm gonna try to find that one myself.

thx
« Last Edit: June 08, 2011, 03:55:27 pm by Eleven »