flat assembler
Message board for the users of flat assembler.

Index > OS Construction > xOS (my operating system) source code

Author
Thread Post new topic Reply to topic
me239



Joined: 06 Jan 2011
Posts: 200
me239
First off, hello everyone! I'm new to this forum; however, I've been using FASM for months now. Throughout my speratic programming I've created a few decent bootloaders and eventually my DOS OS xOS. xOS is a simple shell(no file support yet Sad ) with a few neat commands. Here are the following
hello: hello world!
echo: echo text after command
cls: clear screen
restart: restart prompt
help: all commands listed
alert: my favorite. It creates a messagebox containing the cmdline parameters given and waits for the return key.

P.S this is a slightly older version. The new one is on my other computer and has several bug fixes.
Image
NOTE: This is the super beta, before bootable picture of xOS
UPDATE: Here is the newest version. Don't be fooled by the "A:\", there is no file support.


Description: New xOS cmd.asm file and readme
Download
Filename: newos.zip
Filesize: 1.76 KB
Downloaded: 203 Time(s)

Description: xOS binary, image, and source code
Download
Filename: cmd.zip
Filesize: 9.4 KB
Downloaded: 203 Time(s)



Last edited by me239 on 06 Jan 2011, 22:23; edited 3 times in total
Post 06 Jan 2011, 06:02
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
cool, one more asm OS coder. Very Happy

good continuation Very Happy
Post 06 Jan 2011, 08:27
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
I agree nice work me239.
Post 06 Jan 2011, 18:18
View user's profile Send private message Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 240
Location: the-ideom
Mike Gonta
me239 wrote:
xOS is a simple shell(no file support yet Sad ) with a few neat commands.

Good job.
I took the liberty of translating xOS to 32 bit protected mode to show how easy it is to "overnight" move up to PM32,
(which will also boot and run on any PC that can boot from USB flash) with the same ease and simplicity of 16 bit real mode.
The PM32 boot sector included with the aeBIOS distribution loads a PM32 flat binary file called kernel.bin to 100000h.
This boot sector (located at LBA 36) can be changed or modified. The cmd.bin file (without the boot loader) was renamed
"kernel.bin" and copied to the root directory of the aeBIOS image after it is transferred to the USB flash drive.

_________________
Mike Gonta
the-ideom - now you know how to compile

https://mikegonta.com
Post 06 Jan 2011, 18:46
View user's profile Send private message Visit poster's website Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239
Mike Gonta wrote:
me239 wrote:
xOS is a simple shell(no file support yet Sad ) with a few neat commands.

Good job.
I took the liberty of translating xOS to 32 bit protected mode to show how easy it is to "overnight" move up to PM32,
(which will also boot and run on any PC that can boot from USB flash) with the same ease and simplicity of 16 bit real mode.
The PM32 boot sector included with the aeBIOS distribution loads a PM32 flat binary file called kernel.bin to 100000h.
This boot sector (located at LBA 36) can be changed or modified. The cmd.bin file (without the boot loader) was renamed
"kernel.bin" and copied to the root directory of the aeBIOS image after it is transferred to the USB flash drive.

WOW, thanks. I would really like to give it file support. Can you help me accomplish this?
Post 06 Jan 2011, 20:57
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
me239 wrote:

WOW, thanks. I would really like to give it file support. Can you help me accomplish this?

If your talking realmode a good starting point would be bootprog
http://alexfru.chat.ru/epm.html#bootprog

I have converted it to fasm, let me know if you want a copy.
Post 06 Jan 2011, 21:06
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239
Dex4u wrote:
me239 wrote:

WOW, thanks. I would really like to give it file support. Can you help me accomplish this?

If your talking realmode a good starting point would be bootprog
http://alexfru.chat.ru/epm.html#bootprog

I have converted it to fasm, let me know if you want a copy.

Yeah sure. Would you also know where I can find any good documentation on the FAT12 (All I have found tend to be C oriented) also I need to know how to launch a program(such as loading it into memory and such). Thanks Smile
Post 06 Jan 2011, 21:37
View user's profile Send private message Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 240
Location: the-ideom
Mike Gonta
me239 wrote:
WOW, thanks. I would really like to give it file support. Can you help me accomplish this?
Take a look at the source code for the PM32 boot sector / boot loader. This is the boot sector (located at LBA 36)
which aeBIOS loads to 7C00h.
This code can convert and look up a file name that the user enters on the command line. If found in the root directory
it can be loaded to say 200000h (2 MEG) and run. These apps would have "org 200000h" and could return to the shell
with "ret".

_________________
Mike Gonta
the-ideom - now you know how to compile

https://mikegonta.com


Last edited by Mike Gonta on 17 Sep 2011, 21:36; edited 2 times in total
Post 06 Jan 2011, 22:45
View user's profile Send private message Visit poster's website Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239
Mike Gonta wrote:
me239 wrote:
WOW, thanks. I would really like to give it file support. Can you help me accomplish this?
Take a look at the source code for the PM32 boot sector / boot loader. This is the boot sector (located at LBA 36)
which aeBIOS loads to 7C00h.
This code can convert and look up a file name that the user enters on the command line. If found in the root directory
it can be loaded to say 200000h (2 MEG) and run. These apps would have "org 200000h" and could return to the shell
with "ret".

Hey, thanks man. I've put aside the FAT12 until the weekend and instead I'm simulating int 21h DOS commands using the IVT! I'll be sure to get on the FAT12 support and file execution as all of these are going to go into a new DOS project mine! I'm not fully abandoning xOS, but it's on hold for a while; however, some functions may be adopted into the new project (eg. "alert"). I'll be sure to update my progress as I go Smile
Post 07 Jan 2011, 05:44
View user's profile Send private message Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 240
Location: the-ideom
Mike Gonta
me239 wrote:
I've put aside the FAT12 until the weekend and instead I'm simulating int 21h DOS commands using the IVT!
Setting up an interrupt handler in PM32 with the IDT is only slightly different.
The format of the Protected Mode Interrupt Descriptor Table Pointer is:
Code:
pm_idtr:
  dw NUMBER_OF INTERRUPT_HANDLERS*8-1
  dd POINTER_TO_IDT    
With aeBIOS the PM_IDTR is always located in a global variable at 520h. So to access the IDT:
Code:
PM_IDTR                           equ 520h
  mov esi, [PM_IDTR+2]          ; esi points to IDT    
Each IDT entry is 8 bytes long and contains protection, type and segment information which in a single segment
unprotected memory model can be ignored. The flat 32 bit address of the handler is stored in the entry such that the
lower 16 bits is in the first 2 bytes and the upper 16 bits is in the last 2 bytes.
Hooking a handled interrupt (aeBIOS provides default handlers for all interrupts - most of which merely do an "iret"),
involves saving and replacing the handler address. When the interrupt occurs the new handler will be executed, the last
instruction should be:
Code:
  jmp DWORD [saved_interrupt]    
to return to the original handler which when finished will return to the interrupted code.
Here is a simple framework example of establishing a new handler.
Code:
PM_IDTR                           equ 520h
use32
org 100000h
  mov esi, [PM_IDTR+2]          ; esi points to IDT
  
; save the original handler - not required for int 21h
  mov eax, [esi+21h*8]
  rol eax, 16
  mov ax, [esi+21h*8+6]
  rol eax, 16
  mov [saved_int_21], eax
; option not required
  
  mov WORD [esi+21h*8], int_21 AND 0FFFFh
  mov WORD [esi+21h*8+6], int_21 SHR 16

  mov esi, message
  call print
  xor eax, eax
  int 16h
  int 19h

print:
  mov ah, 2                     ; Write Character To Standard Output
.1:
  mov dl, [esi]
  lea esi, [esi+1]
  test dl, dl
  je .2
  int 21h
  jmp .1
.2:
  ret

message:
  db 'Using int 21h is fun!', 0

int_21:
  pusha
  cmp ah, 2
  jne .1
  mov ah, 0Eh
  xor bh, bh
  mov al, dl
  int 10h
.1:
  popa
; optionally can be simply replace with "iret"
  jmp DWORD [saved_int_21]
saved_int_21: dd 0
; option      
Assemble as kernel.bin, copy to the root directory and boot.

_________________
Mike Gonta
the-ideom - now you know how to compile

https://mikegonta.com
Post 07 Jan 2011, 14:28
View user's profile Send private message Visit poster's website Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239
Mike Gonta wrote:
me239 wrote:
I've put aside the FAT12 until the weekend and instead I'm simulating int 21h DOS commands using the IVT!
Setting up an interrupt handler in PM32 with the IDT is only slightly different.
The format of the Protected Mode Interrupt Descriptor Table Pointer is:
Code:
pm_idtr:
  dw NUMBER_OF INTERRUPT_HANDLERS*8-1
  dd POINTER_TO_IDT    
With aeBIOS the PM_IDTR is always located in a global variable at 520h. So to access the IDT:
Code:
PM_IDTR                           equ 520h
  mov esi, [PM_IDTR+2]          ; esi points to IDT    
Each IDT entry is 8 bytes long and contains protection, type and segment information which in a single segment
unprotected memory model can be ignored. The flat 32 bit address of the handler is stored in the entry such that the
lower 16 bits is in the first 2 bytes and the upper 16 bits is in the last 2 bytes.
Hooking a handled interrupt (aeBIOS provides default handlers for all interrupts - most of which merely do an "iret"),
involves saving and replacing the handler address. When the interrupt occurs the new handler will be executed, the last
instruction should be:
Code:
  jmp DWORD [saved_interrupt]    
to return to the original handler which when finished will return to the interrupted code.
Here is a simple framework example of establishing a new handler.
Code:
PM_IDTR                           equ 520h
use32
org 100000h
  mov esi, [PM_IDTR+2]          ; esi points to IDT
  
; save the original handler - not required for int 21h
  mov eax, [esi+21h*8]
  rol eax, 16
  mov ax, [esi+21h*8+6]
  rol eax, 16
  mov [saved_int_21], eax
; option not required
  
  mov WORD [esi+21h*8], int_21 AND 0FFFFh
  mov WORD [esi+21h*8+6], int_21 SHR 16

  mov esi, message
  call print
  xor eax, eax
  int 16h
  int 19h

print:
  mov ah, 2                     ; Write Character To Standard Output
.1:
  mov dl, [esi]
  lea esi, [esi+1]
  test dl, dl
  je .2
  int 21h
  jmp .1
.2:
  ret

message:
  db 'Using int 21h is fun!', 0

int_21:
  pusha
  cmp ah, 2
  jne .1
  mov ah, 0Eh
  xor bh, bh
  mov al, dl
  int 10h
.1:
  popa
; optionally can be simply replace with "iret"
  jmp DWORD [saved_int_21]
saved_int_21: dd 0
; option      
Assemble as kernel.bin, copy to the root directory and boot.

Oh, I'm not making TSR. I'm just setting up IVT's in my new bootloader that copy int 21h.
Post 07 Jan 2011, 22:07
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.