From 7d6d50e4321d4a9720c5205da53fe38c07952570 Mon Sep 17 00:00:00 2001 From: albertoventurini Date: Mon, 27 Jan 2014 10:02:18 +0100 Subject: [PATCH] First commit --- BIGMEM.ASM | 419 ++++++++++++++++++++ BIGMEM.DRV | Bin 0 -> 602 bytes BOOT12.ASM | 392 +++++++++++++++++++ BOOT12.BIN | Bin 0 -> 512 bytes EXCEPT.ASM | 117 ++++++ FAT12D.ASM | 671 +++++++++++++++++++++++++++++++++ INTERRPT.ASM | 171 +++++++++ KERNEL.ASM | 250 ++++++++++++ KERNEL.BIN | Bin 0 -> 3640 bytes KEYBOARD.ASM | 554 +++++++++++++++++++++++++++ KEYBOARD.drv | Bin 0 -> 563 bytes LOADEXEC.ASM | 279 ++++++++++++++ MEMMANAG.ASM | 191 ++++++++++ PARTCOPY.EXE | Bin 0 -> 11502 bytes PROCESSI.ASM | 557 +++++++++++++++++++++++++++ PROGRAMS/ALBLUR/ALBLUR.ASM | 115 ++++++ PROGRAMS/ALBLUR/ALBLUR.BIN | Bin 0 -> 139 bytes PROGRAMS/ALBLUR/ALBLUR.SYM | Bin 0 -> 173 bytes PROGRAMS/FIRE/ELINK.EXE | Bin 0 -> 32498 bytes PROGRAMS/FIRE/GRAPH32.ASM | 53 +++ PROGRAMS/FIRE/GRAPH32.BIN | Bin 0 -> 78 bytes PROGRAMS/FIRE/MYFIRE.ASM | 191 ++++++++++ PROGRAMS/FIRE/MYFIRE.BIN | Bin 0 -> 309 bytes PROGRAMS/FIRE/MYFIRE.SYM | Bin 0 -> 255 bytes PROGRAMS/FIRE/MYFIRE32.ASM | 229 +++++++++++ PROGRAMS/FIRE/MYFIRE32.BIN | Bin 0 -> 360 bytes PROGRAMS/FIRE/graph32.OBJ | Bin 0 -> 206 bytes PROGRAMS/FIRE/myfire32.OBJ | Bin 0 -> 522 bytes PROGRAMS/SCRSAVER/SCRSAVER.ASM | 103 +++++ PROGRAMS/SCRSAVER/SCRSAVER.BIN | Bin 0 -> 150 bytes PROGRAMS/SCRSAVER/SCRSAVER.SYM | Bin 0 -> 206 bytes PROGRAMS/SHELL/SHELL.ASM | 238 ++++++++++++ PROGRAMS/SHELL/SHELL.BIN | Bin 0 -> 696 bytes PROGRAMS/SHELL/SHELL.SYM | Bin 0 -> 572 bytes PROGRAMS/SHELL/SHELL2.BIN | Bin 0 -> 673 bytes PROGRAMS/SHELL/SHELL2.OLD | 182 +++++++++ PROGRAMS/SHELL/SHELL2.SYM | Bin 0 -> 574 bytes PROGRAMS/SHELL/SHELL2.UND | 1 + README.md | 0 REBOOT.ASM | 2 + REBOOT.BIN | 1 + SHELL.ASM | 330 ++++++++++++++++ SHELL.BIN | Bin 0 -> 862 bytes SYSMEM.ASM | 49 +++ TEST.ASM | 150 ++++++++ TEST.BIN | Bin 0 -> 483 bytes VIDEO.ASM | 464 +++++++++++++++++++++++ VIDEO.DRV | Bin 0 -> 533 bytes install.bat | 19 + readme.txt | 9 + 50 files changed, 5737 insertions(+) create mode 100644 BIGMEM.ASM create mode 100644 BIGMEM.DRV create mode 100644 BOOT12.ASM create mode 100644 BOOT12.BIN create mode 100644 EXCEPT.ASM create mode 100644 FAT12D.ASM create mode 100644 INTERRPT.ASM create mode 100644 KERNEL.ASM create mode 100644 KERNEL.BIN create mode 100644 KEYBOARD.ASM create mode 100644 KEYBOARD.drv create mode 100644 LOADEXEC.ASM create mode 100644 MEMMANAG.ASM create mode 100644 PARTCOPY.EXE create mode 100644 PROCESSI.ASM create mode 100644 PROGRAMS/ALBLUR/ALBLUR.ASM create mode 100644 PROGRAMS/ALBLUR/ALBLUR.BIN create mode 100644 PROGRAMS/ALBLUR/ALBLUR.SYM create mode 100644 PROGRAMS/FIRE/ELINK.EXE create mode 100644 PROGRAMS/FIRE/GRAPH32.ASM create mode 100644 PROGRAMS/FIRE/GRAPH32.BIN create mode 100644 PROGRAMS/FIRE/MYFIRE.ASM create mode 100644 PROGRAMS/FIRE/MYFIRE.BIN create mode 100644 PROGRAMS/FIRE/MYFIRE.SYM create mode 100644 PROGRAMS/FIRE/MYFIRE32.ASM create mode 100644 PROGRAMS/FIRE/MYFIRE32.BIN create mode 100644 PROGRAMS/FIRE/graph32.OBJ create mode 100644 PROGRAMS/FIRE/myfire32.OBJ create mode 100644 PROGRAMS/SCRSAVER/SCRSAVER.ASM create mode 100644 PROGRAMS/SCRSAVER/SCRSAVER.BIN create mode 100644 PROGRAMS/SCRSAVER/SCRSAVER.SYM create mode 100644 PROGRAMS/SHELL/SHELL.ASM create mode 100644 PROGRAMS/SHELL/SHELL.BIN create mode 100644 PROGRAMS/SHELL/SHELL.SYM create mode 100644 PROGRAMS/SHELL/SHELL2.BIN create mode 100644 PROGRAMS/SHELL/SHELL2.OLD create mode 100644 PROGRAMS/SHELL/SHELL2.SYM create mode 100644 PROGRAMS/SHELL/SHELL2.UND create mode 100644 README.md create mode 100644 REBOOT.ASM create mode 100644 REBOOT.BIN create mode 100644 SHELL.ASM create mode 100644 SHELL.BIN create mode 100644 SYSMEM.ASM create mode 100644 TEST.ASM create mode 100644 TEST.BIN create mode 100644 VIDEO.ASM create mode 100644 VIDEO.DRV create mode 100644 install.bat create mode 100644 readme.txt diff --git a/BIGMEM.ASM b/BIGMEM.ASM new file mode 100644 index 0000000..0ee2cd3 --- /dev/null +++ b/BIGMEM.ASM @@ -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 diff --git a/BIGMEM.DRV b/BIGMEM.DRV new file mode 100644 index 0000000000000000000000000000000000000000..df41c73393d5af555b17b26da9b483deaf689178 GIT binary patch literal 602 zcmYjN&1(}u6o0dgi3Frpv`YON6!#)sTK8BL(~Cs3#Cm9~hc-=i(m+jgJKJ6pY(ctp z9sCa@|G~m@BpHd)g9jxo#Mvxr2j2YNypP}Sy=kkC<&+PCTzmqn zRk`>KcoZH=570ZD-vTN#mfu43xCau&9`w+|9t7xs2RrC~#%g>Y)cBaNEUNK~0!zZe zs5Z?bXxTA_7~?YH3BxiWy|kmmq>Ag6DK$oVh76D~(6;l}tT z#NF8C@t`;3-;xzkqKury()=aHmK@`U`8vA%iXLE0PXEshGZtNPXruN1WZOn$!l%Aq z{327N(Cl;oNTnGjg_i((AT)V3?sl)(l^~h$l~l)EGe26+Hdd!(-kR&Js=xqa<~o@QT@zc3d&GqePmWYJeC0my7TY#jXfp2F9~vq9b7R_f zJ_$$ZMREx#_et_7MNx8O(!ARA;qHD)j)l(;t>d z&kLdy4@pPbf}?*xB4q>sy~mvLPO!voR^8&FLj*RDx+2p(-six*yRf_aT6+}9Vold` tI?g4NhOTQVyf~Yg)A0Oah9+k-*)*m(tezU2$xy6oi8*{dm(q5H;Sa^Y_h|qC literal 0 HcmV?d00001 diff --git a/BOOT12.ASM b/BOOT12.ASM new file mode 100644 index 0000000..1d5d10f --- /dev/null +++ b/BOOT12.ASM @@ -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 diff --git a/BOOT12.BIN b/BOOT12.BIN new file mode 100644 index 0000000000000000000000000000000000000000..2673e5d2221895213b7b45a43c514b1db2b3a41c GIT binary patch literal 512 zcmaEDGl7A8V0fVKM&E@!3^kokJHk}D+yuU-i7~tJb(aZlWbwQF&TT(4!;3D4fbK9s zIrjYwY+e-^`##t1%7tU`v-rqghS{3 zi?_Qai#aa7hQNmB{FXOL9%+6kkqhpM7tUNb!|+h^NArXF5*EuFWsH*pI)4XlWWD@2vhT3r?XEDDElg*H zixxyjL^0kF_{4Z$^Iqxd!(6UKMfpVvt`(`tr6rkp=?ZR+A%;c@N%{FD#i_|9`9-{3 t0Y$0B#R`del?vIZl?o;K3Pq_PX 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 diff --git a/FAT12D.ASM b/FAT12D.ASM new file mode 100644 index 0000000..b6f5bf4 --- /dev/null +++ b/FAT12D.ASM @@ -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 + +;------------------------------------------------------------------------------ + diff --git a/INTERRPT.ASM b/INTERRPT.ASM new file mode 100644 index 0000000..eb3d350 --- /dev/null +++ b/INTERRPT.ASM @@ -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 + +;------------------------------------------------------------------------------ diff --git a/KERNEL.ASM b/KERNEL.ASM new file mode 100644 index 0000000..894b870 --- /dev/null +++ b/KERNEL.ASM @@ -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 \ No newline at end of file diff --git a/KERNEL.BIN b/KERNEL.BIN new file mode 100644 index 0000000000000000000000000000000000000000..0ac7f4a3d7409373fb27580831f0d07128a0be9b GIT binary patch literal 3640 zcmdTGZERE5_4@n8jbC4(jc9@JM8OSfxlr7tqD#Lrk}eFW3$=kWlA!@h& zn6zJe(!2MZd(J)I=e!q3T-Wfad8KPKu0ts<@#9=_1(8>C$S;`0Pjks9h%DD6-p(a| zL1d>saUqv{h{zH{kENGQaXn_ZptF#ZC~-GSo;Qew6B;sTNUXDvw^3p>OSWf^erHHL zYazcx3Cxm5vPZ8P5+7K|%cvKn)+P>G$cre!v1Fw|G;a0{%is^Y?kwapOM9ExKAu&bGl78%q)ZKAZVf!d`S6rXnG}+Bm zaZ-c&z|Xtzv7<|p_$Vy)3TH2S(u8oQzHLAP1-w_f8+?kZQZqFf%8PutGpiNZ!MGAJiip!nbj>|p$# zhR+S3GoS0Y_@Sb*lzaZ9=77R#!148P;EQkcN=n6-gvWGknG_zeE2kfU>a$~ z3}wWdjjwU7yg`fb{Q!}6<Jy*v+!`vy#4t zzwr)a`^M{uYg%@dsT$&hzV_HFAbFL}eDbd13=c6qJn(ktOE1j`gj2)~*3OdK)^J7K zRB(+|F1hFH#`ZC&->vJ^7x6)D55gUWOEq6-SV+~KTjKQB2TV-Cn2)d`6+vLXjf?>sbb1YTgvXB?R*vjwxDv!lUXI#HjlJw z` zEEn!$u*~jfl6H{(5<@2sjuh@^K&?tFRgc5-Cdml2>#n42eC*1!o%GI$tI64UdHA^b z!sYO3t%Ljx5SwDGBzf~BXCAWenn}*s&byMp{mPuU;g3%s2l>N1IRtza<^3Vl7eZ=^ zA!!p;&-Eh>-2LkuNzKu_NqW=nJbZXMp(v%Gzj@_?fx+u)Fu~T3f_gfhb>kTWI&wsC zC7sa$wJ_Tm`7~6?{SkibOgOtdqwJVcjbMy-`kOaNb{%Pd{Yl+-|% zWpuGJE(_8+BNwfaE&AvHtXgZNNTBMbVf?RAqok(nB?f;FA{Sig+!3Bvq&sc}^g1n~H1-)-y;L`@R$Ds*Ns$j7WXROq%-Fo$SV_~=--KZN;qEt>_yZcAoDz$q&e9R=$j%KBW)M27*RuD>q8@?HZInZPj+ z5@}z?j9gvJvZ#mreg&ES5_IfisF_rv^F$rlGcP~8R_0M z`T6VzT10Nlrb*Xanrwr;0^TMiO?JW_gZE`kn##P5$~04%Icf5vi8Of&-q$8n+C7xE zg3^{#eSqpIYLJ$vNoHz>YN(!0lX7^Qvgnrpo|^hk!8hT2>r9%|&!iWk@ON+zsqSe} z{0bn;ROB8MzX`|+70IWLPqV8M51KPe5C!aJ7?%`iG{gUtvsahmX*(rWn|n1UOwcd@ zA2Gwv7yOvP4;V`E7IUdb@-*;XQ4ENWAimDm;%oK={Cv$`exFwi@C81<#BbbKzYbf> zi1+zhJPp1&KG0MfsPirm3m1q@VxZRB+#C>j?~9VxuZr;pB;G^scxoDM@jsm9f2Q8c zFI?eUeGLtKjhC0aVx!ORk-T+O9sRgf8p)AKaT9dT#$58-Dcrp)caWH$kcV-1eJ%tO z%XzzUZ3?+LNywx%hR~zi-N8-t>-7LKk`2g29z&!Ex<8LW(E-h{RbylkEP3bzBG00X z5hXU|l8ZM@)#@h;_{?bVve7|2Q*NxutItg)trJEgQWWXFd}s8uRR@Bs@?*(Zf8*NY-CGmzh;@sMw+_CA*Oqlc^g{bI(r&mV zyvDa1jQ^G!&GlX=^8$6lH9r4>@)Fv6{CYJ){34O3t+Oi-^k-W^gwEnU{=Ga{#7hCb zHsF_h{-8JO<(2@yHxT4oJ0 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 ? \ No newline at end of file diff --git a/KEYBOARD.drv b/KEYBOARD.drv new file mode 100644 index 0000000000000000000000000000000000000000..87616625546557e635168784d1a3e2f6417adf30 GIT binary patch literal 563 zcmY*VL1@!p6n_1iW}`awA_FN+bRicZrNotKbI?n{i#8TUy299@c=qu3{^Jm~Mdn59 zQEM-|D3JxMw@Cz7AqG565D^{ikJXEcLQ;$`tsea0=lgi?d+&Sih5Fw1UT+c9?p?UO zuXgW&+EGC37KqwW5sRd^lv2COB&mW+c2mC0#y}M|PSFK6CJ9R?OrU4jI73gfu}D!e zL#2S9gMeR$R|I$=74Q=NIgG3z?jqiRAhFjv=!O>cM-M^?9wT)g-WGdx(O}8E-~1|h_qVw^0oh~Ci2kEqkg8G&p|_qyy~*v=l5e{ zjuwqsn%xj8mt63b(dbs64zFBx@Im#v*tYF?_xGgKgqlqvQJVra=!Bmu=SEJg7cU^kDVX 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 ? + diff --git a/MEMMANAG.ASM b/MEMMANAG.ASM new file mode 100644 index 0000000..a8fa6b6 --- /dev/null +++ b/MEMMANAG.ASM @@ -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 + +;------------------------------------------------------------------------------ diff --git a/PARTCOPY.EXE b/PARTCOPY.EXE new file mode 100644 index 0000000000000000000000000000000000000000..db2c76d4bfe4a2d151d75201097184a39c03c7c6 GIT binary patch literal 11502 zcmeHte|%F_w(rjQl{77FfLM@mYA8^FYGvr1I#7O8D5v6&8bMPcPzI$iD7JpmlNRTe zklrxB$)=3Io&%2e4vyYCh>U~xRt-2$YYUB{AcYwP^dXNjdcvuQP}#^nd+oi~UVHu8YxkZ9&y!KaLR@5PhGG0eR*)p0S$J8 z^!Q$5ef;8Uoy+Iu{Y3Ql1P=v!PpFw;ve!b6b%xq(q0T-vXDiuqGXET%SOAa}Ek9xti~I+rmJjN?zJY?!eIVQL!^j z0&p!KTWo12hsLPc&k;3q8?m=28IcmQwdL){NnX3vQuwtw_d8Ar(`!eFQM4J~jreXL z+BAz>dokTa@Kn6xGEsg{mQ}WSDokKu3%#)SR+7gF!9NlCOz$mAhAC-#uP6I%CEDi< zk9IZR9hSL6WA|o~eRq)9pGi)H{P@sVHAlhD)RBl_R@S2Oa}p8FN&_kZ5|PYG5S4!- z5i()R!L29v?XVmgdt)1hm~bFl!Rl_zi3ljJO%_EI8i%p*BfBQT(a$19}pOj7f&1So4f! zoK=54s_S6g$5xe;x9bI3jqDcG9R#A)Y@2v6MFdOI^Y574g0t|0ML&^jq9_Ye}5 zy9o&e1j%1O+eJGNZxOtzr$?2$=@L68Qk;fjk4yr~Cy()ZBZlGDCfL3D6!a05$%QTM zCOPQF3xCExX#X`kwBODkkz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v}vEZfa;hFQ))xv6fK&f}U41P5okl*nKa}YycAd>KGSC~FCvrQ`C_^jP%P>r+>>3QX61#`p zhG?rzj37iKH#lQDwB|v>926zDp@SY2%2+zZ5-Tx);m0N0tI25`5Z@;GRfJF&XY7#7 zwh=O!6qvl84Q`LfU6cFy*uva&ybE)|^S_RT>Jj}9#zO3v5Rho^)D~pUSl$d~=+dl}<0?zu{4a-y^ zU+}<@FJ^<$BZy^33}q*0Vz7J+_M@gZ*Ba&(!7Hq5{sr2e-cmQ#!z$?N8tR&fuF3)Q z;#>3ES=PWdLXcB+mJ;4$$Zip^1O}%&GCMSzf)u zH8(%sb&G3m&Erq_RCOIO#eUQy+$^7(3f!|b;|R9)kHY&lSUHLHBfA9DfyvDMYfmDM%X!|-n_|2xl$ z!z&J7igp=jBdDxIp`^-J zv!=G-;hM+n4=lXBY~FPHgj!c^jomOMq z)xOS7<}R>&Er+oDXRV_@HKQL+vMe| z*Ho==DK#!%)$$dCYg(?jQtO$pW)ZoHQ}0`?e4py?W0Lu$^IY?*SF+J+{c9B0gcVrK z6KhsiuK<@ZqaS~EatEfmT3cB4uu^kP>%!GPuLA0t73^y#_tdPYS~J~6>j^8`~-TV-4dnN#m$4C7SL>Q`7 literal 0 HcmV?d00001 diff --git a/PROCESSI.ASM b/PROCESSI.ASM new file mode 100644 index 0000000..2d1734a --- /dev/null +++ b/PROCESSI.ASM @@ -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Ť 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 ? diff --git a/PROGRAMS/ALBLUR/ALBLUR.ASM b/PROGRAMS/ALBLUR/ALBLUR.ASM new file mode 100644 index 0000000..a48b05b --- /dev/null +++ b/PROGRAMS/ALBLUR/ALBLUR.ASM @@ -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 \ No newline at end of file diff --git a/PROGRAMS/ALBLUR/ALBLUR.BIN b/PROGRAMS/ALBLUR/ALBLUR.BIN new file mode 100644 index 0000000000000000000000000000000000000000..8f86e71ac0eac680b8bfb229c8bae85123a7cc89 GIT binary patch literal 139 zcmdlWd{$uBNoKEiP60*--o1+mu(?#uw1NL!#J>ZjueLDka$q>C%qG8sVL{)4y|#=q zW`;Gsb7Xws$kt#%y3p<3)5zXvkE{XAm}gvU_3q- literal 0 HcmV?d00001 diff --git a/PROGRAMS/ALBLUR/ALBLUR.SYM b/PROGRAMS/ALBLUR/ALBLUR.SYM new file mode 100644 index 0000000000000000000000000000000000000000..74929f3ac220797e5276bec249be7cd437312263 GIT binary patch literal 173 zcmZRPW8e~K00BlY2_l%_tOkyqO!f@Ej-GzZybKHhjy|p-A+E;EyzC&hDKoD)gQF2M zuO5SszoSdA6EklkgQE#EuMdNdAv13XgAY(Hk|Bf5oq>^sg-KAATa@V{J5x+RkiUD7 rW1UfqqlHumi9R@Sd*N@B&~HU@0IEzyJ|e zY-k7k4Dc_29|67#*aDaY7zxM${EHEN0kQ!frW6|v0`>yF2bcr60gwXt$bkL;{{;9R zU=HBUv|__3z%v$%4_E{^nObZ(4A={}7SL-hHXH@)$tX752bd1{MS8Kp1?bEIPJktV z3_#b=V#BWh)c_OV&=BAYSPz&FZ~#nz-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|JhwE$-UZ2r9U%i^rU#CxJDqd>& EzjKE@e*gdg literal 0 HcmV?d00001 diff --git a/PROGRAMS/FIRE/GRAPH32.ASM b/PROGRAMS/FIRE/GRAPH32.ASM new file mode 100644 index 0000000..f5d9d76 --- /dev/null +++ b/PROGRAMS/FIRE/GRAPH32.ASM @@ -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 \ No newline at end of file diff --git a/PROGRAMS/FIRE/GRAPH32.BIN b/PROGRAMS/FIRE/GRAPH32.BIN new file mode 100644 index 0000000000000000000000000000000000000000..24511411977f154794114044790b1e15f8a2cd72 GIT binary patch literal 78 zcmdnOyvu>%tiJJqz5_cLS#~lsq=l=cce1B7A7^^>EiHbBFvD4aw0#T=Tns=twe)Uw epe!3mHm&&>)1!A=7|yEhUkIv%|1I{dEd_`Abw#s~Ti=q)s6)a&Nc2NGh2jEoo5nEAMQ p)U?I8c^FUWEe6VUg5)}Za;pE?EpL>uXx@1JgZ;3edMZP4EC7jejv4>} literal 0 HcmV?d00001 diff --git a/PROGRAMS/FIRE/MYFIRE.SYM b/PROGRAMS/FIRE/MYFIRE.SYM new file mode 100644 index 0000000000000000000000000000000000000000..95e5c8607cd2aab3f9ce5b647ab3cbbdc3165930 GIT binary patch literal 255 zcmZRPW8e~K00BlY2_l%_tOkyqOp_UW9X;R zerE6i>TY0g^9*tg4PfT&V{ik??__ZH_X}ZGFlKZ#WLD5;bTndCFl6*Gj1OYwRb_PZ z^m7HVbQ#yPxiT=au(;?da|ke9WM_&A2=aFia;!6oakMat@ehsx8Oy++kXxCSS(K`m QSey%VJ`f=IU@pUa04kz70RR91 literal 0 HcmV?d00001 diff --git a/PROGRAMS/FIRE/MYFIRE32.ASM b/PROGRAMS/FIRE/MYFIRE32.ASM new file mode 100644 index 0000000..7c3c018 --- /dev/null +++ b/PROGRAMS/FIRE/MYFIRE32.ASM @@ -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 diff --git a/PROGRAMS/FIRE/MYFIRE32.BIN b/PROGRAMS/FIRE/MYFIRE32.BIN new file mode 100644 index 0000000000000000000000000000000000000000..bfcf60f1114ea8acd5762e9e92ea005abe4b8f79 GIT binary patch literal 360 zcmdlWd{)5tWY@#4p9kJEz4*`I*!+{b^h4Lf?JO@ofjFY2pMjD$8(xb5MIL}e97^A9 zv4@B-y*LLF2`PQI+1}{?i-RCeYU$_g_AjihQQqpj4#?4B3T`Nr-h|4 zf7tLpy@M?+&a?Dcn(;T|1ICxqyV@H5{{PQ>A-&5DLNbEbZ4QhK49ph}zG6!6n0Dab zf1tK$Aa!YOr6+ePRHt{dsdciZH6LRF+U!~SVT<5dv6A*J3}?l5Ff*JL*uu1#;jF^0 z6U6u&%1JF!PzXycD$dN$Q!v#t znAsuB;PCQzM1&Ty##J56KvAD*ObiSeAm+j;)7ThToc&!~U1zW}B=|8fF*2_2U}11r z#5i$55CbCv!xrXU4h(1YjSuu4*uluMlc6CkTrItmJ+1jT)1z-`@jHYW&I+XMV_@K7 q0LrPQce4X!*+8;s&BvG?z1zZYR&@t6P|X&m%?xK1-gg0QE&%{or$hk& literal 0 HcmV?d00001 diff --git a/PROGRAMS/FIRE/myfire32.OBJ b/PROGRAMS/FIRE/myfire32.OBJ new file mode 100644 index 0000000000000000000000000000000000000000..a07865832ee41a7113e57773437c107343aa91ce GIT binary patch literal 522 zcmZqRW8lfHOv@}vH8#>qEY4-?P+(wSkO?U*O3GJoEG|yXP0C3vQcws>Eh^5;&r>kf zGnm;S!r<_dD?CCAMdzCiW}vXoG$say3=nhSlxb`XEYAKeuC6oK84@xWnHU+Tbg(cu zEMlCvAcK*SfnkI2SpnmdT@Sl{9(d36;y;69^H1*54_yzpv%L5O;)s@h21?#+cr5}H zc>oe|D1EoZ9wNf@;v7gMr1afpd!zp^4uUwTrJuLkzu3m`?_kTx(yv>XcR4Ve)lbvw zv`b+$KG1id@5WAs2DS7~_O#~XOpm_pU|7(1AkFwdnqIeA3S*k_|DAUj0(UzwzG!2J zWOewR7M8~RVZ;CQ4z{#7&(ddU#@~z&7+*^7YHRrW|3CAE^e#6D$p~V%IRO2`eBt0L zru2?!2mbvBYMTa9m*!S_a;HLddN-R|Cu>^sF(#nRo~0kQ2%Z%yY2U(dR%{0|!&!kX zOq&_bD(pJJ+;#AsQ`eDqU5DRw9e;P24diIOg-MKh-F$ICLM(xi`H&hjA2*Mhwiq`L z^F_VIK)FtkTqjUY^*_7y;WD-f6SNP%{>FY-P(78QIM!*7BEyla5XK|jA&f`WfmjEK U4T0Dhh&_PVH-u583m9i507!t?0RR91 literal 0 HcmV?d00001 diff --git a/PROGRAMS/SCRSAVER/SCRSAVER.ASM b/PROGRAMS/SCRSAVER/SCRSAVER.ASM new file mode 100644 index 0000000..73de60a --- /dev/null +++ b/PROGRAMS/SCRSAVER/SCRSAVER.ASM @@ -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 ? \ No newline at end of file diff --git a/PROGRAMS/SCRSAVER/SCRSAVER.BIN b/PROGRAMS/SCRSAVER/SCRSAVER.BIN new file mode 100644 index 0000000000000000000000000000000000000000..06af722d0cbc2cac2ca5502e5c66f60fdbe4405c GIT binary patch literal 150 zcmaFi%dp#@VaI=l7k&&~7j{c9?67Be;mpwWVGHwFh0f0hA9HMBIxDdIKUj%2L%?o+ zh8^+@FBBQNZbWQhIIFUS@vLgeULZ?#3)5zXvkF1G92nj%p1=@wIAGxfhJy!~b=etA wnHVmf=;oWmzC0Oce+MF0Q* literal 0 HcmV?d00001 diff --git a/PROGRAMS/SCRSAVER/SCRSAVER.SYM b/PROGRAMS/SCRSAVER/SCRSAVER.SYM new file mode 100644 index 0000000000000000000000000000000000000000..19315cd3d8eab068adbb1239cfcba61379fe219d GIT binary patch literal 206 zcmZRPW8e~K00BlY2_l%_tOkyqOo0r(j-GzZybKIMj(#rwzMfI8%)9{%KK}jzhRnRo zP*G;yC?AYwx$RtqDpGmeJ1N3u?(5OUq5Ay5NUm;ARZ8kswHBQ$o9E~P((iHO_?4?J zk8((V81I*2tamfl^d*XO$#nVx=}(iObO$Xrs#~WAukmm=bQ^0&1-yQi4~T0F*Wcz- zf<}3C?fV|M$GbWc8L56_!^TPa-T8jSBt0J|-8{Q!>!SoVJ}THpF;2iq0cEI@q2xD8 zkfYcB9KHu57nL@rs$YJj-%jB_3?&aaYYobXk~z=kAf$q}j6{nP1Jy*2`Cbd!8O6H% zAG9gET{cl7Gk0orG`n~Y%`Pm>-(9#*N&V5{5`-P@`;=V&dnln~UiLvrh(Zpk2)LTGXUOz$!@ea?c=`a#$XI2V?&=akJC*|&@>JE71o&adDj literal 0 HcmV?d00001 diff --git a/PROGRAMS/SHELL/SHELL.SYM b/PROGRAMS/SHELL/SHELL.SYM new file mode 100644 index 0000000000000000000000000000000000000000..db7baac0841385592a74e2cf0181974a9972e838 GIT binary patch literal 572 zcmZutKT88K6o2U}R+QKbf}1!xiETv$r|UIW4=~9N86jE)Bjd<*G)KAwJZu%pDj2TK2JaXiYF~y(*P#G%7wH*^q;0j`u(4P=kR4Y;H7>SpYDTp>l0`b@{p z@vn1kwj+`r-If_DXVxr3=$L*jy8) z!N_Fk!t_0yrH<^Dcz(b`X*?O*-P50;QbTt2&y+UlJV_%2HVCq3ax)`*w#a;mt{;QX3J()c4rfF6cJSD zt(V?<2t9Zb+)FMag@OuQ1jT>A+fs@L@z7GVvzut^Kj1sP`QA6*k3Vu52Y5#d2X{00 z`GL&fKnow2CO1=gU6A~I^CAoDsUK%+2jb+7qCD9g$Q$Biq3B=Csb}{dlHYOp{EI0b zc2h_m_Vxz>mRpHx^ce-Ia4`CW#RX@ongu$XFjJoc@k}Ucw!WPTn$FZRe0qCM}x*cLdZNpI3FFpdxQl+p0n>Inf5Y zg;tzKgZ7z7%~-L7#%Erk@#)#AiRss+cQdolG~k&rVhro#>Hnh>olH3`5Dxer15vj; z@aoLAb2_nV&~|)iQ7+;;TV@qsFrZwmg1Ma9uwZdma-Bt&HnQ;E_Y|?c6w9c9H(9gL vvP2zX>G&h}EQcGh@o1A;HeFC{6HDm#@RT=z3ZH|D&8Qp8fmd-E;HPjicfDR)F+<4j&&&J0S6+cR)=v+~?(`}Zum0>)X+T297d4~=A|=Df zAiE^43`0k>kS&omHzPzB!N@pr9nFz00~f7Ase<9!Z1RrbLiN6cX z%NNl`Dn8NrVjK+F%OAOp^bV#g8c6SL33p?|?S|UQ36VZP(--4U*(=E%mM%>1U~^5F z1|yTD3)A;-mO8Rq;`sp=(s(kqyQe=xrH1VKpDAt9d6Gs5Y!GD6eSuI-LaCRui-;GHarXLkhngjzm+Rbi=a z1o-Vfp623NulkSR=;P!#Yv)mM7L z1L){J1o4g*#8U^s<;C*M&gp(aZMWO|%Ol+-$RD>WVI0aYjy9CdvzVh*gt5(cu}}kH zYj_&vBfmhB(P@4e^9(b*A3G$ zRz&QcEgS@L#a={_AdOXv7>+CFp<8tbu_Ys8rNtN8l#Dbxq|Vc((IG38G8d^Mlpd?m OrahR`av5oeL;e8{H6Ka< literal 0 HcmV?d00001 diff --git a/SYSMEM.ASM b/SYSMEM.ASM new file mode 100644 index 0000000..bfb8203 --- /dev/null +++ b/SYSMEM.ASM @@ -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 ? \ No newline at end of file diff --git a/TEST.ASM b/TEST.ASM new file mode 100644 index 0000000..42fdfb6 --- /dev/null +++ b/TEST.ASM @@ -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 \ No newline at end of file diff --git a/TEST.BIN b/TEST.BIN new file mode 100644 index 0000000000000000000000000000000000000000..187d7dc20c5d60a90038ff7b12a35228e8421e36 GIT binary patch literal 483 zcmaKny-EW?5XbitK?nq2VaNw0%_(S=&WM5tDte?8_HvWBcpu?*70)-&yoqhDve;g5 zL0j#71S?DD?lzc0Y>u1X|6^wL3(K9wy6Nao`;*rV+<(!xqrX?s{H;VAPG!$)W^?{p zqW&*x7p}5x&%&o3%b98G>B{WT{AcK4*;L>DFkSsW)nYGEJOsQ| z7zY?Ygi(@agCa2G673B9hKrC>yi|6>Fd6f5_s$j^`I$lq$;6ten9^q$BA3N^|5)gj zY09H$`HCyd{Dh}LRdF)IxKKDu1RdU^Ez0#p+^^(=0!nd*16s$Jw}0-r!^30t0~lhg AMgRZ+ literal 0 HcmV?d00001 diff --git a/VIDEO.ASM b/VIDEO.ASM new file mode 100644 index 0000000..6dc1584 --- /dev/null +++ b/VIDEO.ASM @@ -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) diff --git a/VIDEO.DRV b/VIDEO.DRV new file mode 100644 index 0000000000000000000000000000000000000000..af9ad9306539cf58a1fc83fc3a191d9a33764c50 GIT binary patch literal 533 zcmZ9J!D|yy5XR?aliem7yT>S0qpdl3QiHb?^&;N-vVmr^LVENM@Kvv`=)vqt6utB) z)LSnxS#{&ZZ5I+1mS_|_D5wPKi&3Hko3bpszJ%hz2fxeAyqWKt@v?T+wo;JUxCeJ$ zW;X7F8EGIlO?@B>)JJ5V`Vn%1`T{vl{V3sy7&%6LksPJIMCLkd4m#``XO|O09d?Ry zmqR#@p@R!~W!V(mbS_CQ<`U%cEt}lP#R