Description of the MSX-BDos 1 system area Disclaimer This information is gathered experimentaly on a Sony HB-F700P MSX2, so it is still unknown if the addresses are independent of this computer. Please help me by checking (some) addresses in your own computer. Mail me with your results. The biggest part of the information was gathered directly from the BDos itself, by disassembling. The names are (of course) not official names, but the names I have given them to remember the function. Any help to extend the list will be greatly appreciated. Joost Klootwijk (joostk@sci.kun.nl) Uses for the information So far, I have only collected the information and used it to provide a way to load TSR's while in Dos. This is working at the moment, but I'm still looking for a way to be able to keep the tsr's also in Basic. Another useful implementation to be made with the BDos-system area is (possibly as a TSR) an extension of MSX-Dos 1, to give it certain Dos 2 commands (eg. CD, SHELL). Usefull pointers to other information. TSR-modules Memory layout within MSXDos. 0000H-0100H PSP 0001H defw yy03 0006H defw xx06 0100H- Program ... COMMAND.COM - shell part xx00H-1 Top of stack xx06H TPA (starts with a JP) COMMAND.COM - system part ... yy00H-1 Top of system stack Jumptable: 0 WarmBoot 3 WarmBoot 6 BDos ... MSXDOS.SYS Description of the PSP The PSP (Program Segment Prefix), a name derived from the MSDos system, is also available in MSX-Dos. It consists of the bytes 0-100H in the memory. It is partly compatible with CP/M, which was one of the sources of information. PSP Byte Functie 00H-02H Jmp WrmBoot - One of the ways to end your program. Also, The Reboot Jump-address points to the second entry in a jumptable of BDos functions. Always: WrmBoot=yy03H (See description MSXDOS.SYS) 03H-05H Jmp BDos The BDos-jump address also indicates the end of the TPA. At this address starts MSXDOS.SYS Always: TopTPA=xx06H (See description MSXDOS.SYS) 000CH RdSlt - Same as BIOS function 0014H WrtSlt - Same as BIOS function 001CH CalSlt - Same as BIOS function 0024H EnaSlt - Same as BIOS function 0030H CallF - Same as BIOS function 0038H Intr 003BH-005BH Secondary Slotswitch data 005CH-006BH First half of FCB1, filled with Arg1 as expanded filename If you use this as FCB, remember that FCB2 will be truncated! 008CH-007FH FCB2, filled with Arg2 as expanded filename 0080H B Length of commandline 0081H-00FFH Commandline, as typed. Ended by zero? Description of the Warmboot code. The warmboot (return to dos from a programs viewpoint) code is called at the end of a user program in the following ways: 1. RET, while stack is in the same state as it was at the beginning. 2. JP 0 3. BDos(0) 4. BDos(Terminate with Error) (only Dos-2) The code for JP 0 is described below, as this is (eventualy) what actualy happens. The code is really contained within MSXDOS.SYS By changing this warmboot-code, MSX-Dos 1 can be fooled to reserve memory for a TSR. That is why I describe the warmboot-code. Code: 0000: jp yy03 ; C3 03 yy .. .. 0005: jp xx06 ; C3 06 xx TPA equ xx06 yy00: jp WarmBt ; Jumptable, 16 entries yy03: jp WarmBt WarmBt: ld sp,tpa+05FDH ; 31 00 .. call F368H ; CD 68 F3 ei ; FB ld hl,yy03 ; 21 03 yy ld (1),hl ; 22 01 00 ld hl,TPA ; 21 06 xx ld (6),hl ; 22 06 00 ld a,0C3H ; 3E C3 ld (0),a ; 32 00 00 ld (5),a ; 32 05 00 call .... ; CD .. .. Description of the usage of the memory from above TPA: Just above TPA is some usefull information about the loaded COMMAND.COM This can be modified to force a reload of COMMAND.COM, which will take into account any changed adresses for the TPA... xx06: jp xx07: defw BDosF0 F0=WarmBoot xx09: defw BDosF1 F1..F4=Error??? (TPA+0FAH) ... xx11: defw BDosF5 F5=BDos function handler xx13: defw ComStr Startadress of resident COMMAND.COM xx15: defw ComLen Length of COMMAND.COM xx17: defw ComCRC CRC-number of COMMAND.COM (Sum of all words) xx19: defb RunBat RunBat=1 when running a batch-file xx1A: defw ?? xx1C: defw Arg0 Adres of argument 0 (%0) to batch-file ... Adresses point in commandline. Separator 020h/00Dh xx2E: defw Arg9 Adres %9 (nil when absent) xx30: defs 024h FCB for running batch-file xx54: defb 0 Length of commandline? xx55: defs 127 Copy of commandline to batchfile. xxD5: Free? Here, a tsr can be placed. BDos system area Are adresses are also available from Disk-Basic? Are they always at the same adresses? F195H-F1A9H Driver Parameter Block (DPB) A: F1AAH-F1BEH DPB B: F1C1H-F1C2H W Drive Countdown (set counter to zero to stop drive-motor) F1C4H B Number of Active Drive F1C5H B PosHead track A: F1C6H B PosHead track B: F1C7H B Log.Drv. F1C8H B No Real Drv. /\ Variables ____________________________________||__________________________ Most functions switch the BDos-rom into page 1, but do not switch back to the rampage. Use the function at F368H to switch Ram on. F1C9H BDosCall(9): Print string (DE) tot '$' F1D9H switch to rampage, LDIR, switch to BDosRom F1E5H Jmp to 'Abort,Retry..'-question, put your own error handling adress at F1E6H F1E8H Call to HL in ram, return with BDosRom on. F1F4H Hook: Check FileName in (HL), (DE)... /\ Functions ____________________________________||__________________________ F1F7H-F20AH Device names: 'PRN LST NUL AUX CON' F20BH-F215H Filename+Ext F216H-F220H Signed device number (PRN=-5=FBH, LST=-4...) F221H-F222H W date out of FCB F223H-F224H W time out of FCB F22BH-F236H days per month (bytes, no leapyear) F237H-F23AH buffer for BufInp (BDos(10)) F23BH B Boolean Printer on (^P) F23CH-F23DH W DMA-address F23FH-F242H DW Sector number F243H-F244H W Address Current DPB? F247H B Current Drive F248H B Day F249H B Month F24AH W Year-1980 F24CH W Time F24EH W Day of Week /\ Data for BDos ____________________________________||___________________________ Hooks, unknown what they are for. For each the address in the BDos is given, as reference for later to check the use of the hook. All are three-byte hooks (JP Addr) F24FH (625AH) 'Insert disk in drive', adress in AF F252H (41FAH) Start evaluation BDos-function F255H (425AH) Fix filename F258H (42BCH) SearchDir ? Useful, to change (F2DC) to search also for hidden files F25BH (4317H) DirEnt-increase (last DirEnt in AF) F25EH (4348H) NextDirSect F261H (440EH) Fix Filename F264H (4471H) Open F267H ( ) F26AH (4553H) GetDPB F26DH (45CFH) Close F270H (45C5H) DiskRead: BDos(2FH) HL=DMA, DE=sect, B=NumSect F273H (470AH) F276H (4748H) F279H (4755H) DiskWrite: BDos(30H) HL=DMA, DE=sect, B=NumSect F27CH (4916H) HL=DE*BC F27FH (492FH) HL=BC/DE ; HL=BC mod DE F282H (4989H) F285H (49B1H) F288H (4A36H) F28BH (4A46H) F28EH (4B56H) F291H (4BE2H) F294H (4C22H) F297H (4C97H) F29AH (4D65H of 4D05H) F29DH (4D8CH) F2A0H (4E48H) F2A3H (4EDBH) F2A6H (4F12H) F2A9H (4F9EH) F2ACH (5104H) BufIn (BDos(10))? F2AFH (53A8H) Start of ConOut: BDos(2) F2B2H (5496H) F2B5H (5523H) Check for Leapyear /\ 3-byte Hooks for BDos ____________________________________||___________________________ F2B8H B CurDirEnt: Current entry in directory F2B9H-F2D8H DirEnt: copy of last read directory entry F2B9H-F2C3H FileName F2C4H B Attribute (bit 7: open with strange attrib? 1=true) F2CFH W Time F2D1H W Date F2D3H W StartCluster F2D5H W Size F2DCH B Boolean: Accept nonzero attributes? 0=false F2E1H B Current drive absolute read/write F2FEH W Subcounter DrvCountDown F304H W Temporary storage for SP F306H B DefaultDrv - or - InDos flag ???? F307H W Storage for DE (FCB-Adress) F309H W Storage for DPB for Search first/next F30BH W Current Directory-sector F30DH B VerifyState (NZ=on) F30FH-F322H For Kanjii F323H W Errorhandler adress F325H W CtrlC-handler adress /\ Data for BDos ______________________________________||___________________________ Hooks for Com port and BDosCall evaluation. All hooks here are five bytes long (for a RST 30H) F327H AuxInp Out: A=byte from "AUX" default returns ^Z F32CH AuxOut In: A=byte to send? F331H BDosCall Default: Bend to BDosRom 56D3H /\ 5-byte hooks for BDos ______________________________________||___________________________ F336H B Ctrl or Stop was pressed status F337H B Ctrl&Stop status (3=both are pressed now) F338H B Clockchip exists (NZ=true) F339H-F33FH Clockchip-routine data F340H Reboot MSXDos state (same as slotselector BDosrom?) F341H-F344H Slotselectors for Ram in page 0,1,2,3 F345H B Number of free buffers F346H B DosBooted state (NZ=Dos was booted) F347H B Number of drives F348H B RomSlotID BDosRom F349H-F34AH W HighMem - Start of BDos-data, top of `free' memory F34BH-F34CH W ClearAddr MSXDos, start for COMMAND.COM (ClearAddr