zoukankan      html  css  js  c++  java
  • [原]一个简单的将自己移动的boot

    bits 16 ;16位实模式指令
    INITSEG equ 0x7c00  ;boot被加载的位置所有offset需要使用
    start:
           mov  ax, cs    ;cs被初始化为0x0000
           mov  ss, ax  
           mov sp, 0xffff            ;设置一个堆栈
           call   clear
           call  print
           mov  ax, 0x9000     ;boot将被移动到0x90000处
           mov  es, ax
           xor di, di
          
          mov ax, 0x07c0       ;从0x07c00处复制, 注意段寄存器值要右移4位
          mov  ds, ax
          xor   si, si
         
           mov  cx, 256   ;共有512字节
    run:
           mov   ax, [ds:si]     
           mov   [es:di], ax
           inc     si
            inc  si
            inc di
            inc di
            dec  cx
            jnz run
          
            jmp   0x9000:nloop
     nloop:
             mov   ax, cs  ;注意这里cs为0x9000
             mov  ds, ax
             mov  es, ax
             mov  ax, 1301h
             mov  bp, string
             mov  cx,  strlen
             mov dh,  5
            mov dl,  0
            mov  bh, 0
            int 10h
            jmp $
    print:                   
            mov ax, cs    
        mov es, ax
        mov ax , 1301h
        mov bl, 7
        mov bp, INITSEG + string  ;定位字符串位置0x7c00 + string
        mov cx, strlen
        mov dh, 0
        mov dl, 0
        mov bh, 0
        int 10h
        ret         
    clear:
        mov al, ' '
        mov bh, 0
        mov bl, 7
        mov cx, 2000
        mov ah, 09h
        int 10h
        ret    
    string : db 'booting...'
    strlen equ $ - string
    times (512-($ -$$)- 2) db 0 ;padding with 0
    db 0x55
    db 0xaa

    作者:liyonghelpme 发表于2010/6/12 9:48:00 原文链接
    阅读:188 评论:0 查看评论
  • 相关阅读:
    Coding4Fun.Phone.Controls的使用
    发布windows phone应用经历实谈
    我的第一款windows phone软件
    华农js抢课神器
    zookeeper 实战案例分享:cruator客户端编程
    zookeeper学习与实战(二)集群部署
    zookeeper学习与实战(一)环境部署
    Flask框架的学习与实战(三):登陆管理
    Flask框架的学习与实战(二):实战小项目
    Flask框架的学习与实战(一):开发环境搭建
  • 原文地址:https://www.cnblogs.com/liyonghelpme/p/4273545.html
Copyright © 2011-2022 走看看