Page 1 of 1

problems in tutorial 4

Posted: Fri Sep 02, 2011 1:48 pm
by digvijay
i have the following .asm code to display the message "WELCOME TO MY OPERATING SYSTEM!"

*******************************************************

org 0x7c00 ;we are loaded at 07c00
bits 16 ;16 bits real mode

start: jmp loader

msg db 'WELCOME TO MY OS!',0

loader:
sti ;enable interrupts
xor ax,ax
mov ds,ax
mov es,ax

mov ah,0x00 ;setting normal video mode
mov al,0x03
int 0x10

mov si,msg

print:

lodsb
or al,al
jz done
mov ah,0x0E ;request display
mov bl,0x1E ;foreground color
int 0x10 ;call interrupt service
jmp print

done:
jmp $ ;infinite loop

times 510-($-$$) db 0

dw 0xAA55

*******************************************************

however bochs does not display anything except;

booting from floppy....

whats the problem in above code
i have tried with 'call' instruction instead of 'jmp' to print label.even that did not work.

Re: problems in tutorial 4

Posted: Fri Sep 02, 2011 7:04 pm
by chibicitiberiu
Firstly, you should put the print function above the loader. And then call it using 'call'. Also, there is no reason you should change the video mode, you are already in text mode 03h.
And in 'done' you return with 'ret'.

Also, I think you should use quotes for strings, not ' .

Re: problems in tutorial 4

Posted: Sat Sep 03, 2011 7:36 am
by digvijay
this is my new code.even this doesn't works and the same problem persists

*******************************************************
org 0x7c00 ;we are loaded at 07c00
bits 16 ;16 bits real mode

start: jmp loader

msg db "WELCOME TO MY OS!",0




print:

lodsb
or al,al
jz done
mov ah,0x0E ;request display
mov bl,0x1E ;foreground color
int 0x10 ;call interrupt serice
jmp print

done:
ret

loader:

mov ax,00h
mov ds,ax
mov es,ax


mov si,msg
call print


cli
jmp $ ;infinite loop


times 510-($-$$) db ' '

dw 0xAA55
*******************************************************

Re: problems in tutorial 4

Posted: Sat Sep 03, 2011 6:16 pm
by Andyhhp
"call" and "ret" requires the use of the stack.

Therefore, you need to set up ss and sp before you try to print your message.

I suggest something like:

Code: Select all

mov ax,00h
mov ds,ax
mov es,ax
mov ss,ax
mov sp, 0x7bf0
~Andrew