Archived

This topic is now archived and is closed to further replies.

Syrillix

assembly woes

Recommended Posts

man, this is irritating me... ok heres the problem, im trying to access the video segment directly for text output. everything ive read says this: mov ax, 0B800H mov es, ax xor di, di ; clear di now you access vid buffer with es:[di] sooo this should work (and is how ive seen it done alot of the time): mov al, ''A'' mov ah, 4 ; red mov es:[di], al inc dx mov es:[di], ah but no matter what i do nothing shows up on the screen. at first i would blame it on running it under the Dos Em in win xp but i have another program (written by someone else) that uses the same method that works fine. and i cant see where im going wrong. so if any assembly gurus care to shed some light on this it would be very much appreciated. Get busy livin'' or get busy dyin''... - Shawshank Redemption Altered Vision

Share this post


Link to post
Share on other sites
Well, among other things, I don't understand what you're incrementing dx for. That's probably your problem right there—your attribute is overwriting your character, and the attribute never even gets set. You haven't said which assembler this is for, but I'm assuming that it's something like TASM.

Something that's sometimes a problem is that you're assuming that page 0 is visible when it's actually not. I'd suggest setting the page explicitly, just in case:

mov ax, 500h
int 10h

Otherwise, you could ask the BIOS which page is currently visible and calculate the offset accordingly.

Now, I'm just going to run through approximately how I'd do it, just as an excersize for thinking (of course, there are tons of "right" ways to do it):

We need to make sure that we have the segment and offset of the screen buffer (we'll assume the origin at the moment) in the right registers for stosw (which we'll use later):

mov es, 0b800h
mov edi, 0


Then we have to set up the character and the attribute in the right register (ax) for stosw:

mov al, 'A'
mov ah, 4


Finally, we write the character to the buffer (using a string instruction for just one character seems silly, but it's easier to use and will be good when we display things in a loop):

stosw


Needless to say, if you're trying to use 32-bit code, then this won't work because we'll have to have set up a descriptor table entry for the video buffer and have a selector to it. Otherwise, I think that what I showed should work just fine.


[edited by - merlin9x9 on October 7, 2003 9:44:49 PM]

Share this post


Link to post
Share on other sites
Try this:
mov ax, 0003h ; text mode
int 10h

in AL put other values, prabobly Windows is using mode which screen buffer is at B000h (monohrome), but You try to use color screen. Simple try to reset it
Or try to change segment to B000h





"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We Would
When Losers Say Its Over With You Know That It’s A Lie The Gods Made Heavy Metal And It’s Never Gonna Die"

THE GODS MADE HEAVY METAL/by
ManOwaR

Share this post


Link to post
Share on other sites
yeah, i tried that after a few google runs. no joy...
but i did find something strange, when i run it. its just a blank screen. but if i hit the up arrow it shows my app running. i hit it again and goes strange (top 3 lines are my app, the rest is all upside down J or some other letter.
anyone know what that implies?

Get busy livin'' or get busy dyin''... - Shawshank Redemption
Altered Vision

Share this post


Link to post
Share on other sites