OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 1:17 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Mon Feb 13, 2017 8:41 am 
Offline
Member
Member
User avatar

Joined: Wed Aug 17, 2016 4:55 am
Posts: 251
Brendan wrote:
If it's meant for computers it becomes easy - use binary instead of text. If you must use text, then go "concise and precise" with hexadecimal (e.g. maybe "0x1234567 >> 16"). ;)

Sometimes you want to make it easy for programmers to see quickly =P That and avoids the arguments about the exact format to use (pragmatic vs ideal vs let's overengineer it because enterprise say so), if you store a floating point number as text, then the binary format is up to the parser. (also for some kinds of data heavy on numbers it turns out they can compress better)

Brendan wrote:
I'm not sure that it's possible for someone to care enough about Internationalisation to be willing to use what C provides, while also caring so little about Internationalisation that they're willing to use what C provides.

Still better than nothing, if you're going to complain about failing something as simple as grouping (which the standard library does handle). So in that sense there's no excuse, other than most programmers likely not even being aware or outright not caring (in fact I have never bothered to look into it yet - come kill me =P).

Maybe the biggest problem is precisely that it's not blatantly easy to use, would have been nice if it was a parameter to printf-style arguments (then everybody would learn it exists when they're taught the list of modifiers). Similar deal for whatever else any other language prefers to use.

In any case, going back on topic, that probably should be seen as an enhancement to the base algorithm =P (if you can get the number as a string in the most simple way possible, you can start tacking on whatever else is needed on top of it)

Brendan wrote:
I'd be tempted to blame ASCII for "lower case x" (e.g. "1920x1200") too. :)

It's related! (and that most keyboard layouts make it too hard to type ×... I have it mapped on an AltGr key and none of those other than @ and € are labeled on the keyboard at all, nor do many people know that AltGr gives more shift levels)


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Mon Feb 13, 2017 10:41 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
Brendan wrote:
Sure; in mathematics "variables" typically can't be varied (not in an "x = x + 1" way), and yet somehow it's programmers that got it wrong despite being able to distinguish between "constants" (that don't vary) and "variables" (that do vary).


Thing is, a mathematical variable doesn't ever hold a value at all; it represents the idea of variance, not a specific value or even set of values. It is saying, "this is something that can vary depending on a relationship to something else". Mathematical variables aren't values.

When you write x = y + 5 in a mathematical equation, you aren't saying that x is now equal to y plus five; you are saying that x varies according to a relationship with y in a way that is stateless. Neither x nor y actually ever mean something like '2' or '3.1415...' or anything else; they are literally just placeholders. They don't actually mean anything other than "I want to relate one set of values to another".

To put it another way, the problem is really that people have historically confused mathematics, which is a stateless set of assertions, with computation, which is a stateful process. This is one of the things that has seriously messed up the whole field of informatics (a terrible term but still better than the nonsensical "computer science"), because it mixes up several really different things - computation and mathematics are related, but by no means the same, and informatics is itself only tangentially related to either of them.

As for the representation issue, let me ask: when was the last time you actually wrote a number larger than 99 as a literal, in a context where it was actually a number to be used in a computation rather than, say, a loop index, or a bitmask, or an ID code (that is to say, a number used to tag the identity of something)? I'm not going to defend the way programming languages handle numerical literals - that's an open-ended cesspit that better minds than mine have failed to solve - but I will point out that the need to fix it just hasn't been there for most of the past seventy years.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sat Feb 18, 2017 10:21 am 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
Schol-R-LEA wrote:
Some points to be made:

  • The fact that programming overloads the term 'variable' in a way inconsistent with the mathematical meaning, yet all too often tries to read program variables as if they actually were mathematical variables, is our fault, not that of the mathematicians. We should have called them something else from the beginning, because they are really something entirely different from mathematical variables and the analogy had already broken down before Backus had finished the first FORTRAN compiler.
Maybe they aren't different, they more likely have an incomplete set of mathematical properties. For solving that, you would need not just extended precision numbers, but structure-enabled CPU/FPU instruction sets that contained those 80, 128 or 256-bit real numbers, and that also contained a space to store Algebraic-type variable names, Algebraic-term data types, and records for all possible mathematical properties, returned in a dynamic way, just like the E820h memory maps of the CPUID depending on what you want to calculate and obtain (or everything, even if it's huge).

Computers are based in boolean arithmetic (a simplification of math towards unsigned integers and a counting system with base numbers 0 to 1 -binary-).

There's nothing in the computer that hasn't been defined mathematically, but it's extremely poor in terms of proper math. Even with its floating point capabilities, it just has an arithmetic level of function in the available CPUs, and some basic Trigonometry, much like a calculator, maybe less if we talk about the instruction set. Anything not mathematically defined, simply cannot be inside the computer.

We might have powerful floating point data types, but the only thing that the CPU really exposes fully has only arithmetic level, not algebraic, just arithmetic, along with very simple plain floating point data types with nothing else, or very little, too partial, and that's the problem.


_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
For example, think about how we could implement an instruction set, at least emulated, to perform algebraic operations. We would need to separate the precedence of the terms (the things that multiply each other) from the secondary precedence of + and - signs, and group accordingly by terms.

Such instruction set should be able to solve any algebraic expression with or without the values of the variables, up to the point where it's actually possible to solve and simplify, and return strings, and more than that, a set of structures for the terms in a way that we know how to re-write in standard Math formulas (from special numerical structures to expressions natively).

Implementing the whole set of Math, properties, concepts, laws, cases, etc., would simplify, standardize and make it readily usable to programmers, and it would be much easier to understand and emulate those functions, and also faster to implement purely mathematical applications.

It can be done with regular programming by implementing those functions, but if you want to massively perform purely mathematical analysis in purely mathematical terms natively, that's something that still needs to be added to CPUs.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sat Feb 18, 2017 1:40 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
I get the impression that either you didn't read my later post, or you didn't understand it.

Let me put it another way: the majority of working mathematicians never work with any actual numbers except for a handful of fundamental constants such as one, zero, e,i, and π - and they almost never reference the actual values of those constants, just the relationships they have to the logical entities they are working with. It is rare for a mathematician to have to compute a value for anything.

There are well-known stories of mathematicians and theoretical physicists working on the Manhattan Project complaining about the fact that they suddenly were confronted with actual values, and how unaccustomed to that most of them were.

It is no accident that the words 'algorism' (the process of computing by means of transforms on Arabic numerals, which was a radical thing when it was introduced to Europe in the 15th century) and 'algorithm' (a much more modern - mid-19th century - word derived from 'algorism', meaning a description of the process by which a specific value could be computed) were relatively obscure before the introduction of modern calculating hardware.

Mathematics isn't about computation. The idea that everything in a computer system is mathematical is laughably wrong, and does a disservice to both mathematics and computers.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sat Feb 18, 2017 4:49 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
Schol-R-LEA wrote:
I get the impression that either you didn't read my later post, or you didn't understand it.

Let me put it another way: the majority of working mathematicians never work with any actual numbers except for a handful of fundamental constants such as one, zero, e,i, and π - and they almost never reference the actual values of those constants, just the relationships they have to the logical entities they are working with. It is rare for a mathematician to have to compute a value for anything.

There are well-known stories of mathematicians and theoretical physicists working on the Manhattan Project complaining about the fact that they suddenly were confronted with actual values, and how unaccustomed to that most of them were.
That makes as much sense as someone writing source code, but here the exciting thing is that we only use our brain. Somebody formulates theorems and other concepts instead of programs, and somebody else uses them, but there always needs to be at least logical calculations in thousands of years of meditation.

Schol-R-LEA wrote:
It is no accident that the words 'algorism' (the process of computing by means of transforms on Arabic numerals, which was a radical thing when it was introduced to Europe in the 15th century) and 'algorithm' (a much more modern - mid-19th century - word derived from 'algorism', meaning a description of the process by which a specific value could be computed) were relatively obscure before the introduction of modern calculating hardware.

Mathematics isn't about computation. The idea that everything in a computer system is mathematical is laughably wrong, and does a disservice to both mathematics and computers.
Current CPUs, and even more existing software (at least the part understood by most people), is not as complete and modern as Math itself. Mathematics needs to be introduced fully and formally into computing and computers to be able to perform massive mathematical analysis natively, without libraries or with optional ones, but with all functions implemented in the CPU/FPU.

And well, I can't think of something that isn't mathematical in a computer. Maybe it isn't even algebraic, trigonometric or even arithmetic, maybe only sequential, but if it's numerical and if it needs to be accessed numerically, then it's purely mathematical:

- Strings are mathematical values with ranges and sizes, which can be compared for any imaginable purpose. There could easily be string characters with floating point values for some special purpose.

- Bytes are just a series of values from 0 to 255, or from -128 to 127.

- I/O and memory ranges are numerical.

- Comparisons substract two values to see if they are ==, <, <=, > or >=; or at the very least operate with bits in practically the same way, purely numerical.

- Images, sound and codes like keystrokes/scan codes, device commands, etc., as well as the algorithms to encode, compress and store, are all numerical at least at a basic level. They all need to compare numbers, character or string values and nothing else, apart from logic/loops/functions/mathematical series, which also use numerical addresses, counters, etc., just like mathematical formulas of Sine...

- Encryption, unbreakable or extremely poor, always ends up being numerical to encode and reconstruct the values, and it could use as much logic and elements as a programming language and as any high complexity process in mathematics reciprocally.


Please tell me about something that can be stored and processed by a computer that in the end doesn't end up being converted as a set of numbers. I can't think of no device or file format that doesn't use numbers and high or low mathematics to yield the usable results as software and user data.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sun Feb 19, 2017 9:31 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
~ wrote:
Please tell me about something that can be stored and processed by a computer that in the end doesn't end up being converted as a set of numbers. I can't think of no device or file format that doesn't use numbers and high or low mathematics to yield the usable results as software and user data.
Mathematics != numbers and arithmetic. I think, in the context of this discussion, "mathematics" refers to more abstract kinds of mathematics, such as those involving variables, functions, and so on. That stuff is, while superficially similar, considerably different in computing. Mathematics is mostly about determining relationships between values and using those relationships to determine the values; computing is about using known relationships between values to calculate one value from another value.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sun Feb 19, 2017 10:09 am 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
The computer is purely numerical, so it cannot be denied that its nature is purely mathematical.

Even if we don't use any calculations in the surface, even at the lowest assembly level, the internal circuitry always needs to perform basic arithmetic in the form of additions and subtractions for being able to find I/O and memory addresses, to increase instruction and stack pointers, to record S.M.A.R.T. data, to keep track of the time, etc.

What it lacks is a proper instruction set and low/high level language structures to manage Mathematics and related analysis fully and formally so that a mathematician could use the CPU and machine in general and perform analysis tasks without the need of libraries or an OS.

Anyway, what I suspect is that some elements like tables from high-precision side rules/slipsticks/calculus rulers have been included into the FPU to get complex values and calculations as fast as possible, but only an extremely low number of functions and instructions for math are included, and additionally, they are extremely basic, so future CPUs should no doubt become fully specialized for Math besides the current instructions, to be more suitable for truly heavy duty applied tasks of that sort.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sun Feb 19, 2017 11:58 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
I repeat my earlier statement: you are confusing calculation, which is transformations of numbers, with mathematics, which describes the properties of numbers. While they have historically been considered the same thing, that is not how most modern mathematicians see them today.

In any case, your whole argument involves a confusion of levels, and for that matter, a confusion of what computers actually do. It is no more sensible to say, "computers work only on numbers" than it is to say, "computers work only on electrical impulses", despite the fact that they are both true (and indeed, the latter is arguably 'more true' than the former, as it is what is actually physically occurring, while the former is an interpretation we impose on the impulses).

The fact that a string might be made up of a pattern of electrical impulses which we choose to interpret as numbers, which we further interpret as encoding a series of letters and other symbols, doesn't say anything about the semantic value of (say) the Shakespearean sonnet which that string itself encodes. The levels of electrical impulses, of the pattern which can be treated as numbers, or of the characters which the numbers in turn encode, isn't relevant to that. Those are simply the media by which the message is carried, and contrary to what Marshall McLuhan would say, the message is mostly independent of the medium.

I would in fact say that too great an emphasis on the supposedly 'mathematical' nature of computers - an emphasis ingrained in the rather unfortunate name we have given these general-purpose symbol manipulators - has been one of the worst mistakes the field has made. The overwhelming majority of things we use them for are not really computations at all; indeed, as I have already stated, 'computation' is itself an interpretation of the machine's actions, not its inherent nature. Most of the things we use computers for today are things such as social communication (like what were are doing right now, how Hofstadterian), and trying to understand that in terms of mathematics - or computation, take your pick - is pretty much hopeless, even if you are talking in a purely information-theoretical sense.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sun Feb 19, 2017 1:05 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
In that sense, as a minimum, CPUs currently have the capability to count and identify numbers.

We also learn about math in that same way since we are little children, so I see no reason not to call that the same thing.

We know that we have some mathematical functionality and powerful real number native data types, but the next thing we need from a CPU/FPU/GPU/APU is being able to feed it an algebraic expression with any number of variables, no matter if we need to use a low level yet efficient array of structures for the algebraic terms, and have that CPU simplify and solve it up to the point where it's really possible, in the most optimum way, and that it can return us either step by step, or only the final result.

That's the point where I see that current CPUs fall short of advanced mathematical functions. They are truly basic in what they have. The rest needs to be implemented in software currently.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sun Feb 19, 2017 1:13 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 17, 2016 4:55 am
Posts: 251
I'm surprised this whole (derailed) discussion came over arguing the term variable yet nobody ever pointed out how functions are a probably much worse offender. Especially since both the name and the syntax we use to call them comes from BASIC, yet functions in BASIC were a completely different beast much closer to their mathematical counterparts (what we call functions today were actually called subroutines in BASIC, and they had a completely different syntax there).

Now, the way calling subroutines in BASIC sucks (no way to pass arguments nor to declare local variables, ew), but I wonder how things would be if we had come up with a better way to invoke them that doesn't involve having memorized what each argument is meant to be. That's probably a bigger seatback than anything else discussed here, since it heavily slows down code comprehension (and hence productivity as well as increasing the chance of writing buggy code).


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sun Feb 19, 2017 1:22 pm 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
~ wrote:
We also learn about math in that same way since we are little children, so I see no reason not to call that the same thing.
Technically that's arithmetic. It's a minute subset of mathematics that forms the building-blocks of other, more advanced, areas of mathematics. So you can refer to computing/programming as being based in arithmetic.
Sik wrote:
I'm surprised this whole (derailed) discussion came over arguing the term variable yet nobody ever pointed out how functions are a probably much worse offender. Especially since both the name and the syntax we use to call them comes from BASIC, yet functions in BASIC were a completely different beast much closer to their mathematical counterparts (what we call functions today were actually called subroutines in BASIC, and they had a completely different syntax there).
I hinted at the difference between functions in mathematics and functions in programming in my previous post:
onlyonemac wrote:
I think, in the context of this discussion, "mathematics" refers to more abstract kinds of mathematics, such as those involving variables, functions, and so on.
What's "better" or "worse" is subjective, and in my opinion there is no such thing as "better" or "worse" here, since there's nothing to compare. They're completely different fields with their own terminology. The fact that one branched out of another in some way is pretty much irrelevant.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Sun Feb 19, 2017 9:57 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
The fact that learning to apply computing to define proper programs to solve the full range of mathematical problems makes Mathematics more understandable and capable of letting us solve more problems without getting mentally exhausted, proves that programming and Math are part of the same way of thinking.

They add and support each other, so both end up being dramatically more robust in our brain and in the machines we apply it when used together.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Top
 Profile  
 
 Post subject: Re: Tutorial: Printing FPU Floating Numbers in Pure Assembly
PostPosted: Mon Feb 20, 2017 12:50 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

~ wrote:
The fact that learning to apply computing to define proper programs to solve the full range of mathematical problems makes Mathematics more understandable and capable of letting us solve more problems without getting mentally exhausted, proves that programming and Math are part of the same way of thinking.


Don't be silly.

Nothing in a computer is a number. For digital computers there are only "high" and "low" states. For convenience we interpret groups of states as numbers even though they aren't numbers. We don't even use the same interpretation consistently - the same group of states (bits) can be interpreted as signed or unsigned or floating point or something else.

Computers will never be able to do basic arithmetic correctly; because RAM and performance will always cause precision and range limitations. Instead, computers do their own form of computation that only vaguely resembles arithmetic if you're lucky. 5 divided by 3 equals 1; 4 billion plus 4 billion equals 3.7 billion; the number of seconds in a Century plus 3 nanoseconds equals the number of seconds in a Century.

Every piece of useful software that has ever existed, and every piece of useful software that will ever exist, is useful because it doesn't use actual mathematics. Even if you ignore the impossibility of arithmetic; actual mathematics lacks things like flow control, and interrupts/signals, and has no concept of "cost of each operation", and has no concept of "sequence" (in a "this operation occurs before that operation" way).

~ wrote:
They add and support each other, so both end up being dramatically more robust in our brain and in the machines we apply it when used together.


No. If I use mathematics to describe what some software does (or should do), that does not mean that computing is mathematics. In the same way, if I use English to describe what some software does (or should do), that does not mean that computing is English.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 38 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 © 2000, 2002, 2005, 2007 phpBB Group