码迷,mamicode.com
首页 > 其他好文 > 详细

操作系统学习--day2

时间:2015-10-31 19:52:17      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

读取其它扇区数据:

org    0x7c00
jmp    entry

entry:
    mov    ax,cs
    mov    ds,ax
    mov    es,ax
    
    mov    ax,msg
    mov    bp,ax
    mov    cx,26
    mov    ax,0x1301
    mov    bx,000ch
    mov    dl,0
    int 10h

;读扇区:ah=02h    
    mov    ax,0x0820
    mov    es,ax
    mov    ch,0        ;柱面
    mov    dh,0        ;磁头
    mov    cl,2        ;扇区
    
    mov    ah,0x02
    mov    al,1        ;扇区数
    mov    bx,0        ;ES:BX--缓冲区数据
    mov    dl,0x00        ;驱动器:00H~7FH软盘,80H~0FFH硬盘
    int    0x13
    

msg    db    This is program by myself!
    times    510-($-$$) db 0
    dw    0xaa55

 拓展:

  循环读取扇区数据

  

org    0x7c00
jmp    entry

entry:
    mov    ax,cs
    mov    ds,ax
    mov    es,ax
    
    mov    ax,msg
    mov    bp,ax
    mov    cx,26
    mov    ax,0x1301
    mov    bx,000ch
    mov    dl,0
    int 10h

;读扇区:ah=02h    
    mov    ax,0x0820
    mov    es,ax
    mov    ch,0        ;柱面
    mov    dh,0        ;磁头
    mov    cl,2        ;扇区

readloop:    
    mov    ah,0x02
    mov    al,1        ;扇区数
    mov    bx,0        ;ES:BX--缓冲区数据
    mov    dl,0x00        ;驱动器:00H~7FH软盘,80H~0FFH硬盘
    int    0x13
    jnc    next
    mov    ax,0x00
    mov    dl,0x00
    int 0x13        ;重置驱动器
    jmp    readloop
next:
    mov    ax,es
    add    ax,0x20
    mov    es,ax
    inc    cl
    cmp    cl,18        ;最多读取18个扇区
    jbe    readloop
    

msg    db    This is program by myself!
    times    510-($-$$) db 0
    dw    0xaa55

 

操作系统学习--day2

标签:

原文地址:http://www.cnblogs.com/TnaHades/p/4925965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!