![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Aug 2009
Posts: 28
| exe error: "The NTVDM CPU has encountered an illegal instruction" "C:\windows\system32\cmd.exe The NTVDM CPU has encountered an illegal instruction cS:0dca IP:01a7 OP:63 79 67 77 69" I think it may have something to do with the way my makefile is written. Does anyone see anything wrong with it?: Makefile: Code: bin_PROGRAMS = Program1
SOURCE_DIR = $(top_srcdir)
SOURCE_INCLUDE_DIR = $(SOURCE_DIR)/../../include
SOURCE_COMMON_DIR = $(SOURCE_DIR)/../../common
SOURCE_LDSCRIPT_DIR = $(SOURCE_DIR)
CC=gcc
AM_CFLAGS=-c -Wall
AM_LDFLAGS=-M -T $(SOURCE_LDSCRIPT_DIR)/Linker.ld
SOURCES= $(SOURCE_DIR)/Main.c \
$(SOURCE_DIR)/Error1.c \
$(SOURCE_DIR)/File2.c \
$(SOURCE_DIR)/File3.c \
$(SOURCE_DIR)/File4.s \
$(SOURCE_DIR)/File5.s
OBJECTS=$(SOURCES:.c=.o)
all: Map
Map : $(OBJECTS)
$(CC) $(AM_LDFLAGS) $(SOURCES) -o $@
%.o : %.c
$(CC) $(AM_CFLAGS) $< -o $@
%.o : %.s
$(CC) $(AM_CFLAGS) $< -o $@
|
| TheEngineer is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,862
| Have you googled that error message? Do you have something bizarre in your code that was appropriate for 16-bit machines only? |
| tabstop is offline | |
| | #3 |
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,453
| The AM_LDFLAGS looks whacky unless you explain what it's doing. Never seen a command where the path to the link-editor was specified. Also all ".s" files are processed by the assembler not the compiler, unless this make is a smart one to figure it out for you. Even then the macro AM_CFLAGS for the "%.o : %.s" rule would be invalid. Last edited by itCbitC; 10-25-2009 at 02:21 AM. |
| itCbitC is offline | |
| | #4 | ||
| Registered User Join Date: Aug 2009
Posts: 28
| Quote:
Quote:
"You are getting this error because the file you are trying to run is trying to access the computer's memory. Because you are not running the file on a DOS or Win 3.X machine, NTVDM will not allow this. NTVDM allows a 16-bit DOS program to execute on Windows. It is basically a DOS emulator ." I realized that the only place I am attempting to access the computer's memory is in the linker script. I took these files from a program that was cross-compiled for an m68k processor but I need to compile it for the i686 also. Is there anything illegal about these instructions?: Code: PROVIDE (__stack = 0x60300);
MEMORY
{
RomArea (rxi) : ORIGIN = 0x10000, LENGTH = 0x10000
GenArea (rxi) : ORIGIN = 0x60000, LENGTH = 0x2000
RamArea (rwxi): ORIGIN = 0x62000, LENGTH = 0xE000
HighLev (rwxi): ORIGIN = 0x70000, LENGTH = 0x200000
}
SECTIONS
{
.text 0x70000 : { *(.text) } = 0x4e71
.data . : { *(.data) }
.bss . : { *(.bss) *(COMMON) }
_bss_end__ = . ;
__bss_end__ = . ;
. = ALIGN(32 / 8);
. = ALIGN(32 / 8);
__end__ = . ;
_end = .;
PROVIDE (end = .);
.rodata . : { }
.rodata.str1.1 . : { }
.cnfgtbl 0x10000 : {*(.cnfgtbl) . = 0x10000; } /*Load configuration table here */
.genvers 0xFFFE : { . = 0x02; } =0xA5
.aparea2 0x62000 : { . += 0xe000; } /* Reserve area */
.generic 0x60000 : { . = 0x2000; }
}
I also took this makefile from the cross-compiled program and that is how the linker script reference is set up. Is there a more proper way to do this? Also, I wasn't really sure what to do with the ".s" files since the other program didn't have any. Do I list them elsewhere or not include them in the makefile? Thanks! | ||
| TheEngineer is offline | |
| | #5 | |||
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,453
| Quote:
Quote:
Quote:
Were these ".s" files created on the x86 machine or did you port them over from the m68k cross-compilation? If the latter, then throw them away as they will generate arbitrary bit patterns that won't translate to valid opcodes on the target x86 machine ie illegal instructions. | |||
| itCbitC is offline | |
| | #6 |
| Registered User Join Date: Sep 2006
Posts: 3,158
| I get this error when running Turbo C/C++, whenever a pointer goes awry and hits WindowsXP in a sensitive spot, or if the memory it's given on start up, gets too low (by becoming fragmented or "lost"), typically during debugging sessions. It is a 16 bit program, of course. |
| Adak is offline | |
| | #7 | |
| Registered User Join Date: Aug 2009
Posts: 28
| Quote:
I realize that the m68k makefile would not work on the i686, and I made all changes that I thought were necessary. Earlier you mentioned something about the path to the linker script and I was just wondering if you knew a different way to declare it if that will not work? I don't get any errors about it when compiling. Also, the .s files and all the other source files were originally written with Green Hills Multi software and were then edited to work with gnu, so they did not come from the m68k. What should I do with them? The Makefile that I posted is one that I wrote from scratch, using just file locations and names from the m68k version. I have very little experience writing these, as you can tell, and am just looking for any advice about elements that may not work. Again, I'm not getting errors when compiling the exe file, but am getting an illegal instruction error when trying to open it. Thanks for your help | |
| TheEngineer is offline | |
| | #8 | |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,768
| Quote:
Something is, obviously, hilariously wrong.
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot | |
| brewbuck is offline | |
| | #9 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,768
| By the way, the linker script is probably completely irrelevant. All you're trying to do is compile the code for Windows, right? Then you do not care about memory regions or image layout. Just remove the linker script entirely and see what happens.
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot |
| brewbuck is offline | |
| | #10 |
| Registered User Join Date: Aug 2009
Posts: 28
| When I removed it I got some errors while compiling, which seems like progress. Thanks for the suggestion |
| TheEngineer is offline | |
| | #11 |
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,453
| |
| itCbitC is offline | |
| | #12 | |
| Registered User Join Date: Aug 2009
Posts: 28
| Quote:
Code: ../ProgramMain.c: In function `main': ../ProgramMain.c:224: warning: passing arg 2 of `LoadTestProgram' makes pointer from integer without a cast ../ProgramMain.c:80: warning: return type of 'main' is not `int' ../Assembly.s: Assembler messages: ../Assembly.s:10: Error: no such instruction: `ds.l 15' ../Assembly.s:15: Error: no such instruction: `movem.l %D0/%D1/%D2/%D3/%D4/%D5/%D 6/%D7/%A0/%A1/%A2/%A3/%A4/%A5/%A6,RegStore' ../Assembly.s:16: Error: no such instruction: `link %A6,' ../Assembly.s:19: Error: no such instruction: `move.l 8(%A6),%A2' ../Assembly.s:22: Error: no such instruction: `jsr (%A2)' ../Assembly.s:24: Error: no such instruction: `move.l (%A7)+,%A4' ../Assembly.s:26: Error: no such instruction: `unlk %A6' ../Assembly.s:28: Error: no such instruction: `move.l (%SP)+,%A0' ../Assembly.s:29: Error: suffix or operands invalid for `add' ../Assembly.s:30: Error: no such instruction: `move.l %A0,-(%SP)' ../Assembly.s:31: Error: no such instruction: `movem.l RegStore,%D0/%D1/%D2/%D3/% D4/%D5/%D6/%D7/%A0/%A1/%A2/%A3/%A4/%A5/%A6' ../Assembly.s:33: Error: no such instruction: `rts ' make: *** [Program] Error 1 | |
| TheEngineer is offline | |
| | #13 | |
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,453
| Quote:
You stated that the ".s" files had been generated on the x86 machine which is an incorrect statement. It seems that you have copied over everything blindly from the m68k cross-compilation without realizing that this process will never work on your Windows machine. Prefixing a percent sign to m68k registers like A4 or D2 won't help either. The only portable thing between an m68k machine and the Windows (x86) machine is the source code written in C. | |
| itCbitC is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What cause NTVDM CPU error? | xianjianwuhen | C Programming | 4 | 09-04-2009 09:21 AM |
| questions on multiple thread programming | lehe | C Programming | 11 | 03-27-2009 07:44 AM |
| SSH Hacker Activity!! AAHHH!! | Kleid-0 | A Brief History of Cprogramming.com | 15 | 03-06-2005 03:53 PM |