Guest User

pi.asm

a guest
Dec 3rd, 2014
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. bits 16
  2. org 0
  3.  
  4. start:
  5. jmp short entry
  6. nop
  7. dw 'PI_10 ' ; disk name
  8. dw 512 ; sector size
  9. db 16 ; sectors per cluster
  10. dw 1 ; reserved sectors
  11. db 2 ; number of FAT copies
  12. dw 512 ; root entries
  13. dw 80*2*18 ; total # of sectors
  14. db 240 ; media type
  15. dw 1 ; sectors per FAT
  16. dw 18 ; sectors per track
  17. dw 2 ; number of heads
  18. times 4 dw 0
  19. db 0, 0 ; drive number, current head
  20. db 0x29 ; signature
  21. db 0xfd, 0x1a, 0xbe, 0xfa ; id
  22. db 'PI_10 ' ; volume label
  23. db 'FAT12 ' ; type
  24.  
  25. entry:
  26. ; prepare .com-like environment
  27. cld
  28. xor ax, ax ; clear ax and dx
  29. cwd
  30. mov si, 0x100 ; initialize other registers
  31. mov cx, 0xff
  32. mov bp, 0x900
  33. mov di, 0xfffe
  34. xor sp, sp
  35. jmp 0x7c0:0x100 - 5
  36. times start + 0x100 - 5 - $ nop
  37.  
  38. push ax
  39. push cs ; cs=ds=es=ss for DOS---es not needed really
  40. pop ds
  41. push cs
  42. pop ss
  43.  
  44. ; here at 0x100 - based on pi_10.com
  45. dw 5000
  46. mov ch,0x7f
  47. mov es,cx ; es = 0x7fff
  48. inc ax
  49. mov bx,9860
  50. rep stosw
  51. .loop1:
  52. mov cx,es ; cx = 0x7fff
  53. .loop2:
  54. imul bp,cx,byte +0x2
  55. inc bp
  56. div bp
  57. xchg ax,dx
  58. stosw
  59. xchg ax,dx
  60. mul cx
  61. push dx ; dx:ax += 10 * [es:di]
  62. xchg ax,bp
  63. mov ax,10
  64. mul word [es:di]
  65. add ax,bp
  66. pop bp
  67. adc dx,bp
  68. loop .loop2
  69. div word [si]
  70. add al,0x30
  71. xchg ax,dx
  72. stosw
  73. call prch
  74. dec bx
  75. jnz .loop1
  76. cli
  77. hlt
  78.  
  79. prch:
  80. pusha
  81. xchg ax,dx
  82. mov ah, 14
  83. mov bh, 0
  84. int 10h
  85. popa
  86. ret
  87.  
  88. times start + 0x1fe - $ db 0
  89. db 0x55, 0xaa
Advertisement
Add Comment
Please, Sign In to add comment