📄 wrboot.asm
字号:
;NASM-IDE ASM Assistant Assembler Project File[BITS 16] ;Set code generation to 16 bit mode[ORG 0x0100] ;Set code start address to 0100h[SEGMENT .text] ;Main code segmentmov dx,filename ;Set Filenamemov ax,3d00h ;Open For Readint 21h ;Call DOSjc Error_File ;Failed to open filemov dx,buffer ;set buffermov bx,ax ;set file handlemov ah,3fh ;Read Filemov cx,512 ;Read first 512 bytesint 21hjc Error_Filemov ah,3eh ;Close Fileint 21hjc Error_Filerereset:mov dl,0 ;Disk->Amov ah,0 ;Reset Diskint 13h ;BIOS Diskjc reresetretrydisk:mov ah,3 ;Ready to Write Diskmov al,1 ;Number of Sectormov ch,0 ;clyn=0mov cl,1 ;sector=1mov dh,0 ;head=0mov dl,0 ;drive->Amov bx,bufferint 13hjc retrydiskEnd:mov ax,4c00h ;Ready to Exitint 21hError_Disk:mov dx,diskermsgjmp DisplayError_File:mov dx,errornofile ;Failed to openfileDisplay:mov ah,9 ;Ready to Display Messageint 21hjmp End ;Ready to Exit[SEGMENT .data] ;Initialised data segmenterrornofile db "File bootsect.bin not found!",0dh,0ah,"$"filename db "bootsect.bin",0successmsg db "Successfully wrote",0dh,0ah,"$"diskermsg db "Disk Error!",0dh,0ah,"$"[SEGMENT .bss] ;Uninitialised data segmentbuffer resw 512
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -