NASM 0.94
[nasm/avx512.git] / test / bintest.asm
blob6799b3878e58ff98882af2523cdf728ce13367ee
1 ; test source file for assembling to binary files
2 ; build with:
3 ; nasm -f bin -o bintest.com bintest.asm
5 ; When run (as a DOS .COM file), this program should print
6 ; hello, world
7 ; on two successive lines, then exit cleanly.
9 ; This file should test the following:
10 ; [1] Define a text-section symbol
11 ; [2] Define a data-section symbol
12 ; [3] Define a BSS-section symbol
13 ; [4] Define a NASM local label
14 ; [5] Reference a NASM local label
15 ; [6] Reference a text-section symbol in the text section
16 ; [7] Reference a data-section symbol in the text section
17 ; [8] Reference a BSS-section symbol in the text section
18 ; [9] Reference a text-section symbol in the data section
19 ; [10] Reference a data-section symbol in the data section
20 ; [11] Reference a BSS-section symbol in the data section
22 BITS 16
23 ORG 0x100
25 SECTION .text
27 jmp start ; [6]
29 end mov ax,0x4c00 ; [1]
30 int 0x21
32 start mov byte [bss_sym],',' ; [1] [8]
33 mov bx,[bssptr] ; [7]
34 mov al,[bx]
35 mov bx,[dataptr] ; [7]
36 mov [bx],al
37 mov cx,2
38 .loop mov dx,datasym ; [1] [4] [7]
39 mov ah,9
40 push cx
41 int 0x21
42 pop cx
43 loop .loop ; [5] [6]
44 mov bx,[textptr] ; [7]
45 jmp bx
47 SECTION .data
49 datasym db 'hello world', 13, 10, '$' ; [2]
50 bssptr dw bss_sym ; [2] [11]
51 dataptr dw datasym+5 ; [2] [10]
52 textptr dw end ; [2] [9]
54 SECTION .bss
56 bss_sym resb 1 ; [3]