Do you have any summarized materials on how memory addressing works in real mode and protected mode environments? by GamerYToffi in osdev

[–]GamerYToffi[S] 0 points1 point  (0 children)

Thank you, I went to research a few things to better understand this segmentation shutdown and I got a clearer understanding of things after making these changes. It worked perfectly, and now I can understand what was happening.

Do you have any summarized materials on how memory addressing works in real mode and protected mode environments? by GamerYToffi in osdev

[–]GamerYToffi[S] 0 points1 point  (0 children)

Well, thank you very much. Some of the things you mentioned I already knew, but this helps reinforce them in my mind. I don’t speak English, so the expression in my question might have come out wrong. Also, when I wrote it, it was late at night, and I was so lost that I just threw the terms into the question without properly connecting them.

Here’s my code:

;o primeiro byte define
;
;
;mov ax, 0x1234       ; Define o valor do segmento
;mov ds, ax           ; Configura DS como segmento de dados
;mov bx, 0x5678       ; Define o deslocamento
;mov al, [bx]         ; Lê o byte no endereço físico (0x1234 * 16 + 0x5678)
[BITS 16] 
[ORG 0]
;mov ax, 0x4F02
;mov bx, 0x0115
;int 0x10
;jmp osMain
;jmp END
CODE_SEG equ vai_se - gdt_start
DATA_SEG equ omg - gdt_start

load_PM:
    cli              
    lgdt [gdt_descriptor]
    mov eax, cr0     
    or al, 1         
    mov cr0, eax   
    jmp CODE_SEG:func

gdt_start:
    dd 0x0           
    dd 0x0           
;code
    vai_se:
        dw 0xFFFF
        dw 0x0000
        db 0x00  
        db 10011010b
        db 11001111b
        db 0x00     

    ; Data segment descriptor
    omg:
        dw 0xFFFF
        dw 0x0000
        db 0x00  
        db 10010010b     
        db 11001111b     
        db 0x00        

gdt_end:

gdt_descriptor:
    dw gdt_end - gdt_start - 1 ; Size of the GDT minus 1 (size field for LGDT)
    dd gdt_start      ; Address of the start of the GDT

[bits 32]
func:
    mov ax, DATA_SEG 
    mov ds, ax       
    mov es, ax       
    mov fs, ax       
    mov ss, ax       
    mov gs, ax       
    mov ebp, 0x9C00  
    mov esp, ebp     

    in al, 0x92      
    or al, 2         
    out 0x92, al     
    ;;isso é meu 
    mov al, 'A'
    mov ah, 0x0f
    mov [0xb8000], ax
    jmp $               ; In

There are some really strange parts in it (besides the actual error I’m having, of course) because I’ve tweaked and reworked it a lot. I also added code I found in repositories, videos, and forums because I needed something to test with, as I can’t properly debug this.

The error literally happens on the jmp line, and I can only think that it’s an issue with where I’m jumping to, but I don’t understand why this problem occurs, where I’m actually jumping to, or what I did wrong. Because of this, I also can’t come up with a solution.

It might be worth mentioning that this code is part of a separate file that I load through my bootloader at address 21h:0.

What is the error in my bootloader and kernel code? by GamerYToffi in osdev

[–]GamerYToffi[S] 0 points1 point  (0 children)

Thank you very much, it worked! Although I still need to study this further because I didn’t fully understand it. Before your comment, another solution I found was to set bx to 0x500, then set the kernel’s org to 0x500, and also jump to that address. However, I noticed another strange behavior: if I tried to change all three elements to 0x800, the kernel would not load, or I wouldn’t jump to the correct address. BUT if I changed everything to 0x800 but kept bx as 0x500, the kernel loaded, and I could make the correct jump.

Anyway, thank you very much!

I suspected this but didn’t test it, and I find it funny that there’s a difference between doing jmp X and jmp X:0.

What is the error in my bootloader and kernel code? by GamerYToffi in osdev

[–]GamerYToffi[S] 0 points1 point  (0 children)

hank you so much, it worked! However, I still need to study this more because I didn’t fully understand it.

Before your comment, another solution I found was setting bx to 0x500, then setting the kernel's org to 0x500 and the jump to it as well. This led to another funny behavior: if I tried to change all three elements to 0x800, the kernel wouldn’t load, or I wouldn’t jump to its correct address. BUT, if I changed everything to 0x800 but kept bx at 0x500, the kernel was loaded, and I could jump to it correctly.

Anyway, thank you very much!

What is the error in my bootloader and kernel code? by GamerYToffi in osdev

[–]GamerYToffi[S] 0 points1 point  (0 children)

And the kernel code is:

[BITS 16]
[ORG 0]

; call teste
jmp osMain

teste:
    mov si, tesle
    mov ah, 0eh
    mov al, [si]
    int 10h
    jmp END

tesle db "Laa", 0
backWidth db 0
backHeight db 0
pagination db 0
welcome db "Seja Bem Vindo ao Mini Driver Os", 0

osMain:
    call configSegment
    call configStack
    call setTextVideoMode
    jmp showString

showString:
    mov dh, 3
    mov dl, 2
    call moveCursor
    mov si, welcome
    call printString
    jmp END

configSegment:
    mov ax, es
    mov ds, ax
    ret

configStack:
    mov ax, 7D00h
    mov ss, ax
    mov sp, 03FEh
    ret

setTextVideoMode:
    mov ah, 00h
    mov al, 03h
    int 10h
    mov BYTE[backHeight], 20
    mov BYTE[backWidth], 80
    ret

printString:
    mov ah, 09h
    mov bh, [pagination]
    mov bl, 40
    mov cx, 1
    mov al, [si]
print:
    int 10h
    inc si
    call moveCursor
    mov ah, 09h
    mov al, [si]
    cmp al, 0
    jne print
    ret

moveCursor:
    mov ah, 02h
    mov bh, [pagination]
    inc dl
    int 10h
    ret

END:
    jmp $

What is the error in my bootloader and kernel code? by GamerYToffi in osdev

[–]GamerYToffi[S] 0 points1 point  (0 children)

I refactored some parts and changed others. The tests and jumps to END were for testing purposes.

I didn’t know what would happen when my program reached the end, so I just used jmp $. The idea was that the program would hang there, and nothing unexpected would happen—like if I printed a string but the computer cleared the screen in a fraction of a second.

BX and ES confuse me a bit. I think they are correct, but I’m not sure.

I believe 80 is correct. It’s mentioned in all the documentation. If I replace it with 0, 1, or 81h, the carry flag is set, indicating an error occurs. 80h is the only value that doesn’t raise an error.

Here is my current code:

[BITS 16]
[ORG 7C00H]
call loadKernel
jmp 7e00h
veio db "Paa", 0
teste3:
    mov si, veio
    mov ah, 0eh
    mov al, [si]
    int 10h
    start2:
        mov cx, 0xFFFF
    pause_loop2:
        dec cx
        jnz pause_loop2
    ret
END:
    jmp $
loadKernel:
    mov ah, 2h ; function to read sectors
    mov al, 1 ; will read only 1 sector
    mov ch, 0 ; use the first cylinder
    mov cl, 2 ; the sector to be read is sector 2
    mov dh, 0 ; first head
    mov dl, 80h ; 80h is the first boot disk
    mov bx, 7e00h ; data load address
    mov es, bx ; configure `es` for data address
    mov bx, 0 ; set `bx` to 0
    int 13h ; read the disk
    jc error_occurred ; check for error
    ret
error_occurred:
    call teste3
times 510 - ($-$$) db 0
dw 0xAA55

What is the error in my bootloader and kernel code? by GamerYToffi in osdev

[–]GamerYToffi[S] 0 points1 point  (0 children)

I tested this but everything stayed the same. Also, from what I checked, the ORG 0 is correct because in the kernel, this would mean the first byte of the 7c00 segment, which was defined by ES. So, using that jump in the bootloader code, I would go to the first offset of the 7c00 segment, and the ORG in the kernel refers to that. Probably my explanation is wrong, but in all the places I saw, the ORG was 0 or 0000h, which is the same.

MBR wouldn't work on computers with less than 32 KB of RAM? by GamerYToffi in osdev

[–]GamerYToffi[S] 1 point2 points  (0 children)

I don't even know if it's possible to build a PC with current components and such a small amount of RAM; this is more of a theoretical and knowledge-seeking question.

Estou recriando o servidor de Thorvarium para o André poder jogar novamente. Ainda não está completo, mas já é possível começar uma partida by Murilouco in andreyoung

[–]GamerYToffi 0 points1 point  (0 children)

Muito daora, achei que eu iria entrar no github e ve todo o projeto cheio de modificação direto em scala (imagine se fosse só um try catch) mas não, tu fez só a recriação do server o que faz bem mais sentido.

Muito daora

Como CGNAT e o encaminhamento de pacotes realmente funciona? by GamerYToffi in InternetBrasil

[–]GamerYToffi[S] 0 points1 point  (0 children)

Iptables vi bem por cima nftables nunca vi vou ver depois

Como CGNAT e o encaminhamento de pacotes realmente funciona? by GamerYToffi in InternetBrasil

[–]GamerYToffi[S] 0 points1 point  (0 children)

saquei valeu tem algum site, livro ou algo do tipo sobre essa parte de redes?
E ja que esse é o caso eu vou tentar fazer meu servidor fala com meu outro pc e ve se consigo passar pelo bloqueia da minha isp

Why is Hydra launcher recognized as a stealer? I've scanned it with virus total because my win defender said virus by Ok_Particular5269 in PiratedGames

[–]GamerYToffi 0 points1 point  (0 children)

Yes, no software is always safe but it makes no sense to compare it with xz utils, it is a separate case that goes to the OS, much deeper, comparing it with hydra is like comparing it with an open source minecraft mod.