1 ;Testname=unoptimized; Arguments=-O0 -faout -oaouttest.o; Files=stdout stderr aouttest.o
2 ;Testname=optimized; Arguments=-Ox -faout -oaouttest.o; Files=stdout stderr aouttest.o
4 ; test source file for assembling to a.out
6 ; nasm -f aout aouttest.asm
7 ; gcc -o aouttest aouttest.c aouttest.o
8 ; (assuming your gcc is a.out)
10 ; This file should test the following:
11 ; [1] Define and export a global text-section symbol
12 ; [2] Define and export a global data-section symbol
13 ; [3] Define and export a global BSS-section symbol
14 ; [4] Define a non-global text-section symbol
15 ; [5] Define a non-global data-section symbol
16 ; [6] Define a non-global BSS-section symbol
17 ; [7] Define a COMMON symbol
18 ; [8] Define a NASM local label
19 ; [9] Reference a NASM local label
20 ; [10] Import an external symbol
21 ; [11] Make a PC-relative call to an external symbol
22 ; [12] Reference a text-section symbol in the text section
23 ; [13] Reference a data-section symbol in the text section
24 ; [14] Reference a BSS-section symbol in the text section
25 ; [15] Reference a text-section symbol in the data section
26 ; [16] Reference a data-section symbol in the data section
27 ; [17] Reference a BSS-section symbol in the data section
37 COMMON _commvar
4 ; [7]
41 ; prototype: long lrotate(long x, int num);
47 .
label rol eax,1 ; [4] [8]
48 loop .
label ; [9] [12]
53 ; prototype: void greet(void);
54 _greet
mov eax,[_integer
] ; [14]
56 mov [localint
],eax ; [14]
58 mov eax,[localptr
] ; [13]
60 push dword [_integer
] ; [1] [14]
61 push dword _printfstr
; [13]
69 _asmstr
db 'hello, world', 0 ; [2]
72 _printfstr
db "integer==%d, localint==%d, commvar=%d"
76 localptr
dd localint
; [5] [17]
77 _textptr
dd _greet
; [15]
78 _selfptr
dd _selfptr
; [16]