Guest User

Untitled

a guest
May 20th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. org 0x7c00
  2. use16
  3.  
  4. jmp 0x07c0:start
  5.  
  6.  
  7.  
  8. bpbOEM db "VolTeK01"
  9. bpbBytesPerSector dw 512
  10. bpbSectorsPerCluster db 1
  11. bpbReservedSectors dw 1
  12. bpbNumberOfFATs db 2
  13. bpbRootEntries dw 224
  14. bpbTotalSectors dw 2880
  15. bpbMedia db 0xf0
  16. bpbSectorsPerFAT dw 9
  17. bpbSectorsPerTrack dw 18
  18. bpbHeadsPerCylinder dw 2
  19. bpbHiddenSectors dd 0
  20. bpbTotalSectorsBig dd 0
  21. bsDriveNumber db 0
  22. bsUnused db 0
  23. bsExtBootSignature db 0x29
  24. bsSerialNumber dd 0xa0a1a2a3
  25. bsVolumeLabel db "VolTeKOSDSK"
  26. bsFileSystem db "FAT12 "
  27.  
  28.  
  29.  
  30. ;cx, contains loop or how many sectors to load
  31. ;bx, contains what address to load it too
  32. ;ax, contains lba
  33.  
  34. LBA db 0x0000
  35. Sector db 0x00
  36. Track db 0x00
  37. Head db 0x00
  38.  
  39. ReadSectors:
  40. mov WORD [LBA], ax
  41. push dx ;we will be using this for its remainder
  42.  
  43. .sectorReadLoop:
  44. dec cx ;take away one loop to do this one
  45. push cx ;keep it in memory
  46. xor cx,cx
  47. ;Get Track Number
  48. mov al, byte [bpbSectorsPerTrack]
  49. mov cl, byte [bpbHeadsPerCylinder]
  50. mul cl
  51. mov cl,al ;store multiplication in cl
  52. mov ax, word [LBA]
  53. div cl
  54. mov byte [Track],al
  55. ;;===============
  56. pop cx
  57. cmp cx, 0
  58. je .endReadSectors
  59.  
  60. inc bx
  61. inc [LBA]
  62. jmp .sectorReadLoop
  63.  
  64. .endReadSectors:
  65. pop dx
  66. ret
  67. ;;=================================
  68. ;;=================================
  69. ;;=================================
  70.  
  71. print:
  72. lodsb
  73. cmp al, 0
  74. je done
  75. mov ah, 0xe
  76. int 10h
  77. jmp print
  78. done:
  79. ret
  80.  
  81. ;;=================================
  82. ;;=================================
  83. ;;=================================
  84. WordBuffer: times 6 db 0
  85. base dw 0x000a
  86.  
  87.  
  88. ProcedureEntry:
  89. mov cx, 0
  90. mov bx, WordBuffer+5
  91. loopProcedure:
  92.  
  93.  
  94. cmp ax, 0
  95. je endProcedure
  96.  
  97. jmp DoDivide ;;
  98.  
  99. ;cmp ax, [base] ;;check if already 10
  100. ;jge DoDivide
  101.  
  102.  
  103. ;mov dx, ax ;;process as remainder
  104. ;Getting here, means no division was done, which means there will
  105. ;be no remainder, ax equaled something smaller than 10
  106. ;put as remainder and process it.
  107. ;mov ax,0 ;;end loop
  108.  
  109. ProcessRemainder: ;;put remainder into ASCII and put into buffer
  110. ;;we are working backwards, remainder is small number first, or first
  111. ;;place value.
  112. inc cx
  113.  
  114.  
  115.  
  116. ;procesforzero
  117. dec bx
  118. add dl, '0'
  119. mov byte [bx], dl
  120. jmp loopProcedure
  121.  
  122.  
  123.  
  124. DoDivide:
  125. cwd
  126. xor dx, dx
  127.  
  128. div WORD [base]
  129. jmp ProcessRemainder
  130.  
  131. endWithError:
  132. mov ah, 0xe
  133. mov al, 'E'
  134. int 10h
  135.  
  136. endProcedure:
  137. mov bx, WordBuffer+5
  138. mov byte [bx], 0 ;;null out with 0
  139. sub bx, cx ;;if we return from an error, or 0 letters, prints only NULL
  140. ret
  141.  
  142.  
  143. ;;=================================
  144. ;;=================================
  145. ;;=================================
  146.  
  147.  
  148.  
  149.  
  150. start:
  151. mov ax,0
  152. mov es,ax
  153. mov sp,ax
  154. mov ax,0x07c0
  155. mov ds, ax
  156. mov ss, ax
  157.  
  158. mov ax, 19
  159. mov bx, 0x500
  160. mov cx, 1
  161. call ReadSectors
  162.  
  163.  
  164. mov ah, 0
  165. mov al, [Track]
  166. call ProcedureEntry
  167.  
  168. mov si, bx
  169. call print
  170.  
  171. mov ah, 0
  172. int 0x16
  173. cli
  174. hlt
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. times 510 - ($-$$) db 0
  183.  
  184. sig dw 0xAA55
Add Comment
Please, Sign In to add comment