assembly woes

Started by
8 comments, last by Syrillix 20 years, 6 months ago
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
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum
Advertisement
use:
inc di
not
inc dx

or you could use:
mov es:[di],ax
and do both bytes at once
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]
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
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum
nope, nada, nothing.. eh, screw it, i''ll check out google again and see what else i can find.
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum
one last thing, is the video buffer linear in memory? im assuming it is.
oh and thanks for your quick replies too..
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum
Yes, it''s linear.
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
"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We WouldWhen 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
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
Get busy livin' or get busy dyin'... - Shawshank RedemptionIf a man is talking in the forest, and no woman is around to hear him, is he still wrong? - UnknownFulcrum
That sounds suspiciously like a page issue.

This topic is closed to new replies.

Advertisement