"C Nonsense in BASIC" - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: "C Nonsense in BASIC" (/showthread.php?tid=260) |
"C Nonsense in BASIC" - programandala.net - 06-20-2010 First case I moved the main loop of my program into a sub, but I forgot to call the sub... so the program had nothing to do after DIMing and LETing some variables. The program returned to Sinclair BASIC with the error "C Nonsense in BASIC" instead of "0 OK". Then I wrote a test program: just one sub, not called. The program returned to Sinclar BASIC with "0 OK". Strange. So there's something wrong with my program. If I call the sub, or take its content out of the sub, everything works fine. Second Case But then I moved the main loop (out of any sub) to the end of the program... and the same error happened. I suspected two files I'm including, with character sets in assembler format, had something to do. Here you are schematic versions of both cases: This one works fine: Code: ' ....most of the program here...... But this one simply returns with "Nonsense in basic": Code: ' ....most of the program here...... Both included files have the same structure: Code: label: So? Both cases are not the same, but I suspected the included files are the reason of the strange error in the first case, when there was nothing to exectute; and the fact than the main loop is not found in the second case, and the error is returned. I kept the main loop at the end of the program and removed the #includes. The program worked fine! Case 2 confirmed. Then I moved the main loop into a sub but didn't called the sub... The program returned with a "0 OK" message as expected! Case 1 confirmed. Will it happen with explicit (not #included) ASM sections? Let's see. I added some assembler lines right before the main loop sub, but the message was still "0 OK". It seems the strange behaviour is caused by #including the ASM sections. Am I doing something wrong? Is there any limitation about the location of ASM sections or its including? Re: "C Nonsense in BASIC" - boriel - 06-20-2010 Since you are working in MACHINE CODE, you must be careful when including binary files. What is happening there is the program execution is entering the charset.bas file and executing it as machine code. Such case is equivalent to this: Code: PRINT "HELLO WORLD" To ensure the execution never reaches the included data files, just place an END. This will exit your program gracefully: Code: PRINT "HELLO WORLD" Re: "C Nonsense in BASIC" - LCD - 06-20-2010 Move the inclusions after the program (after a END instruction) because if there is a ASM block inside program execution, the Spectrun does not know that this is only DATA, he thinks that is is a Assembler program and tries to execute it. But it does not contain a valid program. This is not a bug, this is normal behaviour of any computer. Edit: Boriel was faster... Re: "C Nonsense in BASIC" - programandala.net - 06-20-2010 boriel Wrote:To ensure the execution never reaches the included data files, just place an END. This will exit your program gracefully: Ahhhhhhhhhhhh I'm executing the bytes of the charset, whatever they do I forgot it's inline machine code right into the compiled code. Thank you. Re: "C Nonsense in BASIC" - programandala.net - 06-20-2010 LCD Wrote:if there is a ASM block inside program execution... Thank you too for the answer. By the way, this makes me remember something: these days I've been thinking about and old project of mine, a huge text adventure written in Z80 assembler for the Spectrum. I worked on it for years in the 80's and the 90's. 700 KiB of pure assembler. It's unfinished but its language parser and its virtual world are very advanced (even by today standards in modern platforms). I've been thinking of resurrecting the project... with the help of ZX BASIC. My idea is to keep all the assembler algorithms and data under a new layer of compiled BASIC. They could mix perfectly... as I've just realized Re: "C Nonsense in BASIC" - LCD - 06-20-2010 I plan to resurrect some of my old projects too. Currently for testing the BorIDE I'm working on a very old project of me, called "Youkai Harvest" (it was planed as "Monster Dinner" in the 90's). Found the drafts some months ago again, But there are also more projects to resurrect after the BorIDE is finished. |