30 July 2016, 19:36 | #1 |
Registered User
Join Date: Jan 2008
Location: somewhere
Posts: 45
|
vbcc bind a variable to a register
Hi
source code : Code:
__reg("d6") ULONG test = 10; tests++; Code:
moveq #10,d0 addq.l #1,d0 Code:
vbccm68k -quiet "test.c" -o= "test.asm" -c99 -sc -cpu=68020 -O=1 |
31 July 2016, 05:11 | #2 |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
I don't believe what you are trying to do is currently possible with the 68k vbcc backend. I don't believe it is possible to specify a register for a variable or even give a hint to the compiler to use a register for a variable (like GCC "register" variables). It is possible to specify a register for functions and inlines and it is possible to leave values in certain registers but vbcc will only use returns in d0 (d0/d1 for 64 bit returns). It is only possible to reserve a4 (when not in a function or inline) so vbcc doesn't use it although it doesn't look difficult to add support to reserve other registers. In general, what you are trying to do is not a good programming practice. If you do have a legitimate reason to do what you are doing then you may want to contact Volker Barthelmann.
|
31 July 2016, 09:56 | #3 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,539
|
The __reg() attribute only works for function arguments at the moment. You can still use __asm() to insert any kind of assembler code into a function you like:
Code:
... __asm("\tmoveq\t#11,d6"); ... |
31 July 2016, 10:20 | #4 |
Registered User
Join Date: Jan 2008
Location: somewhere
Posts: 45
|
The idea is to rewrite the function RawDoFmt in C. It takes a callback function :
Code:
PutChProc(Char (d0.w), PutChData (a3)); My first (naive) try was in my question. Another approach, as suggest phx is to write some asm (I'll give it a try). Another way is maybe define the callback like this : Code:
PutChrProc(__reg("d0") UBYTE Char, __reg("a3") APTR PutChData) |
31 July 2016, 10:29 | #5 | |
Registered User
Join Date: Jan 2008
Location: somewhere
Posts: 45
|
Quote:
Code:
ULONG test = 0x100; __asm("\tmove.l test,d5"); |
|
31 July 2016, 10:40 | #6 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,025
|
|
31 July 2016, 12:29 | #7 |
Registered User
Join Date: Jan 2008
Location: somewhere
Posts: 45
|
Seems to be a the solution :
Code:
typedef void (*callback)(__reg("d0") UBYTE, __reg("a3") APTR); UBYTE t = '#'; APTR aptr = NULL; callback cb = putChProc; cb(t, aptr); |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Join variable and string in scripts. | olesio | support.Apps | 3 | 31 January 2013 11:44 |
Speedy. The variable speed accellerator. | DDNI | Hardware mods | 9 | 18 June 2012 21:33 |
NTSC variable-length scanlines | TheDarkCoder | Coders. Asm / Hardware | 3 | 23 November 2011 15:51 |
Variable Master Clock | wiltshireguyuk | request.UAE Wishlist | 0 | 13 December 2004 16:40 |
One RING to BIND them ALL. | blobrana | Amiga websites reviews | 9 | 20 March 2003 08:40 |
|
|