Search code examples
assemblyx86-16emu8086text-cursor

assembly 8086 cursor placement


I want to place the cursor after the "paper:" wait until an ENTER is given and then place it after "author(s):". both sentences are defined variables that are printed.

enter image description here

    insert db "******* Insert new paper *******",0,0Ah,0Ah,0Ah, 0Dh, "$"  
    inserttitle db "  Title of paper:      ",0Dh,0Ah,0Ah, "  Name of author(s):     ",0Dh ,"$"
    mainext db ,0Ah,0Ah,0Ah,0Ah,0Ah,0Ah,0Ah,0Ah,"     <<Main>>              <<Next>>","$"

 INSERT NEW PAPER

newpaper proc

    call clrscr

    mov dx, offset insert
    call printf

    mov dx, offset inserttitle
    call printf

    mov dx, offset mainext
    call printf

    call w8click   
    ret

newpaper endp

Solution

  • Call next proc to position cursor :

    ;INPUT : DL=X, DH=Y.
    set_cursor proc
          mov  ah, 2                  ;◄■■ SERVICE TO SET CURSOR POSITION.
          mov  bh, 0                  ;◄■■ VIDEO PAGE.
          int  10h                    ;◄■■ BIOS SERVICES.
          RET
    set_cursor endp
    

    Example :

    call clrscr
    
    mov  dx, offset inserttitle ;◄■■ "  Title of paper:      "
    call printf
    
    mov  dl, 18                 ;◄■■ SCREEN COLUMN 18 (X).
    mov  dh, 2                  ;◄■■ SCREEN ROW 2 (Y).
    call set_cursor             ;◄■■ SET CURSOR POSITION.
    

    In previous example cursor will jump to after "paper: ".

    Edit : two more procs, cursor_on and cursor_off, to show and hide cursor:

    cursor_on proc
       mov  ah, 1
       mov  cx, 4          ;◄■■ BIG CURSOR.
       int  10h
       ret
    cursor_on endp
    
    
    cursor_off proc
       mov  ah, 1
       mov  cx, 20h        ;◄■■ NO CURSOR.
       int  10h
       ret
    cursor_off endp