The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: cqzhy1986 on February 27, 2009, 07:36:39 AM

Title: MASM611 problem
Post by: cqzhy1986 on February 27, 2009, 07:36:39 AM

.model tiny

.data
L1 db 30h
L2 db 40h

.code
start:
    org 100h
    mov ax, [L1]
    mov bx, [L2]
    add ax, bx
end start


MASM611 error message is:

Assembling: test.asm
test.asm(10): error A2070: invalid instruction operands
test.asm(11): error A2070: invalid instruction operands

someone tell me what's wrong with my code?  :'(
Title: Re: MASM611 problem
Post by: Neil on February 27, 2009, 09:29:56 AM
You have defined your data as byte and are trying to move it into 16 bit registers, you should use al & bl, also the brackets are not needed.
Title: Re: MASM611 problem
Post by: cqzhy1986 on February 27, 2009, 03:42:29 PM
Quote from: Neil on February 27, 2009, 09:29:56 AM
You have defined your data as byte and are trying to move it into 16 bit registers, you should use al & bl, also the brackets are not needed.

I thought if the brackets are missed, the address will be loaded into registers.

I am a newbie and I will try your advice, thank you
Title: Re: MASM611 problem
Post by: FORTRANS on February 27, 2009, 06:30:43 PM
Quote from: Cao Huanyin on February 27, 2009, 03:42:29 PM
Quote from: Neil on February 27, 2009, 09:29:56 AM
You have defined your data as byte and are trying to move it into 16 bit registers, you should use al & bl, also the brackets are not needed.

I thought if the brackets are missed, the address will be loaded into registers.

I am a newbie and I will try your advice, thank you

Hi,

   A diifferent assembler uses that action (NASM).  MASM uses
the OFFSET operator to load an address.


        MOV     BX,L1   ; loads the contents of L1
        MOV     BX,[L1] ; loads the contents of L1
        MOV     BX,OFFSET L1       ; loads the address offset of L1


Steve N.
Title: Re: MASM611 problem
Post by: cqzhy1986 on February 28, 2009, 08:24:22 AM
Oh...... different rules for different tools...... it is easy to make newbie confused.....
Quote from: FORTRANS on February 27, 2009, 06:30:43 PM
Hi,

   A diifferent assembler uses that action (NASM).  MASM uses
the OFFSET operator to load an address.


        MOV     BX,L1   ; loads the contents of L1
        MOV     BX,[L1] ; loads the contents of L1
        MOV     BX,OFFSET L1       ; loads the address offset of L1


Steve N.