English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 26 September 2017, 11:40   #1
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,548
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!
earok is offline  
Old 26 September 2017, 18:28   #2
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
Some hints from the "libsdev" archive:
Quote:
A6 : Blitz keeps track of A6 to prevent it having to be unnecessarily
re-loaded.
A5 : Blitz 2's global variable base.
A4 : Blitz 2's local variable base.
A3 : Blitz uses this to build temporary strings.
idrougge is offline  
Old 26 September 2017, 23:12   #3
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,381
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.
Daedalus is offline  
Old 27 September 2017, 04:28   #4
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,548
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}
earok is offline  
Old 27 September 2017, 06:52   #5
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,548
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.
earok 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
"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

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 10:31.

Top

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