Results 1 to 16 of 16

Thread: A simple hello world

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    A simple hello world

    I just downloaded the latest version of nasm but the "Hello World!" code in the FAQ doesn't work now. It gives me some kind of error message on Line #1. I just restarted doing assembly after a few months and I remember I was able to run some asm code using nasm but can't now. Any idea on what would the starting lines for Nasm (eg .Stack, .Code, etc) and where to put the actual code?
    Baaaaaaaaah

  2. #2
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    type it

    type your program here and i will see if i can halp u but whole program please
    mm

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    PHP Code:
        jmp    start
    Message1    db 
    "Hello World!$"

    start:
        
    mov    ah, 09h
        mov    dx
    offset Message1
        int    21h

        mov    ax
    4c00h
        int    21h 
    Baaaaaaaaah

  4. #4
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    try this

    .modal small
    .stack 100h
    .data
    rec db 'zdravo narode(hello world)$'
    .code
    start:
    mov dx,@data
    mov ds,dx
    mov dx,offset rec
    mov ah,9h
    int 21h
    mov ah,4ch
    int 21h
    end start
    mm

  5. #5

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Doesn't work - gives me errors (starting from line #1) saying something like "attempt to define a local label before any non-local labels". Also gives me an error message on line 9 saying "Comma or end of line expected" and another error on line #14 saying "parser: instructions expected".
    Baaaaaaaaah

  6. #6
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    hmhmh

    i think we don't use the same version of asm or something like that

    try again

    jmp start
    rec db 'ererrw$'
    start:
    mov dx,@data
    mov ds,dx
    mov dx,offset rec
    mov ah,9h
    int 21h
    mov ah 4ch
    int 21h


    or something like this it should works
    mm

  7. #7

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Still doesn't work.
    Baaaaaaaaah

  8. #8
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    sranje

    try to download this version of asm and 100% it will works
    mm

  9. #9
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    sranje

    well i sugest u to download some other version of asm becouse seample which i gave u is fine and it works very good on my conm

    here some code from my program:

    .model small
    .stack 100h
    .data
    poruka db 13,10,'usa$'
    sifra db 'minja$'
    duz equ $-sifra
    text db 13,10,'Enter password:$'
    poz db 13,10,'HMHMHM$'
    .code
    start:
    mov dx,@data
    mov ds,dx
    poc:
    mov dx,offset text
    mov ah,9
    int 21h
    mov bx,0
    mov cx,0
    ponovi:
    xor ax,ax
    mov ah,8
    int 21h
    cmp al,13
    je lab1
    cmp al,sifra[bx]
    jne lab2
    ispis:
    mov dl,'*'
    mov ah,2
    int 21h
    inc bx
    jmp ponovi
    lab2:
    mov cx,1
    jmp ispis
    lab1:
    cmp cx,1
    jne p2
    p1:
    lea dx,poruka
    mov ah,9
    int 21h
    jmp poc
    p2:
    cmp bx,duz-1
    jne p1
    lea dx,poz
    mov ah,9
    int 21h
    kraj:
    mov ah,4ch
    int 21h
    end start


    tell me if it works
    mm

  10. #10
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    else

    well i sugest u to download some other version of asm becouse seample which i gave u is fine and it works very good on my conm

    here some code from my program:

    .model small
    .stack 100h
    .data
    poruka db 13,10,'usa$'
    sifra db 'minja$'
    duz equ $-sifra
    text db 13,10,'Enter password:$'
    poz db 13,10,'HMHMHM$'
    .code
    start:
    mov dx,@data
    mov ds,dx
    poc:
    mov dx,offset text
    mov ah,9
    int 21h
    mov bx,0
    mov cx,0
    ponovi:
    xor ax,ax
    mov ah,8
    int 21h
    cmp al,13
    je lab1
    cmp al,sifra[bx]
    jne lab2
    ispis:
    mov dl,'*'
    mov ah,2
    int 21h
    inc bx
    jmp ponovi
    lab2:
    mov cx,1
    jmp ispis
    lab1:
    cmp cx,1
    jne p2
    p1:
    lea dx,poruka
    mov ah,9
    int 21h
    jmp poc
    p2:
    cmp bx,duz-1
    jne p1
    lea dx,poz
    mov ah,9
    int 21h
    kraj:
    mov ah,4ch
    int 21h
    end start


    tell me if it works
    mm

  11. #11

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    There is no other version of asm. I think you are talking about the assembler. Right now I am using NASM 0.98 but I'll try to use TASM and see if that works.
    Baaaaaaaaah

  12. #12
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    yes

    i work whit that kind of asembller TASM i don't know what is NASM and all programs from upside going to work if u download TASM

    end i think u gonna find good version of TASM but if you need help just say

    good luck
    mm

  13. #13
    Addicted Member CodeRonin's Avatar
    Join Date
    Jul 2002
    Location
    Vienna, Austria
    Posts
    233

    mmiill

    This is TASM, so it certainly won't work in Nasm...
    However, I wouldn't work with:
    mov dx, offset rec
    I'd use
    lea dx, rec

    It's the newer and better way.

    dozwidanie
    CodeRonin
    Code Ronin

  14. #14
    Lively Member mmiill's Avatar
    Join Date
    May 2002
    Location
    SERBIA
    Posts
    73

    !

    ok lea is better than mov dx,offset text , but his question was about mov etc.

    do u know something about programing whit PORT ......??

    mm

  15. #15
    Hyperactive Member
    Join Date
    Jun 2002
    Posts
    299
    type this in. I had the same problem too. Hope this helps.

    section .data

    db txtString "Hello World$"

    section .bss

    section .text

    @start:

    mov dx,txtString
    mov ah,9h
    int 21h

    @end:
    mov ah,4Ch
    int 21h

  16. #16
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    mmiill, that code listing works in NASM?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width