Help with MOVing MEMORY to MEMORY

The question is simple: what's wrong?

org 100h ; code starts at offset 100h
use16 ; use 16-bit code

mov ah,09h
mov dx,mello
int 21h
mov word [hello],word mello
mov dx,hello
int 21h

int 20h

hello dd ?
mello db 'Mello world!',0Dh,0Ah,24h

I want the output to be:
Mello, world!
Mello, world!

But, instead, it comes out as:
Mello world!
☺ Mello world!

I can't find out what is wrong with the second printing. I suspect that it has todo with the statement "mov word [hello],word mello"

By the way, I'm using FASM to assemble this.


  • : mov word [hello],word mello
    : mov dx,hello
    The code above moves the address of "mello" to the DD hello
    then you print that value as if it was an ASCII number but it's not.
    I don't understand why you would want to print the address's value
    but if you want "Mello, world!" twice, you will never get it by
    printing the second with the adr value.
    Just repeat your first printing that worked?
    & remove everything that has to do with "hello"

    You may not have to give "mello" adr a size in
    : mov word [hello],word mello
    : mov word [hello],mello ;this might work?

  • I hope that last reply helped, but here's a second thought

    mov ah,09h
    mov dx,mello
    int 21h
    mov word [hello],mello ; hello is just a word size, not Dword
    mov dx,[hello] ; putting brackets here moves the addr of mello, stored in the low word of DD of hello into the DX reg.
    int 21h

    I do Nasm codeing lately, and it addresses variables differently than Masm & I'm not sure my help will work using Fasm.
    But I looked at Fasm and it does appear to have an intelegent syntax, associated fairly closely to that of a debuggers output, so you can follow your code while debugging and do immediate indirection with simplicity like Nasm?


    mov ah,09h
    mov dx,mello ;DS:DX = address offset of MELLO DB "string$"
    int 21h ; print once
    int 21h ; print twice (the INT doesn't change AH or DX)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion