26 September 2017, 11:40 | #1 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,549
|
ASM in statements - accessing "shared" variables
I'm starting to convert some of my functions to assembly and I was wondering if there was an easy way of accessing the memory locations of variables declared as "shared" at the top of the function block, and if so - how.
Thanks in advance! |
26 September 2017, 18:28 | #2 | |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,359
|
Some hints from the "libsdev" archive:
Quote:
|
|
26 September 2017, 23:12 | #3 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,393
|
Are GetReg and PutReg what you had in mind?
GetReg d0, MyValue.l Puts the value of MyValue in d0. I haven't tried this, but it's worth a shot: Put the address of variable MyValue in a0: GetReg a0, &MyValue It should then be possible to manipulate its contents directly in memory. |
27 September 2017, 04:28 | #4 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,549
|
Thanks guys, I'll do some more digging/experimentation.
I was thinking it may be easiest (possibly most efficient in the total number of ASM instructions?) just including the address in the function parameters? Something like Function MyFunction{VariableAddress.l} Move.l D0,A0 ASMExit End Function Result=MyFunction{&MyVariable} |
27 September 2017, 06:52 | #5 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,549
|
I did some tests, it seems that the best way to get a shared variable inside an ASM function is indeed to use GetReg.
This code: Shared SharedVar.w GetReg D0, SharedVar Compiled to this: MOVE.W (A5, -$7ff8),D0 Edit: Ahh.. whoops, the function also pushes the registers to the stack and pops them back afterwards, so it's not super efficient.. might still be best to pass the address in via the function's parameters. Last edited by earok; 27 September 2017 at 07:16. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Voices8" 8 Channel Soundtracker "DemoSongI" song - "This is the Amiga with 8 Voices" | DemosongIHunter | request.Music | 45 | 23 May 2022 20:07 |
Problem with "missing" files in shared folder | mark_k | support.WinUAE | 1 | 01 July 2017 21:35 |
Error "No object" generating executable from ASM-One 1.20 | nandius_c | Coders. Asm / Hardware | 12 | 30 October 2013 10:28 |
"special" chip-mem allocation 68K-ASM | Herpes | Coders. System | 4 | 13 June 2013 11:42 |
ASM: why "banging the metal"? | jman | Coders. Tutorials | 7 | 22 April 2011 11:25 |
|
|