You execute a jmp to main right after it, but won't the code be missed, since the BIOS requires the starting code to be at 0x7c00?
Code: Select all
org 0 ; we will set regisers later
start: jmp main ; jump to start of bootloader
Moderator:Moderators
Code: Select all
org 0 ; we will set regisers later
start: jmp main ; jump to start of bootloader
Code: Select all
; read image file into memory (0050:0000)
mov ax, 0x0050
mov es, ax ; destination for image
mov bx, 0x0000 ; destination for image
push bx
Code: Select all
bits 16
; Remember the memory map-- 0x500 through 0x7bff is unused above the BIOS data area.
; We are loaded at 0x500 (0x50:0)
org 0x500
Code: Select all
bits 16
; Remember the memory map-- 0x0050 through 0x7bff is unused above the BIOS data area.
; We are loaded at 0x0050 (0x0050:0)
org 0x0050
Code: Select all
; read image file into memory (0100:0000)
; destination of image CS
mov ax, 0x0100
mov es, ax
; destination for image IP
mov bx, 0x0000
push bx
Code: Select all
[BITS 16]
[ORG 0x0000]
[SEGMENT .text]
; location where kernel is loaded
mov ax, 0x0100
Code: Select all
; read image file into memory (0050:0000)
mov ax, 0x0050
mov es, ax ; destination for image
mov bx, 0x0000 ; destination for image
push bx
Following this formula, 0x50:0 is the same as 0x500.Absolute (Exact) Memory Address = (Segment Address * 16(decimal)) + Offset
Code: Select all
mov ax, 0x0050
mov es, ax ; destination for image
mov bx, 0x0000 ; destination for image
push bx
Code: Select all
mov ax, 0x0100
mov es, ax ; destination for image
mov bx, 0x0000 ; destination for image
push bx
Code: Select all
bits 16
org 0x500
Code: Select all
bits 16
org 0x0000
[SEGMENT .text]
mov ax, 0x0100
Not quite. 0x0050:0 is the same as 0x500 absolute liner address, NOT 0x500:0.So -> 0x0050:0 is the same as 0x500:0
Code: Select all
mov ax, 0x0100
mov es, ax ; destination for image
mov bx, 0x0000 ; destination for image
push bx
Code: Select all
bits 16
org 0x0000
[SEGMENT .text]
mov ax, 0x0100
Not quite. The bootloader is loading (and executing) stage 2 at 0x500 (NOT 0x0050), which is how it worksIm just a little confused by your bootloader calling
stage2.asm into 0x0050 but in stage2.asm it says the address is 0x500
Hm... would you mind elaborating on this for us?if i tried that with the code I already have It finds the secont binary file and then does nothing but crash.
Yes, that would be very helpfulWould you like me to send through my code? maybe it has a potential bug inside it i am not aware of.