blob: 24e9fbd3393e9f983f9b3d459d779a3e91cb0e86 [file] [log] [blame]
H. Peter Anvinea6e34d2002-04-30 20:51:32 +00001; 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
7
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
25
H. Peter Anvind7ed89e2002-04-30 20:52:08 +000026 bits 16
H. Peter Anvinea6e34d2002-04-30 20:51:32 +000027
H. Peter Anvind7ed89e2002-04-30 20:52:08 +000028 global _bsssym ; [1]
29 global _function ; [1]
30 global _selfptr ; [1]
31 global _selfptr2 ; [1]
32 common _commvar 2 ; [3]
33 extern _printf ; [6]
H. Peter Anvinea6e34d2002-04-30 20:51:32 +000034
H. Peter Anvind7ed89e2002-04-30 20:52:08 +000035 group mygroup mybss mydata ; [10]
36 group mygroup2 mycode mycode2 ; [10]
H. Peter Anvinea6e34d2002-04-30 20:51:32 +000037
H. Peter Anvind7ed89e2002-04-30 20:52:08 +000038 segment mycode private
H. Peter Anvinea6e34d2002-04-30 20:51:32 +000039
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
65
66.printf dw _printf, seg _printf ; [2] [4] [16]
67
H. Peter Anvind7ed89e2002-04-30 20:52:08 +000068 segment mycode2 private
H. Peter Anvinea6e34d2002-04-30 20:51:32 +000069
70trampoline: pop ax
71 push cs
72 push ax
73 jmp far _printf
74
H. Peter Anvind7ed89e2002-04-30 20:52:08 +000075 segment mybss private
H. Peter Anvinea6e34d2002-04-30 20:51:32 +000076
77_bsssym resw 64 ; [12]
78
H. Peter Anvind7ed89e2002-04-30 20:52:08 +000079 segment mydata private
H. Peter Anvinea6e34d2002-04-30 20:51:32 +000080
81_selfptr dw _selfptr, seg _selfptr ; [8] [15]
82_selfptr2 dw _selfptr2 wrt mydata, mydata ; [11] [13]