I'm doing research on bootloaders. That is, I'm trying to write simple bootloader with Nasm which will run in VB (vdi disk). For now on I did set up a virtualbox environment for testing purposes and successfully load MBR which resides on absolute address (HXD hex editor) 0x2000. But now I want to jump outside MBR (0x2200 big endian) and execute code which resides there (Below snippet doesn't do the job). I use Nasm directive [org 0x7C00], do I have to use this offset when making jumps?
[BITS 16]
[org 0x7C00]
%define location 0x0022
start:
mov al, 0x12
mov ah, 0
int 0x10
jmp location:0000
TIMES 510 - ($ - $$) db 0
DW 0xAA55
This is hex view from vdi (2000h is where MBR starts, 2200h is where I want to jump):
The boot sector will be loaded at address 0x7c00 (which, due to the peculiarities of real mode segments, may be addressed in multiple ways. The two common ones being 0:0x7c00 and 0x7c0:0 - you shouldn't rely on a particular one). The fact that it is at offset 0x2000 in your disk image is probably due to the format of said image, it has no relevance to the memory address. Also, the boot process only loads a single sector of 512 bytes, if you need more you have to load it yourself. Then you can jump to it, using the address that you loaded it to.