×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Trying to write an OS.. Help me a bit?

Trying to write an OS.. Help me a bit?

Trying to write an OS.. Help me a bit?

(OP)
I'm utilizing a bootloader I found online which I modified. It can load a COM file after booting, and supports minimal error handling. It is copyrighted, so if anyone has a bootloader which I can have that can load a .com file or any other file type that can be made in C or assembly, please tell me. Also: My current problem (while utilizing the bootloader i have) is that I am trying to write a kernel. I am trying to program for keyboard support so that the user can type things in, and then I can have the OS jump to different code based on what they type in. It will be a very simple setup, but this is what i'd like for now. Currently I have this: (i'm new to assembly, so there may well be errors, and the output of this SHOULD [but doesn't] allow the user to display one keypress at a time.)

inputloop:
int 9
in al, 60h
msg db, al
bios_print_string msg
jmp inputloop

RE: Trying to write an OS.. Help me a bit?

Why don't you take a look at existing boot loaders like LILO and GRUB and examine the source to see how they work.  GRUB is my particular preference and you can find it at http://www.gnu.org/software/grub/grub.en.html

Hope that helps.


Trojan.

RE: Trying to write an OS.. Help me a bit?

(OP)
I've tried using loaders like GRUB in the past, but unfortunately for me I build from Windows XP, and it has no DD command. Without DD I can only write one floppy image at a time to a floppy. Only Linux DD has this functionality.

Anyway, I need only one more piece of code to have a functional OS and be able to start writing COM programs for it. I need to know how to execute a COM program from assembly language. I hope to achieve the following with this:

1.
Accept Keyboard Input from the user, and put it into a register (and display it on the screen at the same time)

2.
Upon the user pressing enter, execute the com file that they have typed the name of.

3.
The com files I and others write for this OS will have to have code, that on pressing escape, will restart the main COM file of the OS, which will again query them for a COM file.

This is a simple setup, but it should work. Can you help me to fill in the code for the steps?

RE: Trying to write an OS.. Help me a bit?

I'm sorry but I really don't quite understand your problem.
If you want to boot from floppy (or anything else for that matter), you just need to create a "boot sector" which you can create as a file and then write directly to floppy using something like rawrite (for windoze!!!).
As for creating COM programs, you can simply write whatever assembly code you want and connect it to the end of the boot sector. You just have to make the boot sector point to it and it will then execute directly on boot.
I'm sure you could learn lots about all this from the documentation and even the source code on the GRUB website that I gave you.

Also, GRUB has menus and handles the keyboard for user input.


Trojan.

RE: Trying to write an OS.. Help me a bit?

(OP)
Ok ok.. I'll try to put this into simpler terms.

I have a boot sector. It works. I have it boot the computer, show a "booting the kernel" thing, and then start the kernel, which is in the form of a .COM file.

I need to write the kernel. This is where I need help. I need the kernel to do the following, in this order:

1. Display "Command: "
2. Display keyboard input and record it into a register or variable after the prompt.
3. When the user presses Enter, execute the .COM file with the name specified in the register or variable mentioned in step 2.

Understand now? I need help writing the kernel, and only have a light grasp on assembly, enough to modify code. I haven't found a tutorial that goes into the areas I need to learn for this, and so I turned to human help. I need you to give me code for steps 1, 2, and 3, shown above. Thanks!

RE: Trying to write an OS.. Help me a bit?

We can't write complete kernels for you.  That is way too complex.  That is why I pointed you to sample code that others have developed over many years.
You can look at the source and see how others have done it.
I realise that what you want appears to be simple but you are making many assumptions with that.  When you look at how others have done it you will see some of the issues.
Also, if you have only a light grasp on assembly language, it is going to be much tougher for anyone to explain it all to you.
I suggest you look at other code that works and come back with simpler questions like "how do I make this code [blah blah] do that", rather than "can someone teach me how to write an operating system".



Trojan.

RE: Trying to write an OS.. Help me a bit?

(OP)
Yea, its easy for you to continually point me away to tutorials that don't exist. I have yet to find a single tutorial on the internet that does anything but basic assembly. I get basic assembly, and it doesn't work for what I need. I need to know how to execute an external file. If you can get me that single piece of code, or point me to one of these magical tutorials and code snippets that explain to me how to execute a COM file from assembly code, point away.

RE: Trying to write an OS.. Help me a bit?

To execute an external COM (by which I assume you mean binary image) file, simply load it into memory at any convenient address - since its a COM file the first byte should be executable.  Once you've loaded it call that address.

Your OS code will probably be something like

GetUserInput:
  Read & Process Keys
  Load Requested Program into 1234:0000
  Call 1234:0000
  Jmp GetUserInput

Hope this helps.
  

RE: Trying to write an OS.. Help me a bit?

(OP)
Yes. This does help, this is more what I wanted. I'll go check my "Complete 8086 instruction set" and see how to load the programs into memory... I'll post again if I run into anything, thanks.

RE: Trying to write an OS.. Help me a bit?

You will need to Int 13h, Function 2, the BIOS disk IO Read function to read the file into a buffer.

Hope this helps.

RE: Trying to write an OS.. Help me a bit?

(OP)
After inspecting every command in the reference I have, the closest thing to loading a program into memory I could find was this:
Load Effective Address.

Algorithm:

    * REG = address of memory (offset)


Generally this instruction is replaced by MOV when assembling when possible.

Example:


ORG 100h

LEA AX, m

RET

m  DW  1234h

END

AX is set to: 0104h.
LEA instruction takes 3 bytes, RET takes 1 byte, we start at 100h, so the address of 'm' is 104h.

Needless to say, this doesn't seem to do it... Which command should I be using?

RE: Trying to write an OS.. Help me a bit?

(OP)
Oops, I didn't recheck before posting again, I apologeize, thank you.

RE: Trying to write an OS.. Help me a bit?

(OP)
Ok I've got my code all prepared to read from the proper sectors and such, however, I've a problem.

In order to read from a specific sector of the floppy, I must be able to write from a specific sector of the floppy. I am operating out of Windows, and hence have no DD (DD for windows I have tried to use, but cannot get it to work properly). Rawrite (to my knowledge) cannot write to a specific spot on the floppy. Know of any tools to do this?

RE: Trying to write an OS.. Help me a bit?

I don't think you can do direct disk access through Windows.  You would probably be better off woth an old DOS machine to work on.

RE: Trying to write an OS.. Help me a bit?

(OP)
After searching for a bit, I've found a utility called SecWrite, which can do what I asked. It, coincidentally, is written in ASM.. I'll be converting it into a utility for my OS as well.

RE: Trying to write an OS.. Help me a bit?

I've just had a quick look at SecWrite and a couple of things spring to mind:

It's dated 1998
It uses Int 21h - the DOS services interrupt

It is unlikely to run under protected mode Windows and your operating system wont have access to DOS services.

RE: Trying to write an OS.. Help me a bit?

You can write to the floppy with rawrite to specific sectors by padding the file in 512 byte chunks.

Simply create your binary file with the boot sector at the start of the file and pad to where you want the next block of data to go.  Then write the whole file to floppy as one stream.

For example.  If your boot sector is sector 0 and your code is at sector 1, create a file with your boot sector (say 36 bytes) and pad with null chars or whatever you like until you have written 512 bytes. The add the rest of your binary code to the file and write the whole file in one chunk using rawrite.


Trojan.

RE: Trying to write an OS.. Help me a bit?

TrojanWarBlade, DevPortal is envisaging having more than one "COM" file, so some sort of Filing or Indexing system would be required to identify the Name, Start and Size of each "COM" file.

RE: Trying to write an OS.. Help me a bit?

Or you could pad each one at a specific sector offset.


Trojan.

RE: Trying to write an OS.. Help me a bit?

(OP)
Ok two things.

1. Secwrite works just fine, and I'm running WinXP. WinXP likely has initiated a compatibility mode, so there shouldn't have been a problem anyway.

2. I'm having issues with my loading code. I have two .com applets atm, one is calc.com and one is snake.com.

Calc.com is a calculator, and snake is a game. Calc is at C/H/S 0/0/18, and snake is 0/0/17. (both track 0)

I have this code in a COM file which is loaded after it boots (And i know it is being loaded properly, cuz i have tested it in many ways):

MOV     AH, 02h ; read function.
MOV     AL, 10  ; sectors to read.
MOV     CH, 0   ; cylinder.
MOV     CL, 18   ; sector.
MOV     DH, 0   ; head.
MOV     BX, 0800h   
MOV     ES, BX
MOV     BX, 0
INT     13h
JMP     0800h:0000h

When it loads it shows my loading message for the bootloader, and then it hangs...

RE: Trying to write an OS.. Help me a bit?

(OP)
I've realized two flaws in the code, one is that it is loading 10 sectors, so I have reduced that to 1 (my com's are 1kb each, which is minimum on a floppy). Also, this code is using JMP, i am going to try using CALL. ..will post results...

RE: Trying to write an OS.. Help me a bit?

A sector is 512 bytes so if you programs are 1k then you will need to load two sectors.

RE: Trying to write an OS.. Help me a bit?

(OP)
Oh durr. That means that one is overwriting the other as well. I was thinking that sectors were 512K not 512 bytes... I'll try that then! >.^

RE: Trying to write an OS.. Help me a bit?

RE: Trying to write an OS.. Help me a bit?

(OP)
Ok since I cannot seem to toubleshoot this myself, I'll give you all my code and tell you how/where it is written to my floppy.

First, I have this code, written in bin form using rawrite:

; NYAOS Boot Sector (C) Copyright Sean Tash 1998
; Serpent Boot Sector - DevPortal 2005 Modified from Above
; assemble with: nasm
            bits 16
            org 0x7C00

start:      jmp short begin
            nop
bsOEM       db "Serpent1"               ; OEM String
bsSectSize  dw 512                      ; Bytes per sector
bsClustSize db 1                        ; Sectors per cluster
bsRessect   dw 1                        ; # of reserved sectors
bsFatCnt    db 2                        ; # of fat copies
bsRootSize  dw 224                      ; size of root directory
bsTotalSect dw 2880                     ; total # of sectors if < 32 meg
bsMedia     db 0xF0                     ; Media Descriptor
bsFatSize   dw 9                        ; Size of each FAT
bsTrackSect dw 18                       ; Sectors per track
bsHeadCnt   dw 2                        ; number of read-write heads
bsHidenSect dd 0                        ; number of hidden sectors
bsHugeSect  dd 0                        ; if bsTotalSect is 0 this value is
                                        ; the number of sectors
bsBootDrv   db 0                        ; holds drive that the bs came from
bsReserv    db 0                        ; not used for anything
bsBootSign  db 29h                      ; boot signature 29h
bsVolID     dd 0                        ; Disk volume ID also used for temp
                                        ; sector # / # sectors to load
bsVoLabel   db "NO NAME    "            ; Volume Label
bsFSType    db "FAT12   "               ; File System type

begin:      cli                         ; disable interrupts
            mov [bsBootDrv],dl          ; save drive number
            mov ax,0x9000               ; put stack at 0x98000
            mov ss,ax
            mov sp,0x8000

            mov cx,[bsTrackSect]        ; update int 1E FDC param table
            mov bx,0x0078
            lds si,[ds:bx]
            mov byte [si+4], cl
            mov byte [si+9], 0x0F

            sti                         ; enable interrupts
            push ds
            mov dl,[bsBootDrv]          ; reset controller
            xor ax,ax
            int 0x13
            pop ds
            jc bootfail2                ; display error message
            jmp _l1
bootfail2:  jmp bootfail
_l1:
            mov ax,0x0000
            mov es,ax
            mov ds,ax

            mov si,MsgLoad              ; display load message
            call putstr

            ; find the root directory

            xor ax,ax
            mov al,[bsFatCnt]
            mov bx,[bsFatSize]
            mul bx
            add ax,word [bsHidenSect]
            adc ax,word [bsHidenSect+2]
            add ax,word [bsRessect]     ; ax holds root directory location
            mov word [BootSig],ax

            call checkroot

            xor ax,ax
            add ax,word [start]
            add ax,word [bsVolID]       ; sector number
            add ax,word [BootSig]
            sub ax,2                    ; correction for a mis-calc
            mov cx,word [bsVolID+2]     ; number of sectors

            mov bx,0x8000
            mov es,bx


nextsector: push ax                     ; save registers
            push cx
            push dx
            push es

            xor bx,bx                   ; set zero offset
            call readsect               ; read a sector

            mov si,MsgDot               ; display a dot
            call putstr

            pop es                      ; restore registers
            pop dx
            pop cx
            pop ax
            mov bx,es
            add bx,20h                  ; increment address 512 bytes
            mov es,bx
            inc ax                      ; read next sector
            loopnz nextsector

            mov ax,0x8000               ; set segment registers and jump
            mov es,ax
            mov ds,ax
            push ax
            mov ax,0
            push ax
            retf

checkroot:
            push ax                     ; save registers
            push bx
            push cx
            push dx
            push si
            push di
            
            mov ax,0x8000               ; put root directory at 0x80000
            mov es,ax
            mov ax,32                   ; AX = ((32*RootSize)/512) + 2
            mul word [bsRootSize]
            div word [bsSectSize]
            mov cx,ax                   ; cx holds # of sectors in root
            mov word [start],ax
            mov ax,word [BootSig]       ; get prev. saved loc. for root dir

r1:         xor bx,bx
            push cx                     ; save count
            push ax                     ; save sector number
            push es
            push dx
            call readsect
            xor bx,bx
l_1:        mov di,bx                   ; set address to check from
            mov cx,11                   ; check 11 bytes
            mov si,FileName             ; address of string to check with
            repz cmpsb
            je foundit
            add bx,32                   ; check next entry
            cmp bx,[bsSectSize]         ; end of sector?
            je l_2
            jmp l_1
l_2:        pop dx                      ; restore registers
            pop es
            pop ax
            pop cx
            inc ax                      ; read next sector
            loopnz r1
            jmp bootfail
foundit:    pop dx                      ; get these off the stack
            pop es
            pop ax
            pop cx

            mov di,0x1A                 ; get clustor #
            add di,bx
            push bx                     ; save bx for finding # of sectors
            mov ax,[es:di]
            xor bx,bx                   ; calculate sector #
            mov bl,[bsClustSize]
            mul bx                      ; ax holds sector #
            mov word [bsVolID],ax

            pop bx                      ; get location of directory entry
            mov di,0x1C
            add di,bx
            mov ax,[es:di]              ; put number of bytes in ax
            xor dx,dx
            mov bx,[bsClustSize]        ; # of bytes / 512
            div bx
            inc ax
            mov word [bsVolID+2],ax     ; save number of sectors to load

            pop di                      ; restore registers
            pop si
            pop dx
            pop cx
            pop bx
            pop ax
            
            ret                         ; return to caller
            
putstr:     ; SI = address of string to display
            lodsb
            or al,al
            jz short putstrd
            mov ah,0x0E
            mov bx,0x0007
            int 0x10
            jmp putstr
putstrd:    retn                        ; return to caller

bootfail:   ; display failure message
            mov si,MsgBad               ; display error message
            call putstr
            xor ax,ax                   ; wait for keypress
            int 0x16
            int 0x19                    ; reboot

readsect:   ; ES:BX = Location ; AX = Sector
            mov si,[bsTrackSect]
            div si                      ; divide logical sect by track size
            inc dl                      ; sector # begins at 1
            mov [bsReserv],dl           ; sector to read
            xor dx,dx                   ; logical track left in ax
            div word [bsHeadCnt]        ; leaves head in dl, cyl in ax
            mov dh, [bsBootDrv]         ;
            xchg dl,dh                  ; head to dh, drive to dl
            mov cx,ax                   ; cyl to cx
            xchg cl,ch                  ; low 8 bits of cyl to ch, hi 2 bits
            shl cl,6                    ; shifted to bits 6 and 7
            or cl, byte [bsReserv]      ; or with sector number
            mov al,1                    ; number of sectors
            mov ah,2                    ; use read function of int 0x13
            int 0x13                    ; read sector
            jc bootfail                 ; display error message
            ret                         ; return to caller

padding     times 45 db 0
FileName    db "OSLOADERCOM"
MsgBad      db " OSLOADER.COM is missing.",13,10,0
MsgDot      db ".",0
MsgLoad     db "SerpentOS Loading...",0
BootSig     db 0x55, 0xAA

For some reason it only shows "Serp." when it gets to MsgLoad, but that isn't my primary concern...

OSLOADER.COM is the following in assembly, and is copied to the disk by just copy-pasting:

MOV     AH, 02h ; read function.
MOV     AL, 2  ; sectors to read.
MOV     CH, 0   ; cylinder.
MOV     CL, 16   ; sector.
MOV     DH, 0   ; head.
MOV     BX, 0800h   
MOV     ES, BX
MOV     BX, 0
INT     13h
CALL     0800h:0000h

I currently have it set up just to read the calculator program instead of presenting a menu, but it should test well enough.

The calculator (calc.com) is written at cyl 0, head 0, track 0, sector 16. Its code is unimportant, as I didn't write it, and I've tested it to see that it works.

Anyways, as I said, it shows the bootloader's "SerpentOS Loading..." message, but mangled to be "Serp.". It then hangs. Any errors or fixes or help? >.<

RE: Trying to write an OS.. Help me a bit?

My assembler is very rusty and was based mainly on MASM - in that I would have used either:

     LEA SI, MsgLoad
or  MOV SI, Offset MsgLoad

I'm not sure what difference that would make if any.

RE: Trying to write an OS.. Help me a bit?

(OP)
Well, I tried LEA SI, MsgLoad and it didn't even compile properly.. Maybe you misread, but the bootloader says "Compile in NASM", you use MASM. Big difference in syntax across TASM/NASM/MASM... Also, in the second one: MOV SI, OFFSET MsgLoad, what do I put for offset? Would it be something like MOV SI, 8+MsgLoad??

[Again I still need help getting calc.com to run, this isn't my primary problem, I know that the bootloader works properly..]

RE: Trying to write an OS.. Help me a bit?

(OP)
I know that the problem lies in the OSLOADER.COM code, btw... The bootloader works fine, and the calculator works fine. It is possible that SecWrite is the problem, or how I'm using it, but it appears to write fine...

RE: Trying to write an OS.. Help me a bit?

(OP)
Another way I could take this OS is to pass control off to a C/C++ kernel.. I am better with high level languages, though I'm rusty on C. Anyhow, does anyone know how to load up a C file and pass control? (I think that this would require almost the exact same code, just the executing part would be different..)

RE: Trying to write an OS.. Help me a bit?

(OP)
Now that I recall (sorry for posting so much rapidly, but we don't have edit here...), C++ compiles to exe with the compiler that I have, so I'd have to know how to run exe from ASM... (which I'm aware is even more complex...)

RE: Trying to write an OS.. Help me a bit?

Quote:


Anyways, as I said, it shows the bootloader's "SerpentOS Loading..." message, but mangled to be "Serp.". It then hangs. Any errors or fixes or help?

If DS:SI are pointing to the correct address, INT 10h, function 0Eh displays the character in AL, your code tests AL for 0, which you use as you get out test, your message should display correctly - which is why I thought the problem must lie somewhere there.

I noticed that you are not using MASM, which is why I drew your attention to the fact that my experience was in MASM and that there may be syntactic differences - although its 8 to 10 years since I last did any serious assembler programming.

MOV SI, OFFSET MsgLoad is exactly what I would type for MASM, which would calculate the address.  I'm surprised that LEA didn't work - I nearly always used it in these circumstances.

RE: Trying to write an OS.. Help me a bit?

(OP)
It said that LEA SI, MsgLoad didn't have the proper number of arguments. I will try MOV SI, OFFSET MsgLoad, and then if you haven't posted, check the reference I have for LEA's arguments.

RE: Trying to write an OS.. Help me a bit?

(OP)
MOV SI, OFFSET MsgLoad says comma or end of line expected upon attempts to compile, I am going to try

MOV SI, OFFSET, MsgLoad and see if that works...

RE: Trying to write an OS.. Help me a bit?

(OP)
It says that OFFSET is undefined, which I assume means that it was a MASM specific variable..

RE: Trying to write an OS.. Help me a bit?

(OP)
serpent.asm:57: invalid combination of opcode and operands

This is exactly what I get when I compile with LEA SI, MsgLoad

RE: Trying to write an OS.. Help me a bit?

Try square brackets around MsgLoad ie LEA SI, [MsgLoad]

otherwise I'm afraid I'll have to leave you to someone else, as I said, my assembler skills are so rusty that I would probably be more of a hinderance than a help.

RE: Trying to write an OS.. Help me a bit?

(OP)
YES! Well, that one compiled! I'm going to go test it!

RE: Trying to write an OS.. Help me a bit?

(OP)
It works just as well as MOV did, but one less letter >.< I'm going to try another (probably more recent) version of NASM I have...

RE: Trying to write an OS.. Help me a bit?

(OP)
When compiling with the newer NASM it gave me Serpe. instead of Ser. or Serp.

It seems to always add that period at the end. I did not write that bootloader, so perhaps there was some message-specific coding, such as message size or something? The original message was "doors loading"... I am going to change ""SerpentOS Loading...",0" to "SerpentOS Loading...0"

RE: Trying to write an OS.. Help me a bit?

0 inside quotes has a value of 48 decimal and will not be picked up by OR AL, AL (your end of string test)

RE: Trying to write an OS.. Help me a bit?

(OP)
Well, that shows that the code isn't properly functioning then, since it changes the results by NADDA. I'm going to try the original code (before I modified it to have different messages) and see if it will load the calc program right...

RE: Trying to write an OS.. Help me a bit?

(OP)
Proving that the code was fine, the original message displayed properly, and then nothing happens. This shows that it may be that SecWrite isnt properly writing the file to the disk, so I will attempt to do it on a true DOS 6.22 machine. If it still does not work, I will attempt to find a different program to write a file to a specific sector.

RE: Trying to write an OS.. Help me a bit?

(OP)
Apparently none of my stuff is working any longer, don't know why. I put the basic boot image onto the disk, and copied the calculator applet to my disk as osloader.com. This did not execute. I will have to revamp my project, maybe using differing boot code.

RE: Trying to write an OS.. Help me a bit?

Your bootloader code exceeds the maximum of one sector,
so the bytes above the 512 a falling into the big black
hole.

By recoding the move you just added a byte of machine code
so one more byte of the bootload message falls into....

If there is no 000h found in memory from this point
the bootloader will just ceep sending byte's till all
64k is done and then do it all over again.

Then the second, afther loading a com file you have to start your program at xxxx:0100 and not xxxx:0000

succes, Tessa

RE: Trying to write an OS.. Help me a bit?

Tessa, that definitely deserves a star.

I was on the verge of digging out an old version of MASM to try to make sense of what was going wrong - just shows how rusty I am.

I would not necessarily agree with you about the start address, though.  DOS requires COM files to start at xxxx:0100, but this is to allow for the Program Segment Prefix.  There is no reason why DevPortal's programs can't start from xxxx:0000.

DevPortal,  The Boot Sector does not need to allow for a BIOS Parameter Block since this is not DOS.  All the Boot Sector has to do is load your operating system - NOTHING ELSE.  Asd you don't need complex disk management, the OS (which can be as large as you need) can start from the second sector.  The OS will then provide the resources  that we talked about in my post 8 Jul 05 14:21

Hope this gives you something more to go on.

RE: Trying to write an OS.. Help me a bit?

Some further thoughts on structure:

Disk Layout (AbsoluteSectors):

CODE

0     :  Boot Sector
1 - 8 :  Operating System
9     :  File System
10 -> :  Files

This allows for a 4K operating system
If your file names are limited to 8 characters then up to 64 files
As this does not provide detailed file management files should be fixed at, say, 4K and padded where necessary.

=========

Memory Structure:

CODE

0000:7C00 BS Loaded
0000:8FFE SP
0000:9000 OS
0000:A000 memory copy of File System
0000:B000 user program area

This means that CS, DS, ES and SS can all be 0

==========

Your Boot Sector would then just need to set SS:SP (between CLI and STI) and DS and ES.  Then load AbsoluteSectors 1 to 8 at 0000:9000 and JMP to 9000.

Your OS would then load AbsoluteSector 9 at A000 and then monitor the keyboard.  When Enter is pressed check the string that has been entered against the FileSystem, work out which File was selected (if filenames are fixed at or packed to 8 characters the arithmetic will be easy) and then claculate the AbsoluteSector (which can then be easily converted to Head/Cylinder/Sector) to locate the program, load it into B000 and CALL B000.  Note all your programs must end with RET to get back to the OS loop.

Hope this helps.




RE: Trying to write an OS.. Help me a bit?

If you are building the com files the space for the program segment prefix is reserved in the binairy(== com) file.
So you have to start your programs at xxxx:0100.
If you create your com's thru a other way then an only then you can start at xxxx:0000

Also you have to consider that if you are realy bootloading from the bios level, that means if there is no other operating system loaded before, you can not use "DOS" interrupt call(it simple is not there).
Only the "BIOS" call can be used.

Good luck, Tessa

RE: Trying to write an OS.. Help me a bit?

(OP)
I've already recoded the whole OS and have it passing the control to a C kernel, but am at the same problem only worse than when it was in ASM, cuz I cant even execute programs >.<. Anyway, I think I'm going to two-prong this project, and make an ASM-Only OS and a ASM/C OS. Also: As I said very early in these posts, I'm an ASM noob. I'm also a C noob. I'm pretty much a noob to all normal programming. The only language I have extensive (and I mean GODLIKE) experience in is GML, which is in a program called Gamemaker. It is very very similar to C, so I have some good experience with the structure, and good grasp on programming in general. Anyway, what I'm trying to say is that while I can understand just about everything you guys say, I cannot implement some of the things, because I just don't know how to translate from suggestions-->code. I'm just not experienced enough. (I've made most of what I've made so far through modifying public domain code) Therefore, could someone help me do so?

RE: Trying to write an OS.. Help me a bit?

if you like, go to my mwesite

www.tomcruz.net

and email me from there.  I would be interested in helping you with your c code.  i am not as fluent as some but i do have 5 or 6 years as an intense hobbyist.  i have also begun a study of assembler.  i would not be able to help you much with asm  but i am looking for the opportunity to work with someone els on a project.  your project interests me and i see the opportunity to learn some new skills.


 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close