NASM: how to access ssd drive correctly?

。_饼干妹妹 提交于 2019-12-23 04:49:06

问题


I need to access SSD drive with NASM 16-bit code. When accessing regular hard drive, need to set registers AX, DX, CX to choose Cylinder/Track/Sector/Number of sectors (AH - to choose read sector function, DL - to choose drive number, CH - to choose cylinder, DH - to choose side on disk, CL - to choose sector on track, AL - to choose number of sectors).

However, I suppose SSD disk has some other structure, so how to access them correctly?


回答1:


Assuming translation of fake geometry into LBA (the most likely case), "int 0x13, ah=0x02" can only handle a maximum of 16515072 sectors. At 512 bytes per sector (also the most likely case) that works out to 8064 MiB or about 7.8 GiB. Hard drives (including SSDs) have been larger than this for about 2 decades; so "int 0x13, ah=0x02" isn't a sane option.

Instead, for hard drives (including SSD) you want to use "int 0x13, ah=0x42" (see http://www.ctyme.com/intr/rb-0708.htm ). This function uses LBA addresses and doesn't use CHS; and (with 64-bit LBA address and the same 512 bytes per sector) it can handle (up to) 8589934592 TiB drives.



来源:https://stackoverflow.com/questions/59336069/nasm-how-to-access-ssd-drive-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!