Poster: Shaos Subject: Re: RW1P2 - crosstool for development Sprinter soft | RW1P2 - Crosstool for develop sprite-oriented grafics software for Sprinter,ZX-Spectrum,Orion-128,Specialist,Radio-86RK.
Used RW1 programming language (see http://robots.shaos.ru). Syntax is similar to C-language.
I can offer two programs for show differences between C and RW1:
// hello.c
#include <stdio.h>
main()
{
printf("Hello, World")
}
// hello.rw1
robot "Hello"
author "A.Shabarshin"
main()
{
say "Hello, World"
}
So, RW1 program is "robot" with "author" and main function. At present I develop HELP in English. There is old english documentation.
Similarity C and RW1:
- function main()
- structure if(){...} else{...}
- structure for(;;){...} with break and continue
- structure while(){...} with break and continue
- structure do{...}while() with break and continue
- command goto Label
- command return Expr at end of functions (only v2.1 and above)
RW1 don't have:
- structure switch(){case...} and instead
switch(var)
{
case 0: ok=1; break;
case 2: ok=2; break;
case 3: ok=10; break;
}
we will write
def labs[4]={lab0,0,lab2,lab3}
goto labs[var]
lab0: ok=1; goto end
lab2: ok=2; goto end
lab3: ok=10; goto end
end:
- not support functions that may be used inside expressions (largest minus), but RW1 have "procedures" (in pascal terms) or in other words - functions that may be used inside program body or functions body, not in expressions. And you may use macros inside expressions. See RW1_STD.RWI include file:
@if(3)=((@1)?(@2):(@3))
@max(2)=(((@1)>(@2))?(@1):(@2))
@min(2)=(((@1)<(@2))?(@1):(@2))
@abs(1)=(((@1)<0)?(-(@1)):(@1))
@sqr(1)=((@1)*(@1))
@mod(2)=((@1)%(@2))
@and(2)=((@1)&&(@2))
@or(2)=((@1)||(@2))
@not(1)=(!(@1))
@neg(1)=(-(@1))
If you want use @max macro definition than
aa=10;bb=20;cc=@max(aa,bb)
So cc will be equal 20
- RW1 don't have multidimensional arrays - only onedimention
- variables have size only 16-bit signed (-32768...+32767)
Alexander Shabarshin (shaos@mail.ru)
http://www.shaos.ru
|
|