gpt4 book ai didi

ubuntu - 无法在 Ubuntu 上运行 qemu,即使是一个简单的 guest

转载 作者:太空宇宙 更新时间:2023-11-03 16:56:09 25 4
gpt4 key购买 nike

我有一个简单的任务 - 运行此代码“boothi.asm”:

use16 
org 0x7C00

xor ax, ax
mov es, ax
mov ds, ax
mov ss, ax
mov sp, 0x1000

mov ax, 3
int 10h

mov si, mHello
call print

die: jmp short die

mHello db 'Hello, world - i was booted!',10,13,0


print:
cld
pusha
.PrintChar:
lodsb
test al, al
jz short .Exit
mov ah, 0eh
mov bl, 7
int 10h
jmp short .PrintChar
.Exit:
popa
ret

我已经用它编译了:

nasm -f bin boothi.asm -o boothi.bin

但我不明白 - 如何在虚拟机上运行它进行测试。我尝试创建软盘镜像并像这样使用 qemu 运行它:

dd if=/dev/zero of=disk.img bs=1024 count=1440
dd if=boothi.bin of=disk.img conv=notrunc

但在下一步——

qemu -fda disk.img -boot a

我有奇怪的麻烦-

Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory

我尝试安装 qemu 和 kvm。但是这个错误是在。但是 qemu 尝试运行这段代码并检查所有设备 - hard\cdrom\floppy - 并写下类似“没有要加载\引导的系统”之类的东西。我如何在 Ubuntu 上测试这个 asm 代码?


我电脑上的命令输出:

root@alena-VirtualBox:~# ls -l /dev/kvm
ls: cannot access /dev/kvm: No such file or directory
root@alena-VirtualBox:~# lsmod|grep kvm
kvm 359488 0
root@alena-VirtualBox:~# groups
root
root@alena-VirtualBox:~# qemu -version
No command 'qemu' found, did you mean:
Command 'qtemu' from package 'qtemu' (universe)
Command 'aqemu' from package 'aqemu' (universe)
qemu: command not found
root@alena-VirtualBox:~# qemu-system-i386 -version
QEMU emulator version 1.0 (qemu-kvm-1.0), Copyright (c) 2003-2008 Fabrice Bellard
root@alena-VirtualBox:~# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
stepping : 7
microcode : 0x616
cpu MHz : 2469.580
cache size : 6144 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc up pni monitor ssse3 lahf_lm
bogomips : 4939.16
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

最佳答案

查看您的汇编程序,您需要在引导扇区的末尾添加引导签名 - 0xaa55 - 参见 http://www.nondot.org/sabre/os/files/Booting/nasmBoot.txt

我添加了以下两行,然后您的示例就起作用了:

times 510-($-$$) db 0   ; Fill the file with 0's
dw 0AA55h ; End the file with AA55

关于ubuntu - 无法在 Ubuntu 上运行 qemu,即使是一个简单的 guest ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22643312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com