?? bios.asm
字號:
INC AL ; ...show more
DAA
MOV DL,AL
JNB KBY_01
MOV AL,DH ; ...do carry
ADC AL,0
DAA
MOV DH,AL
KBY_01: MOV AL,DH
CALL DIGIT ; Print hex digit
MOV AL,DL
MOV CL,4
ROR AL,CL
CALL DIGIT ; Print hex digit
MOV AL,DL
CALL DIGIT ; Print hex digit
RET
TIMER: MOV DX,241h ; Check for timer #2 port
CLI
IN AL,DX ; ..read BCD seconds/100
STI
CMP AL,99h ; Are BCD digits in range?
JBE SER_01 ; ...yes, port exists
;
MOV DX,341h ; Check for timer #1 port
CLI
IN AL,DX ; ..read BCD seconds/100
STI
CMP AL,99h ; Are BCD digits in range?
JBE SER_01 ; ...yes, port exists
;
STC ; No hardware, ports 0FFh
RET
SER_01: CLC ; Found timer(s) answering
RET
V_CONT: MOV BP,4 ; Assume monochrome, 4K memory
MOV BX,0B000h ; ...segment in BX
MOV AL,DS:49h ; Get the video mode
CMP AL,7 ; ...was it mono?
JZ M_SEG ; ...yes, skip
MOV BP,10h ; Else CGA, has 16K memory
MOV BX,0B800h ; ...segment in BX
M_SEG: PUSH BX ; Load video seg in ES
POP ES
MOV AL,DS:65h ; Get CRT hardware mode
AND AL,11110111b ; ...disable video
MOV DX,DS:63h ; Get 6845 index port
ADD DX,4 ; ...add offset for
OUT DX,AL ; 6845 controller port
CRTRAM: CALL MEMTST ; Memory check ES:0 - ES:0400
DEC BP
JNZ CRTRAM ; Loop until CRT RAM checked
JNB LE2F5
OR Byte ptr DS:15h,ER_CRT ; Set CRT RAM error in status
LE2F5: CALL V_INIT
MOV AX,1414h ; Time-out value seconds
MOV DS:78h,AX ; ...LPT1
MOV DS:7Ah,AX ; ...LPT2
MOV AX,101h ; Time-out value seconds
MOV DS:7Ch,AX ; ...COM1
MOV DS:7Eh,AX ; ...COM2
MOV SI,offset LPTRS ; SI --> LPTR port table
XOR DI,DI ; ...offset into data seg
MOV CX,3 ; ...number of printers
NXTPRT: MOV DX,CS:[SI] ; Get LPTR port
MOV AL,10101010b ; ...write value
OUT DX,AL ; ...to the LPTR
MOV AL,11111111b ; Dummy data value
OUT 0C0h,AL ; ...on the bus
IN AL,DX ; Read code back
CMP AL,10101010b ; ...check code
JNZ NO_LPT ; ...no printer found
MOV [DI+8],DX ; Save printer port
INC DI
INC DI
NO_LPT: INC SI
INC SI
LOOP NXTPRT
MOV AX,DI ; Number of printers * 2
MOV CL,3 ; ...get shift count
ROR AL,CL ; ...divide by eight
MOV DS:11h,AL ; ...save in equip. flag
XOR DI,DI ; com port(s) at 40:00 (hex)
COM_1: MOV DX,3FBh ; COM #1 line control reg.
MOV AL,00011010b ; ...7 bits, even parity
OUT DX,AL ; Reset COM #1 line cont. reg
MOV AL,11111111b ; ...noise pattern
OUT 0C0h,AL ; Write pattern on data buss
IN AL,DX ; ...read result from COM #1
CMP AL,00011010b ; Check if serial port exists
JNZ COM_2 ; ...skip if no COM #1 port
MOV Word ptr [DI],3F8h ; Else save port # in impure
INC DI ; ...potential COM #2 port
INC DI ; ...is at 40:02 (hex)
COM_2: MOV DX,2FBh ; COM #2 line control reg
MOV AL,00011010b ; ...7 bits, even parity
OUT DX,AL ; Reset COM #2 line cont. reg
MOV AL,11111111b ; ...noise pattern
OUT 0C0h,AL ; Write pattern on data buss
IN AL,DX ; ...read results from COM #2
CMP AL,00011010b ; Check if serial port exists
JNZ COM_CT ; ...skip if no COM #2 port
MOV word ptr [DI],2F8h ; Else save port # in impure
INC DI ; ...total number of serial
INC DI ; ...interfaces times two
COM_CT: MOV AX,DI ; Get serial interface count
OR DS:11h,AL ; ...equip. flag
MOV DX,201h
IN AL,DX ; Read game controller
TEST AL,0Fh ; ...anything there?
JNZ NOGAME ; ...yes, invalid
OR Byte ptr DS:11h,00010000b ; Else game port present
NOGAME: MOV DX,0C000h ; ROM segment start
PUSH DS
FNDROM: MOV DS,DX ; Load ROM segment
XOR BX,BX ; ...ID offset
MOV AX,[BX] ; Read the ROM id
CMP AX,0AA55h
JNZ NXTROM ; ...not valid ROM
MOV AX,40h
MOV ES,AX
MOV AH,0
MOV AL,[BX+2] ; Get ROM size (bytes * 512)
MOV CL,5
SHL AX,CL ; Now ROM size in segments
ADD DX,AX ; ...add base segment
MOV CL,4
SHL AX,CL ; ROM address in bytes
MOV CX,AX ; ...checksum requires CX
CALL CHK_01 ; Find ROM checksum
JNZ BADROM ; ...bad ROM
PUSH DX
MOV Word ptr ES:67h,3 ; Offset for ROM being setup
MOV ES:69h,DS ; Segment for ROM being setup
CALL Dword ptr ES:67h ; ...call ROM initialization
POP DX
JMP short FND_01
BADROM: OR Byte ptr ES:15h,ER_ROM ; ROM present, bad checksum
NXTROM: ADD DX,80h ; Segment for next ROM
FND_01: CMP DX,0F600h ; End of ROM space
JL FNDROM ; ...no, continue
POP DS
IN AL,21h ; Read ic 8259 interrupt mask
AND AL,10111100b ; ...enable IRQ (0,1,6) ints
OUT 21h,AL ; (tod_clock,key,floppy_disk)
MOV AH,1
MOV CH,0F0h
INT 10h ; Set cursor type
CALL BLANK ; ...clear display
PUSH DS
PUSH CS
POP DS
POP ES
TEST Byte ptr ES:10h,1 ; Floppy disk present?
JZ FND_02 ; ...no
CMP Word ptr ES:72h,1234h ; Bios setup before?
JNZ CONFIG ; ...no
FND_02: JMP RESET ; Else skip memory check
CONFIG: MOV AX,41Ah ; Where to move cursor
MOV SI,offset STUF ; ...equipment message
CALL LOCATE ; ...position cursor
CALL PRINT ; ...and print string
MOV AX,51Bh ; New cursor position
MOV SI,offset STUF_1 ; ...CR/LF
CALL Locate ; ...position cursor
CALL PRINT ; ...and print string
TEST Byte ptr ES:15h,11111111b ; Any error so far?
JZ VALID ; ...no, skip
CALL PRINT ; Print string
MOV AL,ES:15h ; ...get error number
CALL NUMBER ; ...print hex value
CALL PRINT ; ...print prompt
MOV BL,4 ; ...long beep
CALL BEEP
CALL GETCH ; Wait for keypress
PUSH AX ; ...save answer
CALL OUTCHR ; ...echo answer
POP AX ; ...get answer
CMP AL,'Y' ; Was it "Y"
JZ FND_02 ; ...ok, continue
CMP AL,'y' ; Was it "y"
JZ FND_02 ; ...ok, continue
JMPF 0F000h,COLD ; Else cold reset
VALID: MOV SI,offset STUF_2 ; No errors found, load banner
CALL PRINT ; ...and print string
MOV AX,81Eh ; Where to move cursor
CALL LOCATE ; ...position cursor
CALL PRINT ; ...and print string
MOV AX,91Ch ; Where to move cursor
CALL LOCATE ; ...position cursor
MOV BL,17h ; Character count
FENCE: MOV AL,'-' ; Load ascii minus
CALL OUTCHR ; ...and print it
DEC BL
JNZ FENCE
MOV AX,0A21h ; Where to move cursor
CALL LOCATE ; ...position cursor
MOV AL,ES:49h ; Get CRT mode
CMP AL,7
JZ FEN_01 ; ...monochrome
MOV SI,offset STUF_3 ; ...color/graphics
FEN_01: CALL PRINT ; Print the string
MOV BX,0B21h
MOV AL,ES:11h ; Get equipment byte
PUSH AX
MOV CL,6
ROR AL,CL
AND AL,3 ; Number of printers
JZ FEN_02
MOV BP,8
MOV SI,offset STUF_4
CALL FAO ; Formatted ascii output
FEN_02: POP AX ; Equipment byte restore
MOV SI,offset STUF_5 ; ...game controller
PUSH AX ; Save a copy of equip. byte
TEST AL,00010000b
JZ NO_TOY ; Jump if no game controller
MOV AX,BX
CALL LOCATE ; Position cursor
CALL PRINT ; ...and print string
INC BH ; ...scroll line
NO_TOY: CALL TIMER ; Timer devices?
JB NO_TIM ; ...skip if none
MOV AX,BX
CALL LOCATE ; Position cursor
INC BH
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -