;; }}}
+macro os_code_section {
+ section '.text' code readable executable
+}
+
+macro os_data_section {
+ section '.data' readable writable
+}
+
section '.text' code executable readable
os_initialize:
ret
os_read_char:
- mov r15, rcx
.read_key:
mov rcx, [system_table] ; EFI_SYSTEM_TABLE* rcx
mov rcx, [rcx + EFI_SYSTEM_TABLE.ConIn] ; EFI_SIMPLE_TEXT_INPUT_PROTOCOL* rcx
cmp rax, r8
je .read_key
- mov ax, [input_key.UnicodeChar]
- mov [r15], al
+ movzx rax, word [input_key.UnicodeChar]
;; Special handling of enter (UEFI gives us '\r', but we want '\n'.)
cmp ax, $D
jne .no_enter
- mov byte [r15], $A
+ mov al, $A
.no_enter:
+ push rax
;; Print the character
- mov rcx, r15
+ mov [char_buffer], al
+ mov rcx, char_buffer
mov rdx, 1
call os_print_string
+ pop rax
ret