程序集8086光标放置

时间:2016-12-02 20:02:51

标签: assembly cursor x86-16 placement emu8086

我想将光标放在"纸张之后:"等到给出一个ENTER然后将它放在"作者之后:"。两个句子都是已打印的定义变量。

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

2 个答案:

答案 0 :(得分:3)

调用下一个proc来定位光标:

;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

答案 1 :(得分:0)

这是一个接收位置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