flat assembler
Message board for the users of flat assembler.

Index > DOS > string question

Author
Thread Post new topic Reply to topic
crackrock



Joined: 09 Apr 2005
Posts: 3
crackrock
Hi, I've got a newbie question about string handling:

ok, so let's say i'm writing a hello world program and have the following code:

Code:
hello db 'Hello world!',24h

mov ah,9

mov dx,hello

int 21h
    


ok, so my question is does dx contain the memory address for the string hello? when you do mov's on variables, does it just move the memory addresses?

-crackrock

_________________
Hello, world.
Post 11 Apr 2005, 13:07
View user's profile Send private message Reply with quote
Giedrius



Joined: 13 Feb 2005
Posts: 40
Location: Lithuania
Giedrius
hello is address, [hello] is the character that hello address contain. [hello]='H', [hello+1]='e' etc...

_________________
Better to rule in hell, than to be a slave in heaven...
Post 11 Apr 2005, 15:48
View user's profile Send private message Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey
"mov dx,hello" puts a memory pointer to the hello world string into the DX register. When you do mov's it doesn't always move memory addresses, it depends on how you use the command, below are examples.

Code:
;moving a value into a register
some_value dw 0xBEEF
mov dx,[some_value]

;Moving two bytes into a register.
;This would move "He" from your 
;hello world string into DX.
mov dx,word [hello]

etc...
    
Post 12 Apr 2005, 08:32
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
check my tutorial it's nicely explained there. Somewhat lot to read but you can be sure you understand it.
Post 12 Apr 2005, 11:33
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Bitdog



Joined: 18 Jan 2004
Posts: 97
Bitdog
yes & no, yes

MOV DX,HELLO ;move offset adr of HELLO to DX reg

SEG:OFF = SEGMENT:OFFSET address=adr is the full adr required to
address memory for read/write, but in ASM the DS seg reg is default
so the adr of HELLO is held in DS:DX after your MOV DX,HELLO
but DS is not updated by the MOV,
so you have to set DS to your data segment where the HELLO data
is located before the INT 21h instruction.
In a .COM file DS=CS at startup
in an .EXE file, data seg is not= to CS=Code Segment = text

(You need a JMP OVERhello to get IP=Instruction Pointer over the
HELLO data during "run time" = program execution.)

There might be some stuff that interests you in this ENV thingie,
http://bitdog.home.att.net/files/fasmenv.zip
unzips to path and creates an environment/dir-tree.
Post 21 Apr 2005, 07:33
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.