title: Bootloader not jumping to kernel, Assembly
body: <p>I'm learning about operating systems from the book, Operating Systems from 0 to 1. I'm trying to use the code in chapter 7 where they build a small bootloader and another small program called sample, where they get the bootloader to jump to the code in sample. In the text they want me to use gdb to put a breakpoint at 0x500 to check if the next assembly code is from sample.asm However when i put a breakpoint in gdb at 0x500, GDB outputs after running the program upto the breakpoint</p>
  <pre><code>Program received signal SIGTRAP, Trace/breakpoint trap.
  0x0000000000000000 in ?? ()
  </code></pre>
  <p>Also layout asm says, &quot;no assembly available&quot;</p>
  <p>I also checked the cf flag after int 0x13 which is 0 which claims there is no error in reading the sector.</p>
  <p>My problem is did I jump to the wrong address or is there a different issue with my code?</p>
  <p>bootloader.asm ;</p>
  <pre><code>;*************************************************
  ; bootloader.asm 
  ; A Simple Bootloader
  ;*************************************************
  org 0x7c00
  bits 16
  start: jmp  boot
  
  ;; constants and variable definitions
  msg db &quot;Welcome to My Operating System!&quot;, 0ah, 0dh, 0h
  
  boot:
  
      cli ; no interrupts 
      cld ; all that we need to init
      
      mov ax, 0x50
  
      ;; set buffer
      mov es, ax  
      xor bx, bx  
  
      mov al, 1   ; read one sector
      mov ch, 0   ; track 0
      mov cl, 2   ; sector to read
      mov dh, 0   ; head number
      mov dl, 0   ; drive number
          
      mov ah, 0x02    ; read sectors from disk    
      int 0x13      ; call the BIOS routine
      jmp 0x50:0x0    ; jump and execute the sector!
      
      hlt ; halt the system 
  
  ; We have to be 512 bytes. Clear the rest of the bytes with 0
  
  times 510 - ($-$$) db 0
  dw 0xAA55 ; Boot Signature
      
  </code></pre>
  <p>sample.asm</p>
  <pre><code>; ******************************************
  ; sample.asm
  ; A Sample Program
  ; ******************************************
  mov eax, 1
  add eax, 1
  </code></pre>
  <p>I wrote the bootloader then sample to an img file on linux,</p>
  <pre><code>nasm -f bin bootloader.asm -o bootloader
  dd if=/dev/zero of=disk.img bs=512 count=2880
  dd if=bootloader of=disk.img conv=notrunc
  dd if=sample of=disk.img bs=512 seek=1 conv=notrunc
  </code></pre>
  <p>then used QEMU</p>
  <pre><code>qemu-system-x86_64 -machine q35 -fda disk.img -gdb tcp::26000 -S
  </code></pre>
  <p>then connected to it using gdb;</p>
  <pre><code>set architecture i386:x86-64
  target remote localhost:26000
  b *0x500
  c
  </code></pre>