Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.7KB

  1. ( ----- 600 )
  2. PC/AT recipe
  3. 602 MBR bootloader 604 KEY/EMIT drivers
  4. 606-608 BLK drivers 610 AT-XY drivers
  5. 612 xcomp unit
  6. ( ----- 602 )
  7. H@ ORG ! 0x7c00 BIN( ! ( BIOS loads boot bin at 0x7c00 )
  8. JMPs, L1 FWRs ( start )
  9. ORG @ 0x25 + HERE ! ( bypass BPB )
  10. L1 FSET ( start )
  11. CLI, CLD, AX 0x800 MOVxI, DS AX MOVsx, ES AX MOVsx,
  12. SS AX MOVsx, DX PUSHx, ( will be popped by OS ) STI,
  13. AH 2 MOVri, DH 0 MOVri, CH 0 MOVri, CL 2 MOVri, AL 15 MOVri,
  14. BX 0 MOVxI, 0x13 INT, ( read sectors 2-15 of boot floppy )
  15. ( TODO: reading 12 sectors like this probably doesn't work
  16. on real vintage PC/AT with floppy. Make this more robust. )
  17. 0x800 0 JMPf,
  18. ORG @ 0x1fe + HERE ! 0x55 A, 0xaa A,
  19. ( ----- 604 )
  20. CODE (emit) 1 chkPS,
  21. AX POPx, AH 0x0e MOVri, ( print char ) 0x10 INT,
  22. ;CODE
  23. CODE (key)
  24. AH AH XORrr, 0x16 INT, AH AH XORrr, AX PUSHx,
  25. ;CODE
  26. ( ----- 606 )
  27. CODE 13H08H ( driveno -- cx dx )
  28. DI POPx, DX PUSHx, ( protect ) DX DI MOVxx, AX 0x800 MOVxI,
  29. ES PUSHs, DI DI XORxx, ES DI MOVsx,
  30. 0x13 INT, DI DX MOVxx, ES POPs, DX POPx, ( unprotect )
  31. CX PUSHx, DI PUSHx,
  32. ;CODE
  33. CODE 13H ( ax bx cx dx -- ax bx cx dx )
  34. SI POPx, ( DX ) CX POPx, BX POPx, AX POPx,
  35. DX PUSHx, ( protect ) DX SI MOVxx, DI DI XORxx,
  36. 0x13 INT, SI DX MOVxx, DX POPx, ( unprotect )
  37. AX PUSHx, BX PUSHx, CX PUSHx, SI PUSHx,
  38. ;CODE
  39. ( ----- 607 )
  40. : FDSPT 0x70 RAM+ ;
  41. : FDHEADS 0x71 RAM+ ;
  42. : _ ( AX BX sec )
  43. ( AH=read sectors, AL=1 sector, BX=dest,
  44. CH=trackno CL=secno DH=head DL=drive )
  45. FDSPT C@ /MOD ( AX BX sec trk )
  46. FDHEADS C@ /MOD ( AX BX sec head trk )
  47. 8 LSHIFT ROT OR 1+ ( AX BX head CX )
  48. SWAP 8 LSHIFT 0x03 C@ ( boot drive ) OR ( AX BX CX DX )
  49. 13H 2DROP 2DROP
  50. ;
  51. ( ----- 608 )
  52. : FD@
  53. 2 * 16 + ( blkfs starts at sector 16 )
  54. 0x0201 BLK( 2 PICK _
  55. 0x0201 BLK( 0x200 + ROT 1+ _ ;
  56. : FD!
  57. 2 * 16 + ( blkfs starts at sector 16 )
  58. 0x0301 BLK( 2 PICK _
  59. 0x0301 BLK( 0x200 + ROT 1+ _ ;
  60. : FD$
  61. ( get number of sectors per track with command 08H. )
  62. 0x03 ( boot drive ) C@ 13H08H
  63. 8 RSHIFT 1+ FDHEADS C!
  64. 0x3f AND FDSPT C!
  65. ;
  66. ( ----- 610 )
  67. : COLS 80 ; : LINES 25 ;
  68. CODE AT-XY ( x y )
  69. ( DH=row DL=col BH=page )
  70. AX POPx, BX POPx, DX PUSHx, ( protect )
  71. DH AL MOVrr, DL BL MOVrr, BX BX XORxx, AH 2 MOVri,
  72. 0x10 INT, DX POPx, ( unprotect )
  73. ;CODE
  74. ( ----- 612 )
  75. 0xff00 CONSTANT RS_ADDR
  76. 0xfffa CONSTANT PS_ADDR
  77. RS_ADDR 0x80 - CONSTANT SYSVARS
  78. 30 LOAD ( 8086 asm )
  79. 262 LOAD ( xcomp ) 270 LOAD ( xcomp overrides )
  80. 445 461 LOADR ( 8086 boot code )
  81. 353 LOAD ( xcomp core low )
  82. 604 LOAD ( KEY/EMIT drivers )
  83. 606 608 LOADR ( BLK drivers )
  84. 610 LOAD ( AT-XY drivers )
  85. 390 LOAD ( xcomp core high )
  86. (entry) _ ( Update LATEST ) PC ORG @ 8 + !
  87. ," BLK$ FD$ ' FD@ BLK@* ! ' FD! BLK!* ! " EOT,