Live data from Hacker News

How many x86 instructions are there? (2016)

fgiesen.wordpress.com

51–60 of 92 posts

Re: How many x86 instructions are there? (2016)

#51
post #4

I feel sudden urge to write some assembly for fun. Have not done it for at least a couple of years I think.

Then you might like TIS-100 [1] and Shenzhen I/O [2].

[1] https://store.steampowered.com/app/370360/TIS100/?curator_cl...

[2] https://store.steampowered.com/app/504210/SHENZHEN_IO/?curat...

Re: How many x86 instructions are there? (2016)

#52
The only real answer is: Too Many.

This complexity is pushed down to operating systems, compilers, assemblers, debuggers. It ends up causing brutal human time overhead throughout the chain, and its cost effectively prevents security and high assurance.

This more than justifies moving away from x86 into RISC architectures, such as the rising open and royalty-free RISC-V.

Re: How many x86 instructions are there? (2016)

#53
post #4

I feel sudden urge to write some assembly for fun. Have not done it for at least a couple of years I think.

You'll feel less miserable if you target a modern RISC architecture such as RISC-V or a cleaner CISC architecture such as the venerable 68000.

Whenever bored, I read or watch chibiakumas tutorials. There's no such thing as knowing too many assemblers.

Re: How many x86 instructions are there? (2016)

#54
post #52

The only real answer is: Too Many. This complexity is pushed down to operating systems, compilers, assemblers, debuggers. It ends up causing brutal human time overhead throughout the chain, and its cost effectively prevents security and high assurance. This more than justifies moving away from x86 into RISC architectures, such as the rising open and royalty-free RISC-V.

Back in the 70s, a friend of mine said he loved the Z80 instruction set the best. I replied that it was the most complicated and kludgy one. He laughed and said the complexity allowed his code to shine above others and he got paid more.

Of course, these days the Z80 instruction set looks trivial :-)

Re: How many x86 instructions are there? (2016)

#55
post #27

Earlier quoted context omitted.

It's not that variable length is expensive, it's that variable length the way Intel does it is expensive. For instance — not that this is a good idea — you could burn the top 2b to mark instructions as 2/4/6/8 bytes (or whatever) in length. Then you can have your variable-width-cake-and-eat-your-fast-decode-too.

Could you elaborate - what is about the Intel design that makes the decode so inefficient? Is "2b" bits here? Are there examples of ISA or chips that handle variable length instruction encoding efficiently?

Due to how the instruction set evolved, for the Intel x86 architecture, you have to look at a lot of bits of the instruction stream to determine where the next instruction starts. To execute multiple instructions per clock cycles you also have to decode instruction multiple instructions per clock cycle.

I think this old Intel patent talks about one of their decoder implementations:

https://patents.google.com/patent/US5758116A/en

Re: How many x86 instructions are there? (2016)

#56

Earlier quoted context omitted.

These days RISC is mostly about regular encoding of instructions which don't present challenges to doing precise interrupts on a deeply pipelined machine rather than just few instructions per se .

What do you mean by "precise" interrupts here? Do some types of interrupts cause worse pipeline stalls than other types? Are the interrupt handlers in RISC faster because of more efficient decoding? Is that the issue?

No, it's just that the fact that RISC didn't have any load-op-store instructions made it easier to pipeline them back in the day while still being able to handle interrupts as if they executed one instruction at a time and there was one instruction that had executed while the following one hadn't executed at all. That's possible to do with CISC architectures, of course, we do it all the time these days. But back in the day being able to implement that easily-ish in a reasonable number of transistors were a big factor in early RISC processors having so much better performance than the CISCs of the time.

In the modern day it mostly just means that you can implement fancy out of order schenanigans with a bit fewer engineer-years than non-RISC ISAs.

Re: How many x86 instructions are there? (2016)

#57

Earlier quoted context omitted.

These days RISC is mostly about regular encoding of instructions which don't present challenges to doing precise interrupts on a deeply pipelined machine rather than just few instructions per se .

What do you mean by "precise" interrupts here? Do some types of interrupts cause worse pipeline stalls than other types? Are the interrupt handlers in RISC faster because of more efficient decoding? Is that the issue?

This is the classic definition

https://dl.acm.org/doi/10.1109/12.4607

"An interrupt is precise if the saved process state corresponds to a sequential model of program execution in which one instruction completes before the next begins. In a pipelined processor, precise interrupts are difficult to implement because an instruction may be initiated before its predecessors have completed."

Re: How many x86 instructions are there? (2016)

#58
post #4

I feel sudden urge to write some assembly for fun. Have not done it for at least a couple of years I think.

Then you might like TIS-100 [1] and Shenzhen I/O [2]. [1] https://store.steampowered.com/app/370360/TIS100/?curator_cl... [2] https://store.steampowered.com/app/504210/SHENZHEN_IO/?curat...

I've been getting a lot of enjoyment out of 6502/z80 projects like rc2015 and ben eaters breadboard 6502 kit/videos. There's also nand2tetris, if you prefer a more academic approach.

Re: How many x86 instructions are there? (2016)

#59

Earlier quoted context omitted.

Then when checking the results are half the speed of what the compiler spits out and the fun is gone. At least that's what happens to me...

I've always been able to beat the compiler, and that's usually after trying to optimize using C. Admittedly, it's a whole lot harder to understand what's fast than it used to be. Access to SSE has it's own benefits. It's been a problem (optimizing) for some time though. I remember it being some work to beat the compiler on the i960CA. OTOH, I seem to remember the i860 being not-so-great and for sure the TI C80 C comp…

One should never loose to the complier, after all you can see it's output and it can't see yours.

Also, the programmer can "cheat" by doing things the compiler would consider invalid but are known to be ok given the larger context of the application.

The restrict keyword in c gives an example of how one can optimize code by knowing the larger context. https://cellperformance.beyond3d.com/articles/2006/05/demyst...

The problem is the ROI is usually pretty bad as these assumptions rarely hold as the code evolves, in my experience, and the optimization usually only lasts for finite (sometimes shockingly short) amount of time. i.e. OS changes, hardware changes, memory changes, etc. etc. etc.

Post reply on HN