Skip to content

Assignment From Pointer To Non-Enclosed Address Space Needle

Split the string into several tokens which can be accessed by successive calls to av_strtok().

A token is defined as a sequence of characters not belonging to the set specified in delim.

On the first call to av_strtok(), s should point to the string to parse, and the value of saveptr is ignored. In subsequent calls, s should be NULL, and saveptr should be unchanged since the previous call.

This function is similar to strtok_r() defined in POSIX.1.

Parameters
sthe string to parse, may be NULL
delim0-terminated list of token delimiters, must be non-NULL
saveptruser-provided pointer which points to stored information necessary for av_strtok() to continue scanning the same string. saveptr is updated to point to the next character after the first delimiter found, or to NULL if the string was terminated
Returns
the found token, or NULL when no token is found

Definition at line 183 of file avstring.c.

Referenced by config_input(), config_output(), fill_items(), frei0r_init(), ftp_auth(), ftp_passive_mode(), get_cookies(), init(), libssh_open(), main(), movie_common_init(), opt_preset(), parse_bsfs(), parse_channel_expressions(), parse_frames(), parse_interval(), parse_times(), and sami_paragraph_to_ass().

The data you're describing (full 24-bit use of program memory to store data) cannot be defined and initialized in C, and cannot read directly via C; the only way to access it is by encapsulating in a C-callable assembly function or an intrinsic.

There are really two questions here:

  1. how to play nicely with the compiler, assembler, and linker, so that when you define your 24-bit data in an assembly file as relocatable data with a symbolic name , rather than unnamed data at a fixed address, the compiler can see this variable to determine its address

  2. how to access the data

The 2nd question (how to access the data) is answered for 33EP parts in DS70613C and should be answered for 33FJ parts in DS70204C (but the examples in the 33FJ manual only use the low 16 bits). Here's an example code snippet from the 33EP reference manual that works for 33EP parts + should for 33FJ (I don't have a 33FJ device easily available):

(note: code uses , whereas it would be better to use and )

You'll note that the builtin functions and are used to read the low and high 16-bit words of data from a program memory location, and can be used to extract the page and offset of the address. In this particular example, the highWord array is always 0, and the lowWord array matches the prog_data defined and initialized in C.

Please note no pointers are used here! Although it is possible to use normal variables that are tagged with , so that they are located by the linker in read-only program space, and so that you can read the memory using standard C pointer techniques, with the compiler automatically managing the paging registers for you, you can only store 16-bit data. You need to access the TBLRDL and TBLRDH builtin functions to get all 24 bits of data.

As for how to play nicely with the compiler/linker/etc, you have to fool the compiler and tell it it's only seeing 16-bit data. Here's an example that worked to get at the variable D1 declared elsewhere:

This does correctly read 24-bit values and stores them in the bottom 24 bits of a uint32_t. The extern D1 variable declared in C is a dummy variable that is only used to get at the starting address by taking advantage of the way the compiler/assembler/linker work together. The builtin functions handle the rest of the work.

What I don't know is how to automatically obtain the size of the data, since it's defined + initialized in assembly.

answered Mar 4 '13 at 23:13