flat assembler
Message board for the users of flat assembler.

Index > Main > moving stuff into memory

Author
Thread Post new topic Reply to topic
Laxori666



Joined: 05 Mar 2004
Posts: 6
Location: NYC
Laxori666
This is a general question, but the specific example I use is to address video memory in DOS.

So yes, es = 0A000h, and I want to move into that segment al which equals a color. In [xPos] and [yPos] I have the x and y positions which I want to use, but it doesn't let me do this:

Code:
mov byte [es: [xPos] + ( [yPos] * 320 )], al
    


it apparently doesn't like the [xPos] within the []. It compiles without the []'s around xpos, but that is clearly not what I want. I don't want to put in its memory address, I want to put in the value stored there... I also tried this

Code:
mov bx, [xPos]
mov cx, [yPos]
mov byte [es: bx + ( cx * 320 )], al
    


but it doesn't like this either. Any help on how to do this?[/code]

_________________
Laxori Shiin, Misguided Fool
Post 09 Mar 2004, 01:02
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
16-bit code has many limitations:
Code:
push     0A000h
pop   es
mov       cx,[yPos]
shl        cx,6
mov     di,cx
shl    cx,2
add     di,cx
add    di,[xPos]
stosb    

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 09 Mar 2004, 01:31
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Laxori666



Joined: 05 Mar 2004
Posts: 6
Location: NYC
Laxori666
Ah, thanks a lot for that. I'd never have been able to figure that out myself, I'm still a newbie at ASM, but I understand what it's doing =).

Now I just need a random number generator... hmma...

_________________
Laxori Shiin, Misguided Fool
Post 09 Mar 2004, 03:04
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
read fasm documentation for allowed addressing modes, i think they are there. They also differ for 16 bit code (DOS) and 32 bit code (windoze / linux).
Post 09 Mar 2004, 19:08
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
asmdemon



Joined: 18 Jan 2004
Posts: 97
Location: Virginia Beach, VA
asmdemon
you need random numbers, here is a link that shows c and asm examples...
Laughing
http://www.agner.org/random/randoma.htm

_________________
It is better to be on the right side of the devil than in his path.
Post 09 Mar 2004, 22:37
View user's profile Send private message Visit poster's website 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. Also on YouTube, Twitter.

Website powered by rwasa.