Bug 1539 – X86 inline assembler fails to recognize when the branch address outside range

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-09-28T20:08:16Z
Last change time
2019-08-08T13:44:06Z
Keywords
accepts-invalid, iasm, wrong-code
Assigned to
No Owner
Creator
Graham

Comments

Comment #0 by grahamc001uk — 2007-09-28T20:08:16Z
Inline assembler for X86 platform fails to recognize when the branch address of a loop assembler instruction falls outside of the -128 .. +127 range. Test program: // Compiled with Digital Mars D Compiler v1.021 // on Windows XP. import std.stdio; void main() { writefln("start of loop"); asm { mov ECX,10 ; next: ; // when the number of nop is increased to 127 the program fails. // with 126 or less it works. nop ; nop ; nop ; nop ; nop ; loop next ; } writefln("end of loop"); } on failure produces the output: start of loop Error: Access Violation despite compiling without any errors or warnings. I classified as minor as I doubt if many people will be hit by it. Only those writing more complex inline assembler code.
Comment #1 by thomas-dloop — 2007-09-30T05:01:04Z
Comment #2 by razvan.nitu1305 — 2019-08-08T13:44:06Z
The error does not manifest in D2. You get a compiler error: block displacement of -132 exceeds the maximum offset of -128 to 127.