1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Help running C program in 8051 emulator.

Discussion in 'Embedded' started by mark.puffer, Apr 14, 2007.

  1. mark.puffer

    mark.puffer Guest

    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
     
    mark.puffer, Apr 14, 2007
    #1
    1. Advertisements

  2. mark.puffer

    Dan Henry Guest

    Use an assembler on assembly code and a C compiler on C code.
     
    Dan Henry, Apr 14, 2007
    #2
    1. Advertisements

  3. mark.puffer

    Dan Henry Guest

    Dan Henry, Apr 14, 2007
    #3
  4. mark.puffer

    Donald Guest

    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
     
    Donald, Apr 15, 2007
    #4
  5. mark.puffer

    Chris Hills Guest

    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.....
    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, Apr 15, 2007
    #5
  6. mark.puffer

    Chris Hills Guest

    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, Apr 15, 2007
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.