Author Topic: OS not displaying text  (Read 4288 times)

Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
OS not displaying text
« on: October 09, 2013, 01:16:09 PM »
Hi I am trying to write a simple text displaying os except all my text doesn't display. My code is:

Code: [Select]
BITS 16

start:
mov ax, 07C0h
add ax, 288
mov ss, ax
mov sp, 4096

mov ax, 07C0h
mov ds, ax


mov si, text_string
call print_string

mov dl,'S'
mov dl,'o'
mov dl,' '
mov dl,'w'
mov dl,'h'
mov dl,'a'
mov dl,'t'
mov dl,' '
mov dl,'i'
mov dl,'s'
mov dl,' '
mov dl,'y'
mov dl,'o'
mov dl,'u'
mov dl,'r'
mov dl,' '
mov dl,'p'
mov dl,'a'
mov dl,'s'
mov dl,'s'
mov dl,'w'
mov dl,'o'
mov dl,'r'
mov dl,'d'     
mov dl,'?'
 
jmp $


ret


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

text_string db 'Password Please and then there will be more loading.', 0


print_string:
mov ah, 0Eh

.repeat:
lodsb
cmp al, 0
              je .done
int 10h
jmp .repeat
.done:


How do I get to print all the words and letters? I am sorry if this in the wrong section. I am new.
« Last Edit: October 09, 2013, 01:53:11 PM by Frank Kotler »

Offline encryptor256

  • Full Member
  • **
  • Posts: 250
  • Country: lv
  • Win64 .
    • On Youtube: encryptor256
Re: OS not displaying text
« Reply #1 on: October 09, 2013, 02:16:05 PM »
Hi!

I see, there is a mistakes, how to fix them, you can find here:

Babystep2!

Find here:

http://wiki.osdev.org/Babystep2
Encryptor256's Investigation \ Research Department.

Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: OS not displaying text
« Reply #2 on: October 09, 2013, 02:20:55 PM »
That is not that helpful saying that does not include multiple strings or my code. Please help.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2437
  • Country: us
Re: OS not displaying text
« Reply #3 on: October 09, 2013, 02:30:58 PM »
Hi Toad1359,

You're in the right place. I put "code tags" around your code....

The problem is that your BIOS (or "fake BIOS" if you're using an emulator) loads 512 bytes of bootsector. Your "times" line and the boot signature pad your bootsector - at that point - to 512 bytes. Your string and your routine to display it are not being loaded. Put those two items before the "times" line and it "should" work (untested!). You'll want a "ret" at the end of your subroutine.

The multiple lines loading individual characters into dl don't do anything useful.

Happy Bootin',
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: OS not displaying text
« Reply #4 on: October 09, 2013, 03:15:10 PM »
The one that says password please... works, it's the one broken up into individual characters that doesn't.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2437
  • Country: us
Re: OS not displaying text
« Reply #5 on: October 09, 2013, 03:44:36 PM »
This?
Code: [Select]
mov dl,'S'
mov dl,'o'
mov dl,' '
mov dl,'w'
mov dl,'h'
mov dl,'a'
mov dl,'t'
mov dl,' '
mov dl,'i'
mov dl,'s'
mov dl,' '
mov dl,'y'
mov dl,'o'
mov dl,'u'
mov dl,'r'
mov dl,' '
mov dl,'p'
mov dl,'a'
mov dl,'s'
mov dl,'s'
mov dl,'w'
mov dl,'o'
mov dl,'r'
mov dl,'d'     
mov dl,'?'
 

I'm sure it "works", but the characters don't appear on screen. Why should they?

If this works...
Code: [Select]
times 510-($-$$) db 0
dw 0xAA55

text_string db 'Password Please and then there will be more loading.', 0


print_string:
mov ah, 0Eh

.repeat:
lodsb
cmp al, 0
              je .done
int 10h
jmp .repeat
.done:
then your BIOS is broken.

I strongly suggest you follow the link Encryptor256 gave you and work through the "babysteps" examples.

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: OS not displaying text
« Reply #6 on: October 09, 2013, 03:50:49 PM »
It's not a bios it is a small text os from this website.

http://mikeos.berlios.de/write-your-own-os-winbuild.html


Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2437
  • Country: us
Re: OS not displaying text
« Reply #7 on: October 09, 2013, 04:03:50 PM »
Well do it the way Mike tells ya then!

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: OS not displaying text
« Reply #8 on: October 09, 2013, 04:22:21 PM »
He doesn't explain multiple strings though.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2437
  • Country: us
Re: OS not displaying text
« Reply #9 on: October 09, 2013, 04:35:12 PM »
Oh fer crissakes...

Code: [Select]
BITS 16

start:
mov ax, 07C0h ; Set up 4K stack space after this bootloader
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096

mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax


mov si, text_string ; Put string position into SI
call print_string ; Call our string-printing routine
        mov si, string2
        call print_string

jmp $ ; Jump here - infinite loop!


text_string db 'This is my cool new OS!', 13, 10, 0
        string2 db "This is Toad's OS!", 13, 10, 0


print_string: ; Routine: output string in SI to screen
mov ah, 0Eh ; int 10h 'print char' function

.repeat:
lodsb ; Get character from string
cmp al, 0
je .done ; If char is zero, end of string
int 10h ; Otherwise, print it
jmp .repeat

.done:
ret


times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s
dw 0xAA55 ; The standard PC boot signature

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: OS not displaying text
« Reply #10 on: October 09, 2013, 05:08:26 PM »
Thank you. Also while I'm at it, what is the syntax of an if statement?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2437
  • Country: us
Re: OS not displaying text
« Reply #11 on: October 09, 2013, 05:28:28 PM »
There is no "if" instruction.  If you've got a macro that implements an "if statement", check the macro for the syntax.

Best,
Frank


Offline toad1359

  • Jr. Member
  • *
  • Posts: 17
Re: OS not displaying text
« Reply #12 on: October 09, 2013, 10:17:01 PM »
Thank you very much. :)