Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crash-happy VGA writing

Status
Not open for further replies.

FinalBirdman

Programmer
Sep 21, 2002
9
0
0
US
An asm prog of mine keeps crashing, and I can't figure out why. It has as simple loop like this that copies a 64000 byte array into the VGA segment (the mode is set already) The buffers and everything else is arleadey set up. This is only a part of the prog.

mov DI,0a00h
mov ES,DI
mov DI,0
mov SI,seg buffer0[0]
mov DS,SI
mov SI,0

copyloop:
mov AL,DS:[SI]
mov ES:[DI],AL
inc SI
inc DI
cmp SI,64000
jnz copyloop

When I run this, it crashes my computer. Some other notes:

This works fine:

mov DI,0a00h
mov ES,DI
mov DI,0
mov SI,seg buffer0[0]
mov DS,SI
mov SI,0

copyloop:
mov AL,DS:[SI]
mov ES:[DI],AL
inc SI
;inc DI
cmp SI,64000
jnz copyloop

And this works fine:

mov DI,0a00h
mov ES,DI
mov DI,0
mov SI,seg buffer0[0]
mov DS,SI
mov SI,0

copyloop:
mov AL,DS:[SI]
;mov ES:[DI],AL
inc SI
inc DI
cmp SI,64000
jnz copyloop

And so does this:
mov DI,0a00h
mov ES,DI
mov DI,0
mov SI,seg buffer0[0]
mov DS,SI
mov SI,0

copyloop:
mov AL,DS:[SI]
mov ES:[DI],AL
inc SI
inc DI
cmp SI,100 ;notice the change in steps
jnz copyloop

I can't figure it out. And it only happens when copying to the VGA segment, copying to other buffers works fine.

Any help is appreciated.


 
mmm... you're testing seems thorough... I like that. I'm not much on segmented memory models & I don't have dos @ work so I can't test this but it seems to me that you're blowing past the end of your segment.

You can test this by printing your addresses out & seeing where it dies.

Off-hand... a00h (2560) + 64000 = 66560 > 65536 would be the culprit. Then again...
 
Yeah, but it dies even if I just write near 10,000. That shouldn't happen. And by the way, the whole 0a00h is a type, I meant 0a000h. So that's not the problem, just in case you wondered. Thanks for the help, let me know if you have any other ideas.
 
hello
the vga memory is at 0a000h
change es to 0a000h and di to 0
than use movsb [w][d]like below
mov cx, 64000
rep movsb
or
mov cx,32000
rep movsw
or
mov cx, 16000
rep movsd
 
Just what mode are you using...? Only 64000 byte mode I know is mode 13h, 320x200x256... maybe your card doesn't support this mode nicely anymore? "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top