Change rights 644 to 755
[nasm/github.git] / test / objtest.asm
blob03b7f9e28caa507590f81753340e98cf7c2d4800
1 ;Testname=unoptimized; Arguments=-O0 -fobj -oobj.o; Files=stdout stderr obj.o
2 ;Testname=optimized; Arguments=-Ox -fobj -oobj.o; Files=stdout stderr obj.o
4 ; test source file for assembling to Microsoft 16-bit .OBJ
5 ; build with (16-bit Microsoft C):
6 ; nasm -f obj objtest.asm
7 ; cl /AL objtest.obj objlink.c
8 ; other compilers should work too, provided they handle large
9 ; model in the same way as MS C
11 ; This file should test the following:
12 ; [1] Define and export a global symbol
13 ; [2] Define a non-global symbol
14 ; [3] Define a common symbol
15 ; [4] Define a NASM local label
16 ; [5] Reference a NASM local label
17 ; [6] Import an external symbol
18 ; [7] Make a PC-relative relocated reference
19 ; [8] Reference a symbol in the same section as itself
20 ; [9] Reference a symbol in a different segment from itself
21 ; [10] Define a segment group
22 ; [11] Take the offset of a symbol in a grouped segment w.r.t. its segment
23 ; [12] Reserve uninitialised data space in a segment
24 ; [13] Directly take the segment address of a segment
25 ; [14] Directly take the segment address of a group
26 ; [15] Use SEG on a non-external
27 ; [16] Use SEG on an external
29 bits 16
31 global _bsssym ; [1]
32 global _function ; [1]
33 global _selfptr ; [1]
34 global _selfptr2 ; [1]
35 common _commvar 2 ; [3]
36 extern _printf ; [6]
38 group mygroup mybss mydata ; [10]
39 group mygroup2 mycode mycode2 ; [10]
41 segment mycode private
43 _function push bp
44 mov bp,sp
45 push ds
46 mov ax,mygroup ; [14]
47 mov ds,ax
48 inc word [_bsssym] ; [9]
49 mov ax,seg _commvar
50 mov ds,ax
51 dec word [_commvar]
52 pop ds
53 mov ax,[bp+6]
54 mov dx,[bp+8]
55 push dx
56 push ax
57 push dx
58 push ax
59 call far [cs:.printf] ; [5] [8]
60 pop ax
61 pop ax
62 call trampoline ; [7]
63 pop ax
64 pop ax
65 mov sp,bp
66 pop bp
67 retf
69 .printf dw _printf, seg _printf ; [2] [4] [16]
71 segment mycode2 private
73 trampoline: pop ax
74 push cs
75 push ax
76 jmp far _printf
78 segment mybss private
80 _bsssym resw 64 ; [12]
82 segment mydata private
84 _selfptr dw _selfptr, seg _selfptr ; [8] [15]
85 _selfptr2 dw _selfptr2 wrt mydata, mydata ; [11] [13]