![]() |
Out of memory when using uinteger array (*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: Out of memory when using uinteger array (*solved*) (/showthread.php?tid=354) Pages:
1
2
|
Out of memory when using uinteger array (*solved*) - Darkstar - 06-08-2011 Code: ' tn = TriangleNumber, mt = MaximumTriangles (# of), rn = RandomNumber, GraphicWidth, GraphicHeight, zn = ZeroNumber (Modifier) 'DIM udg(7) AS UBYTE => {0,1,3,7,15,31,63,127} This crashes after a few pixels drawn with an out of memory error while if you use float it works fine under the latest version of the compiler. In version 1.2.6 uinteger works without a hitch. The compilation options are: zxb Triangles.bas --optimize=2 --output=TRIANGLES.ASM --asm --org=24576 --array-base=1 --string-base=1 --heap-size=1024 zxbasm TRIANGLES.ASM --output=TRIANGLES --tap --BASIC --autorun On to another subject, what is the correct syntax for "DIM udg(7) AS UBYTE => {0,1,3,7,15,31,63,127}" as a multidimensional array? I tried "DIM ma(2,2) AS UBYTE => {1,4,6,2,0,55}" but it did not work. Re: Out of memory when using uinteger array - Darkstar - 06-09-2011 "rn=CAST(UINTEGER,RND)*3+1" Crashes the machine, UBYTE as well. Re: Out of memory when using uinteger array - boriel - 07-13-2011 Darkstar Wrote:Sorry for this mega-delay (I'm alive), but I've been *REALLY* busy (okay, I went to NY for two weeks, but had lot of stuff piled up upon return). I will check this ASAP. Quote:On to another subject, what is the correct syntax for "DIM udg(7) AS UBYTE => {0,1,3,7,15,31,63,127}"Use "vector inside vectors": Code: DIM ma(1 TO 2, 2) AS UBYTE => {{1, 4, 6}, {2, 0, 55}} You can read more about it here: <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:DIM">http://www.boriel.com/wiki/en/index.php/ZX_BASIC:DIM</a><!-- m --> Re: Out of memory when using uinteger array - boriel - 07-13-2011 Darkstar Wrote:"rn=CAST(UINTEGER,RND)*3+1"Sorry, I can't make the machine to crash with the above sentence. Is this part of a greater program? Please download the lastest compiler version (1.2.8s703) and check if it work now. Otherwise, send me the --asm generated file of the above sentence to debug it. Re: Out of memory when using uinteger array - boriel - 07-16-2011 Okay, both bugs seems to be related, and fixed. Even more, the compiler produces a little better code now. Download latest version 1.2.8-s705 and tell me if it works, please. Re: Out of memory when using uinteger array - Darkstar - 07-18-2011 Code: ' tn = TriangleNumber, mt = MaximumTriangles (# of), rn = RandomNumber, GraphicWidth, GraphicHeight, zn = ZeroNumber (Modifier) Code: __LABEL__DrawTriangles: I am trying to get rid of the floating point multiplication in the RND section to gain speed. The arrays work fine now thanks, and thanks for the DIM answer; reminds me of context within a context. I had a feeling that those two bugs might be related. Otherwise, I just checked into the forum as I have been really busy so sorry for the late reply to this thread. Re: Out of memory when using uinteger array - Darkstar - 07-18-2011 Code: @echo off This is the compiling BAT file. Re: Out of memory when using uinteger array - boriel - 07-19-2011 Did you download the latest version 1.2.8-s705 (linked above)? I've run your test for about 10 minutes (at x400 speed) and it does not crash on my emulator... :?: Re: Out of memory when using uinteger array - Darkstar - 07-19-2011 Yes of course I did download 1.2.8-s705, even double checked it using the --version switch before proceeding. However I did not delete the old files but just copied over them thus replacing the old files with the new ones. Could that be it? I am using Spectaculator 7.51. Re: Out of memory when using uinteger array - boriel - 07-19-2011 Check the attached TRIANGLES.asm file and compare it with your one. They should be the same (try using something like gvimdiff or the like). I think it could be a good idea to place a comment in the beginning of the ASM file which read something like: ";; Generated by ZX Basic version XXXX". What do you think? Also assemble this file and run it and tell me if it works ok. :roll: Re: Out of memory when using uinteger array - Darkstar - 07-19-2011 Quote:I think it could be a good idea to place a comment in the beginning of the ASM file which read something like: ";; Generated by ZX Basic version XXXX". What do you think? I would think that would be a very good idea to keep track and to avoid confusion. I have a program made for the 16K that takes up all of the lower memory and it's made with 1.2.6 and I have not recompiled it for the new version might run out of memory, so I keep 1.2.6 around. My asm file is 65.286 bytes. Yours is 64.091 bytes. The code for rnd in the zip file: Code: __LABEL__DrawTriangles: Are you sure you compiled it with this statement? "rn=CAST(UINTEGER,RND)*3+1" Re: Out of memory when using uinteger array - boriel - 07-19-2011 Note: CAST(Uinteger, RND) is *always* 0, because RND returns a float number form 0 to 0.99999999... So CAST(Uinteger, RND * 3) will return an Uinteger number between 0 and 2 (which is most likely what you want). I used this 2nd form, and your program works ok. The first ASM chunk you posted corresponds to CAST(Uinteger, RND) * 3 + 1, and won't work. If you use the 1st one your program will looks like crashed but it is not; it's only generating the same "random" (truncated) numbers once and over again (this should happen both in 1.2.6 and 1.2.8). Check this and tell me. Re: Out of memory when using uinteger array - Darkstar - 07-19-2011 "Note: CAST(Uinteger, RND) is *always* 0, because RND returns a float number form 0 to 0.99999999..." I was waiting for that argument somehow. However can you not do a RND that works on integers. I know it can be done ![]() Re: Out of memory when using uinteger array - Darkstar - 07-19-2011 "Check this and tell me." I have checked this back and forth and the current release is stable. Re: Out of memory when using uinteger array - boriel - 07-19-2011 Darkstar Wrote:"Note: CAST(Uinteger, RND) is *always* 0, because RND returns a float number form 0 to 0.99999999..."It is, and very easy indeed, since the main RAND routine generates a 32bits (DE, HL) integer. I can add a library <rand.bas> which contains a randint() routine, for example (it's just a simple call to RAND routine). Try this: Code: function fastcall randint as ULong |