The standard int 10h
requires only ax
and bx
to be set and it appears you have done this correctly. The calculations at the top leave bx
set to zero and ax
set to 0865H
:
mov ax, 1853 ; ax <- 073dH
mov bl, 15 ; bx <- ??0fH
div bl ; ax <- 087bH
sub al, 2 ; ax <- 0879H
mov bx, 10 ; bx <- 000AH
subtract: ; ten times decrement bx, sub 2 from ax
sub ax, 2
sub bx, 1
cmp bx, 0
jne subtract ; ax <- 0865H, bx <- 0000H
You then set the registers as needed:
mov bl, al ; bx <- 0065H
mov ax, 0 ; ax <- 0000H
mov cx, 0 ; cx <- 0000H
mov dx, 0 ; dx <- 0000H
mov ah, 0x0e ; ax <- 0e00H
mov al, bl ; ax <- 0e65H
mov bx, 0 ; bx <- 0000H
That final value of ax/bx
should be okay to print e
to the console:
ah = 0eH : teletype output command
al = 65H : The 'e' character.
bh = 00H : page zero.
bl = 00H : forground color (only for graphic modes).
The values of cx/dx
should be irrelevant. There was a drop-in BIOS replacement that treated a value of cx = abcdH
specially but it's incredibly unlikely to be an issue here.
Hence your actual code seems to be fine, with or without the "stupid" code. However, as other as have pointed out in comments, there is a known issue with booting from USB (if that is what you're doing) - it appears the USB boot process forces the first bit of the boot sector to hold certain disk property information (the BIOS parameter block, or BPB). That means you'll have to move your code out of the way so that it can run properly.
This answer provides all the gory details and, in terms of working around that, you could probably just shift your code to the end, something like:
[bits 16]
[org 0x7c00]
jmp init
times 510 - ($ - $$) - (last - init) db 0 ; leave as much space as possible.
init:
jmp $ ; your actual code should go here.
last:
dw 0xaa55
This way, you end up with enough space for USB booting to put the BPB (assuming your code isn't too long):
1 [bits 16]
2 [org 0x7c00]
3 0000 E9F901 jmp init
4 0003 00<rept> times 510 - ($ - $$) - (last - init) db 0
5 init:
6 01FC EBFE jmp $
7 last:
8 01FE 55AA dw 0xaa55
Of course, you may want to consider just putting your own BPB in there, of the correct format. That would render unnecessary the trickiness of moving your code to the end of the boot sector.