1) REALLY fix strcat crash (git restored wrong file in previous commit) 2) fopen: less labels ffs

This commit is contained in:
2025-07-27 21:17:59 +02:00
parent ca6d6e6d31
commit f18de90868
2 changed files with 13 additions and 10 deletions

View File

@@ -97,7 +97,7 @@ fgetmod:
; rdi (arg) Pointer to string holding (path+)file name
; rsi Mode to open the file with (see description above)
fopen:
%macro createFile 1
%macro createFile 0
push rdi
push rsi
call fexist
@@ -105,7 +105,7 @@ fopen:
pop rdi
test rax, 1
jz %%createFile
jmp %1
jmp %%cnt
%%createFile:
push rsi
push rdi
@@ -119,6 +119,7 @@ fopen:
syscall
pop rdi
pop rsi
%%cnt:
%endmacro
;;;
;;; ENTRY
@@ -144,26 +145,22 @@ fopen:
mov rsi, O_RDONLY
jmp .open
.setMode_w:
createFile .open_w
.open_w:
createFile
mov rsi, O_WRONLY | O_TRUNC
jmp .open
.setMode_a:
createFile .open_a
.open_a:
createFile
mov rsi, O_WRONLY | O_APPEND
jmp .open
.setMode_R:
mov rsi, O_RDWR
jmp .open
.setMode_W:
createFile .open_W
.open_W:
createFile
mov rsi, O_RDWR | O_TRUNC
jmp .open
.setMode_A:
createFile .open_A
.open_A:
createFile
mov rsi, O_RDWR | O_APPEND
jmp .open

View File

@@ -66,10 +66,12 @@ strcpy:
; r8* Backup for rdi (point to start of dest)
; r9* Backup for rsi
; r10* Backup for rdi (point to end of dest)
; r11* Backup for strlen(dest)
strcat:
mov r8, rdi
mov r9, rsi
call strlen
mov r11, rax
sub rdx, rax
dec rdi
mov r10, rdi
@@ -78,13 +80,17 @@ strcat:
cmp rax, rdx
jb .copy
dec rdx
.copy:
cmp rdx, r11
jle .quit
mov rcx, rdx
mov rsi, r9
mov rdi, r10
cld
rep movsb
mov byte [rdi], EOS
.quit:
mov rax, r8
ret