What you are experiencing is a quirk in MASM syntax. When you have a memory operand with just an immediate value in it that isn't a label (ie [0000]
or [0010]
), MASM will generate an Immediate mode Illegal
error. There really isn't anything wrong with such an instruction, but MASM has specific syntax for it. You must explicitly specify the segment register. Many assemblers will assume DS for this case but MASM doesn't.
To get around this problem use this syntax:
MOV [DS:0000],AX
MOV [DS:0010],AX
MASM also allows:
MOV DS:[0000],AX
MOV DS:[0010],AX
The first one is preferred since TASM (A MASM compatible assembler) doesn't support the latter form. If you place the segment inside it should work with both MASM and TASM assemblers as well as the open source JWASM assembler as well.
If your memory operand includes a register and an offset then MASM will not complain, so this is valid MASM syntax:
MOV [BX+0000],AX
MOV [BX+0010],AX
If you wish to move an immediate value (source) to a memory address that is just an immediate reference then the syntax looks like:
MOV WORD PTR [DS:0000], 0100h
MOV BYTE PTR [DS:0000], 00h
It should be noted that the value 0010 is decimal 10 (not HEX). It is unclear if you meant to use decimal or hex in your code. HEX values have an H
suffix.
Note: I made a comment about zeroing a segment register that is now deleted. Although my comment was correct I didn't look close enough to realize that you did set DS to 0000 so your code is accessing 0000:0000 and 0000:0010. In that regard your code is correct although it is unclear why you are modifying that part of memory. On an IBM-PC compatible system the interrupt vector table (IVT) is in the first 1024 bytes of memory. You may be on a non IBM-PC compatible system and what you are doing may not be a problem at all. I just wanted to give you a heads-up about it.