Commit Graph

  • c80eb0b21d Fix stack alignment in printf; flushing buffer would have unaligned stack if format specifier wasn't %d (only .convertInt aligned the stack) development Kwarde 2025-07-01 11:36:12 +02:00
  • 0de494bf51 printf() fixes: 1) Relative addresses 2) Stack alignment when calling itoa Kwarde 2025-07-01 11:11:59 +02:00
  • 20564bb785 Use %include instead of extern for constants.asm Kwarde 2025-07-01 10:14:38 +02:00
  • ddb5183f5a printf(): Pop RDI when an invalid specifier was used Kwarde 2025-07-01 10:11:30 +02:00
  • bc93a0c4ca Fix comment (opcode -> instruction) Kwarde 2025-06-30 23:03:39 +02:00
  • 9ea889dd12 printf(): Fetch args smarter (fetch from memory, slower, but also less opcodes/compares, and convenient for future;less repeatability) Kwarde 2025-06-29 12:08:19 +02:00
  • 8ab78baa35 Fix typo (FS_stderr->FD_stderr) Kwarde 2025-06-27 19:08:41 +02:00
  • ef19cbda50 Add file descriptor constants Kwarde 2025-06-27 19:05:14 +02:00
  • 9982eabe7c printf(): Always print full string instead of throwing an error; print printfBuff when full and start at index 0 again Kwarde 2025-06-27 18:57:54 +02:00
  • e49c203c34 Prevent errors in make, use -p with mkdir Kwarde 2025-06-26 11:04:07 +02:00
  • 6b850457cd Fix NL in puts Kwarde 2025-06-26 11:01:58 +02:00
  • 7a2d05d838 Fix makefile (create build and build/bin) Kwarde 2025-06-26 10:57:32 +02:00
  • 265ff06686 Seperate source and build files in src and build (and build/bin) Kwarde 2025-06-26 10:55:10 +02:00
  • 2e8da5318f Remove 'all' in makefile Kwarde 2025-06-26 10:39:45 +02:00
  • ec8943ac7c Use NL/EOS instead of 10/0 Kwarde 2025-06-26 10:38:01 +02:00
  • 43b5367790 perror(): Print unknown errors too with errno Kwarde 2025-06-26 10:33:33 +02:00
  • 232d50576f Add perror() (currently only errors 1-34 from asm-generic/errno-base.h) Kwarde 2025-06-26 09:29:54 +02:00
  • fc28643c1a Get rid of unneeded function prologues/epilogues Kwarde 2025-06-26 07:23:29 +02:00
  • 3730086281 Minimalize comments Kwarde 2025-06-26 07:02:00 +02:00
  • 61a1cb50d1 printf() optimization: Use syscall and mov r14 to rax rather than calling print and strlen -- r14 used to contain wrong length: mistakenly increased r14 (and performed checks) for printfNBuff Kwarde 2025-06-25 21:57:01 +02:00
  • 45a62dff93 Remove fopen mode/open flags table comment in file.asm (was only there for convenience while creating fopen base) Kwarde 2025-06-25 21:40:19 +02:00
  • 58cd2cc034 Restore console.asm:.rodata:bufferLength Kwarde 2025-06-25 21:23:15 +02:00
  • c40ac31c1f Don't push/pop r11 in printf(), idk why I did that anymore but it's not needed Kwarde 2025-06-25 21:19:33 +02:00
  • 9794c64cd5 printf(): Don't push and pop rsi before/after itoa (rsi is modified anyway) Kwarde 2025-06-25 20:52:52 +02:00
  • 9d904555eb Improve printf() : Less jumps (cmovX), removal of finish_L/rbx mod Kwarde 2025-06-25 20:48:53 +02:00
  • cef713db14 Minor optimizations in printf() (stop using rbx and r13, use smarter checks instead + pop r11 correctly (prevent stack corruption)) Kwarde 2025-06-25 20:40:35 +02:00
  • d3b801a97b Merge branch 'development' of git.kwarde.com:Kwarde/klibc into development Kwarde 2025-06-25 16:24:37 +02:00
  • 01e14d418a FIX: No longer allow exceeding printf buffer, instead print an error to stdout. Temporary fix Kwarde 2025-06-25 16:23:59 +02:00
  • e020fb15c1 FIX: itoa() not saving rbx Kwarde 2025-06-25 16:23:02 +02:00
  • 6bf73eb5ed Update README (C lib -> C-like lib, since it doesn't mimic the true C library anymore) Kwarde 2025-06-25 15:06:12 +02:00
  • 3e8bcdeb01 Get rid of gcc, adds exit() Kwarde 2025-06-25 14:58:02 +02:00
  • 36d21ca18b Ignore invalid specifiers in printf() Kwarde 2025-06-25 14:40:01 +02:00
  • 5ead6ebdb1 Add support for '%%' in printf() Kwarde 2025-06-25 14:21:46 +02:00
  • 1e095bec77 Add printf() comment, return length of printed message Kwarde 2025-06-25 13:56:30 +02:00
  • d0769f6ffc Add support for %c in printf() Kwarde 2025-06-25 13:49:30 +02:00
  • 74178a6a2d FIX: Loading arg from stack to wrong register (rsi->rdi) for %d Kwarde 2025-06-25 13:43:06 +02:00
  • 266cb57d1c Proper SYS V ABI use (don't restore rsi in itoa) Kwarde 2025-06-25 13:31:48 +02:00
  • f5e1143138 Fix issue in printf() with %d --needed to push+pop several registers before/after itoa() call Kwarde 2025-06-25 13:29:26 +02:00
  • 4438abda11 Dump current state of printf() (adding %d support), adds itoa() Kwarde 2025-06-25 13:07:18 +02:00
  • 1de7731139 printf() comment cleanup Kwarde 2025-06-25 12:12:26 +02:00
  • 3a55212f3e Fix stack usage for printf(), add test Kwarde 2025-06-25 12:00:05 +02:00
  • 7054061734 Working '%s' for printf() (args in stack yet untested) Kwarde 2025-06-25 11:42:44 +02:00
  • 855487e857 printf() no longer crashes, can print string but now aborts after printing first string Kwarde 2025-06-25 11:31:01 +02:00
  • dcb2b8acae Start writing printf() D: Kwarde 2025-06-25 11:08:56 +02:00
  • 1969294f02 Use direct value for mode in fopen() instead of pointer -- mode is always 1 char so no need to store mode letters in memory Kwarde 2025-06-25 10:15:21 +02:00
  • 692c96512e Return -22 (EINVAL) in fopen() if incorrect mode was supplied Kwarde 2025-06-25 10:09:23 +02:00
  • 06fef96cf4 Fix return value comment for fwrite() Kwarde 2025-06-25 10:03:57 +02:00
  • c4ce3212e7 Assure fwrite() and fclose() only work if FD>=3, exit with -9 (EBADF) otherwise Kwarde 2025-06-25 10:02:59 +02:00
  • 3cbf9e8ce0 Fix file.asm return value comments Kwarde 2025-06-25 09:56:40 +02:00
  • fbea8d0322 Adds fopen(), fwrite(), fclose() Kwarde 2025-06-25 09:38:42 +02:00
  • 9d265e3db6 Fix strcmp() Kwarde 2025-06-25 08:35:25 +02:00
  • 6df67b18f4 Improve todo/fix comment for strcmp Kwarde 2025-06-24 19:08:00 +02:00
  • 7dd7217e08 Improved test message (msgStrcmp) Kwarde 2025-06-24 19:07:30 +02:00
  • 6cb90256e7 Fix return value comment for strlclr() Kwarde 2025-06-24 19:00:43 +02:00
  • 354024c1b7 Rewrite tests (most accidentally done in previous commit), add TODO (bugfix) in strcmp() Kwarde 2025-06-24 18:45:17 +02:00
  • e2de729a87 Adds strclr() and strlclr() Kwarde 2025-06-24 18:29:18 +02:00
  • 46051d0082 FIX: strcat() returning wrong address Kwarde 2025-06-24 17:53:56 +02:00
  • 035f3baabf Restore NL in console.asm -- syscall 1 requires mem addr, not constant 0xA Kwarde 2025-06-24 17:02:49 +02:00
  • 2005adf25f Use NL/EOS instead of 10/0, use constants.asm for global constants Kwarde 2025-06-24 16:34:06 +02:00
  • e48e91630e Fix test msg/comment (size for strlcpy 8=>5) Kwarde 2025-06-24 15:54:32 +02:00
  • e620754b13 Adds strlcpy() Kwarde 2025-06-24 15:53:24 +02:00
  • d3e7f47259 Store rcx to r11 instead of stack in tolower()/toupper() tests Kwarde 2025-06-24 15:08:54 +02:00
  • f10b2f3c88 Save/restore rdi to r10 instead of stack in strcat(),puts() Kwarde 2025-06-24 15:06:21 +02:00
  • f4162ed21a (alternative) strcmp() Kwarde 2025-06-23 17:46:42 +02:00
  • 63552b3c64 Allow enabling/disabling tests Kwarde 2025-06-23 17:16:24 +02:00
  • 84264e7f5a Test toupper() and tolower() for entire string Kwarde 2025-06-23 17:10:56 +02:00
  • 6463c3711a FIX: Return value of strcpy() Kwarde 2025-06-23 16:28:05 +02:00
  • 2e7a7c7b5f Fix: EOS not copied to dest in strcpy() Kwarde 2025-06-23 16:21:21 +02:00
  • d718f1ff1d Don't zero rax in tolower/toupper; they both call islower/isupper which already zeroes rax Kwarde 2025-06-23 15:59:40 +02:00
  • acd0afbeba Fix jumps in tolower/toupper; .dtu/.dtl would always be reached. Kwarde 2025-06-23 15:55:38 +02:00
  • 3ec591aab4 tolower(), toupper() Kwarde 2025-06-23 15:47:05 +02:00
  • ed83e83885 Set rax to original rdi in strcat() (make sure dest pointer is returned) Kwarde 2025-06-23 15:35:41 +02:00
  • 0ee1142b75 Add null terminator to dest in strcpy() Kwarde 2025-06-23 15:32:40 +02:00
  • e92afdb199 Remove unneeded saving of rdi in strcpy() Kwarde 2025-06-23 15:30:39 +02:00
  • 26c150cec0 Remove unneeded saving of rdi in strcat() Kwarde 2025-06-23 15:27:02 +02:00
  • 4aee0916db Remove unneeded saving of rdi in print() Kwarde 2025-06-23 15:25:10 +02:00
  • c798157fd8 Use conditional moves in max[u]()/min[u]() Kwarde 2025-06-23 15:24:30 +02:00
  • 3a7b0b5cda Add clean to makefile Kwarde 2025-06-23 15:14:56 +02:00
  • 2f5e3202db min[u](),max[u](),islower(),isupper(),print(),puts(),strlen(),strcpy(),strcat() Kwarde 2025-06-23 15:07:55 +02:00
  • 4820e6242f Add makefile Kwarde 2025-06-23 06:41:52 +02:00
  • 0d6b2465c6 Ignore tests, .o, .lst Kwarde 2025-06-23 06:40:57 +02:00
  • aa2e19e7ae Init repo Kwarde 2025-06-22 06:57:41 +02:00