![]() |
What's wrong with this? (*solved*) - 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: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15) +---- Thread: What's wrong with this? (*solved*) (/showthread.php?tid=479) |
What's wrong with this? (*solved*) - na_th_an - 07-26-2012 Maybe I'm just being thick: Code: Sub Fastcall tdPutChar (c as uByte) Compiler output: Code: H:\Dev\Speccy\mt64x32lib\zxbasic>c:\zxb\zxb textdongle.bas Re: What's wrong with this? - na_th_an - 07-26-2012 The compiler seems to crash whenever I add a subroutine which gets a String parameter. I remove such subs, it works. I add them, even empty, the compiler crashes. Unless I'm missing something quite obvious. Re: What's wrong with this? - LCD - 07-26-2012 Maybe it is not a good idea to try to put a string into byte? Quote:cad As String -> tdPutChar (cad (i)) -> tdPutChar (c as uByte) Re: What's wrong with this? - na_th_an - 07-26-2012 I've tried that. The compiler crashes on the assignment. It doesn't like it. Code: Sub Fastcall tdPutChar (c as uByte) Output: Code: H:\Dev\Speccy\mt64x32lib\zxbasic>c:\zxb\zxb textdongle.bas The problem has to be the cad (i) thing. Any other way to access a single char within a string? EDIT: I've found "mid$" inside string.bas in the library. If I take just that function and add it to my code, replacing the cad (i) for mid (cad, i, 1), I still get the same crash, but inside the mid$ function. Code: function mid$ (ByVal s$, ByVal x As Uinteger, ByVal n As Uinteger) Broken compiler? Re: What's wrong with this? - na_th_an - 07-26-2012 Solved. I was missing a "VAL" (I was just being thick and I was "thinking in C") Code: c = val (cad (i)) I got the clue from v.1.2.8 (which raises an error telling you about VAL being needed). Anyways, v.1.2.9-s888 should be fixed not to crash on such error :-) Re: What's wrong with this? - boriel - 07-26-2012 na_th_an Wrote:Maybe I'm just being thick:Despite of the syntactic/semantic error, this is a compiler bug: the compiler should *NEVER* crash, regardless of the input source code. This is something to be fixed. Also, check for IX/IY when using your routines or IM, since ZX BASIC requires IX for functions, and IY are used for some ROM routines called by ZX BASIC (even for Timer/Interrupt routines). So if you're experiencing some strange crashed, try to push/pop IX and IY on your routines to see if it works. Also, remember the stack is at 32767 or even lower, so when it reaches the BASIC or ROM Variables zone, it could also crash your program. PD: I'm on vacation (yes in the Canaries 8) ) => <!-- m --><a class="postlink" href="http://p.twimg.com/AykD5bpCMAA7Fhp.jpg">http://p.twimg.com/AykD5bpCMAA7Fhp.jpg</a><!-- m --> Re: What's wrong with this? - na_th_an - 07-27-2012 Hah nice picture ![]() The compiler tends to crash on me quite a lot :lol: I promise I will report next time (most of the time I don't have internet around, I find a walkaround, and then forget, sorry). Re: What's wrong with this? - boriel - 07-27-2012 na_th_an Wrote:Hah nice pictureIf you get to crash the compiler, please, paste the code sequence here. It will help me a lot :!: PD: I'm back at home 8) Re: What's wrong with this? - boriel - 07-28-2012 Update: Notice the compiler crash at syntax_error function. In fact, your program effectively has a syntax (semantic) error. BASIC is not C: cad$(i) is not a char; it's a String of length 1. You're trying to coerce cad$(i) into Ubyte. Use CODE(cad$(i)) for that, or ASC: Code: Sub Fastcall tdPutChar (c as uByte) Re: What's wrong with this? - LCD - 07-28-2012 Thats what i meant with: cad As String -> tdPutChar (cad (i)) -> tdPutChar (c as uByte) cad is defined as string, tdPutChar call sends a string char but SUB tdPutChar expects a uByte. To avoid this mistake String should have the $ suffix. The only reason for using STRING would be POKE STRING or PEEK(STRING) but it does not work. Re: What's wrong with this? - boriel - 07-29-2012 Plaese, download the latest version: <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Archive#Latest_Development_Version">http://www.boriel.com/wiki/en/index.php ... nt_Version</a><!-- m --> the compiler should not crash with this error anymore. Re: What's wrong with this? - na_th_an - 07-30-2012 Thank you ![]() |