Skip to content

Commit 5a4aa45

Browse files
Agregado en la cadena de formato el uso de %s, funcion print.
1 parent c05a122 commit 5a4aa45

File tree

3 files changed

+50
-31
lines changed

3 files changed

+50
-31
lines changed

asm/boot/uefi.asm

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,17 @@ exit_uefi_services:
716716
rep stosd
717717
;;;;;;; verificado que el tamano de pantalla correcto
718718

719-
mov rax, [FB] ;; Inicializacion del cursor.
720-
mov [print_cursor], rax ;; Inicializacion del cursor.
719+
mov rax, [FB]
720+
mov [print_cursor], rax ;; Inicializacion del cursor.
721+
mov r9, msg_boot_services_exit_ok
722+
mov rsi, msg_test8
721723
call print
722724

723725

726+
cli
727+
hlt
728+
729+
724730

725731
; Clear registers
726732
xor eax, eax
@@ -1108,24 +1114,21 @@ num2strWord:
11081114
;; print - impresion utf8 a buffer de video luego de ExitBootSerivces()
11091115
;;==============================================================================
11101116
;; Argumentos:
1111-
;; -- rdx = cadena fmt
1117+
;; -- r9 = cadena fmt
11121118
;; -- rsi = 2do argumento en caso de haber %.
1119+
;; Retorno:
1120+
;; -- rax = cursor (address fb) siguiente a la ultima posicion escrita.
1121+
;;
1122+
;; El comportamiento si la cadena de fmt tiene % huerfano (no hay ninguna de las
1123+
;; siguientes a continuacion: d, h, c, s) es: ignora el % y sigue imprimiendo. S
1124+
;; i tiene muchos % siempre va a usar el mismo argumento para la conversion (el
1125+
;; unico que recibe en rsi).
11131126
;;
1114-
;; ###########################El comportamiento si la cadena de fmt tiene % huerfano (no hay ninguna de las
1115-
;; ###########################siguientes a continuacion: d, h, c, s) es: ignora el % y sigue imprimiendo. S
1116-
;; ###########################i tiene muchos % siempre va a usar el mismo argumento para la conversion (el
1117-
;; ###########################unico que recibe en rsi).
1127+
;; El cursor para esta funcion, es la direccion del pixel superior izquierdo del
1128+
;; bounding box del caracter de la fuente.
11181129
;;==============================================================================
11191130

11201131
print:
1121-
;;call strcpy16
1122-
call print_flush
1123-
ret
1124-
1125-
;;strcpy16:
1126-
;; ret
1127-
1128-
print_flush:
11291132
mov rax, [print_cursor]
11301133
mov rdi, [PPSL]
11311134
mov r8, 0 ;; ix src str.
@@ -1135,7 +1138,7 @@ print_flush:
11351138
;; nzar imprimir.
11361139
mov rcx, 0 ;; Blanqueo de parte alta para uso en resolucion de addrress en
11371140
;; .print_next_font.
1138-
mov cl, [msg_boot_services_exit_ok + r8]
1141+
mov cl, [r9 + r8]
11391142
cmp cl, 0
11401143
je .string_flush_end
11411144

@@ -1146,16 +1149,16 @@ print_flush:
11461149
je .check_nextchar_s
11471150

11481151
.print_next_font:
1149-
lea rsi, [font_data + 8 * rcx] ;; rsi p2fontLine 16px chars.
1150-
lea rsi, [rsi + 8 * rcx]
1152+
lea r10, [font_data + 8 * rcx] ;; r10 p2fontLine 16px chars.
1153+
lea r10, [r10 + 8 * rcx]
11511154
mov rdx, 0
11521155

11531156
.loop_font_vertical_line:
11541157
cmp rdx, font_height
11551158
je .char_flush_end
11561159
mov rcx, 0
11571160
mov rbx, 0
1158-
mov bl, [rsi + rdx]
1161+
mov bl, [r10 + rdx]
11591162

11601163
.loop_font_horizontal_pixel:
11611164
cmp rcx, 8
@@ -1167,7 +1170,7 @@ print_flush:
11671170
mov dword [rax + 4 * rcx], 0x00000000
11681171
jmp .nextPixel
11691172
.setPixel:
1170-
mov dword [rax + 4 * rcx], 0x00FFFFFF
1173+
mov dword [rax + 4 * rcx], 0x00E0E0E0
11711174
.nextPixel:
11721175
inc rcx
11731176
jmp .loop_font_horizontal_pixel
@@ -1178,10 +1181,10 @@ print_flush:
11781181
jmp .loop_font_vertical_line
11791182

11801183
.char_flush_end:
1181-
pop rax
1182-
add rax, 32 ;; rax += 8px * 4bytes/px
1184+
add qword [rsp], 32 ;; rax += 8px * 4bytes/px
11831185

11841186
.avance_next_char:
1187+
pop rax
11851188
inc r8
11861189
jmp .loop_read_string_char
11871190

@@ -1198,16 +1201,32 @@ print_flush:
11981201
mov rax, 4 * 16 ;; Bajar 16px.
11991202
mov rdx, 0
12001203
mul rbx ;; rax = offset_bytes
1201-
pop rbx
1202-
lea rax, [rbx + rax]
1204+
add [rsp], rax
12031205
jmp .avance_next_char
12041206

12051207
.check_nextchar_s:
1208+
mov cl, [r9 + r8 + 1]
1209+
cmp cl, 's'
1210+
jne .avance_next_char
12061211

1212+
inc r8
1213+
mov [print_cursor], rax ;; Update cursor to current position.
1214+
1215+
push rdi
1216+
push r8
1217+
push r9
1218+
mov r9, msg_test8
1219+
call print
1220+
pop r9
1221+
pop r8
1222+
pop rdi
1223+
1224+
mov [rsp], rax ;; Actualiza cursor.
1225+
jmp .avance_next_char
12071226

12081227
.string_flush_end:
1209-
cli
1210-
hlt
1228+
add rsp, 8 ;; Quita push de rax q se hace para cada caracter.
1229+
mov [print_cursor], rax ;; Update cursor to current position.
12111230
ret
12121231

12131232

@@ -1236,7 +1255,8 @@ FB: dq 0 ; Frame buffer base address
12361255
FB_SIZE: dq 0 ; Frame buffer size
12371256
HR: dq 0 ; Horizontal Resolution
12381257
VR: dq 0 ; Vertical Resolution
1239-
PPSL: dq 0 ; PixelsPerScanLine
1258+
PPSL: dq 0 ; PixelsPerScanLinemsg_boot_services_exit_ok: db "Exit from UE%FI se", 0x0A, "rvices exit%soso.", 0
1259+
12401260
BPP: dq 0 ; BitsPerPixel
12411261
memmap: dq 0x220000 ;; Address donde quedara el mapa de memoria.
12421262
memmapsize: dq 32768 ;; Tamano max del buffer para memmap [bytes].
@@ -1323,8 +1343,8 @@ msg_notify_memmap_change: dw utf16("Memory map buffer size change: will request
13231343
txt_err_memmap: dw utf16("get memmap feilure"), 0
13241344
msg_will_exit_uefi_services: dw utf16("A continuacion hara exit de uefi services"), 13, 0xA, 0
13251345

1326-
msg_test: dw utf16("Test"), 13, 0xA, 0
1327-
msg_test8: db "ab", 0
1346+
msg_test16: dw utf16("Test"), 13, 0xA, 0
1347+
msg_test8: db "Test", 0
13281348

13291349
fmt_memmap_cant_descriptors: dw utf16("Uefi returned memmap | Cant descriptors = %d"), 13, 0xA, 0
13301350

@@ -1348,8 +1368,7 @@ str_gop_protocol_fatal_err: dw utf16("GOP protocol no localizado"), 0
13481368

13491369
;; UTF8 strings para bootloader.
13501370
____msg_boot_services_exit_ok: db "Exit from UEFI services exitoso.", 0
1351-
msg_boot_services_exit_ok: db "Exit from UEFI se", 0x0A, "rvices exitoso.", 0
1352-
1371+
msg_boot_services_exit_ok: db "Exit from UE%FI se", 0x0A, "rvices exit%soso_1234567890.", 0
13531372

13541373

13551374

build/uefi.elf

0 Bytes
Binary file not shown.

build/uefi.sys

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)