Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted Nanos tarball to prepare for development.
- Loading branch information
Andy Elvey
committed
Mar 23, 2010
1 parent
aa09de2
commit 200ef0e
Showing
106 changed files
with
16,414 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
;============================================ | ||
;Allocation Unit | ||
; | ||
; Written by: Peter Hultqvist | ||
; peter.hultqvist@neocoder.net | ||
; | ||
; Description: | ||
; This is a memory/paging/ioports/anything allocation unit | ||
; | ||
; Allocation is used in blocks | ||
; | ||
;============================================ | ||
|
||
|
||
size equ 2^32 ;Size of entire area | ||
|
||
min_bits equ 12 | ||
max_bits equ 32 | ||
min_size equ 2^min_bits ;Minimum block size | ||
max_size equ 2^max_bits ;Maximum block size | ||
|
||
|
||
|
||
|
||
;Structure: | ||
; 0 4 Start | ||
; 4 4 Size | ||
; 8 4 Next linear pointer | ||
; C 4 Next same size pointer | ||
; 10 4 Prev linear pointer | ||
; 14 4 Prev same size pointer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
; Information | ||
; | ||
; Program Title : NASM-IDE Fire Code Demo | ||
; External name : FIRE.COM | ||
; Version : 1.0 | ||
; Start date : 15/10/1997 | ||
; Last update : 15/10/1997 | ||
; Author : Rob Anderton | ||
; Description : An example of a flickering fire effect programmed using | ||
; NasmEdit 1.0 and NASM 0.98. | ||
; | ||
; Based on code by Denthor of Asphyxia (written using TASM). | ||
|
||
|
||
[BITS 16] ; Set 16 bit code generation | ||
[ORG 0x0100] ; Set code start address to 100h (COM file) | ||
|
||
[SECTION .data] ; Data section (initialised variables) | ||
|
||
FireSeed db $1234 ; Random number seed | ||
|
||
%include "FIREPAL.INC" ; Include 256 colour palette RGB data | ||
|
||
; Text message displayed at the end of the demo | ||
EndMessage db 'Fire demonstration for NASM-IDE 1.1.', 13, 10, '$' | ||
|
||
[SECTION .bss] ; BSS section (unitialised variables) | ||
|
||
FireScreen resb $2300 ; Virtual screen buffer | ||
|
||
|
||
[SECTION .text] ; Text section (the code to be assembled) | ||
|
||
jmp START ; Jump to main code section | ||
|
||
|
||
FIRE_INIT: ; Initialise 320x200 X mode | ||
|
||
mov ax, $0013 ; Set MCGA 320x200x256 mode | ||
int $10 | ||
|
||
mov ax, $0A000 | ||
mov es, ax | ||
xor di, di ; ES:DI points to top left of screen | ||
|
||
cli | ||
cld | ||
mov dx, $03C4 | ||
mov ax, $0604 ; Enter unchained mode | ||
out dx, ax | ||
|
||
mov ax, $0F02 ; Enable all planes | ||
out dx, ax | ||
|
||
xor ax, ax | ||
mov cx, 32767 | ||
rep stosw ; Clear the screen | ||
|
||
mov dx, $03D4 | ||
mov ax, $14 | ||
out dx, ax ; Disable DWORD mode | ||
|
||
mov ax, $0E317 ; Enable byte mode | ||
out dx, ax | ||
out dx, ax | ||
mov ax, $0409 ; Set cell height | ||
out dx, ax | ||
|
||
mov si, FirePal ; DS:SI points to palette data | ||
mov dx, $03C8 ; Palette write register | ||
mov al, 0 ; Start at colour index 0 | ||
out dx, al | ||
inc dx | ||
mov cx, 768 | ||
|
||
.PALLOOP: | ||
|
||
outsb ; Output colour data | ||
dec cx | ||
jnz .PALLOOP | ||
|
||
ret | ||
|
||
;END FIRE_INIT | ||
|
||
|
||
FIRE_RANDOM: ; Generates psuedo-random numbers | ||
|
||
mov ax, [FireSeed] ; Use current seed to generate new number | ||
mov dx, $8405 | ||
mul dx ; Multiply AX by DX, result in DX:AX | ||
inc ax | ||
mov [FireSeed], ax ; Store seed | ||
ret ; Return to calling address | ||
|
||
;END FIRE_RANDOM | ||
|
||
|
||
START: ; Main code section | ||
|
||
call FIRE_INIT ; Initialise screen | ||
|
||
mov WORD [FireSeed], $1234 ; Initialse random number seed | ||
|
||
mov si, FireScreen ; Clear virtual screen buffer | ||
mov cx, $2300 | ||
xor ax, ax | ||
rep stosb | ||
|
||
.MAINLOOP: | ||
|
||
mov si, FireScreen | ||
add si, $2300 | ||
sub si, 80 | ||
mov cx, 80 | ||
xor dx, dx | ||
|
||
.NEWLINE: | ||
|
||
call FIRE_RANDOM | ||
mov [ds:si], dl | ||
inc si | ||
dec cx | ||
jnz .NEWLINE | ||
|
||
mov cx, $2300 | ||
sub cx, 80 | ||
mov si, FireScreen | ||
add si, 80 | ||
|
||
.FIRELOOP: | ||
|
||
xor ax, ax | ||
mov al, [ds:si] | ||
add al, [ds:si + 1] | ||
adc ah, 0 | ||
add al, [ds:si - 1] | ||
adc ah, 0 | ||
add al, [ds:si + 80] | ||
adc ah, 0 | ||
shr ax, 2 | ||
jz .ZERO | ||
dec ax | ||
|
||
.ZERO: | ||
|
||
mov [ds:si - 80], al | ||
inc si | ||
dec cx | ||
jnz .FIRELOOP | ||
|
||
mov dx, $03DA | ||
|
||
.L1: | ||
in al, dx | ||
and al, $08 | ||
jnz .L1 | ||
|
||
.L2: | ||
in al, dx | ||
and al, $08 | ||
jz .L2 | ||
|
||
mov cx, $2300 | ||
shr cx, 1 | ||
mov si, FireScreen | ||
xor di, di | ||
rep movsw | ||
|
||
mov ah, $01 | ||
int $16 ; Check for keypress | ||
jz .MAINLOOP | ||
|
||
mov ah, $00 | ||
int $16 ; Clear input buffer | ||
|
||
mov ax, $0003 ; Set 80x25 text mode | ||
int $10 | ||
|
||
mov dx, EndMessage | ||
mov ah, $09 | ||
int $21 ; Display end message using DOS function call | ||
|
||
mov ax, $4C00 ; This function exits the program | ||
int $21 ; and returns control to DOS. | ||
|
||
;END START |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
; | ||
; | ||
;Nanos System Library | ||
; | ||
; C Library | ||
; | ||
|
||
[BITS 32] | ||
|
||
SECTION .text | ||
|
||
global start | ||
extern _main | ||
start: | ||
;create interfaces | ||
call _main | ||
;end process | ||
jmp $ | ||
|
||
%include '../mem.asm' | ||
|
||
;============================= | ||
; service macro: | ||
; | ||
; service name, number, [parameters...] | ||
;============================= | ||
; orig_ebp ss:ebp | ||
; return_eip ss:ebp + 4 | ||
%define param1 ss:ebp + 8 | ||
%define param2 ss:ebp + 0Ch | ||
%define param3 ss:ebp + 10h | ||
%define param4 ss:ebp + 14h | ||
%define param5 ss:ebp + 18h | ||
%define param6 ss:ebp + 1Ch | ||
|
||
|
||
%macro service 2 | ||
global _%1 | ||
_%1: | ||
mov eax, %2 | ||
call kern_sel:00000000h | ||
ret | ||
%endmacro | ||
|
||
|
||
%macro service 3 ;one parameter | ||
global _%1 | ||
_%1: | ||
push ebp | ||
mov ebp, esp | ||
push %3 | ||
mov %3, [param1] | ||
mov eax, %2 | ||
call kern_sel:00000000h | ||
pop %3 | ||
pop ebp | ||
ret | ||
%endmacro | ||
|
||
%macro service 4 ;two parameters | ||
global _%1 | ||
_%1: | ||
push ebp | ||
mov ebp, esp | ||
push %3 | ||
push %4 | ||
mov %3, [param1] | ||
mov %4, [param2] | ||
mov eax, %2 | ||
call kern_sel:00000000h | ||
pop %4 | ||
pop %3 | ||
pop ebp | ||
ret | ||
%endmacro | ||
|
||
%macro service 5 ;3 parameters | ||
global _%1 | ||
_%1: | ||
push ebp | ||
mov ebp, esp | ||
push %3 | ||
push %4 | ||
push %5 | ||
mov %3, [param1] | ||
mov %4, [param2] | ||
mov %5, [param3] | ||
mov eax, %2 | ||
call kern_sel:00000000h | ||
pop %5 | ||
pop %4 | ||
pop %3 | ||
pop ebp | ||
ret | ||
%endmacro | ||
|
||
%macro service 6 ;4 parameters | ||
global _%1 | ||
_%1: | ||
push ebp | ||
mov ebp, esp | ||
push %3 | ||
push %4 | ||
push %5 | ||
push %6 | ||
mov %3, [param1] | ||
mov %4, [param2] | ||
mov %5, [param3] | ||
mov %6, [param3] | ||
mov eax, %2 | ||
call kern_sel:00000000h | ||
pop %6 | ||
pop %5 | ||
pop %4 | ||
pop %3 | ||
pop ebp | ||
ret | ||
%endmacro | ||
|
||
;============================= | ||
; The functions | ||
;============================= | ||
|
||
|
||
; sys.version ;(eax = Version) == () | ||
service version, 1 | ||
; page.freemem ;(eax Free memory) == () | ||
service memfree, 8 | ||
|
||
; module.create ;(eax Selector) == (ecx LDT Size) | ||
service module_create, 10h, ecx | ||
; module.move ;(eax Selector) == (edx Source selector, ebx Target [module][selector]) | ||
service module_move, 14h, edx, ebx | ||
|
||
service life, 19h | ||
|
||
; desc.create_data (eax = Selector) == (edx [Settings][Selector], ecx Size) | ||
service data_segment, 20h, edx, ecx | ||
; sysm.delete ;(eax = Status) == (edx Selector) | ||
service delete_segment, 27h, edx | ||
|
||
; page.alloc ;() == (edx = [Settings][Selector], ebx = Base, ecx = Size) | ||
service page_alloc, 28h, edx, ebx, ecx | ||
; page.dealloc ;() == (edx = Selector, ebx = Base, ecx = Size) | ||
service page_free, 29h, edx, ebx, ecx | ||
; page.phys_allocate ;() == (edx Selector, ebx Base, edi First PTE, ecx Size) | ||
service map_memory, 2Eh, edx, ebx, edi, ecx | ||
; mult.create ;(eax = Selector) == (edx EIP, ebx ss, ecx ESP) | ||
service new_task, 30h, edx, ebx, ecx | ||
; mult.add ;() == (dx = TSS Selector) | ||
service start_task, 32h, edx | ||
; mult.remove ;(eax Status) == (edx = TSS Selector) | ||
service stop_task, 33h, edx | ||
; interface.create ;(eax = Status) == (edx Type, ebx Process(TSS selector)) | ||
service interface, 38h, edx, ebx |
Oops, something went wrong.