![]() |
Forum Index : Microcontroller and PC projects : CMM2 Large Integer Array Issue
Author | Message | ||||
GerryL Newbie ![]() Joined: 24/01/2019 Location: AustraliaPosts: 39 |
Note sure if I'm doing something wrong in assuming an integer array, DisplayLoc in program below, to be 64kb in size by declaring an array of 8000 integers but it doesn't appear to be 64kb in size. In the program below reading and writing to the 64kb array up to &HFA00 works fine but writing to the other array, DisplayLoc, interferes with the 64kb array data above location &HFB00. Setting the size of the 64kb to 8100 integers fixes the issue, even up to &HFFFF. The test program is, OPTION EXPLICIT OPTION DEFAULT NONE OPTION CONSOLE SERIAL DIM AS INTEGER DisplayLoc(15,3) DIM AS INTEGER Memory64k(8000) ' 64k data POKE VAR Memory64k(), &HFA00, 33 ' put 33 at byte location FA00 print "BEFORE FA00 = ", PEEK(VAR Memory64k(), &HFA00) DisplayLoc(0,0) = 200 print "AFTER FA00 = ", PEEK(VAR Memory64k(), &HFA00) POKE VAR Memory64k(), &HFB00, 33 ' put 33 at byte location FB00 print "BEFORE FB00 = ", PEEK(VAR Memory64k(), &HFB00) DisplayLoc(0,0) = 200 print "AFTER FB00 = ", PEEK(VAR Memory64k(), &HFB00) The program output is, BEFORE FA00 = 33 AFTER FA00 = 33 ' this is good BEFORE FB00 = 33 AFTER FB00 = 200 ' this is not so good Details are: CMM2 Firmware Version 5.0702 Option List CURRENT VGA mode 800x600 RGB332 CURRENT DISPLAY 50,100 OPTION USBKEYBOARD US OPTION MOUSE 0,4 OPTION RAM ON OPTION MAXCTRLS 100 Note that the issue is the same when using OPTION FLASH The memory check printout below may indicate that the array is not 64k long > memory Program: 1K ( 1%) Program (15 lines) 515K (99%) Free Data: 63K ( 1%) 2 Variables 0K ( 0%) General 4764K (99%) Free As mentioned I'm working around this by declaring the array to be 8100 integers so not a big issue as the CMM2 has stax of variable memory but it would be interesting to know why it does this. Gerry |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5089 |
The first entry in the array is 0, so when you declare an array size 8000, then it contains 8001 variables. PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
You can, of course, use OPTION BASE 1 to start the array at element 1. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
Isn't &HFB00 (64256 decimal) outside the array? John Edited 2021-12-28 18:30 by JohnS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
An array specified as DIM a%(8000) is 64008 bytes long /1024 = 62K bytes long An array specified as DIM b%(15,3) is 512 bytes long hence total rounded up of 63K bytes As John says &HFB00 is well outside the limits of a% which finishes at &HFA07 so poking it will corrupt the following array Much better to forget POKE and stick to array indicies ![]() |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
64kB array should be DIM AS INTEGER Memory64k(8192) ' 64k data Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
GerryL Newbie ![]() Joined: 24/01/2019 Location: AustraliaPosts: 39 |
Thanks guys, you have set me straight, appreciate the feedback. Gerry |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |