Hello!
I am interested in learning assembly programming, but not for any
particular OS. I'm rather interested in making my pc boot up with my
own os :)
After getting this idea I have searched the internet, played around
with emu8086, and struggled with masm/tasm, and never really getting
anything compiled *lol* well, not quite true.. i got some samples
compiled. But, to be honest, I seem to struggle more getting the
compilers to work than actually learning the language.
So my one simple, straightforward question is: is it possible to
compile a program that can be written to boot sector of a floppy,
which prints a message to the screen? If i could only get THAT to
work, i would be safely on my way to jollyness :)
Thanks!
Rune
ps im aware that there probably is a lot lot lot more to it than what
I think... but i just need to know at least :P
|
|
0
|
|
|
|
Reply
|
tigern75
|
11/3/2003 9:05:28 PM |
|
In article <b46ef704.0311031305.506c2076@posting.google.com>,
Rune Kristiansen <tigern75@hotmail.com> wrote:
>Hello!
>
>I am interested in learning assembly programming, but not for any
>particular OS. I'm rather interested in making my pc boot up with my
>own os :)
>
>After getting this idea I have searched the internet, played around
>with emu8086, and struggled with masm/tasm, and never really getting
>anything compiled *lol* well, not quite true.. i got some samples
>compiled. But, to be honest, I seem to struggle more getting the
>compilers to work than actually learning the language.
You don't mean "compiled", right? Assembler code is "assembled",
then linked.
>So my one simple, straightforward question is: is it possible to
>compile a program that can be written to boot sector of a floppy,
>which prints a message to the screen? If i could only get THAT to
>work, i would be safely on my way to jollyness :)
How's this for a start:
Page 56,132
Title BOOT
CODE Segment Public 'Code'
Org 00000H
Assume CS:CODE
INIT Proc Near
; Got here by 0:7c00 or 7c0:0 - not sure which
Jmp Dword Ptr CS:FAR_JMP
INIT Endp
FAR_JMP Label Dword
Dw Offset CODE:INIT2 ;Offset for far jmp
Dw 007C0H ;Code segment for far jmp
HELLO Db 13,10,"Hello, World...",13,10,0
INIT2 Proc Far
Mov AX,CS ;Either way, we're now at 0:7c00
Mov DS,AX ;Set up DS
Assume DS:CODE
Lea SI,HELLO ;Point DS:SI to our string
Cld ;
INIT2a: Lodsb ;Get a character
Or AL,AL ;End of string?
Jz INIT2z ;Yes.
Mov AH,00EH ;AH = 00EH (Teletype output)
Mov BX,00007H ;BX = 00000H (page 0, foreground white)
Int 010H ;Call the ROM BIOS
Jmp INIT2a ;And loop
INIT2z:
Xor AH,AH ;Wait for a key...
Int 016H ;
Int 019H ;Reboot
INIT2 Endp
Org 001FEH ;
Db 055H,0AAH ;Not sure if it's 55,AA or AA,55
CODE Ends
End
Using Microsoft tools, do the following:
masm boot,,boot;
link boot/m;
locate boot.exe boot.sys
The file BOOT.SYS looks like this:
00000000 2e ff 2e 05 00 1d 00 c0 07 0d 0a 48 65 6c 6c 6f .......@...Hello
00000010 2c 20 57 6f 72 6c 64 2e 2e 2e 0d 0a 00 8c c8 8e , World.......H.
00000020 d8 8d 36 09 00 fc ac 0a c0 74 09 b4 0e bb 07 00 X.6..|,.@t.4.;..
00000030 cd 10 eb f2 32 e4 cd 16 cd 19 00 00 00 00 00 00 M.kr2dM.M.......
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
(repeat)
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa ..............U*
Load BOOT.SYS into the boot sector and see what happens?
I did this from memory and didn't get to try it, but I'm pretty confident
about it. I wrote my first boot sector for MSDOS over 20 years ago - it's
amazing how much code you can fit in 512 bytes!
Have fun!
Patrick
========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
Patrick Klos Email: patrick@klos.com
Klos Technologies, Inc. Web: http://www.klos.com/
==================== You can't win if you don't play! ======================
|
|
0
|
|
|
|
Reply
|
patrick
|
11/4/2003 1:11:43 AM
|
|
patrick@klos.com wrote in message news:<bo6ucf$508$1@pyrite.mv.net>...
>
> Load BOOT.SYS into the boot sector and see what happens?
>
> I did this from memory and didn't get to try it, but I'm pretty confident
> about it. I wrote my first boot sector for MSDOS over 20 years ago - it's
> amazing how much code you can fit in 512 bytes!
>
> Have fun!
>
Hi Patrick!
Thanks for your reply. I tried your solution and managed to get it
assembled! I wasnt quite sure what you meant about locating boot.exe
and boot.sys at first, but then after looking at the files, i guess
you meant the masm would produce either of the two? I got only
boot.exe.
I tried to load the boot.exe to the boot sector of a floppy. I have
found only one tool that writes boot sectors and it is in german so I
am not sure if I got it all correct, because when I boot using my disk
I get "missing ntldr" (cant remember exact wording, but it is a common
msg I have seen this before).
But, it didnt say "non system disk" at least :D maybe we're on our
way!
Thanks for your time
|
|
0
|
|
|
|
Reply
|
tigern75
|
11/4/2003 9:26:29 AM
|
|
On 3 Nov 2003 13:05:28 -0800, tigern75@hotmail.com (Rune Kristiansen)
wrote:
>Hello!
>
>I am interested in learning assembly programming, but not for any
>particular OS. I'm rather interested in making my pc boot up with my
>own os :)
>
>After getting this idea I have searched the internet, played around
>with emu8086, and struggled with masm/tasm, and never really getting
>anything compiled *lol* well, not quite true.. i got some samples
>compiled. But, to be honest, I seem to struggle more getting the
>compilers to work than actually learning the language.
>
>So my one simple, straightforward question is: is it possible to
>compile a program that can be written to boot sector of a floppy,
>which prints a message to the screen? If i could only get THAT to
>work, i would be safely on my way to jollyness :)
>
>Thanks!
>Rune
>
>ps im aware that there probably is a lot lot lot more to it than what
>I think... but i just need to know at least :P
What assembler do you use? (I strongly recommend you to chose NASM
since most OS sources out there is written with NASM dialect in mind).
Here are some things to keep in mind when programming your own OS:
- IT TAKES TIME!
- Some information is hard to find (I still havn't found any VIA
Programming docs for example)
- It really forces you to learn computers, which is good :)
- It's really fun.
You say don't know ASM and wan't to make your own OS.
Well the first thing you need to ask yourself is: Is it really worth
making my OS in ASM? asm would many times require twice as much code
to perform the same thing a C source can but insted asm granted you
with things C can't.
For example the code size and speed will probaly be direct propotional
to how good you are on programming asm while in C the compiler
"optimizes" (makes the code running faster or makes is shorter in size
or some combination of the two) the code.
I my self has coded a OS in asm (only for fun of cource) and it
contains about 25 000 lines of code (where comments and blank lines
are included), which may sound a awful lot but you need to be ready
that your OS project might require the same amount of lines.
If you still want to make your OS in ASM i recommend you to at least
know a bit of how x86 asm works (I assume you want to run you OS on a
Intel or AMD processor).
//Spike
|
|
0
|
|
|
|
Reply
|
Spike
|
11/4/2003 4:58:45 PM
|
|
On 4 Nov 2003 01:11:43 GMT, patrick@klos.com wrote:
>In article <b46ef704.0311031305.506c2076@posting.google.com>,
>Rune Kristiansen <tigern75@hotmail.com> wrote:
>>Hello!
>>
>>I am interested in learning assembly programming, but not for any
>>particular OS. I'm rather interested in making my pc boot up with my
>>own os :)
>>
>>After getting this idea I have searched the internet, played around
>>with emu8086, and struggled with masm/tasm, and never really getting
>>anything compiled *lol* well, not quite true.. i got some samples
>>compiled. But, to be honest, I seem to struggle more getting the
>>compilers to work than actually learning the language.
>
>You don't mean "compiled", right? Assembler code is "assembled",
>then linked.
>
>>So my one simple, straightforward question is: is it possible to
>>compile a program that can be written to boot sector of a floppy,
>>which prints a message to the screen? If i could only get THAT to
>>work, i would be safely on my way to jollyness :)
>
>How's this for a start:
>
> Page 56,132
> Title BOOT
>
>CODE Segment Public 'Code'
>
> Org 00000H
>
> Assume CS:CODE
>
>INIT Proc Near
>; Got here by 0:7c00 or 7c0:0 - not sure which
>
> Jmp Dword Ptr CS:FAR_JMP
>INIT Endp
>
>FAR_JMP Label Dword
> Dw Offset CODE:INIT2 ;Offset for far jmp
> Dw 007C0H ;Code segment for far jmp
>
>HELLO Db 13,10,"Hello, World...",13,10,0
>
>INIT2 Proc Far
> Mov AX,CS ;Either way, we're now at 0:7c00
> Mov DS,AX ;Set up DS
>
> Assume DS:CODE
>
> Lea SI,HELLO ;Point DS:SI to our string
> Cld ;
>INIT2a: Lodsb ;Get a character
> Or AL,AL ;End of string?
> Jz INIT2z ;Yes.
>
> Mov AH,00EH ;AH = 00EH (Teletype output)
> Mov BX,00007H ;BX = 00000H (page 0, foreground white)
> Int 010H ;Call the ROM BIOS
>
> Jmp INIT2a ;And loop
>
>INIT2z:
> Xor AH,AH ;Wait for a key...
> Int 016H ;
>
> Int 019H ;Reboot
>INIT2 Endp
>
> Org 001FEH ;
>
> Db 055H,0AAH ;Not sure if it's 55,AA or AA,55
Your right the BIOS Bootable signature is 55AAh.
>
>CODE Ends
> End
>
>Using Microsoft tools, do the following:
>
> masm boot,,boot;
> link boot/m;
> locate boot.exe boot.sys
>
>The file BOOT.SYS looks like this:
>
>00000000 2e ff 2e 05 00 1d 00 c0 07 0d 0a 48 65 6c 6c 6f .......@...Hello
>00000010 2c 20 57 6f 72 6c 64 2e 2e 2e 0d 0a 00 8c c8 8e , World.......H.
>00000020 d8 8d 36 09 00 fc ac 0a c0 74 09 b4 0e bb 07 00 X.6..|,.@t.4.;..
>00000030 cd 10 eb f2 32 e4 cd 16 cd 19 00 00 00 00 00 00 M.kr2dM.M.......
>00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> (repeat)
>000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa ..............U*
>
>Load BOOT.SYS into the boot sector and see what happens?
>
>I did this from memory and didn't get to try it, but I'm pretty confident
>about it. I wrote my first boot sector for MSDOS over 20 years ago - it's
>amazing how much code you can fit in 512 bytes!
>
>Have fun!
>
>Patrick
>========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
> Patrick Klos Email: patrick@klos.com
> Klos Technologies, Inc. Web: http://www.klos.com/
>==================== You can't win if you don't play! ======================
|
|
0
|
|
|
|
Reply
|
Spike
|
11/4/2003 5:00:36 PM
|
|
Hello,
I thought that a boot sector must bef*gin by " EB ** ( jmp short ** )
then, it must have 12, or 16 bytes format fat ; a label ; name of file to
load : an Input Output system file .....and others ....things ...
<patrick@klos.com> a �crit dans le message : bo6ucf$508$1@pyrite.mv.net...
> In article <b46ef704.0311031305.506c2076@posting.google.com>,
> Rune Kristiansen <tigern75@hotmail.com> wrote:
> >Hello!
> >
> >I am interested in learning assembly programming, but not for any
> >particular OS. I'm rather interested in making my pc boot up with my
> >own os :)
> >
> >After getting this idea I have searched the internet, played around
> >with emu8086, and struggled with masm/tasm, and never really getting
> >anything compiled *lol* well, not quite true.. i got some samples
> >compiled. But, to be honest, I seem to struggle more getting the
> >compilers to work than actually learning the language.
>
> You don't mean "compiled", right? Assembler code is "assembled",
> then linked.
>
> >So my one simple, straightforward question is: is it possible to
> >compile a program that can be written to boot sector of a floppy,
> >which prints a message to the screen? If i could only get THAT to
> >work, i would be safely on my way to jollyness :)
>
> How's this for a start:
>
> Page 56,132
> Title BOOT
>
> CODE Segment Public 'Code'
>
> Org 00000H
>
> Assume CS:CODE
>
> INIT Proc Near
> ; Got here by 0:7c00 or 7c0:0 - not sure which
>
> Jmp Dword Ptr CS:FAR_JMP
> INIT Endp
>
> FAR_JMP Label Dword
> Dw Offset CODE:INIT2 ;Offset for far jmp
> Dw 007C0H ;Code segment for far jmp
>
> HELLO Db 13,10,"Hello, World...",13,10,0
>
> INIT2 Proc Far
> Mov AX,CS ;Either way, we're now at 0:7c00
> Mov DS,AX ;Set up DS
>
> Assume DS:CODE
>
> Lea SI,HELLO ;Point DS:SI to our string
> Cld ;
> INIT2a: Lodsb ;Get a character
> Or AL,AL ;End of string?
> Jz INIT2z ;Yes.
>
> Mov AH,00EH ;AH = 00EH (Teletype output)
> Mov BX,00007H ;BX = 00000H (page 0, foreground
white)
> Int 010H ;Call the ROM BIOS
>
> Jmp INIT2a ;And loop
>
> INIT2z:
> Xor AH,AH ;Wait for a key...
> Int 016H ;
>
> Int 019H ;Reboot
> INIT2 Endp
>
> Org 001FEH ;
>
> Db 055H,0AAH ;Not sure if it's 55,AA or AA,55
>
> CODE Ends
> End
>
> Using Microsoft tools, do the following:
>
> masm boot,,boot;
> link boot/m;
> locate boot.exe boot.sys
>
> The file BOOT.SYS looks like this:
>
> 00000000 2e ff 2e 05 00 1d 00 c0 07 0d 0a 48 65 6c 6c 6f
........@...Hello
> 00000010 2c 20 57 6f 72 6c 64 2e 2e 2e 0d 0a 00 8c c8 8e ,
World.......H.
> 00000020 d8 8d 36 09 00 fc ac 0a c0 74 09 b4 0e bb 07 00
X.6..|,.@t.4.;..
> 00000030 cd 10 eb f2 32 e4 cd 16 cd 19 00 00 00 00 00 00
M.kr2dM.M.......
> 00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
.................
> (repeat)
> 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
...............U*
>
> Load BOOT.SYS into the boot sector and see what happens?
>
> I did this from memory and didn't get to try it, but I'm pretty confident
> about it. I wrote my first boot sector for MSDOS over 20 years ago - it's
> amazing how much code you can fit in 512 bytes!
>
> Have fun!
>
> Patrick
> ========= For LAN/WAN Protocol Analysis, check out PacketView Pro!
=========
> Patrick Klos Email: patrick@klos.com
> Klos Technologies, Inc. Web: http://www.klos.com/
> ==================== You can't win if you don't play!
======================
>
|
|
0
|
|
|
|
Reply
|
asso
|
11/4/2003 6:33:20 PM
|
|
patrick@klos.com wrote in message news:<bo6ucf$508$1@pyrite.mv.net>...
[snip]
> >> I did this from memory and didn't get to try it, but I'm pretty confident
> about it. I wrote my first boot sector for MSDOS over 20 years ago - it's
> amazing how much code you can fit in 512 bytes!
>
> Have fun!
>
> Patrick
> ========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
> Patrick Klos Email: patrick@klos.com
> Klos Technologies, Inc. Web: http://www.klos.com/
> ==================== You can't win if you don't play! ======================
Hello Patrick and thanks for your reply!
I did a reply already, but it never got through.... if it does, please
disregard (yes, its been over 6 hours now, so I guess it should have
gotten through by now)
Anyway, i tried your example and i got it assembled! I wrote it to the
boot sector of a floppy and tried booting my pc. All it said was
"ntldr missing" I have most likely made a mistake. My boot sector
program is in german so I'm not sure if I did it all correctly... At
least it didnt say "non system disk" :)
I will try some more, and see what I get. Maybe look for another
program to write boot sector to disk/cd
Thanks!
|
|
0
|
|
|
|
Reply
|
tigern75
|
11/4/2003 9:14:57 PM
|
|
"Rune Kristiansen" <tigern75@hotmail.com> wrote in message
news:b46ef704.0311040126.2ff7f44a@posting.google.com...
<snip>
> I tried to load the boot.exe to the boot sector of a floppy. I have
> found only one tool that writes boot sectors and it is in german so I
> am not sure if I got it all correct, because when I boot using my disk
> I get "missing ntldr" (cant remember exact wording, but it is a common
> msg I have seen this before).
The rawrite utility is very good at this. You normally write out a full
floppy image at a time, but I think you can write out smaller images and it
will simply write the front of the disk.
A friend of mine wrote a utility to construct a FAT12 boot disk image which
can be used with rawrite. He has given me permission to post the source, so
here it is:
http://my.fit.edu/~mtaylor/makeflpimg.zip
Happy experimenting!
-Matt
|
|
0
|
|
|
|
Reply
|
Matt
|
11/4/2003 10:38:29 PM
|
|
On 4 Nov 2003 13:14:57 -0800, tigern75@hotmail.com (Rune Kristiansen)
wrote:
>patrick@klos.com wrote in message news:<bo6ucf$508$1@pyrite.mv.net>...
>[snip]
>> >> I did this from memory and didn't get to try it, but I'm pretty confident
>> about it. I wrote my first boot sector for MSDOS over 20 years ago - it's
>> amazing how much code you can fit in 512 bytes!
>>
>> Have fun!
>>
>> Patrick
>> ========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
>> Patrick Klos Email: patrick@klos.com
>> Klos Technologies, Inc. Web: http://www.klos.com/
>> ==================== You can't win if you don't play! ======================
>
>Hello Patrick and thanks for your reply!
>
>I did a reply already, but it never got through.... if it does, please
>disregard (yes, its been over 6 hours now, so I guess it should have
>gotten through by now)
>
>Anyway, i tried your example and i got it assembled! I wrote it to the
>boot sector of a floppy and tried booting my pc. All it said was
>"ntldr missing" I have most likely made a mistake. My boot sector
>program is in german so I'm not sure if I did it all correctly... At
>least it didnt say "non system disk" :)
>
>I will try some more, and see what I get. Maybe look for another
>program to write boot sector to disk/cd
>
>Thanks!
Try these sites:
http://www.osdever.net
http://electrichamster.net/lucie/Downloads/BLWalkthrough.zip (this is
a BootSector walkthrough it might be of help)
//Spike
|
|
0
|
|
|
|
Reply
|
Spike
|
11/4/2003 10:39:54 PM
|
|
"Spike" <im_a_user@hotmail.com> wrote in message
news:kolfqvgq9rkj3t5s5d1rth0n3mrg00nj4g@4ax.com...
> On 3 Nov 2003 13:05:28 -0800, tigern75@hotmail.com (Rune Kristiansen)
> wrote:
<snip>
> You say don't know ASM and wan't to make your own OS.
> Well the first thing you need to ask yourself is: Is it really worth
> making my OS in ASM? asm would many times require twice as much code
> to perform the same thing a C source can but insted asm granted you
> with things C can't.
>
> For example the code size and speed will probaly be direct propotional
> to how good you are on programming asm while in C the compiler
> "optimizes" (makes the code running faster or makes is shorter in size
> or some combination of the two) the code.
>
> I my self has coded a OS in asm (only for fun of cource) and it
> contains about 25 000 lines of code (where comments and blank lines
> are included), which may sound a awful lot but you need to be ready
> that your OS project might require the same amount of lines.
>
> If you still want to make your OS in ASM i recommend you to at least
> know a bit of how x86 asm works (I assume you want to run you OS on a
> Intel or AMD processor).
Another good suggestion is using real mode for your first project,
particularly if you are not intimately familiar with x86 architecture.
Protected mode is riddled with complexities that take a while to understand.
(Even a few years after having written a pmode OS, I was corrected several
times about the GDT being translated through paging! Seems I got lucky...)
Real mode is pretty simple. You have full control over conventional memory.
I do not recall the lower bound, but the upper bound is physical A0000h
above which devices may be mapped. As long as you understand how segments
work, you're pretty much good to go. Most old PC hardware is fairly well
documented and straightforward to interface with.
My first attempt was 4,444 lines of C & assembly. I had pre-emptive
multitasking with round-robin scheduling, console/keyboard support, a system
timer, a rich, NT-like synchronization model, a fast memory allocator
w/custom block size, and a very basic serial port interface. I used Borland
C++ 2.0 with TASM. Amusingly enough, I didn't know about exe2bin, so I
simply hand-linked all my global variables. It was fun...
-Matt
|
|
0
|
|
|
|
Reply
|
Matt
|
11/4/2003 11:06:12 PM
|
|
"asso.smia" <asso-fuck.smia-spam@wanadoo.fr> wrote in message
news:bo8r9l$hp8$1@news-reader1.wanadoo.fr...
> Hello,
> I thought that a boot sector must bef*gin by " EB ** ( jmp short ** )
> then, it must have 12, or 16 bytes format fat ; a label ; name of file to
> load : an Input Output system file .....and others ....things ...
<snip>
Microsoft calls that the media descriptor. It is not required to be
executable, but it is important if you intend to interoperate with software
that uses the media descriptor. Particularly for a boot floppy, it shouldn't
matter.
-Matt
|
|
0
|
|
|
|
Reply
|
Matt
|
11/4/2003 11:10:30 PM
|
|
In article <b46ef704.0311040126.2ff7f44a@posting.google.com>,
Rune Kristiansen <tigern75@hotmail.com> wrote:
>patrick@klos.com wrote in message news:<bo6ucf$508$1@pyrite.mv.net>...
>
>>
>> Load BOOT.SYS into the boot sector and see what happens?
>>
>> I did this from memory and didn't get to try it, but I'm pretty confident
>> about it. I wrote my first boot sector for MSDOS over 20 years ago - it's
>> amazing how much code you can fit in 512 bytes!
>>
>> Have fun!
>>
>
>Hi Patrick!
>
>Thanks for your reply. I tried your solution and managed to get it
>assembled! I wasnt quite sure what you meant about locating boot.exe
>and boot.sys at first, but then after looking at the files, i guess
>you meant the masm would produce either of the two? I got only
>boot.exe.
No, I meant use the LOCATE utility. If you don't have a utility program
called LOCATE.EXE, see if you have EXE2BIN.EXE. Replace the "locate"
line with this:
exe2bin boot.exe boot.sys
>I tried to load the boot.exe to the boot sector of a floppy. I have
>found only one tool that writes boot sectors and it is in german so I
>am not sure if I got it all correct, because when I boot using my disk
>I get "missing ntldr" (cant remember exact wording, but it is a common
>msg I have seen this before).
You cannot load the .EXE version since it has a header that cannot be
put in the boot sector. As I said above, use EXE2BIN if you don't have
LOCATE.
Someone else mentioned RAWRITE - you might find that to write to the
boot sector.
========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
Patrick Klos Email: patrick@klos.com
Klos Technologies, Inc. Web: http://www.klos.com/
==================== You can't win if you don't play! ======================
|
|
0
|
|
|
|
Reply
|
patrick
|
11/5/2003 3:30:52 AM
|
|
In article <bo8r9l$hp8$1@news-reader1.wanadoo.fr>,
asso.smia <asso-fuck.smia-spam@wanadoo.fr> wrote:
>Hello,
>I thought that a boot sector must bef*gin by " EB ** ( jmp short ** )
>then, it must have 12, or 16 bytes format fat ; a label ; name of file to
>load : an Input Output system file .....and others ....things ...
That would be a DOS boot sector. It's not actually necessary of a BOOT
sector - it's necessary for DOS to read a file system from the disk. I
suppose the original poster will want to put his boot code on a regular
DOS floppy somedat, but I wanted to get him going first.
========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
Patrick Klos Email: patrick@klos.com
Klos Technologies, Inc. Web: http://www.klos.com/
==================== You can't win if you don't play! ======================
|
|
0
|
|
|
|
Reply
|
patrick
|
11/5/2003 3:34:28 AM
|
|
Spike <im_a_user@hotmail.com> wrote in message news:<kolfqvgq9rkj3t5s5d1rth0n3mrg00nj4g@4ax.com>...
> On 3 Nov 2003 13:05:28 -0800, tigern75@hotmail.com (Rune Kristiansen)
> wrote:
> >
> What assembler do you use? (I strongly recommend you to chose NASM
> since most OS sources out there is written with NASM dialect in mind).
I use MASM at the moment, I never really got TASM to work... havent
tried NASM yet, but I have downloaded it.
>
> Here are some things to keep in mind when programming your own OS:
> - IT TAKES TIME!
> - Some information is hard to find (I still havn't found any VIA
> Programming docs for example)
> - It really forces you to learn computers, which is good :)
> - It's really fun.
It will probably take several months for me to even print "Runex" or
similar on the screen ;) I have accepted the time consuming bit
> You say don't know ASM and wan't to make your own OS.
> Well the first thing you need to ask yourself is: Is it really worth
> making my OS in ASM? asm would many times require twice as much code
> to perform the same thing a C source can but insted asm granted you
> with things C can't.
I lied a little bit. I know asm... for C64 :D I have a little idea,
but its very vague... i did asm for C64 for like 15 years ago, and
even that wasnt really advanced. I know C a little, I mainly program
in basic (at work), have done a few console apps in C (or was it
C++?).
But... if you compile a C program... could you get that program to run
from PC boot? I thought C was dependent on a subsystem (dos, win etc).
[snip]
> If you still want to make your OS in ASM i recommend you to at least
> know a bit of how x86 asm works (I assume you want to run you OS on a
> Intel or AMD processor).
Yes, id like to go for asm. And im reading up on x86 at the moment.
> //Spike
Thanks for your reply :)
|
|
0
|
|
|
|
Reply
|
tigern75
|
11/5/2003 8:29:14 AM
|
|
"Rune Kristiansen" <tigern75@hotmail.com> wrote in message
news:b46ef704.0311050029.5e4a050a@posting.google.com...
<snip>
> But... if you compile a C program... could you get that program to run
> from PC boot? I thought C was dependent on a subsystem (dos, win etc).
<snip>
C was designed as an operating system language, and C++ kept this as a goal
as well. It has been adapted to applications. It is the runtime library that
is dependent on an environment. If you don't use the runtime library, it
works perfectly fine for OS code. The vast majority of the Linux kernel is
written in C, and I used a large bit of C in my microkernel.
-Matt
|
|
0
|
|
|
|
Reply
|
Matt
|
11/5/2003 12:02:32 PM
|
|
Hi Rune,
tigern75@hotmail.com (Rune Kristiansen) wrote:
> I use MASM at the moment, I never really got TASM to work... havent
> tried NASM yet, but I have downloaded it.
Here a short source for NASM.
1. save the asm source between the lines in boot.asm
2. assemble it with nasm boot.asm -o boot.bin
3. write the boot.bin to the floppy boot sector
debug boot.bin
-w 100 0 0 1
-q
If you boot the computer from this disc it show an short text, load the MBR from first IDE harddisk and execute it.
=== begin ===
org 0h
jmp start
db 'MrB (c) ' ; manufacturer id
db 00h, 02h ; byte / sector
db 01h ; sectors / cluster
db 01h, 00h ; reserved sectors
db 02h ; number FAT
db 0e0h, 00h ; max. root entries
db 040h, 0bh ; number sectors
db 0f0h ; media descriptor
db 09h, 00h ; sectors / FAT
db 12h, 00h ; sectors / track
db 02h, 00h ; number read/write heads
db 00h, 00h ; gap first sector
start:
jmp 07c0h:main ; to jump from 0000:7c00h to
; 07c0:0000h
main:
mov ah, 03h ; save row / column
mov bh, 00 ; DH - column DL - row
int 10h
mov ax, 07c0h ; buffer segment
mov es, ax
mov ax, text1 ; buffer offset
mov bp, ax
mov ah, 13h ; function
mov al, 01h ; subfunction
mov bl, 1eh ; color yellow/blue
mov cx, textend ; buffer length
mov bh, 00h ; screen page
int 10h
cli ; move program code, to
sub ax, ax ; get place for the MBR
mov ss, ax ; code
mov ax, 7c00h
mov sp, ax
sti
cld
sub ax, ax
mov ds, ax
mov si, 7c00h ; source segment
mov ax, 60h ; destination segment
mov es, ax
sub di, di
mov cx, text1 ; copy only code, no data
repz
movsw
jmp 0060h:hdmbr ; jump to moved address
hdmbr:
mov ax, 00h ; bootstrap area
mov es, ax ; buffer segment
mov ax, 7c00h
mov bx, ax ; buffer offset
mov ah, 02h ; function: load sector
mov dl, 80h ; drive number
mov dh, 00h ; head number
mov ch, 00h ; cylinder number
mov cl, 01h ; start sector
mov al, 01h ; number of sectors to read
int 13h
jmp 0000:7c00h
text1:
db ' -<[ here some boot information ]>- ', 07h, 0dh, 0ah
textend:
times 510-($-$$) db 00h ; fill with zero byte up to
; 1fdh
dw 0AA55h ; bootable mark
=== end ===
Frank
|
|
0
|
|
|
|
Reply
|
Frank
|
11/5/2003 6:59:29 PM
|
|
On Tue, 04 Nov 2003 23:06:12 GMT, "Matt Taylor" <para@tampabay.rr.com>
wrote:
>"Spike" <im_a_user@hotmail.com> wrote in message
>news:kolfqvgq9rkj3t5s5d1rth0n3mrg00nj4g@4ax.com...
>> On 3 Nov 2003 13:05:28 -0800, tigern75@hotmail.com (Rune Kristiansen)
>> wrote:
><snip>
>> You say don't know ASM and wan't to make your own OS.
>> Well the first thing you need to ask yourself is: Is it really worth
>> making my OS in ASM? asm would many times require twice as much code
>> to perform the same thing a C source can but insted asm granted you
>> with things C can't.
>>
>> For example the code size and speed will probaly be direct propotional
>> to how good you are on programming asm while in C the compiler
>> "optimizes" (makes the code running faster or makes is shorter in size
>> or some combination of the two) the code.
>>
>> I my self has coded a OS in asm (only for fun of cource) and it
>> contains about 25 000 lines of code (where comments and blank lines
>> are included), which may sound a awful lot but you need to be ready
>> that your OS project might require the same amount of lines.
>>
>> If you still want to make your OS in ASM i recommend you to at least
>> know a bit of how x86 asm works (I assume you want to run you OS on a
>> Intel or AMD processor).
>
>Another good suggestion is using real mode for your first project,
>particularly if you are not intimately familiar with x86 architecture.
>Protected mode is riddled with complexities that take a while to understand.
>(Even a few years after having written a pmode OS, I was corrected several
>times about the GDT being translated through paging! Seems I got lucky...)
Yes it true, Pmode is pure pain in the beginning (i remeber putting
the label "int10" inside me IDT, the only problem was: NASM took it as
a LOCK prefix. It took me quite some time to find!).
My recommation is: Learn asm thru real mode but as soon as you know
jump over to protected mode.
You can't write a serious OS in real mode, not a change!
>
>Real mode is pretty simple. You have full control over conventional memory.
>I do not recall the lower bound, but the upper bound is physical A0000h
>above which devices may be mapped. As long as you understand how segments
>work, you're pretty much good to go. Most old PC hardware is fairly well
>documented and straightforward to interface with.
I never liked Real Mode since it is too many memory bound to keep in
head and since Real Mode limits the programmer to only use 1MB of RAM!
So if your computer has 512 MB of RAM the processor will limit it to 1
MB. This due to "backwards compability", remeber Bill Gates: "640K
should be enough for everybody" :)
>
>My first attempt was 4,444 lines of C & assembly. I had pre-emptive
>multitasking with round-robin scheduling, console/keyboard support, a system
>timer, a rich, NT-like synchronization model, a fast memory allocator
>w/custom block size, and a very basic serial port interface. I used Borland
>C++ 2.0 with TASM. Amusingly enough, I didn't know about exe2bin, so I
>simply hand-linked all my global variables. It was fun...
:)
>
>-Matt
>
|
|
0
|
|
|
|
Reply
|
Spike
|
11/5/2003 8:02:56 PM
|
|
You can also do it the old fashion way, use debug to write the .bin
file out to the boot sector.... Get help on the "W" command....
|
|
0
|
|
|
|
Reply
|
John
|
11/6/2003 2:41:27 AM
|
|
|
17 Replies
305 Views
(page loaded in 0.296 seconds)
Similiar Articles: assembly for boot sectors - comp.lang.asm.x86Hello! I am interested in learning assembly programming, but not for any particular OS. I'm rather interested in making my pc boot up with my own os ... boot sector - comp.lang.asm.x86assembly for boot sectors - comp.lang.asm.x86 Hello! I am interested in learning assembly programming, but not for any particular OS. I'm rather interested in making my pc ... boot from floppy but run the bootstrap loader on the hard drive ...assembly for boot sectors - comp.lang.asm.x86 - Some information is hard to find (I still havn't ... Particularly for a boot floppy, it shouldn't matter. ... problem with int 13h function - comp.lang.asm.x86assembly for boot sectors - comp.lang.asm.x86 problem with int 13h function - comp.lang.asm.x86 assembly for boot sectors - comp.lang.asm.x86... mov bp, ax mov ah, 13h ... Intel C++ Compiler (Linux x86_64) - "GNU-style Inline Assembly ...assembly for boot sectors - comp.lang.asm.x86 Intel C++ Compiler (Linux x86_64) - "GNU-style Inline Assembly ... assembly for boot sectors - comp.lang.asm.x86 The vast ... reg - How to load font file (ttf, etc) using assembly - comp.lang ...assembly for boot sectors - comp.lang.asm.x86... fat ; a label ; name of file to load ... on a subsystem (dos, win etc ... calling ttf (true type font file)file in vc++ ... what is the difference between reboot and init6 - comp.unix ...Boot Image: Sup 720 - comp.dcom.sys.cisco what is the difference between reboot and init6 - comp.unix ... bootflash vs. sup-bootflash - comp.dcom.sys.cisco on a 6509 with ... calling ttf (true type font file)file in vc++ project - comp.fonts ...assembly for boot sectors - comp.lang.asm.x86... and boot.sys at first, but then after looking at the files, i ... calling ttf (true type font file)file in vc++ project ... ASM disk cannot be found - comp.databases.oracle.serverassembly for boot sectors - comp.lang.asm.x86 ASM disk cannot be found - comp.databases.oracle.server assembly for boot sectors - comp.lang.asm.x86 ASM disk cannot be ... X86 Boot Up from Mirrored Disk. - comp.unix.solarisassembly for boot sectors - comp.lang.asm.x86 I'm rather interested in making my pc boot up with my own os ... ... cannot be found - comp.databases.oracle.server assembly ... [bochs][nasm][video memory] - comp.lang.asm.x86assembly for boot sectors - comp.lang.asm.x86 [bochs][nasm][video memory] - comp.lang.asm.x86 assembly for boot sectors - comp.lang.asm.x86 [bochs][nasm][video memory ... FAR CALL/JMP to an absolute address - comp.lang.asm.x86assembly for boot sectors - comp.lang.asm.x86... not sure which Jmp Dword Ptr CS:FAR_JMP ... Int 010H ;Call the ROM BIOS Jmp ... floppy to the memory segment 0x500 ( the ... Can anyone help me with assembly language? - comp.lang.asm.x86 ...assembly for boot sectors - comp.lang.asm.x86 Can anyone help me with assembly language? - comp.lang.asm.x86 ... assembly for boot sectors - comp.lang.asm.x86 Writing Boot ... Global Offset Table of a ELF executable - comp.unix.programmer ...assembly for boot sectors - comp.lang.asm.x86 Global Offset Table of a ELF executable - comp.unix.programmer ... assembly for boot sectors - comp.lang.asm.x86 Global ... Pleae help..... Could not start Apachectl "Cannot find ELF" - comp ...assembly for boot sectors - comp.lang.asm.x86 Pleae help..... Could not start Apachectl "Cannot find ELF" - comp ... assembly for boot sectors - comp.lang.asm.x86... am ... Writing Boot Sector Code - Susam PalThe details of the assembly language won't be discussed. Only how to write code for boot sector will be discussed. All code examples used in this article are available at ... Tutorial – Building a Simple Boot Sector on OS X « M3 Operating ...Obviously, our boot sector at this point is essentially useless, but we’ve learned how to compile our boot sector assembly code into a binary, place that ... 7/25/2012 9:46:40 PM
|