We have now written a simple Rittle program to print the numbers from 0 to 9. The program can be compiled and executed, stored in a file, or stored as a binary executable file.
Compiling the program is done by dot-command .[
1: var byte a=0;
2: while a<10;
3: print a++,CRLF;
4: until;
5: .[
lines compiled: 4
code length: 48 bytes
5:
Now the program ready for execution with a .> command. In fact the entire compilation and execution process could be expressed in a single line. We might also like to see the compiled binary RVM code by inserting ‘%’ key before the ‘[‘ command (refer back to the help):
5: .%[>
lines compiled: 4
code length: 48 bytes
000000 0f 4b b8 44 .reset K╕D
000004 00 .nop
000005 2a 12 01 00 00 00 .var .sint8 V1
00000b 12 00 .sint8 0
00000d 29 01 00 .set V1
000010 28 01 00 .get V1
000013 12 0a .sint8 10
000015 32 <
000016 0a 2e 00 00 00 .ifnot (addr 0x0000002e)
00001b 28 01 00 .get V1
00001e 28 01 00 .get V1
000021 49 .++
000022 29 01 00 .set V1
000025 38 CRLF
000026 3f print
000027 12 00 .sint8 0
000029 0a 10 00 00 00 .ifnot (addr 0x00000010)
00002e 3f print
00002f 05 .exit
0
1
2
3
4
5
6
7
8
9
>> ok
5:
The program compiled, listed the binary RVM code, and then executed. After it finished, a message ‘>> ok’ was displayed and the editor is ready for more text or new commands.