wok diff BootProg/stuff/boot32.asm @ rev 25706
BootProg/boot32.asm: add int 21h services 02h, 09h, 25h, 35h
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Jun 26 17:36:15 2024 +0000 (4 months ago) |
parents | 7db7b7aaf63e |
children |
line diff
1.1 --- a/BootProg/stuff/boot32.asm Sat Jun 22 12:48:49 2024 +0000 1.2 +++ b/BootProg/stuff/boot32.asm Wed Jun 26 17:36:15 2024 +0000 1.3 @@ -101,6 +101,7 @@ 1.4 Always2FATs equ 0 ; -4 bytes 1.5 WaitForKey equ 0 ; +5 bytes 1.6 AnyWhere equ 1 ; +3 bytes 1.7 +Int21h equ 1 ; +70 bytes 1.8 1.9 [BITS 16] 1.10 [CPU 386] 1.11 @@ -165,6 +166,15 @@ 1.12 ;; BPB2 ends here ;; 1.13 ;;;;;;;;;;;;;;;;;;;; 1.14 1.15 +%macro Abort 1 1.16 + call Error 1.17 + db %1 1.18 + db '.' 1.19 +%if Int21h 1.20 + db '$' 1.21 +%endif 1.22 +%endm 1.23 + 1.24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.25 ;; Boot sector code starts here ;; 1.26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.27 @@ -269,6 +279,14 @@ 1.28 mov sp, 512+StackSize ; bytes 0-511 are reserved for the boot code 1.29 %endif 1.30 1.31 +%if Int21h 1.32 + mov ax, 3521h 1.33 + mov dx, Int21xx 1.34 + pushf 1.35 + push cs 1.36 + call dx 1.37 +%endif 1.38 + 1.39 %if ClusterMask != 0 1.40 and byte [bx(bsRootDirectoryClusterNo+3)], 0Fh ; mask cluster value 1.41 %endif 1.42 @@ -321,8 +339,7 @@ 1.43 cmp esi, 0FFFFFF6h ; carry=0 if last cluster, and carry=1 otherwise 1.44 jnc RootDirReadContinue ; continue to the next root dir cluster 1.45 ErrFind: 1.46 - call Error ; end of root directory (dir end reached) 1.47 - db "No bootfile." 1.48 + Abort "No bootfile" ; end of root directory (dir end reached) 1.49 %if ExtraBootSector != 0 1.50 %endm 1.51 %macro BootFileName 0 1.52 @@ -379,6 +396,63 @@ 1.53 xor sp, sp 1.54 push bp ; cs, ds and es 1.55 jmp short Run 1.56 + 1.57 +%if Int21h 1.58 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.59 +;; DOS service ah=02h,09h,25h,35h ;; 1.60 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.61 + 1.62 +Int21xx: 1.63 + cld 1.64 + push si 1.65 + mov si, dx 1.66 + push ds 1.67 + push ax 1.68 + xchg al, ah 1.69 + push bx 1.70 + xor bx, bx 1.71 + cmp al, 09h 1.72 + je putslp 1.73 + cmp al, 02h 1.74 + jne I21x5 1.75 + dec bx 1.76 + mov al, dl 1.77 + 1.78 +putc: mov ah, 0Eh 1.79 + inc bx 1.80 + int 10h 1.81 + dec bx 1.82 + jnz Iret1 1.83 + 1.84 +putslp: lodsb 1.85 + cmp al,'$' 1.86 + jnz putc 1.87 + xchg ax, bx 1.88 + 1.89 +I21x5: push ds 1.90 + mov ds, bx 1.91 + mov bl, ah 1.92 + shl bx, 2 1.93 + cmp al, 35h 1.94 + je I2135 1.95 + pop ds 1.96 + cmp al, 25h 1.97 + jne Iret1 1.98 + 1.99 +I2125: les bx, [bx] 1.100 + pop ax 1.101 + jmp Iret2 1.102 + 1.103 +I2135: push dx 1.104 + pop dword [bx] 1.105 +Iret1: pop bx 1.106 +Iret2: pop ax 1.107 + pop ds 1.108 + pop si 1.109 + iret 1.110 + 1.111 +%endif 1.112 + 1.113 %if ExtraBootSector != 0 1.114 %endm 1.115 %macro BootCode 0 1.116 @@ -433,6 +507,7 @@ 1.117 ;; All done, transfer control to the program now ;; 1.118 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.119 retf 1.120 + 1.121 %if ExtraBootSector != 0 1.122 %endm 1.123 %endif 1.124 @@ -442,6 +517,15 @@ 1.125 ;;;;;;;;;;;;;;;;;;;;;;;;;; 1.126 1.127 Error: 1.128 +%if Int21h 1.129 + pop dx 1.130 +%if WaitForKey != 0 1.131 + mov ax, 0900h 1.132 +%else 1.133 + mov ah, 09h 1.134 +%endif 1.135 + int 21h 1.136 +%else 1.137 pop si 1.138 puts: 1.139 mov ah, 0Eh 1.140 @@ -450,8 +534,11 @@ 1.141 int 10h 1.142 cmp al, '.' 1.143 jne puts 1.144 +%endif 1.145 %if WaitForKey != 0 1.146 +%if Int21h == 0 1.147 cbw 1.148 +%endif 1.149 int 16h ; wait for a key... 1.150 int 19h ; bootstrap 1.151 %endif 1.152 @@ -638,9 +725,7 @@ 1.153 dec bp ; up to 32 retries 1.154 jnz ReadSectorRetry 1.155 %endif 1.156 - 1.157 - call Error 1.158 - db "Read error." 1.159 + Abort "Read error" 1.160 1.161 ReadSuccess: 1.162