From: SourceForge.net <no...@so...> - 2009-11-02 20:21:31
|
Bugs item #1505956, was opened at 2006-06-14 13:04 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1505956&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: Duplicate Priority: 5 Private: No Submitted By: Frieder Ferlemann (frief) Assigned to: Nobody/Anonymous (nobody) Summary: sjmp and conditional jump out of range Initial Comment: The code below fails with: ?ASxxxx-Error-<a> in line 139 of sjmp.asm <a> machine specific addressing or addressing mode error ?ASxxxx-Error-<a> in line 217 of sjmp.asm <a> machine specific addressing or addressing mode error Lines 139 and 217 contain jumps to labels which are not within reach of the addressing mode: jc 00275$ sjmp 00272$ -----------8<------------------------------------------ #define NOP1 do { _asm nop _endasm; } while (0) #define NOP2 do { _asm nop nop _endasm; } while (0) #define NOP4 do { _asm nop nop nop nop _endasm; } while (0) #define NOP8 do { NOP4; NOP4; } while (0) #define NOP16 do { NOP8; NOP8; } while (0) #define NOP32 do { NOP16; NOP16; } while (0) #define NOP64 do { NOP32; NOP32; } while (0) volatile char t; void main(void) { volatile unsigned char i; for( i=0; i<100; i++ ) { t++; NOP64; NOP32; NOP16; NOP8; // NOP4; NOP2; // NOP1; } t++; } ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2009-11-02 21:21 Message: Here's another idea. Let the preprocessor replace multiline macros with multiple _asm/_endasm pairs instead of using a separator. E.g. for NOP2: _asm cpl a _endasm; _asm cpl a _endasm After that we can make the assembler reject multiple instructions on one line. This means it is no longer valid to have multiple asm instructions in a single line C macro. ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2009-10-09 18:07 Message: Duplicate of bug 1406219 Leaving it open because of the comments. ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2008-01-19 20:04 Message: Logged In: YES user_id=888171 Originator: NO Looked into this again today. It would be easier if the assembler would reject multiple instructions per line unless separated by a special separator(e.g. '|'). Andif the preprocessor could insert this separator at places where it finds a backslash in the macro while inside a _asm/_endasm pair. Then the above NOP2 would have to be changed into either: #define NOP2 do { _asm cpl a | cpl a _endasm; } while (0) or: #define NOP2 do { _asm \ cpl a \ cpl a \ _endasm; } while (0) Now what would be a good candidate for the separator? And how many people rely already on the multiple instructions per line acceptance? Any idea is welcome. ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2007-08-14 22:53 Message: Logged In: YES user_id=888171 Originator: NO The problem here is that one cannot tell the preprocessor to put those assembly instructions on seperate lines. So for NOP4 it generates: nop nop nop nop I expected the assembler to choke on this but it accepts it and generates four 0x00 bytes correctly. However the peephole optimizer only tries to read one instruction per line when calculating the instrcution size (see asmLineNodeFromLineNode() in src/mcs51/main.c) and treats the second and third nop as operands. The last one is ignored alltogether. And thus the calculated size for this line is 1 byte instead of 4. The workaround is obvious: don't put two or more asm instructions in a macro #define NOP do { _asm nop _endasm; } while (0) #define NOP2 do { NOP; NOP; } while (0) #define NOP4 do { NOP2; NOP2; } while (0) The real solution would be to skip the inst and its op's in instructionSize() after the calculation and process the rest of the line. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1505956&group_id=599 |