Jump to content


Action! - initializing an INT array with negative numbers


3 replies to this topic

#1 slx OFFLINE  



  • 1,461 posts
  • Location:Vienna, Austria

Posted Sun Aug 5, 2018 12:14 PM

My son tried the following in Action! (version 3.7)

INT Array x=[-1 -2 -3 -4]

This results in an Error 9. The same happens when initializing a single INT to a negative value. Parentheses around the (-1) make no difference.


I didn't find anything in the the manual that would prohibit initializing to negative numbers.


Any ideas how to work around this or where/how to store values to initialize the array after it has been declared?

Edited by slx, Mon Aug 6, 2018 2:26 AM.

#2 joyfulcoder OFFLINE  


    Star Raider

  • 96 posts
  • Location:Western Mass

Posted Mon Aug 6, 2018 7:53 PM

a work around:

INT Array x=[65535 65534 65533 65532]

#3 slx OFFLINE  



  • Topic Starter
  • 1,461 posts
  • Location:Vienna, Austria

Posted Fri Aug 10, 2018 6:25 AM

Would still be interesting why it doesn't work as documented. 

#4 Alfred OFFLINE  



  • 292 posts
  • Location:Elmwood, Ontario

Posted Fri Aug 10, 2018 6:56 PM

It doesn't work because the =[  ] data storing routine is looking for constants:


;       GetConst(token)
;       ---------------
gconst ldy       #cnserr
        cmp     #$81
        bcc     adrerr
        cmp     #constt+strt
        bcs     adrerr
        lda     nxtadr
        ldx     nxtadr+1


The A register is holding the token for the "-" minus symbol, not the value, and thus it fails the test. There's a few things that would have to be changed to allow for the presence of unary minus, like mnum would have to be updated to invoke part of the expression evaluator to process the constant.  I expect he left it this way because it's so much simpler, and can be worked around. Don't forget, the cartridge is really tight for space.

Also tagged with one or more of these keywords: Action!

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users