![]() |
Forum Index : Microcontroller and PC projects : CMM2: arbitrary memory copy routine ?
Author | Message | ||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Is there a command for arbitrarily copying bytes of memory around that I have missed, e.g. BLIT MEM src_adr, dst_adr, num_bytes If not then could it be added to the list of possibilities for 5.05.07, I don't think there are enough ways for us to crash the firmware ![]() Seriously though it would be useful for more efficient string storage and implementation of some datastructure manipulations such as insertion into an array without having to resort to a CSUB. Tom Edited 2020-10-30 00:04 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Try MEMORY COPY sourceaddress, destinationaddres, numberofbytes ![]() You can also try: MEMORY SET address, byte, numberofbytes MEMORY SET BYTE address, byte, numberofbytes MEMORY SET SHORT address, short, numberofshorts '2 bytes per short MEMORY SET WORD address, word, numberofwords '4 bytes per word MEMORY SET INTEGER address, integer, numberofintegers '8bytes per integer MEMORY SET FLOAT address, float, numberoffloats '8 bytes per float |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Wow, when did we get those ![]() ![]() ![]() Please note they do not appear to be in the manual accompanying the lastest firmware RC. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
NPHighview![]() Senior Member ![]() Joined: 02/09/2020 Location: United StatesPosts: 203 |
I suspect Peter has many such tricks up his sleeve :-) And documentation always lags :-( Live in the Future. It's Just Starting Now! |
||||
MustardMan![]() Senior Member ![]() Joined: 30/08/2019 Location: AustraliaPosts: 175 |
Very nice! Is this a CMM specific addition, or does it apply to lower grade devices as well (I have an Explore 100: PIC32MX470)? Cheers, |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Only CMM2 but some of the new functions will filter down to the other variants. It is a useful addition to the MATHs functions. As a test, I filled a subset of elements in an array. Useful for clearing part of an array or moving data arround quickly. dim integer bigarray(20) dim integer n, x, addr, startfill x = 99 'find the starting address of the target array addr = PEEK(VARADDR bigarray()) ' set the starting point to the 5th array element startfill = addr + 8*5 ' fill 10 array elements starting at element 5 memory set integer startfill, x, 10 'show the results for n = 0 to 20 print n,bigarray(n) next n Output: 0 0 1 0 2 0 3 0 4 0 5 99 6 99 7 99 8 99 9 99 10 99 11 99 12 99 13 99 14 99 15 0 16 0 17 0 18 0 19 0 20 0 Jim VK7JH MMedit |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
New functionality in RC10 just posted MEMORY SET INTEGER address, integervalue ,numberofintegers [,increment] MEMORY SET FLOAT address, floatingvalue ,numberofloats [,increment] MEMORY COPY INTEGER sourceaddress, destinationaddress, numberofintegers [,sourceincrement][,destinationincrement] MEMORY COPY FLOAT sourceaddress, destinationaddress, numberoffloats [,sourceincrement][,destinationincrement] Together these allow you to crash the system in more ways than you can imagine but more importantly they allow for very fast copies between single and multidimensional arrays i.e array slicing. In all cases the increments default to one unless specified. option explicit option default none dim float sourcearray(3,39),destinationarray(39),d2array(39),x=99.99 dim integer n, addr, addr2, addr3 'find the starting address of the source 2 dimensional array addr = PEEK(VARADDR sourcearray()) 'find the starting address of the first desination 1 dimensional array addr2 = PEEK(VARADDR destinationarray()) 'find the starting address of the second desination 1 dimensional array addr3 = PEEK(VARADDR d2array()) ' fill 160 array elements starting at element 0,0 memory set float addr, x,160 'now make some changes to the source array to prove it all works for n=0 to 39: sourcearray(2,n)=n:next n 'copy the sourcearray(0,all) to destinationarray memory copy float addr, addr2,40,BOUND(sourcearray(),1)-BOUND(sourcearray(),0)+1,1 'now point to the start of the second dimension in the source array addr = addr + 8*2 'copy the sourcearray(2,all) to destinationarray2 memory copy float addr, addr3,40,BOUND(sourcearray(),1)-BOUND(sourcearray(),0)+1,1 'show the results for n = 0 to 39 print n,sourcearray(0,n),sourcearray(2,n),destinationarray(n),d2array(n) next n For large arrays this will be massively faster than using Basic FOR loops Edited 2020-10-31 03:07 by matherp |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Hi Peter! Where? Regards Michael causality ≠correlation ≠coincidence |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Usual place http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Contains CMM2V5.05.05RC9.bin causality ≠correlation ≠coincidence |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Try clearing your cache or similar and try again - works for me |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Try clearing your cache or similar and try again - works for me I confirm. causality ≠correlation ≠coincidence |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |