opsftw

ASM Boot Loader

Aug 17th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BITS 16
  2. org 0x7c00
  3.  
  4. _bitSetup:
  5.         xor ax, ax
  6.         mov ah, 0x00
  7.         mov al, 0x03
  8.         int 0x10
  9. _startBoot:
  10.         mov si, IntroString
  11.         call _printString
  12.         mov si, LoadingMessage
  13.         call _printString
  14.         call _LaunchProgram
  15.         jmp $
  16.        
  17. _LaunchProgram:
  18. .readAttempt:
  19.         mov si, ReadingDisk
  20.         call _printString
  21.  
  22.         mov bx, 0x8000
  23.         mov es, bx
  24.         mov bx, 0x0000
  25.        
  26.         mov ah, 0x02    ;Read func
  27.         mov al, 0x03    ;Sectors
  28.         mov ch, 0x00    ;Cylinder
  29.         mov cl, 0x02    ;Sector
  30.         mov dh, 0x00    ;Head
  31.         mov dl, 0x00    ;Drive
  32.         int 0x13
  33.         jc .readAttempt ;Jump back if error.
  34.         jmp 0x8000:0x0000
  35.         ret
  36.  
  37. _printString:
  38.         mov ah, 0x0e
  39.         xor bl, bl
  40. .loop:
  41.         lodsb
  42.         test al, al
  43.         jz .done
  44.         int 0x10
  45.         jmp .loop
  46. .done:
  47.         ret
  48.  
  49.         IntroString db "Axolotl's Memory Loader", 0x0d, 0x0a, 0
  50.         LoadingMessage db "Will attempt to load image to memory address 0x8000", 0x0d, 0x0a, 0
  51.         ReadingDisk db "Disk read attempt...", 0x0d, 0x0a, 0
  52.         ReadFailed db "Disk read failure", 0x0d, 0x0a, 0
  53.         DiskWarn db "Disk failure warning. Disk may be near or at end of life. Operation aborted.", 0x0d, 0x0a, 0
  54.         DiskLoaded db "Disk read success. Now launching stored program.", 0x0d, 0x0a, 0
  55.  
  56.         times 510-($-$$) db 0x00
  57.         dw 0xAA55
Add Comment
Please, Sign In to add comment