我正在用NASM編寫簡單的時鐘程序。我在OSX上通過iTerm使用Ubuntu 14.10 Vagrant框。終端是xterm,所以應該是VT-100兼容的。VT-100命令奇怪地工作
我需要刪除一行。舉例來說,我希望以下行爲:
Hello, this is clock program
13:01:25 UTC+4
下一刻:
Hello, this is clock program
13:01:26 UTC+4
我寫了下面的功能。對於打印:
func_print:
mov eax, sys_write
mov ebx, stdout
int 0x80
ret
對於明確:
clr db 0x1b, "[K"
clr_len equ $-clr
...
func_clear:
mov ecx, clr
mov edx, clr_len
call func_print
保存和恢復位置我使用VT-100和它的命令:[7
和[8
分別爲:
csave db 0x1b, "[7"
csave_len equ $-csave
crestore db 0x1b, "[8"
crestore_len equ $-crestore
我的代碼:
global _start
_start:
mov ecx, welcome
mov edx, welcome_len
call func_print
call func_print
call func_save_cursor_pos
mov dword [tv_sec], 2
mov dword [tv_usec], 0
call func_sleep
call func_clear
call func_restore_cursor_pos
mov ecx, welcome
mov edx, welcome_len
call func_print
jmp func_exit
然而,結果是:
[email protected]:~$ ./run.sh
Hello, this is the clock program
Hello, this is the clock program
Hello, this is the clock program
[email protected]:~$
我怎樣才能解決這個問題:
[email protected]:~$ ./run.sh
Hello, this is the clock program
Hello, this is the clock program
Hello, this is the clock program
[email protected]:~$
如果我加入[1A
或[1B
似乎被刪除線,以比所需的更高或更低的太大變化clr
?什麼是正確的代碼?
既然你只是更新一行,你是否考慮過使用'\ r'而不是? –
這只是一個例子,我想更新任意數量的行,實際上 – ka2m