startup.com主要代码

 Su Main的主要代码startup.com的入口代码
[bits 16]
[section .text]
org 0
Start:
  jmp  RealStart   ;地址为0x20000
 
  times 512-($-$$) db 0
 
RealStart:
  mov  ax,cs
  mov  ss,ax
  mov  ds,ax
    
  xor  eax,eax
  xor  ecx,ecx
  xor  edx,edx
  xor  ebx,ebx
  xor  esi,esi
  xor  edi,edi
  xor  ebp,ebp
  mov  esp,SuStack
  call SuMain
SuMain:
  push bp
  mov  bp,sp
  
  call ConstructMemoryDescriptors   ;建立和物理内存的描述符
  call EnableA20       ;开启A20 80286处于实模式下时,防止用户程序访问到100000h~10FFEFh之间的内存(高端内存) 如果读写0x10ffef实际上是0x0ffef
  call Relocatex86Structures    ;重定位GDT和IDT(最感兴趣的全局描述符表和中断描述符表)
 
  push word 0
  call EnableProtectPaging     ;开启保护模式,但是不开启分页机制。经常搞得禁用cr0
  add  sp,2
  push dword  BootRecord.OsLoaderEnd
  push dword  BootRecord.OsLoaderStart
  call RelocateLoaderSections    ;加载osloader到0x00400000
  add  sp,8
    
  push eax
  call TransferToLoader     ;把系统控制权转给osloader
  add  sp,4
  
  mov  sp,bp
  pop  bp
  retn

转载于:https://my.oschina.net/fatboy/blog/401587

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值