Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:22 11 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : memory pack question

Author Message
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5056
Posted: 10:04am 15 Jan 2025
Copy link to clipboard 
Print this post

All,

This is a generic question about MEMORY PACK and MEMORY UNPACK.
These commands can be used to pack data into 64 bit integers (i.e. 8 bytes per integer).

What I am trying to achieve is packing text (ASCII data) for use in PIO FIFO's.
The FIFO's are 32 bit wide, and a DMA of integers will fill the PIO FIFO 32 bits at at time (2 FIFO locations per integer). But I need to fill the FIFO with text in a$.

I already experimented with peek(varaddr a$) as sourceaddr% and an array%() as destination. But I never seem to get the right mapping of text into the integer to match the FIFO. What I need is

MSByte                      LSbyte
0   0   0  a$:2  0   0   0  a$:1

I currently use a loop (slow) to transfer character for character into integers (1 char per integer), and then pack the integers in a new array (2 char per integer).

But the loop is slow (when the string is long). So I wonder if there is a way to avoid the loop, and use either a single MEMORY PACK, or 2 MEMORY PACK's ...

Any advise ?

Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10232
Posted: 10:12am 15 Jan 2025
Copy link to clipboard 
Print this post

s$="1234567890"
a%=Peek(varaddr s$)+1
Dim o%(4)
b%=Peek(varaddr o%())
Memory copy a%,b%,10,1,4
For i=0 To 4
Print Hex$(o%(i))
Next
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5056
Posted: 10:19am 15 Jan 2025
Copy link to clipboard 
Print this post

Wauw

that is fast....
tested: it works...

Thanks a lot.
Can use this the other way around also.

Volhout
Edited 2025-01-15 20:46 by Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4301
Posted: 02:29pm 15 Jan 2025
Copy link to clipboard 
Print this post

That form of MEMORY COPY doesn't seem to be in the manual.

Would I be correct in assuming it is a byte copy and that the last two parameters are the optional source and destination increments (c.f. MEMORY COPY INTEGER and MEMORY COPY FLOAT).

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10232
Posted: 03:08pm 15 Jan 2025
Copy link to clipboard 
Print this post

Yes, it's a manual omission. I've asked Geoff to update.

You could also do what Harm wants with an UNPACK from char to integer and then a pack from integer to word. Bit clunkier but works fine.

s$="1234567890"
a%=Peek(varaddr s$)+1
Dim o%(9),oo%(4)
Memory unpack a%,o%(),10,8
Memory pack o%(),oo%(),10,32
For i=0 To 4
Print Hex$(oo%(i))
Next
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4301
Posted: 03:47pm 15 Jan 2025
Copy link to clipboard 
Print this post

Thanks Peter, more stuff to go in MMB4L post v0.7.

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
javavi

Guru

Joined: 01/10/2023
Location: Ukraine
Posts: 459
Posted: 04:41pm 15 Jan 2025
Copy link to clipboard 
Print this post

To play music in MOD format, a MODBUFFER is used, which is located in the Pico flash, and each time a composition is loaded, this area of ​​​​flash memory is reflashed, which is not good for intensive listening to many compositions.
Is it possible to make it so that if there is a PSRAM, this MODBUFFER is located in it?
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5056
Posted: 04:54pm 15 Jan 2025
Copy link to clipboard 
Print this post

Javavi,

A system is in place to only reprogram when changed.

Volhout
PicomiteVGA PETSCII ROBOTS
 
javavi

Guru

Joined: 01/10/2023
Location: Ukraine
Posts: 459
Posted: 05:10pm 15 Jan 2025
Copy link to clipboard 
Print this post

  Volhout said  A system is in place to only reprogram when changed.

Yes, but I wrote a music player and just listen to this music for hours and the compositions change one after another continuously.
And I'm already starting to worry about the state of Pico's flash memory!
That's why I'm saying that it wouldn't be bad to have this MODBUFFER in RAM in a configuration with PSRAM.
Edited 2025-01-16 03:12 by javavi
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10232
Posted: 05:25pm 15 Jan 2025
Copy link to clipboard 
Print this post

  Quote  To play music in MOD format, a MODBUFFER is used, which is located in the Pico flash, and each time a composition is loaded, this area of ​​​​flash memory is reflashed, which is not good for intensive listening to many compositions.
Is it possible to make it so that if there is a PSRAM, this MODBUFFER is located in it?


Wrong thread - but good idea


 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025