问题描述
我写了一个终端样式的操作系统,但下一个扇区没有加载,我似乎无法找到为什么我从未告诉它打印的字符串正在打印。
[bits 16] ; tell assembler that working in real mode(16 bit mode)
[org 0x7c00] ; organize from 0x7C00 memory location where BIOS will load us
%define cr 0xd
%define lf 0xa
start: ; start label from where our code starts
xor ax,ax ; set ax register to 0
mov ds,ax ; set data segment(ds) to 0
mov es,ax ; set extra segment(es) to 0
mov bx,0x8000
;clear screen
mov ah,00h
mov al,2
int 10h
;reset cursor
mov ah,02h
mov bh,00h
mov dh,00h
mov dl,00h
int 10h
;start kernl
mov si,intro_os
call print_str ;here is where I call the defined print function,it should move straight to pt2 of it
;Functions here
print_str:
mov ah,0xE
.repeat:
lodsb
cmp al,0
je .done
int 10h
jmp .repeat
.done:
ret
read_inp:
.repeat:
mov ah,00h
int 16h
cmp al,0x1c
je .done
mov bx,[input_idx]
mov [input+bx],al
inc byte [input_idx]
mov ah,0xE
int 10h
jmp .repeat
.done:
mov byte [input_idx],0
ret
;end functions
;vars and strings
intro_os db 'ProtOS VERSION:ALPHA-001,written by Julian Ratcliffe.',cr,lf,0
loading db 'Please wait,we are loading the operating system...',0 ;this is being printed unintentionally
kern_mn db cr,'<ProtOS_V_A001>---$ ',0
input times 100 db 0
input_idx db 0
;end vars and strings
; load second sector into memory
mov ah,0x02 ; load second stage to memory
mov al,1 ; numbers of sectors to read into memory
mov dl,0x80 ; sector read from fixed/usb disk
mov ch,0 ; cylinder number
mov dh,0 ; head number
mov cl,2 ; sector number
mov bx,_OS_Stage_2 ; load into es:bx segment :offset of buffer
int 0x13 ; disk I/O interrupt
jmp _OS_Stage_2 ; jump to second stage
; boot loader magic number
times ((0x200 - 2) - ($ - $$)) db 0x00 ;set 512 bytes for boot sector which are necessary
dw 0xAA55 ; boot signature 0xAA & 0x55
_OS_Stage_2:
;part two of OS (it never reaches this)
mov ah,02h
int 10h
mov si,intro_os
call print_str
mov si,kern_mn
call print_str
call read_inp
; add how much memory we need
times (1024 - ($-$$)) db 0x00
它调用打印函数来打印 intro_os 字符串,但它以某种方式最终打印出加载字符串,并且代码中的所有移动都停止了,我确实尝试通过将 cli 和 hlt 放在调用下方来查看它是什么打印功能,这表明它(故障)在函数部分或 vars 部分。 请帮我看看我做错了什么,提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)