22 March 2024, 17:38 | #21 |
Registered User
Join Date: May 2023
Location: Norwich
Posts: 446
|
The same trick works entirely with offsets though.
E.g. the two buffers are stored starting at $xxxx, let's assume they're 16 bytes long Buffer1 = $xxxx + 0 Buffer2 = $xxxx + 16 Thus SUM = 16 (this will always be the length of the buffer) First time, X= 0, i.e. first buffer X = SUM - X = 16-0 = 16 Second time X = 16, i.e. using second buffer X = SUM - X = 16-16 = 0 No doubling of anything. We don't even ever have to care what $xxxx actually is for the maths to work out. |
22 March 2024, 20:06 | #22 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,553
|
Quote:
Quote:
What you would achieve here is that a section's load-address is added twice to the 32-bit addend stored at a specific section-offset. This can only work when bufferis at offset 0. As soon as you want to double a label from a different section offset it fails. EDIT: Hmm. Thinking about it, it could indeed work, if you also double the section-offset part of the addend at that section location. I.e. for buffer+buffer+24, when buffer resides at section offset 100, if would become 100+100+24. Last edited by phx; 22 March 2024 at 20:12. Reason: Hmm... |
||
22 March 2024, 20:45 | #23 |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,770
|
Me too, on any platform (very bad when you need to put a routine into ROM).
Using self-modifying code would make it slightly faster, but you should always look at the big picture before going for such micro-optimizations. Chances are the buffer address will not be held in a register continuously but be stored in a memory location for later use, and then you have to consider the time taken to store and retrieve it. Of course you will also have more code that uses the buffer. The more code is involved the less important that micro-optimization becomes. Generally it is better to concentrate on overall efficiency and not sweat about little stuff like this. I usually start by writing code that does what I want in the obvious and logical way, then optimize it later only if necessary (when other avenues have already been exhausted). |
22 March 2024, 21:00 | #24 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,501
|
eheh, I was about to upload the exe to clear your doubt, but you understood what I intended to do
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Double PAL / Double NTSC, oficially supported by WHDLoad... | Shoonay | project.WHDLoad | 3 | 15 May 2021 19:42 |
DOUBLE DRAGON II vs DOUBLE DRAGON 3 AMIGA TITLE MUSIC | ZEUSDAZ | Retrogaming General Discussion | 20 | 16 January 2021 13:29 |
Any way to avoid value change in memory address permanently | fstarred | Coders. General | 6 | 12 August 2020 18:51 |
List memory address range | solarmon | Coders. Scripting | 2 | 18 December 2019 15:31 |
NAT address | -Rob- | support.Other | 7 | 07 April 2008 00:06 |
|
|