First commit
This commit is contained in:
commit
7d6d50e432
50 changed files with 5737 additions and 0 deletions
BIGMEM.ASMBIGMEM.DRVBOOT12.ASMBOOT12.BINEXCEPT.ASMFAT12D.ASMINTERRPT.ASMKERNEL.ASMKERNEL.BINKEYBOARD.ASMKEYBOARD.drvLOADEXEC.ASMMEMMANAG.ASMPARTCOPY.EXEPROCESSI.ASMREADME.mdREBOOT.ASMREBOOT.BINSHELL.ASMSHELL.BINSYSMEM.ASMTEST.ASMTEST.BINVIDEO.ASMVIDEO.DRVinstall.batreadme.txt
PROGRAMS
ALBLUR
FIRE
ELINK.EXEGRAPH32.ASMGRAPH32.BINMYFIRE.ASMMYFIRE.BINMYFIRE.SYMMYFIRE32.ASMMYFIRE32.BINgraph32.OBJmyfire32.OBJ
SCRSAVER
SHELL
419
BIGMEM.ASM
Normal file
419
BIGMEM.ASM
Normal file
|
@ -0,0 +1,419 @@
|
|||
;NXOS
|
||||
;Written by: Alberto Venturini (Alb‚) - 2001
|
||||
;Email address: -albe-@libero.it
|
||||
|
||||
;Modulo aggiuntivo di gestione della memoria
|
||||
;Questo modulo cambia la modalit… del processore da
|
||||
;Real mode 16-bit a Real mode 32-bit.
|
||||
;In questo modo si ha accesso a taaaanta memoria (64 Mbyte
|
||||
;al massimo...ma direi che sono pi— che sufficienti!)
|
||||
;e si ha comunque compatibilit… con la real mode 16-bit.
|
||||
|
||||
;Questo file va assemblato con tasm32.exe e linkato con un
|
||||
;linker che supporti l'output in flat binary (".bin") (ad
|
||||
;esempio elink.exe).
|
||||
|
||||
StartingOffset equ 120000h ;Offset a partire dal quale Š disponibile
|
||||
;la memoria utente
|
||||
TableOffset equ 110000h ;Offset della tabella per l'allocazione
|
||||
|
||||
.386p
|
||||
|
||||
Code Segment Para Public Use16
|
||||
Assume CS:Code
|
||||
|
||||
org 0h
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Main:
|
||||
;Installazione del driver
|
||||
cli
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,offset Int2fh
|
||||
mov es:[2fh*4],ax
|
||||
mov ax,cs
|
||||
mov es:[2fh*4+2],ax
|
||||
|
||||
call Real32Init
|
||||
|
||||
mov ah,02h
|
||||
mov bl,1
|
||||
int 20h
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Int2fh:
|
||||
cmp ah,00h
|
||||
je Int2fh_00h
|
||||
cmp ah,01h
|
||||
je Int2fh_01h
|
||||
cmp ah,02h
|
||||
je Int2fh_02h
|
||||
cmp ah,03h
|
||||
je Int2fh_03h
|
||||
cmp ah,04h
|
||||
je Int2fh_04h
|
||||
cmp ah,05h
|
||||
je Int2fh_05h
|
||||
iret
|
||||
|
||||
Int2fh_00h:
|
||||
call Real32Init
|
||||
iret
|
||||
Int2fh_01h:
|
||||
call Real32End
|
||||
iret
|
||||
Int2fh_02h:
|
||||
call XMS_Avail
|
||||
iret
|
||||
Int2fh_03h:
|
||||
call MemAlloc32
|
||||
iret
|
||||
Int2fh_04h:
|
||||
call MemoryLeft
|
||||
iret
|
||||
Int2fh_05h:
|
||||
call MemFree32
|
||||
iret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Real32Init:
|
||||
;Inizializza la Real Mode a 32 bit
|
||||
;no Input, no Output
|
||||
pusha
|
||||
|
||||
call Check_Safety ;giusto per sicurezza, anche se non dovrebbero
|
||||
;esserci errori.
|
||||
test ax,ax
|
||||
jnz Real32Init_Error
|
||||
|
||||
call Enable_A20 ;Inizializza la 32bit real mode
|
||||
call Pmode
|
||||
|
||||
call XMS_Avail ;Calcola la memoria totale
|
||||
cmp ax,128
|
||||
jbe Real32Init_Error
|
||||
|
||||
mov word ptr cs:[TotalMemory],ax ;Mettiamo la memoria totale in
|
||||
;questa variabile
|
||||
|
||||
Real32Init_PrepareTable:
|
||||
mov cx,ax ;In AX ho il numero totale di Kbytes presenti.
|
||||
;Inizializza il valore corrispondente a questi
|
||||
;Kbytes a zero.
|
||||
sub cx,64 ;Toglie 64 (perchŠ Š primi 64 kbytes sono occupati
|
||||
;dalla tabella di allocazione della memoria).
|
||||
mov ax,0
|
||||
mov es,ax
|
||||
mov edi,TableOffset
|
||||
|
||||
Real32Init_Table2:
|
||||
;Azzera tutte le posizioni nella tabella di allocazione della memoria
|
||||
mov es:[edi],al ;Nota: non funziona il "tradizionale" stosb...
|
||||
inc edi
|
||||
loop Real32Init_Table2
|
||||
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
Real32Init_Error:
|
||||
|
||||
call Disable_A20
|
||||
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Real32End:
|
||||
;Termina la Real Mode a 32 bit
|
||||
push ax
|
||||
call Disable_A20
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
MemAlloc32:
|
||||
;Input DX=numero di Kbytes da allocare
|
||||
;Output EDI=offset a partire dal quale Š disponibile la memoria
|
||||
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push es
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov edi,TableOffset ;edi punta alla tabella di allocazione memoria
|
||||
|
||||
MemAlloc32_CheckSingle:
|
||||
;Esegue questo ciclo finchŠ non trova un valore uguale a 0 (cioŠ un Kbyte
|
||||
;libero).
|
||||
mov al,es:[edi]
|
||||
inc edi
|
||||
cmp di,cs:[TotalMemory]
|
||||
jae MemAlloc32_MemoryNotFound
|
||||
test al,al
|
||||
jnz MemAlloc32_CheckSingle
|
||||
|
||||
MemAlloc32_CheckTotal:
|
||||
mov cx,dx
|
||||
dec cx
|
||||
|
||||
MemAlloc32_CheckTotal2:
|
||||
;Controlla se ci sono abbastanza Kbytes contigui liberi
|
||||
test cx,cx
|
||||
jz MemAlloc32_MemoryFound
|
||||
mov al,es:[edi]
|
||||
inc edi
|
||||
cmp di,cs:[TotalMemory]
|
||||
jae MemAlloc32_MemoryNotFound
|
||||
dec cx
|
||||
test al,al
|
||||
jz MemAlloc32_CheckTotal2
|
||||
|
||||
jmp MemAlloc32_CheckSingle
|
||||
|
||||
MemAlloc32_MemoryFound:
|
||||
sub di,dx
|
||||
mov al,1
|
||||
|
||||
push edi
|
||||
|
||||
MemAlloc32_MemoryFound2:
|
||||
;Occupa la memoria!
|
||||
mov es:[edi],al
|
||||
inc edi
|
||||
dec dx
|
||||
jnz MemAlloc32_MemoryFound2
|
||||
|
||||
pop edi
|
||||
|
||||
;Conversione di EDI: da indice nella tabella di allocazione a offset
|
||||
and edi,0000FFFFh
|
||||
|
||||
shl edi,10 ;converte il risultato in Kbytes
|
||||
|
||||
add edi,StartingOffset
|
||||
|
||||
pop es
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
MemAlloc32_MemoryNotFound:
|
||||
;[...]
|
||||
|
||||
pop es
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
MemoryLeft:
|
||||
;questa procedura ritorna la memoria libera disponibile.
|
||||
;CX=numero di Kbytes *contigui* liberi
|
||||
;DX=numero di Kbytes *totali* liberi
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push es
|
||||
push edi
|
||||
|
||||
mov edi,TableOffset
|
||||
xor ax,ax
|
||||
mov dx,ax
|
||||
mov bx,ax
|
||||
mov es,ax
|
||||
|
||||
MemoryLeft_1:
|
||||
mov al,es:[edi]
|
||||
inc edi
|
||||
cmp di,cs:[TotalMemory]
|
||||
je MemoryLeft_End
|
||||
test al,al
|
||||
jnz MemoryLeft_1
|
||||
|
||||
inc dx
|
||||
mov cx,1
|
||||
|
||||
MemoryLeft_2:
|
||||
mov al,es:[edi]
|
||||
inc edi
|
||||
cmp di,cs:[TotalMemory]
|
||||
je MemoryLeft_End2
|
||||
test al,al
|
||||
jnz MemoryLeft_3
|
||||
inc cx
|
||||
inc dx
|
||||
jmp MemoryLeft_2
|
||||
|
||||
MemoryLeft_3:
|
||||
cmp cx,bx
|
||||
jbe MemoryLeft_1
|
||||
mov bx,cx
|
||||
jmp MemoryLeft_1
|
||||
|
||||
MemoryLeft_End2:
|
||||
cmp cx,bx
|
||||
jbe MemoryLeft_End
|
||||
mov bx,cx
|
||||
|
||||
MemoryLeft_End:
|
||||
pop edi
|
||||
pop es
|
||||
pop bx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
MemFree32:
|
||||
;input EDI=offset a partire dal quale va liberata la memoria
|
||||
;DX=numero di Kbytes da liberare
|
||||
|
||||
push ax
|
||||
push dx
|
||||
push es
|
||||
push edi
|
||||
|
||||
sub edi,StartingOffset
|
||||
shr edi,10
|
||||
|
||||
add edi,TableOffset
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
|
||||
MemFree32_1:
|
||||
mov es:[edi],al
|
||||
inc edi
|
||||
dec dx
|
||||
jnz MemFree32_1
|
||||
|
||||
pop edi
|
||||
pop es
|
||||
pop dx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;Il codice sotto l'ho preso da un file di Alexei A. Frounze
|
||||
;Il file originale si chiama "4gb.zip" ed Š scaricabile dal
|
||||
;sito dell'autore: http://www.chat.ru/~alexfru
|
||||
|
||||
;--------------------------- A20 line switching ----------------------------
|
||||
|
||||
Enable_A20:
|
||||
Mov AL, 0D1h
|
||||
Out 64h, AL
|
||||
Mov AL, 0DFh
|
||||
Out 60h, AL
|
||||
Ret
|
||||
|
||||
Disable_A20:
|
||||
Mov AL, 0D1h
|
||||
Out 64h, AL
|
||||
Mov AL, 0DDh
|
||||
Out 60h, AL
|
||||
Ret
|
||||
|
||||
;----------- Checking processor mode and looking for Himem.sys -------------
|
||||
|
||||
Check_Safety:
|
||||
SMSW CS:XXX
|
||||
Mov AX, CS:XXX
|
||||
And AX, 1
|
||||
JNZ @@CSQ ; 1 - Processor is in Protected Mode
|
||||
@@CSQ:
|
||||
Ret
|
||||
XXX DW ?
|
||||
|
||||
;------------------------- Getting XMS ammount -----------------------------
|
||||
|
||||
Read_CMOS:
|
||||
Out 70h, AL ; CMOS address should be stored in the AL register
|
||||
Jmp @@RCW ; Little delay
|
||||
@@RCW:
|
||||
In AL, 71h ; AL = value
|
||||
Ret
|
||||
|
||||
|
||||
XMS_Avail:
|
||||
;Output AX=memoria disponibile (con un massimo di circa 64Mb,
|
||||
;perchŠ Š una word...)
|
||||
;Questa funzione restituisce la memoria XMS disponibile.
|
||||
|
||||
Mov AL, 31h ; 31h = hi byte address
|
||||
Call Read_CMOS
|
||||
Mov AH, AL
|
||||
Mov AL, 30h ; 30h = low byte address
|
||||
Call Read_CMOS ; AX = XMS installed above 1MB (in Kilobytes)
|
||||
sub ax,128 ;toglie 128 perchŠ la memoria disponibile inizia da 120000h
|
||||
ret
|
||||
|
||||
;-------- Protected mode intialization and creation of 4GB segment ---------
|
||||
|
||||
PMode:
|
||||
Xor EAX, EAX
|
||||
Mov AX, CS
|
||||
Shl EAX, 4
|
||||
LEA EDX, GDT
|
||||
Add EAX, EDX
|
||||
Mov DWord Ptr CS:GDTR+2, EAX; Fill in GDTR with physical address
|
||||
; of Global Descriptor Table
|
||||
Push DS
|
||||
CLI
|
||||
LGDT FWord Ptr CS:GDTR ; Load Global Descriptor Table
|
||||
Mov EAX, 1
|
||||
Mov CR0, EAX ; Set Protected Mode
|
||||
Mov AX, 8
|
||||
Mov DS, AX
|
||||
Mov ES, AX
|
||||
Mov FS, AX
|
||||
Mov GS, AX ; All segment registers are loaded
|
||||
; with 4GB segment's selector
|
||||
Xor EAX, EAX
|
||||
Mov CR0, EAX ; Set Real Mode
|
||||
STI
|
||||
Pop DS
|
||||
|
||||
;----------------------------------------------------------;
|
||||
; Now you can access all the memory by putting zero to a ;
|
||||
; segment register and 32bit physical address to an index ;
|
||||
; register. ;
|
||||
; -= Simple example =- ;
|
||||
; Xor AX, AX ;
|
||||
; Mov ES, AX ; zero the ES register ;
|
||||
; Mov EDI, 1024*1024+65536 ; 1st byte we can use freely ;
|
||||
; Mov BL, Byte Ptr ES:[EDI] ; read byte ;
|
||||
; Mov DWord Ptr ES:[EDI], EDX ; write dword ;
|
||||
;----------------------------------------------------------;
|
||||
|
||||
Ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GDT DQ 0, 8F92000000FFFFh ; "0" & "4GB" Descriptors
|
||||
GDTR DW 16, 0, 0
|
||||
|
||||
TotalMemory dw ?
|
||||
Errormsg db 'An error occurred while switching to 32-bit real mode',13,10,0
|
||||
|
||||
Code EndS
|
||||
|
||||
End
|
BIN
BIGMEM.DRV
Normal file
BIN
BIGMEM.DRV
Normal file
Binary file not shown.
392
BOOT12.ASM
Normal file
392
BOOT12.ASM
Normal file
|
@ -0,0 +1,392 @@
|
|||
; boot12.asm FAT12 bootstrap for real mode image or loader
|
||||
; Version 1.0, Jul 5, 1999
|
||||
; Sample code
|
||||
; by John S. Fine johnfine@erols.com
|
||||
; I do not place any restrictions on your use of this source code
|
||||
; I do not provide any warranty of the correctness of this source code
|
||||
;_____________________________________________________________________________
|
||||
;
|
||||
; Documentation:
|
||||
;
|
||||
; I) BASIC features
|
||||
; II) Compiling and installing
|
||||
; III) Detailed features and limits
|
||||
; IV) Customization
|
||||
;_____________________________________________________________________________
|
||||
;
|
||||
; I) BASIC features
|
||||
;
|
||||
; This boot sector will load and start a real mode image from a file in the
|
||||
; root directory of a FAT12 formatted floppy or partition.
|
||||
;
|
||||
; Inputs:
|
||||
; DL = drive number
|
||||
;
|
||||
; Outputs:
|
||||
; The boot record is left in memory at 7C00 and the drive number is patched
|
||||
; into the boot record at 7C24.
|
||||
; SS = DS = 0
|
||||
; BP = 7C00
|
||||
;_____________________________________________________________________________
|
||||
;
|
||||
; II) Compiling and installing
|
||||
;
|
||||
; To compile, use NASM
|
||||
;
|
||||
; nasm boot12.asm -o boot12.bin
|
||||
;
|
||||
; Then you must copy the first three bytes of BOOT12.BIN to the first three
|
||||
; bytes of the volume and copy bytes 0x3E through 0x1FF of BOOT12.BIN to
|
||||
; bytes 0x3E through 0x1FF of the volume. Bytes 0x3 through 0x3D of the
|
||||
; volume should be set by a FAT12 format program and should not be modified
|
||||
; when copying boot12.bin to the volume.
|
||||
;
|
||||
; If you use my PARTCOPY program to install BOOT12.BIN on A:, the
|
||||
; commands are:
|
||||
;
|
||||
; partcopy boot12.bin 0 3 -f0
|
||||
; partcopy boot12.bin 3e 1c2 -f0 3e
|
||||
;
|
||||
; PARTCOPY can also install to a partition on a hard drive. Please read
|
||||
; partcopy documentation and use it carefully. Careless use could overwrite
|
||||
; important parts of your hard drive.
|
||||
;
|
||||
; You can find PARTCOPY and links to NASM on my web page at
|
||||
; http://www.erols.com/johnfine/
|
||||
;_____________________________________________________________________________
|
||||
;
|
||||
; III) Detailed features and limits
|
||||
;
|
||||
; Most of the limits are stable characteristics of the volume. If you are
|
||||
; using boot12 in a personal project, you should check the limits before
|
||||
; installing boot12. If you are using boot12 in a project for general
|
||||
; distribution, you should include an installation program which checks the
|
||||
; limits automatically.
|
||||
;
|
||||
; CPU: Supports any 8088+ CPU.
|
||||
;
|
||||
; Volume format: Supports only FAT12.
|
||||
;
|
||||
; Sector size: Supports only 512 bytes per sector.
|
||||
;
|
||||
; Drive/Partition: Supports whole drive or any partition of any drive number
|
||||
; supported by INT 13h.
|
||||
;
|
||||
; Diskette parameter table: This code does not patch the diskette parameter
|
||||
; table. If you boot this code from a diskette that has more sectors per
|
||||
; track than the default initialized by the BIOS then the failure to patch
|
||||
; that table may be a problem. Because this code splits at track boundaries
|
||||
; a diskette with fewer sectors per track should not be a problem.
|
||||
;
|
||||
; File position: The file name may be anywhere in the root directory and the
|
||||
; file may be any collection of clusters on the volume. There are no
|
||||
; contiguity requirements. (But see track limit).
|
||||
;
|
||||
; Track boundaries: Transfers are split on track boundaries. Many BIOS's
|
||||
; require that the caller split floppy transfers on track boundaries.
|
||||
;
|
||||
; 64Kb boundaries: Transfers are split on 64Kb boundaries. Many BIOS's
|
||||
; require that the caller split floppy transfers on track boundaries.
|
||||
;
|
||||
; Cluster boundaries: Transfers are merged across cluster boundaries whenever
|
||||
; possible. On some systems, this significantly reduces load time.
|
||||
;
|
||||
; Cluster 2 limit: Cluster 2 must start before sector 65536 of the volume.
|
||||
; This is very likely because only the reserved sectors (usually 1) and
|
||||
; the FAT's (two of up to 12 sectors each) and the root directory (usually
|
||||
; either 15 or 32 sectors) precede cluster 2.
|
||||
;
|
||||
; Track limit: The entire image file must reside before track 32768 of the
|
||||
; entire volume. This is true on most media up to 1GB in size. If it is a
|
||||
; problem it is easy to fix (see boot16.asm). I didn't expect many people
|
||||
; to put FAT12 partitions beyond the first GB of a large hard drive.
|
||||
;
|
||||
; Memory boundaries: The FAT, Root directory, and Image must all be loaded
|
||||
; starting at addresses that are multiples of 512 bytes (32 paragraphs).
|
||||
;
|
||||
; Memory use: The FAT and Root directory must each fit entirely in the
|
||||
; first 64Kb of RAM. They may overlap.
|
||||
;
|
||||
; Root directory size: As released, it supports up to 928 entries in the
|
||||
; root directory. If ROOT_SEG were changed to 0x7E0 it would support up
|
||||
; to 1040. Most FAT12 volumes have either 240 or 512 root directory
|
||||
; entries.
|
||||
;_____________________________________________________________________________
|
||||
;
|
||||
; IV) Customization
|
||||
;
|
||||
; The memory usage can be customized by changing the _SEG variables (see
|
||||
; directly below).
|
||||
;
|
||||
; The file name to be loaded and the message displayed in case of error
|
||||
; may be customized (see end of this file).
|
||||
;
|
||||
; The ouput values may be customized. For example, many loaders expect the
|
||||
; bootsector to leave the drive number in DL. You could add "mov dl,[drive]"
|
||||
; at the label "eof:".
|
||||
;
|
||||
; Some limits (like maximum track) may be removed. See boot16.asm for
|
||||
; comparison.
|
||||
;
|
||||
; Change whatever else you like. The above are just likely possibilities.
|
||||
;_____________________________________________________________________________
|
||||
|
||||
|
||||
; Change the _SEG values to customize memory use during the boot.
|
||||
; When planning memory use, remember:
|
||||
;
|
||||
; *) Each of ROOT_SEG, FAT_SEG, and IMAGE_SEG must be divisible by 0x20
|
||||
;
|
||||
; *) None of ROOT, FAT or IMAGE should overlap the boot code itself, or
|
||||
; its stack. That means: avoid paragraphs 0x7B0 to 0x7DF.
|
||||
;
|
||||
; *) The FAT area must not overlap the IMAGE area. Either may overlap
|
||||
; the ROOT area; But, if they do then the root will not remain in
|
||||
; memory for possible reuse by the next stage.
|
||||
;
|
||||
; *) The FAT area and the root area must each fit within the first 64Kb
|
||||
; excluding BIOS area (paragraphs 0x60 to 0xFFF).
|
||||
;
|
||||
; *) A FAT12 FAT can be up to 6Kb (0x180 paragraphs).
|
||||
;
|
||||
; *) A FAT12 root directory is typically either 0x1E0 or 0x400 paragraphs
|
||||
; long, but larger sizes are possible.
|
||||
;
|
||||
; *) The code will be two bytes shorter when FAT_SEG is 0x800 than when it
|
||||
; is another value. (If you reach the point of caring about two bytes).
|
||||
;
|
||||
%define ROOT_SEG 0x60
|
||||
%define FAT_SEG 0x800
|
||||
%define IMAGE_SEG 0x1000
|
||||
|
||||
%if ROOT_SEG & 31
|
||||
%error "ROOT_SEG must be divisible by 0x20"
|
||||
%endif
|
||||
%if ROOT_SEG > 0xC00
|
||||
%error "Root directory must fit within first 64Kb"
|
||||
%endif
|
||||
%if FAT_SEG & 31
|
||||
%error "FAT_SEG must be divisible by 0x20"
|
||||
%endif
|
||||
%if FAT_SEG > 0xE80
|
||||
%error "FAT must fit within first 64Kb"
|
||||
%endif
|
||||
%if IMAGE_SEG & 31
|
||||
%error "IMAGE_SEG must be divisible by 0x20"
|
||||
%endif
|
||||
|
||||
; The following %define directives declare the parts of the FAT12 "DOS BOOT
|
||||
; RECORD" that are used by this code, based on BP being set to 7C00.
|
||||
;
|
||||
%define sc_p_clu bp+0Dh ;byte Sectors per cluster
|
||||
%define sc_b4_fat bp+0Eh ;word Sectors (in partition) before FAT
|
||||
%define fats bp+10h ;byte Number of FATs
|
||||
%define dir_ent bp+11h ;word Number of root directory entries
|
||||
%define sc_p_fat bp+16h ;word Sectors per FAT
|
||||
%define sc_p_trk bp+18h ;word Sectors per track
|
||||
%define heads bp+1Ah ;word Number of heads
|
||||
%define sc_b4_prt bp+1Ch ;dword Sectors before partition
|
||||
%define drive bp+24h ;byte Drive number
|
||||
|
||||
org 0x7C00
|
||||
|
||||
entry:
|
||||
jmp short begin
|
||||
nop
|
||||
|
||||
; Skip over the data portion of the "DOS BOOT RECORD". The install method
|
||||
; must merge the code from this ASM with the data put in the boot record
|
||||
; by the FAT12 formatter.
|
||||
;
|
||||
times 0x3B db 0
|
||||
|
||||
begin:
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
mov ss, ax
|
||||
mov sp, 0x7C00
|
||||
mov bp, sp
|
||||
mov [drive], dl ;Drive number
|
||||
|
||||
mov al, [fats] ;Number of FATs
|
||||
mul word [sc_p_fat] ; * Sectors per FAT
|
||||
add ax, [sc_b4_fat] ; + Sectors before FAT
|
||||
;AX = Sector of Root directory
|
||||
|
||||
mov si, [dir_ent] ;Max root directory entries
|
||||
mov cl, 4
|
||||
dec si
|
||||
shr si, cl
|
||||
inc si ;SI = Length of root in sectors
|
||||
|
||||
mov di, ROOT_SEG/32 ;Buffer (paragraph / 32)
|
||||
call read_16 ;Read root directory
|
||||
push ax ;Sector of cluster two
|
||||
%define sc_clu2 bp-2 ;Later access to the word just pushed is via bp
|
||||
|
||||
mov dx, [dir_ent] ;Number of directory entries
|
||||
push ds
|
||||
pop es
|
||||
mov di, ROOT_SEG*16
|
||||
|
||||
search:
|
||||
dec dx ;Any more directory entries?
|
||||
js error ;No
|
||||
mov si, filename ;Name we are searching for
|
||||
mov cx, 11 ;11 characters long
|
||||
lea ax, [di+0x20] ;Precompute next entry address
|
||||
push ax
|
||||
repe cmpsb ;Compare
|
||||
pop di
|
||||
jnz search ;Repeat until match
|
||||
|
||||
push word [di-6] ;Starting cluster number
|
||||
|
||||
mov ax, [sc_b4_fat] ;Sector number of FAT
|
||||
mov si, [sc_p_fat] ;Length of FAT
|
||||
mov di, FAT_SEG/32 ;Buffer (paragraph / 32)
|
||||
call read_16 ;Read FAT
|
||||
|
||||
next:
|
||||
pop bx ;Cluster number
|
||||
mov si, bx ;First cluster in this sequence
|
||||
mov ax, bx ;Last cluster in this sequence
|
||||
|
||||
.0:
|
||||
cmp bx, 0xFF8 ;End of file?
|
||||
jae .2 ; Yes
|
||||
inc ax ;Last cluster plus one in sequence
|
||||
|
||||
;Look in FAT for next cluster
|
||||
mov di, bx ;Cluster number
|
||||
rcr bx, 1 ;1.5 byte entry per cluster
|
||||
;bx = 0x8000 + cluster/2
|
||||
;c-bit set for odd clusters
|
||||
|
||||
mov bx, [bx+di+FAT_SEG*16-0x8000]
|
||||
jnc .1
|
||||
shr bx, 1
|
||||
shr bx, 1
|
||||
shr bx, 1
|
||||
shr bx, 1
|
||||
.1: and bh, 0xF
|
||||
|
||||
cmp ax, bx ;Is the next one contiguous?
|
||||
je .0 ;Yes: look further ahead
|
||||
.2: sub ax, si ;How many contiguous in this sequence?
|
||||
jz eof ;None, must be done.
|
||||
|
||||
push bx ;Save next (eof or discontiguous) cluster
|
||||
|
||||
mov bl, [sc_p_clu] ;Sectors per cluster
|
||||
mov bh, 0 ; as a word
|
||||
mul bx ;Length of sequence in sectors
|
||||
.3: mov di, IMAGE_SEG/32 ;Destination (paragraph / 32)
|
||||
add [.3+1], ax ;Precompute next destination
|
||||
xchg ax, si ;AX = starting cluster ;SI = length in sectors
|
||||
dec ax
|
||||
dec ax ;Starting cluster minus two
|
||||
mul bx ; * sectors per cluster
|
||||
add ax, [sc_clu2] ; + sector number of cluster two
|
||||
adc dl, dh ;Allow 24-bit result
|
||||
|
||||
call read_32 ;Read it
|
||||
jmp short next ;Look for more
|
||||
|
||||
eof:
|
||||
jmp IMAGE_SEG:0
|
||||
|
||||
error: mov si, errmsg ;Same message for all detected errors
|
||||
mov ax, 0xE0D ;Start message with CR
|
||||
mov bx, 7
|
||||
.1: int 10h
|
||||
lodsb
|
||||
test al, al
|
||||
jnz .1
|
||||
xor ah, ah
|
||||
int 16h ;Wait for a key
|
||||
int 19h ;Try to reboot
|
||||
|
||||
read_16:
|
||||
xor dx, dx
|
||||
|
||||
read_32:
|
||||
;
|
||||
; Input:
|
||||
; dx:ax = sector within partition
|
||||
; si = sector count
|
||||
; di = destination segment / 32
|
||||
;
|
||||
; The sector number is converted from a partition-relative to a whole-disk
|
||||
; (LBN) value, and then converted to CHS form, and then the sectors are read
|
||||
; into (di*32):0.
|
||||
;
|
||||
; Output:
|
||||
; dx:ax updated (sector count added)
|
||||
; di updated (sector count added)
|
||||
; si = 0
|
||||
; bp, ds preserved
|
||||
; bx, cx, es modified
|
||||
|
||||
.1: push dx ;(high) relative sector
|
||||
push ax ;(low) relative sector
|
||||
|
||||
add ax, [sc_b4_prt] ;Convert to LBN
|
||||
adc dx, [sc_b4_prt+2]
|
||||
|
||||
mov bx, [sc_p_trk] ;Sectors per track
|
||||
div bx ;AX = track ;DX = sector-1
|
||||
sub bx, dx ;Sectors remaining, this track
|
||||
cmp bx, si ;More than we want?
|
||||
jbe .2 ;No
|
||||
mov bx, si ;Yes: Transfer just what we want
|
||||
.2: inc dx ;Sector number
|
||||
mov cx, dx ;CL = sector ;CH = 0
|
||||
cwd ;(This supports up to 32767 tracks
|
||||
div word [heads] ;Track number / Number of heads
|
||||
mov dh, dl ;DH = head
|
||||
|
||||
xchg ch, al ;CH = (low) cylinder ;AL=0
|
||||
ror ah, 1 ;rotate (high) cylinder
|
||||
ror ah, 1
|
||||
add cl, ah ;CL = combine: sector, (high) cylinder
|
||||
|
||||
sub ax, di
|
||||
and ax, byte 0x7F ;AX = sectors to next 64Kb boundary
|
||||
jz .3 ;On a 64Kb boundary already
|
||||
cmp ax, bx ;More than we want?
|
||||
jbe .4 ;No
|
||||
.3: xchg ax, bx ;Yes: Transfer just what we want
|
||||
.4: push ax ;Save length
|
||||
mov bx, di ;Compute destination seg
|
||||
push cx
|
||||
mov cl, 5
|
||||
shl bx, cl
|
||||
pop cx
|
||||
mov es, bx
|
||||
xor bx, bx ;ES:BX = address
|
||||
mov dl, [drive] ;DL = Drive number
|
||||
mov ah, 2 ;AH = Read command
|
||||
int 13h ;Do it
|
||||
jc error
|
||||
pop bx ;Length
|
||||
pop ax ;(low) relative sector
|
||||
pop dx ;(high) relative sector
|
||||
add ax, bx ;Update relative sector
|
||||
adc dl, dh
|
||||
add di, bx ;Update destination
|
||||
sub si, bx ;Update count
|
||||
jnz .1 ;Read some more
|
||||
ret
|
||||
|
||||
errmsg db 10,"Error Executing FAT12 bootsector",13
|
||||
db 10,"Press any key to reboot",13,10,0
|
||||
|
||||
size equ $ - entry
|
||||
%if size+11+2 > 512
|
||||
%error "code is too large for boot sector"
|
||||
%endif
|
||||
times (512 - size - 11 - 2) db 0
|
||||
|
||||
filename db "LOADER BIN" ;11 byte name
|
||||
db 0x55, 0xAA ;2 byte boot signature
|
BIN
BOOT12.BIN
Normal file
BIN
BOOT12.BIN
Normal file
Binary file not shown.
117
EXCEPT.ASM
Normal file
117
EXCEPT.ASM
Normal file
|
@ -0,0 +1,117 @@
|
|||
;NXOS
|
||||
;--------
|
||||
;Written by: Alberto Venturini (Alb‚) - 2001
|
||||
;Email address: -albe-@libero.it
|
||||
;
|
||||
;NXOS exception handlers
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
InstallExceptionHandlers:
|
||||
push ax
|
||||
push es
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,offset Int00h
|
||||
mov word ptr es:[0000h],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[0000h+2],ax
|
||||
|
||||
mov ax,offset Int06h
|
||||
mov word ptr es:[0006h*4],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[0006h*4+2],ax
|
||||
|
||||
mov ax,offset Int07h
|
||||
mov word ptr es:[0007h*4],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[0007h*4+2],ax
|
||||
|
||||
pop es
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
Int00h:
|
||||
;L'interrupt 00h Š invocato quando si verifica una divisione per 0
|
||||
;(quando il divisore di DIV o IDIV Š 0)
|
||||
;Questa routine termina il processo che ha provocato l'errore.
|
||||
|
||||
cli
|
||||
|
||||
push cs
|
||||
pop ds
|
||||
|
||||
mov si,offset Int00hMsg
|
||||
jmp TerminateProcess
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
Int06h:
|
||||
;L'int 06h si verifica quando c'Š un'istruzione non valida.
|
||||
;Termina il processo che ha provocato l'errore
|
||||
|
||||
cli
|
||||
|
||||
push cs
|
||||
pop ds
|
||||
|
||||
mov si,offset Int06hMsg
|
||||
jmp TerminateProcess
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
Int07h:
|
||||
;L'int 07h viene generato quando c'Š un'istruzione di un coprocessore
|
||||
;che per• non Š presente.
|
||||
;Termina il processo che ha provocato l'errore.
|
||||
|
||||
cli
|
||||
|
||||
push cs
|
||||
pop ds
|
||||
|
||||
mov si,offset Int07hMsg
|
||||
jmp TerminateProcess
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
TerminateProcess:
|
||||
;input SI --> offset del messaggio di errore da visualizzare
|
||||
|
||||
push si
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
mov ah,04h
|
||||
int 24h
|
||||
|
||||
mov si,offset GeneralErrorMsg
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
pop si
|
||||
int 24h
|
||||
|
||||
mov si,offset TerminateProcessMsg
|
||||
int 24h
|
||||
|
||||
mov ah,00h
|
||||
int 25h
|
||||
|
||||
mov ah,02h
|
||||
mov bl,0
|
||||
int 20h
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
GeneralErrorMsg db 13,10,'Fatal error:',0
|
||||
Int00hMsg db ' division by zero (int 00h).',13,10,0
|
||||
Int06hMsg db ' invalid opcode (int 06h).',13,10,0
|
||||
Int07hMsg db ' processor extension not avaliable (int 07h).',13,10,0
|
||||
TerminateProcessMsg db 'The process will be terminated.',13,10,0
|
671
FAT12D.ASM
Normal file
671
FAT12D.ASM
Normal file
|
@ -0,0 +1,671 @@
|
|||
;NXOS
|
||||
;Written by: Alberto Venturini (Alb‚) - 2001
|
||||
;Email address: -albe-@libero.it
|
||||
|
||||
;Questo codice funziona ma Š abbastanza "bad coded" (vedi Fat12_FileSearch)...
|
||||
;Appena ho tempo lo devo riscrivere.
|
||||
|
||||
|
||||
;Procedure "pubbliche":
|
||||
;
|
||||
;1) Fat12_FatInit
|
||||
; (no input, no output)
|
||||
;
|
||||
;2) Fat12_OpenFile
|
||||
; Input: DS:SI punta al nome del file da aprire
|
||||
; Output: SI Š il file handler.
|
||||
;
|
||||
;3) Fat12_CloseFile
|
||||
; Input: SI file handler
|
||||
;
|
||||
;4) Fat12_ReadFile
|
||||
; Input DX: numero di bytes da leggere
|
||||
; SI: file handler
|
||||
; ES:DI buffer in cui memorizzare il file
|
||||
;5) Fat12_ChDir
|
||||
; Input DS:SI punta al nome della directory
|
||||
|
||||
|
||||
|
||||
|
||||
Fat12_MaxFiles equ 5
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_DriveParams:
|
||||
;chiama l'int 13h per sapere i parametri del drive 00h (il primo floppy drive)
|
||||
;memorizza il numero di heads, sectors e cylinders del drive.
|
||||
;Input: no inputs. Output: no outputs.
|
||||
;Modifica AX,CX,DX
|
||||
mov ah,08h
|
||||
xor dx,dx
|
||||
int 13h
|
||||
mov al,dh
|
||||
xor ah,ah
|
||||
inc ax
|
||||
mov cs:[Fat12_Heads],ax
|
||||
mov al,cl
|
||||
and ax,3fh
|
||||
mov cs:[Fat12_Sectors],ax
|
||||
mov al,ch
|
||||
mov ah,cl
|
||||
mov cl,6
|
||||
shr ah,cl
|
||||
inc ax
|
||||
mov cs:[Fat12_Cylinders],ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_FatInit:
|
||||
;inizializza le variabili che serviranno per la lettura dei file con la FAT12
|
||||
;Questa procedura Š da chiamare prima di eseguire qualsiasi operazione con i
|
||||
;file.
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push es
|
||||
|
||||
call Fat12_DriveParams
|
||||
mov ax,0800h
|
||||
mov cs:[Fat12_FatSegment],ax
|
||||
|
||||
push si
|
||||
xor si,si
|
||||
xor ax,ax
|
||||
Fat12_FatInit_ClearFile:
|
||||
mov word ptr cs:[Fat12_FileSector+si],ax
|
||||
add si,2
|
||||
cmp si,(Fat12_MaxFiles*2)
|
||||
jb Fat12_FatInit_ClearFile
|
||||
pop si
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,word ptr es:[7c00h+0eh] ;reserved sectors (logical sector in cui inizia la fat)
|
||||
mov cs:[Fat12_FatStart],ax
|
||||
mov ax,word ptr es:[7c00h+16h] ;sectors per fat
|
||||
mov cs:[Fat12_SectorsPerFat],ax
|
||||
push ax
|
||||
mov al,byte ptr es:[7c00h+10h] ;number of fats
|
||||
mov cs:[Fat12_NumberOfFats],al
|
||||
cbw
|
||||
mov cx,ax
|
||||
pop ax
|
||||
mul cx
|
||||
add ax,cs:[Fat12_FatStart]
|
||||
mov cs:[Fat12_RootStart],ax
|
||||
mov cs:[Fat12_CurrentDir],ax
|
||||
|
||||
mov ax,word ptr es:[7c00h+11h] ;root directory entries
|
||||
mov cs:[Fat12_RootEntries],ax
|
||||
mov ax,cs:[Fat12_SectorsPerFat]
|
||||
xor cx,cx
|
||||
mov cl,cs:[Fat12_NumberOfFats]
|
||||
mul cx ;AX=total fat sectors
|
||||
mov bx,ax
|
||||
mov ax,cs:[Fat12_RootEntries]
|
||||
mov cl,4
|
||||
shr ax,cl
|
||||
mov cs:[Fat12_RootSectors],ax
|
||||
mov cs:[Fat12_CurrentDirSize],ax
|
||||
add ax,bx
|
||||
add ax,cs:[Fat12_FatStart]
|
||||
mov cs:[Fat12_DataArea],ax
|
||||
|
||||
pop es
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_ReadSector:
|
||||
;this translates the logical sector value in AX, in CHS value
|
||||
;logical sector in DX:AX (or simply in AX); then read the sector in ES:BX
|
||||
;input:
|
||||
;DX:AX=logical sector
|
||||
;ES:BX=buffer
|
||||
;CL=number of sectors to read
|
||||
;Modifica AX,BX,CX,DX,SI
|
||||
push bx
|
||||
push cx
|
||||
mov bx,ax
|
||||
mov ax,dx
|
||||
xor dx,dx
|
||||
div cs:[Fat12_Sectors]
|
||||
mov cx,ax
|
||||
mov ax,bx
|
||||
div cs:[Fat12_Sectors]
|
||||
inc dx
|
||||
xchg cx,dx
|
||||
div cs:[Fat12_Heads]
|
||||
mov ch,al
|
||||
ror ah,1
|
||||
ror ah,1
|
||||
or cl,ah
|
||||
mov dh,dl
|
||||
mov dl,00h
|
||||
pop si
|
||||
pop bx
|
||||
mov ax,si
|
||||
mov ah,02h
|
||||
int 13h
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_WriteSector:
|
||||
;this translates the logical sector value in AX, in CHS value
|
||||
;logical sector in DX:AX (or simply in AX); then writes the sector from ES:BX
|
||||
;input:
|
||||
;DX:AX=logical sector to write
|
||||
;ES:BX=data buffer
|
||||
;CL=number of sectors to write
|
||||
|
||||
; push bx
|
||||
; push cx
|
||||
; mov bx,ax
|
||||
; mov ax,dx
|
||||
; xor dx,dx
|
||||
; div [Fat12_Sectors]
|
||||
; mov cx,ax
|
||||
; mov ax,bx
|
||||
; div [Fat12_sectors]
|
||||
; inc dx
|
||||
; xchg cx,dx
|
||||
; div [Fat12_Heads]
|
||||
; mov ch,al
|
||||
; ror ah,1
|
||||
; ror ah,1
|
||||
; or cl,ah
|
||||
; mov dh,dl
|
||||
; mov dl,00h
|
||||
; pop si
|
||||
; pop bx
|
||||
; mov ax,si
|
||||
; mov ah,03h
|
||||
; int 13h
|
||||
; ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_NextCluster:
|
||||
;input AX=current cluster
|
||||
;output AX=fat value for current cluster (next cluster or eof...etc)
|
||||
;Modifica AX
|
||||
push dx
|
||||
push es
|
||||
push di
|
||||
push ax
|
||||
mov di,3
|
||||
mul di
|
||||
shr ax,1
|
||||
mov di,ax
|
||||
mov ax,cs:[Fat12_FatSegment]
|
||||
mov es,ax
|
||||
mov ax,word ptr es:[di]
|
||||
pop di
|
||||
and di,1
|
||||
test di,di
|
||||
jz nextcluster_even
|
||||
push cx
|
||||
mov cl,4
|
||||
shr ax,cl
|
||||
pop cx
|
||||
jmp nextcluster_done
|
||||
nextcluster_even:
|
||||
and ax,0fffh
|
||||
nextcluster_done:
|
||||
pop di
|
||||
pop es
|
||||
pop dx
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_FileSearch:
|
||||
;this looks for a file in the current directory
|
||||
;entry:
|
||||
;DS:SI=pointer to file name
|
||||
;output:carry set if file not found
|
||||
;carry clear if found - ES:DI points to file entry
|
||||
;If a bad sector is found, the carry is set and DI is set to 0ffffh
|
||||
;Modifica AX,BX,CX,DX,DI,ES
|
||||
|
||||
;Questa Š una delle procedure pi— "critiche" di tutto il supporto Fat...
|
||||
push cs:[Fat12_RootSectors]
|
||||
push cs:[Fat12_CurrentDir]
|
||||
|
||||
; push cs
|
||||
; pop es
|
||||
|
||||
push si
|
||||
push ds
|
||||
|
||||
; call Fat12_GetFileName
|
||||
|
||||
file_ini:
|
||||
xor dx,dx
|
||||
mov ax,cs:[Fat12_CurrentDir] ;DX:AX=directory starting sector
|
||||
mov bx,offset Fat12_DirBuffer ;ES:BX=buffer
|
||||
push bx
|
||||
mov cl,1 ;legge 1 settore
|
||||
push si
|
||||
call Fat12_ReadSector
|
||||
pop si
|
||||
pop di ;ES:DI=buffer
|
||||
|
||||
xor dx,dx ;DX=counter
|
||||
filenext:
|
||||
mov cx,11 ;ogni nome di file Š lungo 11 bytes
|
||||
|
||||
push si
|
||||
push di
|
||||
|
||||
rep cmpsb
|
||||
|
||||
pop di
|
||||
pop si
|
||||
je filefound
|
||||
add di,32 ;passa alla prossima entry
|
||||
add dx,32
|
||||
cmp dx,512
|
||||
jb filenext ;se DX>512 vuol dire che dobbiamo passare ad un altro settore
|
||||
mov ax,cs:[Fat12_CurrentDir]
|
||||
cmp cs:[Fat12_DataArea],ax
|
||||
ja rootdir
|
||||
add ax,2
|
||||
sub ax,cs:[Fat12_Dataarea] ;sistemazione del valore del settore
|
||||
call Fat12_nextcluster
|
||||
cmp ax,0ff7h ;controlla se siamo alla fine della directory
|
||||
ja filenotfound
|
||||
je filesearch_badsector
|
||||
sub ax,2
|
||||
add ax,cs:[Fat12_DataArea]
|
||||
mov cs:[Fat12_CurrentDir],ax
|
||||
jmp file_ini
|
||||
rootdir:
|
||||
dec cs:[Fat12_RootSectors]
|
||||
jz filenotfound
|
||||
inc cs:[Fat12_CurrentDir]
|
||||
jmp file_ini
|
||||
filenotfound:
|
||||
stc
|
||||
|
||||
; mov bx,0000h ;setta l'errore 0000h
|
||||
; mov ah,01h
|
||||
; int 21h
|
||||
|
||||
jmp filesearch_end
|
||||
filesearch_badsector:
|
||||
stc
|
||||
|
||||
; mov bx,0001h ;setta l'errore 0001h
|
||||
; mov ah01h
|
||||
; int 21h
|
||||
|
||||
mov di,0ffffh
|
||||
jmp filesearch_end
|
||||
filefound:
|
||||
clc
|
||||
filesearch_end:
|
||||
pop ds
|
||||
pop si
|
||||
|
||||
pop cs:[Fat12_CurrentDir]
|
||||
pop cs:[Fat12_RootSectors]
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_GetFileName:
|
||||
;input DS:[SI] name of the file
|
||||
;This routine translates the name "namefile.ext" into NAMEFILEEXT
|
||||
|
||||
push ax
|
||||
push cx
|
||||
push di
|
||||
push es
|
||||
|
||||
mov di,offset GetFileNameBuffer
|
||||
mov cx,9
|
||||
|
||||
GetFileName_StoreFileName:
|
||||
lodsb
|
||||
cmp al,96
|
||||
jbe GetFileName_UpCaseOk
|
||||
|
||||
sub al,32
|
||||
GetFileName_UpCaseOk:
|
||||
cmp al,'.'
|
||||
je GetFileName_StoreExtension
|
||||
dec cx
|
||||
jz GetFileName_StoreExtension
|
||||
stosb
|
||||
jmp GetFileName_StoreFileName
|
||||
|
||||
GetFileName_StoreExtension:
|
||||
test cx,cx
|
||||
; jz GetFileName_StoreExtension2
|
||||
jnz GetFileName_CompleteName
|
||||
lodsb
|
||||
cmp al,'.'
|
||||
jne GetFileName_NoExtension
|
||||
jmp GetFileName_StoreExtension
|
||||
|
||||
|
||||
GetFileName_CompleteName:
|
||||
dec cx
|
||||
test cx,cx
|
||||
jz GetFileName_StoreExtension2
|
||||
mov al,' '
|
||||
rep stosb
|
||||
|
||||
GetFileName_StoreExtension2:
|
||||
mov cx,3
|
||||
rep movsb
|
||||
|
||||
GetFileName_NoExtension:
|
||||
mov si,offset GetFileNameBuffer
|
||||
|
||||
push cs
|
||||
pop ds
|
||||
|
||||
pop es
|
||||
pop di
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
GetFileNameBuffer db 12 dup (?)
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_ChDir:
|
||||
;Cambia la directory corrente
|
||||
;entry:
|
||||
;DS:SI=pointer to directory name
|
||||
;output:carry set if directory not found
|
||||
;Modifica AX,BX,CX,DX,DI,ES
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push es
|
||||
push di
|
||||
|
||||
push si
|
||||
push ds
|
||||
|
||||
call Fat12_GetFileName
|
||||
push si
|
||||
add si,8
|
||||
mov al,' '
|
||||
mov cx,3
|
||||
Fat12_ChDir_1:
|
||||
mov byte ptr ds:[si],al
|
||||
inc si
|
||||
loop Fat12_ChDir_1
|
||||
pop si
|
||||
|
||||
call Fat12_FileSearch
|
||||
jc chdir_notfound
|
||||
mov al,byte ptr es:[di+0bh] ;legge gli attributi del file
|
||||
and al,00010000b
|
||||
cmp al,10h ;controlla se si tratta di una subdir
|
||||
stc
|
||||
jne chdir_notfound
|
||||
mov ax,word ptr es:[di+1ah]
|
||||
sub ax,2
|
||||
add ax,cs:[Fat12_DataArea]
|
||||
mov cs:[Fat12_CurrentDir],ax
|
||||
|
||||
mov cx,8
|
||||
mov di,offset Fat12_DirName
|
||||
|
||||
ChDir_StoreName1:
|
||||
mov al,byte ptr ds:[si]
|
||||
cmp al,' '
|
||||
jne ChDir_StoreName2
|
||||
mov al,0
|
||||
ChDir_StoreName2:
|
||||
mov byte ptr cs:[di],al
|
||||
loop ChDir_StoreName1
|
||||
|
||||
clc
|
||||
|
||||
chdir_notfound:
|
||||
pop ds
|
||||
pop si
|
||||
|
||||
pop di
|
||||
pop es
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_GetCurrentDirName:
|
||||
;output ES:DI=pointer to directory name
|
||||
mov di,cs
|
||||
mov es,di
|
||||
mov di,offset Fat12_DirName
|
||||
ret
|
||||
|
||||
|
||||
Fat12_DirName db '\',0,' ' ;initial directory name (root directory)
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_OpenFile:
|
||||
;entry:
|
||||
;DS:SI=pointer to file name
|
||||
;output:carry set if file not found
|
||||
;SI=file number (if file was found)
|
||||
;inizializes [file_sector] to the first sector of the file
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push es
|
||||
push di
|
||||
|
||||
push cs
|
||||
pop es
|
||||
push ds
|
||||
push si
|
||||
call Fat12_GetFileName
|
||||
call Fat12_FileSearch
|
||||
pop si
|
||||
pop ds
|
||||
jc open_file_error2
|
||||
|
||||
mov cx,Fat12_MaxFiles+1
|
||||
xor si,si
|
||||
open_file_1:
|
||||
mov ax,cs:[Fat12_FileSector+si]
|
||||
test ax,ax
|
||||
jz open_file_2
|
||||
dec cx
|
||||
jz open_file_error
|
||||
add si,2
|
||||
jmp open_file_1
|
||||
open_file_2:
|
||||
mov cx,si
|
||||
mov ax,es:[di+1ah]
|
||||
sub ax,2
|
||||
add ax,cs:[Fat12_DataArea]
|
||||
mov cs:[Fat12_FileSector+si],ax
|
||||
xor ax,ax
|
||||
mov cs:[Fat12_FileBytes+si],ax
|
||||
mov ax,word ptr es:[di+1ch]
|
||||
push si
|
||||
add si,si
|
||||
mov word ptr cs:[Fat12_FileSize+si+2],ax
|
||||
mov ax,word ptr es:[di+1eh]
|
||||
mov word ptr cs:[Fat12_FileSize+si],ax
|
||||
|
||||
pop si
|
||||
mov al,byte ptr es:[di+0bh]
|
||||
shr si,1
|
||||
mov byte ptr cs:[Fat12_FileAttr+si],al
|
||||
mov si,cx
|
||||
clc
|
||||
jmp open_file_error2
|
||||
open_file_error:
|
||||
stc
|
||||
open_file_error2:
|
||||
; pop si
|
||||
; pop ds
|
||||
|
||||
pop di
|
||||
pop es
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_CloseFile:
|
||||
;input SI:number of file to close
|
||||
push ax
|
||||
xor ax,ax
|
||||
mov cs:[Fat12_FileSector+si],ax
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_ReadFile:
|
||||
;input DX=number of bytes to read
|
||||
;SI=file number
|
||||
;ES:DI=buffer for data
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push si
|
||||
push di
|
||||
|
||||
test dx,dx
|
||||
jz readfile_end1
|
||||
readfile_ini:
|
||||
mov bx,offset Fat12_DirBuffer
|
||||
push dx
|
||||
xor dx,dx
|
||||
mov ax,cs:[Fat12_FileSector+si]
|
||||
mov cl,1
|
||||
push si
|
||||
push es
|
||||
|
||||
push cs
|
||||
pop es
|
||||
call Fat12_ReadSector
|
||||
pop es
|
||||
pop si
|
||||
mov cx,cs:[Fat12_FileBytes+si]
|
||||
add bx,cx
|
||||
mov ax,512
|
||||
sub ax,cx
|
||||
mov cx,ax
|
||||
pop dx
|
||||
r1:
|
||||
mov al,byte ptr cs:[bx]
|
||||
mov byte ptr es:[di],al
|
||||
|
||||
inc word ptr cs:[Fat12_FileBytes+si]
|
||||
; dec dx
|
||||
; jz readfile_end1
|
||||
push si
|
||||
add si,si
|
||||
dec word ptr cs:[Fat12_FileSize+si+2]
|
||||
jnz r2
|
||||
cmp word ptr cs:[Fat12_FileSize+si],0
|
||||
je readfile_eof
|
||||
dec word ptr cs:[Fat12_FileSize+si]
|
||||
mov ax,0ffffh
|
||||
mov word ptr cs:[Fat12_FileSize+si+2],ax
|
||||
jmp r2
|
||||
|
||||
readfile_end1:
|
||||
jmp readfile_end
|
||||
r2:
|
||||
pop si
|
||||
dec dx
|
||||
jz readfile_end
|
||||
inc bx
|
||||
inc di
|
||||
loop r1
|
||||
xor ax,ax
|
||||
mov word ptr cs:[Fat12_FileBytes+si],ax
|
||||
mov ax,word ptr cs:[Fat12_FileSector+si]
|
||||
add ax,2
|
||||
sub ax,cs:[Fat12_DataArea]
|
||||
call Fat12_NextCluster
|
||||
cmp ax,0ff7h
|
||||
ja readfile_badcluster
|
||||
; je readfile_eof
|
||||
je readfile_end
|
||||
sub ax,2
|
||||
add ax,cs:[Fat12_DataArea]
|
||||
mov word ptr cs:[Fat12_FileSector+si],ax
|
||||
jmp readfile_ini
|
||||
readfile_eof:
|
||||
pop si
|
||||
readfile_badcluster:
|
||||
readfile_end:
|
||||
|
||||
pop di
|
||||
pop si
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Fat12_WriteFile:
|
||||
;This procedure writes to a file.
|
||||
;input:
|
||||
;SI=number of file
|
||||
;ES:DI=data buffer
|
||||
;DX=number of bytes to write
|
||||
|
||||
|
||||
|
||||
; ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Fat12_GetFileSize:
|
||||
;Input SI=file handler
|
||||
;Output AX=File size (per ora solo word...)
|
||||
|
||||
;Attenzione: questa procedura ritorna un valore corretto SOLO se viene chiamata
|
||||
;subito dopo aver aperto il file.
|
||||
|
||||
push si
|
||||
|
||||
add si,si
|
||||
mov ax,word ptr cs:[Fat12_FileSize+si+2]
|
||||
pop si
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
171
INTERRPT.ASM
Normal file
171
INTERRPT.ASM
Normal file
|
@ -0,0 +1,171 @@
|
|||
;INT 20h --> Process management
|
||||
|
||||
InstallInterrupt:
|
||||
push ax
|
||||
push es
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
|
||||
;Installing Interrupt 20h
|
||||
mov ax,offset Int20h
|
||||
mov word ptr es:[20h*4],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[(20h*4)+2],ax
|
||||
|
||||
;Installing Interrupt 21h
|
||||
mov ax,offset Int21h
|
||||
mov word ptr es:[21h*4],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[(21h*4)+2],ax
|
||||
|
||||
;Installing Interrupt 22h
|
||||
mov ax,offset Int22h
|
||||
mov word ptr es:[22h*4],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[(22h*4+2)],ax
|
||||
|
||||
;Installing Interrupt 23h
|
||||
mov ax,offset Int23h
|
||||
mov word ptr es:[23h*4],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[(23h*4+2)],ax
|
||||
|
||||
pop es
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Int20h:
|
||||
cmp ah,00h
|
||||
je Int20h_00h
|
||||
cmp ah,01h
|
||||
je Int20h_01h
|
||||
cmp ah,02h
|
||||
je Int20h_02h
|
||||
cmp ah,03h
|
||||
je Int20h_03h
|
||||
cmp ah,04h
|
||||
je Int20h_04h
|
||||
cmp ah,05h
|
||||
je Int20h_05h
|
||||
cmp ah,06h
|
||||
je Int20h_06h
|
||||
cmp ah,07h
|
||||
je Int20h_07h
|
||||
cmp ah,08h
|
||||
je Int20h_08h
|
||||
|
||||
iret
|
||||
|
||||
Int20h_00h:
|
||||
call LoadProgram
|
||||
retf 2
|
||||
Int20h_01h:
|
||||
call RunProcess
|
||||
iret
|
||||
int20h_02h:
|
||||
call KillProcess
|
||||
iret
|
||||
int20h_03h:
|
||||
call GetProcessInfo
|
||||
iret
|
||||
int20h_04h:
|
||||
call SetVisibleProcess
|
||||
iret
|
||||
int20h_05h:
|
||||
call GoToNextProcess
|
||||
iret
|
||||
int20h_06h:
|
||||
call GetNextProcess
|
||||
iret
|
||||
Int20h_07h:
|
||||
call LoadComProgram
|
||||
iret
|
||||
Int20h_08h:
|
||||
call ExeLoader
|
||||
iret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Int21h:
|
||||
cmp ah,00h
|
||||
je Int21h_00h
|
||||
cmp ah,01h
|
||||
je Int21h_01h
|
||||
cmp ah,02h
|
||||
je Int21h_02h
|
||||
iret
|
||||
|
||||
Int21h_00h:
|
||||
call EndSystem
|
||||
iret
|
||||
Int21h_01h:
|
||||
call GetError
|
||||
iret
|
||||
Int21h_02h:
|
||||
call SetError
|
||||
iret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Int22h:
|
||||
cmp ah,00h
|
||||
je Int22h_00h
|
||||
cmp ah,01h
|
||||
je Int22h_01h
|
||||
cmp ah,02h
|
||||
je Int22h_02h
|
||||
cmp ah,03h
|
||||
je Int22h_03h
|
||||
cmp ah,04h
|
||||
je Int22h_04h
|
||||
cmp ah,05h
|
||||
je Int22h_05h
|
||||
|
||||
iret
|
||||
|
||||
Int22h_00h:
|
||||
call Fat12_OpenFile
|
||||
sti
|
||||
retf 2
|
||||
Int22h_01h:
|
||||
call Fat12_ReadFile
|
||||
iret
|
||||
Int22h_02h:
|
||||
call Fat12_CloseFile
|
||||
iret
|
||||
Int22h_03h:
|
||||
call Fat12_ChDir
|
||||
sti
|
||||
retf 2
|
||||
Int22h_04h:
|
||||
call Fat12_GetFileSize
|
||||
iret
|
||||
Int22h_05h:
|
||||
call Fat12_GetCurrentDirName
|
||||
iret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Int23h:
|
||||
cmp ah,00h
|
||||
je Int23h_00h
|
||||
cmp ah,01h
|
||||
je Int23h_01h
|
||||
cmp ah,02h
|
||||
je Int23h_02h
|
||||
iret
|
||||
|
||||
Int23h_00h:
|
||||
call MemAlloc
|
||||
iret
|
||||
Int23h_01h:
|
||||
call MemFree
|
||||
iret
|
||||
Int23h_02h:
|
||||
call GetFreeMem
|
||||
iret
|
||||
|
||||
;------------------------------------------------------------------------------
|
250
KERNEL.ASM
Normal file
250
KERNEL.ASM
Normal file
|
@ -0,0 +1,250 @@
|
|||
;NXOS kernel
|
||||
;-----------
|
||||
;Written by: Alberto Venturini (Alb‚) - 2000/2001
|
||||
;Email address: -albe-@libero.it
|
||||
;------------------------------------------------
|
||||
;
|
||||
;
|
||||
;Sorry, but comments are in italian... :(
|
||||
|
||||
org 0h
|
||||
|
||||
InitSystem:
|
||||
|
||||
;Inizializzo i segmenti
|
||||
mov ax,1000h
|
||||
mov ss,ax
|
||||
mov sp,0fffeh
|
||||
mov ds,ax
|
||||
|
||||
mov ax,0003h
|
||||
int 10h
|
||||
mov si,offset InitSystemMsg
|
||||
call WriteSimple
|
||||
|
||||
;Inizializzo gli "exception handlers"
|
||||
call InstallExceptionHandlers
|
||||
|
||||
;Inizializzo gli interrupt per le chiamate di sistema
|
||||
call InstallInterrupt
|
||||
|
||||
;Inizializzo la Fat
|
||||
mov si,offset InitFat
|
||||
call WriteSimple
|
||||
call Fat12_FatInit
|
||||
|
||||
;Inizializzo la gestione della memoria
|
||||
mov si,offset InitMem
|
||||
call WriteSimple
|
||||
call MemInit
|
||||
|
||||
;Inizializzo la gestione dei processi multitasking
|
||||
mov si,offset InitMt
|
||||
call WriteSimple
|
||||
call StartMultiTasking
|
||||
|
||||
mov al,13
|
||||
mov ah,0eh
|
||||
int 10h
|
||||
mov al,10
|
||||
int 10h
|
||||
|
||||
;Installo il driver video
|
||||
mov si,offset InitVideoDrv
|
||||
call WriteSimple
|
||||
|
||||
mov si,offset VideoDrv
|
||||
call LoadProgram
|
||||
jc KeyboardInstall
|
||||
mov bl,1
|
||||
call RunProcess
|
||||
|
||||
KeyboardInstall:
|
||||
;Installo il driver della tastiera
|
||||
mov si,offset InitKeyboardDrv
|
||||
call WriteSimple
|
||||
|
||||
mov si,offset KeyboardDrv
|
||||
call LoadProgram
|
||||
jc BigMemInstall
|
||||
mov bl,1
|
||||
call RunProcess
|
||||
|
||||
BigMemInstall:
|
||||
;Installo il driver per la Real mode 32-bit
|
||||
mov si,offset InitBigMemDrv
|
||||
call WriteSimple
|
||||
|
||||
mov si,offset BigMemDrv
|
||||
call LoadProgram
|
||||
jc ShellInstall
|
||||
mov bl,1
|
||||
call RunProcess
|
||||
|
||||
ShellInstall:
|
||||
mov si,offset ContinueMsg
|
||||
call WriteSimple
|
||||
|
||||
mov ah,00h
|
||||
int 25h
|
||||
|
||||
; [..]
|
||||
|
||||
mov si,offset InitShell
|
||||
call WriteSimple
|
||||
|
||||
; mov ah,00h
|
||||
; int 25h
|
||||
|
||||
mov si,offset Shell
|
||||
call LoadProgram
|
||||
jc ErrorNoShell
|
||||
call RunProcess
|
||||
|
||||
mov si,1
|
||||
mov ah,02h
|
||||
int 24h
|
||||
|
||||
InitSystem_End:
|
||||
mov ah,02h
|
||||
mov bl,1
|
||||
int 20h
|
||||
|
||||
ErrorNoShell:
|
||||
mov si,offset ErrorShell
|
||||
call WriteSimple
|
||||
|
||||
mov ah,00h
|
||||
int 25h
|
||||
|
||||
jmp EndSystem
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
EndSystem:
|
||||
call EndMultiTasking
|
||||
|
||||
mov ah,01h ;Termina la Real Mode a 32 bit.
|
||||
int 2fh
|
||||
|
||||
mov ah,04h
|
||||
int 25h ;Termina il driver della tastiera
|
||||
|
||||
mov si,offset ShutDown
|
||||
|
||||
EndSystem_WriteMsg:
|
||||
call WriteSimple
|
||||
mov ah,00h
|
||||
int 16h
|
||||
|
||||
cmp al,'R'
|
||||
je EndSystem_Reboot
|
||||
cmp al,'r'
|
||||
je EndSystem_Reboot
|
||||
cmp al,'S'
|
||||
je EndSystem_ShutDown
|
||||
cmp al,'s'
|
||||
je EndSystem_ShutDown
|
||||
|
||||
jmp EndSystem_WriteMsg
|
||||
|
||||
EndSystem_Reboot:
|
||||
int 19h
|
||||
|
||||
EndSystem_ShutDown:
|
||||
mov ax,5300h
|
||||
xor bx, bx
|
||||
int 15h
|
||||
mov ax,5304h
|
||||
xor bx, bx
|
||||
int 15h
|
||||
mov ax,5301h
|
||||
xor bx, bx
|
||||
int 15h
|
||||
mov ax,5307h
|
||||
mov bx,1
|
||||
mov cx,3
|
||||
int 15h
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
SetError:
|
||||
;input AL=codice dell'errore
|
||||
mov cs:[SystemError],al
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GetError:
|
||||
;output AL=codice dell'errore
|
||||
mov al,cs:[SystemError]
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
WriteSimple:
|
||||
;input CS:SI --> indirizzo della stringa
|
||||
push ax
|
||||
push bx
|
||||
push si
|
||||
|
||||
mov ah,0eh
|
||||
mov bx,7
|
||||
WriteSimple_1:
|
||||
mov al,byte ptr cs:[si]
|
||||
test al,al
|
||||
jz WriteSimple_End
|
||||
int 10h
|
||||
inc si
|
||||
jmp WriteSimple_1
|
||||
|
||||
WriteSimple_End:
|
||||
pop si
|
||||
pop bx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
include Fat12d.asm
|
||||
include MemManag.asm
|
||||
include Processi.asm
|
||||
include Interrpt.asm
|
||||
include Except.asm
|
||||
include LoadExeC.asm
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
;Kernel Data
|
||||
|
||||
;Messaggi
|
||||
InitSystemMsg db 'NXOS version 0.3.3',13,10,0
|
||||
InitFat db 'Initializing filesystem: 12-bit Fat...',13,10,0
|
||||
InitMem db 'Initializing 16-bit memory management...',13,10,0
|
||||
InitMt db 'Initializing process manager (multitasker)...',13,10,0
|
||||
InitVideoDrv db 'Loading video driver (video.drv)...',13,10,0
|
||||
InitKeyboardDrv db 'Loading keyboard driver (keyboard.drv)...',13,10,0
|
||||
InitBigMemDrv db 'Loading 32-bit real mode driver (bigmem.drv)...',13,10,0
|
||||
InitShell db 'Loading shell (shell.bin)...',13,10,0
|
||||
ErrorShell db 'Error - file shell.bin not found.',13,10,0
|
||||
|
||||
ContinueMsg db 'Press any key to continue...',13,10,0
|
||||
|
||||
ShutDown db 'Do you want to (R)eboot or (S)hutdown?',0
|
||||
|
||||
;Shell db 'SHELL BIN'
|
||||
|
||||
;VideoDrv db 'VIDEO DRV'
|
||||
;KeyboardDrv db 'KEYBOARDDRV'
|
||||
|
||||
;BigMemDrv db 'BIGMEM DRV'
|
||||
|
||||
Shell db 'SHELL.BIN'
|
||||
VideoDrv db 'VIDEO.DRV'
|
||||
KeyboardDrv db 'KEYBOARD.DRV'
|
||||
|
||||
BigMemDrv db 'BIGMEM.DRV'
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
include Sysmem.asm
|
BIN
KERNEL.BIN
Normal file
BIN
KERNEL.BIN
Normal file
Binary file not shown.
554
KEYBOARD.ASM
Normal file
554
KEYBOARD.ASM
Normal file
|
@ -0,0 +1,554 @@
|
|||
;Driver della tastiera per NXOS
|
||||
;------------------------------
|
||||
;Written by: MaX and Alb‚ - 2001
|
||||
;
|
||||
;Questo driver sostituisce le routine dell'int 16h del bios.
|
||||
;Controlla anche se particolari combinazioni di tasti sono state premute:
|
||||
;
|
||||
;CTRL+C o CTRL+Del --> Termina il processo visibile
|
||||
;CTRL+N --> Rende visibile il processo successivo
|
||||
|
||||
;Prossima funzione da implementare: GetString
|
||||
|
||||
|
||||
org 0h
|
||||
|
||||
InstallDriver:
|
||||
cli
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,offset Int25h
|
||||
mov word ptr es:[25h*4],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[(25h*4)+2],ax
|
||||
|
||||
mov ax,word ptr es:[09h*4]
|
||||
mov word ptr cs:[OldInt09h],ax
|
||||
mov ax,word ptr es:[09h*4+2]
|
||||
mov word ptr cs:[OldInt09h+2],ax
|
||||
|
||||
mov ax,offset Int09h
|
||||
mov word ptr es:[09h*4],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[09h*4+2],ax
|
||||
|
||||
mov ah,02h
|
||||
mov bl,1
|
||||
int 20h
|
||||
|
||||
;==============================================================================
|
||||
|
||||
Int25h:
|
||||
cmp ah,00h
|
||||
je Int25h_00h
|
||||
cmp ah,01h
|
||||
je Int25h_01h
|
||||
cmp ah,02h
|
||||
je Int25h_02h
|
||||
cmp ah,03h
|
||||
je Int25h_03h
|
||||
cmp ah,04h
|
||||
je Int25h_04h
|
||||
cmp ah,05h
|
||||
je Int25h_05h
|
||||
cmp ah,06h
|
||||
je Int25h_06h
|
||||
cmp ah,07h
|
||||
je Int25h_07h
|
||||
iret
|
||||
Int25h_00h:
|
||||
call GetKey
|
||||
iret
|
||||
Int25h_01h:
|
||||
call TestKey
|
||||
retf 2 ;Attenzione qui: uso "retf 2" invece di "iret", perchè iret
|
||||
;ripristina lo stato dei
|
||||
;flags, mentre io voglio che il flag Z sia settato dalla
|
||||
;procedura "TestKey"
|
||||
Int25h_02h:
|
||||
call GetStatus
|
||||
iret
|
||||
Int25h_03h:
|
||||
call SetAutoRpt
|
||||
iret
|
||||
Int25h_04h:
|
||||
call EndKeyboardDriver
|
||||
iret
|
||||
Int25h_05h:
|
||||
call StoreKey
|
||||
iret
|
||||
Int25h_06h:
|
||||
call GetKeyWithEcho
|
||||
iret
|
||||
Int25h_07h:
|
||||
call GetStringWithEcho
|
||||
iret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
EndKeyboardDriver:
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,word ptr cs:[OldInt09h]
|
||||
mov es:[09h*4],ax
|
||||
mov ax,word ptr cs:[OldInt09h+2]
|
||||
mov es:[09h*4+2],ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GetKey:
|
||||
;prende il codice del tasto premuto dal buffer di tastiera e lo retituisce in AX
|
||||
;Output: al=ascii-code ah=scan-code
|
||||
push cx
|
||||
push si
|
||||
|
||||
GetKey1:
|
||||
mov ah,03h
|
||||
int 20h
|
||||
cmp si,cx
|
||||
je GetKey2 ;se il processo Š quello visibile, allora legge il tasto
|
||||
mov ah,05h ;altrimenti passa al processo successivo
|
||||
int 20h
|
||||
jmp GetKey1
|
||||
|
||||
GetKey2:
|
||||
Call TestKey
|
||||
jz GetKey1
|
||||
|
||||
cli
|
||||
push ds
|
||||
mov ax,40h
|
||||
mov ds,ax
|
||||
mov si,word ptr ds:[HeadPtr] ;carica in bx l'indirizzo del prossimo carattere
|
||||
mov ax,ds:[si] ;preleva il carattere e lo mette in ax
|
||||
inc si
|
||||
inc si
|
||||
cmp si,ds:[82h] ;check for overflow
|
||||
jnz GetKey_End
|
||||
mov si,ds:[80h] ;ripristina il valore originale di HeadPtr
|
||||
|
||||
GetKey_End:
|
||||
mov word ptr ds:[HeadPtr],si
|
||||
pop ds
|
||||
|
||||
pop si
|
||||
pop cx
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
TestKey:
|
||||
;verifica se e' disponibile un carattere nel buffer
|
||||
; ZF=1 il carattere non e' disponibile
|
||||
; ZF=0 il carattere e' disponibile
|
||||
; se il car. e' disponibile allora al= ascii-code ah=scan-code
|
||||
; il carattere non viene rimosso dal buffer
|
||||
|
||||
push ds
|
||||
push bx
|
||||
|
||||
TestKey1:
|
||||
mov ah,03h
|
||||
int 20h
|
||||
cmp si,cx
|
||||
je TestKey2
|
||||
mov ah,05h
|
||||
int 20h
|
||||
jmp TestKey1
|
||||
|
||||
TestKey2:
|
||||
mov ax, 40h
|
||||
mov ds, ax
|
||||
cli ;regione critica
|
||||
mov bx, word ptr ds:[HeadPtr]
|
||||
mov ax, ds:[bx] ;mette il carattere letto dal buffer in ax
|
||||
cmp bx, word ptr ds:[TailPtr] ;ZF=1, se il buffer e' vuoto
|
||||
pop bx
|
||||
pop ds
|
||||
sti ;Bisogna ricordarsi di risettare l'interrupt flag, perchŠ
|
||||
;da TestKey non esco con un "iret" ma con "retf 2" (quindi
|
||||
;non viene risettato il valore originale dei flags)
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------------------------
|
||||
|
||||
GetStringWithEcho:
|
||||
;Input: DS:[SI] --> buffer in cui memorizzare la stringa
|
||||
;Output CX=numero di caratteri della stringa.
|
||||
;La stringa finisce quando viene premuto CR (#13) (cioŠ Enter). Il carattere
|
||||
;CR non viene memorizzato nel buffer
|
||||
;I caratteri premuti vengono visualizzati sul video.
|
||||
|
||||
push ax
|
||||
push si
|
||||
|
||||
xor cx,cx
|
||||
|
||||
GetString1:
|
||||
call GetKey
|
||||
cmp al,13
|
||||
je GetString_End
|
||||
cmp al,8
|
||||
je GetString_DelPressed
|
||||
mov byte ptr ds:[si],al
|
||||
inc si
|
||||
inc cx
|
||||
mov ah,00h
|
||||
int 24h
|
||||
jmp GetString1
|
||||
|
||||
GetString_DelPressed:
|
||||
test cx,cx
|
||||
jz GetString1
|
||||
|
||||
dec si
|
||||
dec cx
|
||||
mov al,' '
|
||||
mov byte ptr ds:[si],al
|
||||
|
||||
mov ah,05h
|
||||
int 24h
|
||||
sub dl,1
|
||||
push dx
|
||||
mov ah,06h
|
||||
int 24h
|
||||
|
||||
mov al,' '
|
||||
mov ah,00h
|
||||
int 24h
|
||||
|
||||
pop dx
|
||||
mov ah,06h
|
||||
int 24h
|
||||
|
||||
jmp GetString1
|
||||
|
||||
GetString_End:
|
||||
|
||||
pop si
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GetKeyWithEcho:
|
||||
;output AL=ascii code, AH=scan code
|
||||
|
||||
call GetKey
|
||||
push ax
|
||||
mov ah,00h
|
||||
int 24h
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;patch dell'interrupt 09h
|
||||
;Questo Š necessario per determinare la pressione di certe combinazioni di tasti
|
||||
;(es CTRL+C --> termina il processo visibile...ecc.)
|
||||
|
||||
;Per maggiori informazioni, consultate il capitolo 20 del libro
|
||||
;"The Art of Assembly Language".
|
||||
|
||||
Int09h:
|
||||
cli
|
||||
push ax
|
||||
push cx
|
||||
push ds
|
||||
|
||||
|
||||
mov ax,40h
|
||||
mov ds,ax
|
||||
; mov al,0adh
|
||||
; call SetCmd ;disabilita temporaneamente la tastiera
|
||||
|
||||
cli
|
||||
; xor cx,cx
|
||||
|
||||
Int09h_Wait4Data:
|
||||
; in al,64h
|
||||
; test al,10b
|
||||
; loopnz Int09h_Wait4Data
|
||||
|
||||
mov al,byte ptr ds:[17h]
|
||||
test al,100b
|
||||
jz OrigInt09h
|
||||
|
||||
and al,11111011b
|
||||
mov byte ptr ds:[17h],al
|
||||
|
||||
in al,60h
|
||||
cmp al,2eh ;guarda se Š stata premuta una C (per il CTRL+C)
|
||||
je Int09h_CtrlC
|
||||
cmp al,53h ;controlla se Š premuto Del
|
||||
je Int09h_CtrlC
|
||||
|
||||
cmp al,31h ;controlla se Š premuto il tasto 'N'
|
||||
je Int09h_CtrlN
|
||||
|
||||
; jmp OrigInt09h ;altrimenti salta all'interrupt originale
|
||||
|
||||
mov al,20h
|
||||
out 20h,al
|
||||
|
||||
pop ds
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
iret
|
||||
|
||||
|
||||
Int09h_CheckCtrlC:
|
||||
|
||||
; mov al,byte ptr ds:[17h]
|
||||
; test al,100b ;controlla se Š premuto CTRL
|
||||
; jnz Int09h_CtrlC
|
||||
|
||||
; jmp OrigInt09h
|
||||
|
||||
Int09h_CheckCtrlN:
|
||||
; mov al,byte ptr ds:[17h]
|
||||
; test al,100b
|
||||
; jnz Int09h_CtrlN
|
||||
|
||||
; jmp OrigInt09h
|
||||
|
||||
Int09h_CtrlC:
|
||||
;CTRL+C o CTRL+Del sono stati premuti
|
||||
; mov al,0aeh ;riabilita la tastiera
|
||||
; call SetCmd
|
||||
|
||||
mov al,20h ;segnale di fine interrupt
|
||||
out 20h,al
|
||||
|
||||
pop ds
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
mov ah,02h ;termina il processo corrente
|
||||
mov bl,0
|
||||
int 20h
|
||||
|
||||
Int09h_CtrlN:
|
||||
mov ah,06h ;controlla qual'Š il processo successivo
|
||||
int 20h
|
||||
|
||||
mov ah,02h ;setta visibile il processo successivo
|
||||
int 24h
|
||||
|
||||
; mov al,0aeh ;riabilita la tastiera
|
||||
; call SetCmd
|
||||
|
||||
mov al,20h ;segnale di fine interrupt
|
||||
out 20h,al
|
||||
|
||||
pop ds
|
||||
pop cx
|
||||
pop ax
|
||||
iret
|
||||
|
||||
OrigInt09h:
|
||||
; mov al,0aeh ;riabilita la tastiera
|
||||
; call SetCmd
|
||||
|
||||
; mov al,20h
|
||||
; out 20h,al
|
||||
|
||||
pop ds
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
jmp dword ptr cs:[OldInt09h] ;salta all'int 09h originale
|
||||
|
||||
|
||||
;--------------------------------------
|
||||
|
||||
SetCmd:
|
||||
;Questa procedura manda un comando al microcontroller della tastiera
|
||||
;INPUT AL:comando da mandare
|
||||
push cx
|
||||
cli
|
||||
xor cx,cx
|
||||
|
||||
push ax
|
||||
|
||||
SetCmd_Wait4Empty:
|
||||
in al,64h
|
||||
test al,10b
|
||||
loopnz SetCmd_Wait4Empty
|
||||
|
||||
pop ax
|
||||
out 64h,al
|
||||
|
||||
sti
|
||||
pop cx
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------------------------
|
||||
|
||||
;preleva lo stato dei tasti modificatori
|
||||
;NON TESTATO!!
|
||||
|
||||
GetStatus:
|
||||
|
||||
push ds
|
||||
mov ax, 40h
|
||||
mov ds, ax
|
||||
mov al, byte ptr ds:[KbdFlags1] ;mette in al lo stato dei tasti modificatori
|
||||
pop ds
|
||||
|
||||
ret
|
||||
|
||||
;----------------------------------------------
|
||||
|
||||
;setta il rapporto di autoripetizione
|
||||
;bh=0, 1, 2, or 3 (delay in 1/4 sec before autorepeat starts)
|
||||
;and bl=0..1Fh (repeat rate, about 2:1 to 30:1 (chars:sec).
|
||||
|
||||
;BH=0 --> 250 ms
|
||||
;BH=1 --> 500 ms
|
||||
;BH=2 --> 750 ms
|
||||
;Bh=3 --> 1 second
|
||||
|
||||
;BL=0 --> 30 rpts/sec
|
||||
;BL=1 --> 26 rpts/sec
|
||||
;...
|
||||
;BL=1fh --> 2 rpts /sec
|
||||
|
||||
SetAutoRpt:
|
||||
|
||||
push ax
|
||||
push cx
|
||||
push bx
|
||||
|
||||
mov al, 0ADh ;Disable kbd for now.
|
||||
call SetCmd
|
||||
and bh, 11b ;Force into proper range.
|
||||
mov cl, 5
|
||||
shl bh, cl ;Move to final position.
|
||||
and bl, 1Fh ;Force into proper range.
|
||||
or bh, bl ;8042 command data byte.
|
||||
mov al, 0F3h ;8042 set repeat rate cmd.
|
||||
call SendCmd ;Send the command to 8042.
|
||||
mov al, bh ;Get parameter byte
|
||||
call SendCmd ;Send parameter to the 8042.
|
||||
mov al, 0AEh ;Reenable keyboard.
|
||||
call SetCmd
|
||||
mov al, 0F4h ;Restart kbd scanning.
|
||||
call SendCmd
|
||||
|
||||
pop bx
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;----------------------------------------------
|
||||
|
||||
|
||||
; memorizza il carattere in CX nel buffer
|
||||
; CH=scan-code CL=ascii-code
|
||||
|
||||
;NON TESTATO!
|
||||
|
||||
StoreKey:
|
||||
|
||||
push ds
|
||||
push bx
|
||||
mov ax, 40h
|
||||
mov ds, ax
|
||||
cli ;regione critica
|
||||
mov bx, word ptr ds:[TailPtr] ;indirizzo di memorizzazione tasto
|
||||
push bx ;salva l'inidirizzo nello stack
|
||||
mov [bx], cx ;memorizza
|
||||
inc word PTR ds:[TailPtr] ;incrementa il puntatore di coda
|
||||
cmp bx, word ptr ds:[HeadPtr] ;sono stati sovrascritti dati?
|
||||
jne StoreOkay ;se non salta, se si continua
|
||||
pop word ptr cs:[TailPtr] ;riprende il vecchio indirizzo e ignora
|
||||
sub sp, 2 ;sistema lo stack
|
||||
StoreOkay:
|
||||
add sp, 2 ;rimuove dati dallo stack
|
||||
pop bx
|
||||
pop ds
|
||||
|
||||
ret
|
||||
|
||||
;-------------------------------------------------
|
||||
|
||||
; Spedisce un comando o un dato alla
|
||||
; keyboard data port (port 60h).
|
||||
|
||||
SendCmd:
|
||||
push ds
|
||||
push bx
|
||||
push cx
|
||||
mov cx, 40h
|
||||
mov ds, cx
|
||||
mov bx, ax ;Salva il dato
|
||||
mov bh, 3
|
||||
RetryLp:
|
||||
cli
|
||||
|
||||
; cancella il flag del registro KbdFlags4
|
||||
; flags: Cancella errori , riconoscimento accettato, rispedisci flags
|
||||
|
||||
and byte ptr ds:[KbdFlags4], 4fh
|
||||
|
||||
;aspetta finche' l'8042 processa il comando corrente
|
||||
|
||||
xor cx, cx
|
||||
|
||||
SendCmd_Wait4Empty:
|
||||
in al, 64h ;legge lo stato del registro
|
||||
test al, 10b ;Input buffer pieno?
|
||||
loopnz SendCmd_Wait4Empty ;aspetta finche' e' vuoto
|
||||
|
||||
|
||||
; Ok spedisci i dato alla porta 60h
|
||||
|
||||
mov al, bl
|
||||
out 60h, al
|
||||
sti
|
||||
|
||||
; Wait for the arrival of an acknowledgement from the keyboard ISR:
|
||||
|
||||
xor cx, cx
|
||||
Wait4Ack:
|
||||
test byte ptr ds:[KbdFlags4], 10 ;Acknowledge received bit.
|
||||
jnz GotAck
|
||||
loop Wait4Ack
|
||||
|
||||
dec bh
|
||||
jne RetryLp
|
||||
|
||||
; If the operation failed after 3 retries, set the error bit and quit.
|
||||
|
||||
or byte ptr ds:[KbdFlags4], 80h ;Set error bit.
|
||||
|
||||
GotAck:
|
||||
pop cx
|
||||
pop bx
|
||||
pop ds
|
||||
ret
|
||||
|
||||
;--------------------------------------
|
||||
|
||||
; variabili BIOS
|
||||
|
||||
KbdFlags1 equ 17h ; variabile che contiene lo stato dei tasti modificatori
|
||||
KbdFlags2 equ 18h ; altra variabile " " " " " "
|
||||
AltKpd equ 19h
|
||||
HeadPtr equ 1ah ; puntatore alla testa del buffer
|
||||
TailPtr equ 1ch ; puntatore alla coda del buffer
|
||||
Buffer equ 1eh ; buffer
|
||||
EndBuf equ 3eh
|
||||
KbdFlags3 equ 96h ; miscellaneos keyboard flags
|
||||
KbdFlags4 equ 97h ; " " " "
|
||||
|
||||
;variabili driver
|
||||
|
||||
OldInt09h dd ?
|
BIN
KEYBOARD.drv
Normal file
BIN
KEYBOARD.drv
Normal file
Binary file not shown.
279
LOADEXEC.ASM
Normal file
279
LOADEXEC.ASM
Normal file
|
@ -0,0 +1,279 @@
|
|||
;LoadExe - Exe file loader for NXOS
|
||||
;
|
||||
;Written by Alberto Venturini (Alb‚) - 2001
|
||||
;-albe-@libero.it
|
||||
;
|
||||
;http://nxos.cjb.net
|
||||
|
||||
;EXE Header
|
||||
|
||||
Sig equ 0 ;Exe signature "MZ"
|
||||
MLength equ 2 ;File size mod 512
|
||||
Pages equ 4 ;Length in pages (512 bytes)
|
||||
Relocs equ 6 ;Number of relocation items in relocation table
|
||||
HeadSize equ 8 ;Header size in paragraphs (16 btyes)
|
||||
MinAlloc equ 10 ;Minimum memory needed in paragraphs
|
||||
MaxAlloc equ 12 ;Maximum memory desired in paragraphs
|
||||
DispSs equ 14 ;Starting stack
|
||||
BaseSp equ 16 ;
|
||||
Checksum equ 18 ;
|
||||
BaseIp equ 20 ;Starting IP
|
||||
DispCs equ 22 ;Starting CS
|
||||
RelocOfs equ 24 ;Offset of relocation table
|
||||
Overlay equ 26 ;
|
||||
|
||||
|
||||
ExeLoader:
|
||||
;Main procedure.
|
||||
;Input DS:[SI] --> file name
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push di
|
||||
push es
|
||||
|
||||
;Apre il file
|
||||
|
||||
call Fat12_OpenFile
|
||||
jc ExeLoader_End1
|
||||
|
||||
mov word ptr cs:[EL_FileHandler],si
|
||||
|
||||
;Ottiene la dimensione del file
|
||||
|
||||
call Fat12_GetFileSize
|
||||
mov word ptr cs:[EL_SizeInBytes+2],ax
|
||||
|
||||
;Alloca la memoria necessaria per contenere il file
|
||||
|
||||
shr ax,10 ;Converte in kbytes
|
||||
inc ax ;"Melium abundare quam deficere..." :))
|
||||
mov dx,ax
|
||||
mov word ptr cs:[EL_MemoryAllocated],ax
|
||||
call MemAlloc
|
||||
|
||||
;Legge l'intero file nella memoria allocata
|
||||
|
||||
mov dx,word ptr cs:[EL_SizeInBytes+2]
|
||||
xor di,di
|
||||
call Fat12_ReadFile
|
||||
|
||||
;Chiude il file...tanto non mi serve +
|
||||
|
||||
call Fat12_CloseFile
|
||||
|
||||
;Controlla se Š un EXE
|
||||
|
||||
mov ax,word ptr es:[Sig]
|
||||
cmp ax,'ZM'
|
||||
jne ExeLoader_End
|
||||
|
||||
jmp EL_GoOn1
|
||||
|
||||
ExeLoader_End1:
|
||||
jmp ExeLoader_End
|
||||
|
||||
EL_GoOn1:
|
||||
;Alloca il resto della memoria...ecc. ecc.
|
||||
|
||||
push es
|
||||
call EL_AllocateMemory
|
||||
pop es
|
||||
call BuildPsp
|
||||
call LoadRelocs
|
||||
|
||||
mov dx,word ptr es:[HeadSize]
|
||||
|
||||
mov ax,es
|
||||
add ax,dx
|
||||
add es:[DispSs],ax
|
||||
add es:[DispCs],ax
|
||||
|
||||
mov bl,0
|
||||
call RunExeProcess
|
||||
|
||||
jmp ExeLoader_End
|
||||
|
||||
ExeLoader_Error:
|
||||
mov si,offset EL_ErrorMsg
|
||||
call WriteSimple
|
||||
|
||||
ExeLoader_End:
|
||||
pop es
|
||||
pop di
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
EL_AllocateMemory:
|
||||
;Alloca il resto della memoria
|
||||
mov dx,word ptr es:[MinAlloc]
|
||||
shr dx,6 ;Convert it in Kbytes
|
||||
push dx
|
||||
call MemAlloc
|
||||
pop dx
|
||||
add word ptr cs:[EL_MemoryAllocated],dx
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
BuildPsp:
|
||||
;input ES --> segment where the program will be stored
|
||||
;The PSP will start at ES:100h
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
LoadRelocs:
|
||||
test word ptr es:[Relocs],-1
|
||||
jz LoadRelocs_End
|
||||
|
||||
push ds
|
||||
push si
|
||||
|
||||
mov dx,es
|
||||
add dx,word ptr es:[HeadSize] ;DX contiene il segmento a partire dal
|
||||
;quale Š memorizzato il codice
|
||||
mov di,word ptr es:[RelocOfs] ;DI=offset della relocation table
|
||||
mov cx,word ptr es:[Relocs] ;CX=numero di relocation items
|
||||
|
||||
LoadRelocs_Loop1:
|
||||
mov ax,word ptr es:[di+2] ;carica il segmento
|
||||
add ax,dx ;aggiunge il "base segment"
|
||||
mov ds,ax
|
||||
mov si,word ptr es:[di] ;SI=offset
|
||||
add word ptr ds:[si],dx
|
||||
add di,4
|
||||
loop LoadRelocs_Loop1
|
||||
|
||||
pop si
|
||||
pop ds
|
||||
|
||||
LoadRelocs_End:
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
RunExeProcess:
|
||||
; BL=0 --> rende visibile il processo (normale)
|
||||
; BL=1 --> non rende visibile il processo
|
||||
|
||||
;Questa procedura Š un po' incasinata...
|
||||
|
||||
push ax
|
||||
push si
|
||||
pushf
|
||||
|
||||
pushf
|
||||
cli
|
||||
|
||||
;Cerca un posto libero nella "ProcessList"
|
||||
mov si,0ffffh
|
||||
RunExeProcess_Loop1:
|
||||
inc si
|
||||
cmp si,(MaxProcess)
|
||||
jae RunExeProcess_Error1
|
||||
mov al,byte ptr cs:[ProcessList+si]
|
||||
test al,al
|
||||
jnz RunExeProcess_Loop1
|
||||
|
||||
;Ora in SI ho il numero del primo processo libero...
|
||||
|
||||
mov al,1
|
||||
mov byte ptr cs:[ProcessList+si],al ;"occupa" il posto nella ProcessList
|
||||
|
||||
test bl,bl
|
||||
jnz RunExeProcess_DontSetVisible ;Nuova opzione: se BL=1 allora il
|
||||
;processo non viene reso visibile
|
||||
;(utile per processi come i driver)
|
||||
|
||||
mov ah,02h ;rende visibile il processo
|
||||
int 24h
|
||||
|
||||
RunExeProcess_DontSetVisible:
|
||||
add si,si
|
||||
|
||||
jmp RunExeProcess_2
|
||||
|
||||
RunExeProcess_Error1:
|
||||
popf
|
||||
popf
|
||||
pop si
|
||||
pop ax
|
||||
ret
|
||||
|
||||
RunExeProcess_2:
|
||||
|
||||
push si
|
||||
mov ax,es
|
||||
|
||||
add si,si ;Salva in ProcessMemory la memoria occupata
|
||||
mov word ptr cs:[ProcessMemory+si],ax ;dal programma
|
||||
|
||||
mov ax,word ptr cs:[EL_MemoryAllocated]
|
||||
mov word ptr cs:[ProcessMemory+si+2],ax
|
||||
pop si
|
||||
|
||||
mov dx,word ptr es:[BaseSp]
|
||||
sub dx,6
|
||||
mov word ptr cs:[P_Sp+si],dx ;Salva SP iniziale (importante!)
|
||||
|
||||
mov ax,word ptr es:[DispSs]
|
||||
mov word ptr cs:[P_Ss+si],ax ;setta i valori dei segment registers
|
||||
mov ax,es
|
||||
mov ax,word ptr es:[DispCs] ;sistema il valore di DS iniziale
|
||||
sub ax,10h
|
||||
mov word ptr cs:[P_Ds+si],ax
|
||||
mov ax,es
|
||||
mov word ptr cs:[P_Es+si],ax
|
||||
xor ax,ax
|
||||
mov word ptr cs:[P_Ax+si],ax ;setta a 0 gli altri registri
|
||||
mov word ptr cs:[P_Bx+si],ax
|
||||
mov word ptr cs:[P_Cx+si],ax
|
||||
mov word ptr cs:[P_Dx+si],ax
|
||||
mov word ptr cs:[P_Bp+si],ax
|
||||
mov word ptr cs:[P_Si+si],ax
|
||||
mov word ptr cs:[P_Di+si],ax
|
||||
|
||||
pop ax ;salva nello stack del processo i flags,
|
||||
or ax,0000001000000000b ;abilita l'interrupt flag
|
||||
|
||||
push ds
|
||||
push si
|
||||
mov si,word ptr es:[DispSs]
|
||||
mov ds,si ;prepara lo Stack Segment
|
||||
|
||||
mov si,dx
|
||||
|
||||
|
||||
mov word ptr ds:[si+4],ax
|
||||
mov ax,word ptr es:[DispCs]
|
||||
mov word ptr ds:[si+2],ax
|
||||
mov ax,word ptr es:[BaseIp]
|
||||
mov word ptr ds:[si],ax
|
||||
|
||||
pop si
|
||||
pop ds
|
||||
|
||||
popf
|
||||
pop si
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
EL_FileHandler dw ?
|
||||
EL_ErrorMsg db 13,10,'An error occurred while opening the EXE file.',13,10,0
|
||||
EL_SizeInBytes dd ?
|
||||
EL_MemoryAllocated dw ?
|
||||
|
191
MEMMANAG.ASM
Normal file
191
MEMMANAG.ASM
Normal file
|
@ -0,0 +1,191 @@
|
|||
;Memory management module
|
||||
|
||||
StartSector equ 2000h
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
MemInit:
|
||||
push ax
|
||||
push cx
|
||||
push si
|
||||
xor ax,ax
|
||||
mov cx,MaxKBytes
|
||||
xor si,si
|
||||
MemInit_1:
|
||||
mov byte ptr cs:[MemoryTable+si],al
|
||||
inc si
|
||||
loop MemInit_1
|
||||
pop si
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
MemAlloc:
|
||||
;input DX=# di kbytes che servono
|
||||
;output ES=segmento a partire dal quale la memoria Š disponibile.
|
||||
|
||||
test dx,dx ;Non si possono allocare 0 Kbyes!
|
||||
jz MemAlloc_End
|
||||
|
||||
push si
|
||||
push cx
|
||||
push ax
|
||||
|
||||
call GetFreeMem ;Guarda se i Kbytes richiesti sono disponibili
|
||||
cmp cx,dx
|
||||
jb MemAlloc_NotFound2
|
||||
|
||||
xor si,si
|
||||
push dx
|
||||
|
||||
MemAlloc_1:
|
||||
;Cerca un Kbytes libero nella "MemoryTable"
|
||||
mov al,cs:[MemoryTable+si]
|
||||
test al,al
|
||||
jnz MemAlloc_GoOn
|
||||
dec dx
|
||||
jz MemAlloc_Found
|
||||
inc si
|
||||
cmp si,MaxKbytes
|
||||
jne MemAlloc_1
|
||||
jmp MemAlloc_NotFound
|
||||
|
||||
MemAlloc_GoOn:
|
||||
pop dx
|
||||
push dx
|
||||
inc si
|
||||
cmp si,MaxKbytes
|
||||
jb MemAlloc_1
|
||||
|
||||
MemAlloc_NotFound:
|
||||
pop dx
|
||||
MemAlloc_NotFound2:
|
||||
mov ax,0a000h
|
||||
mov es,ax
|
||||
|
||||
pop ax
|
||||
pop cx
|
||||
pop si
|
||||
|
||||
ret
|
||||
|
||||
MemAlloc_Found:
|
||||
pop dx
|
||||
sub si,dx ;Si riporta al primo valore libero
|
||||
inc si
|
||||
|
||||
push si
|
||||
|
||||
mov al,1
|
||||
MemAlloc_2:
|
||||
mov byte ptr cs:[MemoryTable+si],al
|
||||
inc si
|
||||
dec dx
|
||||
jnz MemAlloc_2
|
||||
|
||||
pop si
|
||||
|
||||
mov cl,6 ;Converte il valore ottenuto in un segmento
|
||||
shl si,cl
|
||||
add si,StartSector
|
||||
mov es,si
|
||||
|
||||
pop ax
|
||||
pop cx
|
||||
pop si
|
||||
|
||||
MemAlloc_End:
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
|
||||
MemFree:
|
||||
;input DX=# di kbytes da liberare
|
||||
; ES=segmento a partire dal quale la memoria deve essere liberata
|
||||
; (deve essere multiplo di 40h)
|
||||
|
||||
|
||||
;Ora la procedura funziona correttamente...
|
||||
|
||||
test dx,dx
|
||||
jz MemFree_End2
|
||||
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push si
|
||||
|
||||
mov si,es
|
||||
sub si,StartSector
|
||||
mov cl,6
|
||||
shr si,cl
|
||||
|
||||
|
||||
mov al,0
|
||||
MemFree_1:
|
||||
mov byte ptr cs:[MemoryTable+si],al
|
||||
inc si
|
||||
dec dx
|
||||
jnz MemFree_1
|
||||
|
||||
MemFree_End:
|
||||
pop si
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
MemFree_End2:
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GetFreeMem:
|
||||
;input: no input
|
||||
;output: CX=numero massimo di Kbytes contigui liberi che ha trovato
|
||||
|
||||
push ax
|
||||
push dx
|
||||
push si
|
||||
|
||||
xor si,si
|
||||
xor cx,cx
|
||||
xor dx,dx
|
||||
|
||||
GetFreeMem_Again1:
|
||||
mov al,byte ptr cs:[MemoryTable+si]
|
||||
test al,al
|
||||
jnz GetFreeMem_NotFree
|
||||
inc cx
|
||||
|
||||
GetFreeMem_Again2:
|
||||
inc si
|
||||
cmp si,MaxKBytes
|
||||
jb GetFreeMem_Again1
|
||||
|
||||
cmp cx,dx
|
||||
ja GetFreeMem_Fine2
|
||||
|
||||
GetFreeMem_Fine:
|
||||
mov cx,dx
|
||||
GetFreeMem_Fine2:
|
||||
pop si
|
||||
pop dx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
GetFreeMem_NotFree:
|
||||
cmp cx,dx
|
||||
jbe GetFreeMem_NotFree2
|
||||
mov dx,cx
|
||||
|
||||
GetFreeMem_NotFree2:
|
||||
xor cx,cx
|
||||
jmp GetFreeMem_Again2
|
||||
|
||||
;------------------------------------------------------------------------------
|
BIN
PARTCOPY.EXE
Normal file
BIN
PARTCOPY.EXE
Normal file
Binary file not shown.
557
PROCESSI.ASM
Normal file
557
PROCESSI.ASM
Normal file
|
@ -0,0 +1,557 @@
|
|||
MaxProcess equ 7
|
||||
|
||||
;MULTITASKER
|
||||
|
||||
;Procedure "pubbliche":
|
||||
|
||||
;1) StartMultiTasking (no input, no output)
|
||||
;2) LoadProgram
|
||||
; Input: CS:SI --> nome del file che contiene il programma
|
||||
; Output: ES:DI --> indirizzo a partire dal quale Š stato memorizzato il codice
|
||||
;3) RunProcess (da chiamare subito dopo LoadProgram per iniziare l'esecuzione
|
||||
; del processo)
|
||||
;4) KillProcess
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
StartMultiTasking:
|
||||
mov word ptr cs:[CurrentProg],0
|
||||
mov al,1
|
||||
mov byte ptr cs:[ProcessList],al
|
||||
|
||||
pushf
|
||||
cli
|
||||
call InstallTimerInt
|
||||
popf
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
EndMultiTasking:
|
||||
push ax
|
||||
push es
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,word ptr cs:[oldint]
|
||||
mov es:[(1ch*4)],ax
|
||||
|
||||
mov ax,word ptr cs:[oldint+2]
|
||||
mov es:[(1ch*4+2)],ax
|
||||
|
||||
pop es
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GetProcessInfo:
|
||||
;No input
|
||||
;Output: SI --> [CurrentProg] (processo corrente)
|
||||
; CX --> [VisibleProcess]
|
||||
|
||||
mov si,word ptr cs:[CurrentProg]
|
||||
mov cx,word ptr cs:[VisibleProcess]
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
SetVisibleProcess:
|
||||
;input SI --> numero del processo da rendere visibile
|
||||
push ax
|
||||
|
||||
mov al,byte ptr cs:[ProcessList+si]
|
||||
test al,al
|
||||
jz SetVisibleProcess_End
|
||||
|
||||
mov word ptr cs:[VisibleProcess],si
|
||||
|
||||
SetVisibleProcess_End:
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GetNextProcess:
|
||||
;output SI --> processo attivo successivo al processo corrente
|
||||
;esempio sono attivi i processi 0 e 1, ed Š visibile il processo 1.
|
||||
;In questo caso, GetNextProcess restituir… 0.
|
||||
|
||||
push ax
|
||||
|
||||
mov si,word ptr cs:[CurrentProg]
|
||||
|
||||
GetNextProcess_ScanList:
|
||||
inc si
|
||||
GetNextProcess_ScanList2:
|
||||
mov al,byte ptr cs:[ProcessList+si]
|
||||
cmp si,(MaxProcess)
|
||||
je GetNextProcess_RestartScan
|
||||
test al,al
|
||||
jz GetNextProcess_ScanList
|
||||
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
GetNextProcess_RestartScan:
|
||||
xor si,si
|
||||
jmp GetNextProcess_ScanList2
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
LoadProgram:
|
||||
;input DS:SI nome del file che contiene il programma
|
||||
;output ES:DI indirizzo a partire dal quale Š stato memorizzato il codice
|
||||
; DX=Memoria allocata per il programma (in Kbytes)
|
||||
|
||||
cli
|
||||
|
||||
push ax
|
||||
|
||||
call Fat12_OpenFile ;apre il file
|
||||
jc LoadProgram_Error
|
||||
call Fat12_GetFileSize ;ottiene la grandezza del file
|
||||
|
||||
mov dx,ax
|
||||
|
||||
mov cl,10
|
||||
shr dx,cl ;DX=DX/1024
|
||||
add dx,2 ;Calcola la memoria da allocare (alloca 2kb in pi—
|
||||
;necessari per lo stack)
|
||||
|
||||
push dx
|
||||
|
||||
call MemAlloc
|
||||
|
||||
mov dx,ax
|
||||
xor di,di
|
||||
push es
|
||||
push di
|
||||
|
||||
; xor di,di
|
||||
call Fat12_ReadFile ;legge il file
|
||||
call Fat12_CloseFile ;chiude il file
|
||||
|
||||
pop di
|
||||
pop es
|
||||
pop dx
|
||||
|
||||
pop ax
|
||||
sti
|
||||
|
||||
ret
|
||||
|
||||
LoadProgram_Error:
|
||||
sti
|
||||
xor dx,dx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;RealDS dw 0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
LoadComProgram:
|
||||
;input DS:SI nome del file
|
||||
; DS:BX parametri
|
||||
;output ES:DI indirizzo a partire dal quale Š memorizzato il codice
|
||||
; (per default DI=100h)
|
||||
; DX memoria allocata per il programma (in kbytes)
|
||||
|
||||
;Da aggiungere: costruzione del PSP (program segment prefix)
|
||||
|
||||
cli
|
||||
|
||||
push ax
|
||||
|
||||
call Fat12_OpenFile
|
||||
jc LoadComProgram_Error
|
||||
|
||||
mov dx,64 ;per avere completa compatibilit… con il formato "com"
|
||||
;del dos, alloco 64 Kb di memoria
|
||||
|
||||
push dx
|
||||
|
||||
call MemAlloc ;alloca 64 kb di memoria
|
||||
|
||||
call Fat12_GetFileSize
|
||||
mov dx,ax
|
||||
|
||||
push bx
|
||||
push cx
|
||||
|
||||
mov di,80h
|
||||
mov cx,80h
|
||||
|
||||
LoadComProgram_LoadParameters:
|
||||
mov al,byte ptr ds:[bx]
|
||||
mov byte ptr es:[di],al
|
||||
inc bx
|
||||
inc di
|
||||
loop LoadComProgram_LoadParameters
|
||||
|
||||
pop cx
|
||||
pop bx
|
||||
|
||||
|
||||
mov di,100h ;offset iniziale 100h
|
||||
push es
|
||||
push di
|
||||
|
||||
call Fat12_ReadFile ;memorizza il file a partire da ES:[100h]
|
||||
call Fat12_CloseFile
|
||||
|
||||
pop di
|
||||
pop es
|
||||
pop dx
|
||||
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
LoadComProgram_Error:
|
||||
xor dx,dx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
RunProcess:
|
||||
;Fa in modo che un processo, gi… caricato in memoria, sia eseguito.
|
||||
;input ES:DI=segment:offset di partenza del processo.
|
||||
; DX=memoria allocata per il programma
|
||||
; BL=0 --> rende visibile il processo (normale)
|
||||
; BL=1 --> non rende visibile il processo
|
||||
;La procedura setta P_Ds, P_Es, P_Ss del processo uguali a ES.
|
||||
;P_Sp del processo = 0fffah
|
||||
;Gli altri registri = 0
|
||||
;Flags = indefiniti
|
||||
;
|
||||
;Carica nello stack del processo i flags, il segmento e l'offset del processo
|
||||
;cos<6F> l'interrupt del timer sa dove tornare con IRET.
|
||||
;Rende visibile il processo caricato.
|
||||
|
||||
;Questa procedura Š un po' incasinata...
|
||||
|
||||
push ax
|
||||
push si
|
||||
pushf
|
||||
|
||||
pushf
|
||||
cli
|
||||
|
||||
;Cerca un posto libero nella "ProcessList"
|
||||
mov si,0ffffh
|
||||
RunProcess_Loop1:
|
||||
inc si
|
||||
cmp si,(MaxProcess)
|
||||
jae RunProcess_Error1
|
||||
mov al,byte ptr cs:[ProcessList+si]
|
||||
test al,al
|
||||
jnz RunProcess_Loop1
|
||||
|
||||
;Ora in SI ho il numero del primo processo libero...
|
||||
|
||||
mov al,1
|
||||
mov byte ptr cs:[ProcessList+si],al ;"occupa" il posto nella ProcessList
|
||||
|
||||
test bl,bl
|
||||
jnz RunProcess_DontSetVisible ;Nuova opzione: se BL=1 allora il
|
||||
;processo non viene reso visibile
|
||||
;(utile per processi come i driver)
|
||||
|
||||
mov ah,02h ;rende visibile il processo
|
||||
int 24h
|
||||
|
||||
RunProcess_DontSetVisible:
|
||||
add si,si
|
||||
|
||||
jmp RunProcess_2
|
||||
|
||||
RunProcess_Error1:
|
||||
popf
|
||||
popf
|
||||
pop si
|
||||
pop ax
|
||||
ret
|
||||
|
||||
RunProcess_2:
|
||||
|
||||
push si
|
||||
mov ax,es
|
||||
|
||||
add si,si ;Salva in ProcessMemory la memoria occupata
|
||||
mov word ptr cs:[ProcessMemory+si],ax ;dal programma
|
||||
|
||||
mov ax,dx
|
||||
|
||||
mov word ptr cs:[ProcessMemory+si+2],ax
|
||||
pop si
|
||||
|
||||
push cx
|
||||
mov cl,10
|
||||
shl dx,cl ;DX=DX*1024
|
||||
sub dx,6 ;Calcola la posizione iniziale di SP
|
||||
pop cx
|
||||
|
||||
mov word ptr cs:[P_Sp+si],dx ;Salva SP iniziale (importante!)
|
||||
|
||||
mov ax,es
|
||||
mov word ptr cs:[P_Ss+si],ax ;setta i valori dei segment registers
|
||||
mov word ptr cs:[P_Ds+si],ax
|
||||
mov word ptr cs:[P_Es+si],ax
|
||||
xor ax,ax
|
||||
mov word ptr cs:[P_Ax+si],ax ;setta a 0 gli altri registri
|
||||
mov word ptr cs:[P_Bx+si],ax
|
||||
mov word ptr cs:[P_Cx+si],ax
|
||||
mov word ptr cs:[P_Dx+si],ax
|
||||
mov word ptr cs:[P_Bp+si],ax
|
||||
mov word ptr cs:[P_Si+si],ax
|
||||
mov word ptr cs:[P_Di+si],ax
|
||||
|
||||
pop ax ;salva nello stack del processo i flags,
|
||||
or ax,0000001000000000b ;abilita l'interrupt flag
|
||||
|
||||
push si
|
||||
mov si,dx
|
||||
|
||||
mov word ptr es:[si+4],ax
|
||||
mov ax,es
|
||||
mov word ptr es:[si+2],ax
|
||||
mov word ptr es:[si],di
|
||||
|
||||
pop si
|
||||
|
||||
popf
|
||||
pop si
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
KillProcess:
|
||||
;Elimina dalla lista di esecuzione il processo puntato da cs:[CurrentProg]
|
||||
;Input BL = 0 --> Libera la memoria occupata dal programma
|
||||
; BL = 1 --> Non libera la memoria (Terminate and stay resident)
|
||||
|
||||
cli ;meglio disabilitare gli interrupt...
|
||||
|
||||
mov ah,04h ;"ClearScreen": cancella lo schermo del processo
|
||||
int 24h ;da terminare
|
||||
|
||||
mov si,word ptr cs:[CurrentProg]
|
||||
|
||||
mov al,0
|
||||
mov byte ptr cs:[ProcessList+si],al
|
||||
|
||||
cmp si,word ptr cs:[VisibleProcess]
|
||||
jne KillProcess_2 ;se il processo non Š visibile, lo termina
|
||||
;direttamente
|
||||
|
||||
;se invece il processo Š visibile, allora ne deve cercare un altro
|
||||
;da rendere visibile
|
||||
|
||||
push si
|
||||
|
||||
KillProcess_NextVisibleProcess:
|
||||
;cerca il prossimo processo visibile
|
||||
dec si
|
||||
cmp si,0ffffh
|
||||
je KillProcess_1
|
||||
mov al,byte ptr cs:[ProcessList+si]
|
||||
test al,al
|
||||
jz KillProcess_NextVisibleProcess
|
||||
|
||||
mov ah,02h
|
||||
int 24h ;Attenzione, il driver video dev'essere presente!
|
||||
|
||||
pop si
|
||||
|
||||
;controlla se c'Š un solo processo disponibile: in questo caso, infatti,
|
||||
;non viene terminato. Se viene terminato l'ultimo processo disponibile,
|
||||
;il sistema va in crash...
|
||||
|
||||
jmp KillProcess_2
|
||||
|
||||
KillProcess_1:
|
||||
mov si,(MaxProcess)
|
||||
jmp KillProcess_NextVisibleProcess
|
||||
|
||||
|
||||
KillProcess_2:
|
||||
;controlla se BL=0...se non Š zero, allora la memoria del processo
|
||||
;non viene liberata (Terminate and Stay Resident).
|
||||
test bl,bl
|
||||
jnz KillProcess_3
|
||||
|
||||
add si,si ;SI=SI*4
|
||||
add si,si
|
||||
|
||||
mov ax,word ptr cs:[ProcessMemory+si]
|
||||
mov es,ax
|
||||
mov dx,word ptr cs:[ProcessMemory+si+2]
|
||||
|
||||
call MemFree ;libera la memoria occupata dal programma
|
||||
|
||||
KillProcess_3:
|
||||
sti
|
||||
|
||||
KillProcess_End:
|
||||
jmp KillProcess_End ;jmp infinito finchŠ non si verifica un
|
||||
;timer interrupt (che toglie definitivamente
|
||||
;l'esecuzione al processo).
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
InstallTimerInt:
|
||||
push ax
|
||||
push es
|
||||
push di
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov di,(1ch*4)
|
||||
mov ax,word ptr es:[di]
|
||||
mov word ptr cs:[oldint],ax
|
||||
mov ax,offset TimerInt
|
||||
mov word ptr es:[di],ax
|
||||
|
||||
add di,2
|
||||
mov ax,word ptr es:[di]
|
||||
mov word ptr cs:[oldint+2],ax
|
||||
mov ax,cs
|
||||
mov word ptr es:[di],ax
|
||||
pop di
|
||||
pop es
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
TimerInt:
|
||||
|
||||
;salva tutti i registri tranne CS e IP, perchŠ tanto CS e IP sono gi…
|
||||
;salvati nello stack del programma chiamante.
|
||||
|
||||
mov word ptr cs:[temp_si],si
|
||||
mov si,word ptr cs:[currentprog]
|
||||
add si,si
|
||||
|
||||
mov word ptr cs:[p_ax+si],ax
|
||||
mov word ptr cs:[p_bx+si],bx
|
||||
mov word ptr cs:[p_cx+si],cx
|
||||
mov word ptr cs:[p_dx+si],dx
|
||||
mov word ptr cs:[p_di+si],di
|
||||
mov ax,ds
|
||||
mov word ptr cs:[p_ds+si],ax
|
||||
mov ax,es
|
||||
mov word ptr cs:[p_es+si],ax
|
||||
mov ax,ss
|
||||
mov word ptr cs:[p_ss+si],ax
|
||||
mov word ptr cs:[p_sp+si],sp
|
||||
mov word ptr cs:[p_bp+si],bp
|
||||
mov di,si
|
||||
mov ax,word ptr cs:[temp_si]
|
||||
mov word ptr cs:[p_si+di],ax
|
||||
|
||||
|
||||
;Ora cerca nella ProcessList il prossimo processo da attivare
|
||||
shr si,1 ;lavoro in byte
|
||||
; xor cx,cx
|
||||
goon_1:
|
||||
inc si
|
||||
goon_12:
|
||||
; inc cx
|
||||
; cmp cx,(MaxProcess+1)
|
||||
; je TimerInt_EndSystem
|
||||
mov al,byte ptr cs:[ProcessList+si]
|
||||
cmp si,(MaxProcess)
|
||||
jb TimerInt_TestAl
|
||||
|
||||
xor si,si
|
||||
jmp goon_12
|
||||
|
||||
TimerInt_TestAl:
|
||||
test al,al
|
||||
jz goon_1
|
||||
|
||||
|
||||
;Ora in SI ho il numero del processo da eseguire
|
||||
|
||||
goon_2:
|
||||
mov word ptr cs:[CurrentProg],si
|
||||
|
||||
add si,si ;lavoro in word
|
||||
|
||||
mov bx,word ptr cs:[p_bx+si]
|
||||
mov cx,word ptr cs:[p_cx+si]
|
||||
mov dx,word ptr cs:[p_dx+si]
|
||||
mov di,word ptr cs:[p_di+si]
|
||||
mov ax,word ptr cs:[p_ds+si]
|
||||
mov ds,ax
|
||||
mov ax,word ptr cs:[p_es+si]
|
||||
mov es,ax
|
||||
mov ax,word ptr cs:[p_ss+si]
|
||||
mov ss,ax
|
||||
mov sp,word ptr cs:[p_sp+si]
|
||||
mov bp,word ptr cs:[p_bp+si]
|
||||
mov ax,word ptr cs:[p_ax+si]
|
||||
mov si,word ptr cs:[p_si+si]
|
||||
|
||||
TimerInt_End:
|
||||
|
||||
push ax
|
||||
mov al,20h
|
||||
out 20h,al
|
||||
pop ax
|
||||
|
||||
iret
|
||||
|
||||
TimerInt_EndSystem:
|
||||
call EndSystem
|
||||
|
||||
temp_si dw 0
|
||||
|
||||
;---------------------------------
|
||||
|
||||
p_ax dw MaxProcess dup 0
|
||||
p_bx dw MaxProcess dup 0
|
||||
p_cx dw MaxProcess dup 0
|
||||
p_dx dw MaxProcess dup 0
|
||||
p_si dw MaxProcess dup 0
|
||||
p_di dw MaxProcess dup 0
|
||||
p_ds dw MaxProcess dup 0
|
||||
p_es dw MaxProcess dup 0
|
||||
p_ss dw MaxProcess dup 0
|
||||
p_sp dw MaxProcess dup 0
|
||||
p_bp dw MaxProcess dup 0
|
||||
|
||||
CurrentProg dw 0 ;indica il processo che Š attivo
|
||||
VisibleProcess dw 0 ;indica il processo che Š visibile
|
||||
|
||||
ProcessList db MaxProcess dup 0
|
||||
|
||||
ProcessMemory dd MaxProcess dup 0 ;indica la memoria occupata da ogni
|
||||
;programma. La prima word indica il segmento (e si presuppone
|
||||
;che l'offset sia 0), la seconda word indica la quantit…
|
||||
;di memoria occupata in kbytes.
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GoToNextProcess:
|
||||
;Questa procedura serve al sistema operativo...ad esempio nel driver della
|
||||
;tastiera: se un processo NON visibile ha chiesto un tasto e lo sta attendendo,
|
||||
;finchŠ non Š visibile spreca solo risorse, quindi il driver della tastiera
|
||||
;chiama questa funzione per passare al processo successivo.
|
||||
cli
|
||||
int 1ch
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
oldint dd ?
|
||||
longadr dd ?
|
115
PROGRAMS/ALBLUR/ALBLUR.ASM
Normal file
115
PROGRAMS/ALBLUR/ALBLUR.ASM
Normal file
|
@ -0,0 +1,115 @@
|
|||
;Coded by: Albe
|
||||
;-albe-@libero.it
|
||||
;"Al-blur" written for #asm 128 bytes competition
|
||||
;
|
||||
;2/11/2000
|
||||
;
|
||||
|
||||
org 0h
|
||||
|
||||
main:
|
||||
mov al,13h ;set vga mode 13h
|
||||
int 10h
|
||||
|
||||
mov dx,3c9h ;palette register
|
||||
;this palette routine only affects color >= 13, but i don't care...
|
||||
palette3:
|
||||
dec dx ;dec and inc save some bytes instead of
|
||||
;"mov dx,3c9h", "mov dx,3c8h"
|
||||
out dx,al
|
||||
inc dx
|
||||
push ax ;saves ax
|
||||
xor al,al
|
||||
out dx,al ;don't set red...
|
||||
out dx,al ;don't set green!
|
||||
pop ax
|
||||
push ax
|
||||
cmp al,210 ;the first 210 colors are the same (dark blu)
|
||||
ja pal5
|
||||
mov al,15 ;set dark blu (15)
|
||||
pal5:
|
||||
out dx,al ;set blu
|
||||
pop ax
|
||||
inc al
|
||||
jnz palette3
|
||||
|
||||
mov ah,00h
|
||||
mov dx,64
|
||||
int 23h ;allocate memory
|
||||
|
||||
push es
|
||||
pop ds
|
||||
|
||||
mov ax,0a000h
|
||||
mov es,ax
|
||||
mov bp,317 ;we need to add 317 to SI 2 times, and using
|
||||
;lea si,[si+bp] is better (saves 1 byte)
|
||||
a2:
|
||||
cbw ;AL here is always 0, so cbw will set AX to 0
|
||||
cwd ;AX here is always 0, so cwd will set DX to 0
|
||||
push si ;save current position
|
||||
sub si,321
|
||||
call loadsb
|
||||
lea si,[si+bp]
|
||||
lodsb
|
||||
add dx,ax
|
||||
inc si
|
||||
lodsb
|
||||
add dx,ax
|
||||
lea si,[si+bp]
|
||||
call loadsb
|
||||
pop si
|
||||
|
||||
shr dx,3 ;calculate the average of pixels around
|
||||
inc dx ;2 "inc"s save 1 byte (instead of add dx,2)
|
||||
inc dx
|
||||
a4:
|
||||
mov byte ptr ds:[si],dl ;store the pixel
|
||||
inc si
|
||||
jnz a2
|
||||
|
||||
mov dx,3dah ;this is waitretrace
|
||||
l1:
|
||||
in al,dx
|
||||
and al,08h
|
||||
jnz l1
|
||||
l2:
|
||||
in al,dx
|
||||
and al,08h
|
||||
jz l2
|
||||
|
||||
mov cx,0ffffh/2+1
|
||||
rep movsw ;copy mem to mem
|
||||
|
||||
mov ah,11h
|
||||
int 16h ;key pressed?
|
||||
jz a2
|
||||
|
||||
mov ah,00h
|
||||
int 16h
|
||||
|
||||
push ds ;free mem
|
||||
pop es
|
||||
mov dx,64
|
||||
mov ah,01h
|
||||
int 23h
|
||||
|
||||
mov ax,0003h
|
||||
int 10h
|
||||
|
||||
mov ah,02h
|
||||
mov bl,0
|
||||
int 20h
|
||||
|
||||
|
||||
|
||||
|
||||
loadsb proc
|
||||
lodsb
|
||||
add dx,ax
|
||||
lodsb
|
||||
add dx,ax
|
||||
lodsb
|
||||
add dx,ax
|
||||
ret
|
||||
loadsb endp
|
BIN
PROGRAMS/ALBLUR/ALBLUR.BIN
Normal file
BIN
PROGRAMS/ALBLUR/ALBLUR.BIN
Normal file
Binary file not shown.
BIN
PROGRAMS/ALBLUR/ALBLUR.SYM
Normal file
BIN
PROGRAMS/ALBLUR/ALBLUR.SYM
Normal file
Binary file not shown.
BIN
PROGRAMS/FIRE/ELINK.EXE
Normal file
BIN
PROGRAMS/FIRE/ELINK.EXE
Normal file
Binary file not shown.
53
PROGRAMS/FIRE/GRAPH32.ASM
Normal file
53
PROGRAMS/FIRE/GRAPH32.ASM
Normal file
|
@ -0,0 +1,53 @@
|
|||
.386
|
||||
|
||||
Code segment
|
||||
assume cs:Code
|
||||
|
||||
Main proc
|
||||
mov ah,03h
|
||||
mov dx,64
|
||||
int 2fh
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
|
||||
mov ax,0401h
|
||||
mov cx,32768
|
||||
push edi
|
||||
|
||||
Main1:
|
||||
mov es:[edi],ax
|
||||
add edi,2
|
||||
loop Main1
|
||||
|
||||
pop edi
|
||||
|
||||
mov ax,0013h
|
||||
int 10h
|
||||
|
||||
mov esi,0a0000h
|
||||
|
||||
mov cx,32768
|
||||
|
||||
Main2:
|
||||
mov ax,es:[edi]
|
||||
mov es:[esi],ax
|
||||
add edi,2
|
||||
add esi,2
|
||||
loop Main2
|
||||
|
||||
mov ah,00h
|
||||
int 25h
|
||||
|
||||
mov ax,0003h
|
||||
int 10h
|
||||
|
||||
mov ah,02h
|
||||
mov bl,0
|
||||
int 20h
|
||||
|
||||
Main endp
|
||||
|
||||
Code ends
|
||||
|
||||
end
|
BIN
PROGRAMS/FIRE/GRAPH32.BIN
Normal file
BIN
PROGRAMS/FIRE/GRAPH32.BIN
Normal file
Binary file not shown.
191
PROGRAMS/FIRE/MYFIRE.ASM
Normal file
191
PROGRAMS/FIRE/MYFIRE.ASM
Normal file
|
@ -0,0 +1,191 @@
|
|||
;Fire effect for NXOS
|
||||
org 0h
|
||||
|
||||
main:
|
||||
mov al,13h
|
||||
int 10h
|
||||
xor cx,cx
|
||||
p1:
|
||||
mov ah,cl
|
||||
mov bh,cl
|
||||
shr bh,2
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,11
|
||||
jne p1
|
||||
|
||||
p2:
|
||||
mov ah,cl
|
||||
mov bh,4
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,21
|
||||
jne p2
|
||||
|
||||
p3:
|
||||
mov ah,cl
|
||||
mov bl,cl
|
||||
sub bl,20
|
||||
mov bh,4
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,64
|
||||
jne p3
|
||||
|
||||
p4:
|
||||
mov ah,63
|
||||
mov bl,cl
|
||||
sub bl,20
|
||||
mov bh,2
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,84
|
||||
jne p4
|
||||
|
||||
p5:
|
||||
mov bl,63
|
||||
xor bh,bh
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,101
|
||||
jne p5
|
||||
|
||||
p6:
|
||||
mov bh,63
|
||||
call setpal
|
||||
inc cl
|
||||
test cl,cl
|
||||
jne p6
|
||||
|
||||
setseg:
|
||||
; mov ax,8000h ;some free memory...somewhere...
|
||||
; mov es,ax
|
||||
; mov cx,32000 ;let's free this mem!
|
||||
|
||||
mov dx,64 ;allocate memory
|
||||
mov ah,00h
|
||||
int 23h
|
||||
|
||||
xor di,di
|
||||
|
||||
mov ch,7dh
|
||||
xor ax,ax
|
||||
rep stosw ;free it
|
||||
push es
|
||||
pop ds
|
||||
mov ax,0a000h
|
||||
mov es,ax
|
||||
|
||||
l0:
|
||||
mov cx,220
|
||||
l1:
|
||||
push cx
|
||||
mov bx,320
|
||||
call random
|
||||
pop cx
|
||||
l2:
|
||||
add ax,64320
|
||||
mov si,ax
|
||||
mov al,255
|
||||
mov ds:[si],al
|
||||
dec cx
|
||||
jnz l1
|
||||
|
||||
xor si,si
|
||||
fireup: ;the fire algorythm
|
||||
xor ax,ax
|
||||
; cwd
|
||||
xor dx,dx ;xor is faster...
|
||||
mov al,byte ptr ds:[si-640]
|
||||
add dx,ax
|
||||
mov al,byte ptr ds:[si-1]
|
||||
add dx,ax
|
||||
mov al,byte ptr ds:[si+1]
|
||||
add dx,ax
|
||||
mov al,byte ptr ds:[si+320]
|
||||
add dx,ax
|
||||
shr dx,2
|
||||
mov byte ptr ds:[si-320],dl
|
||||
mov byte ptr ds:[si-640],dl
|
||||
inc si
|
||||
jnz fireup
|
||||
|
||||
mov cx,((64000-960)/2)
|
||||
f1:
|
||||
mov ax,word ptr ds:[si]
|
||||
mov word ptr es:[si],ax
|
||||
add si,2
|
||||
dec cx
|
||||
jnz f1
|
||||
|
||||
mov ah,11h
|
||||
int 16h
|
||||
jz l0
|
||||
|
||||
mov ah,00h
|
||||
int 16h
|
||||
|
||||
mov ah,01h
|
||||
mov dx,64
|
||||
push ds
|
||||
pop es
|
||||
int 23h
|
||||
|
||||
mov ax,0003h
|
||||
int 10h
|
||||
|
||||
mov ah,02h
|
||||
mov bl,0
|
||||
int 20h
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
setpal:
|
||||
;input cl=color
|
||||
;ah=red
|
||||
;bl=green
|
||||
;bh=blu
|
||||
mov dx,3c8h
|
||||
mov al,cl
|
||||
out dx,al
|
||||
inc dx
|
||||
mov al,ah
|
||||
out dx,al
|
||||
mov al,bl
|
||||
out dx,al
|
||||
mov al,bh
|
||||
out dx,al
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
random:
|
||||
;input BX=max num
|
||||
push es
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,cs:cont
|
||||
mov cx,cs:a1
|
||||
mov dx,cs:a2
|
||||
add ax,dx
|
||||
add cx,es:[3083]
|
||||
sub dx,es:[3083]
|
||||
add dx,cx
|
||||
mov cs:cont,ax
|
||||
mov cs:a1,cx
|
||||
mov cs:a2,dx
|
||||
and ax,11111111111b
|
||||
l1_r:
|
||||
cmp ax,bx
|
||||
jbe fine_r
|
||||
sub ax,bx
|
||||
jmp l1_r
|
||||
fine_r:
|
||||
pop es
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
a1 dw 10001
|
||||
a2 dw 101
|
||||
cont dw 23923
|
BIN
PROGRAMS/FIRE/MYFIRE.BIN
Normal file
BIN
PROGRAMS/FIRE/MYFIRE.BIN
Normal file
Binary file not shown.
BIN
PROGRAMS/FIRE/MYFIRE.SYM
Normal file
BIN
PROGRAMS/FIRE/MYFIRE.SYM
Normal file
Binary file not shown.
229
PROGRAMS/FIRE/MYFIRE32.ASM
Normal file
229
PROGRAMS/FIRE/MYFIRE32.ASM
Normal file
|
@ -0,0 +1,229 @@
|
|||
.386
|
||||
;Fire effect for NXOS
|
||||
Code segment
|
||||
assume cs:Code
|
||||
|
||||
org 0h
|
||||
|
||||
main proc
|
||||
mov al,13h
|
||||
int 10h
|
||||
xor cx,cx
|
||||
p1:
|
||||
mov ah,cl
|
||||
mov bh,cl
|
||||
shr bh,2
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,11
|
||||
jne p1
|
||||
|
||||
p2:
|
||||
mov ah,cl
|
||||
mov bh,4
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,21
|
||||
jne p2
|
||||
|
||||
p3:
|
||||
mov ah,cl
|
||||
mov bl,cl
|
||||
sub bl,20
|
||||
mov bh,4
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,64
|
||||
jne p3
|
||||
|
||||
p4:
|
||||
mov ah,63
|
||||
mov bl,cl
|
||||
sub bl,20
|
||||
mov bh,2
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,84
|
||||
jne p4
|
||||
|
||||
p5:
|
||||
mov bl,63
|
||||
xor bh,bh
|
||||
call setpal
|
||||
inc cx
|
||||
cmp cx,101
|
||||
jne p5
|
||||
|
||||
p6:
|
||||
mov bh,63
|
||||
call setpal
|
||||
inc cl
|
||||
test cl,cl
|
||||
jne p6
|
||||
|
||||
setseg:
|
||||
; mov ax,8000h ;some free memory...somewhere...
|
||||
; mov es,ax
|
||||
; mov cx,32000 ;let's free this mem!
|
||||
|
||||
; mov dx,64 ;allocate memory
|
||||
; mov ah,00h
|
||||
; int 23h
|
||||
|
||||
mov ah,03h
|
||||
mov dx,64
|
||||
int 2fh
|
||||
|
||||
; xor di,di
|
||||
;
|
||||
; mov ch,7dh
|
||||
; xor ax,ax
|
||||
; rep stosw ;free it
|
||||
; push es
|
||||
; pop ds
|
||||
|
||||
mov cs:[BaseOfst],edi
|
||||
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ds,ax
|
||||
mov cx,32768
|
||||
|
||||
freemem1:
|
||||
mov es:[edi],ax
|
||||
add edi,2
|
||||
loop freemem1
|
||||
|
||||
|
||||
mov ax,0a000h
|
||||
mov es,ax
|
||||
|
||||
xor eax,eax
|
||||
|
||||
l0:
|
||||
mov esi,cs:[BaseOfst]
|
||||
xor edi,edi
|
||||
mov cx,220
|
||||
l1:
|
||||
push cx
|
||||
mov bx,320
|
||||
call random
|
||||
pop cx
|
||||
l2:
|
||||
add ax,64320
|
||||
; mov esi,eax
|
||||
|
||||
push esi
|
||||
add esi,eax
|
||||
mov al,255
|
||||
mov ds:[esi],al
|
||||
pop esi
|
||||
dec cx
|
||||
jnz l1
|
||||
|
||||
xor esi,esi
|
||||
fireup: ;the fire algorythm
|
||||
xor ax,ax
|
||||
; cwd
|
||||
xor dx,dx ;xor is faster...
|
||||
mov al,byte ptr ds:[esi-640]
|
||||
add dx,ax
|
||||
mov al,byte ptr ds:[esi-1]
|
||||
add dx,ax
|
||||
mov al,byte ptr ds:[esi+1]
|
||||
add dx,ax
|
||||
mov al,byte ptr ds:[esi+320]
|
||||
add dx,ax
|
||||
shr dx,2
|
||||
mov byte ptr ds:[esi-320],dl
|
||||
mov byte ptr ds:[esi-640],dl
|
||||
inc esi
|
||||
jnz fireup
|
||||
|
||||
mov cx,((64000-960)/2)
|
||||
f1:
|
||||
mov ax,word ptr ds:[esi]
|
||||
mov word ptr es:[di],ax
|
||||
add esi,2
|
||||
add di,2
|
||||
dec cx
|
||||
jnz f1
|
||||
|
||||
mov ah,11h
|
||||
int 16h
|
||||
jz l0
|
||||
|
||||
mov ah,00h
|
||||
int 16h
|
||||
|
||||
; mov ah,01h
|
||||
; mov dx,64
|
||||
; push ds
|
||||
; pop es
|
||||
; int 23h
|
||||
|
||||
mov ax,0003h
|
||||
int 10h
|
||||
|
||||
mov ah,02h
|
||||
mov bl,0
|
||||
int 20h
|
||||
|
||||
main endp
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
setpal:
|
||||
;input cl=color
|
||||
;ah=red
|
||||
;bl=green
|
||||
;bh=blu
|
||||
mov dx,3c8h
|
||||
mov al,cl
|
||||
out dx,al
|
||||
inc dx
|
||||
mov al,ah
|
||||
out dx,al
|
||||
mov al,bl
|
||||
out dx,al
|
||||
mov al,bh
|
||||
out dx,al
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
random:
|
||||
;input BX=max num
|
||||
push es
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,cs:cont
|
||||
mov cx,cs:a1
|
||||
mov dx,cs:a2
|
||||
add ax,dx
|
||||
add cx,es:[3083]
|
||||
sub dx,es:[3083]
|
||||
add dx,cx
|
||||
mov cs:cont,ax
|
||||
mov cs:a1,cx
|
||||
mov cs:a2,dx
|
||||
and ax,11111111111b
|
||||
l1_r:
|
||||
cmp ax,bx
|
||||
jbe fine_r
|
||||
sub ax,bx
|
||||
jmp l1_r
|
||||
fine_r:
|
||||
pop es
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
a1 dw 10001
|
||||
a2 dw 101
|
||||
cont dw 23923
|
||||
BaseOfst dd ?
|
||||
|
||||
code ends
|
||||
|
||||
end
|
BIN
PROGRAMS/FIRE/MYFIRE32.BIN
Normal file
BIN
PROGRAMS/FIRE/MYFIRE32.BIN
Normal file
Binary file not shown.
BIN
PROGRAMS/FIRE/graph32.OBJ
Normal file
BIN
PROGRAMS/FIRE/graph32.OBJ
Normal file
Binary file not shown.
BIN
PROGRAMS/FIRE/myfire32.OBJ
Normal file
BIN
PROGRAMS/FIRE/myfire32.OBJ
Normal file
Binary file not shown.
103
PROGRAMS/SCRSAVER/SCRSAVER.ASM
Normal file
103
PROGRAMS/SCRSAVER/SCRSAVER.ASM
Normal file
|
@ -0,0 +1,103 @@
|
|||
;Screen saver per NXOS
|
||||
;---------------------
|
||||
|
||||
|
||||
org 0h
|
||||
|
||||
Main:
|
||||
call Randomize
|
||||
|
||||
Loop1:
|
||||
mov bx,79
|
||||
mov ax,11111111b
|
||||
call Random
|
||||
|
||||
mov dl,al
|
||||
|
||||
mov bx,24
|
||||
mov ax,111111b
|
||||
call Random
|
||||
|
||||
mov dh,al
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
|
||||
mov bx,si
|
||||
shl bx,8
|
||||
|
||||
mov ah,02h
|
||||
int 10h
|
||||
|
||||
mov bx,255
|
||||
mov ax,00ffh
|
||||
call Random
|
||||
|
||||
push ax
|
||||
mov bx,15
|
||||
mov ax,11111b
|
||||
call Random
|
||||
|
||||
mov bl,al
|
||||
pop ax
|
||||
mov ah,00h
|
||||
int 24h
|
||||
|
||||
mov ah,01h
|
||||
int 25h
|
||||
jz Loop1
|
||||
|
||||
mov ah,00h
|
||||
int 25h
|
||||
|
||||
mov ah,02h
|
||||
mov bl,0
|
||||
int 20h
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
randomize:
|
||||
push dx
|
||||
mov dx,40h
|
||||
in ax,dx
|
||||
mov [cont],ax
|
||||
pop dx
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
random:
|
||||
;input bx=limitation
|
||||
; ax=bit limitation
|
||||
;output ax=random num
|
||||
;(uses ax bx cx)
|
||||
push ax
|
||||
mov ax,[cont]
|
||||
rol ax,3
|
||||
sub ax,7
|
||||
xor ax,2
|
||||
ror ax,1
|
||||
mov cx,[a1]
|
||||
add ax,cx
|
||||
inc cx
|
||||
mov [a1],cx
|
||||
mov cx,[a2]
|
||||
sub ax,cx
|
||||
sub cx,2
|
||||
mov [a2],cx
|
||||
mov [cont],ax
|
||||
pop cx
|
||||
and ax,cx
|
||||
l1_r2:
|
||||
cmp ax,bx
|
||||
jbe fine_r2
|
||||
sub ax,bx
|
||||
jmp l1_r2
|
||||
fine_r2:
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
cont dw ?
|
||||
a1 dw ?
|
||||
a2 dw ?
|
BIN
PROGRAMS/SCRSAVER/SCRSAVER.BIN
Normal file
BIN
PROGRAMS/SCRSAVER/SCRSAVER.BIN
Normal file
Binary file not shown.
BIN
PROGRAMS/SCRSAVER/SCRSAVER.SYM
Normal file
BIN
PROGRAMS/SCRSAVER/SCRSAVER.SYM
Normal file
Binary file not shown.
238
PROGRAMS/SHELL/SHELL.ASM
Normal file
238
PROGRAMS/SHELL/SHELL.ASM
Normal file
|
@ -0,0 +1,238 @@
|
|||
;NXOS shell
|
||||
;----------
|
||||
;Written by: Alberto Venturini (Alb‚) - 2001
|
||||
;Email address: -albe-@libero.it
|
||||
|
||||
org 0h
|
||||
|
||||
cld
|
||||
Main1:
|
||||
mov si,offset Prompt ;shows the prompt
|
||||
mov ah,01h
|
||||
mov bl,07h
|
||||
int 24h
|
||||
|
||||
mov di,offset Command
|
||||
xor cx,cx
|
||||
|
||||
GetCommand: ;Get a string from the keyboard
|
||||
mov si,offset Command
|
||||
mov ah,07h
|
||||
int 25h
|
||||
dec si
|
||||
|
||||
ToUpCase: ;Turns everything upcase
|
||||
inc si
|
||||
mov al,ds:[si]
|
||||
cmp al,13
|
||||
je EndCommand
|
||||
cmp al,90
|
||||
jbe ToUpCase
|
||||
sub al,32
|
||||
mov ds:[si],al
|
||||
jmp ToUpCase
|
||||
|
||||
EndCommand:
|
||||
test cx,cx ;If only CR was pressed, just re-write the prompt
|
||||
jz Main1
|
||||
|
||||
push cx
|
||||
mov di,offset Command
|
||||
|
||||
Test4Extension: ;tests if file extension is available
|
||||
mov al,es:[di]
|
||||
cmp al,'.'
|
||||
je ExtensionOk
|
||||
inc di
|
||||
dec cx
|
||||
jnz Test4Extension
|
||||
|
||||
NoExtension: ;there's no extension...assume it's an internal
|
||||
;shell command
|
||||
|
||||
pop cx
|
||||
|
||||
mov di,offset Command
|
||||
|
||||
mov cx,3
|
||||
mov si,offset ClsCmd
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ShellCommand_Cls
|
||||
|
||||
mov cx,4
|
||||
mov si,offset HelpCmd
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ShellCommand_Help
|
||||
|
||||
mov ah,01h
|
||||
mov si,offset Error3
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
ShellCommand_Cls: ;executes the "CLS" command
|
||||
mov ah,04h
|
||||
int 24h
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
ShellCommand_Help:
|
||||
mov si,offset HelpTxt
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
|
||||
ExtensionOk: ;there's the extension
|
||||
pop cx
|
||||
|
||||
StoreExtension: ;store the extension in a buffer ("Extension")
|
||||
push di
|
||||
inc di
|
||||
mov si,di
|
||||
mov di,offset Extension
|
||||
|
||||
movsb
|
||||
movsb
|
||||
movsb
|
||||
|
||||
pop di
|
||||
|
||||
push di
|
||||
sub di,offset Command
|
||||
|
||||
cmp di,8
|
||||
jb StoreExtension2
|
||||
|
||||
pop di ;file name must be <= 8
|
||||
mov di,offset Command
|
||||
add di,8
|
||||
jmp StoreExtension3
|
||||
|
||||
StoreExtension2:
|
||||
mov cx,8
|
||||
sub cx,di
|
||||
mov al,' '
|
||||
|
||||
pop di
|
||||
|
||||
rep stosb
|
||||
|
||||
StoreExtension3:
|
||||
mov si,offset Extension
|
||||
movsb
|
||||
movsb
|
||||
movsb
|
||||
|
||||
ExecuteProgram:
|
||||
mov di,offset Extension
|
||||
mov si,offset BinExtension
|
||||
|
||||
mov cx,3
|
||||
|
||||
push di
|
||||
rep cmpsb ;tests if the extension is "BIN"
|
||||
pop di
|
||||
je ExecuteBinProgram
|
||||
|
||||
mov si,offset ComExtension
|
||||
mov cx,3
|
||||
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ExecuteComProgram
|
||||
|
||||
mov ah,01h
|
||||
mov si,offset Error2
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
jmp Main1
|
||||
|
||||
ExecuteBinProgram:
|
||||
push es
|
||||
|
||||
mov si,offset Command
|
||||
mov ah,00h
|
||||
int 20h
|
||||
test dx,dx
|
||||
jz FileNotFound
|
||||
mov bl,0
|
||||
mov ah,01h
|
||||
int 20h
|
||||
|
||||
pop es
|
||||
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
ExecuteComProgram:
|
||||
push es
|
||||
|
||||
mov si,offset Command
|
||||
mov ah,07h
|
||||
int 20h
|
||||
test dx,dx
|
||||
jz FileNotFound
|
||||
mov bl,0
|
||||
mov ah,01h
|
||||
int 20h
|
||||
|
||||
pop es
|
||||
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
FileNotFound:
|
||||
pop es
|
||||
mov si,offset Error1
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
ClearCommandBuffer:
|
||||
mov di,offset Command
|
||||
mov al,' '
|
||||
mov cx,95
|
||||
|
||||
ClearCommandBuffer2:
|
||||
mov byte ptr cs:[di],al
|
||||
inc di
|
||||
loop ClearCommandBuffer2
|
||||
|
||||
jmp Main1
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Command db 100 dup (32)
|
||||
Prompt db 13,10,'Ready:',0
|
||||
Error1 db 13,10,'File not found',13,10,0
|
||||
Error2 db 13,10,'Invalid file name',13,10,0
|
||||
Error3 db 13,10,'Invalid command',13,10,0
|
||||
NextLine db 13,10,0
|
||||
Extension db 3 dup (?)
|
||||
BinExtension db 'BIN',0
|
||||
ComExtension db 'COM',0
|
||||
|
||||
ClsCmd db 'CLS'
|
||||
HelpCmd db 'HELP'
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;Help text
|
||||
|
||||
HelpTxt db 13,10,'NXOS shell',13,10
|
||||
db '-------------',13,10
|
||||
db 13,10
|
||||
db 'How to use this shell:',13,10
|
||||
db 'if you want to execute an external program, just type the',13,10
|
||||
db 'file name, with his extension.',13,10
|
||||
db 13,10
|
||||
db 'Available shell commands:',13,10
|
||||
db ' CLS: clears the screen',13,10
|
||||
db ' HELP: shows this screen',13,10,0
|
BIN
PROGRAMS/SHELL/SHELL.BIN
Normal file
BIN
PROGRAMS/SHELL/SHELL.BIN
Normal file
Binary file not shown.
BIN
PROGRAMS/SHELL/SHELL.SYM
Normal file
BIN
PROGRAMS/SHELL/SHELL.SYM
Normal file
Binary file not shown.
BIN
PROGRAMS/SHELL/SHELL2.BIN
Normal file
BIN
PROGRAMS/SHELL/SHELL2.BIN
Normal file
Binary file not shown.
182
PROGRAMS/SHELL/SHELL2.OLD
Normal file
182
PROGRAMS/SHELL/SHELL2.OLD
Normal file
|
@ -0,0 +1,182 @@
|
|||
;NXOS shell
|
||||
;----------
|
||||
;Written by: Alberto Venturini (Alb‚) - 2001
|
||||
;Email address: -albe-@libero.it
|
||||
|
||||
org 0h
|
||||
|
||||
cld
|
||||
Main1:
|
||||
mov si,offset Prompt ;shows the prompt
|
||||
mov ah,01h
|
||||
mov bl,07h
|
||||
int 24h
|
||||
|
||||
mov di,offset Command
|
||||
xor cx,cx
|
||||
|
||||
GetCommand: ;Get a string from the keyboard
|
||||
mov si,offset Command
|
||||
mov ah,07h
|
||||
int 25h
|
||||
dec si
|
||||
|
||||
ToUpCase: ;Turns everything upcase
|
||||
inc si
|
||||
mov al,ds:[si]
|
||||
cmp al,13
|
||||
je EndCommand
|
||||
cmp al,90
|
||||
jbe ToUpCase
|
||||
sub al,32
|
||||
mov ds:[si],al
|
||||
jmp ToUpCase
|
||||
|
||||
EndCommand:
|
||||
test cx,cx ;If only CR was pressed, just re-write the prompt
|
||||
jz ClearCommandBuffer
|
||||
|
||||
push cx
|
||||
mov di,offset Command
|
||||
|
||||
Test4Extension: ;tests if file extension is available
|
||||
mov al,es:[di]
|
||||
cmp al,'.'
|
||||
je ExtensionOk
|
||||
inc di
|
||||
dec cx
|
||||
jnz Test4Extension
|
||||
|
||||
NoExtension: ;there's no extension...assume it's an internal
|
||||
;shell command
|
||||
|
||||
pop cx
|
||||
|
||||
mov di,offset Command
|
||||
|
||||
mov cx,3
|
||||
mov si,offset ClsCmd
|
||||
rep cmpsb
|
||||
je ShellCommand_Cls
|
||||
|
||||
mov ah,01h
|
||||
mov si,offset Error3
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
ShellCommand_Cls: ;executes the "CLS" command
|
||||
mov ah,04h
|
||||
int 24h
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
;[...]
|
||||
|
||||
ExtensionOk: ;there's the extension
|
||||
pop cx
|
||||
|
||||
StoreExtension: ;store the extension in a buffer ("Extension")
|
||||
push di
|
||||
inc di
|
||||
mov si,di
|
||||
mov di,offset Extension
|
||||
|
||||
movsb
|
||||
movsb
|
||||
movsb
|
||||
|
||||
pop di
|
||||
|
||||
push di
|
||||
sub di,offset Command
|
||||
|
||||
cmp di,8
|
||||
jb StoreExtension2
|
||||
|
||||
pop di ;file name must be <= 8
|
||||
mov di,offset Command
|
||||
add di,8
|
||||
jmp StoreExtension3
|
||||
|
||||
StoreExtension2:
|
||||
mov cx,8
|
||||
sub cx,di
|
||||
mov al,' '
|
||||
|
||||
pop di
|
||||
|
||||
rep stosb
|
||||
|
||||
StoreExtension3:
|
||||
mov si,offset Extension
|
||||
movsb
|
||||
movsb
|
||||
movsb
|
||||
|
||||
ExecuteProgram:
|
||||
mov di,offset Extension
|
||||
mov si,offset BinExtension
|
||||
|
||||
mov cx,3
|
||||
|
||||
rep cmpsb ;tests if the extension is "BIN"
|
||||
je ExecuteBinProgram
|
||||
|
||||
mov ah,01h
|
||||
mov si,offset Error2
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
jmp Main1
|
||||
|
||||
ExecuteBinProgram:
|
||||
push es
|
||||
|
||||
mov si,offset Command
|
||||
mov ah,00h
|
||||
int 20h
|
||||
test dx,dx
|
||||
jz FileNotFound
|
||||
mov bl,0
|
||||
mov ah,01h
|
||||
int 20h
|
||||
|
||||
pop es
|
||||
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
FileNotFound:
|
||||
pop es
|
||||
mov si,offset Error1
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
ClearCommandBuffer:
|
||||
mov di,offset Command
|
||||
mov al,' '
|
||||
mov cx,95
|
||||
|
||||
ClearCommandBuffer2:
|
||||
mov byte ptr cs:[di],al
|
||||
inc di
|
||||
loop ClearCommandBuffer2
|
||||
|
||||
jmp Main1
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Command db 100 dup (32)
|
||||
Prompt db 13,10,'Ready:',0
|
||||
Error1 db 13,10,'File not found',13,10,0
|
||||
Error2 db 13,10,'Invalid file name',13,10,0
|
||||
Error3 db 13,10,'Invalid command',13,10,0
|
||||
NextLine db 13,10,0
|
||||
Extension db 3 dup (?)
|
||||
BinExtension db 'BIN',0
|
||||
|
||||
ClsCmd db 'CLS'
|
||||
|
||||
;------------------------------------------------------------------------------
|
BIN
PROGRAMS/SHELL/SHELL2.SYM
Normal file
BIN
PROGRAMS/SHELL/SHELL2.SYM
Normal file
Binary file not shown.
1
PROGRAMS/SHELL/SHELL2.UND
Normal file
1
PROGRAMS/SHELL/SHELL2.UND
Normal file
|
@ -0,0 +1 @@
|
|||
CLEARCOMMAND in shell2.asm
|
0
README.md
Normal file
0
README.md
Normal file
2
REBOOT.ASM
Normal file
2
REBOOT.ASM
Normal file
|
@ -0,0 +1,2 @@
|
|||
org 0h
|
||||
int 21h
|
1
REBOOT.BIN
Normal file
1
REBOOT.BIN
Normal file
|
@ -0,0 +1 @@
|
|||
<EFBFBD>!
|
330
SHELL.ASM
Normal file
330
SHELL.ASM
Normal file
|
@ -0,0 +1,330 @@
|
|||
;NXOS shell
|
||||
;----------
|
||||
;Written by: Alberto Venturini (Alb‚) - 2001
|
||||
;Email address: -albe-@libero.it
|
||||
|
||||
org 0h
|
||||
|
||||
cld
|
||||
Main1:
|
||||
; mov si,offset Prompt ;shows the prompt
|
||||
; mov ah,01h
|
||||
; mov bl,07h
|
||||
; int 24h
|
||||
|
||||
call ShowPrompt
|
||||
|
||||
mov di,offset Command
|
||||
xor cx,cx
|
||||
|
||||
GetCommand: ;Get a string from the keyboard
|
||||
mov si,offset Command
|
||||
mov ah,07h
|
||||
int 25h
|
||||
dec si
|
||||
|
||||
ToUpCase: ;Turns everything upcase
|
||||
inc si
|
||||
mov al,ds:[si]
|
||||
cmp al,13
|
||||
je EndCommand
|
||||
cmp al,90
|
||||
jbe ToUpCase
|
||||
sub al,32
|
||||
mov ds:[si],al
|
||||
jmp ToUpCase
|
||||
|
||||
EndCommand:
|
||||
test cx,cx ;If only CR was pressed, just re-write the prompt
|
||||
jz Main1
|
||||
|
||||
push cx
|
||||
mov di,offset Command
|
||||
|
||||
Test4Extension: ;tests if file extension is available
|
||||
mov al,es:[di]
|
||||
cmp al,'.'
|
||||
je ExtensionOk2
|
||||
inc di
|
||||
dec cx
|
||||
jnz Test4Extension
|
||||
|
||||
NoExtension: ;there's no extension...assume it's an internal
|
||||
;shell command
|
||||
|
||||
pop cx
|
||||
|
||||
mov di,offset Command
|
||||
|
||||
mov cx,3
|
||||
mov si,offset ClsCmd
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ShellCommand_Cls
|
||||
|
||||
mov cx,4
|
||||
mov si,offset HelpCmd
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ShellCommand_Help
|
||||
|
||||
mov cx,8
|
||||
mov si,offset ShutdownCmd
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ShellCommand_Shutdown
|
||||
|
||||
mov cx,2
|
||||
mov si,offset CdCmd
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ShellCommand_Cd
|
||||
|
||||
mov ah,01h
|
||||
mov si,offset Error3
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
ExtensionOk2:
|
||||
jmp ExtensionOk
|
||||
|
||||
ShellCommand_Cls: ;executes the "CLS" command
|
||||
mov ah,04h
|
||||
int 24h
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
ShellCommand_Cd:
|
||||
mov si,offset CiaoDir
|
||||
mov ah,02h
|
||||
int 22h
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
CiaoDir db 'CIAO ',0
|
||||
|
||||
ShellCommand_Help:
|
||||
mov si,offset HelpTxt
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
ShellCommand_ShutDown:
|
||||
mov al,13
|
||||
mov ah,00h
|
||||
int 24h
|
||||
mov al,10
|
||||
int 24h
|
||||
xor ax,ax
|
||||
int 21h
|
||||
|
||||
|
||||
ExtensionOk: ;there's the extension
|
||||
pop cx
|
||||
|
||||
StoreExtension: ;store the extension in a buffer ("Extension")
|
||||
push di
|
||||
inc di
|
||||
mov si,di
|
||||
mov di,offset Extension
|
||||
|
||||
movsb
|
||||
movsb
|
||||
movsb
|
||||
|
||||
mov di,offset Parameters ;store the parameters in a buffer
|
||||
mov cx,90
|
||||
inc si
|
||||
rep movsb
|
||||
|
||||
pop di
|
||||
|
||||
jmp ExecuteProgram
|
||||
|
||||
push di
|
||||
sub di,offset Command
|
||||
|
||||
cmp di,8
|
||||
jb StoreExtension2
|
||||
|
||||
pop di ;file name must be <= 8
|
||||
mov di,offset Command
|
||||
add di,8
|
||||
jmp StoreExtension3
|
||||
|
||||
StoreExtension2:
|
||||
mov cx,8
|
||||
sub cx,di
|
||||
mov al,' '
|
||||
|
||||
pop di
|
||||
|
||||
rep stosb
|
||||
|
||||
StoreExtension3:
|
||||
mov si,offset Extension
|
||||
movsb
|
||||
movsb
|
||||
movsb
|
||||
|
||||
ExecuteProgram:
|
||||
mov di,offset Extension
|
||||
mov si,offset BinExtension
|
||||
|
||||
mov cx,3
|
||||
|
||||
push di
|
||||
rep cmpsb ;tests if the extension is "BIN"
|
||||
pop di
|
||||
je ExecuteBinProgram
|
||||
|
||||
mov si,offset ComExtension
|
||||
mov cx,3
|
||||
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ExecuteComProgram
|
||||
|
||||
mov si,offset ExeExtension
|
||||
mov cx,3
|
||||
push di
|
||||
rep cmpsb
|
||||
pop di
|
||||
je ExecuteExeProgram
|
||||
|
||||
mov ah,01h
|
||||
mov si,offset Error2
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
jmp Main1
|
||||
|
||||
ExecuteBinProgram:
|
||||
push es
|
||||
|
||||
mov si,offset Command
|
||||
mov ah,00h
|
||||
int 20h
|
||||
test dx,dx
|
||||
jz FileNotFound
|
||||
mov bl,0
|
||||
mov ah,01h
|
||||
int 20h
|
||||
|
||||
pop es
|
||||
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
ExecuteComProgram:
|
||||
push es
|
||||
|
||||
mov si,offset Command
|
||||
mov bx,offset Parameters
|
||||
mov ah,07h
|
||||
int 20h
|
||||
test dx,dx
|
||||
jz FileNotFound
|
||||
mov bl,0
|
||||
mov ah,01h
|
||||
int 20h
|
||||
|
||||
pop es
|
||||
|
||||
jmp ClearCommandBuffer
|
||||
ExecuteExeProgram:
|
||||
mov si,offset Command
|
||||
mov ah,08h
|
||||
int 20h
|
||||
jmp ClearCommandBuffer
|
||||
|
||||
FileNotFound:
|
||||
pop es
|
||||
mov si,offset Error1
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
ClearCommandBuffer:
|
||||
mov di,offset Command
|
||||
mov al,' '
|
||||
mov cx,95
|
||||
|
||||
ClearCommandBuffer2:
|
||||
mov byte ptr cs:[di],al
|
||||
inc di
|
||||
loop ClearCommandBuffer2
|
||||
|
||||
jmp Main1
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
ShowPrompt:
|
||||
mov si,offset Prompt
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov al,'\'
|
||||
mov ah,00h
|
||||
int 24h
|
||||
|
||||
; push ds
|
||||
; push es
|
||||
; push di
|
||||
|
||||
; mov ah,05h ;get current dir name in ES:[DI]
|
||||
; int 22h
|
||||
;
|
||||
; push es
|
||||
; pop ds
|
||||
; mov si,di
|
||||
; mov ah,01h
|
||||
; int 24h
|
||||
;
|
||||
; pop di
|
||||
; pop es
|
||||
; pop ds
|
||||
|
||||
ret
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Command db 100 dup (32)
|
||||
Prompt db 13,10,'Ready:',0
|
||||
Error1 db 13,10,'File not found',13,10,0
|
||||
Error2 db 13,10,'Invalid file name',13,10,0
|
||||
Error3 db 13,10,'Invalid command',13,10,0
|
||||
NextLine db 13,10,0
|
||||
Extension db 3 dup (?)
|
||||
BinExtension db 'BIN',0
|
||||
ComExtension db 'COM',0
|
||||
ExeExtension db 'EXE',0
|
||||
|
||||
ClsCmd db 'CLS'
|
||||
CdCmd db 'CD'
|
||||
HelpCmd db 'HELP'
|
||||
ShutdownCmd db 'SHUTDOWN'
|
||||
|
||||
;Help text
|
||||
|
||||
HelpTxt db 13,10,'NXOS shell',13,10
|
||||
db '-------------',13,10
|
||||
db 13,10
|
||||
db 'How to use this shell:',13,10
|
||||
db 'if you want to execute an external program, just type the',13,10
|
||||
db 'file name, with his extension.',13,10
|
||||
db 13,10
|
||||
db 'Available shell commands:',13,10
|
||||
db ' CLS: clears the screen',13,10
|
||||
db ' HELP: shows this screen',13,10
|
||||
db ' SHUTDOWN: reboots or shutdowns the system',13,10,0
|
||||
|
||||
Parameters: ;where to store the parameters
|
BIN
SHELL.BIN
Normal file
BIN
SHELL.BIN
Normal file
Binary file not shown.
49
SYSMEM.ASM
Normal file
49
SYSMEM.ASM
Normal file
|
@ -0,0 +1,49 @@
|
|||
;Organizzazione della memoria di sistema
|
||||
|
||||
DATA SEGMENT
|
||||
|
||||
Version dw 0000h ;word, indica la versione del sistema
|
||||
SystemId db 30 dup (0) ;Š la stringa di identificazione del sistema (30 bytes)
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
;FAT12
|
||||
|
||||
Fat12_MaxFiles equ 5
|
||||
|
||||
Fat12_FatSegment dw 0800h ;segmento in cui Š memorizzata la fat
|
||||
Fat12_FatStart dw ? ;logical sector in cui Š presente la fat
|
||||
Fat12_SectorsPerFat dw ? ;sectors per fat
|
||||
Fat12_NumberOfFats db ? ;number of fats
|
||||
Fat12_RootStart dw ? ;logical sector in cui inizia la root directory
|
||||
Fat12_RootEntries dw ? ;number of root directory entries
|
||||
Fat12_RootSectors dw ? ;length of root in sectors
|
||||
Fat12_Chain dw ? ;tiene traccia del settore successivo di un file
|
||||
Fat12_CurrentDir dw ? ;Š il sector della directory corrente (inizializzato alla root) --> Š gi… stata compiuta l'operazione di sottrazione di 2 e aggiunta della "dataarea"
|
||||
Fat12_CurrentDirSize dw ? ;grandezza della directory corrente in settori
|
||||
Fat12_DirBuffer db 512 dup (?) ;buffer per memorizzare 1 settore di directory
|
||||
|
||||
;drive parameter
|
||||
Fat12_Heads dw ?
|
||||
Fat12_Sectors dw ?
|
||||
Fat12_Cylinders dw ?
|
||||
|
||||
;file data
|
||||
Fat12_FileSector dw Fat12_MaxFiles dup (0)
|
||||
Fat12_FileAttr db Fat12_MaxFiles dup (0)
|
||||
Fat12_FileBytes dw Fat12_MaxFiles dup (0)
|
||||
Fat12_FileSize dd Fat12_MaxFiles dup (0)
|
||||
|
||||
Fat12_DataArea dw ? ;inizio dell'area dati in logical sectors
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;Tabella per la gestione della memoria ( MaxKBytes Š specificato nel file
|
||||
;"memmanag.asm" )
|
||||
|
||||
MaxKBytes equ 512
|
||||
|
||||
MemoryTable db MaxKbytes dup (0)
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
SystemError db ?
|
150
TEST.ASM
Normal file
150
TEST.ASM
Normal file
|
@ -0,0 +1,150 @@
|
|||
org 0h
|
||||
|
||||
main:
|
||||
; mov ax,0003h
|
||||
; int 10h
|
||||
|
||||
main2:
|
||||
mov si,offset msg1
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov si,offset msg2
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
|
||||
mov dx,si
|
||||
mov ah,03h
|
||||
int 24h
|
||||
|
||||
mov si,offset msg3
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
|
||||
mov dx,cx
|
||||
mov ah,03h
|
||||
int 24h
|
||||
|
||||
mov si,offset msg4
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov ah,02h
|
||||
int 2fh
|
||||
mov dx,ax
|
||||
mov ah,03h
|
||||
int 24h
|
||||
|
||||
mov si,offset msg5
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov ah,02h
|
||||
int 23h
|
||||
mov dx,cx
|
||||
mov ah,03h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov si,offset msg6
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov dx,40
|
||||
mov ah,00h
|
||||
int 23h
|
||||
|
||||
mov si,offset msg7
|
||||
mov ah,01
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov dx,40
|
||||
mov ah,01h
|
||||
int 23h
|
||||
|
||||
mov si,offset msg5
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov ah,02h
|
||||
int 23h
|
||||
mov dx,cx
|
||||
mov ah,03h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov si,offset msg8
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov ah,03h
|
||||
xor bx,bx
|
||||
int 25h
|
||||
|
||||
mov si,offset msg9
|
||||
mov ah,01h
|
||||
mov bl,7
|
||||
int 24h
|
||||
|
||||
mov si,offset filename
|
||||
mov ah,00h
|
||||
int 22h
|
||||
|
||||
push si
|
||||
mov si,offset msg10
|
||||
mov ah,01h
|
||||
int 24h
|
||||
pop si
|
||||
|
||||
mov ah,04h
|
||||
int 22h
|
||||
|
||||
mov dx,ax
|
||||
mov ah,03h
|
||||
int 24h
|
||||
|
||||
mov ah,02h
|
||||
int 22h
|
||||
|
||||
fine:
|
||||
mov ah,00h
|
||||
int 25h
|
||||
|
||||
mov ah,02h
|
||||
mov bl,0
|
||||
int 20h
|
||||
|
||||
msg1 db 'Testing the system:',13,10,0
|
||||
msg2 db 13,10,'Process number ... ',0
|
||||
msg3 db 13,10,'Visible process ... ',0
|
||||
msg4 db 13,10,'Total extended memory: ',0
|
||||
msg5 db 13,10,'Base memory available: ',0
|
||||
|
||||
msg6 db 13,10,'Allocating 40 Kbytes of memory...',0
|
||||
msg7 db 13,10,'Releasing 40 Kbytes of memory...',0
|
||||
|
||||
msg8 db 13,10,'Reprogramming the keyboard...',0
|
||||
|
||||
msg9 db 13,10,'Opening a file (test.bin)...',0
|
||||
msg10 db 13,10,'File size:',0
|
||||
|
||||
nextline db 13,10,0
|
||||
|
||||
Cont db 0
|
||||
|
||||
filename db 'TEST.BIN',0
|
BIN
TEST.BIN
Normal file
BIN
TEST.BIN
Normal file
Binary file not shown.
464
VIDEO.ASM
Normal file
464
VIDEO.ASM
Normal file
|
@ -0,0 +1,464 @@
|
|||
;Driver video per NXOS
|
||||
|
||||
MaxProcess equ 7
|
||||
|
||||
org 0h
|
||||
|
||||
InstallDriver:
|
||||
;Questa procedura installa l'interrupt 24h che sar… usato dal driver video
|
||||
|
||||
cli
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
mov ax,offset Int24h
|
||||
mov es:[24h*4],ax
|
||||
mov ax,cs
|
||||
mov es:[24h*4+2],ax
|
||||
|
||||
mov ah,02h ;termina il processo
|
||||
mov bl,1 ;non libera la memoria (perchŠ le procedure devono
|
||||
;essere sempre presenti in memoria)
|
||||
int 20h
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
Int24h:
|
||||
cmp ah,00h
|
||||
je Int24h_00h
|
||||
cmp ah,01h
|
||||
je Int24h_01h
|
||||
cmp ah,02h
|
||||
je Int24h_02h
|
||||
cmp ah,03h
|
||||
je Int24h_03h
|
||||
cmp ah,04h
|
||||
je Int24h_04h
|
||||
cmp ah,05h
|
||||
je Int24h_05h
|
||||
cmp ah,06h
|
||||
je Int24h_06h
|
||||
cmp ah,07h
|
||||
je Int24h_07h
|
||||
iret
|
||||
|
||||
Int24h_00h:
|
||||
call WriteChar
|
||||
iret
|
||||
Int24h_01h:
|
||||
call WriteString
|
||||
iret
|
||||
Int24h_02h:
|
||||
call SetVisibleProcess
|
||||
iret
|
||||
Int24h_03h:
|
||||
call WriteNumber
|
||||
iret
|
||||
Int24h_04h:
|
||||
call ClearScreen
|
||||
iret
|
||||
Int24h_05h:
|
||||
call GetCursorPos
|
||||
iret
|
||||
Int24h_06h:
|
||||
call SetCursorPos
|
||||
iret
|
||||
Int24h_07h:
|
||||
call GetChar
|
||||
iret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
WriteChar:
|
||||
;input AL=carattere da scrivere
|
||||
; BL=attributi
|
||||
|
||||
;Da aggiungere: supporto per lo "scrolling" verticale
|
||||
|
||||
;Finalmente sostituita la procedura del bios con una mia procedura!
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push si
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
|
||||
; mov dx,si
|
||||
; mov bh,dl
|
||||
|
||||
cmp al,13
|
||||
je WriteChar_13
|
||||
cmp al,10
|
||||
je WriteChar_10
|
||||
test al,al
|
||||
jz WriteChar_End
|
||||
cmp al,9
|
||||
je WriteChar_09
|
||||
|
||||
push ax
|
||||
push di
|
||||
push es
|
||||
|
||||
call GetCursorPos
|
||||
|
||||
mov di,dx
|
||||
shr di,8
|
||||
push ax
|
||||
mov ax,80
|
||||
push dx
|
||||
mul di
|
||||
pop dx
|
||||
xor dh,dh
|
||||
mov di,ax
|
||||
add di,dx
|
||||
add di,di
|
||||
|
||||
mov ax,0b000h
|
||||
mov es,ax
|
||||
add di,8000h
|
||||
mov ax,si
|
||||
shl ax,12
|
||||
add di,ax
|
||||
pop ax
|
||||
mov ah,bl
|
||||
stosw
|
||||
|
||||
pop es
|
||||
pop di
|
||||
pop ax
|
||||
|
||||
|
||||
jmp WriteChar_AggiornaCursore
|
||||
|
||||
WriteChar_13:
|
||||
call GetCursorPos
|
||||
|
||||
mov dl,0
|
||||
; mov ah,02h
|
||||
; int 10h
|
||||
call SetCursorPos
|
||||
jmp WriteChar_End
|
||||
|
||||
WriteChar_10:
|
||||
call GetCursorPos
|
||||
|
||||
cmp dh,24
|
||||
je WriteChar_ScrollUp
|
||||
|
||||
inc dh
|
||||
; mov ah,02h
|
||||
; int 10h
|
||||
call SetCursorPos
|
||||
jmp WriteChar_End
|
||||
|
||||
WriteChar_09:
|
||||
call GetCursorPos
|
||||
add dl,9
|
||||
cmp dl,80
|
||||
jbe WriteChar_09_Ok
|
||||
|
||||
sub dl,80
|
||||
inc dh
|
||||
|
||||
WriteChar_09_OK:
|
||||
call SetCursorPos
|
||||
jmp WriteChar_End
|
||||
|
||||
WriteChar_AggiornaCursore:
|
||||
call GetCursorPos
|
||||
|
||||
cmp dl,79
|
||||
je WriteChar_NextLine
|
||||
inc dl
|
||||
; mov ah,02h
|
||||
; int 10h
|
||||
call SetCursorPos
|
||||
|
||||
WriteChar_End:
|
||||
pop si
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
WriteChar_NextLine:
|
||||
cmp dh,24
|
||||
je WriteChar_ScrollUp
|
||||
mov dl,0
|
||||
inc dh
|
||||
; mov ah,02h
|
||||
; int 10h
|
||||
call SetCursorPos
|
||||
jmp WriteChar_End
|
||||
|
||||
WriteChar_ScrollUp:
|
||||
;int 10h funzione 06h:scroll up window
|
||||
;Da sostituire con una mia funzione: questa funziona solo con le pagine attive
|
||||
xor cx,cx ;in CX c'Š il punto in alto a sinistra della finestra
|
||||
mov ah,06h
|
||||
mov al,1 ;in AL c'Š il numero di righe da aggiungere
|
||||
mov bh,07h ;in BH ci sono gli attributi per la nuova riga
|
||||
mov dh,24
|
||||
mov dl,79
|
||||
int 10h
|
||||
jmp WriteChar_End
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GetChar:
|
||||
;input DL=X, DH=Y
|
||||
;output AH=attributi del carattere, AL=carattere letto
|
||||
|
||||
push dx
|
||||
call GetCursorPos
|
||||
mov bx,dx
|
||||
pop dx
|
||||
call SetCursorPos
|
||||
|
||||
push bx
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
mov bx,si
|
||||
mov bh,bl
|
||||
mov ah,08h
|
||||
int 10h
|
||||
|
||||
pop dx
|
||||
call SetCursorPos
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
WriteString:
|
||||
;input DS:[SI] --> indirizzo della stringa
|
||||
; BL --> attributi dei caratteri
|
||||
;Nota: la stringa finisce con uno 0 o con un '$'
|
||||
push ax
|
||||
push si
|
||||
|
||||
WriteString_Ini:
|
||||
mov al,[si]
|
||||
test al,al
|
||||
jz WriteString_EndString
|
||||
cmp al,'$'
|
||||
je WriteString_EndString
|
||||
|
||||
call WriteChar
|
||||
inc si
|
||||
jmp WriteString_Ini
|
||||
|
||||
WriteString_EndString:
|
||||
pop si
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
SetVisibleProcess:
|
||||
;input SI --> numero del processo da rendere visibile
|
||||
|
||||
cmp si,(MaxProcess)
|
||||
jae SetVisibleProcess_End
|
||||
|
||||
cli
|
||||
|
||||
push ax
|
||||
mov ax,si
|
||||
|
||||
mov ah,05h
|
||||
int 10h
|
||||
|
||||
mov ah,04h
|
||||
int 20h
|
||||
|
||||
pop ax
|
||||
|
||||
SetVisibleProcess_End:
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
WriteNumber:
|
||||
;Scrive un numero decimale
|
||||
;input DX=numero
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
|
||||
push dx
|
||||
pop ax
|
||||
|
||||
mov cx,0ffffh
|
||||
push cx
|
||||
mov cx,10
|
||||
a1_shownum:
|
||||
xor dx,dx
|
||||
div cx
|
||||
or dl,30h
|
||||
push dx
|
||||
cmp ax,0
|
||||
jne a1_shownum
|
||||
pop ax
|
||||
a2_shownum:
|
||||
mov bl,7
|
||||
call WriteChar
|
||||
pop ax
|
||||
cmp ax,0ffffh
|
||||
jne a2_shownum
|
||||
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
ClearScreen:
|
||||
;Il nome dice tutto...
|
||||
;Input SI=numero del processo il cui schermo verr… cancellato
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push es
|
||||
push di
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
|
||||
mov ax,0b000h
|
||||
mov es,ax
|
||||
mov di,8000h
|
||||
|
||||
mov ax,si
|
||||
shl ax,12
|
||||
add di,ax
|
||||
|
||||
mov cx,2000
|
||||
mov ax,0720h
|
||||
rep stosw
|
||||
|
||||
mov ax,si
|
||||
mov bh,al
|
||||
mov ah,02h
|
||||
xor dx,dx
|
||||
int 10h
|
||||
|
||||
pop di
|
||||
pop es
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
;==============================================================================
|
||||
|
||||
SetCursorPos2:
|
||||
;Setta la posizione del cursore
|
||||
;input: BL=X, BH=Y
|
||||
;output: no output
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
mov al,bh
|
||||
cbw
|
||||
; mov cx,word ptr [Video_MaxX]
|
||||
mov cx,80
|
||||
mul cx ;AX=Y*80, BL=X,BH=Y
|
||||
xchg ax,bx ;AL=X,AH=Y, BX=Y*80
|
||||
cbw ;AX=X
|
||||
add bx,ax ;BX=X+(Y*80)
|
||||
; mov word ptr [Video_CursorPos],bx
|
||||
mov al,0eh
|
||||
mov ah,bh
|
||||
mov dx,3d4h
|
||||
out dx,ax
|
||||
mov al,0fh
|
||||
mov ah,bl
|
||||
out dx,ax
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;==============================================================================
|
||||
|
||||
SetCursorPos:
|
||||
;input DL=X, DH=Y
|
||||
;Setta la posizione del cursore del processo chiamante
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
push si
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
mov bx,si
|
||||
mov bh,bl
|
||||
|
||||
mov bl,0
|
||||
|
||||
mov ah,02h
|
||||
int 10h
|
||||
|
||||
pop si
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
GetCursorPos:
|
||||
;output DL=X position, DH=Y position
|
||||
;Restituisce la posizione del cursore del processo chiamante
|
||||
|
||||
push ax
|
||||
push bx
|
||||
push es
|
||||
|
||||
push cx
|
||||
push si
|
||||
|
||||
mov ah,03h
|
||||
int 20h
|
||||
mov bx,si
|
||||
add bx,bx
|
||||
; add si,si
|
||||
|
||||
mov ax,40h
|
||||
mov es,ax
|
||||
|
||||
mov dx,word ptr es:[50h+bx]
|
||||
|
||||
pop si
|
||||
pop cx
|
||||
|
||||
pop es
|
||||
pop bx
|
||||
pop ax
|
||||
|
||||
ret
|
||||
|
||||
|
||||
;==============================================================================
|
||||
|
||||
|
||||
ProcessPage db 16 dup (0)
|
||||
;ProcessCursor dw 16 dup (0)
|
||||
Resolution dw (80*50)
|
BIN
VIDEO.DRV
Normal file
BIN
VIDEO.DRV
Normal file
Binary file not shown.
19
install.bat
Normal file
19
install.bat
Normal file
|
@ -0,0 +1,19 @@
|
|||
@echo off
|
||||
cls
|
||||
echo Questo programma installerà NXOS su un floppy disk.
|
||||
echo Assicurarsi che sia inserito un dischetto VUOTO nel drive A:
|
||||
pause
|
||||
echo Copia del bootsector in corso...
|
||||
PARTCOPY boot12.bin 0 3 -f0 0
|
||||
PARTCOPY boot12.bin 3E 1C2 -f0 3E
|
||||
echo Copia del Kernel in corso
|
||||
copy kernel.bin a:\
|
||||
echo Copia del driver video in corso
|
||||
copy video.drv a:\
|
||||
echo Copia del driver della tastiera in corso
|
||||
copy keyboard.drv a:\
|
||||
echo Copia del driver Real Mode 32-bit in corso
|
||||
copy bigmem.drv a:\
|
||||
echo Copia della shell in corso
|
||||
copy shell.bin a:\
|
||||
echo Installazione completata
|
9
readme.txt
Normal file
9
readme.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
20/02/2001
|
||||
|
||||
NXOS
|
||||
|
||||
Per installare il sistema, decomprimere il file nxos.zip in una
|
||||
cartella temporanea ed eseguire install.bat.
|
||||
|
||||
Alcuni programmi di prova sono contenuti nella cartella PROGRAMS. Per usarli, dovete copiare il file
|
||||
.bin, .com o .exe sul dischetto di NXOS nella directory di root.
|
Loading…
Add table
Reference in a new issue