flat assembler
Message board for the users of flat assembler.

Index > OS Construction > AXOS

Author
Thread Post new topic Reply to topic
addes3



Joined: 09 May 2011
Posts: 29
addes3
Hi folks, I'm making a simple real-mode OS called AXOS.
Currently all it does is load the kernel and set an interrupt, but I'm hoping I'll be able to extend it to support I/O, Files, etc.
I've been skimming through OSDev.org and http://www.brokenthorn.com/Resources/OSDev1.html

I've recently had a problem when running on bare hardware with a 1.44MB floppy.

Currently AXOS prints 'A' when resetting the floppy, 'B' when loading the kernel, 'C' at the start of the kernel, set's int 50h in the IVT, then calls int 50h which prints 'D'.
This is what happens in Bochs. The floppy currently prints 'ABC' then freezes.
I use PartCopy to put the image on the floppy, like so: partcopy axos.img 0 400 -f0

Here's the code:
x_boot.asm:
Code:
        format  binary
        use16
        org     7c00h

        jmp     start
        nop

OEM:                    db "adamsxos"
bpbBytesPerSector:      dw 512
bpbSectorsPerCluster:   db 1
bpbReservedSectors:     dw 2
bpbNumberOfFATs:        db 2
bpbRootEntries:         dw 224
bpbTotalSectors:        dw 2880
bpbMedia:               db 0F0h
bpbSectorsPerFAT:       dw 9
bpbSectorsPerTrack:     dw 18
bpbHeadsPerCylinder:    dw 2
bpbHiddenSectors:       dd 0
bpbTotalSectorsBig:     dd 0
bsDriveNumber:          db 0
bsUnused:               db 0
bsExtBootSignature:     db 29h
bsSerialNumber:         dd 0
bsVolumeLabel:          db "X          "
bsFileSystem:           db "FAT12   "

start:
  reset_floppy: ;reset the floppy drive
        mov     ax,0e41h
        xor     bx,bx
        int     10h

        mov     ah,00h
        int     13h
        jc      reset_floppy

  read_floppy:
        mov     ax,0e42h
        xor     bx,bx
        int     10h

        mov     ax,0000h
        mov     es,ax
        mov     bx,1000h

        mov     ah,2
        mov     al,1
        mov     ch,0
        mov     cl,2
        mov     dh,0

        int     13h     ;read 1 sector from floppy drive
        jc      read_floppy   ;if error, try again

        jmp     0000:1000h

times   510 - ($-$$)    nop
        dw      0aa55h    

x_kernel.asm:
Code:
        format  binary
        use16
        org     1000h

start:
        mov     ax,0e43h
        xor     bx,bx
        int     10h

        mov     dword [320],0000+interrupt
        mov     [boot_drive],dl

        int     50h

        cli
        hlt

interrupt:
        mov     ax,0e44h
        xor     bx,bx
        sti
        int     10h
        cli
        iret

boot_drive db 0

times   512 - ($-$$)    nop    


Here's what I use to make the image:
Code:
format binary as 'img'
file 'x_boot.bin'
file 'x_kernel.bin'    
Post 17 Aug 2011, 00:52
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239
nice job. Have you seen my xOS? It's a realmode OS with FAT12 support with source included if you wanted to take a look.
Post 17 Aug 2011, 02:07
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
me239, where is it. I'd like to take a look at it please Very Happy
Post 17 Aug 2011, 03:32
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239
typedef wrote:
me239, where is it. I'd like to take a look at it please Very Happy
I detect some sarcasm here, but anyways it's under OS construction xOS version 0.2.
Post 17 Aug 2011, 04:02
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
me239 wrote:
typedef wrote:
me239, where is it. I'd like to take a look at it please Very Happy
I detect some sarcasm here, but anyways it's under OS construction xOS version 0.2.



No dude, lol Very Happy. This is real
Post 17 Aug 2011, 04:46
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Quote:
I've recently had a problem when running on bare hardware with a 1.44MB floppy.


Hello,
you must set the stack and the data segment in early stage
of your bootloader Wink
you are making too many wrong assumptions Shocked

_________________
Nil Volentibus Arduum Razz
Post 17 Aug 2011, 07:30
View user's profile Send private message Reply with quote
addes3



Joined: 09 May 2011
Posts: 29
addes3
Thank you Smile Works now.

@me239: Sounds cool, I'll look it up.
Post 17 Aug 2011, 21:17
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239
addes3 wrote:
Thank you Smile Works now.

@me239: Sounds cool, I'll look it up.

http://board.flatassembler.net/topic.php?t=13249
Post 18 Aug 2011, 04:15
View user's profile Send private message Reply with quote
addes3



Joined: 09 May 2011
Posts: 29
addes3
Here's an updated version. Currently no file support, though.

x_boot.asm:
Code:
        format  binary
        use16
        org     7c00h

        jmp     start
        nop

OEM:                    db "ADAMS OS"
bpbBytesPerSector:      dw 512
bpbSectorsPerCluster:   db 1
bpbReservedSectors:     dw 2880
bpbNumberOfFATs:        db 2
bpbRootEntries:         dw 224
bpbTotalSectors:        dw 2880
bpbMedia:               db 0F0h
bpbSectorsPerFAT:       dw 9
bpbSectorsPerTrack:     dw 18
bpbHeadsPerCylinder:    dw 2
bpbHiddenSectors:       dd 0
bpbTotalSectorsBig:     dd 0
bsDriveNumber:          db 0
bsUnused:               db 0
bsExtBootSignature:     db 29h
bsSerialNumber:         dd 0
bsVolumeLabel:          db "AXOS       "
bsFileSystem:           db "FAT12   "

start:
        cli     ;set up the segments and stack
        xor     ax,ax
        mov     ds,ax
        mov     es,ax
        mov     fs,ax
        mov     gs,ax

        mov     ax,0fffh
        mov     ss,ax
        mov     sp,0ffffh
        mov     bp,sp
        sti

  reset_floppy: ;reset the floppy drive
        mov     ah,00h
        int     13h
        jc      reset_floppy

  read_kernel:
        mov     ax,0000h
        mov     es,ax
        mov     bx,1000h

        mov     ah,2
        mov     al,1
        mov     ch,0
        mov     cl,2
        mov     dh,0

        int     13h     ;read 1 sector from floppy drive
        jc      read_kernel   ;if error, try again

        jmp     0000:1000h

times   510 - ($-$$)    nop
        dw      0aa55h    

x_kernel.asm:
Code:
        format  binary
        use16
        org     1000h

crlf    equ     0dh,0ah
macro   mov     p1,p2 {
  if p2 eqtype ''
    local ..string,..skip
        jmp     ..skip
      ..string db p2,0
      ..skip:
        mov     p1,..string
  else
        mov     p1,p2
  end if
}

start:
        mov     ax,0e43h
        xor     bx,bx
        int     10h

        mov     dword [320],0000+interrupt
        mov     [boot_drive],dl

        mov     ax,0003h
        int     10h

        mov     si,.msg
        mov     ah,01h
        int     50h

        mov     di,.input
        mov     dx,19h
        mov     ah,03h
        int     50h

        mov     si,new_line
        mov     ah,01h
        int     50h

        mov     si,.input
        mov     ah,01h
        int     50h

        cli
        hlt
.msg db 'AXOS V0.01',0dh,0ah,'>',0
.input rb 20h

error:
        mov     si,.msg
        mov     ah,01h
        int     50h
        cli
        hlt
.msg db 'WHOOPS: AXOS ERROR!',0

interrupt:
        or      ah,ah
        jz      terminate_program
        cmp     ah,01h
        je      print_string
        cmp     ah,02h
        je      clear_screen
        cmp     ah,03h
        je      get_string
        cmp     ah,04h
        je      wait_enter
        cmp     ah,05h
        jmp     error

terminate_program:
        cli     ;set up the segments and stack
        xor     ax,ax
        mov     ds,ax
        mov     es,ax
        mov     fs,ax
        mov     gs,ax

        mov     ax,0fffh
        mov     ss,ax
        mov     sp,0ffffh
        mov     bp,sp
        sti

        jmp     2000h

;prints a zero-terminated, ds:si pointed string
print_string:
        push    ax

      @@:
        lodsb
        or      al,al
        jz      .ret
        mov     ah,0eh
        int     10h
        jmp     @b

      .ret:
        pop     ax
        iret

;clears the screen, no args or returns
clear_screen:
        push    ax di es dx

        mov     ax,0b800h
        mov     es,ax
        xor     di,di

      @@:
        mov     byte [es:di],0
        add     di,2
        cmp     di,4000
        jne     @b

        mov     ah,02h
        mov     dx,0000h
        int     10h

      .ret:
        pop     dx es di ax
        iret

;gets a string from the keyboard, es:di points to the reserved memory, dx holds maximum characters to collect
;returns: es:di string, dx = 0 or bytes of memory not used
get_string:
        push    ax

        dec     dx

      @@:
        xor     ah,ah
        int     16h
        or      al,al
        jz      .extended
        cmp     al,0ah
        je      .ret
        cmp     al,0dh
        je      .ret

        mov     ah,0eh
        int     10h

      .store:
        stosb

        dec     dx
        or      dx,dx
        jz      .ret

        jmp     @b

    .extended:
        shr     ax,8
        jmp     .store

      .ret:
        mov     al,0
        stosb

        pop     ax
        iret

;waits until return key is pressed
wait_enter:
        push    ax

      @@:
        xor     ah,ah
        int     16h
        cmp     ah,0ah
        jne     @b

      .ret:
        pop     ax
        iret

boot_drive db 0
new_line db crlf,0

times   200h - ($-$$)   nop    
Post 18 Aug 2011, 22:48
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239
addes3 wrote:
Here's an updated version. Currently no file support, though
Why not start with a FAT12 Bootloader?
Post 19 Aug 2011, 01:43
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.