我想在汇编中打印0到9的多个数字表.所以我编写下面的代码:
data_seg segment
I DB 0D
J DB 0D
R DB ?
DIVER DB 10D
data_seg ends
stack_seg segment
stack_seg ends
code_seg segment
MAIN proc far
assume cs:code_seg, ds:data_seg, ss:stack_seg
MOV AX,data_seg
MOV DS,AX
FOR1:
MOV J,0D
FOR2:
MOV AX,0H
MOV AL,I
MUL J
DIV DIVER
MOV R,AH
ADD AL,48D
MOV AH,0EH
INT 10H
MOV AL,R
ADD AX,48D
MOV AH,0EH
INT 10H
MOV AX,32D
MOV AH,0EH
INT 10H
INC J
MOV AX,0
MOV AL,J
SUB AX,10D
JNZ FOR2
INC I …Run Code Online (Sandbox Code Playgroud) 假设x是一个寄存器,其值不知道.我必须让x=2a+3b地方a和b有未知值.
我可以用8086个汇编指令mov,add,sub,neg只.mul不允许使用该指令,并且仅限4条指令.
它甚至可能吗?
我正在阅读这篇关于操作系统编程的精彩剧本
http://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf
在第 12 页上有一个简单的引导加载程序。
如果我理解正确,显示的代码是您必须在 NASM 中编写的代码才能让 BIOS 打印出字符。
我不明白的是:
它说
we need interrupt 0x10 and to set ah to 0x0e (to indicate tele-type mode)
and al to the ASCII code of the character we wish to print.
Run Code Online (Sandbox Code Playgroud)
但第一条指令是:
mov ah , 0x0e ;int 10/ ah = 0eh -> scrolling teletype BIOS routine
Run Code Online (Sandbox Code Playgroud)
我不明白该行的评论。为什么第一行代码没有说:
mov ah, 0xeh
int 0x10
Run Code Online (Sandbox Code Playgroud)
如果那是你需要做的?
感谢帮助!
集会:
[BITS 16]
global _start
_start:
mov ax, 0x07C0
mov ds, ax
mov si, hw
call print_string
jmp $
print_string:
mov ah, 0x0E
.char:
lodsb
cmp al, 0
je .exit
int 0x10
jmp .char
.exit: ret
times 0x100-($-$$) db 0
hw: db "Hello, World!", 0
times 510-($-$$) db 0
dw 0xAA55
Run Code Online (Sandbox Code Playgroud)
组装这个:
$ nasm file.asm -felf -o file.o
Run Code Online (Sandbox Code Playgroud)
然后将其与:
$ ld -melf_i386 -o file.bin file.o --oformat binary
Run Code Online (Sandbox Code Playgroud)
给出以下错误:
file.asm:(.text+0x6): relocation truncated to fit: R_386_16 against `.text'
Run Code Online (Sandbox Code Playgroud)
在稍微摆弄代码后,我发现更改mov si, hw …
我正在学习汇编语言.我写了一个简单的bootloader.测试后,它没有用.这是我的代码:
[bits 16]
[org 0x7c00]
jmp start
data:
wolf_wel_msg db 'Welcome to Bootloader!!!',0x0D,0x0A,0
wolf_kernel_load db 'Loading kernel....',0x0D,0x0A,0
wolf_error_msg db 'Kernel.bin not found!',0x0D,0x0A,0
wolf_error_msg1 db 'Press any key to restart..',0
start:
mov si, wolf_wel_msg
call wolf_print
mov si, wolf_kernel_load
call wolf_print
pushf
stc
mov ah,00
mov dl,00
int 13h
read_sector:
mov ax, 0x0
mov es, ax
xor bx, bx
mov ah, 02
mov al, 01
mov ch, 01
mov cl, 02
mov dh, 00
mov dl, 00
int 13h
jc wolf_error …Run Code Online (Sandbox Code Playgroud) 我正在用汇编编写引导加载程序,它似乎在 qemu、bochs 和 virtualbox 上运行良好。但是,它并没有在真实硬件上加载内核(似乎)。
引导加载程序首先将一个字符写入视频内存(用于调试),然后从驱动器读取扇区 2 并远跳转到内核。然后内核将一些字符写入视频内存。
在真机上,我在屏幕上看到引导加载程序中的字符,它挂在那里(闪烁的插入符号)。
我已经尝试将 DS、ES、SI 设置为零,并且我也在设置堆栈段。
我正在使用 bios int 13 function 2 从驱动器读取扇区 2。我有点怀疑它与驱动器编号有关。我都尝试使用在启动时(在 dl 中)传递给引导加载程序的驱动器号,并将其手动设置为 0x0、0x80 和 0x81。
我注意到的一件奇怪的事情是,我用来接近跳转的标签神奇地获得了正确的地址。使用 objdump 我看到例如:jmp 0x2,而使用 gdb 和 qemu,它说:jmp 0x7c02。CS 和所有其他段寄存器为零。无论我在链接中使用 -Ttext 0x0 还是 -Ttext 0x7c00,引导加载程序在所有模拟器上都能正常工作。当我与 -Ttext 0x7c00 链接时,objdump 说 jmp 0x7c02。
编辑,引导加载程序如下所示:
.code16
.text
movw $0xb800, %ax
movw %ax, %ds
movw $0x0741, (0x0)
xorw %ax, %ax
movw %ax, %ds
movw %ax, %si
movw %ax, %es
movw $0x8000, %ax
movw %ax, %ss
movw $0, %sp
movb $2, …Run Code Online (Sandbox Code Playgroud) 我已经在程序集8086中创建了“愤怒的小鸟”游戏。我现在的主要问题是我想在主循环运行时播放游戏的歌曲。我已经写了音乐代码。我考虑过使用多线程,但发现用于创建线程的程序集中断仅适用于cmd,不适用于DOSBox。
但是,我发现执行多线程的另一种方法是从C ++ Windows.h文件调用一个创建线程的命令。那太复杂了。
现在,我设法使用中断14h通过LAN端口发送消息,从而在两个不同的DOSBox窗口之间进行通信。基本上,我已经为音乐编写了单独的代码。这两个代码都运行,并且只有当音乐代码获得符号时,它才开始播放音乐。
但是,我发现打开两个DOSBox窗口时,只有主要的声音起作用。您必须切换窗口才能收听音乐,这意味着您听不到声音。
有没有人知道如何解决这个问题,或者在主循环运行时播放音乐?
谢谢
我在 DosBox 0.74 上用 TASM 3.0 编写,我正在尝试在模式 x(调整 13h,未链接模式 13)中编写,但在这里您可以在图像中看到,它不太正确。似乎平面 1(第二个平面)根本没有打印,所有其他平面的顺序都不正确。我知道这里的代码效率低下,但我想让它工作然后清理它。
proc showBMP
push cx
mov ax, 0A000h
mov es, ax
mov cx, [BMPHeight]
mov ax, [BMPWidth]
xor dx, dx
mov si, 4
div si
mov bp, dx
mov dx, [BMPX]
showBMP_nextLine:
call VGAPlaneStartBMP
push cx
push dx
mov di, cx
add di, [BMPY]
mov cx, di
shl cx, 6
shl di, 8
add di, cx
add di, dx
mov ah, 3fh
mov cx, [BMPWidth]
add …Run Code Online (Sandbox Code Playgroud) 1我在 DosBox 0.74 上用 TASM 3.0 写,我想用模式 x(调整 13h,非链接模式 13)写,我遇到了一个问题,你如何在图像中看到,每一行都被打印出来,但是在每行,每组四个像素只打印第一个像素的颜色,这是在VRAM中的不同空间打印图像进行双缓冲后,因此所有四个平面都有第一个平面的数据。
这是图像的打印方式(这是没有双缓冲区的直接打印,是的,计时器有问题,但没关系)

这是使用双缓冲打印图像的方式
我确实认为问题在于模式x时VGA端口中的数据与读写不同,这里是选择VGA平面的代码
proc VGAPlaneSelect
push ax
push dx
push cx
mov al, 02h
mov dx, 03C4h
out dx, al
VGAPlaneSelect_start:
mov ax, 1
mov cl, [VGAPlane]
shl ax, cl
cmp [VGAPlane], 4
jne VGAPlaneSelect_end
mov [VGAPlane], 0
jmp VGAPlaneSelect_start
VGAPlaneSelect_end:
mov dx, 03C5h
out dx, al
pop cx
pop dx
pop ax
ret
endp VGAPlaneSelect
Run Code Online (Sandbox Code Playgroud)
如果输出不是问题,这里是内存传输的代码:
proc DoubleBuffer
mov ax, 0A000h
mov es, ax …Run Code Online (Sandbox Code Playgroud)