problems in tutorial 4

If you are new to development, plan on spending some time here before visiting the other forums.

Moderator: Moderators

problems in tutorial 4

Postby digvijay » Fri Sep 02, 2011 1:48 pm

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.
digvijay
 
Posts: 4
Joined: Mon Aug 29, 2011 5:55 am

Re: problems in tutorial 4

Postby chibicitiberiu » Fri Sep 02, 2011 7:04 pm

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 ' .
chibicitiberiu
 
Posts: 22
Joined: Sat Jul 17, 2010 7:55 am

Re: problems in tutorial 4

Postby digvijay » Sat Sep 03, 2011 7:36 am

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
*******************************************************
digvijay
 
Posts: 4
Joined: Mon Aug 29, 2011 5:55 am

Re: problems in tutorial 4

Postby Andyhhp » Sat Sep 03, 2011 6:16 pm

"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
Image
Andyhhp
Moderator
 
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1


Return to Beginners

Who is online

Users browsing this forum: No registered users and 1 guest

cron