- 论坛徽章:
- 0
|
修改了一下 keyboard.asm 代码,加入 event 机制
修改了一下 shell ,输入没这么乱了,但是还是没做好。 - shell_entry:
- mov r12, buf_ptr
- shell_loop:
- mov rdi, shell_string
- call puts
- mov rax, [qword keybuf_tail_ptr]
- mov [r12], rax
- call wait_for_enter ; 等待按 <enter> 键
- mov rsi, [r12]
- mov rdi, command
- call strcpy
- mov rdi, command
- call execute ; 执行命令
- call println
- jmp shell_loop
-
-
-
- ;--------------------------------------------
- ; wait_for_enter()
- ; description:
- ; wait for <enter> key press
- ;--------------------------------------------
- wait_for_enter:
- mov rax, [qword key_flags]
- bt rax, 12
- jnc wait_for_enter
- btr rax, 12
- mov [qword key_flags], rax
- ret
-
-
- ;---------------------------------------------------------
- ; shell_keyboard_event_handler()
- ; description:
- ; keyboard event handler for shell process
- ;---------------------------------------------------------
- shell_keyboard_event_handler:
- push rbx
- mov rbx, keybuf_tail_ptr
- mov rax, [qword key_flags]
- bt rax, 63 ; 是否按下
- jc keyboard_event_handler_done
- call cursor ; 打印光标
- mov rax, [rbx]
- movzx rdi, byte [rax]
- call putc ; 打印字符
- inc qword [rbx]
- keyboard_event_handler_done:
- pop rbx
- ret
复制代码 (1)、shell_keyboard_event_handler() 是 shell 的 keyboard 按键处理例程,做2个工作:打印光标,打印字符
(2)、wait_for_enter() 是等待按 <enter> 键 |
|