News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_HAL6128

Just a question from a newbie in assembler

Started by HAL6128, 12:08, 07 March 12

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TFM

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Executioner

Quote from: hal 6128 on 08:33, 04 April 12
Yes, you're right. "denn" has the same meening as "als". So: "than = denn" and "then = dann". Oh, shitty... :-\

They must be teaching German to all the students in the US now then :)

Bryce

Quote from: TFM/FS on 19:57, 04 April 12
Oachkatzlschwoaf!

And who said the Bavarians can't speak Hochdeutsch :D

Bryce.

MaV

Quote from: Bryce on 13:00, 05 April 12
And who said the Bavarians can't speak Hochdeutsch :D
Ah, but they do. And it's about time that the Northern German speakers accept the Southern dialects as equal because by number of speakers alone we're more (Southern Germany, Switzerland and Austria). Language diversity is the motto, because the language "Hochdeutsch" is but a convention to ease communication. In the end it needs the dialects to enrichen it, otherwise it'd be as clean and sterile as Latin is today.

Imagine English without Cockney, Mancunian, Irish, Scottish, Australian English!
brrr!
Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

Bryce

As someone who normally speaks Kölsch, my comments on Hochdeutsch shouldn't really be taken all that seriously :D

Bryce.

beaker

#30
Quote from: MaV on 13:40, 05 April 12
Ah, but they do. And it's about time that the Northern German speakers accept the Southern dialects as equal because by number of speakers alone we're more (Southern Germany, Switzerland and Austria). Language diversity is the motto, because the language "Hochdeutsch" is but a convention to ease communication. In the end it needs the dialects to enrichen it, otherwise it'd be as clean and sterile as Latin is today.

Imagine English without Cockney, Mancunian, Irish, Scottish, Australian English!
brrr!

What? You've never heard of the North/South divide in England? Neither have really ever accepted each other...

England North/South Divide

MugUK

I tried explaining the North/South Divide to my friend in Oldenburg who runs the retro museum there.

I also tried defining how close the gap was between accents (esp. in the North) from the tip of the North Wales coast all the way along to Manchester then onto Yorkshire.

As for the North / South Divide in Germany, I have only visited the South once (last year) and was happy to able to pronounce 'bread' down there as for the life of me I can't get my tongue around the umlauts in the Northern word for it :)


I love poking (and peeking) around files.  I used to write saved-game editors on the Atari ST (and Amiga) using GFA BASIC, so looking forward to having some fun with my 6128 :)

beaker

I always use Mars Bars to work out the North/South divide in the UK. You're in the South up to the point where the locals think good food is frying a Mars Bar in batter...  ???

MaV

Quote from: beaker on 16:23, 05 April 12
What? You've never heard of the North/South divide in England? Neither have really ever accepted each other...
I've heard of it, but never perceived it to be so problematic.

Then again, my one and only trip to England (and Scotland) has been 18 years ago for three weeks. Not enough to recognise the seriousness of this.
The media distorts the picture somewhat, series like Life on Mars (the guv) rather glorify the North (or perhaps I've just overlooked the movies about the divide.)

Personally, I prefer the pronounciation of the North (sorry, Southerners!). The sounds - especially the vowels - have retained the original qualities and therefore sound more continental. The u-sound in cup should be a shortened "oo". Linguistically the southern dialects are a recent development - measured in hundreds of years, of course.

Yeah, I know. I'm standing in a minefield now waiting about what's to happen next. :D
Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

HAL6128

...just another quick question:
could somebody explain me like a six year old child how a floating point number will be brouht into the RAM of the CPC and how to read it out?
I've read something about in the Firmware or "whole memory guide", but... no clue.
for example "43.375" is in memory "00 00 80 35 86". How are the conversion/calculations rules?
I know that most left byte = LSB and the forth byte = MSB and the most right byte = exponent. That's all!??
Cheers!!
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

MaV

Quote from: hal 6128 on 20:53, 15 April 12
...
for example "43.375" is in memory "00 00 80 35 86". How are the conversion/calculations rules?
I know that most left byte = LSB and the forth byte = MSB and the most right byte = exponent. That's all!??
First of all, there is no way a six year old will be able to understand that, unless he's a genius.

Second, your representation of 43.375 in memory is wrong. It should be "00 00 80 2D 86".

This link might help:
Technical information about Locomotive BASIC - CPCWiki - The Ultimate Amstrad

But I have to say the order of the mantissa bits in the structure is also wrong!

The first byte contains the least significant bits of the mantissa, and every following byte up to the fourth byte contain the bits following the first in significance and in exactly that order!

That means that you have to turn around the first four bytes if you want to read the mantissa correctly:
2D800000
or
0010.1101.1000.0000.0000.0000.0000.0000
in binary (the stops are inserted for better readability).

Now the highest significant bit here is 0, so the number is positive.
What's more, you need to clear that bit and substitute the implied highest bit (see description in the link), which is always 1 (regardless of the deleted sign bit!!!).
Thus you get:
AD800000
or
1010.1101.1000.0000.0000.0000.0000.0000
in binary.

The mantissa has an implied decimal point before the number. Since the number is 2^32 bits (i.e. 4 bytes) long you have to divide by 2^32 to get the proper decimal representation.

AD800000 (hex) = 2910846976 (dec)

2910846976 / 2^32 = 0.677734375

The mantissa in a decimal representation is: 0.677734375

Now, the last byte contains the exponent: 86 (hex) or 134 (dec). You need to subtract 128 to get the real exponent, the highest bit tells you that the exponent is positive (1) or negative (0). Your exponent is 6.

0.677734375 * 2^6 = 43.375


Another example:
PI is represented in memory as:
A2 DA 0F 49 82

The mantissa is
490FDAA2 (highest significant bit is zero => number is positive)
The exponent is
82 (=positive mantissa, value=2 thus multiply mantissa with 2^2)

Delete the sign bit (which is 0 anyway), and then add the implied 1 bit:
C90FDAA2 (hex) = 3373259426 (dec) = 1100.1001.0000.1111.1101.1010.1010.0010 (bin)

Calculate the decimal representation of the mantissa:
3373259426 / 2^32 = 0,7853981633670628070831298828125

Then add the exponent (82h - 80h = 2 thus 2^2)
0,7853981633670628070831298828125 * 2^2 = 3,14159265346825122833251953125

Voilà! The internal representation of the number PI on the CPC is: 3,14159265346825122833251953125

If you compare to a (more) correct representation of PI, you'll see that the CPC is correct up to the 9th decimal place:

CPC:
3.14159265346825122833251953125
more correctly:
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986...


Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

HAL6128

#36
Yes, I got it!  ;D

Thank you very much for the good reproducible explenation!!!
Now I understand. (Honestly no, I still don't what is happening inside the Z80 when calculating with floatings but for the first it's ok)
Wow, calculation with a floating point is a real pain in the ass / time consuming...

I've changed the wiki page "technical information" for BASIC with the structure information into the right Bit order.
Is it ok for you, if I add your description and explenation to the "technical information"??
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

MaV

Quote from: hal 6128 on 12:22, 16 April 12
Thank you very much for the good reproducible explenation!!!
You're welcome!

Quote
Now I understand. (Honestly no, I still don't what is happening inside the Z80 when calculating with floatings but for the first it's ok)
Wow, calculation with a floating point is a real pain in the ass / time consuming...
The floating point code in the wiki is the next step. But I don't see quite the need to know it inside out to understand the principles.
And remember that the CPC almost always does the painful work for you.

Quote
I've changed the wiki page "technical information" for BASIC with the structure information into the right Bit order.
Is it ok for you, if I add your description and explenation to the "technical information"??
Yes, if this will help others understand the floating point format in the CPC, copy this into the wiki.

TBH, it was a bit late in the night, and I haven't thought about that.
Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

Powered by SMFPacks Menu Editor Mod