Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [bits 16]
  2. [org 0x7c00]
  3. mov bp, 0x8000
  4. mov sp, bp
  5.  
  6. mov bx, rdd
  7. call print
  8. call print_nl
  9.  
  10. mov bx, 0x9000
  11. mov dh, 2
  12.  
  13. call disk_load
  14.  
  15. mov dx, [0x9000]
  16. mov bx, ok
  17. call print
  18. call print_nl
  19. mov bx, nxt
  20. call print
  21. call print_nl
  22.  
  23. call print_hex
  24. call print_nl
  25.  
  26. jmp 0x9000
  27. jmp $
  28.  
  29. disk_load:
  30.     pusha
  31.     push dx
  32.    
  33.     mov ah, 0x02 ;INT 0x13 read mode
  34.     mov al, dh
  35.     mov cl, 0x02 ;Sector
  36.     mov ch, 0x00 ;Cylinder
  37.     mov dh, 0x00 ;Head
  38.    
  39.     int 0x13
  40.     jc disk_error
  41.    
  42.     pop dx
  43.     cmp al, dh
  44.    
  45.     jne sectors_error
  46.     popa
  47.     ret
  48.  
  49. disk_error:
  50.     mov bx, diskerror
  51.     call print
  52.     call print_nl
  53.     jmp $
  54.    
  55. sectors_error:
  56.     mov bx, sectorerror
  57.     call print
  58.     jmp $
  59.    
  60. print:
  61.     pusha
  62.  
  63. start:
  64.     mov al, [bx]
  65.     cmp al, 0
  66.     je done
  67.  
  68.     mov ah, 0x0e
  69.     int 0x10
  70.  
  71.     add bx, 1
  72.     jmp start
  73.  
  74. done:
  75.     popa
  76.     ret
  77.  
  78.  
  79. print_nl:
  80.     pusha
  81.    
  82.     mov ah, 0x0e
  83.     mov al, 0x0a
  84.     int 0x10
  85.     mov al, 0x0d
  86.     int 0x10
  87.    
  88.     popa
  89.     ret
  90.  
  91. print_hex:
  92.     pusha
  93.  
  94.     mov cx, 0
  95.  
  96. hex_loop:
  97.     cmp cx, 4
  98.     je end
  99.    
  100.     mov ax, dx
  101.     and ax, 0x000f
  102.     add al, 0x30
  103.     cmp al, 0x39
  104.     jle step2
  105.     add al, 7
  106.  
  107. step2:
  108.     mov bx, HEX_OUT + 5
  109.     sub bx, cx
  110.     mov [bx], al
  111.     ror dx, 4
  112.  
  113.     add cx, 1
  114.     jmp hex_loop
  115.  
  116. end:
  117.     mov bx, HEX_OUT
  118.     call print
  119.  
  120.     popa
  121.     ret
  122.  
  123. HEX_OUT db '0x0000',0
  124. ok db "[OK] Stage 2 sectors loaded",0
  125. nxt db "[SB] Executing stage 2...",0
  126. rdd db "[SB] Reading disk...",0
  127. diskerror db "[ER] Disk error",0
  128. sectorerror db "[ER] Sector error",0
  129.  
  130. times 510-($-$$) db 0
  131. dw 0xaa55
  132.  
  133. mov al, 0Eh
  134. mov ax, 'A'
  135. int 10h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement