It is currently Fri Aug 23, 2019 2:29 am

All times are UTC - 7 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Jul 14, 2019 5:38 pm 
Formerly Espozo
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3501
Location: Richmond, Virginia
I got around to re-implementing sprintf in x86-64 assembly using NASM's macro features: ... printf.asm

Example usage:
   mov r15, 1000
   sprintf outBuffer, `Value of r15: %#010lX\n%ln`, r15, r10,
   write STDOUT_FILENO, outBuffer, r10

   Value of r15: 0X000003E8

As such, it cannot parse the format string at runtime, although honestly, I have never felt the need to do this. Additionally (and this actually is a problem) there's no floating point support right now, due to having no idea how to implement that sort of thing. If anyone has an idea on what to do for this, I would greatly appreciate it. Everything else (that I know of) is there though.

PostPosted: Tue Jul 16, 2019 5:33 am 

Joined: Fri Feb 24, 2012 12:09 pm
Posts: 972
Runtime parsing would be smaller (if you have a lot of strings (or wasteful if otherwise)).

For floating point, just use the Fxxx FPU opcodes, something like fdiv by powers of 10, then grab the resulting digits as integer... that would be my first idea. Or are you up to something else?

The other functions - wow - you have some pretty surprising optimizations in there, recip(r)o(ri)cal multiplication for displaying decimal numbers, and MMX instructions for hex numbers, I have never ever considered to optimize numeric text output as if it were a cinematic high-end 3D video engine.

PS. Did you thought about implementing GPU and multi-core CPU support for even faster printing ; )

homepage - patreon

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group