As Debs points out, the problem is that he has defined an EXE-DOS structure, which needs to set up the different segments, otherwise anything could be happen.
SEGMENT datos1 data
val1 DB 3
SEGMENT datos2 data
val2 DB 7
SEGMENT Pila STACK ; Stack segment
RESB 256 ; 256 bytes
InicioPila:
SEGMENT code
..start: ; Informamos que aquí empieza el código
MOV AX, Pila ; Setting up the stack
MOV SS, AX
MOV SP, InicioPila
MOV AX, datos1 ; Setting up DS
MOV DS, AX
MOV AH, 0Eh
mov AL, [val1] ; byte you want to print
OR AL, 30h
INT 10h
MOV AX, datos2 ; Setting up DS
MOV DS, AX
MOV AH, 0Eh
mov AL, [val2] ; byte you want to print
OR AL, 30h
INT 10h
MOV AH, 4ch
INT 21h ; Salimos AL DOS
compile with:
>nasmw -fobj Program.asm
>link with your favourite linker
While COM-DOS structure doesn't need to set up the differents segments because all are the same, everything lies in the same segment.
[org 100h]
[section .text]
MOV AH, 0Eh
mov AL, [var1] ; byte you want to print
OR AL, 30h
INT 10h
mov AL, [var2] ; byte you want to print
OR AL, 30h
INT 10h
RET
[section .data]
var1 db 3
var2 db 7
compile with:
> nasmw -fbin Program.asm -o Program.com