English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 22 March 2024, 17:38   #21
AestheticDebris
Registered User
 
Join Date: May 2023
Location: Norwich
Posts: 384
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.
AestheticDebris is offline  
Old 22 March 2024, 20:06   #22
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by ross View Post
It's not a problem with LoadSeg or the Amiga Hunks, nothing in the relocation table prevents you from 'rearranging' the same longword in memory twice.
Correct. But even then it would rarely help you.

Quote:
So I can also create one for you by 'replacing' the linker job, but I don't think that's the purpose
I doubt that.

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
buffer
is 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...
phx is offline  
Old 22 March 2024, 20:45   #23
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,588
Quote:
Originally Posted by remz View Post
1) Rotareneg: I personally hate self-modifying code,
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).
Bruce Abbott is offline  
Old 22 March 2024, 21:00   #24
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
Quote:
Originally Posted by phx View Post
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.
eheh, I was about to upload the exe to clear your doubt, but you understood what I intended to do
ross is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:30.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.06879 seconds with 13 queries