T
T
Type Programmer2018-05-01 22:06:04
assembler
Type Programmer, 2018-05-01 22:06:04

The bootloader works in a virtual machine, but not on real hardware, what to do where is the error?

I'm writing for real-time mode (like that's what it's called)
So right away the source:

#make_boot#

org 7c00h 
use16 
jmp start 

e: 
mov ax,cs
mov ds,ax
mov es,ax
ret 


put_pix: 
push ax 
push dx 
mov ax,8000h
mov es, ax 
mov ax,320 
mul cx 
pop dx 
add ax,dx 
mov di,ax 
pop ax 
stosb 
ret 

fill_disp: 
push ax 
mov ax,8000h 
mov ds,ax 
pop ax 
mov ah,al  
mov bx,0000h
mov [bx],ax 
p0: 
add bx,2
mov [bx],ax 
cmp bx,0FFFEh 
jz e 
jmp p0 

e_draw: 
pop dx 
pop bx 
mov [x],dx 
mov [y],bx 
ret 

draw_sprite_nexline: 
inc si 
mov al,00h 
cmp al,[bx+si] 
jz e_draw 
dec si 
add [y],01h 
mov ax,[x_ret] 
mov [x],ax 
inc si 
jmp draw_sprite_1 

draw_sprite: 
mov ax,bx 
mov dx,[x] 
mov bx,[y] 
push bx 
push dx 
mov bx,ax 
mov ax,[x] 
mov [x_ret],ax 
mov si,0000h 
draw_sprite_1: 
mov ax,8000h
mov es, ax 
mov ax,320 
mov cx,[y] 
mul cx 
mov dx,[x] 
add ax,dx 
mov di,ax 
mov al,[bx+si] 
cmp al,255 
jz draw_sprite_2 
stosb 
draw_sprite_2: 
inc si 
mov al,00h 
cmp al,[bx+si] 
jz draw_sprite_nexline 
add [x],1 
jmp draw_sprite_1 

draw_display:
mov di,0000h
mov bx,0000h
mov si,0000h
mov ax,8000h
mov ds,ax         
mov ax,0A000h
mov es,ax
draw_display_1:
cmp bx,0FFFFh
jz draw_display_2 
mov al,[bx]
stosb
inc bx         
jmp draw_display_1
draw_display_2:   
jz e


left_sprite: 
sub [x],01h 
jmp p3 
right_sprite: 
add [x],01h 
jmp p3 

start: 
mov ah, 0 
mov al, 13h 
int 10h 
mov al,40 
;call fill_disp 
mov di,0000h 
mov si,0000h 
mov bx,sprite 
;call draw_sprite 
p4: 
mov ah,01h 
int 16h 
jz p7 
mov ah,00h 
int 16h 
cmp al,'a' 
jz left_sprite 
cmp al,'d' 
jz right_sprite 
p7: 
p3: 
mov di,0000h 
mov si,0000h     
mov al,60
call fill_disp
mov di,0000h 
mov si,0000h    
mov bx,sprite 
call draw_sprite
call draw_display
jmp p4 




x_ret dw 0 
x dw 5
y dw 5 


sprite db 30,30,30,30,30,0,30,30,30,30,30,0,30,30,30,30,30,0,30,30,30,30,30,0,30,30,30,30,30,0,30,30,30,30,30,0,0,0

In fact, it is implemented there, filling the screen, creating sprites, and so that it does not flicker, I created a second buffer through which it is already displayed on the screen, And oh yes, this miracle works in a virtual machine, I was able to write a piece of code myself and I thought all the things .. without emulation in the hardware, and then a black screen began, then a bunch of different pixels, as if I climbed onto some piece of code being used .. And I don’t really understand where to find memory for the second video buffer, I thought that it didn’t exist, but they answered me .
320x200 is 64KB, not 64MB as you posted above.
if you are using real mode and 1 MB is available to you, there is no need to write about 64 MB.
half of 1 MB is about 500 KB. 7-8 64 KB video buffers will fit here.

I have already changed the location of the buffer a couple of times and nothing works. Tell me what and how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
forspamonly2, 2018-05-03
@forspamonly2

Without calling into question the expediency of the training itself (some people have even more useless hobbies), I cannot but note the stupidity of the methodology.
learning assembler itself, learning how to write a bootloader and learning how to draw graphics are three different things. why do you complicate everything for yourself, mixing everything together and trying to understand at once?
The boot sector should not draw anything at all, its task is to load and initialize the main bootloader and transfer control to it.
writing on ASMA in real mode (addressing, not time) is easiest by collecting dos com files, running them in a virtual dos machine of some old Windows (like winXP), and debugging with some kind of dos debugger (like a turbo debugger ). go through your code step by step and immediately understand what is wrong.
if both the ignorance of the architecture (such as that question about memory) and the ignorance of the assembler cause difficulties at the same time, then you can first deal with memory allocation and the basic techniques for working with graphics (such as the same double buffering), in a slightly higher-level language, like C, not using the standard library. having a formed idea of ​​\u200b\u200bwhat needs to be done, it will be much easier to rewrite it in assembler. Moreover, this can be done in parts - individual functions can be replaced with assembler inserts, which will make it possible to compare the results of the work of small sections of sish and asm code.
then, when you write your graphic piece, you will separately make the simplest loader for it, and you will be happy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question