我对装配很新,但我正试图深入了解低级计算的世界.我正在尝试学习如何编写将作为引导加载程序代码运行的汇编代码; 所以独立于任何其他操作系统,如Linux或Windows.在阅读了本页和其他几个x86指令集列表之后,我想出了一些汇编代码,它应该在屏幕上打印10 A然后是1 B.
BITS 16
start:
mov ax, 07C0h ; Set up 4K stack space after this bootloader
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096
mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax
mov cl, 10 ; Use this register as our loop counter
mov ah, 0Eh ; This register holds our BIOS instruction
.repeat:
mov al, 41h ; Put …Run Code Online (Sandbox Code Playgroud) 我学会了使用基于DOS的简单Bootloader切换到保护模式。该加载程序加载kernel.bin到缓冲区中,并将缓冲区复制到100000h(内核为8KiB)。然后将控制权转移到内核。当我从内核返回并尝试切换到实模式时,我遇到了一个问题。
我的FASM汇编代码(类似于我先前的Stackoverflow问题)如下:
format MZ
push cs
pop ds
mov eax,cs
shl eax,4
mov [AdresSegmentuProgramu_32],eax ;Calculating real mode segment
add eax,gdt_table
mov [gdtr+2],eax
mov ax,[AdresSegmentuProgramu_32+2]
mov [code_realsegment_descriptor+3],ax
mov al,[AdresSegmentuProgramu_32+1] ;Setting 16-bit descriptors to return from protected mode
mov [code_realsegment_descriptor+2],al
mov ax,[AdresSegmentuProgramu_32+2]
mov [data_realsegment_descriptor+3],ax
mov al,[AdresSegmentuProgramu_32+1]
mov [data_realsegment_descriptor+2],al
mov ax,3d00h
mov dx,NazwaPliku
int 21h
mov bx,ax
mov ax,3f00h
mov cx,8192
mov dx,KernelGDOS32
int 21h
mov ax,3e00h
int 21h
lgdt [gdtr]
mov eax,[AdresSegmentuProgramu_32]
add eax, pmode_entry ;Far jump to …Run Code Online (Sandbox Code Playgroud) 我正在编写引导加载程序并尝试测试处理器间中断。我有以下两个问题阻止了我:
1、在哪里可以找到启动AP的流程;
2、在发出IPI时,我应该加载内存地址告诉目标处理器从哪个内存地址开始。
感谢您的回答,如果您能附上一个装配示例。