Thread: Assembly question

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470

    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.
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur 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 geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    That worked. Thanx Mats.
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur English)

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

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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 geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    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.
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur 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 geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    i just assembled it into a COM file without the org line -- still it works.
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur 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, 04:28 AM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. C/C++ vs assembly: speed comparison
    By Just in forum C++ Programming
    Replies: 11
    Last Post: 11-25-2002, 03:33 PM