汇编 8086 光标放置

assembly 8086 cursor placement

我想将光标放在 "paper:" 之后,等待输入 ENTER,然后将其放在 "author(s):" 之后。两个句子都是打印的定义变量。

    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

调用下一个过程来定位光标:

;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

示例:

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.

在前面的示例中,光标将跳转到 "paper: " 之后。

编辑: 另外两个过程,cursor_oncursor_off,用于显示和隐藏光标:

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

这是一个接收位置 X,Y 的宏


gotoxy macro x y 
    mov ah,02h
    mov bh, 00h
    mov dl,x
    mov dh,y
    int 10h
    goto endm

; to call it just write: gotoxy 2,4