Board index » delphi » A Borland joke?

A Borland joke?

A curious phenomenon that I (and a fellow Delphi 3 programmer) have
independently come across:

A piece of assembly code in an asm statement in an application I'm
developing is crashing with an access violation at occasional random
intervals - I've yet to find out why, but that's another story.

When I examine the register contents in the watch window, I get:-

EAX = $BADF00D
ECX = $FEEDFAD
EDX = $F000BAAA

Other registers are the sort of values I might expect. There's no way
that these values could have arisen from my code - it has to be the IDE
having me on.  Am I paranoid, or has anyone else experienced this?

My friend is not using assembler, but is getting the same values from
pointers in a misbehaving sort routine.

If anyone can throw any light on this, or knows if it's telling me
anything useful, I'd be grateful to hear from them. In the meantime,
it's putting me off my supper :-)
--
Chris Bazalgette

 

Re:A Borland joke?


Quote
Chris Bazalgette wrote:
> A piece of assembly code in an asm statement in an application I'm
> developing is crashing with an access violation at occasional random
> intervals - I've yet to find out why, but that's another story.

You must preserve the contents of the EDI, ESI, ESP, EBP, and EBX
registers. So, push them on the stack on start of the asm routine and
pop them from the stack when ending the asm routine, or preserve them in
another way. This may help.

Quote
> When I examine the register contents in the watch window, I get:-

> EAX = $BADF00D
> ECX = $FEEDFAD
> EDX = $F000BAAA

Delphi's online help (asm; register use) says: "Except for EDI, ESI,
ESP, EBP, and EBX, an asm statement can assume nothing about register
contents on entry to the statement."

Hope this helps,
Wouter.

Re:A Borland joke?


Quote
Wouter Ras wrote in message <3634C6D1.2...@dutccis.ct.tudelft.nl>...
>Chris Bazalgette wrote:

>> When I examine the register contents in the watch window, I get:-

>> EAX = $BADF00D
>> ECX = $FEEDFAD
>> EDX = $F000BAAA

>Delphi's online help (asm; register use) says: "Except for EDI, ESI,
>ESP, EBP, and EBX, an asm statement can assume nothing about register
>contents on entry to the statement."

So you're saying this isn't a joke, but rather a cute way of
telling a programmer that they've done something wrong?

--
Jeremy Collins
Kansai Business Systems

Re:A Borland joke?


Wouter,
Thanks for the quick reply.

Quote
>You must preserve the contents of the EDI, ESI, ESP, EBP, and EBX
>registers. So, push them on the stack on start of the asm routine and
>pop them from the stack when ending the asm routine, or preserve them in
>another way. This may help.

I know about preserving the registers, and I'm doing that.

Quote
>Delphi's online help (asm; register use) says: "Except for EDI, ESI,
>ESP, EBP, and EBX, an asm statement can assume nothing about register
>contents on entry to the statement."

I know this also - it's what *my* code is doing to the registers that
I'm interested in, and it has already set them to other values before
the point where I get the access violation.

How about setting up some code to do a deliberate access violation, and
seeing if you get the same thing?

--
Chris Bazalgette

Re:A Borland joke?


Quote
Chris Bazalgette wrote:
> How about setting up some code to do a deliberate access violation, and
> seeing if you get the same thing?

> --
> Chris Bazalgette

Chris,

I did that. But when monitoring the asm statements step by step there
was no problem for me. The tiny program that I did tested was this:

procedure TForm1.Button1Click(Sender: TObject);
begin
  asm;
      mov eax,123456789
      mov ecx,987654321
      mov edx,33
      mov eax,[0]           // raise exception
  end;
end;

This showed the right values in the watch window, until the exception.
I can't help you further.

Goodluck,
Wouter.

Re:A Borland joke?


Quote
>Chris,

>I did that. But when monitoring the asm statements step by step there
>was no problem for me. The tiny program that I did tested was this:

>procedure TForm1.Button1Click(Sender: TObject);
>begin
>  asm;
>      mov eax,123456789
>      mov ecx,987654321
>      mov edx,33
>      mov eax,[0]           // raise exception
>  end;
>end;

>This showed the right values in the watch window, until the exception.
>I can't help you further.

Hmmm - very odd.

I've tried exactly the same code and still got the "BAD FOOD" effect,
with AX, CX & DX reporting their contents as I described.

Do we have the same versions of Delphi? Mine is Delphi 3.0 Build 5.53,
running on Win 95 4.0 (Build 1111:b).

Thanks for your interest -

--
Chris Bazalgette

Re:A Borland joke?


Quote
Chris Bazalgette wrote:
> When I examine the register contents in the watch window, I get:-

> EAX = $BADF00D
> ECX = $FEEDFAD
> EDX = $F000BAAA

> Other registers are the sort of values I might expect. There's no way
> that these values could have arisen from my code - it has to be the IDE
> having me on.  Am I paranoid, or has anyone else experienced this?

Yeah, I've seen this. In the heat of a frustrating debugging session, it
made me giggle. Maybe the Zen-masters at Inprise put this in to give
frustrated developers some "perspective".

(Cute hex words turn up all the time, by the way. There is a four-byte
"magic number" in the header for Java's byte-code (.class) files. This
number is $CAFEBABE.)

Dave

Re:A Borland joke?


Quote
Chris Bazalgette wrote in message ...
>I've tried exactly the same code and still got the "BAD FOOD" effect,
>with AX, CX & DX reporting their contents as I described.

Maybe it's a Microsoft joke...
--
Garry Knight
Computer programmer, psychotherapist, writer
ga...@garryknight.freeserve.co.uk

Re:A Borland joke?


Garry Knight <ga...@garryknight.freeserve.co.uk> schrieb in Nachricht
713am4$fc...@newsreader1.core.theplanet.net...

Quote
>Chris Bazalgette wrote in message ...
>>I've tried exactly the same code and still got the "BAD FOOD" effect,
>>with AX, CX & DX reporting their contents as I described.

>Maybe it's a Microsoft joke...

Maybe a Intel, AMD or Cyrix joke?

Chris: What processor did you use?

Helli

Re:A Borland joke?


Quote
Chris Bazalgette wrote:
> I've tried exactly the same code and still got the "BAD FOOD" effect,
> with AX, CX & DX reporting their contents as I described.

Well, I'm at a loss. I only get the $BADF00D after the exception.

Quote
> Do we have the same versions of Delphi? Mine is Delphi 3.0 Build 5.53,
> running on Win 95 4.0 (Build 1111:b).

I'm running Delphi 3 (5.53) on Win95 4.0 (1212:b). I've used systems with
older Win95 builds as well, but never encountered the problem. I hope
you're able to solve your problem... eventually.

Wouter

Re:A Borland joke?


Quote
>>Maybe it's a Microsoft joke...

>Maybe a Intel, AMD or Cyrix joke?

>Chris: What processor did you use?

>Helli

My processor is a bog-standard Intel Pentium II. My money is on the
pranksters being at Borland.
--
Chris Bazalgette

Re:A Borland joke?


Quote
Chris Bazalgette wrote:

> When I examine the register contents in the watch window, I get:-

> EAX = $BADF00D
> ECX = $FEEDFAD
> EDX = $F000BAAA

Have you considered that fact that the code that takes the exception and
unwinds the stack (and thus gets triggered by the OS exception handlers)
or, failing that (but less likely) the IDE, deliberately sets these
values? It seems to me that this is the most likely cause.

Remember that an awful lot of code executes between your app causing the
exception, and the Delphi IDE getting a chance to intervene.

MH.

--
Martin Harvey

mailto:mar...@aziraphale.demon.co.uk
http://www.harvey27.demon.co.uk/mch24/

Undoubtedly, someone can learn Object Oriented Programming from
reading code - after all Alan Kay learned OO by deciphering
an 80 page Simula program thinking it was Algol.
However, most people are not in the same league as Alan.
- Bjarne Stroustrup

Re:A Borland joke?


Quote
Dave Shapiro wrote:
> number is $CAFEBABE.)

Yeah.... there are lots more nice ones :-)

$EEDFACE

and

0xFACE

are two nice ones I've seen recently... these were used as error
constants, no doubt reminding the programmer that caused the errors of
their lack of talent :-)

MH.

--
Martin Harvey

mailto:mar...@aziraphale.demon.co.uk
http://www.harvey27.demon.co.uk/mch24/

Undoubtedly, someone can learn Object Oriented Programming from
reading code - after all Alan Kay learned OO by deciphering
an 80 page Simula program thinking it was Algol.
However, most people are not in the same league as Alan.
- Bjarne Stroustrup

Re:A Borland joke?


Maybe it's a Chris Bazalgette joke??? ;-)
Quote
Chris Bazalgette wrote in message ...
>>>Maybe it's a Microsoft joke...

>>Maybe a Intel, AMD or Cyrix joke?

>>Chris: What processor did you use?

>>Helli

>My processor is a bog-standard Intel Pentium II. My money is on the
>pranksters being at Borland.
>--
>Chris Bazalgette

Re:A Borland joke?


In article <ZY96vDA5CZN2E...@cbaz.demon.co.uk>, Chris Bazalgette
<ch...@cbaz.demon.co.uk> writes

Quote
>>>Maybe it's a Microsoft joke...

>>Maybe a Intel, AMD or Cyrix joke?

>>Chris: What processor did you use?

>>Helli

>My processor is a bog-standard Intel Pentium II. My money is on the
>pranksters being at Borland.

I guess you haven't seen the great feature from "another large software
firm" whereby when you hit the Save button the app crashes, destroying
your live file in the process...

Sigh...

--
Return address removed for anti-spam purposes.
Email replies to news at maelstrom dot demon dot co dot uk
Email replies to this address may be copied to relevant newsgroups

Go to page: [1] [2]

Other Threads