Search code examples
assemblynasmmov

ASM lodsw to mov and inc


I have in my simple program loaded some strings into

mov si, song

witch load:

song:
%if 1
dw E0, C, A, E1, C, A, E2, B, A, E3, C, B
%endif
dw E0, C, A, E1, C, A, 0

E0 equ 14000 etc...

Im loading elements from it with

 lodsw; (one transition use three of them)

And I need to do it with

 mov and inc

I tried

mov ax, [si+dx]
inc dx

But this dont want to work, Any ideas


Solution

  • lodsw is equivalent (if omitting flags) to

    mov ax, word [si]
    add si, 2
    

    I am not sure you can use dx in an address expression like [si+dx] (in 16-bit mode, only si, di, bp and bx are index registers). If you don't want to change si, use bx.

    (By the way: do you really want to write 16-bit code? It's quite outdated. NASM compiles 32-bit code perfectly.)