从pc裸机磁盘(第一个扇区以后的扇区)中载入程序数据并运行

;$$ - start position
	bits 16
	cpu 8086
	org 07c00h
	mov ax,cs
	mov ds,ax
	mov es,ax
	
	;output bootMsg -- first msg
	mov ax,bootMsg  ;input parameter msg
	mov cx,bootMsgLen		;str length
	mov dh,00h ;第1行
	call ShowMsg	;output str
	
	;load second Second Sector Code data
	;Have to load it! Or errors will occur.
	call LoadSecondSectorRun
	
	;exec second sector code
	jmp SecondSectorRun
	
	jmp $ ;loop at current postion
	
ShowMsg:
	mov bp,ax
	mov ax,01301h
	mov bx,000ch
	mov dl,0 ;列 dh 是行
	int 10h
	ret
	
	;载入第二个扇区数据,从磁盘到内存
LoadSecondSectorRun:
	mov ah,02h                            ;读磁盘扇区  
    mov al,01h                            ;读取1个扇区  
    mov ch,00h                            ;起始磁道  
    mov cl,02h                            ;起始扇区  
    mov dh,00h                            ;磁头号  
    mov dl,00h                            ;驱动器号  
    mov bx,SecondSectorRun                             ;存储缓冲区  
    int 13h
    ret 
	
bootMsg: 
	db "Hello,World!"
	bootMsgLen equ $-bootMsg
	;$ -current position 
times 510-($-$$) db 0
dw 0xaa55

SecondSectorRun:
	;output secondSectorRunMsg -- first msg
	mov ax,secondSectorRunMsg  ;input parameter msg
	mov cx,ssrmLen		;str length
	mov dh,01h ;第2行
	call ShowMsg	;output str
	
secondSectorRunMsg:
	db "Loaded Second Sector Data Successfully!"
	ssrmLen equ $-secondSectorRunMsg
times 512*2-($-$$) db 0 

从磁盘载入数据到内存,用 int 13h,相关参数查文档.
这里磁盘载入的数据以扇区为单位.
还有相关的LBA什么的,要想了解,也要查资料.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值