1 ; test source file for assembling to COFF
2 ; build with (under DJGPP, for example):
3 ; nasm -f coff cofftest.asm
4 ; gcc -o cofftest cofftest.c cofftest.o
6 ; This file should test the following:
7 ; [1] Define and export a global text-section symbol
8 ; [2] Define and export a global data-section symbol
9 ; [3] Define and export a global BSS-section symbol
10 ; [4] Define a non-global text-section symbol
11 ; [5] Define a non-global data-section symbol
12 ; [6] Define a non-global BSS-section symbol
13 ; [7] Define a COMMON symbol
14 ; [8] Define a NASM local label
15 ; [9] Reference a NASM local label
16 ; [10] Import an external symbol
17 ; [11] Make a PC-relative call to an external symbol
18 ; [12] Reference a text-section symbol in the text section
19 ; [13] Reference a data-section symbol in the text section
20 ; [14] Reference a BSS-section symbol in the text section
21 ; [15] Reference a text-section symbol in the data section
22 ; [16] Reference a data-section symbol in the data section
23 ; [17] Reference a BSS-section symbol in the data section
33 COMMON _commvar
4 ; [7]
37 ; prototype: long lrotate(long x, int num);
43 .
label rol eax,1 ; [4] [8]
44 loop .
label ; [9] [12]
49 ; prototype: void greet(void);
50 _greet
mov eax,[_integer
] ; [14]
52 mov [localint
],eax ; [14]
54 mov eax,[localptr
] ; [13]
56 push dword [_integer
] ; [1] [14]
57 push dword _printfstr
; [13]
65 _asmstr
db 'hello, world', 0 ; [2]
68 _printfstr
db "integer==%d, localint==%d, commvar=%d"
72 localptr
dd localint
; [5] [17]
73 _textptr
dd _greet
; [15]
74 _selfptr
dd _selfptr
; [16]