Assembler






DOS INT 27H

. -
. AUTOEXEC.BAT,
.
,
-. DOS
.
,
, .
 
DOS
. IBM
: DOS, ,
CP/M-86 Digital Research UCSD p-System SofTech
Microsystems. , IBM,
.
,
, ,
DOS.
 
, ,
IBM PC.
- ,
BIOS, IBM.
BIOS
.
INT 27H,
, DOS.
,
.
 
, DOS,
.

.
. ,
.
, BIOS,
.
BIOS
.
.
,
.
IBM BIOS
.
, .
,
.
 
. . 10.2
.

.
. ,
.
 
A
Microsoft (R) Macro Assembler Version 5.00 1/1/80 01:21:50
. 10.2() - Page 1-1
 
 
PAGE ,132
TITLE . 10.2() -
0000 NEW_DISK SEGMENT
0000 DISK_BIOS LABEL FAR
0003 ORG 3
0003 OLD_VECTOR LABEL WORD
0003 NEW_DISK ENDS
 
0000 ABS0 SEGMENT AT 0
004C ORG 13H*4
004C DISK_VECTOR LABEL WORD
0410 ORG 410H
0410 EQUIPMENT LABEL WORD
0413 ORG 413H
0413 MEMORY_SIZE LABEL WORD
 
= 00A0 DISK_SIZE EQU 160
7C00 ORG 7C00H ; ,
7C00 BOOT_RECORD LABEL FAR
7C00 ABS0 ENDS
 
0000 CODE SEGMENT
ASSUME CS:CODE,DS:ABS0
7C00 ORG 7C00H
7C00 8C C8 MOV AX,CS
7C02 8E D8 MOV DS,AX
7C04 8E C0 MOV ES,AX
7C06 8D 36 7C00 R LEA SI,BOOT_RECORD
7C0A 8D 3E 7A00 R LEA DI,BOOT_RECORD-200H ; ,
7C0E B9 0200 MOV CX,512 ;
7C11 F3/ A4 REP MOVSB ;
7C13 E9 7A16 R JMP NEXT_LOCATION-200H
7C16 NEXT_LOCATION:
 
. 10.2 - ()
7C16 83 06 0410 R 40 ADD EQUIPMENT,40H ;
7C1B A1 0413 R MOV AX,MEMORY_SIZE
7C1E 2D 00A0 SUB AX,DISK_SIZE
7C21 A3 0413 R MOV MEMORY_SIZE,AX ; ,-
7C24 B1 06 MOV CL,6 ; -
7C26 D3 E0 SHL AX,CL ; 1024/16
7C28 8E C0 MOV ES,AX ;
7C2A B8 0201 MOV AX,201H ;
7C2D BB 0000 MOV BX,0
7C30 B9 0002 MOV CX,2
7C33 BA 0000 MOV DX,0
7C36 CD 13 INT 13H
7C38 72 1A JC BOOT_ERROR
ASSUME ES:NEW_DISK
7C3A A1 004C R MOV AX,DISK_VECTOR
7C3D 26: A3 0003 R MOV OLD_VECTOR,AX
7C41 A1 004E R MOV AX,DISK_VECTOR+2 ; -
7C44 26: A3 0005 R MOV OLD_VECTOR+2,AX ; 13h
7C48 C7 06 004C R 0000 MOV DISK_VECTOR,0 ; 17h
7C4E 8C 06 004E R MOV DISK_VECTOR+2,ES ;
7C52 EB 07 JMP SHORT REBOOT ;
7C54 BOOT_ERROR:
7C54 8D 36 7A93 R LEA SI,ERROR_MSG-200H ;
7C58 E8 7C81 R CALL PRINT_MSG
7C5B REBOOT:
7C5B 8D 36 7AA5 R LEA SI,BOOT_MSG-200H ;
7C5F E8 7C81 R CALL PRINT_MSG
7C62 WAIT_BOOT:
7C62 B4 00 MOV AH,0
7C64 CD 16 INT 16H ;
7C66 3C 20 CMP AL,' ' ;
7C68 75 F8 JNE WAIT_BOOT
7C6A B8 0201 MOV AX,201H
7C6D BB 7C00 MOV BX,7C00H
7C70 B9 0001 MOV CX,1
7C73 BA 0000 MOV DX,0
7C76 8E C2 MOV ES,DX ;
7C78 CD 13 INT 13H
7C7A 72 D8 JC BOOT_ERROR
7C7C EA 7C00 ---- R JMP BOOT_RECORD
 
7C81 PRINT_MSG PROC NEAR
7C81 2E: 8A 04 MOV AL,CS:[SI] ;
7C84 46 INC SI
7C85 3C 24 CMP AL,'$' ;
7C87 75 01 JNE OUTPUT
7C89 C3 RET
7C8A OUTPUT:
7C8A B4 0E MOV AH,14
7C8C BB 0000 MOV BX,0
7C8F CD 10 INT 10H ; BIOS
7C91 EB EE JMP PRINT_MSG
7C93 8E E8 A8 A1 AA A0 20 ERROR_MSG DB ' ',13,10,'$'
A7 A0 A3 E0 E3 A7 AA
A8 0D 0A 24
 
. 10.2 - ()
7CA5 82 E1 E2 A0 A2 EC E2 BOOT_MSG DB ' ',13,10
A5 20 AD AE A2 E3 EE
20 A4 A8 E1 AA A5 E2
E3 20 E1 20 84 8E 91
0D 0A
7CC3 A8 20 AD A0 A6 AC A8 DB ' ',10,13,'$'
E2 A5 20 AD A0 20 AF
E0 AE A1 A5 AB 0A 0D
24
7CD9 PRINT_MSG ENDP
7CD9 CODE ENDS
END
 
Microsoft (R) Macro Assembler Version 5.00 1/1/80 04:06:49
. 10.2() - Page 1-1
 
 
PAGE ,132
TITLE . 10.2() -
0000 CODE SEGMENT
ASSUME CS:CODE
;--------------------------------------------
; 1 0
; -. 2
;
;--------------------------------------------
0000 DISK PROC FAR
= 0140 DISK_SIZE EQU 320 ; -
0000 EB 05 90 JMP START_BIOS
0003 ???????? ORIGINAL_VECTOR DD ?
 
0007 START_BIOS:
0007 80 FA 02 CMP DL, 2 ;
000A 74 05 JE L1 ; () 2
000C OLD_BIOS:
000C 2E: FF 2E 0003 R JMP ORIGINAL_VECTOR ;
0011 L1:
0011 3C 01 CMP AL, 1
0013 76 F7 JBE OLD_BIOS
0015 80 FC 04 CMP AH, 4
0018 72 06 JB READ_WRITE ;
;
001A OK_RETURN:
001A B4 00 MOV AH, 0 ; - 0
001C F8 CLC ; C- -
001D CA 0002 RET 2
0020 READ_WRITE:
0020 53 PUSH BX ;
0021 51 PUSH CX
0022 52 PUSH DX
0023 56 PUSH SI
0024 57 PUSH DI
0025 1E PUSH DS
0026 06 PUSH ES
 
. 10.2 - ()
;----- -
 
0027 50 PUSH AX ;
0028 B0 08 MOV AL, 8 ;
002A F6 E5 MUL CH
002C B5 00 MOV CH, 0
002E 03 C1 ADD AX, CX ;
0030 80 FE 00 CMP DH, 0 ;
0033 74 03 JE HEAD_0
0035 05 0140 ADD AX, 320 ;
0038 HEAD_0:
0038 48 DEC AX
0039 3D 0140 CMP AX, DISK_SIZE ; ?
003C 76 0E JBE DISK_OK
003E RECORD_NOT_FOUND:
003E 58 POP AX ;
003F 07 POP ES
0040 1F POP DS
0041 5F POP DI
0042 5E POP SI
0043 5A POP DX
0044 59 POP CX
0045 5B POP BX
0046 B4 04 MOV AH, 4 ; :
0048 F9 STC
0049 CA 0002 RET 2 ;
004C DISK_OK:
004C B1 05 MOV CL, 5
004E D3 E0 SHL AX, CL ;
0050 8C C9 MOV CX, CS ; -
0052 03 C8 ADD CX, AX ; CX
;
0054 51 PUSH CX
0055 8B D3 MOV DX, BX ; DX
0057 B1 04 MOV CL, 4
0059 D3 EA SHR DX, CL
005B 8C C1 MOV CX, ES
005D 03 D1 ADD DX, CX ; DX
;
005F 59 POP CX
0060 83 E3 0F AND BX, 0Fh ; 4
0063 58 POP AX ;
0064 80 FC 02 CMP AH, 2
0067 74 11 JE READ_OPN
0069 WRITE_OPN:
0069 8C CE MOV SI, CS
006B 3B CE CMP CX, SI ;
006D 74 1B JE ALL_DONE
006F 8E C1 MOV ES, CX
0071 BF 0000 MOV DI, 0
0074 8E DA MOV DS, DX
0076 8B F3 MOV SI, BX ;
0078 EB 09 JMP SHORT DO_MOVE
007A READ_OPN:
007A 8E D9 MOV DS, CX
 
. 10.2 - ()
007C BE 0000 MOV SI, 0
007F 8E C2 MOV ES, DX
0081 8B FB MOV DI, BX
0083 DO_MOVE:
0083 8A E8 MOV CH, AL ;
0085 B1 00 MOV CL, 0
0087 FC CLD
0088 F3/ A5 REP MOVSW ;
008A ALL_DONE:
008A 07 POP ES ;
008B 1F POP DS
008C 5F POP DI
008D 5E POP SI
008E 5A POP DX
008F 59 POP CX
0090 5B POP BX
0091 B4 00 MOV AH, 0 ;
0093 F8 CLC
0094 CA 0002 RET 2
0097 DISK ENDP
0097 CODE ENDS
END
. 10.2 () ;
(b) .
 
, ,
. 160

, . 160 ,
IBM. ,
.
-
,
. , -
,
, .
.
160K ,
-. ,
, 256 ,
96 .
160
. ,
, ,
, ,
.
 
. 10.2 - .
1 0 .
, . POST
1 0 ,
0:7C00H. POST
. IBM
DOS .
,
.
 
NEW_DISK -
, (. .
10.2). ,

. ABS0 ,
. CODE, ,
. CODE -
, .
 
, -
0:7A00H. , ,
,
. 0:7C00H.
,
,
.
 
NEXT_LOCATION
.

. "" ,
.
MEMORY_SIZE 160 ,
.
. ,
160
, , .
, -
2 0 .
2
1.
 
,
BIOS BIOS (INT
13H), .
, .

, . ,
.
, .
( ,
). ,
,

.
 
, ,
. -,
.
. . 10.3 ,
, .
DOS DEBUG .
7C00H, DEBUG.
, BIOS
.
, 200H.
, .
 
2
, . 10.3. DEBUG
.
DEBUG 1
( 2 0) , A:.

.
 
BIOS DEBUG

BIOS. , BIOS,
DEBUG.
,
DEBUG.
.
 
- .
10.2. ,
(INT 13H) 3. -

, -.
, -
2.
BIOS, ORIGINAL_VECTOR
. BIOS.
, -,
, - ,
. -
, ,
.
 
,
- .

.
. ,
REP MOVSW -
.

.
 
, ,
. ,
,
,
.
, . ,
DOS,
,
A
A>MASM BOOT,,,;
The IBM Personal Computer MACRO Assembler
Version 1.00 (C)Copyroght IBM Corp 1981
 
Warning Severe
Errors Errors
0 0
 
A>B:LINK BOOT,,,;
 
IBM Personal Computer Linker
Version 1.00 (C)Copyroght IBM Corp 1981
 
Warning: No STACK segment
 
Therhe was 1 error detected
 
A>MASM DISK,,,;
The IBM Personal Computer MACRO Assembler
Version 1.00 (C)Copyroght IBM Corp 1981
 
Warning Severe
Errors Errors
0 0
 
A>B:LINK DISK,,,;
 
IBM Personal Computer Linker
Version 1.00 (C)Copyroght IBM Corp 1981
 
Warning: No STACK segment
 
Therhe was 1 error detected
 
A>DEBUG BOOT.EXE
-R
 
AX=0000 BX=0000 CX=7CD3 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=06D7 ES=06D7 SS=06E7 CS=06E7 IP=0000 NV UP DI PL NZ NA PO NC
06E7:0000 0000 ADD [BX+SI],AL DS:0000=CD
-U7C00 7C05
06E7:7C00 8CC8 MOV AX,CS
06E7:7C00 8CD8 MOV DS,AX
06E7:7C00 8CC0 MOV ES,AX
-RAX
AX 0000
:301
-RBX
BX 0000
:7C00
-RCX
CX 7CD3
:1
-RDX
DX 0000
:
-RES
ES 06D7
:6E7
-E200
O6D7:0200 OO.CD 00.13 00.CC ;***
-g=100
 
AX=0000 BX=7C00 CX=0001 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=06D7 ES=06D7 SS=06E7 CS=06E7 IP=0102 NV UP EI PL NZ NA PE NC
06E7:0102 CC INT 3
-NDISK.EXE ;***
-L
-UD 10
06E7:0000 EB05 JMPS 0007
06E7:0002 90 NOP
06E7:0003 0000 ADD [BX+SI],AL
06E7:0005 0000 ADD [BX+SI],AL
06E7:0007 80FA02 CMP DL,02
06E7:000A 7405 CMP 0011
06E7:000C 2E SEG CS
06E7:000D FF2E0300 JMP L,[0003] ;***
-W0 0 1 1
-Q
A>
A
. 10.3

FAT.
DOS "" C:.
- ,
FORMAT FAT ,
DOS.
 
-
- 1 0. DOS
C:,
. , , -
0,
.
 
,
. ,
.
-
, DOS, INT
27H.
.