我正在为 x86 编写游戏引导程序。有一次,在启动初期,我需要将启动驱动器中的一些扇区加载到内存中。我用中断 0x13 (ah=02) 来做到这一点,当我在我的虚拟机中尝试它时,它就像一个魅力。但是,当我将映像刻录到 USB 驱动器时,机器无法启动,我将其固定到扇区加载指令,显然我的 USB 驱动器不是驱动器 0(软盘 A),因此读取失败。
如何确定用于启动的驱动器?
谢谢!
嗨,我在编译 x86 汇编程序代码时遇到问题,我使用 nasm 进行编译,但编译器告诉我语法错误。我不明白,因为我使用了一个简单的标签并跳转到它?有人可以给我解释一下吗..
; reads character and prints ascii code in console
[BITS 16]
SEGMENT code
..start:
mov ax, pile
mov ss, ax
mov ax, topofstack
mov sp, ax
loop: ; gives syntax error
mov ah, 00h
int 16h
cmp ax, 1c0dh ; user pressed enter, jump to end
je end
mov ah, 09h ; write character and attribute at cursor position
mov bh, 0h ; flags...
mov bl, 08h
mov cx, 01h
int 10h
jmp loop ; …Run Code Online (Sandbox Code Playgroud) 我想知道在第一个线程的run方法中中断另一个线程是否违法.如果是,当我在第一个线程的run方法中调用另一个线程的中断方法时,会抛出"InterruptedException"吗?像这样:
public static void main(String[] args) {
Thread thread1 = new Thread(() -> {
while (true) {
}
}, "thread1");
try {
thread1.sleep(10000);
} catch (InterruptedException e) {
System.out.println("Oops! I'm interrupted!");
}
Thread thread2 = new Thread(() -> {
System.out.println("I will interrupt thread1!");
thread1.interrupt();
System.out.println("Thread1 interruption done!");
}, "thread2");
thread1.start();
thread2.start();
}
Run Code Online (Sandbox Code Playgroud)
但我没有留言"哎呀!我被打断了!" 在控制台中.
发生中断时CPU自动保存的状态是什么?以哪个顺序?
我正在开发一个 Arduino 项目,在该项目中我通过 I2C 通信接收消息。我有几个例程,程序在其中花费了大量时间而没有返回。目前,我在发生中断时设置一个中断标志,我基本上在几个地方检查这些函数,如果发生中断,我就返回。我想知道中断函数是否可以调用我的入口点函数。
所以这是我目前的中断功能
void ReceivedI2CMessage(int numBytes)
{
Serial.print(F("Received message = "));
while (Wire.available())
{
messageFromBigArduino = Wire.read();
}
Serial.println(messageFromBigArduino);
I2CInterrupt = true;
}
Run Code Online (Sandbox Code Playgroud)
在程序花费大部分时间的功能中,我不得不在几个地方这样做
if(I2CInterrupt) return;
Run Code Online (Sandbox Code Playgroud)
现在我想知道是否可以从我的 ReceiveI2CMessage 中调用我的入口点函数。我主要担心的是这可能会导致内存泄漏,因为当中断发生时我将正在执行的函数留在后面,然后我将返回到程序的开头。
你能在这里帮我一下,告诉我我做错了什么吗?EXTI1 和 EXTI2 不会触发,而 EXTI4 则正常工作。这不是硬件。如果我切换引脚,新的 EXTI4 按钮将继续触发,而我切换它的按钮不再触发。
我已经彻底检查了所有段,但我无法弄清楚为什么 EXTI0_1_IRQHandler 没有触发,而 EXTI4_15_IRQHandler 没有触发。请参阅下面我用于库的两个文件。我在 OpenSTM32 IDE 中使用 SPL。“main.c”只调用
ENCODER_STM32_configureInterface();
Run Code Online (Sandbox Code Playgroud)
所以真的没有其他事情发生。
// ENCODER_STM32 library: This library shall enable interfacing an encoder on an STM32F0 chip.
// GPIO Definitions
#define ENCODER_GPIO_PORT GPIOA
#define ENCODER_GPIO_CLK_PIN GPIO_Pin_1
#define ENCODER_GPIO_DT_PIN GPIO_Pin_2
#define ENCODER_GPIO_SW_PIN GPIO_Pin_4
#define ENCODER_GPIO_PERIPH RCC_AHBPeriph_GPIOA
// EXTI Definitions
#define ENCODER_EXTI_PORTSRC EXTI_PortSourceGPIOA
#define ENCODER_EXTI_CLK_PINSRC EXTI_PinSource1
#define ENCODER_EXTI_CLK_LINE EXTI_Line1
#define ENCODER_EXTI_DT_PINSRC EXTI_PinSource2
#define ENCODER_EXTI_DT_LINE EXTI_Line2
#define ENCODER_EXTI_SW_PINSRC EXTI_PinSource4
#define ENCODER_EXTI_SW_LINE EXTI_Line4
#define ENCODER_EXTI_PERIPH RCC_APB2Periph_SYSCFG
#define ENCODER_EXTI_MODE …Run Code Online (Sandbox Code Playgroud) 第二个循环如何实际中断休眠的主线程,而第一个没有?我的理解是在Thread.sleep(3000)之后,代码Thread.currentThread().interrupt()会在3秒后执行。谁能解释它实际上是如何工作的
for (int i = 0; i < 2; i++) {
try {
System.out.println("loop : " + i);
Thread.sleep(3000);
System.out.println("Woke up");
Thread.currentThread().interrupt();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
loop : 0
Woke up
loop : 1
java.lang.InterruptedException: sleep interrupted
exception loop:1
at java.base/java.lang.Thread.sleep(Native Method)
at multithreadings.Mainclass.main(Mainclass.java:13)
Run Code Online (Sandbox Code Playgroud) 我想在 NASM 中有一个中断,它调用的不是硬编码中断而是 int。在一个寄存器中。给你一个例子:
mov al, 0x10
int al ; you can't do this for some reason
Run Code Online (Sandbox Code Playgroud)
因此,如果我将 0x10 存储在寄存器 al 中,那么我可以根据该寄存器中的内容调用中断。
有什么办法可以做到这一点吗?
当我的页面错误处理程序中断被调用时(它应该挂起系统),在调用之前有一些变量被推送到堆栈中。我启用了虚拟内存,当我设置一个无效的堆栈指针(esp)并且 int14 处理程序被调用时,它会立即导致另一个页面错误等等。我应该如何解决这种情况?
我的 int14 代码:
isr14:
; interrupt handler for isr14
jmp $
iretd
Run Code Online (Sandbox Code Playgroud)
导致它中断的代码:
mov esp, 0x1000 ; 0x1000 is not mapped in the VM directory
push dword 'A'
jmp $
Run Code Online (Sandbox Code Playgroud)
我的 IDT 表的部分:
irq14:
dw isr14
dw 0x0008
db 0x00
db 10101110b
dw 0x0000
irq15:
........
Run Code Online (Sandbox Code Playgroud) 我试图通过阅读Robert Love 的 Linux Kernel Development来了解 Linux 内核的内部结构。
在第 74 页上,他说将参数传递给 a 的最简单方法syscall是通过:
不知何故,用户空间必须在陷阱期间将参数传递给内核。最简单的方法是通过传递系统调用号的相同方式:参数存储在寄存器中。在 x86-32 上,寄存器 ebx、ecx、edx、esi 和 edi 按顺序包含前五个参数。
现在这让我感到困扰,原因有很多:
asmlinkage选项定义。这意味着参数总是在堆栈上而不是寄存器上找到。那么寄存器的所有这些业务是什么?