How do I put a word in a variable

前端 未结 1 982
情歌与酒
情歌与酒 2021-01-28 18:27

I\'m doing an program inassembly 8086 processor, but i have one doubt. I want move one word to my created string, but the compiler show me an error: error A2004: constant value

1条回答
  •  不知归路
    2021-01-28 18:50

    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
    

    0 讨论(0)
提交回复
热议问题