I'm working on a "Write your own Operating System using assembly only by holding your hand along the way" project. I've written from scratch everything with the like of MikeOS with the exception of harddrive reading and writing. The importance of reading and writing is to allow for an operating system to be larger then the Basic Input Output System memory of 512 length.
I wrote a test case for reading from the hard drive and printing the first character on screen. Using qemu, I can define which file to use as the harddrive within regards to that I define the positions of the registers the program can point to that harddrive with 0x80 option during the read function inturrupt.
The first test code was with out the harddrive selection and thus the reading code would read its own running binary and produce an "a" presuming due to the binary had produced an "a"(ascii) in the beginning of the running file loaded into the Basic Input Output System.
So my question here is...
When I define the harddrive selection why does it not read the string "Hello" in the file on screen like it does when I do not define the harddrive?
Is my code correct to begin with and the "a" produced on screen is a coincidence that there is an "a" in the beginning of the produced binary file that runs in the emulator?
For everyone sake please respond with explanations and code. There are two questions I've found in Stack Overflow that are both answered with English explanations with what is wrong with their code but no code to demonstrate why they are correct in their explanations. It is a moot point to explain but not show your work.
Do not suggest me to use C, C++, or anything else besides assembly, if you have done your research and I have done my research and dis-assemble high-level languages like C, C++ or anything else you will see a simple "defining and reading a string on to the console" is not only significantly larger but just careless in regards to efficiency. These dis-assembled C code comparisons to handwritten assembly examples will also be released in the project files.
I appreciate your time and when I release the project as open source tutorials society will appreciate how much time you have saved anyone else in the same position as me. (Human knowledge belongs to the world -Antitrust Movie, Year 2001)
[bits 16]
[org 0x7c00]
message db "Hello"
mov ah, 0x02 ;point to read sector function
mov ch, 0x00 ;ch track/cylinder number
mov dh, 0x00 ;dh head number
mov cl, 0x00 ;cl sector number
mov dl, 0x80 ;drive number 80 is drive0, 81 is drive1
int 0x13
;read disk into terminal.... might be working, just displays 'a'...
mov ah, 0x0e
mov al, [bx]
int 0x13
;Purpose, move to the next character read from file
mov ah, 0x0e
mov es, bx
mov al, [bx]
int 0x13
times 510 - ($-$$) db 0
dw 0xAA55
;==============================================================
; Reference Notes
;==============================================================
;
;;;;;;;;;;;;; Interupt 02 - Read from sector ;;;;;;;;;;;;
;AH = 02
;AL = number of sectors to read (1-128 dec.)
;CH = track/cylinder number (0-1023 dec., see below)
;CL = sector number (1-17 dec.)
;DH = head number (0-15 dec.)
;DL = drive number (0=A:, 1=2nd floppy, 80h=drive 0, 81h=drive 1)
;ES:BX = pointer to buffer
;
;on return:
;AH = status (see INT 13,STATUS)
;AL = number of sectors read
;CF = 0 if successful
; = 1 if error
;;;;;;;; Inturrupt 13 - Video card functions ;;;;;;;;
;AH = 02, means TTY mode, print to console mode
;AL = which character to print to console