Introduce SEGALIGN directive
authorCyrill Gorcunov <gorcunov@gmail.com>
Tue, 20 Apr 2010 11:33:45 +0000 (15:33 +0400)
committerCyrill Gorcunov <gorcunov@gmail.com>
Tue, 20 Apr 2010 21:07:47 +0000 (01:07 +0400)
No real handling yet though. Definition only.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
directives.dat
nasm.c
standard.mac

index b08d387..fbcf666 100644 (file)
@@ -48,6 +48,7 @@ list
 section
 segment
 warning
+segalign
 
 ; --- Format-specific directives
 export                         ; outcoff, outobj
diff --git a/nasm.c b/nasm.c
index a1ff56c..afd9ea4 100644 (file)
--- a/nasm.c
+++ b/nasm.c
@@ -1232,7 +1232,19 @@ static void assemble_file(char *fname, StrList **depend_ptr)
                         location.segment = seg;
                     }
                     break;
-                case D_EXTERN:         /* [EXTERN label:special] */
+                case D_SEGALIGN:        /* [SEGALIGN n] */
+                    {
+                        if (*value) {
+                            int align = atoi(value);
+                            if (!is_power2(align)) {
+                                nasm_error(ERR_NONFATAL,
+                                           "segment alignment `%s' is not power of two",
+                                            value);
+                            }
+                        }
+                    }
+                    break;
+                case D_EXTERN:              /* [EXTERN label:special] */
                     if (*value == '$')
                         value++;        /* skip initial $ if present */
                     if (pass0 == 2) {
index a3e8eea..a7a52db 100644 (file)
 %define __SECT__ [segment %1]
          __SECT__
 %endmacro
+%imacro segalign 1+.nolist
+%define __SECT__ [segalign %1]
+         __SECT__
+%endmacro
 
 %imacro absolute 1+.nolist
 %define __SECT__ [absolute %1]