1; test source file for assembling to binary files 2; build with: 3; yasm -f bin -o bintest.com bintest.asm 4 5; When run (as a DOS .COM file), this program should print 6; hello, world 7; on two successive lines, then exit cleanly. 8 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 21 22[BITS 16] 23[ORG 0x100] 24 25[SECTION .text] 26 27 jmp start ; [6] 28 29endX mov ax,0x4c00 ; [1] 30 int 0x21 31 32start 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 46 47[SECTION .data] 48 49datasym db 'hello world', 13, 10, '$' ; [2] 50bssptr dw bss_sym ; [2] [11] 51dataptr dw datasym+5 ; [2] [10] 52textptr dw endX ; [2] [9] 53 54[SECTION .bss] 55 56bss_sym resb 1 ; [3] 57