Hello,
We stduying the 8086 and 386 using boarland linker.
while stduing for a test I have I came across a queation about menaging and printing 64bit numbers.
the numbers are represented as an array of chars (8) and I need to implement a rutine that puts the number in a string.

If it was a 32 bit number (long int) or 16 bit I would have just use a loop that does modulo 10, add the hascii of zero and put that in the string.
but the problem is I cant do the idiv/div action for 64 bit( if I divide by dword than it will work on EDX:EAX and thats what I want but the answer is than put to EDX and EAX and then I get devide overflow...

The form of the question (translated):
"In the following exercise you need to support actions on long long unsigned integers that are 64bit long. (8 bytes).
The inner representasion of the numbers will be the same as unsigned int (16bit) or long unsigned int (32bit).
Remeber that bytes in the memory are in order of significase meaning:
if the number takes adresses 1000-1007 than adress 1000 will store the least segnificant byte and the 1007 the most.
You are not allowed to use the Floate Proccessing unit, it does not support unsigned number anyway.
The c definition of the 64 bit number is:
typedef char INT64[8];
You are to write two assembly function called from C's main:
1.
extern void INT64tostr( char str[], INT64 ptr );
str is a string into which you need to put a 64bit number ptr (remember ptr is pointer to array)
2.
extern void addINT64( INT64 ptr3, INT64 ptr1, INT64 ptr2 );
This rutine needs to sum two 64bit numbers and put in the third
remember all perameters are pointers.
You need to write it in model small. "

and it goes on with an example of printing fibonatchi numbers that goes really high...

I do not expect for you guys to completely solve this (unless you want to) but more of an algorithm on how to do the first one, as I said before the problem for me is puting in a string...
The second one is easier, I just do ADC (add with carry) for all but the first bytes and put that respecivly in the new array...
Its the first one I got stick with...
Thank you all in advance
John Rose

Recommended Answers

All 2 Replies

Nothing in the assignment says that you have to print them as decimals. Just print them as hex. You may want to clarify it with your professor though.

It does mean decimal, it implies. they also gave an uotput example out of C main for fibonatchi, that uses the sum rutine to add two memebrs and the string rutine to prints it as %s and it is decimal.
Fibo(3) = 2
Fibo(4) = 3
Fibo(5) = 5
Fibo(6) = 8
Fibo(7) = 13
Fibo(8) = 21
Fibo(9) = 34
Fibo(10) = 55
Fibo(11) = 89
Fibo(12) = 144
Fibo(13) = 233
Fibo(14) = 377
........
Fibo(70) = 190392490709135
Fibo(71) = 308061521170129
Fibo(72) = 498454011879264
Fibo(73) = 806515533049393
Fibo(74) = 1304969544928657
I can write each byte as two hex digits, than I'll have a 16 digits number in hexa. will that get me closer to the answer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.