🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.asm.x86
7 messages
7 total messages Started by tunney Wed, 10 Mar 1999 00:00
Thick
#112
Author: tunney
Date: Wed, 10 Mar 1999 00:00
6 lines
1153 bytes
I know that this is a thick question, but could someone explain to me
how to clear the screen in text and video mode, can't for the life of me
figure out how. Please help me I have an exam in this soon.
Also could someone explain int 21h service 0Ah

Thanks a million.
Re: Thick
#95
Author: TK - TBD
Date: Thu, 11 Mar 1999 00:00
49 lines
2177 bytes
tunney <bigmacmeal@hotmail.com> wrote in article
<7c6u0d$cue$1@winter.news.rcn.net>...
> I know that this is a thick question, but could someone explain to me
> how to clear the screen in text and video mode, can't for the life of me
> figure out how. Please help me I have an exam in this soon.
> Also could someone explain int 21h service 0Ah
> 
> Thanks a million.

Clearing the screen (TEXTMODE) is easy:

mov ax, 3	; set mode 3, voil� screen is cleared.
int 10h		;

For less flickering... you could clear it by filling video mem
directly, like this:

push 0B800h
pop es
xor ax, ax
xor di, di
mov cx, 16384
rep stosw

For video mode, ask someone else.

DOS Fn 0A - get input?

Do as the function tells you to, point to a buffer with

MAXLEN, CURLEN, string buffer

Where MAX/CUR-len are bytes.

Example:

dosBufThingy DB 10, 0, 10 DUP (?)

mov ah, 0Ah
mov dx, OFFSET dosBufThingy
int 21h

The CURLEN will be the number of characters you can "recall", F3??
once you're editing the text.

-- 
Regards,
TK - TBD
-= feel free to visit my old homepage @ home.c2i.net/tkjoerne =-
Re: Thick
#113
Author: Quad
Date: Thu, 11 Mar 1999 00:00
52 lines
3145 bytes
I assume that the text and video modes are respectively 80x25 (mode 3h) and
320x200 (mode 13h).

you should know that the video memory segment is 0b800h, so pointing with,
say, the registers es:di at 0b800h:0000h then sending bytes (value 0) at
this location will clear the screen (you have to move 4000 bytes :
80x25=2000 and 2000x2=4000 because each location on screen takes 2 bytes,
one for the character and the other is for the attribute). why sending 0s ??
because 0 are for the null character and the color black. here's a sample
code of how to do that... (with the basic 8086 instructions set)

    mov ax, 0b800h    ; make es point at seg b800h
    mov es, ax
    xor di, di                 ; zero di (offset within the seg)
    xor al, al                 ; zero al, this is the byte to send
    mov cx, 4000        ; we move 4000 bytes
    repnz stosb            ; repeat while not zero, store bytes at es:di

in order to clear the screen in graphic mode, you just have to do the same
thing, with the change that es:di now points to 0a000h:0000h and that we
move not 4000 bytes but 64000 (320 x 200 = 64000 bytes). then you send zeros
again...!

the function 0ah for int 21h allows the user to fill some buffer with a
string, ending when the user press 'enter'. you have to prepare the buffer
yourself in memory before calling this function. this is a special
structured buffer,
byte    size    description
0         1        maximum characters buffer can hold (N)
1         1        (on call) number of chars
                        from last input which may be recalled
                     (on ret) number of chars read, excluding the carriage
return
2    N Bytes   the input buffer itself, including the CR

when interrupting,
ah = 0ah
ds:dx = address of buffer

I hope these informations will help you !

Quad
quadid@videotron.ca

>I know that this is a thick question, but could someone explain to me
>how to clear the screen in text and video mode, can't for the life of me
>figure out how. Please help me I have an exam in this soon.
>Also could someone explain int 21h service 0Ah
>
>Thanks a million.
>
>
Re: Thick
#114
Author: Jesus Reina Carvajal
Date: Thu, 11 Mar 1999 00:00
267 lines
6808 bytes
This is a multi-part message in MIME format.
--------------43B02FC7BBB9CDD4A8EFA626
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi assembler users,

Assembler is power! Borland's compilers are fantastic!

Here I attached a program that clears the screen in text mode.
It can be used without parameters to clear screen through INT 10h or
with parameter /M or /m clearing the screen using direct access to video
memory. Last method is much faster.

CLRSCR.ASM should be compiled and linked with Borland Turbo Assembler.
tasm /ml clrscr.asm
tlink clrscr.obj /t
/t - gernerate .COM file

The function 0Ah of INT 21h is called "Buffered Keyboard Input" and is used
as follows:

 AH = 0A
 DS:DX = pointer to input buffer of the format:

  max | count  |  BUFFER (N bytes)
                            BUFFER is the input buffer
             count is the number of characters returned (byte)
    max is the maximum number of characters to read (byte)

 returns nothing

 - since strings can be pre-loaded, it is recommended that the
   default string be terminated with a CR
 - N bytes of data are read from STDIN into buffer+2
 - max buffer size is 255, minimum buffer size is 1 byte
 - chars up to and including a CR are placed into the buffer
   beginning at byte 2; Byte 1 returns the number of chars
   placed into the buffer  (extended codes take 2 characters)
 - DOS editing keys are active during this call
 - INT 23 is called if Ctrl-Break or Ctrl-C detected



Best wishes,
Jesus

tunney wrote:

> I know that this is a thick question, but could someone explain to me
> how to clear the screen in text and video mode, can't for the life of me
> figure out how. Please help me I have an exam in this soon.
> Also could someone explain int 21h service 0Ah
>
> Thanks a million.



--------------43B02FC7BBB9CDD4A8EFA626
Content-Type: text/plain; charset=us-ascii; name="clrscr.ASM"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="clrscr.ASM"

.model TINY
.code
org 100h

;----------------- Program Entry point --------------------------
Entry:
	jmp	Init		; go to initialization

;--- switch stack and set memory allocation


useMem		db	0


include video.inc



Start:

	call	videoInit
	or	al, al				; use memory? (AX is preserved in videoInt)
	jne	Use_Mem

	mov	bh, 07h				; gray chars on black background
	xor	ax, ax
	mov	cx, ax				; upper row and column (0,0)
	mov	dl, video_Cols
	mov	dh, video_Rows
	call	videoCpag
	jmp	Finish

Use_Mem:
	call	clearScrMem

Finish:
	mov	ah, 4Ch
	int	21h



Init:
	xor	ax, ax
	mov	si, 80h				; command tail
	lodsb					; get the length
	or	al, al				; check if none
	jz	Init_X
	mov	cl, al
	sub	ch, ch				; put count in cx

;--- loop through characters in command tail

Init_C:
	lodsb					; load next byte	
	cmp	al, '/'				; check if switch
        je      Init_F				; jump if so
Init_L:
	loop	Init_C				; otherwise loop back

Init_X:
	jmp	Start

;--- found slash

Init_F:
	dec	cx				; reduce count	
	jz	Init_X				; jump if no more bytes

	lodsb					; load command character	
	sub	al, 'a'-'A'			; convert to upper-case
	cmp	al, 'M'				; check if M
	jne	Init_N
	inc	ah

Init_N:
	xchg	al, ah
	jmp	Start

	mov	ax, 4cffh			; exit function
	int	21h				; execute

END Entry

--------------43B02FC7BBB9CDD4A8EFA626
Content-Type: text/plain; charset=us-ascii; name="video.inc"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="video.inc"


video_Mode	db	?	; present mode
video_Page	db	?	; active page
video_Seg	dw	0B800h	; video segment (for direct memory access), color by default
video_Cols	db	?	; screen columns
video_Rows	db	?	; screen rows
video_Size	dw	?	; video page size in bytes

MONO		equ	7	; monochrome video mode


videoInt	proc	near
	push	di
	push	si
	push	bp
	int	10h			; call video
	pop	bp
	pop	si
	pop	di
	ret
endp	; videoInt


videoInit	proc	near

	push	es
	push	ax
	push	bx

	mov	ah, 0Fh			; function
	call	videoInt		; interrupt 10H
	mov	video_Mode, al		; save mode
	dec	ah			; screen columns 0-79, not in 1-80 format
	mov	video_Cols, ah		; save columns
	mov	video_Page, bh		; save page

	mov	ax, 0040h
	mov	es, ax
	mov	ax, es:[004Ch]		; size of one video page in current mode (4096)
	shr	ax, 10
	mov	bx, 03E8h		; 1000
	imul	bx
	mov	video_Size, ax		; we get exact 4000

	mov	al, es:[0084h]		; rows on the screen -1 (0-24, not 1-25)
	mov	video_Rows, al

	mov	ax, video_Seg
	cmp	video_Mode, MONO
	jne	vInit_X
	mov	ax, 0B000h
	mov	video_Seg, ax

vInit_X:	
	pop	bx
	pop	ax
	pop	es
	ret
endp		; videoInit







;================================================
; Scroll a portion of the screen up.
;
; In: DH= upper left hand row; DL= upper left
; hand column; CH= lower left hand row; cl= lower
; left hand column; AL= lines to scroll (0 means
; clear instead of scroll); BL= attribute to use.
;=================================================
;
video_Spag	proc	near
	push	ax
	mov	ah, 6			; function
	call	videoInt		; interrupt 10H
	pop	ax
	ret
endp		; video_Spag



;================================================
; Clear a portion of the screen.
;
; In: DH= upper left hand row; DL= upper left
; hand column; CH= lower left hand row; cl= lower
; left hand column; BL= attribute to use.
;================================================
;
videoCpag	proc	near
	push	ax
	sub	al, al			; scroll lines zero (blank window)
	call	video_Spag		; clear screen
	pop	ax
	ret
endp		; video_Cpag



clearScrMem	proc	near

	mov	ax, video_Seg
	mov	es, ax
	xor	di, di
	mov	cx, video_Size
	shr	cx, 1
	mov	ax, 0720h
	rep	stosw

	ret
endp		; clearScrMem
--------------43B02FC7BBB9CDD4A8EFA626--
Re: Thick
#96
Author: black_phantom
Date: Fri, 12 Mar 1999 00:00
75 lines
3061 bytes
  "TK - TBD" <PISS_OFF_SPAMMERS_Thomas_Kjoernes@phoenix.com> wrote:
> tunney <bigmacmeal@hotmail.com> wrote in article
> <7c6u0d$cue$1@winter.news.rcn.net>...
> > I know that this is a thick question, but could someone explain to me
> > how to clear the screen in text and video mode, can't for the life of me
> > figure out how. Please help me I have an exam in this soon.
> > Also could someone explain int 21h service 0Ah
> >
> > Thanks a million.
>
> Clearing the screen (TEXTMODE) is easy:
>
> mov ax, 3	; set mode 3, voil� screen is cleared.
> int 10h		;
>
> For less flickering... you could clear it by filling video mem
> directly, like this:
>
> push 0B800h
> pop es
> xor ax, ax
> xor di, di
> mov cx, 16384
> rep stosw
>
> For video mode, ask someone else.

I think it should be "graphics" mode, not "video" mode. It's not a lot harder.
For CGA graphics modes the above will also work. For chained modes (MCGA 13h)
you clear 64k starting at 0A0000h:

clear_a0000:
mov ax, 0A000h
mov es, ax
sub ax, ax
sub di, di
mov cx, 32768
cld
rep stosw

For non-chained modes the above clears only bit plane selected in sequencer.
To clear screen you need to allow write to all 4 bit planes:

mov dx, 3c4h
mov ax, 0F02h
out dx, ax

Of course, it's a good idea to save previous bit plane write bitmask and later
restore it.

Save (in BL):
mov dx, 3c4h
mov al, 2
out dx, al
inc dx
in al, dx
mov bl, al

; Here allow write to all bitplanes and clear memory.

Restore (from BL):
mov dx, 3c4h
mov al, 2
mov ah, bl
out dx, ax

That's all for standard VGA BIOS modes. I hope that you don't need to deal
with non-standard modes ('X' or how is it called now?) - it's no harder just
more dirty work.


-- Sclerosis cannot be healed but can be forgotten --

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
Re: Thick
#97
Author: Samir Wyszynski
Date: Fri, 12 Mar 1999 00:00
81 lines
3304 bytes
black_phantom@my-dejanews.com wrote:
> 
>   "TK - TBD" <PISS_OFF_SPAMMERS_Thomas_Kjoernes@phoenix.com> wrote:
> > tunney <bigmacmeal@hotmail.com> wrote in article
> > <7c6u0d$cue$1@winter.news.rcn.net>...
> > > I know that this is a thick question, but could someone explain to me
> > > how to clear the screen in text and video mode, can't for the life of me
> > > figure out how. Please help me I have an exam in this soon.
> > > Also could someone explain int 21h service 0Ah
> > >
> > > Thanks a million.
> >
> > Clearing the screen (TEXTMODE) is easy:
> >
> > mov ax, 3     ; set mode 3, voilà screen is cleared.
> > int 10h               ;
> >
> > For less flickering... you could clear it by filling video mem
> > directly, like this:
> >
> > push 0B800h
> > pop es
> > xor ax, ax
> > xor di, di
> > mov cx, 16384
> > rep stosw
> >
> > For video mode, ask someone else.
> 
> I think it should be "graphics" mode, not "video" mode. It's not a lot harder.
> For CGA graphics modes the above will also work. For chained modes (MCGA 13h)
> you clear 64k starting at 0A0000h:
> 
> clear_a0000:
> mov ax, 0A000h
> mov es, ax
> sub ax, ax
> sub di, di
> mov cx, 32768
> cld
> rep stosw
> 
> For non-chained modes the above clears only bit plane selected in sequencer.
> To clear screen you need to allow write to all 4 bit planes:
> 
> mov dx, 3c4h
> mov ax, 0F02h
> out dx, ax
> 
> Of course, it's a good idea to save previous bit plane write bitmask and later

> That's all for standard VGA BIOS modes. I hope that you don't need to deal
> with non-standard modes ('X' or how is it called now?) - it's no harder just
> more dirty work.
> 
What do you mean nonstandard - the 32K 64K and true color where each
pixel is described by 2 or 3 consecutive bytes? 
I was exited about planar video memory on Amigas when they first came
out, and all I had was 4 color Commodore 64 but soon after I realized
that it is very awkward to handle.
Personaly I thing the new modes are much more elegant way of handling
the display. There is no need to access 4 different locations while
switching banks. Most high res VGAs have vesa BIOS or it is available as
a TSR.
Piece of cake.
Re: Thick
#98
Author: black_phantom
Date: Sat, 13 Mar 1999 00:00
97 lines
4320 bytes
In article <7cbvvv$9oc$1@winter.news.rcn.net>,
  Samir Wyszynski <samirw@connection.com> wrote:
> black_phantom@my-dejanews.com wrote:
> > =
>
> >   "TK - TBD" <PISS_OFF_SPAMMERS_Thomas_Kjoernes@phoenix.com> wrote:
> > > tunney <bigmacmeal@hotmail.com> wrote in article
> > > <7c6u0d$cue$1@winter.news.rcn.net>...
> > > > I know that this is a thick question, but could someone explain to =
> me
> > > > how to clear the screen in text and video mode, can't for the life =
> of me
> > > > figure out how. Please help me I have an exam in this soon.
> > > > Also could someone explain int 21h service 0Ah
> > > >
> > > > Thanks a million.
> > >
> > > Clearing the screen (TEXTMODE) is easy:
> > >
> > > mov ax, 3     ; set mode 3, voil=E0 screen is cleared.
> > > int 10h               ;
> > >
> > > For less flickering... you could clear it by filling video mem
> > > directly, like this:
> > >
> > > push 0B800h
> > > pop es
> > > xor ax, ax
> > > xor di, di
> > > mov cx, 16384
> > > rep stosw
> > >
> > > For video mode, ask someone else.
> > =
>
> > I think it should be "graphics" mode, not "video" mode. It's not a lot =
> harder.
> > For CGA graphics modes the above will also work. For chained modes (MCG=
> A 13h)
> > you clear 64k starting at 0A0000h:
> > =
>
> > clear_a0000:
> > mov ax, 0A000h
> > mov es, ax
> > sub ax, ax
> > sub di, di
> > mov cx, 32768
> > cld
> > rep stosw
> > =
>
> > For non-chained modes the above clears only bit plane selected in seque=
> ncer.
> > To clear screen you need to allow write to all 4 bit planes:
> > =
>
> > mov dx, 3c4h
> > mov ax, 0F02h
> > out dx, ax
> > =
>
> > Of course, it's a good idea to save previous bit plane write bitmask an=
> d later
>
> > That's all for standard VGA BIOS modes. I hope that you don't need to d=
> eal
> > with non-standard modes ('X' or how is it called now?) - it's no harder=
>  just
> > more dirty work.
> > =
>
> What do you mean nonstandard - the 32K 64K and true color where each
> pixel is described by 2 or 3 consecutive bytes? =

  Bit planes can be grouped in bytes rather than bits. Memory can be mapped
in defferent ranged between A0000h and BFFFFh. Bit planes can be accessed in
couples (odd/even modes) - that's what happens in text modes in fact. That's
all only standerd VGA; non-standard adapters can have 8 and more bit planes.
All those and other possibilities can be checked via VGA registers but I'd
rather support only standard BIOS modes.

>
> I was exited about planar video memory on Amigas when they first came
> out, and all I had was 4 color Commodore 64 but soon after I realized
> that it is very awkward to handle.
> Personaly I thing the new modes are much more elegant way of handling
> the display. There is no need to access 4 different locations while
> switching banks. Most high res VGAs have vesa BIOS or it is available as
> a TSR.
> Piece of cake.
>

-- Sclerosis cannot be healed but can be forgotten --

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads