It's very simple. If you know a programming language, it's very simple. Do you know qbasic!
If you do, you can take a look at the post I wrote about getting the hard disk serial number. That program directly uses I/O ports.
Because the BIOS doesn't provide the service of the hard disk serial number, so you must send instructions to the hard disk's ports such as (&H170......) by yourself, and then read the serial number. Note that this serial number is not the number of each partition of the hard disk. Some netizens say that the C drive, D drive, etc. all have serial numbers. In fact, that's the volume label!
The advantage of reading and writing the hard disk through I/O instructions is: you can bypass the services provided by the BIOS, so you can break through restoration software, and you can read and write hard disks no larger than 137GB on old 486 computers!
Of course, the more important use is not here. There are many hard disk-specific commands that must be implemented through I/O instructions, such as writing negative tracks, adding bad sectors to the G table, etc.
All powerful hard disk repair software use I/O instructions, such as the PC3000 and MHDD that we are familiar with.
It is recommended that you learn a programming language. C language is the best choice! Although I don't know C language, I only know qbasic!