This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Dear GNUs, I'm looking for some information on what code should be used before calling main. My problem is as follows, I'm trying to write code for a i486 system, that boots from a ROM. I've got code to boot the main system board and get the processor running. The boot code copies a section of executable code from the rom to 10000h in memory and then calls it. This boot code works lovely! I've tried a bit of low level to output post codes to port 80h with great success. Then I installed a cross compiler, 'i486-coff', and wrote a bit of C. I've compiled code using the command i486-coff-gcc -nostdlib -Tmemoryscript.ld flashGPIO.c This compiles but gives an error about not finding _start and relocates the start of the code to 10000h. This seems OK, but the code dosen't work on the target system, so I had a look at the dissembly of the code to find this :- a.out: file format coff-i386 Disassembly of section .text: 00010000 <main>: 10000: 55 push %ebp 10001: 89 e5 mov %esp,%ebp 10003: 83 ec 08 sub $0x8,%esp 10006: 83 e4 f0 and $0xfffffff0,%esp 10009: b8 00 00 00 00 mov $0x0,%eax 1000e: 29 c4 sub %eax,%esp 10010: e8 47 00 00 00 call 1005c <__main> 10015: a0 aa 00 00 00 mov 0xaa,%al 1001a: e6 80 out %al,$0x80 1001c: c7 45 fc 00 00 00 00 movl $0x0,0xfffffffc(%ebp) 10023: 81 7d fc fd ff ff 7f cmpl $0x7ffffffd,0xfffffffc(%ebp) 1002a: 7e 02 jle 1002e <main+0x2e> 1002c: eb 0e jmp 1003c <main+0x3c> 1002e: a0 11 00 00 00 mov 0x11,%al 10033: e6 80 out %al,$0x80 10035: 8d 45 fc lea 0xfffffffc(%ebp),%eax 10038: ff 00 incl (%eax) 1003a: eb e7 jmp 10023 <main+0x23> 1003c: c7 45 fc 00 00 00 00 movl $0x0,0xfffffffc(%ebp) 10043: 81 7d fc fd ff ff 7f cmpl $0x7ffffffd,0xfffffffc(%ebp) 1004a: 7e 02 jle 1004e <main+0x4e> 1004c: eb ce jmp 1001c <main+0x1c> 1004e: a0 22 00 00 00 mov 0x22,%al 10053: e6 80 out %al,$0x80 10055: 8d 45 fc lea 0xfffffffc(%ebp),%eax 10058: ff 00 incl (%eax) 1005a: eb e7 jmp 10043 <main+0x43> 0001005c <__main>: 1005c: 55 push %ebp 1005d: 89 e5 mov %esp,%ebp 1005f: 5d pop %ebp 10060: c3 ret 10061: 8d 76 00 lea 0x0(%esi),%esi Disassembly of section .data: My feeling is that the code is not working because :- 1) the code/data/other segments aren't set 2) The stack pointer gets changed at the start of the code above, but before 'Main' Is there some 'Special' code I require before 'Main' and after '_start' to setup the enviroment for 'main'? Why does the compiled code play wih ESP/EBP registers? Ta. Thanks for your time. Nigel. ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |