flat assembler
Message board for the users of flat assembler.

Index > OS Construction > HelloWorldOS in trouble

Author
Thread Post new topic Reply to topic
DennisB



Joined: 13 Nov 2003
Posts: 3
DennisB 13 Nov 2003, 14:01
[CORRECTED]

Hi all!
Code:
org 0x7C00
use16

start:
        mov si, msg_hello
        call print
        call getch
        call reboot

print:
        mov ah, 0x0E
        mov bx, 0x0007
        print_loop:
                lodsb
                or al, al
                jz print_done
                int 0x10
                jmp print_loop
        print_done:
        ret

getch:
        mov ax, 0x0000
        int 0x16
        ret

reboot:
        jmp 0xFFFF:0
        ret

msg_hello db 'Hello, World! Smile',0

times 510-($-start) db 0
dw 0xAA55    


When I try to boot this, I just get a single 'H' on the screen.
What is missing or wrong and please try to explain why.
I'm sitting here infront of a big questionmark!
Thx for all help.

_________________
The optimist finds to every problem a solution,
The pessimist to every solution a problem


Last edited by DennisB on 17 Nov 2003, 19:35; edited 1 time in total
Post 13 Nov 2003, 14:01
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 13 Nov 2003, 15:30
Maybe you should clear D flag: "cld" instruction. I simply don't know what is D during boot process. Simply include "cld" as first instruction ans try.
Post 13 Nov 2003, 15:30
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 15 Nov 2003, 04:03
I don't really remember how int 10h works, been a while since I did DOS programming, but I recommend you write directly to the VGA memory. You wont be able to use interrupts easily in protected mode, and if you plan on doing anything more than "hello world" you will need protected mode. Not sure if you're familiar with how that works, but a simple loop like this should do the trick:
Code:
Print:
      MOV  AH,0Eh
      MOV  BX,String
      MOV  CX,SizeofString
      MOV  DI,0B800h
      MOV  ES,DI
      SUB   DI,Di
      _PrintLoop:
          PUSH AX
          XLATB
          STOSW
          POP  AX
          INC  AL
          LOOP _PrintLoop
      RET
    

I haven't assembled that, so it might not work, in which case you may laugh at me for messing up 10 lines of code. Adding a CLD to the beginning of that like John mentioned would also be a good idea.

Good luck.
Post 15 Nov 2003, 04:03
View user's profile Send private message Reply with quote
merlin



Joined: 17 Nov 2003
Posts: 11
merlin 17 Nov 2003, 16:00
@DennisB:
You forgot to set DS segment.
Post 17 Nov 2003, 16:00
View user's profile Send private message Reply with quote
DennisB



Joined: 13 Nov 2003
Posts: 3
DennisB 17 Nov 2003, 19:33
Thx for all reply!
But I found the fault: I use loop but where is cx set?
that's stupid of me. jmp should do a better job in this case Wink
But Ralph: I will test it and don't worry! I never laugh about anyones mistakes. Wink

_________________
The optimist finds to every problem a solution,
The pessimist to every solution a problem
Post 17 Nov 2003, 19:33
View user's profile Send private message Reply with quote
CodeWorld



Joined: 15 Nov 2003
Posts: 69
CodeWorld 19 Nov 2003, 04:38
DennisB wrote:
Thx for all reply!
But I found the fault: I use loop but where is cx set?
that's stupid of me. jmp should do a better job in this case Wink
But Ralph: I will test it and don't worry! I never laugh about anyones mistakes. Wink


you write OS? please write your ICQ...

_________________
Image
FASM & RUS OSDEV at WWW.SYSBIN.COM (EN: ww2.sysbin.com)
Post 19 Nov 2003, 04:38
View user's profile Send private message Visit poster's website Reply with quote
terex



Joined: 31 Dec 2003
Posts: 16
Location: Saint-Petersburg, Russia
terex 31 Dec 2003, 02:37
CodeWorld wrote:
you write OS? please write your ICQ...

Every russian guy, who studys assembler, exactly begins to write his own OS Wink Me too Wink
Post 31 Dec 2003, 02:37
View user's profile Send private message Visit poster's website Reply with quote
CodeWorld



Joined: 15 Nov 2003
Posts: 69
CodeWorld 31 Dec 2003, 05:37
terex wrote:
CodeWorld wrote:
you write OS? please write your ICQ...

Every russian guy, who studys assembler, exactly begins to write his own OS Wink Me too Wink

write CodeWorld@sysbin.com

_________________
Image
FASM & RUS OSDEV at WWW.SYSBIN.COM (EN: ww2.sysbin.com)
Post 31 Dec 2003, 05:37
View user's profile Send private message Visit poster's website Reply with quote
terex



Joined: 31 Dec 2003
Posts: 16
Location: Saint-Petersburg, Russia
terex 31 Dec 2003, 10:19
@CodeWorld: i would not to wrtie... Because the main aim of os-writing for me is take an expirence in low level protected mode programming and understanding a principles of modern os design.
Post 31 Dec 2003, 10:19
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.