Code: Select all
mov ax,0xb800;
mov es,ax;
mov ax,0x07c0;
mov ds,ax;
xor ax,ax;
mov di,ax;
mov ax,disk_drive_number;
mov si,ax;
call printStr;
mov ax,bx;
call printInt;
call jmp;
;prints ax to screen
printInt:
mov cx,0x0000;
divide:
mov dx,0x0000;
mov bx,0x000A;
div bx;
inc cx;
add dx,48;
mov dh,0x4e;
push dx;
cmp ax,0x0000;
jne divide;
print:
pop dx;
mov di,[video_memory_index];
mov [es:di], dx;
inc di;
inc di;
mov [video_memory_index],di;
dec cx;
cmp cx,0x0000;
jne print;
ret;
;prints string in [ds:si] to screen
printStr:
cld;inc si after lodsb
loadchr:
lodsb;
cmp al,0x00;
je printStrFinish;
cmp al,0x0A;
je newline;
mov ah,0x4e;
mov di,[video_memory_index];
mov [es:di],ax;
inc di;
inc di;
mov [video_memory_index],di;
jmp loadchr;
newline:
push dx;
push bx;
push ax;
mov bx,0x00A0;
add [video_memory_index],bx;
mov dx,0;
mov ax,[video_memory_index];
div bx;
sub [video_memory_index],dx;
pop ax;
pop bx;
pop dx;
jmp loadchr;
printStrFinish:
ret;
jmp:
nop
call jmp
video_memory_index dw 0x00A0;
disk_drive_number db 'drivenumber:',0x00;
ax_str db 'ax:',0x0A,0x00;
bx_str db 'bx:',0x00;
cx_str db 'cx:',0x00;
dx_str db 'dx:',0x00;
sp_str db 'sp:',0x00;
bp_str db 'bp:',0x00;
si_str db 'si:',0x00;
di_str db 'di:',0x00;
times 510-($-$$) db 0
db 0x55
db 0xAA