Jump to content

Bug in VARPTR used with constant arrays


Recommended Posts

I'm sorry I return on the topic but something strange is happening with varptr...


This lines do not work, as intybasic keeps telling that the expression is not constant


    const #max_bit_index = (VARPTR #bitstream_end(0) - VARPTR #bitstream(0)) * 16


but it is very constant as  the arrays are

 DATA     &1001100110011001,&1001100110011001,&1001100110011001,&1001100110011001,&1001100110011001



Moreover, I spotted that randomly, if I use the minuscule varprt, sometimes it does not compile, telling that some brackets is odd


    #max_bit_index = (varprt #bitstream_end(0) - varprt #bitstream(0)) * 16


It is like varprt (in minuscule) sometimes is confused by a variable name....


Link to comment
Share on other sites

For the first problem, I just checked that the compiler does not evaluate VARPTR as a numeric expression.  From "eval_leval7()" It returns:

return new node(C_NAME_R, temp, NULL, NULL);

But the "Const" parser is checking exclusively for "C_NUM" type.  This seems to be a current limitation or an oversight.



For the second problem, it's ... a little more silly.  You've mistyped "VARPTR" in lower-case:  You've put the "R" before the "T", "VARPRT".  If you correct that, it'll work.


I recommend enabling "Option Explicit" to catch these sort of errors.  You'll have to declare all your variables before hand, but in my opinion it is worth it.  With "Option Explicit" the error I get is:

Error: variable 'VARPRT' not defined previously in line 23
Error: missing right parenthesis in line 23

Where the first line makes it obvious that there is a typo.



Edited by DZ-Jay
Link to comment
Share on other sites

On the 1st problem, I've seen CONST limitations, DEF FN can be used as a workaround.

'asm BitStreamX: EQU ((label_BITSTREAM_END - label_BITSTREAM) * 16)
DEF FN BitStream =  ((VARPTR bitstream_end(0) - VARPTR bitstream(0)) * 16)
'PRINT AT 120,<>BitStream 

Too bad IntyBasic can't use asm constants. I'd probably use placeholder IntyBasic constants, then replace them in the final .asm source.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...