I remember having read a elaboration (in this forum?) on how WHILE/WEND was implemented on some Basic extension.
Roughly, the scheme was that during the RUN command, the WHILEs and WENDs were searched in the programtext and associated link-pointers were filled in, before the actual program was started.
Does anybody have a suggestion as to where I might find this article ?
Regards,
Wim.
WHILE-WEND implementation in WimBasic
Moderator: Moderators
-
- Vic 20 Afficionado
- Posts: 345
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
WHILE-WEND implementation in WimBasic
Last edited by wimoos on Thu Nov 14, 2013 1:58 am, edited 1 time in total.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
- Mike
- Herr VC
- Posts: 4816
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: How to implement WHILE-WEND
Waterloo BASIC speeds up the processing of its program flow control commands this way. This applies to IF blocks, loop constructs and procedure calls. I briefly mentioned the 3-byte tokens used for that purpose in a posting here.
From what I remember, the extension does not go over the whole program as a preparing step after RUN and before starting the execution, but fills in the TXTPTR fields only on a per-use basis and clears them all when the program is edited or has just been loaded.
From what I remember, the extension does not go over the whole program as a preparing step after RUN and before starting the execution, but fills in the TXTPTR fields only on a per-use basis and clears them all when the program is edited or has just been loaded.
-
- Vic 20 Afficionado
- Posts: 345
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
@moderator: please delete this post
Last edited by wimoos on Tue Nov 19, 2013 2:56 pm, edited 1 time in total.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
-
- Vic 20 Afficionado
- Posts: 345
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
Re: WHILE-WEND implementation in WimBasic
Hello all,
I have now added WHILE-WEND to WimBasic, which is available in a 6502 and a 65C02 version at http://wimbasic.webs.com/wimbasic.zip .
WHILE and WEND in WimBasic are not constrained to a first position in the programline like in Waterloo. Example:
WHILE-WENDs may be nested.
A premature break from the WHILE-WEND loop can be done through the QUIT statement. Processing then resumes after the corresponding WEND statement.
For those interested in testing, you're invited to do so. Please let me know what you find.
An interesting addition to this is the IF A$ THEN quirk in CBM Basic that got also inherited in WimBasic. This gives the opportunity to test after WEND how the loop was ended.
Regards,
Wim.
I have now added WHILE-WEND to WimBasic, which is available in a 6502 and a 65C02 version at http://wimbasic.webs.com/wimbasic.zip .
WHILE and WEND in WimBasic are not constrained to a first position in the programline like in Waterloo. Example:
Code: Select all
10 A=TI+200:WHILE TI<A:WEND
A premature break from the WHILE-WEND loop can be done through the QUIT statement. Processing then resumes after the corresponding WEND statement.
Code: Select all
10 WHILE 1
20 GET A$:IF A$>"" THEN QUIT
25 PRINT "PRESS A KEY..."
30 WEND
An interesting addition to this is the IF A$ THEN quirk in CBM Basic that got also inherited in WimBasic. This gives the opportunity to test after WEND how the loop was ended.
Code: Select all
WHILE <boolean1>
...
IF <boolean2> QUIT
...
WEND
IF A$ THEN <loop ended because boolean2 was true> ELSE <loop ended because boolean1 was false>
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic