Jumps Sizes .


         

The Jumps in a Code Section can be either long (four Bytes) or short (one Byte) signed Displacements.


The RosAsm Assembler does not optimize the Jumps Sizes. That is, if you declare a long jmp where it could as well be short, it will remain long.


This optimization that some Assemblers do, has no effect on the speed of the Code. It only concerns the size of Code. As short Jumps are limited to -128 Bytes upward and +127 Bytes downward, the real interest of these shorter forms is also limited to a very local scope.


There are two x86 Instructions that can only be short, and never long: LOOP and JECXZ. Inside a loop, saving three Bytes here, three Bytes there, may effectively make a real difference, as it may become an organization problem, when the Block of Instructions comes closer to the 128 Byte limit.


This is one of the reasons why the RosAsm Assembler implements the Local Labels with Sizes and Directions Markers: Locally, you take care of your jumps sizes. In case of an overpassed limit, the Assembler error Message tells you the number of overflowing Bytes, and then, its on you to take the decision to make your loop shorter, with other Instructions, or to re-organize the given Chunk of Code in another manner.


Another reason is that this choice between short and long forms of the jumps enables the RosAsm Programmer with an easy and friendly method for preventing a very usual developement error: The missing Label Declaration.


Let us take an example with the standard If Macros set, with the leading Periods, for the various If levels. You should always start the development of an If case with the short form. That way, in case you would forget to write the required End_If, the Assembler will point the error out, because, even if some End_If is to be found somewhere else, downward, the distance will much likely be too long. Otherwise, this type of error could be difficult to debug.


~~~~~~~