It is currently Mon Oct 20, 2014 4:01 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: RND Clarification?
PostPosted: Wed Jul 06, 2011 2:20 am 
Offline
User avatar
 Profile

Joined: Mon Jan 24, 2011 6:10 pm
Posts: 29
Rich, I notice your use of the RND function in the demo (nice demo, BTW!), is confined to usage within the EQUB directive, thus making it somewhat static (i.e. generates a random number at assembly, but thereafter, remains fixed).

Is there a way to use this function mid-code to facilitate dynamic random number generation?

(Also, did I read in another thread somewhere that you're working on making usage of such functions non-case sensitive, or am I going through another senior moment? :D ).

Would appreciate any clarification...TIA!


Top
 
 Post subject: Re: RND Clarification?
PostPosted: Wed Jul 06, 2011 7:09 am 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
Hi!

No you can't use RND mid-code because it's not a 6502 subroutine, it's just a function which (like RND in BASIC) just returns a random number when called at assemble-time. So the random number tables will be statically baked into the executable, and contain the same values each time it's run, but different tables would be generated each time it's assembled, if that makes sense.

If you wanted it to be truly dynamic, you'd have to write a 6502 random number subroutine (e.g. the one that tricky posted the other day), and fill out the table at runtime - and even then, you'd have to use some kind of seed based on the current time, otherwise chances are it'd generate the same values each time it was run.

Regarding case-sensitivity in function keywords, I ruled this out and made them upper-case only, because of things like the variable 'hitcount' being interpreted as HI(tcount). On reflection, I could make the brackets part of the keyword, but this'd mean I'd have to rewrite my expression parser, and I didn't really fancy this. Also, BBC BASIC doesn't require brackets around function parameters, and I wanted to keep this compatible.


Top
 
 Post subject: Re: RND Clarification?
PostPosted: Wed Jul 06, 2011 7:55 am 
Offline
User avatar
 Profile

Joined: Mon Jan 24, 2011 6:10 pm
Posts: 29
Just as I figured! Thanks for the clarification ;)


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron