User Tools

Site Tools


wswan:guide:memory_management

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wswan:guide:memory_management [2025/04/03 18:10] asiewswan:guide:memory_management [2025/04/03 18:24] (current) – [Addressing RAM and ROM] asie
Line 13: Line 13:
  
 <code C> <code C>
-// The variable below will be stored in IRAM, even if it's declared const.+// The variable below will be stored in IRAM, even if it's declared as read-only (const).
 static const uint16_t table_iram[] = {0, 1, 2, 3}; static const uint16_t table_iram[] = {0, 1, 2, 3};
  
-// The variable below will now be stored in ROM instead of IRAM.+// The variable below will now be stored in ROM instead of IRAM, as it is read-only and far.
 static const uint16_t __far table[] = {0, 1, 2, 3}; static const uint16_t __far table[] = {0, 1, 2, 3};
 +
 +// As will this one, except it's not static, so you can reference it in a .h file...
 +const uint16_t __far global_table[] = {0, 1, 2, 3};
 +
 +// ... like so.
 +extern const uint16_t __far global_table[];
  
 void process_table_iram(uint16_t *tbl); // This function can accept pointers to IRAM only. void process_table_iram(uint16_t *tbl); // This function can accept pointers to IRAM only.
Line 38: Line 44:
  
   * ''.fartext'' - far code, last 768 KiB of ROM   * ''.fartext'' - far code, last 768 KiB of ROM
-  * ''.farrodata'' - far data, last 768 KiB of ROM+  * ''.farrodata'' - far read-only data, last 768 KiB of ROM
   * ''.text'' - code, RAM   * ''.text'' - code, RAM
   * ''.rodata'', ''.data'' - data, RAM   * ''.rodata'', ''.data'' - data, RAM
Line 48: Line 54:
  
 <code> <code>
-    .section .fartext.my_asm_code, "ax" +.section .fartext.my_rom_code_segment, "ax" 
-    .section .farrodata.my_asm_data, "a"+.section .farrodata.my_rom_data_segment, "a
 +.section .text.my_ram_code, "ax" 
 +.section .data.my_ram_data, "aw"
 </code> </code>
  
wswan/guide/memory_management.1743703821.txt.gz · Last modified: 2025/04/03 18:10 by asie