I did another tutorial and came accross the following piece of code.
My question is, why should the code be placed into the AX register before moving it to the DS. Why can't it be moved directly into the DS?Code:; This is a simple program which displays "Hello World!" ; on the screen. .model small .stack .data Message db "Hello World!$" ; message to be display .code mov dx,OFFSET Message ; offset of Message is in DX mov ax,SEG Message ; segment of Message is in AX mov ds,ax ; DS:DX points to string mov ah,9 ; function 9 - display string int 21h ; call dos service mov ax,4c00h ; return to dos DOS int 21h END start ;end here
Like this:Well I tried it and the program didn't work any more. But I do not understand why.Code:; This is a simple program which displays "Hello World!" ; on the screen. .model small .stack .data Message db "Hello World!$" ; message to be display .code mov dx,OFFSET Message ; offset of Message is in DX mov ds,SEG Message ; segment of Message is in DS mov ah,9 ; function 9 - display string int 21h ; call dos service mov ax,4c00h ; return to dos DOS int 21h END start ;end here
Can somebody explain this to me? I am sure this is an obvious beginner-question.
Thanks for all help!




.
Reply With Quote