Schrijver
| How do i create a loop using MSX BASIC?
|
GuyveR800 msx guru Berichten: 3048 | Geplaatst: 21 September 2003, 01:05   |
Hmz, it appears you're right 
Anyway... I'm a big proponent of extending the MSX BASIC a bit, more in the direction of QBASIC (although SUB's suck). Time is not on my side however  |
|
djh1697 online msx professional Berichten: 542 | Geplaatst: 21 September 2003, 11:50   |
Quote:
| Yeah there is, but you still need the command "GOTO"
10 i=0 ' initialize
20 'Do
30 'do the loop instructions
40 if i<5 then goto 20 'Loop while i<5
|
of course you could always count backwards
10 loop=5 (or what ever value you want)
20 'loop instruction(s)
20 loop=loop-1
30 if loop<>0 then goto 20
I used to do a lot of machine code programming - on MSX and other 8 bit machines, to count backwards was a lot easier
When you had completed the loop intructions it was a simple case of doing a DEC instruction followed by an XOR intruction. If the result was a none zero you needed to rerun the loop. |
|
GuyveR800 msx guru Berichten: 3048 | Geplaatst: 21 September 2003, 13:56   |
Quote:
| 10 loop=5 (or what ever value you want)
20 'loop instruction(s)
20 loop=loop-1
30 if loop<>0 then goto 20
I used to do a lot of machine code programming - on MSX and other 8 bit machines, to count backwards was a lot easier
|
10 for loop=5 to 1 step -1
20 ' loop instructions
30 next
faster and easier... |
|
wolf_
 msx legend Berichten: 4663 | Geplaatst: 21 September 2003, 14:03   |
depends on what you wish to do with the loop
if you want to draw pixels from (0,0) to (255,0)
then counting from 0 .. endvalue..
for x=0 to 255
pset(x,0),15
next
is more logical..
..I wouldn't want to count backwards here..
|
|
Necron msx lover Berichten: 108 | Geplaatst: 22 September 2003, 17:42   |
Why do you say that the SUB from QBasico sucks? It is an usefull tool...
|
|
msd msx professional Berichten: 608 | Geplaatst: 22 September 2003, 18:27   |
Counting backwords is amlost for every cpu easier,since the zero flag is set after a dec and no extra compare is needed. Most compilers suck when makeing loops, always a lot of extra jumps etc.
|
|
GuyveR800 msx guru Berichten: 3048 | Geplaatst: 22 September 2003, 20:22   |
Also, there's DJNZ.
Funny enough, the x86 equivalent LOOP is discouraged for AMD processors (and Intel too I believe) in favour of a seperate decrease+jump. x86 is such a hack nowadays ^^;
|
|
GuyveR800 msx guru Berichten: 3048 | Geplaatst: 22 September 2003, 20:23   |
Quote:
| Why do you say that the SUB from QBasico sucks? It is an usefull tool...
|
Mwah... It's a bit half-assed.. with stupid local variables and ... it just complicates matters too much for a beginners language that BASIC is supposed to be. |
|
Necron msx lover Berichten: 108 | Geplaatst: 24 September 2003, 22:06   |
Quote:
|
Mwah... It's a bit half-assed.. with stupid local variables and ... it just complicates matters too much for a beginners language that BASIC is supposed to be.
|
Come onnnn... Life is beautiful... Don't be so hard to the SUB... haha  |
|
Yukio msx professional Berichten: 778 | Geplaatst: 17 September 2005, 05:17   |
1 for x%=1 to 2
2 if (YourCondition) = (YourCriteria) then x%=2 else x%=1
3 next
 |
|
Yukio msx professional Berichten: 778 | Geplaatst: 17 September 2005, 05:19   |
for x%=1 to 2: if (condition)=(criteria) then x%=2 else x%=1
next
|
|
ibanezman1990 msx user Berichten: 40 | Geplaatst: 15 Maart 2006, 08:37   |
Or like this:
10 Cls
20 Print "MSX RESOURCE CENTRE"
30 Beep
40 Goto 20
|
|
BiFi msx guru Berichten: 3142 | Geplaatst: 15 Maart 2006, 09:20   |
1 CLS:PRINT"MRC":BEEP:POKE-609,118 |
|
MäSäXi msx addict Berichten: 418 | Geplaatst: 29 Maart 2006, 11:14   |
Quote:
| WHILE...WEND and DO...LOOP
|
I remember BBC had something like that in it´s BASIC.  And MSX is atleast 23 years old.
|
|
AuroraMSX
 msx master Berichten: 1231 | Geplaatst: 29 Maart 2006, 17:44   |
Quote:
|
for x%=1 to 2: if (condition)=(criteria) then x%=2 else x%=1
next
|
DEFINT X
FOR X=1 TO 2
X = 1 - (condition)=(criteria)
NEXT
'condition = criteria' evaluates to either 0 (false) or -1 (true).
So, X will become 1 when the equation is false/0 and 2 when the equation is true/-1 ...
|
|
|
|
|