FAQ  •  Register  •  Login

GOTO (arithmetical expression)

<<

JBGV

Posts: 55

Joined: Wed Feb 16, 2011 6:12 am

Post Mon May 09, 2011 8:23 pm

GOTO (arithmetical expression)

Hello!

Could anyone tell me how I can simulate "GOTO (arithmetical expression)":

ex:

  Code:
N can have a value between 1 and 20

GOTO (1000+(N*10))


I need to assign values ​​to an array depends on the value "N", I had thought something like this:

  Code:
ASM
ORG 62000
DEFB 12,5,8,11,12,11,4,11,(...)       
END ASM

DIM P(7) AS UBYTE

...

N=20

...

FOR B=0 TO 7
P(B)=PEEK (62000+N+B)
NEXT B


Is this efficient?

Is there a danger that the program itself erase the data stored at positions 62000?

THANKS
<<

LCD

Posts: 507

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Wed May 11, 2011 8:01 am

Re: GOTO (arithmetical expression)

Line numbers? this is stone age! just make a buffer and calculate the offset to copy the data from memory to variable array.

pseudocode, as I'm at work now:
  Code:
address=@labelofdata+size*n
copymemory(address,@p(),size)

There is a include for copymemory...
This if efficiency! GoTo calculation was working only in HiSoft Basic compiler, but you had do define all possible lines for calculated jumps with REM: GOTO directive. With more programming experience there is absolutly no need for calculated goto.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

JBGV

Posts: 55

Joined: Wed Feb 16, 2011 6:12 am

Post Wed May 11, 2011 8:01 pm

Re: GOTO (arithmetical expression)

Copymemory, Thanks ¡

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO