D
D
Daniil Sidorov2017-11-12 19:18:35
assembler
Daniil Sidorov, 2017-11-12 19:18:35

Why does an error occur when compiling in NASM?

Hello, I'm just starting to learn assembler. I have a program code, I'm trying to compile it:

Program code
.model tiny
.286
.data
msg db  'Hello World11111111111111111111111111111111111111111111111111111111'
position    word    0312h
color   db  03dh
count   word    0043h
.code
 
org 100h
 
start:
    call    clrscr
    mov ax, 0   ;word
    mov ax, 1300h
    mov bp, offset msg
    mov cx, count
    mov dx, position
    mov bl, color
    int 10h
 
    mov ah, 02h
    mov dx, position
    sub dx, 0101h
    int 10h
    mov ah, 09h
    mov al, 0c9h
    mov cx, 1
    int 10h
 
    mov ah, 02h
    inc dx
    int 10h 
    mov ah, 09h
    mov al, 0cdh
    mov cx, count
    int 10h
 
    add dx, count
    mov ah, 02h
    int 10h
    mov ah, 09h
    mov al, 0bbh
    mov cx, 1
    int 10h
 
    mov ah, 02h
    add dx, 0100h
    int 10h
    mov ah, 09h
    mov al, 0bah
    mov cx, 1
    int 10h
 
    mov ah, 02h
    sub dx, count
    dec dx
    int 10h
    mov ah, 09h
    int 10h
 
    mov ah, 02h
    add dx, 0100h
    int 10h
    mov ah, 09h
    mov al, 0c8h
    int 10h
    
    mov ah, 02h
    inc dx
    int 10h
    mov ah, 09h
    mov al, 0cdh
    mov cx, count
    int 10h
    
    mov ah, 02h
    add dx, count
    int 10h
    mov ah, 09h
    mov al, 0bch
    mov cx, 01h
    int 10h
 
    mov ah, 02h
    mov dx, 1801h
    int 10h
    int 20h
        
clrscr:
    mov ah, 0h
    mov al, 03h
    int 10h
    ret
end start


I compile with the command:
nasm -f bin first.asm -o first.com
I get the following errors:
D:\Assembler>nasm -f bin first.asm -o first.com
first.asm:1: error: attempt to define a local label before any non-local labels
first.asm:1: error: parser: instruction expected
first.asm:2: warning: label alone on a line without a colon might be in error [-w+orphan-labels]
first.asm:2: error: attempt to define a local label before any non-local labels
first.asm:3: warning: label alone on a line without a colon might be in error [-w+orphan-labels]
first.asm:3: error: attempt to define a local label before any non-local labels
first.asm:5: error: parser: instruction expected
first.asm:7: error: parser: instruction expected
first.asm:8: warning: label alone on a line without a colon might be in error [-w+orphan-labels]
first.asm:16: error: comma, colon, decorator or end of line expected after operand
first.asm:95: error: parser: instruction expected

My friends just somehow transfer this code to DoxBOX and everything works fine there. Please tell me how can I fix the program code so that it can be compiled correctly by NASM. Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question