GetCursorPosition 函数
GetCursorPosition 函数获取文本模式屏幕上当前光标的位置。
参数: 函数不接受参数。
返回值: AH:行号;AL:列号。
标志状态: 函数不改变标志状态。
程序源代码
Intel 8086 汇编程序示例,演示使用 GetCursorPosition 函数获取当前光标位置。
title .model small .stack 100h data segment public string db "Hello, World of Assembler!\0" data ends code segment public ; 代码段开始 assume ds:data, cs:code include Handyfar.inc ; 包含函数文件 main proc ; main 过程开始 call SetDataSegment ; 调用过程 SetDataSegment mov ax, 0606h ; 将新的光标位置复制到寄存器 ax call SetCursorPosition ; 调用过程 SetCursorPosition(ah:06, al:06) lea ax, ds:[string] ; 将变量 string 的地址装入寄存器 ds:ax call WriteString ; 调用过程 WriteString(ax:string) call GetCursorPosition ; 调用过程 GetCursorPosition() := AX add ah, 6 ; 行号增加 6 add al, 6 ; 列号增加 6 call SetCursorPosition ; 调用过程 SetCursorPosition(ah:12, al:12) lea ax, ds:[string] ; 将变量 string 的地址装入寄存器 ds:ax call WriteString ; 调用过程 WriteString(ax:string) xor al, al ; 清零寄存器 al call ExitProcess ; 调用过程 ExitProcess main endp ; main 过程结束 code ends ; 代码段结束 end main ; 文件结束。入口点指定为过程 main
(该字符串输出两次:先在位置 (6,6),然后在位置 (12,12))
示例取自教材 "HANDYFAR - MASM (Dovgopolov Evgeny Sergeevich)".