Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding memory layout
#3
I've made some progress with this by looking at the memory map (produced when you specify --mmap filename as part of the compile command).  By comparing the output from the same compile command with only the heap size changed, I can see that the heap is at the beginning of the program code. E.g., this is the memory map for a 1024-byte heap:

Code:
7148: .__START_PROGRAM
7161: .ZXBASIC_MEM_HEAP
7161: .ZXBASIC_USER_DATA
7561: ._CR
7563: ._FU
---and here is the corresponding excerpt of the map for a 2048-byte heap:

Code:
7148: .__START_PROGRAM
7161: .ZXBASIC_MEM_HEAP
7161: .ZXBASIC_USER_DATA
7961: ._CR
7963: ._FU

(Note that CR and FU are variables).

So, if the heap grows down from the ZXBASIC_MEM_HEAP address and I don't have a big enough heap, then the program will grow below the origin address (above it is 0x7148) and start to impinge on Sinclair BASIC memory. I've been able to fortuitously work around the issue by moving the origin: the heap can spill over more before I see the problem. I think the issue is that I haven't made the heap big enough, so when my program overflows the heap it starts to impact on Sinclair BASIC stuff like the loader program and system variables.

Surprisingly, though, the --debug-memory option didn't produce an Out of memory error, when the program was running. Perhaps it isn't possible to catch all of the memory-overflow problems.

Hope that makes sense,

Darn. Sadly that's not the whole story. Returning the origin address is 26000 and increasing the heap size does not solve the problem. I should have remembered I tried experimenting with the heap size earlier on. Back to the memory map ...
Reply


Messages In This Thread
Understanding memory layout - by georgeo - 03-13-2021, 11:11 AM
RE: Understanding memory layout - by georgeo - 03-13-2021, 03:11 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)