?
Solved

Clear screen loop, when directly accessing video (ie not thru BIOS)

Posted on 2003-03-18
8
Medium Priority
?
359 Views
Last Modified: 2008-03-10
Hey everyone,
I think the name pretty much says it all, but what I'd like to do is this: create a loop that would set every character on the screen (80 x 25) to, say, a space (20 hex). Here is the code to set a single character (bottom right character becomes a $):

mov ax,B800  ; address of video memory
mov ds,ax
mov byte[0F9E],24  ;put the $ character on the bottom right of the screen (the last character).

Since I'm not very proficient with assembly I'm not too sure how I would go about looping this so that every 2nd byte is filled with a 20h.

Thanks for the help,
KyleG

0
Comment
Question by:KyleG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 

Author Comment

by:KyleG
ID: 8162697
Alright well I've figured it out, so whoever the firs person is that answers this correctly gets the points
0
 
LVL 3

Accepted Solution

by:
TascoDLX earned 800 total points
ID: 8162827
Well, here's the simple version.  Although the simplest version would be to use the appropriate interrupt to reset the display, this version accesses the display memory directly (as requested).

This code sets every character word to 0x20 0x07.  If you don't want to set the attribute, change "mov [bx],0720h" to "mov byte[bx],20h".

mov ax,B800h
xor bx,bx
mov ds,ax
LOOP:
mov [bx],0720h
add bx,2
cmp bx,4000 ;; = 80*25*2
jl  LOOP
0
 
LVL 3

Expert Comment

by:TascoDLX
ID: 8162841
Quick correction:

LOOP is a reserved word.  Change that to TEXT_LOOP.
0
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 

Expert Comment

by:rtf
ID: 8163249
Another solution would be to use the STOSW instruction.

mov     ax,0B800h
mov     es,ax

mov     ax,0720h   ;AH=Attribute, AL=Char to display
xor     di,di
mov     cx,2000    ;# of words to store
rep      stosw
0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 8163273
mov     ax,B800h
mov     es,ax
xor     di,di
mov     ax,020h
mov     cx,80*25
rep     stosw
0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 8163280
Oops, rtf already posted it.:o(
0
 

Author Comment

by:KyleG
ID: 8163364
tasco: i was doin this with Debug, so i dont think LOOP works. but since it is a valid answer i'm gonna hafta give the points to him.
sorry guys
0
 
LVL 3

Expert Comment

by:TascoDLX
ID: 8163633
Thanks Kyle.

Just for clarification, that last instruction was a JL that I mislabelled.

And you can do it with DEBUG, you just need to count bytes.

  mov ax,B800
  xor bx,bx
  mov ds,ax
  ;; Loop starts here
  mov [bx],0720
  add bx,2
  cmp bx,0FA0
  db  7C,F2

7C is the JL instruction and F2 is a signed displacement.
Or you could use JL if you know the absolute address of the first instruction in the loop.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question