English Amiga Board

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

Thread Tools
Old 23 June 2012, 08:11   #1
Registered User
NovaCoder's Avatar
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 3,960
GCC Assembler return value question...

I'm using GCC to 'talk' to my assembler files.

To call a function that doesn't return anything like this:
void __asm c2p8_deinit(register __a0 void *c2p);
I have to do this:
static inline void c2p8_deinit_stub(void *c2p) {

    register void *_c2p __asm("a0") = c2p;

    __asm("jsr _c2p8_deinit" : : "r" (_c2p) : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a1", "a2", "a3", "a4", "cc", "memory");

Anyone got a clue what I would do for this puppy which returns a pointer?

void __asm *c2p8_reloc(register __a0 struct BitMap *bitmap);

	movem.l d2-d7/a2-a6,-(sp)

	move.l	a0,-(sp)
	move.l  #_c2p8_end-_c2p8start,d0
	move.l  #MEMF_FAST,d1
	move.l	4.w,a6
	jsr     _LVOAllocVec(a6)
	move.l	(sp)+,a3
	tst.l   d0
	beq     .fail
	move.l  d0,a0                   ; FIXME: align by cache line
					; size and make changes to
					; the c2p too.
	lea     _c2p8start,a1
	move.w  #_c2p8_end-_c2p8start-1,d1
	move.b  (a1)+,(a0)+
	dbf     d1,.loop

	move.l	bm_Planes(a3),d2

	move.l  d0,a0
	move.l  bm_Planes+4(a3),d1
	sub.l   d2,d1
	patch	c2p8_p1_1
	patch	c2p8_p1_2
	move.l  bm_Planes+8(a3),d1
	sub.l   d2,d1
	patch	c2p8_p2_1
	patch	c2p8_p2_2
	move.l  bm_Planes+12(a3),d1
	sub.l   d2,d1
	patch	c2p8_p3_1
	patch	c2p8_p3_2
	move.l  bm_Planes+16(a3),d1
	sub.l   d2,d1
	patch	c2p8_p4_1
	patch	c2p8_p4_2
	move.l  bm_Planes+20(a3),d1
	sub.l   d2,d1
	patch	c2p8_p5_1
	patch	c2p8_p5_2
	move.l  bm_Planes+24(a3),d1
	sub.l   d2,d1
	patch	c2p8_p6_1
	patch	c2p8_p6_2
	move.l  bm_Planes+28(a3),d1
	sub.l   d2,d1
	patch	c2p8_p7_1
	patch	c2p8_p7_2

	move.l	d0,-(sp)
	move.l	4.w,a6
	jsr     _LVOCacheClearU(a6)
	move.l	(sp)+,d0

	movem.l (sp)+,d2-d7/a2-a6

	cnop    0,16
I hate having to answer my own assembler questions again but anyway for the benefit of others...

void  *c2p8_reloc(register __a0 struct BitMap *bitmap);
void  c2p8_deinit(register __a0 void *c2p);
void  c2p8(register __a0 void *c2p,
		register __a1 struct BitMap *bmp,
		register __a2 UBYTE *chunky,
		register __d0 ULONG size);

void *c2p8_reloc_stub(struct BitMap *bitmap) {

    register void *_return __asm("d0");

    register struct BitMap *_bitmap __asm("a0") = bitmap;

    __asm("jsr _c2p8_reloc" : : "r" (_return), "r" (_bitmap) : "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a1", "a2", "a3", "a4", "cc", "memory");

    return _return;

static inline void c2p8_deinit_stub(void *c2p) {

    register void *_c2p __asm("a0") = c2p;

    __asm("jsr _c2p8_deinit" : : "r" (_c2p) : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a1", "a2", "a3", "a4", "cc", "memory");

static inline void c2p8_stub(void *c2p, struct BitMap *bitmap, UBYTE *chunky, ULONG size) {

    register ULONG _size __asm("d0") = size;

    register void *_c2p __asm("a0") = c2p;
    register struct BitMap *_bitmap __asm("a1") = bitmap;
    register UBYTE *_chunky __asm("a2") = chunky;

   __asm("jsr _c2p8" : : "r" (_size), "r" (_c2p), "r" (_bitmap), "r" (_chunky) : "d1", "d2", "d4", "d6", "d7", "a3", "a4", "cc", "memory");

Last edited by NovaCoder; 26 June 2012 at 15:09. Reason: Because I worked it out myself...
NovaCoder 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
GCC and GCCFindHit tygre Coders. Language 2 20 February 2012 17:45
LouiSe's GCC Environment Morbane request.Apps 0 27 December 2011 09:02
Quick x86 Assembler question :( Nostalgeek Coders. General 3 18 May 2010 01:00
Linking to assembler objects using C++ gcc (StormV4) NovaCoder Coders. General 6 09 December 2009 20:35
StormC4/GCC JoJo Coders. General 0 28 October 2002 10:38

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 13:28.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.06189 seconds with 15 queries