Advertisement
martinmunozdr

Minimum assembly bootloader

Feb 18th, 2014
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. BITS 16
  2. ; Load a program off the disk and jump to it
  3.  
  4. ; Tell the compiler that this is offset 0.
  5. ; It isn't offset 0, but it will be after the jump.
  6. ;to run
  7. ;nasm floppyboatloader.asm -o floppyboatloader.bin
  8. ;dd status=noxfer conv=notrunc if=floppyboatloader.bin of=floppyboatloader.flp
  9. ;qemu-system-i386 -fda floppyboatloader.flp
  10. [ORG 0]
  11.  
  12. jmp start ; Goto segment 07C0
  13.  
  14. start:
  15. ; Update the segment registers
  16.  
  17. mov ax, cs
  18. mov ds, ax
  19. mov es, ax
  20.  
  21. reset: ; Reset the floppy drive
  22. mov ax, 0 ;
  23. mov dl, 0 ; Drive=0 (=A)
  24. int 13h ;
  25.  
  26. jc reset ; ERROR => reset again
  27.  
  28. read:
  29. mov ax, 1000h ; ES:BX = 1000h:0000
  30. mov es, ax ;
  31. mov bx, 0h ;
  32.  
  33. mov ah, 2 ; Load disk data to ES:BX
  34. mov al, 5 ; Load 5 sectors
  35. mov ch, 0 ; Cylinder=0
  36. mov cl, 9 ; Sector=2
  37. mov dh, 0 ; Head=0
  38. mov dl, 0 ; Drive=0
  39. int 13h ; Read!
  40.  
  41. jc read ; ERROR => Try again
  42.  
  43. jmp 1000h:0h ; Jump to the program
  44.  
  45. times 510-($-$$) db 0
  46. dw 0AA55h
  47.  
  48. mov ah, 0Eh
  49. mov al, '='
  50. int 10h
  51.  
  52. mov ah, 0Eh
  53. mov al, '1'
  54. int 10h
  55.  
  56. mov ah, 0Eh
  57. mov al, '2'
  58. int 10h
  59.  
  60. mov ah, 0Eh
  61. mov al, '3'
  62. int 10h
  63.  
  64. mov ah, 0Eh
  65. mov al, '4'
  66. int 10h
  67.  
  68. jmp $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement