📄 disk.s
字号:
push ds pop es lea di,ac0 push di stosw mov ax,dx stosw xor ax,ax stosw stosw pop si call dprint call say .ascii " sectors) --> " .byte 0 call sizeit call say .byte 10,0 pop dx push dx call inqedd jc xdd1 br xdd4xdd1: call say .ascii " EDD rev " .byte 0 mov al,(si+1) mov cl,#4 mov ah,al shr al,cl add al,#'0 call putc mov al,#'. call putc mov al,ah and al,#0x0F add al,#'0 call putc call say .ascii " geometry = " .byte 0 test byte (si+2),#2 jz xdd2 mov ax,(si+4) mov dx,(si+6) or dx,dx jnz xdd1a cmp ax,#1024 jb xdd1bxdd1a: inc byte (bigcyl)xdd1b: call print call punct mov ax,(si+8) mov dx,(si+10) call print call punct mov ax,(si+12) mov dx,(si+14) call print call say .ascii " " .byte 0xdd2: call say .ascii "(" .byte 0 lea si,(si+16) call dprint call say .ascii " sectors) --> " .byte 0 mov ax,(si+6) cmp ax,nlimit+6 jb xdd3 ja xdd2a mov ax,(si+4) cmp ax,nlimit+4 jb xdd3 ja xdd2a mov ax,(si+2) cmp ax,nlimit+2 jb xdd3 ja xdd2a mov ax,(si) cmp ax,nlimit jb xdd3xdd2a: inc byte bigflagxdd3: mov dl,#1 call sizeit call say .byte 10,0xdd4: pop dx pop si pop di pop es pop cx pop bx pop ax pop bp retpunct: mov al,#': call putc retchars: .ascii " KMGTxyz"sizeit: push ax push bx push cx push dx push si push es push di lea bx,chars-1 mov di,si push ds pop es mov ax,#512 or dx,dx jz dpr5 ;handle small disks call intmul jmp dpr6dpr5: mov ax,#2 call intdiv inc bxdpr6: mov ax,#1000 lea di,ac1dpr7: lea bx,(bx+1) mov cx,dx call intdiv xchg si,di jnz dpr7 mov si,bx mov ax,dx xor bx,bx call dec3 cmp byte ptr (si),#'K je dpr8 mov al,#'. call putc mov ax,cx#if 1 mov bx,#0x800a add ax,#5 div bl xor ah,ah div bl add al,#'0 call putc xchg al,ah#else mov bx,#0x8000+100 add ax,#50 div bl#endif add al,#'0 call putcdpr8: mov al,(si) call putc pop di pop es pop si pop dx pop cx pop bx pop ax ret; print the decimal double word number in DX:AX;print: push ds push si xor si,si push si push si push dx push ax push ss pop ds mov si,sp call dprint lea sp,(si+8) pop si pop ds ret; print the decimal quad-word number in [DS:SI];dprint: push ax push bx push dx push es push di push ds push si sub sp,#8 mov di,sp push ss pop es xor bx,bx mov ax,#1000dpr1: inc bx call intdiv mov si,di push es pop ds push dx jnz dpr1 jmp dpr3dpr2: mov al,#', call putcdpr3: pop ax call dec3 mov bh,#0x80 dec bl jnz dpr2 lea sp,(di+8) pop si pop ds pop di pop es pop dx pop bx pop ax ret; multiply the number in the ac pointed at by [DS:SI] by the AX, putting; the result in the ac pointed to by [ES:SI]. Return overflow in AX.; SI and DI may be the sameintmul: push bp push si push di push bx push cx push dx mov cx,#4 mov bp,ax xor dx,dxim4: mov bx,dx lodsw mul bp add ax,bx adc dx,#0;;; nop ;spacer stosw loop im4 mov ax,dx pop dx pop cx pop bx pop di pop si pop bp ret ; divide the ac pointed at by [DS:SI] by the AX, producing a result; in [ES:DI], and a remainder in DX; the Z flag reflects the quotient; DI may equal SI for in-place divisionintdiv: push bx push cx push bp push di push si mov cx,#4 mov bx,cx dec bx add bx,bx lea si,(si+bx) lea di,(di+bx) xor dx,dx xor bp,bp std mov bx,axid2: lodsw div bx or bp,ax ;sets the Z flag stosw loop id2 cld mov ax,bx pop si pop di pop bp pop cx pop bx ret; write the number < 1000 in AX as 3 decimal digits; BH flags whether leading zeroes are printed (0x80=yes, 0=no)dec3: push bx push ax push cx mov cx,#2 mov bl,#100dec32: div bl xor al,bh jz dec36 xor al,bh mov bh,#0x80dec34: add al,#'0 call putc mov bh,#0x80dec36: mov al,ah mov ah,#0 mov bl,#10 dec cx jg dec32 jz dec34 pop cx pop ax pop bx ret; write the <nul> terminated string which follows the call; no registers alteredsay: push bp mov bp,sp push ds push si push ax mov si,(bp+2) push cs pop dssay1: lodsb or al,al jz say2 call putc jmp say1say2: mov (bp+2),si pop ax pop si pop ds pop bp ret; write the word in AX in hexwout: xchg ah,al call bout xchg ah,al call bout ret; write the byte in AL in hexbout: push ax push cx push ax mov cx,#0x204 shr al,clbout1: add al,#'0 cmp al,#'9 jbe bout2 add al,#'A-'0-10bout2: call putc dec ch jz bout4 pop ax and al,#0xF jmp bout1bout4: pop cx pop ax ret; write the character in AL in teletype mode; all registers are preservedputc: push bx push ax mov ah,#14 xor bh,bh cmp al,#10 ;test for new-line jne putc2 mov al,#13 ;get <cr> int 0x10 mov al,#10putc2: int 0x10 pop ax pop bx ret#define LILO_ASM#include "lilo.h"#include "read.S"#include "bdata.h"#define BD_VERBOSE#include "biosdata.S"exit: mov ax,cs mov dx,ds cmp ax,dx jae bd_testexit_dos: mov ax,#0x4c00 int 0x21bd_test: call pause call say .ascii "BIOS data collection test.\n" .ascii "Failure of this test will require booting all Linux\n" .ascii "kernels with the 'nobd' command-line option.\n" .ascii "Hit <ESC> to bypass, any other key to continue..." .byte 0 mov ah,#0 int 0x16 call say .byte 10,10,0 cmp al,#0x1b ; <ESC> je bd_test_skip#if 1 mov ax,cs mov bx,#SYSSEG cmp ax,bx jae collect mov es,bx mov di,#theend-1 std lea cx,(di+1) mov si,di rep movsb mov ss,bx mov ds,bx cld push es push #collect retfcollect:#endif call io_biosdata call say .ascii "\nALL OKAY\n\n" .byte 0bd_test_skip: call say .ascii "Remove the floppy disk from the drive.\n" .ascii "Hit any key to reboot..." .byte 0 mov ah,#0 int 0x16 call say .byte 10,10,10,0bs_helper: int 0x19 ;label here for kludgeid_string: .ascii "Disk.Com" .byte 0ac0: .word 0,0,0,0ac1: .word 0,0,0,0dparam: .word dlthdflags: .word 0dcyl: dd 0dhead: dd 0dsec: dd 0dsecs: dd 0,0ssize: .word 0dptp: dd 0dlthe:dlth = dlthe-dparammodelist:theend:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -