English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 16 February 2014, 13:46   #1
aragon
Registered User
aragon's Avatar
 
Join Date: Aug 2003
Location: hamburg
Posts: 55
vbcc: no startup

I'm trying to figure out how to work with vbcc's minstartup.o.

If I compile the hello_min.c example from the manual, it links correctly, but when running this from CLI results in a 80000004 guru message.
I'm running under OS 3.1.

Compiler and linker are invoked with
Code:
vc -sc -sd -O2 hello_min.c -o hello_min -nostdlib $VBCC/targets/m68k-amigaos/lib/minstart.o -lamigas
Any idea what is going wrong here? Is the source file minstart.asm available?
And why do I need to link with amiga.lib? I thought that if I use pragmas and a custom _main(), amiga.lib would not be necessary?
aragon is offline  
Old 16 February 2014, 14:35   #2
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,924
You have to put minstart.o before hello_min.c in the command line. If you link without standard lib, then the first object module becomes the entry to the program. If hello_min is first, then main becomes the entry and not minstart as intended.

Given that minstart.o does not do much anyway, it's completely superfluous IMHO.

If this is your hello_min.c:

Code:
#include <proto/exec.h>

#define __NOLIBBASE__
#include <proto/dos.h>

struct Library *DOSBase;

int main (void)

{
if (DOSBase = OpenLibrary ("dos.library",36))
	{
	Printf ("Hello World!\n");

	CloseLibrary (DOSBase);
	}

return (RETURN_OK);
}
then this is my hello_min_min.c which links well without minstart.o:

Code:
#define __NOLIBBASE__
#include <proto/exec.h>
#include <proto/dos.h>

struct Library *SysBase;
struct Library *DOSBase;

__saveds
int main (void)

{
SysBase = *((struct Library **)4);

if (DOSBase = OpenLibrary ("dos.library",36))
	{
	Printf ("Hello World!\n");

	CloseLibrary (DOSBase);
	}

return (RETURN_OK);
}
thomas is offline  
Old 16 February 2014, 15:52   #3
aragon
Registered User
aragon's Avatar
 
Join Date: Aug 2003
Location: hamburg
Posts: 55
Thanks thomas, that helped a lot.

So this is now my initial program:
Code:
/* minimal startup code
vc -sc -sd -O2 $VBCC/targets/m68k-amigaos/lib/minstart.o hello_min.c -o hello_min -nostdlib  
*/

#include <proto/exec.h>
#include <proto/dos.h>

struct DosLibrary *DOSBase; 

main()
{
	if(DOSBase=(struct DosLibrary*)OpenLibrary("dos.library",0)){
		Write(Output(),"Hello, world!\n",14);
		CloseLibrary((struct Library *)DOSBase);
	}
	return 0;
}
This compiles to 232 bytes and works as expected.

I changed your version to this:
Code:
/* no startup
vc -nostdlib -sc -sd -O2 hello_min3.c -o hello_min3
*/
#define __NOLIBBASE__
#include <proto/exec.h>
#include <proto/dos.h>

struct Library *SysBase;
struct Library *DOSBase;

__saveds
int main (void){
	SysBase = *((struct Library **)4L);
	if (DOSBase =  OpenLibrary ("dos.library",0L)){
		Write(Output(),"Hello, world!\n",14); 
		CloseLibrary (DOSBase);
	}

	return (RETURN_OK);
}
This executable has only 180 bytes.

Compared with the SAS/C Example2 (124 bytes) this is fine.
aragon 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
Compiling CLib37 with VBCC 0.9 tnt23 Coders. General 2 29 July 2013 11:28
Using timer.device in C (VBCC) DBAlex Coders. General 2 28 June 2011 23:10
VBCC as cross sompiler under Linux gilgamesh Coders. General 13 21 March 2010 13:43
VBCC 0.8j for Windows hitchhikr Coders. General 11 09 October 2008 01:58
Kickstart 1.3 and GCC or VBCC? cdoty Coders. General 1 23 April 2005 07:10

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


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