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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I get text at the top left of a cleared screen with asm?

Status
Not open for further replies.

redwing26

Programmer
Feb 16, 2006
21
GB
I scroll up the screen in nasm using into 10,6 to clear it I then want to print

ZeonOS
ReadyFI
Code:
^^at the top left of the cleared section of the screen, what happens in reality is the screen clears but the text  appears half way down the cleared section of the screen e.g

--------cleared area start--------------



Zeon
ReadyFI


-------cleared area end------------------

;----------------------------------------------------------------------
; Hello World Operating System
;
; Joel Gompert 2001
;
; Disclaimer: I am not responsible for any results of the use of the contents
;   of this file
;----------------------------------------------------------------------

; --------------------------------------------
;  Here is the operating system entry point
; --------------------------------------------
begin:
	mov	ax, cs		; Get the current segment
	mov	ds, ax		; The data is in this segment
	cli			; disable interrupts while changing stack
	mov	ss, ax		; We'll use this segment for the stack too
	mov	sp, 0xfffe	; Start the stack at the top of the segment
	sti			; Reenable interrupts

	mov	si, msg		; load address of our message
	call    zap
	call	putstr		; print the message


hang:
	jmp	hang		; just loop forever.

; --------------------------------------------
; data for our program


msg	db	'Zeon', 0
stx	db	'ReadyFI', 0

; ---------------------------------------------
; Print a null-terminated string on the screen
; ---------------------------------------------

zap:
;Gives you an on-screen button to click on with the mouse, and
;proceeds only when you do!
mov ah,06h ;this calls SCROLL SCREEN UP
mov al,00h ;AL specifies how many lines... 0 just clears the screen
mov ch,00h
mov cl,00h
mov dh,255
mov dl,255
int 10h
retn

putstr:
	lodsb		; AL = [DS:SI]
	or al, al	; Set zero flag if al=0
	jz putstrd	; jump to putstrd if zero flag is set
	mov ah, 0x0e	; video function 0Eh (print char)
	mov bx, 0x0007	; color
	int 0x10
	jmp putstr
putstrd:
	retn

How would I get the desired result?
 
I don't have masm installed on this machine so I can't test anything, but as you haven't set the video mode prior to the call to 0600h, I would prseume the default to be 80 columns by 25 rows - so DH and DL should contain 25 and 80 respectively.

Function 0600h clears a WINDOW, which may or may not be the whole screen (and in your case seems to be more than the screen) - is it possible that the function wraps around the video buffer?.

You might also consider using function 02h to set the cursor position prior to the call to function 0eh.


Hope this helps.

[vampire][bat]
 

try this..
i don't have nasm but it worked with a86.

mov ah,06
mov al,00
mov bh,07
mov cx,00
mov dx,184fh
int 10h
 
the above code will clear the screen.
add the following code to set cursor
position.

mov ah,02
mov dl,30
mov bh,00
mov dx,00
int 10h
 
Hi folks,

I am really enjoying asm and making my own crapy os but I have really been struggling with this aspect so thank you very much all. I will give all those suggestions a try. I plan to use memmory mapped io at some point if anyone knows any sites of how I can use it to handle keyboard input please fire away. I am very new to it though and Im still trying to figure out how the screen is handled from what Ive learned (correct me if im wrong) the video memmry is mapped to 0xB8000 (is this in ram now?) . B8001 would be the style/color of any text put at b8000........these addresses b8002 b8003 b8004 etc go on to represent each area of the screen. The guide im reading then shows

outbyte(0x3D4, 14); // write to register 14 first
outbyte(0x3D5, (cursorpos>>8) & 0xFF); // output high byte
outbyte(0x3D4, 15); // again to register 15
outbyte(0x3D5, cursorpos & 0xFF);

I think the above is psuedo code Im not sure how to translatre to assembly? Im thinking 0x3D4 is the graphics card port .......and theres register 14 is this a register on the graphics card and would this be the case for my radeon x800 gto pci express. As said Im happy with the assembly exerts given and that should solve my text problem but the guide im reading has ended and Im just needing somethings about this memmory mapping and graphics card registers clarified so I can better understand things.

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top