Page 1 of 1

What value DS need to display message ?

Posted: Sun Nov 07, 2010 2:33 am
by van7hu
Hi all,sorry for this trivial question.
I have a MBR (sector #1) loads sector #2

Code: Select all

;MBR
 ;boot sector,clear the screen
 mov ax,0x07c0
 mov ds,ax
 ; Clear the screen
 mov cx,0x7D0
 claer:
 	mov ah,0xe
 	mov al,0
 	int 0x10
 	loop claer
 ;Print message 1
 	mov ah,0x2
 	mov dx,0
 	int 0x10
 	mov si,stage1_msg
 print1:
 	lodsb
 	or al,al
 	jz message2
 	mov ah,0xe
 	int 0x10
 	jmp print1
 ; Print message 2
 message2:
 	mov ah,0x2
 	mov dx,0x0100
 	int 0x10
 	mov si,stage2_msg
 print2:
 	lodsb
 	or al,al
 	jz reset_floppya
 	mov ah,0xe
 	int 0x10
 	jmp print2
 ;Loading another sector
 reset_floppya:	
 	mov ah,0x0
 	mov dl,0x0
 	int 0x13
 	jmp check_driver
 print_check_success:
 	mov ah,0x2
 	mov dx,0x0200
 	int 0x10
 	mov si,check_success_msg
 print3:
 	lodsb
 	or al,al
 	jz read_sector2
 	mov ah,0xe
 	int 0x10
 	jmp print3
 ;
 check_driver:
 	mov ah,0x1
 	int 0x13
 	or al,al
 	jz print_check_success
 print_check_failed:
 	mov ah,0x2
 	mov dx,0x0200
 	int 0x10
 	mov si,check_failed_msg
 print4:
 	lodsb
 	or al,al
 	jz hang
 	mov ah,0xe
 	int 0x10
 	jmp print4
 ;
 read_f_error:
 	mov ah,0x2
 	mov dx,0x0300
 	int 0x10
 	mov si,read_fr_msg
 print5:
 	lodsb
 	or al,al
 	jz hang
 	mov ah,0xe
 	int 0x10
 	jmp print5
 read_f_success:
 	push es
 	push bx
 	retf
 read_sector2:
 	mov ax,0
 	mov es,ax
 	mov bx,0x500  
 	mov ah,0x2
 	mov al,0x1
 	mov dl,0x0
 	mov dh,0
 	mov ch,0
 	mov cl,2
 	int 0x13
 	jc read_f_error
 	jmp read_f_success
 ;
 hang:
 	jmp hang
 stage1_msg db "Loading sector1...",0x0
 stage2_msg db "Loading sector2...",0x0
 check_success_msg db "Check floppy drive successfully!",0x0
 check_failed_msg db "Check floppy drive failed!",0x0
 read_fr_msg db "Reading failed!",0x0
 times 510-($-$$) db 0
 dw 0xaa55
sector #2 :

Code: Select all

;clear the screen
 xor ax,ax
 mov ds,ax					;Ds is wrong?
 mov cx,0x7d0
 clear_s:
 	mov ah,0xe
 	mov al,0
 	int 0x10	
 	loop clear_s
 ;messaging
 	mov ah,0x2
 	mov dx,0
 	xor bh,bh
 	int 0x10
 	mov si,msg
 messages:
 	lodsb
 	or al,al
 	jz hang
 	mov ah,0xe
 	int 0x10
 ;	jmp messages
 hang:
 	jmp hang
 ;
 
 msg db "Sector2...",0x0
 times 512-($-$$) db 0
What value DS need to display msg ?

Re: What value DS need to display message ?

Posted: Sun Nov 07, 2010 3:05 am
by Love4Boobies

Re: What value DS need to display message ?

Posted: Sun Nov 07, 2010 8:17 am
by Combuster
You need required knowledge to see that the OP is playing "Guess the number"? :evil:

@OP: That link is especially for you.

Re: What value DS need to display message ?

Posted: Sun Nov 07, 2010 1:14 pm
by Love4Boobies
Well, this isn't really an assembly forum and this is an assembly question (and judging by the thread title an easy one too). Since assembly is marked as required knowledge I thought I'd paste that link. Yours makes just as much sense :)

Re: What value DS need to display message ?

Posted: Sun Nov 07, 2010 4:37 pm
by Kmt
well, i might point out a few other things than just "READ ........." :P
First, what "ORG" - is the code set to in both the boot loader code, and the second part ?, in the second part it should be "org 0x500", since the code will be running at memory location 0x500
so that is one error, the next one(from what i remember, correct me if I'm wrong), is that you use BIOS to clear the screen, but the teletype output does not let you chose where to put the characters, so when you first clear the screen , BIOS might start over again(with the current screen page) or it might start at a new one, But my advice is for you to first set the cursor position (int 0x10, ah =0x02), and then afterwards call your clean screen function, but to be honest, it is much simpler and easier to code some functions for doing the VGA stuff yourself ( and pretty faster i can tell). But BIOS functions are a good place to start.

well guess that is all for today. :D

KMT