Assembly question

This is a discussion on Assembly question within the Tech Board forums, part of the Community Boards category; Hi i'm trying to compile this newbies' asm prog on nasm16. but i get 'invalied combination of opcode and operands' ...

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    362

    Assembly question

    Hi i'm trying to compile this newbies' asm prog on nasm16. but i get 'invalied combination of opcode and operands' error on line 18: mov es:[bx], ah. Could anyone point out the reason please?

    Code:
    [BITS 16]
    [ORG 0100H]
    
    [SECTION .text]
    
    START:    
    
    mov ax, 0003h
    int 10h
    
    mov bx, 0b800h
    mov es, bx
    
    mov bx,0
    mov ah, 1
    mov es:[bx], ah
    
    mov ax, 0100h
    int 21h
    
    mov ax, 4c00h
    int 21h
    
    [SECTION .data]
    thx.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You will need to change your code to have:
    Code:
    mov [es:bx], ah
    or
    Code:
    es mov [bx], ah
    or
    Code:
    es
    mov [bx], ah
    See http://nasm.sourceforge.net/doc/nasm...ml#section-3.1

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    362
    That worked. Thanx Mats.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Plotting pixels in B800 video eh. Why are you specifying this is a COM file?

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    Quote Originally Posted by Bubba View Post
    Plotting pixels in B800 video eh. Why are you specifying this is a COM file?
    org 100h doesn't necessarily mean a COM file. An EXE could have its origin there as well, although I'm not sure why you'd do that.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    362
    i picked up the org 100h thing from a book. Here's the books' explanation for it: "The real mode flat model has a 256-byte prefix at the beginning of its single segment. This is the Program Segment Prefix (PSP) and it has several uses that I won't be explaining here. The PSP is basically a data buffer and contains no code. The code cannot begin until after the PSP, so the 0100H value is there to tell DOS to skip those first 256 bytes."

    Though the prog works fine when i remove the org 100h line.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by geek@02 View Post
    i picked up the org 100h thing from a book. Here's the books' explanation for it: "The real mode flat model has a 256-byte prefix at the beginning of its single segment. This is the Program Segment Prefix (PSP) and it has several uses that I won't be explaining here. The PSP is basically a data buffer and contains no code. The code cannot begin until after the PSP, so the 0100H value is there to tell DOS to skip those first 256 bytes."

    Though the prog works fine when i remove the org 100h line.
    That is because the "space for PSP" is only needed for .COM applications, not for .EXE applications.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    362
    i just assembled it into a COM file without the org line -- still it works.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by geek@02 View Post
    i just assembled it into a COM file without the org line -- still it works.
    Probably because nasm automagically adds a org 100h anyways [or something to that extent].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assembly Language Question
    By John_L in forum Tech Board
    Replies: 2
    Last Post: 03-13-2008, 07:44 PM
  2. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM
  5. C/C++ vs assembly: speed comparison
    By Just in forum C++ Programming
    Replies: 11
    Last Post: 11-25-2002, 02:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21