×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

NASM newbies

NASM newbies

NASM newbies

(OP)
I'm trying to learn NASM, starting with 16 bit DOS, but I'm
not having much luck with sources.  The official NASM site
has a beginner's site, but it doesn't work.  Does anyone have any suggestions?  I would hate to waste peoples' time
posting beginner questions on a pro site.  Any references
would be appreciated.

RE: NASM newbies

Are you saying you are attempting to learn how to use the NASM assembler or how to use Assembly (the language)... the compiler can be downloaded and there should also be documentation on the site that you can also download.  If you know how to "code for" MASM, NASM is a bit fickle (fewer directives, some slight syntax differences) but no more difficult than adjusting to AT&T syntax (gas)... post newbie questions please!  Often those are the most interesting.

RE: NASM newbies

"gas" is the assembler ultimatum


Do not rejoice that ur code works.
it might be a special case of an error

RE: NASM newbies

(OP)
To Twistor:  Actually, both.  Here's my current problem.
Attempting to assemble a simple, sort of "Hello World",
program, the NASM16 assembler is telling me that my segment
names are "unrecognized" and that my '..start:' label is an
'unrecognized special symbol'.  O.K., so I'm doing something
wrong.  But, I can't seem to find any answer as to what in
the NASM manual.  In addition I have some sample source code
that came with the text I'm using and it won't assemble
either - same errors!  But, I know the source code is good
because the obj and exe files came along with the source.
Could I have an os problem?

To Sarnath:  Maybe so, but at my level it shouldn't make any
difference and (as an old Fortraner) Intel syntax feels more
comfortable.  Besides, for NASM I have a 'textbook' which
doesn't assume a PhD in CS.

RE: NASM newbies

--- hello.asm (for DOS/Windows & NASM)
SEGMENT .CODE
..start:
        push    cs
        pop     ds
        mov     ah,9
        mov     dx,hello
        int     21h
        mov     ah,4ch
        int     21h
        ret

hello   db      'Hello, world!',13,36
---
Assemble with
nasm -o hello.obj -f obj hello.asm
Link with your favourite linker

Wouter Dijkslag
 
http://www.wody.demon.nl
 

RE: NASM newbies

I think "..start" is the problem.
Jus say "start:"
That would do..
If this works, vote me as the TIP Master of the week..
ha ha ha...
just joking..

Sarnath


Do not rejoice that ur code works.
it might be a special case of an error

RE: NASM newbies

Hello,
No, this does not work. Since the .OBJ file-format is used, ..start must be used as the startup-symbol.
If you do not do this, at link-time the linker will complain about no progam entry point, because NASM doesn't know what other label to use, since it doesn't support something like 'end start' like TASM and MASM etc support.
The code as I have shown above is 100% correct.

Wouter Dijkslag
 
http://www.wody.demon.nl
 

RE: NASM newbies

(OP)
To Wody and Sarnath:  Thank you ladies and/or gentlemen;  I
think I have resolved the problem.  I may have been (I hang
my newbi head in shame) misspecifying the output format as
bin and nasm, thinking I was trying to create a COM file,
didn't like the segment names or the start label.  My IDE
(nasmide) appears to be under the same impression - indicating only that I dont know how to use it.
Now I have a new problem, having to do with the stack.  Like
Wednesday's child, newbis are full of woe.  I'm going to
start a new thread for it.

Thanks again.

RE: NASM newbies

--- hello.asm (for DOS/Windows & NASM) (obj->com version)
SEGMENT .CODE
resb 100h
..start:
        mov     ah,9
        mov     dx,hello
        int     21h
        ret

hello   db      'Hello, world!',13,36
---
Assemble with
nasm -o hello.obj -f obj hello.asm
Link with your favourite linker

--- hello.asm (DOS/Windows & NASM) (bin fileformat version)
org 0100h
start:
        mov     ah,9
        mov     dx,hello
        int     21h
        ret

hello   db      'Hello, world!',13,36
---
Assemble with
nasm -o hello.com -f bin hello.asm


Wouter Dijkslag
 
http://www.wody.demon.nl
 

RE: NASM newbies

;The previous examples require a linker. It creates a simple 16-bit dos .com file.
;use:  nasmw -fbin hello.asm -o hello.com

    org    100h
start:
    jmp    begin
data:
    msg    db     "Hiya there!$"

begin:    
    lea     dx, [msg]     ; load offset of string into dx register
    mov   ah, 09          ; set ah to function 9 "print $-terminated string"
    int     21h              ; call dos services

    mov   ax, 4c00h     ; set ah to 0 for "exit fucntion"
    int     21h              ; call dos services

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close