1

I don't understand why I get an error in this assembly code. I want to assign the byte 0Ah at the memory location with address 0100h (in the data segment). I get the error "illegal immediate" at line 6 but I believe the direct addressing I am using is fine - I saw similar examples in some texts.

.MODEL small
.DATA
.STACK
.CODE
.STARTUP
    MOV Byte Ptr[0100h], 0Ah

    MOV AH, 4Ch
    INT 21H
END

Any ideas?

Fifoernik
  • 9,779
  • 1
  • 21
  • 27
Nicola
  • 222
  • 3
  • 9
  • 2
    You forgot to mention which assembler you are using. In general, that addressing mode indeed exists but the syntax may vary depending on the assembler. – Jester Jan 04 '16 at 18:30
  • 3
    Looks like masm/tasm. You probably need to add the segment. Try `MOV Byte Ptr [ds:0100h], 0Ah` – Michael Petch Jan 04 '16 at 19:01
  • You forgot a placeholder in the data segment: `DB ?` and for the stack segment some more bytes too. – Dirk Wolfgang Glomp Jan 04 '16 at 19:04
  • @DirkWolfgangGlomp Default stack in masm/tasm (16-bit targets) I believe is 1024 when a value isn't specified. – Michael Petch Jan 04 '16 at 19:08
  • I forgot to mention I use TASM. MOV Byte Ptr [ds:0100h], 0Ah works, thanks. I thought [0100h] would it be the same of ds:[0100h] and of [ds:0100h]. Are there different versions of assembly where this could be right or did I get it totally wrong? – Nicola Jan 04 '16 at 21:54
  • 1
    Different assemblers will have different syntax, so it all depends. You might have been reading about NASM or GNU Assembler which have differences. – Michael Petch Jan 04 '16 at 23:24

0 Answers0