Add tokens vex.ww and vex.wx; vex.wx is the default
[nasm/autotest.git] / test / objtest.asm
blob24e9fbd3393e9f983f9b3d459d779a3e91cb0e86
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
26 bits 16
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
40 _function push bp
41 mov bp,sp
42 push ds
43 mov ax,mygroup ; [14]
44 mov ds,ax
45 inc word [_bsssym] ; [9]
46 mov ax,seg _commvar
47 mov ds,ax
48 dec word [_commvar]
49 pop ds
50 mov ax,[bp+6]
51 mov dx,[bp+8]
52 push dx
53 push ax
54 push dx
55 push ax
56 call far [cs:.printf] ; [5] [8]
57 pop ax
58 pop ax
59 call trampoline ; [7]
60 pop ax
61 pop ax
62 mov sp,bp
63 pop bp
64 retf
66 .printf dw _printf, seg _printf ; [2] [4] [16]
68 segment mycode2 private
70 trampoline: pop ax
71 push cs
72 push ax
73 jmp far _printf
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]