; cx: len_buffer ; si: buffer ; dl: start_x NOTE: Will contain the end of the text on-screen ; dh: start_y NOTE: Will contain the end of the text on-screen print_string: .prolog: push di push cx push bx push ax xor di, di ; character index .printing_loop: .set_cursor_position: mov ah, 0x02 mov bh, 0 int 0x10 .write_character: push cx ; save len_buffer ; get the current character mov bx, si add bx, di mov al, [bx] ; al now contains the current character ; set the other needed interrupt values mov ah, 0x0a ; wanted function (write character at cursor position) mov bh, 0 ; page number mov cx, 1 ; repetitions of character int 0x10 ; call bios basic draw functions pop cx ; restore len_buffer inc dl ; go to next column ; go to a new line if needed cmp dl, 80 jb .no_new_line_needed xor dl, dl inc dh ; increase column .no_new_line_needed: inc di ; go to next character ; go further if the string-printing hasn't been finished cmp di, cx jb .printing_loop .epilog: pop ax pop bx pop cx pop di ret