A simple bootstrap

原创 2004年11月01日 22:14:00

                                                A simple bootstrap
                                                                    -----2004.11.1 (C) Gr1x
To make a long story short, and enough material can be found about the PC's POST procedure, I'll just show my code and explain sth important steps, I think my source code is self-explaining enough 'cause it's short and easy to understand . I have tested it with a floppy disk,  it's risky to test it with ur harddrive. If  u did do it, I  am not responsible for any damage u made : )
Environment :(Window Platform)
     a.VMWare(Optional).If u don't want to reboot ur system many times, u should get this.
     b: Nasm.(Essential). As u need it to compile ur code . u may use Ndisasm as well to disassemble the plain binary code compiled.
    c:Visual C++ 6 or Visual Stdio .Net. As we have to write a EXE to write the bootstrap to floppy.
       U may use WinHex to write bootstrap to floppy too instead of this writing a programme.
1>Write the bootstrap procedure
;                     bootstrap.asm: 2004-11-1 (C) Gr1x
;                     Email:gr1x@sina.com
[ORG 0]
     jmp 07C0h:start                ; remember that BIOS loads this procedure in  0:7C00h, but don't count on registers like DS
                                             ;was initialized to 0. So we jump to it ourself.
    msg db 'Hello Gr1x!',0x0
    ; Update the segment registers
     mov ax, cs
     mov ds, ax
     mov es, ax
     mov si, msg ; Print msg
     lodsb ; loads charater at 0x7C0h:msg
     mov ah, 0eh ; 
     int 10h
     cmp al, 0 ;
     jne print ; 
     jmp $
     times 510-($-$$) db 0
     dw 0000h        ;or dw 0AA55h, u can write anything here , it seems that BIOS doesn't check this 2 bytes when 
                            ; it try to boot from a floppy disk
OK , now compile it:
        >nasm bootstrap.asm -o bootstrap.bin
2.Now , copy this bootstrap to floppy's boot sector. If u do it with WinHex , u can omit following.
   I wrote a program which do this action.
//              write_fd.cpp: 2004-11-1 (C) Gr1x
//               Email:gr1x@sian.com

#include <windows.h>
#include <winioctl.h>
#include <stdio.h>
#pragma comment(linker,"/subsystem:console" )
void Banner()
 printf("  write_fd:write a file to floppy in raw mode/n");
 printf("  author:gr1x              email:gr1x@sian.com/n");
 printf("  usage:write_fd filename/n");

int main(int argc, char **argv)
 HANDLE                  hDevice=NULL,hFile=NULL;
 TCHAR                   szDevicename[64];
 LPTSTR                  szBuff=NULL;
 DISK_GEOMETRY           Geometry;
 BOOL                    bRet;
 DWORD                   bytes,bread,count;
  printf("Usage:%s filename/n",*argv);
  if (hDevice == INVALID_HANDLE_VALUE)
   printf("Error in open file %s!/n",argv[1]);
  hDevice = CreateFile( szDevicename,

  if (hDevice == INVALID_HANDLE_VALUE)
   printf("Error in open floppy device!");

  DeviceIoControl(hDevice,FSCTL_LOCK_VOLUME, NULL,0,NULL,0,&count,NULL);
  szBuff = (LPSTR)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,Geometry.BytesPerSector*2);
  if ( szBuff == NULL)
   printf("Error in HeapAlloc!");
  bytes = 512*2;
  bRet = ReadFile(hFile, szBuff, bytes, &bread, NULL);
  if (bRet==FALSE || bread<512)
   printf("Error in read file!");
  printf("%d bytes read from %s/n",bread,argv[1]);
  if (bRet==FALSE || bread<512)
   printf("Error in write file to floppy!");
  if(!DeviceIoControl(hDevice,FSCTL_UNLOCK_VOLUME, NULL,0,NULL,0,&count,NULL))
   printf("DeviceIoControl(hDevice,FSCTL_UNLOCK_VOLUME, NULL,0,NULL,0,&count,NULL) error!/n");
  DeviceIoControl(hDevice,FSCTL_UNLOCK_VOLUME, NULL,0,NULL,0,&count,NULL);
  printf("Write finished!/nBoot sector in HEX:/n");
  for(int j=0,int i=0; i<512; i++)
   unsigned char ch=(unsigned char) szBuff[i];
   if (j==8) printf(" -");
   if (j==16)
   if (ch<0x10) printf(" %2x",ch);
   else printf(" %2x",ch);
 return 0;
Don't ask me how to compile this cpp file!
3>Type following commad in CMD
    >write_fd bootstrap.bin
4>OK, boot ur system with the floppy.God bless u!


00x1 问题提出 Collecting flask-bootstrap Could not fetch URL https://pypi.python.org/simple/flask-boots...
  • pythonniu
  • pythonniu
  • 2017年07月16日 14:14
  • 1177


一、Bootstrap简介:       Bootstrap是Twitter推出的一个开源的用于前端开发的工具包。它由Twitter的设计师Mark Otto和Jacob Thornton合作开发。B...
  • SQ_Bang
  • SQ_Bang
  • 2016年05月06日 09:59
  • 988

线段树模版—A Simple Problem with Integers

D - A Simple Problem with Integers Time Limit:5000MS     Memory Limit:131072KB     64bit IO Format:...
  • llzhh
  • llzhh
  • 2016年04月29日 00:03
  • 159

关于cmake is not able to compile a simple test program

指定了交叉编译 set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_FIND_ROOT_PATH "/opt/mips/eldk4.1/usr/bin") set(CMAK...
  • fzs333
  • fzs333
  • 2016年05月23日 18:52
  • 3367

[NLP论文阅读]A simple but tough-to-beat baseline for sentence embedding

  • sinat_31188625
  • sinat_31188625
  • 2017年05月24日 15:50
  • 1857

compiler "cl" is not able to compile a simple test program.

以下是我遇到的问题。网络上找来找去,还有外国的朋友也出现过的问题,只是都没有正确解决。 至于怎么下载ogre,怎么运行cmake。我这里就不说了。ogre中文网上都有详细说明。 主要问题是...
  • hongqiang200
  • hongqiang200
  • 2012年11月12日 20:51
  • 8436

eclipse构建maven project 的web项目,不勾选Create a simple project 。 < =2= >

eclipse构建maven project  的web项目,不勾选Create a simple project 。 1、开启eclipse,右键new——》other,如下图找到mav...
  • big_bigwolf
  • big_bigwolf
  • 2016年10月21日 09:46
  • 3775

eclipse构建maven project 的web项目,勾选Create a simple project < =1= >

Eclipse+Maven创建webapp项目 1、开启eclipse,右键new——》other,如下图找到maven project 2、选择maven project,显示创建maven...
  • big_bigwolf
  • big_bigwolf
  • 2016年10月21日 09:39
  • 3292

Dropout: A Simple Way to Prevent Neural Networks from Overtting(泛读)

一.文献名字和作者     Dropout: A Simple Way to Prevent Neural Networks from Overtting     二.阅读时间    ...
  • shengno1
  • shengno1
  • 2014年11月19日 01:20
  • 2591


概括来说,这篇文章主要设计了一种无监督的 sentence embedding 方法,即如何加权句子中的每个单词从而计算得到整个句子的向量表示,所设计的模型在文本相似度、文本蕴含、文本分类等任务上表现...
  • CristianoJason
  • CristianoJason
  • 2017年09月15日 20:15
  • 808
您举报文章:A simple bootstrap