3 One day someone wrote that nasm needs:
5 > - A good ALIGN mechanism, similar to GAS's. GAS pads out space by
6 > means of the following (32-bit) instructions:
7 > 8DB42600000000 lea esi,[esi+0x0]
8 > 8DB600000000 lea esi,[esi+0x0]
9 > 8D742600 lea esi,[esi+0x0]
10 > 8D7600 lea esi,[esi+0x0]
13 > It uses up to two of these instructions to do up to 14-byte pads;
14 > when more than 14 bytes are needed, it issues a (short) jump to
15 > the end of the padded section and then NOPs the rest. Come up with
16 > a similar scheme for 16 bit mode, and also come up with a way to
17 > use it - internal to the assembler, so that programs using ALIGN
18 > don't knock over preprocess-only mode.
19 > Also re-work the macro form so that when given one argument in a
20 > code section it calls this feature.
22 Well palign is your friend.
25 This is a modified version of nasm-0.98.24 that can accept
26 two new directives.The two new directives that control
27 the align mechanism are 'palign' and 'p2align'.They are nasm directives
28 that don't depend on preprocessor but rather align the code while assembling
30 The syntax of these directives is
32 [palign n] where '0 <= n <= 6' and
33 [p2align n] where '0 <= n <=6'
35 The use of these directives is
39 Pad the location counter to a particular storage boundary.
40 The n is a number between 0 and 6 of low-order zero bits the location counter
41 must have after advancement.
42 For example `palign 3' advances the location counter until
43 it a multiple of 8.If the location counter is already a multiple of 8,
45 If n=0 then nothing is done
46 if n => 6 then palign advances the location counter until it a multiple
47 of 64.For now the maximum is 64 bytes,if you want more use the ALIGN macro.
51 This directive do almost the same thing with a little exception.
52 It will continue aligning until a directive [p2align 0] meet or until
53 the current section changes.So this piece of code
66 guarantee that all the instructions in the code segment will be aligned
67 in a 32 byte boundary so than no instruction break the cache line on a
72 Well my english are very very bad.
73 This optimization will not work
74 for now for 16-bit code.
75 Also there may be a problem with the prefixes like ds,es,rep,lock etc
77 so this code will work
86 if you want to be sure put the prefix in the same line
89 Also don't try this in a data or a bss segment.Use the ALIGN macro better
93 If you have any suggestion, comment or found a bug please email me
94 and i will try to reply immediately.
95 From your feedback it depends this project to get better as i intend
96 to implement more things and improve the code in the next version of nasm.
99 Panos Minos 03-04-2002
100 email: <panosminos@mycosmos.gr> , <panosminos1@mycosmos.gr>