NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: toad1359 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:
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.
-
Hi!
I see, there is a mistakes, how to fix them, you can find here:
Babystep2!
Find here:
http://wiki.osdev.org/Babystep2 (http://wiki.osdev.org/Babystep2)
-
That is not that helpful saying that does not include multiple strings or my code. Please help.
-
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
-
The one that says password please... works, it's the one broken up into individual characters that doesn't.
-
This?
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...
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
-
It's not a bios it is a small text os from this website.
http://mikeos.berlios.de/write-your-own-os-winbuild.html
-
Well do it the way Mike tells ya then!
Best,
Frank
-
He doesn't explain multiple strings though.
-
Oh fer crissakes...
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
-
Thank you. Also while I'm at it, what is the syntax of an if statement?
-
There is no "if" instruction. If you've got a macro that implements an "if statement", check the macro for the syntax.
Best,
Frank
-
Thank you very much. :)