diff --git a/src/kernel.asm b/src/kernel.asm index e1c172d8..a7007daa 100644 --- a/src/kernel.asm +++ b/src/kernel.asm @@ -23,17 +23,6 @@ jmp _start %define STYLE(f,b) ((f << 4) + b) -%macro PRINT_NORMAL 2 - call set_current_position - mov rbx, %1 - mov dl, STYLE(BLACK_F, WHITE_B) - call print_string - - mov rax, [current_column] - add rax, %2 - mov [current_column], rax -%endmacro - _start: ; Reset data segments because the bootloader set it to ; a value incompatible with the kernel @@ -208,7 +197,9 @@ lm_start: jmp .start .command_not_found: - PRINT_NORMAL unknown_command_str_1, unknown_command_str_1_length + mov r8, unknown_command_str_1 + mov r9, unknown_command_str_1_length + call print_normal call set_current_position @@ -221,7 +212,9 @@ lm_start: add rax, rbx mov [current_column], rax - PRINT_NORMAL unknown_command_str_2, unknown_command_str_2_length + mov r8, unknown_command_str_2 + mov r9, unknown_command_str_2_length + call print_normal .end: mov qword [current_input_length], 0 @@ -229,7 +222,9 @@ lm_start: call goto_next_line ;Display the command line - PRINT_NORMAL command_line, command_line_length + mov r8, command_line + mov r9, command_line_length + call print_normal jmp .start_waiting @@ -239,6 +234,7 @@ lm_start: set_current_position: push rax push rbx + push rdx ; Line offset mov rax, [current_line] @@ -251,6 +247,7 @@ set_current_position: lea rdi, [rax + rbx + TRAM] + pop rdx pop rbx pop rax @@ -314,7 +311,35 @@ clear_screen: mov qword [current_line], 1 ;Display the command line - PRINT_NORMAL command_line, command_line_length + mov r8, command_line + mov r9, command_line_length + call print_normal + + ret + +; Print the given string at the current position and update +; the current position for later print +; r8 = string to print +; r9 = length of the string to print +print_normal: + push rax + push rbx + push rdx + push rdi + + call set_current_position + mov rbx, r8 + mov dl, STYLE(BLACK_F, WHITE_B) + call print_string + + mov rax, [current_column] + add rax, r9 + mov [current_column], rax + + pop rdi + pop rdx + pop rbx + pop rax ret @@ -443,7 +468,9 @@ sysinfo_command: push rcx push rdx - PRINT_NORMAL sysinfo_vendor_id, sysinfo_vendor_id_length + mov r8, sysinfo_vendor_id + mov r9, sysinfo_vendor_id_length + call print_normal xor eax, eax cpuid @@ -458,7 +485,9 @@ sysinfo_command: call print_string call goto_next_line - PRINT_NORMAL sysinfo_stepping, sysinfo_stepping_length + mov r8, sysinfo_stepping + mov r9, sysinfo_stepping_length + call print_normal mov eax, 1 cpuid @@ -473,7 +502,9 @@ sysinfo_command: call print_int call goto_next_line - PRINT_NORMAL sysinfo_model, sysinfo_model_length + mov r8, sysinfo_model + mov r9, sysinfo_model_length + call print_normal ; model id mov r14, r15 @@ -499,7 +530,9 @@ sysinfo_command: call print_int call goto_next_line - PRINT_NORMAL sysinfo_family, sysinfo_family_length + mov r8, sysinfo_family + mov r9, sysinfo_family_length + call print_normal mov r8, r13 add r8, r11 @@ -508,7 +541,9 @@ sysinfo_command: call print_int call goto_next_line - PRINT_NORMAL sysinfo_features, sysinfo_features_length + mov r8, sysinfo_features + mov r9, sysinfo_features_length + call print_normal mov eax, 1 cpuid @@ -520,7 +555,9 @@ sysinfo_command: cmp r15, 0 je .sse - PRINT_NORMAL sysinfo_mmx, sysinfo_mmx_length + mov r8, sysinfo_mmx + mov r9, sysinfo_mmx_length + call print_normal .sse: @@ -529,7 +566,9 @@ sysinfo_command: cmp r15, 0 je .sse2 - PRINT_NORMAL sysinfo_sse, sysinfo_sse_length + mov r8, sysinfo_sse + mov r9, sysinfo_sse_length + call print_normal .sse2: @@ -538,7 +577,9 @@ sysinfo_command: cmp r15, 0 je .ht - PRINT_NORMAL sysinfo_sse2, sysinfo_sse2_length + mov r8, sysinfo_sse2 + mov r9, sysinfo_sse2_length + call print_normal .ht: @@ -547,7 +588,9 @@ sysinfo_command: cmp r15, 0 je .sse3 - PRINT_NORMAL sysinfo_ht, sysinfo_ht_length + mov r8, sysinfo_ht + mov r9, sysinfo_ht_length + call print_normal .sse3: @@ -556,7 +599,9 @@ sysinfo_command: cmp r15, 0 je .sse4_1 - PRINT_NORMAL sysinfo_sse3, sysinfo_sse3_length + mov r8, sysinfo_sse3 + mov r9, sysinfo_sse3_length + call print_normal .sse4_1: @@ -565,7 +610,9 @@ sysinfo_command: cmp r15, 0 je .sse4_2 - PRINT_NORMAL sysinfo_sse4_1, sysinfo_sse4_1_length + mov r8, sysinfo_sse4_1 + mov r9, sysinfo_sse4_1_length + call print_normal .sse4_2: @@ -574,7 +621,9 @@ sysinfo_command: cmp r15, 0 je .last - PRINT_NORMAL sysinfo_sse4_2, sysinfo_sse4_2_length + mov r8, sysinfo_sse4_2 + mov r9, sysinfo_sse4_2_length + call print_normal .last: