Learning Assembly and computer architecture for x86

Click For Summary
Learning assembly and computer architecture for x86 involves understanding the differences between CISC (Complex Instruction Set Computing) and RISC (Reduced Instruction Set Computing) architectures. The discussion emphasizes starting with a C compiler to generate assembly code, which aids in understanding the underlying processes. It is noted that modern x86 assembly is complex and rarely used for full programs, with high-level languages being more effective for most applications. Resources like Intel's programmer's reference manual and various assembly programming books are recommended, but the importance of practical experience is highlighted. Ultimately, gaining foundational knowledge through existing systems and gradually expanding one's understanding is advised.
  • #91
pbuk said:
I don't think that is true any more, at least not in the UK or Europe, but I'd be interested in any reference.
In 2001, the U.S. Securities and Exchange Commission (SEC) mandated "decimalization" for all U.S. stock markets (xx 3/4 becomes xx.75). In the US in 1792 the coinage act established decimal currency. The main issue is decimal fractions like 0.1 can't represented exactly with binary floating point. I'm not sure about non US laws or standards, but if the currency is in decimal, then it would make sense to have the math done in decimal to avoid rounding issues or inconsistencies between financial institutions.
 
Technology news on Phys.org
  • #92
rcgldr said:
The main issue is decimal fractions like 0.1 can't represented exactly with binary floating point.

But any problems with that can be solved by storing values as cents and using integer arithmetic. This is what is done in practice in all the financial software with which I am familiar (with adaptations for other currencies to cater for example for denominations of 0.5 cent where these exist).

rcgldr said:
if the currency is in decimal, then it would make sense to have the math done in decimal to avoid rounding issues or inconsistencies between financial institutions.

No, the problem arises instead when potential rounding differences cannot be avoided.

Let's say a customer has an overdraft with an interest rate of 3.75% applied on an daily/365 basis. Before the days of computers this was done using precomputed tables and with a 6 figure table you would be accurate to within 1 cent on a balance up to $10,000.

However a calculation now might be on an overnight deposit of $10 Mn where 6 figures accuracy gives a potential difference of $50 either way - not so good. In practice this should not be a problem because modern computers generally use 16 digit accuracy provided by IEEE 754 double precision.

However the problem could instead be addressed by legislation (or other standardisation) which is why I was interested in your comment
rcgldr said:
Financial institutions are required by law to perform the math in decimal.
However I am disappointed to see that you cannot provide a reference for this.

Anyway this is way off-topic so it is probably time to call this to a halt.
 
  • #93
pbuk said:
disappointed to see that you cannot provide a reference for this.

Do web search for "banks required to use decimal math in the US", and you will find explanations. I'm aware that the government institutions that monitor the banks have matching calculations that require the rounding of decimal numbers be consistent between banks and the monitors, but can't find a specific law.

I recall a case of salami slicing where a someone rounded off transactions by a fraction of a cent and transferred the trimmed-off money into a separate account which the government caught when it synced up with the money a bank was supposed to have base on common rounding algorithms and the precision of the decimal math involved.
 
Last edited:
  • Like
Likes FactChecker
  • #94
rcgldr said:
Do web search for "banks required to use decimal math in the US", and you will find explanations. I'm aware that the government institutions that monitor the banks have matching calculations that require the rounding of decimal numbers be consistent between banks and the monitors, but can't find a specific law.

I recall a case of salami slicing where a someone rounded off transactions by a fraction of a cent and place the trimmed-off money into a separate account which the government caught when it synced up with the money a bank was supposed to have base on common rounding algorithms and the precision of the decimal math involved.
So "Office Space" was fiction??!? It sure seemed realistic to me. :-)

(Don't it feel good to be a gangster?)
 
  • #95
elias001 said:
@FactChecker if someone learns to understand assembly language through looking understand the hood of a C program, then take away their C programming, can they write a program from scratch in assembly? There are heaps of books on assembly for the ibm pc family of computers even before x86 architecture arrived on the scene. Can they program in assembly and know assembly better than someone who is learning it through how assembly language codes the syntax of a C program?
This is a confusing statement. The very first IBM PC used an Intel 8088 microprocessor, which is essentially the same instruction set as x86 except that it had 8-bit registers instead of 16 on an 8-bit duplexing bus, and so it ran a bit slower than an 8086. For many years thereafter, IBM compatible PC's ran the x86 instruction set (and some). Even as the Windows operating system evolved, command line programs written in the 1980s continued to execute adequately. Which is really remarkable, considering how much worse the Mac community has fared in terms of old software compatibility.

What made a PC compatible with the original IBM PC was also its boot ROM, the so-called BIOS, which was basically an API for the hardware. You could use a call to the BIOS, for example, to disable interrupts on the hardware, if you intended to poll the I/O ports directly. The BIOS was extended with some rewriteable memory at the beginning of its boot disk, so you could also tell the PC at boot time what kind of disk drives and other peripherals were attached. This had the useful effect to making it possible to buy a different hard drive for your PC from almost any vendor. You just had to format and low-level write the extended part of the BIOS "firmware" onto boot sectors of the new drive.

But the BIOS had disk drive size limitations, and in the late 1990s-2005, new Windows PCs replaced the BIOS with EUFI, and it was then not so possible for consumers to swap out disks. It was a needful change, but marked the end of cheap Windows PCs and easy at home tinkering for IBM compatible PCs.

So, you can learn the x86 instruction set using some kind of simulator. You can also run the instruction set on newer Intel based Windows PCs. But when talking about computer architecture, be sure to specify whether you mean "instruction set" architecture, or something like the IBM-compatible PC, which requires an instruction set architecture (either x86 based, which as in the CISC category, or ARM based, which is in the RISC category) as well as BIOS boot technology or EUFI boot technology. The latter determines how the computer loads it's operating system. Both the ISA and the boot method are required to make a machine IBM PC compatible.

Also, I wish to say I am happy to see anyone eager to learn assembler level programming. It becomes essential, not only to understand OS internals, but for topics such as dynamic vs static software libraries. At assembler level, you see how dynamic binding of a subroutine really works. You see how interrupt service routines work (and it's alternate I /O method, polling). If someone is going to code in robotics only using some high level language, they may never understand performance issues unless they learn assembler. This kind of theoretical understanding can also be useful in performance engineering using VM based programming languages such as Java- or .NET based programming.
 
Last edited:
  • Love
  • Informative
Likes Mark44 and sbrothy
  • #96
harborsparrow said:
[...] Also, I wish to say I am happy to see anyone eager to learn assembler level programming. [...]
I agree generally, but this sentence in particular matches my sentiment exactly.

EDIT: "Sentiments?
 
  • Like
Likes harborsparrow
  • #97
Some confusions above, and I want to try to clarify:

* there is the "machine instruction set", which is the real x86 instruction set architecture (ISA)
* there is Microsoft assembler code, which is called a LOW-level programming language because many (but not all) of its instructions correspond one on one with machine instructions; it's just that they are written in human readable form (ASCII), and the assembler is the program that reads and parses the human-readable instructions and outputs the actual binary numbers which comprise the instruction stream to the machine.
* a HIGH-level language, such as C, may appear to compile directly down to an executable hunk of machine instructions (on x86, called an exe file), but in the past (and sometimes now also), the high-level compilers would generate an assembler instruction stream (which again, a skilled human could look at a decipher, because it's ASCII), and then the assembler instruction stream would be "assembled" into the .exe file. Of course, this is a vast simplification (not taking into account subroutines and shared code and what not all), but it is important to have the 10,000 mile high view before you get down to machine code.

In my career of 40+ years of programming, I wrote production code in three different instruction set architectures. It was a pain in the butt to learn at the time, but I did benefit greatly from seeing different ISA's at the assembler level. I only wrote one production program in x86 (it was enough! ugh!) and it was to hijack the machine during boot up and kill the interrupts, putting instead an I/O polling loop in. That was extremely illuminating in terms of performance. It was for a very high speed application in telephony, and you cannot EVER trust fully that interrupt service routines will finish their work in a timely manner (although they do about 99% of the time).

Anyway, when I studied computer science for a master's degree, everyone was required to gain minimal competence in at least one assembler language. I hope that requirement still exists, but in the age of AI, it may not.

But--chuckling here--there is no danger that people who understand low-level machine and OS and linking/loading issues will become rare. Such people are called hackers, and quite a few have malicious intent. Thus, it's very important that people who are legitimate in intent learn these concepts also.
 
  • #98
P S - A trivia question (and please don't answer it here--let people look it up). WHO invented the concept of an assembler (from which, later, the concept of a compiler was derived)?
 
  • #99
I believe RollerCoaster Tycoon was written in Assembly, so if you know about this language and your crazy enough to use it, you can make quality things. And *CRIES* I can't even figure out Python?
 
  • Love
Likes harborsparrow
  • #100
SleipnirTheHorse said:
I believe RollerCoaster Tycoon was written in Assembly, so if you know about this language and your crazy enough to use it, you can make quality things. And *CRIES* I can't even figure out Python?
Really? Assembly? I think I’ve got it mixed up with another game. What strikes me as weird with that is that porting it would be a nightmare!
 
  • #101
SleipnirTheHorse said:
I believe RollerCoaster Tycoon was written in Assembly, so if you know about this language and your crazy enough to use it, you can make quality things. And *CRIES* I can't even figure out Python?
I usually refer to languages such as Python. TCL, Perl etc as glue. Languages used to glue other programs together with. A little unfair against Perl but there you have it.
 
  • #102
harborsparrow said:
P S - A trivia question (and please don't answer it here--let people look it up). WHO invented the concept of an assembler (from which, later, the concept of a compiler was derived)?
It was probably like reinventing the wheel. o0)
 
  • Love
Likes harborsparrow
  • #103
SleipnirTheHorse said:
RollerCoaster Tycoon
Which one exactly?
 

Similar threads

  • · Replies 25 ·
Replies
25
Views
2K
Replies
5
Views
4K
  • · Replies 13 ·
Replies
13
Views
2K
Replies
14
Views
3K
  • · Replies 4 ·
Replies
4
Views
15K
  • · Replies 397 ·
14
Replies
397
Views
19K
Replies
6
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 8 ·
Replies
8
Views
5K