EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Help running C program in 8051 emulator.

Started by Unknown April 14, 2007
Greetings everyone,

I'm new to programming, and I'm having trouble running a c program in
an 8051 emulator.  I'm using emu51.exe (http://sourceforge.net/
projects/emu51/) with asm51.exe (http://www.metaice.com/ASM51/
ASM51.htm).  When I use asm51 to convert the c program to a HEX file,
I receive the following message:



C:\UHCL\CPROGR~1\asm51>asm51.exe

8051 Cross-Assembler, Version 1.2k

     (c) Copyright 1984-1996 by MetaLink

     Source file drive and name [.ASM]:

1\P08-15.c     Second pass

     ASSEMBLY COMPLETE, 30 ERRORS FOUND



Although the HEX and LST files are created, they don't appear to load
into the emu51.exe emulator.  I assume it is due to the errors I'm
receiving during "assembly" in asm51.exe.  Below is the source that I
am using.  If you could help me out with this, I would certainly
appreciate an email!

#include <stdio.h>

#define MAX_ROWS  5
#define MAX_COLS  4


void fillArray (int table[][MAX_COLS], int numRows);

int main (void)
{

	int row;
	int col;
	int	ary[MAX_ROWS][MAX_COLS];


	fillArray(ary, MAX_ROWS);
	printf("Data: \n");
	for (row = 0; row < 5; row++)
        {
         for (col = 0; col < 4; col++)
              printf("%8d", ary [row][col]);
         printf("\n");
        }
	return 0;
}


void fillArray (int table[][MAX_COLS], int numRows)
{

	for (int row = 0; row < numRows; row++)
	   {
	    table [row][0] = row * 10;
	    for (int col = 1; col < MAX_COLS; col++)
	        table [row][col] = table [row][col - 1] + 1;
	   }
	return;
}

Best regards,


Mark

On 14 Apr 2007 14:51:16 -0700, mark.puffer@earthlink.net wrote:

>I'm new to programming, and I'm having trouble running a c program in >an 8051 emulator. I'm using emu51.exe (http://sourceforge.net/ >projects/emu51/) with asm51.exe (http://www.metaice.com/ASM51/ >ASM51.htm). When I use asm51 to convert the c program to a HEX file, >I receive the following message: > > > >C:\UHCL\CPROGR~1\asm51>asm51.exe > >8051 Cross-Assembler, Version 1.2k > > (c) Copyright 1984-1996 by MetaLink > > Source file drive and name [.ASM]: > >1\P08-15.c Second pass > > ASSEMBLY COMPLETE, 30 ERRORS FOUND
Use an assembler on assembly code and a C compiler on C code. -- Dan Henry
On Sat, 14 Apr 2007 16:31:48 -0600, Dan Henry <usenet@danlhenry.com>
wrote:

>On 14 Apr 2007 14:51:16 -0700, mark.puffer@earthlink.net wrote: > >>I'm new to programming, and I'm having trouble running a c program in >>an 8051 emulator. I'm using emu51.exe (http://sourceforge.net/ >>projects/emu51/) with asm51.exe (http://www.metaice.com/ASM51/ >>ASM51.htm). >> ===SNIP=== > >Use an assembler on assembly code and a C compiler on C code.
SDCC is a free compiler. http://sdcc.sourceforge.net/ -- Dan Henry
mark.puffer@earthlink.net wrote:

> Greetings everyone, > > I'm new to programming, and I'm having trouble running a c program in > > Mark >
So you ran a C file thru an assembler !?!?! Where did you get the idea you can do that ?? I think you are in the wrong line of work !! donald
In article <1176587476.214586.50700@n59g2000hsh.googlegroups.com>, 
mark.puffer@earthlink.net writes
>Greetings everyone, > >I'm new to programming, and I'm having trouble running a c program in >an 8051 emulator. I'm using emu51.exe (http://sourceforge.net/ >projects/emu51/)
That is a simulator. An emulator in this context is hardware. See "ICE" You don't mention which C compiler you are using to convert the C source you have into assembler.....
>with asm51.exe (http://www.metaice.com/ASM51/ >ASM51.htm). When I use asm51 to convert the c program to a HEX file, >I receive the following message: >C:\UHCL\CPROGR~1\asm51>asm51.exe >8051 Cross-Assembler, Version 1.2k > (c) Copyright 1984-1996 by MetaLink > Source file drive and name [.ASM]: >1\P08-15.c Second pass > ASSEMBLY COMPLETE, 30 ERRORS FOUND
You have 30 errors in the source code. You need to fix the source and have NO ERRORS before you try and run it in the simulator. I would suggest you download the Keil eval compiler/simulator and use that to test the code as the Keil 8051 tools are probably the best in the world. Then from a solid and confirmed start point you can use the sourceforge simulator when the code is too big for the Keil eval sim. -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ /\/\/ chris@phaedsys.org www.phaedsys.org \/\/\ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
In article <0nl22397h0q4ghgbgbdq0m5oe7r2m7g8hv@4ax.com>, Dan Henry 
<usenet@danlhenry.com> writes
>On Sat, 14 Apr 2007 16:31:48 -0600, Dan Henry <usenet@danlhenry.com> >wrote: > >>On 14 Apr 2007 14:51:16 -0700, mark.puffer@earthlink.net wrote: >> >>>I'm new to programming, and I'm having trouble running a c program in >>>an 8051 emulator. I'm using emu51.exe (http://sourceforge.net/ >>>projects/emu51/) with asm51.exe (http://www.metaice.com/ASM51/ >>>ASM51.htm). >>> ===SNIP=== >> >>Use an assembler on assembly code and a C compiler on C code. > >SDCC is a free compiler. > >http://sdcc.sourceforge.net/ >
However as it is only a very small amount of C he is better off using the Keil eval system. That will be a LOT more reliable and robust. It also had a good set of manuals and a LOT more support. Besides the simulator in the Keil system will be a lot better than anything else he can find -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ /\/\/ chris@phaedsys.org www.phaedsys.org \/\/\ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Memfault Beyond the Launch