Running of TR-DOS Operating System
Above video demonstrates trdos while running. TR-DOS has partial ms-dos compatibility feature but it has almost different kernel and internal structures for prototyping of 32 bit Singlix operating system. And also, it uses 100% different and fast file system under name of "Singlix FS1" or "TRFS1" in addition to FAT and FAT32 file systems... (At the beginning i had thougth Singlix as a bit like as Unix but nowadays i think to develop Singlix more near to DOS as 32 bit protected mode, flat memory type operating system with 100% different executable file format than EXE and ELF. But, in fact, Singlix operating system will stand between DOS and UNIX. System calls will be 100% different than any operating systems. Device and file handling will be separated (for example : open device and open file will be different system call subject). I am at same point just as at the beginning of TR-DOS and TR-Multix development idea in 1998 in my mind... The main factor in this (singlix/multix) idea was and is the "DIRECT DRIVE " concept...
TRDOS 2011 (TRDOS 1.0) project files
RETRO UNIX 2014 (Retro UNIX 8086 v1) project (http://youtu.be/qt7ytl-VMWw)
Running of Retro UNIX 8086 v1Operating System
Above video demonstrates 'retro unix 8086 v1' while running. Retro UNIX 8086 v1 is a 8086 -IBM PC/AT compatible- derivation of original UNIX v1, PDP-11. I have written this simple operating system completely in assembly language (Microsoft Macro Assembler 6.14) and i have tried it on Bochs Emulator and also by using a real 1.44 MB (3.5") bootable floppy on my old pc. Except tty (multi screen) functions, i have used (if it is possible) 1 to 1 equivalent kernel code (almost near to original PDP-11 code but of course, I have done some modifications due to 8086 register conditions, otherwise it would not be possible to port it). I have used INT 20h and ax, bx, cx, dx registers (in order, ax for function, bx for argument 1, cx for argument 2, dx for argument 3) for system calls. Due to get/ensure multi tasking and multi screens, i have adapted original PC/AT int 10h (video functions) code to Retro Unix 8086 kernel with ability of write/set each video page instead of active video page only (as original int 10h). Also I have used "Alt + F" keys for multi screen (active video page switching) functions and also I have separated keyboard keystrokes for each video page by monitoring active video page during keystroke. "getc" procedure responses to it's caller if a keystroke is present for requested video page (it was not possible in DOS and standalone programs which use Rombios.) "Sleep" and "wakeup" procedures ensures that. (if there is not a keystroke, process is sent to sleep, if there is a keystroke on active page, sleeping process is awaken). ("S1" to "S9" signs are for sleeping in 'unix.tst' test kernel run while "W1" to "W9" are wakeup signs).
RETRO UNIX 2014 (Retro UNIX 8086 v1) project
DOS File Name File Size Long File Name Description
WIN95_~1 ASM 32.547 win95_boot_sector.asm Boot Sector Code Sample ENABLE~1 ASM 4.408 enableA20.asm IO Programming Sample IDEHDC ASM 23.440 idehdc.asm HD IO Programming Sample HDPORTS ASM 6.261 HDPORTS.ASM HD IO Programming Sample SIMPL_PM ASM 3.851 SIMPL_PM.asm Protected Mode Sample SB_DSP ASM 4.854 SB_DSP.ASM Sound Card programming SBDETECT ASM 9.896 SBDETECT.ASM Sound card Programming VOODOO ASM 3.512 voodoo.asm Unreal Mode Programming IE8086 C 51.517 ie8086.c CD-ROM Driver Source Code BOOTAB~1 DOC 117.760 BootableCDFormat.doc Bootable CD Word Document ISO966~1 HTM 22.288 iso9660.html ISO9660 CD-ROM FS Document ATA-AT~1 HTM 38.484 ATA-ATAPI_HIW.html ATA-ATAPI Explanations JOLIET~1 HTM 29.198 Joliet.html Joliet Format (CD-ROM FS) IDE_RE~1 HTM 54.297 IDE_Reference_FAQ.html IDE Reference Document LINUX2~1 HTM 10.994 Linux 2_0 Boot Sector.html Linux Boot Sector Code CP_PAR~1 PDF 78.329 CP_Parallel.pdf Parallel Port Programming CP_SER~1 PDF 143.030 CP_Serial.pdf Serial Port Programming D1510R0A PDF 289.842 d1510r0a.pdf ATA Host Adapter Standards FATFOR~1 PDF 109.659 FatFormat.pdf Microsoft FAT File System INFO_S~1 PDF 81.155 Info_Spec_Bootable_CD-ROM.pdf Bootable CD SFF Document 3DNOW PDF 563.265 3dnow.pdf AMD 3D-NOW Programming INTROD~1 PDF 200.211 IntroductionToISO9660.pdf ISO9660 FS Document BIOSBO~1 PDF 183.180 BIOSBootSpecsV1.01.pdf BIOS Boot Specification PBIOS_~1 PDF 424.320 pbios_userman.pdf Phoenix BIOS User Manual INTELC~1 PDF 145.670 IntelCodeTable.pdf 80x86 Instructions Table V1VLLA89 PDF 168.521 v1vlla89.pdf MS FAT32 FS Specification LONGFI~1 PDF 86.091 LongFileName.pdf MS Long FileName Spec PCASM-~1 PDF 570.623 pcasm-book.pdf PC Assembly Book OMF11~1 PDF 161.416 OMF1.1.pdf Object Module Format PE PDF 49.441 PE.pdf Portable Exe Formats MSCDEX21 TXT 132.784 MSCDEX21.txt MSCDEX 2.1 Document AWE32P10 TXT 50.840 AWE32P10.TXT SB AWE32 Programming PENTIUM TXT 37.905 pentium.txt Pentium CPU Instructions PMODE-OS TXT 76.099 PMODE-OS.txt Protected Mode Development MBR TXT 12.769 MBR.txt Masterboot Document BIOS-ASM ZIP 37.262 bios-asm.zip IBM PC/XT BIOS Source Code PCATBIOS ZIP 147.725 pcatbios.zip IBM PC/AT BIOS Source Code ATA3-R6 ZIP 284.044 ATA3-R6.ZIP ATA-3 Revision 6 Document PM-9-94 ZIP 87.168 PM-9-94.ZIP Protected Mode Programming OS-FAQ ZIP 56.497 os-faq.zip OS Development FAQs OBJ_FORM ZIP 58.048 OBJ_FORM.ZIP MS OBJ Format Documents 386P_101 ZIP 117.845 386P_101.ZIP 386 Extender Source 386P_200 ZIP 313.803 386P_200.ZIP 386 Extender Source MYBOOT~1 ZIP 23.775 MyBootSector.zip Boot Sector Programming NASM098T ZIP 104.244 nasm098t.zip Netwide Assembler Document NASM098P ZIP 105.804 nasm098p.zip NASM Program v0.98 32 bit NASM098R ZIP 77.587 nasm098r.zip NASM Program v0.98 16 bit NASM098S ZIP 546.166 nasm098s.zip NASM Program Source Code NASM098D ZIP 443.455 nasm098d.zip NASM Documents (html) PMTUTS ZIP 207.788 pmtuts.zip ! PM Startup ! Protected Mode Tutorials (ASM) ATADRVR ZIP 84.916 atadrvr.zip ATA IO Driver Source Code READCDA ZIP 19.524 READCDA.zip Audio CD Reader Source WIN32HST ZIP 149.789 win32hst.zip WIN32 Assembly Programming DASM ZIP 426.065 dasm.zip Disassemblers (DOS) LOS4D ZIP 111.802 los4d.zip ! OS & Standalone ! Low Level DOS Programming 386INTEL ZIP 178.580 386INTEL.zip 80386 Programming Document SOUNDX ZIP 33.084 SOUNDX.ZIP Sound Blaster Programming PNPISA ZIP 130.840 pnpisa.pdf PNP ISA Specification v1.0a AGP30_~1 PDF 789.523 agp30_final_10.pdf AGP Interface Specification PCI22 PDF 3.835.430 PCI22.pdf PCI Local Bus Specification 78XWW-CA PDF 207.164 78xww-ca.pdf (Device Mapping) Pentium Modules (PCI Config) PCI_CO~1 TXT 1.538 pci_config_space.txt (Pascal) PCI Configuration Sample ATAPI-~1 PDF 532.117 ATAPI-SFF8020i.pdf ATAPI Specification Rev 2.6 ATAPI-~2 PDF 790.350 atapi-cdd3610.pdf (CD-Writer) Philips CD-R/W Specification ECMA-119 PDF 327.807 Ecma-119.pdf ! ISO9660 book ! ECMA-119 (ISO9660) Standard CHIPSETS PDF 557.628 chipsets.pdf Motherboad Chipsets BUS21B~1 PDF 66.901 bus21bridge.pdf PCI to Local Bridge Study ESCD PDF 101.994 escd.pdf ESCD Specification v1.02AUNIX Version 1.0 restoration project (& emulation programs) : UNIX_V1 (www.tuhs.org)Retro UNIX 8086 v1 (a derivation from original UNIX Version 1) project files: runix/UNIX EPOCH/TIME Calculation/Converter Utility (DOS program and ASM source code) : runix/
Microsoft Macro Assembler 6.11 (for DOS) full : masm611.zip (4 MB) ART OF ASSEMBLY book : http://webster.cs.ucr.edu/index.html (by Randall Hyde) MASM32 Windows (GUI) Assembler: http://www.movsd.com/ (hutch's home page) http://www.usb.org (USB Specifications) http://www.t13.org (AT&ATAPI Specifications)http://www.microsoft.com/hwdev/resources/specs/default.asp (Various Documents)Original WINDOWS XP English MBR : XP_MASTERBOOT.ASM XP_MASTERBOOT.PDF XP_MASTERBOOT.HEX XP_MASTERBOOT.BIN
Original WINDOWS XP Turkish MBR : masterboot.bin XP_MASTERBOOT.ASM
WINDOWS Boot Sector Code: XP_FAT32_BootRecord.html XP_NTFS_BootRecord.html WINDOWS7.BIN
SINGLIX FS1 HD Master Boot Code (MBR) :
FS1_MASTERBOOT.ASM Singlix_FS1_MasterBoot.pdf FS1_MBR.HEX FS1_MBR.BIN
FSFDISK.ASM (partitioning) DRV_INIT0.ASM FS1_MBR.TXT
SINGLIX FS1 HD Boot Code (BS) :HDFORMAT.ASM (formatting) FS1_HDBS.ASM FS1_HDBS.BIN FS1_HDBS.TXT HDFORMAT_32KB.ASM FS1_HDBS.HEX
BOCHS_SINGLIX_FS1_HD_BOOT.TXT (bochs for windows snapshot)
SINGLIX FS1 1.44MB Floppy Disk Formatting :
TR-DOS Running in QEMU, with SINGLIX FILESYSTEM, download this one:
SINGLIX.EXE (installs a.disk, b.disk, c.disk for qemu, with singlix.cmd, then runs singlix.cmd after setup)a.disk: Singlix File System (1.44 MB floppy disk image)
b.disk: FAT 12 (bootable 1.44 MB disk image with kernel draft "trdos.com")
c.disk: FAT 16 (hard disk image 64 MB)[ use simple/common msdos commands (dir, cd etc.) and "show <filename>" command
after launching trdos from a.disk or b.disk ]BOCHS FOR WINDOWS DISPLAY SNAPSHOT: http://bochs.sourceforge.net/ Bochs IA-32 Emulator Project
Virtual Floppy Disk: http://chitchat.at.infoseek.co.jp/vmware/vfd.html (for creating a: or b: image file for Bochs Emulator)SINGLIX FS1 FORMATTED hd0 (C.IMG file) BOOTING IN BOCHS EMULATOR: (19 May 2009)
This 'hd0' drive with FS1 partition is created by using 'fsfdisk.com' and 'hdformat hd0f' commands in virtual B: (a.img) drive
Bochs VBE Display Adapter enabled Bochs BIOS - build: 04/18/09 $Revision: 1.230 $ $Date: 2009/04/10 16:36:34 $ Options: apmbios pcibios eltorito rombios32 ata0 master: Generic 1234 ATA-6 Hard-Disk ( 63 MBytes) ata1 slave: Generic 1234 ATA-6 Hard-Disk ( 127 MBytes) Press F12 for boot menu. Booting from Floppy... Boot failed: could not read the boot disk Booting from Hard Disk... Singlix FS1 default startup file running on disk 80h Volume Name : Erdogan Tan [ 19 MAYIS 2009 ] Volume Serial No : 0012-DA6E Replace disk and press any key to reboot... _SINGLIX File System Project (as single/standard, ATA=512 byte/sector, ATAPI= 2048 byte/sector disk FS)
(as an alternative to ext2, ext3, reiserfs, FAT, FAT32, ntfs and iso9660 file systems)
the Fastest FS ... the Simplest FS (except FAT16 FS) ... [ for all non-sequental (random accessable), file based data storage devices ]
FSDISK.COM: Singlix FSFDISK.ASM (standalone program, for singlix HD partitioning functions)
DRVINIT0.ASM FS1_MBR.TXT FS1_MASTERBOOT.ASM FS1_MBR.HEX FS1_MASTERBOOT.PDF
Components of SINGLIX ATA/ATAPI disk file system:
* Boot Sector Parameters (BS) [ Basic features of SINGLIX file system ]
* Master Allocation Table (MAT) [ Disk Allocation Table Descriptor/Header ]
* Disk Allocation Table (DAT) [ Allocation Table of Disk Sections ]
* File Descriptor Table (FDT) [ File Data Section Header ]
* Root Directory Descriptor Table (RDT) [ Root Directory Entry Section Header ]
* Sub Directory Descriptor Table (DDT) [ Sub Directory Entry Section Header ]
SAMPLE 1 : FDFORMAT.ASM [ Sample MS-DOS Program formats 1.44 MB Floppy Disk for Bootable Singlix FS ]
SAMPLE 2 : SINGLIX FS1 File System Image File Manipulation (a windows program)
* Building a new non-bootable SINGLIX FS1 (Floppy Disk 1.44 MB) File System by using Visual Basic Program
* Manipulating SINGLIX FS Image File via Visual Basic Program
* Copying startup file and other files to SINGLIX FS Image File
* Writing image file to disk. (Building singlix file system on the disk.)Recent VB (5.0/6.0) Project files : fs_basic.zip (v1.0)
Binary File Editor 2.0 Alfa VB (5.0/6.0) project Files : bfe_src.zip
FSFD.exe (Singlix Image File manipulation, developing Singlix FS access/handling commands with VB 5.0) (Procedures and functions will be translated/derivated to/for Assembly Language later) If you know Assembly and Visual Basic enoughly, you will understand the new FS project details, as follows:Note: Following visual basic program is purely using assembly language equivalent (also direct drive) commands for FS file system. It is a demo for yet... But not a play/game... By carefully looking at sample codes, you will see it is just for standalone execution on SINGLIX FS; with other words, it is FS module draft of the singlix (& trdos) operation system kernel. VB instead of the Assembly, for now...FSFD.exe Singlix FS FIND FIRST FILE Sample (Visual Basic Code instead of ASSEMBLY LANGUAGE Code)Private Function FindFirstFile(Drive As Integer, File As String) As Double Rem Found First File - Drive Number FFF_DRV = 0 Rem Found First File - File Name FFF_FNAME = "" Rem Found First File - Directory Descriptor Table Location FFF_DDT = 0 Rem Found First File - Directory Data Sector FFF_DSEC = 0 Rem Found First File - Directory Entry Number FFF_DENUM = 0 Rem Above parameters are for FindNextFile Procedures Rem They will be assigned/valid if the first proper file will be found. Call ParseFileName(Drive, File, DirNameBuffer()) FindFirstFile = 0 If PName <> "" And FName <> "" Then DDT_Location = LocateOnDirectory(0, PName) If DDT_Location = 0 Then Exit Function Else If PName = "/" Then ReturnCode = ReadSector(0, DDT_Location, 1, RDT()) If ReturnCode <> 0 Then Exit Function End If Call SetOpenDirStructure(RDT()) Else Call SetOpenDirStructure(DDT()) End If End If Repeat1: Rem If DD.SectorCount < 1 Then Rem FindFirstFile = 0 Rem Exit Function Rem End If For K = 1 To DD.SectorCount ReturnCode = ReadSector(0, DDT_Location + K, 1, SD_Data()) If ReturnCode <> 0 Then Exit Function End If For R = 0 To 511 Step 4 File = "" S1 = CDbl(SD_Data(R + 3)) S1 = 16777216 * S1 S2 = CLng(SD_Data(R + 2)) S2 = 65536 * S2 S3 = CLng(SD_Data(R + 1)) S3 = S3 * 256 S4 = CInt(SD_Data(R)) FDT_Location = S1 + S2 + S3 + S4 If FDT_Location < 1 Then Exit For If FDT_Location < 4294967295# Then ReturnCode = ReadSector(0, FDT_Location, 1, FDT()) If ReturnCode <> 0 Then FDT_Location = 0 Exit For End If For X = 1 To 64 Y = FDT(63 + X) If Y = 0 Then Exit For File = File + Chr(Y) Next X If NameCmp(FName, File) <> False Then FFF_DRV = Drive FFF_FNAME = FName FFF_DDT = DDT_Location FFF_DSEC = CLng(K) FFF_DENUM = R / 4 Exit For End If End If Next R If FDT_Location < 1 Then Exit For Next K If FDT_Location < 1 Then Exit Function If File = "" Then K = DD.NextDDTNumber If K > 0 Then ReturnCode = ReadSector(0, K, 1, DDT()) If ReturnCode = 0 Then Call SetOpenDirStructure(DDT()) If DD.DDTSign = "DDT" Or DD.DDTSign = "RDT" Then DDT_Location = K GoTo Repeat1 End If End If End If Else FindFirstFile = FDT_Location End If End If End FunctionFSFD.exe Singlix FS SAVE FILE Sample (Visual Basic Code instead of ASSEMBLY LANGUAGE Code)Private Sub fsSaveFile_Click() Label1.Caption = "" If ImageFileName = "" Then Label1.Caption = "FS Image File : NONE" MsgBox ("There is not a loaded SINGLIX FS Image file !"), 48, " Save as FS File" Label1.Caption = "" Exit Sub Else If WinFileName = "" Then Label1.Caption = "Windows File : NONE" MsgBox ("There is not a loaded Windows file !"), 48, " Save as FS File" Label1.Caption = "" Exit Sub End If End If FS_FileName = "" Repeat1: Label1.Caption = "FS Directory : " + FS_CDIR FS_FileName = InputBox("FS File Name :", " Save as Singlix FS File", WinFileName) FS_FileName = Trim$(FS_FileName) Label1.Caption = Label1.Caption + Chr$(13) + Chr$(10) + "FS File : " + FS_FileName L = Len(FS_FileName) If L > 0 Then If L > 64 Then MsgBox ("FS File name must not be more then 64 bytes !"), 48, " Save as Singlix FS File" GoTo Repeat1 Else For X = 1 To L Y = AscB(Mid$(FS_FileName, X, 1)) If Y = AscB("/") Or Y = AscB("?") Or Y = AscB("*") Or Y = AscB(":") Or Y = AscB("\") Then MsgBox ("Invalid file name chars ('/','?','*',':','\') !..."), 48, " Save as Singlix FS File" L = 0 Exit For End If Next X If L < 1 Then GoTo Repeat1 If L < 64 Then For X = L + 1 To 64 FS_FileName = FS_FileName + Chr(0) Next X End If End If Else Exit Sub End If Free_Sectors = GetFreeSpace() FreeSpace = 512 * Free_Sectors RequiredSpace = WinFileSize + 512 If FreeSpace < RequiredSpace Then MsgBox ("The is no enough free space to save the file on the Singlix File System!..." + Chr$(13) + Chr$(10) + "Free Space = " + CStr(FreeSpace) + " bytes"), 48, " Save as FS File" Exit Sub End If Rem Sector K = WinFileSize Mod 512 If K > 0 Then SectorCount = ((WinFileSize - K) / 512) + 1 Else SectorCount = (WinFileSize - K) / 512 End If SectorCount = SectorCount + 1 BeginningSector = GetFirstFreeSector() FDT_Location = GetFirstFreeSection(BeginningSector, SectorCount) If FDT_Location = 0 Then Rem Allocation will be done later, as multi sections MsgBox ("Free consecutive sectors are not enough!..."), 48, " Save as FS File" Else Call ResetFDTBuffer FD.FDTSign = "FDT" FD.FDTVersion = 0 FD.SectorSize = 512 FD.FDTNumber = FDT_Location FD.NextFDTNumber = 0 FD.SectorCount = SectorCount - 1 FD.ParentDirNumber = FS_DirNumber FD.ParentDirSerial = FS_DirSerial FD.FileSize = WinFileSize FD.FileSizeHigh = 0 FD.FileType = 0 FD.CheckSum = 0 FD.Attributes = 1 FD.OwnerCode = 0 FD.GroupCode = 0 FD.Country = 90 FD.TimeZone = 0 FS_Second = Second(Now) FS_Minute = Minute(Now) FS_Hour = Hour(Now) FS_Day = Day(Now) FS_Month = Month(Now) FS_Year = Year(Now) FD.CreatingDate = SetFSDate(FS_Year, FS_Month, FS_Day) FD.CreatingTime = SetFSTime(FS_Hour, FS_Minute, FS_Second) FD.CTimeMode = 0 FD.LastModifDate = FD.CreatingDate FD.LastModifTime = FD.CreatingTime FD.LastMTimeMode = 0 FD.FileName = FS_FileName FD.FileDescription = 0 Call SetFDTBuffer If Chr$(FDT(0)) = "F" And Chr$(FDT(1)) = "D" And Chr$(FDT(2)) = "T" And FDT(3) = 0 And FDT(4) = 0 And FDT(5) = 2 Then Label1.Caption = Label1.Caption + Chr$(13) + Chr$(10) + "Writing FDT Sector..." DRV(0).Drv_FStatus = 0 ReturnCode = WriteSector(0, FDT_Location, 1, FDT()) DRV(0).Drv_FStatus = ReturnCode If ReturnCode <> 0 Then MsgBox ("Writing Error !"), 48, " Writing FDT" Exit Sub End If Label1.Caption = Label1.Caption + " OK." WinFileNumber = FreeFile Open WinFileName For Binary As WinFileNumber Len = 1 If FileLen(WinFileName) <> WinFileSize Then MsgBox ("File Error !"), 48, " Writing File Data" Exit Sub End If Label1.Caption = Label1.Caption + Chr$(13) + Chr$(10) + "Writing File Data..." X = 0 BeginningSector = FDT_Location For S1 = 1 To WinFileSize Get WinFileNumber, S1, Y File_Data(X) = Y X = X + 1 If X = 512 Then BeginningSector = BeginningSector + 1 ReturnCode = WriteSector(0, BeginningSector, 1, File_Data()) If ReturnCode <> 0 Then MsgBox ("Writing Error !"), 48, " Writing File Data" Exit For End If X = 0 End If Next S1 If ReturnCode <> 0 Then Exit Sub If X > 0 And X < 512 Then For X = X To 511 File_Data(X) = 0 Next X BeginningSector = BeginningSector + 1 ReturnCode = WriteSector(0, BeginningSector, 1, File_Data()) If ReturnCode <> 0 Then MsgBox ("Writing Error !"), 48, " Writing File Data" Exit Sub End If End If Label1.Caption = Label1.Caption + " OK." If FS_CDIR = "/" Then ReturnCode = ReadSector(0, FS_DirNumber, 1, RDT()) Else ReturnCode = ReadSector(0, FS_DirNumber, 1, DDT()) End If If ReturnCode <> 0 Then MsgBox ("Directory Descriptor Table Reading Error !"), 48, " Reading Directory Descriptor Table" Exit Sub End If FS_Second = Second(Now) FS_Minute = Minute(Now) FS_Hour = Hour(Now) FS_Day = Day(Now) FS_Month = Month(Now) FS_Year = Year(Now) Label1.Caption = Label1.Caption + Chr$(13) + Chr$(10) + "Updating Directory Data..." If FS_CDIR = "/" Then K = SetFSDate(FS_Year, FS_Month, FS_Day) L = CInt(K Mod 256) RDT(56) = CByte(L) K = (K - L) / 256 L = K Mod 256 RDT(57) = CByte(L) K = (K - L) / 256 L = K Mod 256 RDT(58) = CByte(L) K = (K - L) / 256 RDT(59) = CByte(K) K = SetFSTime(FS_Hour, FS_Minute, FS_Second) L = CInt(K Mod 256) RDT(60) = CByte(L) K = (K - L) / 256 L = K Mod 256 RDT(61) = CByte(L) K = (K - L) / 256 L = K Mod 256 RDT(62) = CByte(L) RDT(63) = 0 Else K = SetFSDate(FS_Year, FS_Month, FS_Day) L = CInt(K Mod 256) DDT(56) = CByte(L) K = (K - L) / 256 L = K Mod 256 DDT(57) = CByte(L) K = (K - L) / 256 L = K Mod 256 DDT(58) = CByte(L) K = (K - L) / 256 DDT(59) = CByte(K) K = SetFSTime(FS_Hour, FS_Minute, FS_Second) L = CInt(K Mod 256) DDT(60) = CByte(L) K = (K - L) / 256 L = K Mod 256 DDT(61) = CByte(L) K = (K - L) / 256 L = K Mod 256 DDT(62) = CByte(L) DDT(63) = 0 End If If FS_CDIR = "/" Then ReturnCode = WriteSector(0, FS_DirNumber, 1, RDT()) Else ReturnCode = WriteSector(0, FS_DirNumber, 1, DDT()) End If If ReturnCode <> 0 Then MsgBox ("Directory Descriptor Table Writing Error !"), 48, " Updating Directory Data" Exit Sub End If If FS_CDIR = "/" Then ReturnCode = ReadSector(0, FS_DirNumber + 1, 1, RD_Data()) Else ReturnCode = ReadSector(0, FS_DirNumber + 1, 1, SD_Data()) End If If ReturnCode <> 0 Then MsgBox ("Directory Data Reading Error !"), 48, " Updating Directory Data" Exit Sub End If If FS_CDIR = "/" Then For X = 0 To 511 Step 4 If RD_Data(X) = 0 And RD_Data(X + 1) = 0 And RD_Data(X + 2) = 0 And RD_Data(X + 3) = 0 Then K = FDT_Location L = CInt(K Mod 256) RD_Data(X) = CByte(L) K = (K - L) / 256 L = K Mod 256 RD_Data(X + 1) = CByte(L) K = (K - L) / 256 L = K Mod 256 RD_Data(X + 2) = CByte(L) K = (K - L) / 256 RD_Data(X + 3) = CByte(K) Exit For End If Next X Else For X = 0 To 511 Step 4 If SD_Data(X) = 0 And SD_Data(X + 1) = 0 And SD_Data(X + 2) = 0 And SD_Data(X + 3) = 0 Then K = FDT_Location L = CInt(K Mod 256) SD_Data(X) = CByte(L) K = (K - L) / 256 L = K Mod 256 SD_Data(X + 1) = CByte(L) K = (K - L) / 256 L = K Mod 256 SD_Data(X + 2) = CByte(L) K = (K - L) / 256 SD_Data(X + 3) = CByte(K) Exit For End If Next X End If If FS_CDIR = "/" Then ReturnCode = WriteSector(0, FS_DirNumber + 1, 1, RD_Data()) Else ReturnCode = WriteSector(0, FS_DirNumber + 1, 1, SD_Data()) End If If ReturnCode <> 0 Then MsgBox ("Directory Data Writing Error !"), 48, " Updating Directory Data" Exit Sub End If Label1.Caption = Label1.Caption + " OK." ReturnCode = ReadSector(0, MAT_Location, 1, MAT()) If ReturnCode <> 0 Then MsgBox ("Reading Error !"), 48, " Reading MAT Sector" Exit Sub End If Rem S1 = CDbl(MAT(15)) Rem S1 = 16777216 * S1 Rem S2 = CLng(MAT(14)) Rem S2 = 65536 * S2 Rem S3 = CLng(MAT(13)) Rem S3 = S3 * 256 Rem S4 = CInt(MAT(12)) Rem Sector Rem DAT_Location = S1 + S2 + S3 + S4 Rem S1 = CDbl(MAT(19)) Rem S1 = 16777216 * S1 Rem S2 = CLng(MAT(18)) Rem S2 = 65536 * S2 Rem S3 = CLng(MAT(17)) Rem S3 = S3 * 256 Rem S4 = CInt(MAT(16)) Rem Sector Count Rem DAT_SCount = CLng(S1 + S2 + S3 + S4) L = WinFileSize Mod 512 If L > 0 Then K = ((WinFileSize - L) / 512) + 1 Else K = (WinFileSize / 512) + 1 End If S1 = GetFreeSpace() FreeSpace = S1 - (K + 1) ReturnCode = ReadSector(0, DAT_Location, DAT_SCount, DAT()) If ReturnCode <> 0 Then MsgBox ("Reading Error !"), 48, " Reading DAT Sectors" Exit Sub End If L = CInt(FDT_Location) DAT(L) = &H5 For K = L + 1 To L + K L = CInt(K) DAT(L) = &HF0 Next K ReturnCode = WriteSector(0, DAT_Location, DAT_SCount, DAT()) If ReturnCode <> 0 Then MsgBox ("Writing Error !"), 48, " Writing DAT Sectors" Exit Sub End If K = FreeSpace L = CInt(K Mod 256) MAT(20) = CByte(L) K = (K - L) / 256 L = K Mod 256 MAT(21) = CByte(L) K = (K - L) / 256 L = K Mod 256 MAT(22) = CByte(L) K = (K - L) / 256 MAT(23) = CByte(K) S1 = CDbl(MAT(27)) S1 = 16777216 * S1 S2 = CLng(MAT(26)) S2 = 65536 * S2 S3 = CLng(MAT(25)) S3 = S3 * 256 S4 = CInt(MAT(24)) BeginningSector = S1 + S2 + S3 + S4 K = GetFirstFreeSection(BeginningSector, 1) L = CInt(K Mod 256) MAT(24) = CByte(L) K = (K - L) / 256 L = K Mod 256 MAT(25) = CByte(L) K = (K - L) / 256 L = K Mod 256 MAT(26) = CByte(L) K = (K - L) / 256 MAT(27) = CByte(K) ReturnCode = WriteSector(0, MAT_Location, 1, MAT()) If ReturnCode <> 0 Then MsgBox ("Writing Error !"), 48, " Writing MAT Sector" Exit Sub End If MsgBox ("File has been recorded on the Singlix FS '" + FS_CDIR + "' directory as '" + FS_FileName + "'"), 0, " Save Open/Windows File as Singlix FS File" Label1.Caption = "FS Directory : " + FS_CDIR Label1.Caption = Label1.Caption + Chr$(13) + Chr$(10) + "FS File : " + FS_FileName Label1.Caption = Label1.Caption + Chr$(13) + Chr$(10) + "File Size: " + CStr(WinFileSize) + " bytes." End If End If End SubFSFD.exe Singlix FS WRITE SECTOR Sample (Visual Basic Code instead of ASSEMBLY LANGUAGE Code)Note: This function runs as 'write disk sector' for writing 512 byte blocks to FS image file. In near future, it will really write on Singlix FS formatted Disks/Drives.Private Function WriteSector(DrvNumber As Integer, Sector As Double, SectorCount As Long, Buffer() As Byte) As Long Dim Offset As Double Dim Count As Double Dim Location As Double Dim WriteByte As Byte Dim Counter As Integer If DrvNumber > 31 Then WriteSector = -1 Exit Function End If ImageFileName = Trim$(DRV(DrvNumber).Drv_FName) If ImageFileName = "" Then WriteSector = -1 Exit Function End If If Dir(ImageFileName) <> ImageFileName Then WriteSector = -1 Exit Function End If ImageFileSize = FileLen(ImageFileName) If ImageFileSize <> DRV(DrvNumber).Drv_FSize Then WriteSector = -1 Exit Function End If Offset = (Sector * 512) Count = SectorCount * 512 If Count < 512 Then WriteSector = -1 Exit Function Else If Offset > ImageFileSize - 512 Then WriteSector = -1 Exit Function End If End If On Error GoTo ReturnErrCode ImageFileNumber = FreeFile DRV(DrvNumber).Drv_FNumber = ImageFileNumber Open ImageFileName For Binary As ImageFileNumber Len = 1 For Location = Offset + 1 To Offset + Count WriteByte = Buffer(Counter) Put ImageFileNumber, Location, WriteByte Counter = Counter + 1 Next Location WriteSector = 0 Close ImageFileNumber DRV(DrvNumber).Drv_FStatus = 0 FCikis: DRV(DrvNumber).Drv_FNumber = 0 Exit Function ReturnErrCode: WriteSector = CLng(Err.Number) DRV(DrvNumber).Drv_FStatus = WriteSector Close ImageFileNumber GoTo FCikis End FunctionFSFD.exe Singlix FS READ SECTOR Sample (Visual Basic Code instead of ASSEMBLY LANGUAGE Code)Note: This function runs as 'read disk sector' for reading 512 byte blocks from FS image file. In near future, it will really read Singlix FS formatted Disks/Drives.Private Function ReadSector(DrvNumber As Integer, Sector As Double, SectorCount As Long, Buffer() As Byte) As LongDim Offset As Double Dim Count As Double Dim Location As Double Dim ReadByte As Byte Dim Counter As Integer If DrvNumber > 31 Then ReadSector = -1 Exit Function End If ImageFileName = Trim$(DRV(DrvNumber).FileName) If ImageFileName = "" Then ReadSector = -1 Exit Function End If If Dir(ImageFileName) <> ImageFileName Then ReadSector = -1 Exit Function End If ImageFileSize = FileLen(ImageFileName) If ImageFileSize <> DRV(DrvNumber).FileSize Then ReadSector = -1 Exit Function End If Offset = (Sector * 512) Count = SectorCount * 512 If Count < 512 Then ReadSector = -1 Exit Function Else If Offset > ImageFileSize - 512 Then ReadSector = -1 Exit Function End If End If On Error GoTo ReturnErrCode ImageFileNumber = FreeFile DRV(DrvNumber).FileNumber = ImageFileNumber Open ImageFileName For Binary As ImageFileNumber Len = 1 For Location = Offset + 1 To Offset + Count Get ImageFileNumber, Location, ReadByte Buffer(Counter) = ReadByte Counter = Counter + 1 Next Location ReadSector = 0 Close ImageFileNumber DRV(DrvNumber).FileStatus = 0 FCikis: DRV(DrvNumber).FileNumber = 0 Exit Function ReturnErrCode: ReadSector = CLng(Err.Number) DRV(DrvNumber).FileStatus = ReadSector Close ImageFileNumber GoTo FCikisEnd FunctionATAPI CD-ROM & ISO 9660 FS Programming Samples (in MASM) : ataid.html atapinq.html readpvdl.html
NOTE: html files include code & links to sample ASM files and zip files for CD-ROM & ISO9660 assembly programming.
8 bit CheckSum (CRC) Calculation Sample: CHKSUM.ASM CHKSUM.COM (8086 assembly)
MASM 6.11 -> "masm.bat" or "new-vars.bat"
< masm chksum, link /t chksum > or < ml /Zm /AT CHKSUM.ASM >
proc_calculate_checksum -> INPUT: DS:SI = DOS Short DirEntry location, OUTPUT: AL = CheckSum value
Entrance: index.html [ Last Update: 02/08//2014 ]