• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

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

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
KyleG
Asked:
KyleG
  • 3
  • 2
  • 2
  • +1
1 Solution
 
KyleGAuthor Commented:
Alright well I've figured it out, so whoever the firs person is that answers this correctly gets the points
0
 
TascoDLXCommented:
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
 
TascoDLXCommented:
Quick correction:

LOOP is a reserved word.  Change that to TEXT_LOOP.
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
rtfCommented:
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
 
BeyondWuCommented:
mov     ax,B800h
mov     es,ax
xor     di,di
mov     ax,020h
mov     cx,80*25
rep     stosw
0
 
BeyondWuCommented:
Oops, rtf already posted it.:o(
0
 
KyleGAuthor Commented:
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
 
TascoDLXCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now