VOGONS


First post, by Harry Potter

User metadata
Rank Oldbie
Rank
Oldbie

Hi! I have a library for the cc65 compiler called CBMSimpleIO. cc65 is a C compiler that runs on modern computers but targets some 8-bit computers. CBMSimpleIO is a replacement for some of standard C's text I/O functions such as printf() that is much more efficient. It does this by interfacing with the OS directly rather than doing a lot of extra processing. Now, I'm wondering if I should port it to some DOS-target C compilers. If so, I need to know how to handle assembler-based __fastcall functions. I also want to be able to print longs and unsigned longs. In order to do this, on 16-bit computers, I usually need to do extra work. On the 8086 and 286, how do I perform the 32-bit divide by 10 needed to convert to decimal/ANSI?

Joseph Rose, a.k.a. Harry Potter
Working magic in the computer community

Reply 1 of 4, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie

hmm well what do you call "more efficient" watcom already has assembler for 64bit multiply + divide of uint32_t.. and it works on 8086 too... and in 32bit watcom I dont see the point of trying to optimise printf.

unlike 8bit home machines like the c64, the pc doesnt really have routines in rom per-se, it as the bios and really only uses the disk int13h stuff....

--/\-[ Stu : Bloody Cactus :: [ https://bloodycactus.com :: http://kråketær.com ]-/\--

Reply 3 of 4, by jakethompson1

User metadata
Rank Oldbie
Rank
Oldbie

On 8086, you can divide a 32-bit quantity in DX:AX by a 16-bit quantity, but only if both the remainder and quotient both fit in 16 bits (otherwise it triggers an exception).

You might read up on how compilers might optimize a divide by 5, from which you could derive divide (and remainder) by 10: https://stackoverflow.com/questions/41183935/ … ng-integer-divi

Reply 4 of 4, by Jo22

User metadata
Rank l33t++
Rank
l33t++

Why don't just use x87? The poor fellows without an NPU can run EMUL87.

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//