Sram hunting - #305
Conversation
Otherwise it is put on SRAM location.
This reflexs the function better. Moving `byte` arguments to __xdata which saves 1 SRAM byte.
saves 4 bytes.
Refactor some code. Saves 2 bytes.
Saves 10-bytes.
Save atleast 2 bytes.
|
Nice direction — the double- Caveat up front: this is build-time analysis only. I have not flashed or run any of these images on hardware, so nothing below says the SFP path still works — only that the code still compiles, links, and emits the same bytes. Measured deltasFull builds,
So −10 bytes of internal RAM, at a cost of +18 B XDATA and +218 B ROM. Consistent across all three. Good trade here given the linker already says I couldn't reproduce the 14 B figure. Also — and this is the main reason I'm writing — the Static checks — no runtime testingTo be clear, none of this was verified on a switch. What I did check, at build time: For the i.e. exactly the Dropping the Small things
|
Saves 2 bytes
|
Thanks for the quick review. Tomorrow I will look into it. |
|
Re-measured against
Two things I noticed reading it, neither of which breaks anything today.
The other is in Things I checked at commit 9 and found fine: the JSON and HTTP literals are unchanged apart from folding All of the above is build-time analysis — I haven't run this on hardware. |
Adapt the relevant parts of upstream PR logicog#305 (Sram hunting) to this fork, which is already ahead of upstream in several places: - httpd.c: timeptr now an __xdata-stored pointer (content_type/session were already converted in this fork) - uip.c/uip.h: uip_conn, uip_udp_conn and the uip_udp_new ripaddr parameter are __xdata-stored pointers (2 B each) - uip/uip-fw.c: fwcache_register and uip_fw_forward keep their forwarding-cache pointer in XDATA; the loop scans by index instead of walking the pointer - uip/uip-neighbor.c/.h: uip_neighbor_add's addr parameter - uip/uip_arp.c: uip_arp_update's parameters, the loop index, and the ARP table checks now use the new memcmp / is_mem_zero helpers - rtlplayground_mem.asm: memcmp and is_mem_zero implemented in hand-written assembly, following the fork's existing memcpy/strtox convention (upstream ships C versions, but the fork's asm helpers are smaller and faster) Not applied, with reasons: - strtox / memcpy / memset: already hand-written assembly in this fork - content_type / session pointers: already __xdata-stored - syslog.c: does not exist in this fork - page_impl.c sfp_send_data / xstrtox refactor: ~3 B IRAM for a hardware-facing change; not worth the risk Measured: DSEG+OSEG 72 -> 60 B (limit 80 B), all four build variants link, and the device (PCB-K0402WS-V3.0) passes login/status, telnet, ARP table (the new asm helpers), the /enc roundtrip and the full Playwright WebUI suite.
|
Still working on this I my own repo/branch https://github.com/vDorst/RTLPlayground/tree/SRAM-HUNTING_move_sfr_data. |
I am hunting for SRAM bytes.
I am looking in every generated
output/*.asmto see what is using SRAM.Looking for section
XDATA.__xdatain the front. Although that is not ideal, I am not sure why SDCC is doing that.Still work in progress but I want it to share it already.
Current progress: 31 bytes of SRAM freed.
Baseline code: c86d4b3 vs this PR.