Results 1 to 4 of 4

Thread: Segment reference in NASM

  1. #1

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

    Segment reference in NASM

    I am using NASM now instead of TASM but the syntax is pretty different. I am trying to a usual "Hello World" program but it gives me an error when I try to get the segment of a variable or symbol (although NASM supports that).
    Here's the code:
    PHP Code:
    bits 32
    section
    .data:
    message db "Hello""$"
    section.text:
    _start:
    mov axseg message
    mov ds
    ax
    mov dx
    message
    mov ah
    9h
    int 21h

    mov ax
    4c00h
    int 21h 
    It gives me this error:
    a.asm:6: error: binary output format does not support segment base references
    Line 6 is mov ax, seg message
    Baaaaaaaaah

  2. #2
    Lively Member
    Join Date
    Sep 2000
    Location
    England
    Posts
    94
    In Nasm

    it should be

    Code:
    bits 32
    section.data:
    message db "Hello", "$"
    section.text:
    _start:
    mov ax, [message]
    mov ds, ax
    mov dx, message
    mov ah, 9h
    int 21h
    
    mov ax, 4c00h
    int 21h
    basically segment offset are done with a [] on Nasm
    i think im still quite new to assembly hope this helps

    Peter
    "Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
    -- Judas Priest

    My email is [email protected]

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Unfortunately, [message] doesn't refer to the segment of "message". It's used to access the actual value of "message" which is "Hello". I need the segment address of "message"...I already got the offset using just message.
    Baaaaaaaaah

  4. #4
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Shouldn't it be:
    Code:
    [bits 32]
    ?

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