NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: c0wb0yc0d3r on August 19, 2010, 08:48:11 PM

Title: Question about registers
Post by: c0wb0yc0d3r on August 19, 2010, 08:48:11 PM
I just starting to learn assembly and I am curious as to whether I can use any register to store anything or if only certain registers can store certain data.

Any help would be awesome, thanks everyone!

EDIT:

After doing some poking around, am I right in saying that I have to use certain register for certain tasks?

For instance, i found this code snippet:
Code: [Select]
org 100h ; dos will load us at offset 100h (256) into some segment

section .text

    mov ah, 9
    mov dx, msg
    int 21h

    ret

section .data
    msg db "hello world!$"

here: http://forum.nasm.us/index.php?topic=832.msg2691#msg2691 (http://forum.nasm.us/index.php?topic=832.msg2691#msg2691)

When I compiled it as a .COM file using the -f bin flag it ran just fine. However when I modified the code like this:

Code: [Select]
org 100h ; dos will load us at offset 100h (256) into some segment

section .text

    mov ax, 9
    mov dx, msg
    int 21h

    ret

section .data
    msg db "hello world!$"

and recompiled it using the -f bin flag it no longer works. Can someone possibly explain to me why the first code snippet works and the second one does not?
Title: Re: Question about registers
Post by: Keith Kanios on August 19, 2010, 09:17:07 PM
Have a look at THIS (http://www.ctyme.com/intr/rb-2562.htm) entry in RBIL.