textbox

IT博客 联系 聚合 管理
  103 Posts :: 7 Stories :: 22 Comments :: 0 Trackbacks

编辑工具:  EditPlug 3.01
光盘镜像工具 :  UltraISO 9.2.0
编译工具:nasm 0.98.38
调试工具:Bochs-2.3.7

BootSect.asm 文件


 bits 16
 org 0x0000
 ;org 0x0100 
%define BOOT_STARTRUN_ADDR 0x7c0
%define BCB_TO_ASCII(x)  add x , 0x30
%define TIME_POSITION_ROW 0x9
%define TIME_POSITION_COLUMN 0x9
%define SYSTE_START 0x1000

 start:
    cli   
    mov ax , BOOT_STARTRUN_ADDR
    mov es , ax
    mov ds , ax
    mov ss , ax
    call Print_Menu   
    call ReadKey ;;读区键盘缓冲区的字符 并写到 [var_tmp] 中
    cmp byte [var_tmp] , 0x31
    je ResetPC
    cmp byte [var_tmp] , 0x32
    je LoadSystem
    cmp byte [var_tmp] , 0x33
    je Time
    cmp byte [var_tmp] , 0x34
    je SetTime
    jmp bootend
 ReadKey:
    .s:
    mov ah , 0
    int 0x16   
    cmp al , 0xd ;按回车键
    je .ReadKey_end
    cmp al , 0x30  ;只能输入大于 0x30的数字
    jbe .s
    cmp al , 0x35  ;只能输入小于于0x34的数字
    jae .s
    mov byte [var_tmp] ,al
    call Get_Pos
    mov cx , 1
    mov ah , 0xa
    mov al , byte [var_tmp]
    int 0x10
    jmp .s
    .ReadKey_end
    ret
 LoadSystem:
    mov byte [DiskAddressPacket.PackSize] , 0x10
    mov byte [DiskAddressPacket.Reserved] , 0x0
    mov word [DiskAddressPacket.BlockCount] , 0x1
    mov dword [DiskAddressPacket.BufferAddr] , BOOT_STARTRUN_ADDR*16+SYSTE_START ; Buffer's LBA
    mov dword [DiskAddressPacket.BlockNum],   0x0
    mov dword [DiskAddressPacket.BlockNum+4], 0x0
    mov ah , 0x42
    mov dl , 0x80
    mov si , DiskAddressPacket
;    mov ah , 0x41
;    mov bx , 0x55AA
;    mov dl , 0x80
    int 0x13       ;这里调用扩展int13 42号功能读取光盘数据 我怎弄都不不行. 这个运行之后 ax=0x420d ????? 根据扩展 int13说明 ah =错误代码? 可是我怎么找都早不到42号错误代码是什么?
    jb error_input
    jmp SYSTE_START
    jmp bootend
 ResetPC: ;;从新启动电脑
    jmp word 0xffff:0000
 SetTime: ;;设置时间
    call Time
    jmp bootend
 Time: ;;打印时间
  call Get_Pos
  s:
  mov bx , var_time
  mov ah , 9
  call ReadTime  
  mov ah , 8
  call ReadTime  
  mov ah , 7
  call ReadTime
  mov ah , 4
  call ReadTime
  mov ah , 2
  call ReadTime
  mov ah , 0
  call ReadTime
  call print_time
  jmp s
  ret
 error_input:
    call Get_Pos
    mov cx , time_str-error
    mov bx , 0x0007
    mov bp , error
    mov ax , 0x1301
    int 0x010               ;;Print out the loading message.    利用10中断在屏幕输出字符          
    jmp bootend
 print_time
    mov ax , word [var_time.Year]
    mov word [time_str+2] ,ax
    mov ax , word [var_time.Month]
    mov word [month] ,ax
    mov ax , word [var_time.Day]
    mov word [day] ,ax
    mov ax , word [var_time.Hour]
    mov word [hour] ,ax
    mov ax , word [var_time.Minitue]
    mov word [minitue] ,ax
    mov ax , word [var_time.Second]
    mov word [Second] ,ax
   
    mov al , 1
    mov bh , 0
    mov bx , 0x0007
    mov bp , time_str
    mov cx , end_Print_message - time_str
    mov ah , 0x13
    int 0x010
    ret
bootend:  ;;程序结束空循环
;    mov cx,0x0001
;    loop bootend
     jmp $
 Print_Menu:
    call Get_Pos
    mov cx , error -System_menu
    mov bx , 0x0007
    mov bp , System_menu
    mov ax , 0x1301
    int 0x010                    ;;Print out the loading message.    利用10中断在屏幕输出字符
    ret                          ;;End of the procedure.
Get_Pos:
    mov ah , 0x3
    mov bh , 0x0
    int 0x10
    ret
ReadTime    
    mov al ,ah
    out 70h ,al
    in al , 71h
    mov ah , al
    mov cl , 4
    shr ah , cl
    and al , 00001111b
    BCB_TO_ASCII (ah)
    BCB_TO_ASCII (al)
    mov byte [bx] ,ah
    mov byte [bx+1] ,al
    add bx , 2
    ret
 Print_message:
    System_menu
            db 0x0d      ;;0x0d =13 回车
            db 0x0a         ;;换行
            db '1) Reset PC'
            db 0x0d
            db 0x0a
            db '2)Load system'
            db 0x0d
            db 0x0a
            db '3) Clock'
            db 0x0d
            db 0x0a
            db '4) Set clock'
            db 0x0d
            db 0x0a
            db 'SelectItem : '
      error db 0x0d
            db 0x0a
            db 'Boot Error'
            db 0x0d
            db 0x0a
   time_str db 0x0d
            db 0x0a
            db 0,0,
            db '-'
      month db 0,0
            db '-'
      day    db 0,0
            db ' '
       hour    db 0,0
            db ':'
    minitue    db 0,0
            db ':'
     Second db 0,0
  end_Print_message
    var_tmp db 0x0
    var_time
        .Year   db    0,0
        .Month    db    0,0
        .Day    db    0,0
        .Hour    db    0,0
        .Minitue db    0,0
        .Second db    0,0
    endvar_time
    DiskAddressPacket
        .PackSize    db 0
        .Reserved    db 0
        .BlockCount db 0,0
        .BufferAddr db 0,0,0,0
        .BlockNum    db 0,0,0,0,0,0,0,0
    endDiskAddressPacket
  end_boot
    times 510 - ($ - $$) db 0x00
            dw 0xaa55
;=====================================================================
以下是int 13 42号功能的说明

IBM/MS INT 13 Extensions - EXTENDED READ

AH = 42h
DL = drive number
DS:SI -> disk address packet (see #0249)

Return:
CF clear if successful
AH = 00h
CF set on error
AH = error code (see #0211)
disk address packet's block count field set to number of blocks
successfully transferred

See Also:AH=02h - AH=41h"INT 13 Ext" - AH=43h"INT 13 Ext"


Format of disk address packet:

Offset Size Description (Table 0249)
00h BYTE 10h (size of packet)
01h BYTE reserved (0)
02h WORD number of blocks to transfer (max 007Fh for Phoenix EDD)
04h DWORD -> transfer buffer
08h QWORD starting absolute block number
(for non-LBA devices, compute as
(Cylinder*NumHeads + SelectedHead) * SectorPerTrack +
SelectedSector - 1

制作iso光盘镜像文件
利用UltraISO工具建立光盘让后在菜单里选 启动光盘->加载引导文件
选择上面编译过生成的 bootSect.bin的二进制文件.生成 Boot.iso

最后在 bochs 的demo的配置文件修改
原来:
ata0-master: type=disk, path="hd10meg.img", cylinders=306, heads=4, spt=17
修改成
ata0-master: type=cdrom, path="D:\boot\Bin\boot.iso", status=inserted
 启动 bochs开始调试.....................
哪个高手能帮我解决掉这个问题!!!!!!!!

posted on 2008-09-22 00:36 零度 阅读(1639) 评论(4)  编辑 收藏 引用

Feedback

# re: 自己写的一个MBR 其中扩展int 13实在是读不出光盘映射文件的数据,这问题都挂了好几天了...那位高手 2010-02-20 15:33 羊宝
上面,光盘上文件是有特殊格式的。  回复  更多评论
  

# re: 自己写的一个MBR 其中扩展int 13实在是读不出光盘映射文件的数据,这问题都挂了好几天了...那位高手 2010-02-22 11:43 零度
@羊宝
中断读出的只是二进制的数据跟文件的格式没有关系,什么文件的格式保存到光盘里面都是二进制数据。
我的卡的问题是int 13 中断为什么读不出我做的Boot.iso里面的数据。

不过还是谢谢你回答这个问题! 虽然问题都挂着很久没有去弄了。  回复  更多评论
  

# re: 自己写的一个MBR 其中扩展int 13实在是读不出光盘映射文件的数据,这问题都挂了好几天了...那位高手 2010-04-12 15:58 某某
光盘的话是DL=9F ,我也卡了好几天,找N多资料找不出来,最后自己试出来的。QQ331928520有问题一起探讨  回复  更多评论
  

# re: 自己写的一个MBR 其中扩展int 13实在是读不出光盘映射文件的数据,这问题都挂了好几天了...那位高手 2012-03-04 14:59 某某
@某某
很是感谢啊..找了好久都没找到光盘的DL应该是多少..终于找到了..  回复  更多评论
  

只有注册用户登录后才能发表评论。