好吧,我已经在程序集中编写了一个引导加载程序,并尝试从中加载C内核。
这是引导程序:
bits 16
xor ax,ax
jmp 0x0000:boot
extern kernel_main
global boot
boot:
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 ;0 for floppy; 0x80 for hd
mov ch, 0 ; cylinder number
mov dh, 0 ; head number
mov cl, 2 ; sector number
mov bx, 0x8000 ; load into es:bx segment :offset of buffer
int 0x13 ; …Run Code Online (Sandbox Code Playgroud) 我正在构建一个 6502 模拟器,我希望以可视方式表示 cpu 和内存状态。
我正在使用 SDL2 来实现此目的。当 6502 cpu 或内存改变状态时,我必须在 SDL 窗口上渲染文本。
即我希望以文本和数字的形式显示整个内存内容、当前正在执行的指令、先前的CPU状态、当前的CPU状态。
这是我尝试使用 Linux 系统中已有的字体来呈现文本。后来我希望渲染动态文本和数字而不是静态字符串。
#include<SDL2/SDL.h>
#include<SDL2/SDL_ttf.h>
#define SCREEN_HEIGHT 640
#define SCREEN_WIDTH 480
int quit=false;
SDL_Window *window;
SDL_Renderer *renderer;
int initializeDrawing(int argc,char** argv){
if (SDL_Init(SDL_INIT_VIDEO) != 0){
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
window = SDL_CreateWindow("6502 cpu display!", 100, 100, SCREEN_HEIGHT, SCREEN_WIDTH, SDL_WINDOW_SHOWN);
if (window == nullptr){
std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}
renderer = …Run Code Online (Sandbox Code Playgroud)