Subj : Re: Inline Assembler bug with structs of certain size To : borland.public.cpp.borlandcpp From : Jeremy Date : Fri Dec 03 2004 08:58 am Ed, Thanks for the prompt reply. I see you're not getting the same results as me. In fact, both of yours seem to give erroneous results from the inline assembler functions (should return the same value as &TestStruct or 0xEEEE - I assigned this value to _AX just to illustrate that the routine does nothing at all when the structure is the "wrong" size). I had noticed that choosing "C to Assembler" compile in the IDE would give me correct assembler code, but going direct to object didn't. Also, changing TestStruct to a char array the same length doesn't exhibit the same weird result (unfortunately this isn't a viable option for my real-world code, at least, not a readable option). I have managed a workaround in the meantime - I'm setting up the pointers to & length of the structure prior to scanning using the _ES, _DI & _CX pseudovariables just prior to the inline assembly & the code's identical to the old assembly. So in that sense I've "cured" my problem, but I'd love to know the mechanism behind the weirdness - especially the fact that it only occurs over a certain (reasonably large) range of sizes. Jeremy "Ed Mulroy [TeamB]" wrote in message news:41ae9b91$1@newsgroups.borland.com... > Here is what you posted handled with BC++ 5.02. Note > that -B is for compile via assembly and without -B it uses > the built in assembler (BASM) which won't align the code > on boundaries the same as is done when generating an > assembly language file and passing it to Tasm. If I were > doing embedded work such as you are, I'd use -B and > add -TL to the command line so that I'd have a listing. > > It's late now (11:30 PM) and I'm tired. I'll look at it a bit more > tomorrow. > > ------------------ > F:\Projects\lookat\q408 > >bcc -1 -tDe -ml -B ques408.c > Borland C++ 5.2 Copyright (c) 1987, 1997 Borland International > Mar 19 1997 17:29:40 > ques408.c: > Turbo Assembler Version 4.1 Copyright (c) 1988, 1996 Borland International > > Assembling file: ques408.ASM > Error messages: None > Warning messages: None > Passes: 1 > Remaining memory: 400k > > Turbo Link Version 7.1.32.2. Copyright (c) 1987, 1996 Borland International > > F:\Projects\lookat\q408 > >ques408 > length of asm_test1 = 8 > &TestStruct1 = 0b70, via asm = 1441 > length of asm_test2 = 8 > &TestStruct2 = 594a, via asm = 1441 > > F:\Projects\lookat\q408 > >bcc -1 -tDe -ml ques408.c > Borland C++ 5.2 Copyright (c) 1987, 1997 Borland International > Mar 19 1997 17:29:40 > ques408.c: > Turbo Link Version 7.1.32.2. Copyright (c) 1987, 1996 Borland International > > F:\Projects\lookat\q408 > >ques408 > length of asm_test1 = 8 > &TestStruct1 = 0b70, via asm = 1441 > length of asm_test2 = 5 > &TestStruct2 = 594a, via asm = 1441 > > F:\Projects\lookat\q408 > > > ------------------ > > . Ed > > > Jeremy wrote in message > > news:41ae833d$1@newsgroups.borland.com... > > > > I found an interesting bug in the BC5.0B inline assembler > > today (after a couple of days tracking it down). I mention > > it here because it may still exist in newer versions. > > .