Skip to content

Conversation

earlephilhower
Copy link
Collaborator

The ROM routine __divsi3 is called by code whenever a division is needed,
because there is no divide unit on the ESP8266 core. When the divide
routine in ROM hits a div-by-zero case, it jumpt to an ILL(egal instruction)
at a fixed address which causes a HW exception 0 (IllegalInsnException).

In the postmortem dump, when an ILL exception is detected at this address
in ROM, convert it to a DivByZeroException for printout (6).

Divde by zero errors now print as follows:

--------------- CUT HERE FOR EXCEPTION DECODER --------------- Exception (6): epc1=0x4000dce5 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000 >>>stack>>> ... <<<stack<<< --------------- CUT HERE FOR EXCEPTION DECODER --------------- 

And will decode as follows:

Exception 6: IntegerDivideByZero: QUOS, QUOU, REMS, or REMU divisor operand is zero PC: 0x4000dce5 EXCVADDR: 0x00000000 Decoding stack results ... 
The ROM routine __divsi3 is called by code whenever a division is needed, because there is no divide unit on the ESP8266 core. When the divide routine in ROM hits a div-by-zero case, it jumpt to an ILL(egal instruction) at a fixed address which causes a HW exception 0 (IllegalInsnException). In the postmortem dump, when an ILL exception is detected at this address in ROM, convert it to a DivByZeroException for printout (6). Divde by zero errors now print as follows: ```` --------------- CUT HERE FOR EXCEPTION DECODER --------------- Exception (6): epc1=0x4000dce5 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000 >>>stack>>> ... <<<stack<<< --------------- CUT HERE FOR EXCEPTION DECODER --------------- ```` And will decode as follows: ```` Exception 6: IntegerDivideByZero: QUOS, QUOU, REMS, or REMU divisor operand is zero PC: 0x4000dce5 EXCVADDR: 0x00000000 Decoding stack results ... ````
@earlephilhower
Copy link
Collaborator Author

Unfortunately, the mod (%) operator intrinsic function is not in ROM, so the same trick can't be used as it will move around in flash depending on the code.

@earlephilhower earlephilhower merged commit 5b3d290 into esp8266:master Aug 17, 2020
@earlephilhower earlephilhower deleted the div0 branch August 17, 2020 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants