1 ; test source file for assembling to Microsoft 16-bit .OBJ
2 ; build with (16-bit Microsoft C):
3 ; nasm -f obj objtest.asm
4 ; cl /AL objtest.obj objlink.c
5 ; other compilers should work too, provided they handle large
6 ; model in the same way as MS C
8 ; This file should test the following:
9 ; [1] Define and export a global symbol
10 ; [2] Define a non-global symbol
11 ; [3] Define a common symbol
12 ; [4] Define a NASM local label
13 ; [5] Reference a NASM local label
14 ; [6] Import an external symbol
15 ; [7] Make a PC-relative relocated reference
16 ; [8] Reference a symbol in the same section as itself
17 ; [9] Reference a symbol in a different segment from itself
18 ; [10] Define a segment group
19 ; [11] Take the offset of a symbol in a grouped segment w.r.t. its segment
20 ; [12] Reserve uninitialised data space in a segment
21 ; [13] Directly take the segment address of a segment
22 ; [14] Directly take the segment address of a group
23 ; [15] Use SEG on a non-external
24 ; [16] Use SEG on an external
28 [global _bsssym
] ; [1]
29 [global _function
] ; [1]
30 [global _selfptr
] ; [1]
31 [global _selfptr2
] ; [1]
32 [common _commvar
2] ; [3]
33 [extern _printf
] ; [6]
35 [group mygroup mybss mydata
] ; [10]
36 [group mygroup2 mycode mycode2
] ; [10]
38 [segment mycode private
]
45 inc word [_bsssym
] ; [9]
56 call far [cs:.printf
] ; [5] [8]
66 .printf
dw _printf
, seg _printf
; [2] [4] [16]
68 [segment mycode2 private
]
75 [segment mybss private
]
77 _bsssym resw
64 ; [12]
79 [segment mydata private
]
81 _selfptr
dw _selfptr
, seg _selfptr
; [8] [15]
82 _selfptr2
dw _selfptr2 wrt mydata
, mydata
; [11] [13]