Marco
Marco

Reputation: 625

How do I put a string in a variable

I'm doing an program in assembly 8086 processor, but i have one doubt. I want move one word to my created string, but the assembler shows me an error: error A2004: constant value too large.

Declaration:

Fich db 'menu.txt',0

doing this:

mov Fich,'menu.txt'

Upvotes: 0

Views: 1449

Answers (1)

STLDev
STLDev

Reputation: 6174

In 8086 assembler, you cannot move a string of bytes into a memory location using a mov statement.

You can move strings using the movsb statement by loading the source address in the SI register, the destination address in the DI register, and the length of the string in the CX register, and then finally calling MOVSB.

Here is a simple example:

TARGET db 80 dup(0)
SOURCE db 'Hello', 0

mov si, offset SOURCE  ; address of SOURCE
mov di, offset TARGET  ; address of TARGET
mov cx, 6              ; number of bytes to move (size of SOURCE)
rep movsb              ; move cx number of bytes from SOURCE to TARGET

Upvotes: 2

Related Questions