#### Archived

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

# assembly woes

This topic is 5396 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
use:
inc di
not
inc dx

or you could use:
mov es:[di],ax
and do both bytes at once

##### 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, 500hint  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, 0b800hmov  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 on other sites
yeah, inc dx was a typo, was in abit of rush. was meant to be di.

well i''ll give those a try.

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

##### Share on other sites
nope, nada, nothing.. eh, screw it, i''ll check out google again and see what else i can find.

##### Share on other sites
one last thing, is the video buffer linear in memory? im assuming it is.
oh and thanks for your quick replies too..

##### Share on other sites
Yes, it''s linear.

##### 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"

ManOwaR

##### 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 on other sites
That sounds suspiciously like a page issue.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 15
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631724
• Total Posts
3001903
×