| 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 |
| 3 |
|
| 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 |
| 10 |
|
| 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 |
| 28 |
|
| 29 |
bits 16 |
| 30 |
|
| 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] |
| 37 |
|
| 38 |
group mygroup mybss mydata |
| 39 |
group mygroup2 mycode mycode2 |
| 40 |
|
| 41 |
segment mycode private |
| 42 |
|
| 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 |
| 68 |
|
| 69 |
.printf dw _printf, seg _printf ; [2] [4] [16] |
| 70 |
.printfd dd _printf, seg _printf ; [2] [4] [16] |
| 71 |
.printfq dq _printf, seg _printf ; [2] [4] [16] |
| 72 |
|
| 73 |
segment mycode2 private |
| 74 |
|
| 75 |
trampoline: pop ax |
| 76 |
push cs |
| 77 |
push ax |
| 78 |
jmp far _printf |
| 79 |
|
| 80 |
segment mybss private |
| 81 |
|
| 82 |
_bsssym resw 64 ; [12] |
| 83 |
|
| 84 |
segment mydata private |
| 85 |
|
| 86 |
_selfptr dw _selfptr, seg _selfptr ; [8] [15] |
| 87 |
_selfptr2 dw _selfptr2 wrt mydata, mydata ; [11] [13] |