Shortened Assembly printf library implementation for Windows.
The idea is to understand how printf works from the inside and understand the intricacies of writing applications for the Windows system in NASM using the Windows API.
There are %%, %c, %s, %d, %x, %o, %b (%b stands for "convert number to binary format") specifiers.
- Strlib contains
btoa,printString,PrintChar,itoa,memset. - Winlib contains macroses-wrappers for Windows API:
GetStdHandle,WriteFile,ExitProcess. - Printflib contains only
_myPrintfimplementation.
switchis implemented viajump table.itoais implemented with the faster division if the given base (radix) is a power of two.GetNextPrintfArgumentfunction gets each new unproceed printf argument using global variable (it is assumed that the number of arguments passed afterformat stringis not less than the number of specifiers in it).
Compile, link and run examples:
cd examples
nasm.exe -f win32 ownPrintf.asm -o ownPrintf.obj
gcc.exe -m32 -o ownPrintf
.\ownPrintf.exe
Compile printflib.asm , link and run with another program (e.g. with C program)
cd examples
<path_to_nasm_assembler>\nasm.exe -f win32 ..\lib\printflib.asm
<path_to_mingw32_gcc>\gcc.exe -c test.c -o test.o
<path_to_mingw32_gcc>\gcc.exe test.o ..\lib\printflib.obj -o test.exe
.\test.exe
