** Please note that when I say a boot program, I do not mean a program that loads the OS. I mean, a simple program that starts when the computer starts and does something.
Good, so I'm not very good at Assembly / NASM, but I think I understand it well enough to write simple boot programs.
Well, I thought I had enough grip. Apparently not.
I tried a simple boot program that I found on the Internet. It went fine (typing the letter "A"). Then I changed it to print a letter stored in memory. This failed; instead of typing "A", he prints a smiley face. (I swear the computer is laughing at me right now.)
This is the code from the source file:
[BITS 16] ; We start up in 16-bit real mode
[ORG 0x7C00] ; We're booted into memory at this address. (Or so I'm told)
mov ah, 0x0E ; Teletype command
mov bh, 0x00 ; Page number
mov bl, 0x07 ; Attributes (7 == white foreground, black background)
mov al, [testChar] ; Character to print; load it from the memory referenced by testChar.
int 0x10 ; Tell the BIOS to execute the teletype command.
jmp $ ; Infinite loop prevents us from going off and executing the other junk in memory
testChar db 65 ; This is the character we want to print. 'A'.
; The following code pads the rest of the outputted binary file
; and concludes it with the bootloader signature so I don't have
; to do so manually.
times 510-($-$$) db 0
dw 0xAA55
If I replace " move al, [testChar] " with " move al, 65 ", the letter "A" will be printed correctly. I tried moving the memory declaration around, I tried every combination of brackets with or without brackets around BITS and ORG, and I tried to increase and decrease testChar (ie [TestChar + 1]). Each time it prints either a smiley or a reverse smiley (when I increase testChar), or nothing at all (when I add a memory declaration in front of the code, possibly because no code is executed = P). I can't get this damn thing to work.
Now for the specifications (because they are probably relevant):
Dell Latitude CPi Intel Pentium II, , ( . ). , x86, Windows XP, Ubuntu Arch Linux.
Arch Linux NASM.
' nasm -f bin FILENAME' .
"mformat" "mtools" AL " mformat -f 1440 -B BOOTPROGRAM A:.
, ? /BIOS?