Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 0x7c00
- use16
- jmp 0x07c0:start
- bpbOEM db "VolTeK01"
- bpbBytesPerSector dw 512
- bpbSectorsPerCluster db 1
- bpbReservedSectors dw 1
- bpbNumberOfFATs db 2
- bpbRootEntries dw 224
- bpbTotalSectors dw 2880
- bpbMedia db 0xf0
- bpbSectorsPerFAT dw 9
- bpbSectorsPerTrack dw 18
- bpbHeadsPerCylinder dw 2
- bpbHiddenSectors dd 0
- bpbTotalSectorsBig dd 0
- bsDriveNumber db 0
- bsUnused db 0
- bsExtBootSignature db 0x29
- bsSerialNumber dd 0xa0a1a2a3
- bsVolumeLabel db "VolTeKOSDSK"
- bsFileSystem db "FAT12 "
- ;cx, contains loop or how many sectors to load
- ;bx, contains what address to load it too
- ;ax, contains lba
- LBA db 0x0000
- Sector db 0x00
- Track db 0x00
- Head db 0x00
- ReadSectors:
- mov WORD [LBA], ax
- push dx ;we will be using this for its remainder
- .sectorReadLoop:
- dec cx ;take away one loop to do this one
- push cx ;keep it in memory
- xor cx,cx
- ;Get Track Number
- mov al, byte [bpbSectorsPerTrack]
- mov cl, byte [bpbHeadsPerCylinder]
- mul cl
- mov cl,al ;store multiplication in cl
- mov ax, word [LBA]
- div cl
- mov byte [Track],al
- ;;===============
- pop cx
- cmp cx, 0
- je .endReadSectors
- inc bx
- inc [LBA]
- jmp .sectorReadLoop
- .endReadSectors:
- pop dx
- ret
- ;;=================================
- ;;=================================
- ;;=================================
- print:
- lodsb
- cmp al, 0
- je done
- mov ah, 0xe
- int 10h
- jmp print
- done:
- ret
- ;;=================================
- ;;=================================
- ;;=================================
- WordBuffer: times 6 db 0
- base dw 0x000a
- ProcedureEntry:
- mov cx, 0
- mov bx, WordBuffer+5
- loopProcedure:
- cmp ax, 0
- je endProcedure
- jmp DoDivide ;;
- ;cmp ax, [base] ;;check if already 10
- ;jge DoDivide
- ;mov dx, ax ;;process as remainder
- ;Getting here, means no division was done, which means there will
- ;be no remainder, ax equaled something smaller than 10
- ;put as remainder and process it.
- ;mov ax,0 ;;end loop
- ProcessRemainder: ;;put remainder into ASCII and put into buffer
- ;;we are working backwards, remainder is small number first, or first
- ;;place value.
- inc cx
- ;procesforzero
- dec bx
- add dl, '0'
- mov byte [bx], dl
- jmp loopProcedure
- DoDivide:
- cwd
- xor dx, dx
- div WORD [base]
- jmp ProcessRemainder
- endWithError:
- mov ah, 0xe
- mov al, 'E'
- int 10h
- endProcedure:
- mov bx, WordBuffer+5
- mov byte [bx], 0 ;;null out with 0
- sub bx, cx ;;if we return from an error, or 0 letters, prints only NULL
- ret
- ;;=================================
- ;;=================================
- ;;=================================
- start:
- mov ax,0
- mov es,ax
- mov sp,ax
- mov ax,0x07c0
- mov ds, ax
- mov ss, ax
- mov ax, 19
- mov bx, 0x500
- mov cx, 1
- call ReadSectors
- mov ah, 0
- mov al, [Track]
- call ProcedureEntry
- mov si, bx
- call print
- mov ah, 0
- int 0x16
- cli
- hlt
- times 510 - ($-$$) db 0
- sig dw 0xAA55
Add Comment
Please, Sign In to add comment