Eric
Eric

Reputation: 464

divide-zero error

a divide expression in my code is " a / b ". when it is compiled to assemble, there is a trap-testing instruction(teq in MIPS assemble) following the normal divide instruction.
will all compiler add this kind of trap instruction behind the normal divide instruction? I'm not familar with this situation. Thanks very much.

Upvotes: -1

Views: 275

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308071

Most compilers won't specify the results when you do a divide by zero. Since you didn't indicate what language or compiler you're using, it's impossible to be more specific than that.

P.S. Being able to read the assembly output from the compiler is a huge advantage in cases like this.

Upvotes: 3

Related Questions