Live data from Hacker News

X86 assembly doesn’t have to be scary

blog.benjojo.co.uk

11–20 of 129 posts

Re: X86 assembly doesn’t have to be scary

#11
I wonder if the history of x86 is holding us back in a big way. It started out being close to the metal but now it's an abstraction that can mislead you if you think processors are literally working the way x86 assembly describes.

And surely the whole spectre issue could be lessened if we could be less reliant on CPUs having to guess what to keep in cache, which code paths are most likely, etc?

Re: X86 assembly doesn’t have to be scary

#12
post #3

If your intention is to avoid scaring newbies off, I'm not sure if 16bit real mode, PC boot process, BIOS services and all that arcana that follows is the best place to begin.

Why not? If they're determined enough, they'll get it. I learned a lot back in the day by spending many hours with the book PC Intern and some other book on x86 Assembler. Granted, I had a little experience with assembler on a C=64, but, I learned _that_ in a similar way.

> If they're determined enough, they'll get it.

That's the exact opposite mindset of someone trying to "not scare newbies away."

Re: X86 assembly doesn’t have to be scary

#13

Earlier quoted context omitted.

Why not? If they're determined enough, they'll get it. I learned a lot back in the day by spending many hours with the book PC Intern and some other book on x86 Assembler. Granted, I had a little experience with assembler on a C=64, but, I learned _that_ in a similar way.

> If they're determined enough, they'll get it. That's the exact opposite mindset of someone trying to "not scare newbies away."

On the other hand, I think it is fair to assume that people who are interested in assembly programming at all bring a certain degree of determination to the table.

Re: X86 assembly doesn’t have to be scary

#14
post #11

I wonder if the history of x86 is holding us back in a big way. It started out being close to the metal but now it's an abstraction that can mislead you if you think processors are literally working the way x86 assembly describes. And surely the whole spectre issue could be lessened if we could be less reliant on CPUs having to guess what to keep in cache, which code paths are most likely, etc?

Well, Intel has tried repeatedly to replace x86 (AXP32, i860/i960, Itanium), but in a way, they were a victim of their own success.

Re: X86 assembly doesn’t have to be scary

#15
I wasn't really familiar with webassebly, but when I've seen this source for fibonacci I immediately recognized familiar features which can't be said of the rest of the assembly implementations:

https://github.com/nebulet/nebulet/blob/master/wasm/fibonacc...

https://github.com/Hanks10100/wasm-examples/blob/master/simp...

Re: X86 assembly doesn’t have to be scary

#16
post #11

I wonder if the history of x86 is holding us back in a big way. It started out being close to the metal but now it's an abstraction that can mislead you if you think processors are literally working the way x86 assembly describes. And surely the whole spectre issue could be lessened if we could be less reliant on CPUs having to guess what to keep in cache, which code paths are most likely, etc?

there was at least one non-realized research project where the cache was exposed as part of the architecture to be managed by the compiler (ppc lets you do some of that).

i think thats a potentially very fruitful approach, but would it have helped the spectre situation in any way?

oh, what you're suggesting in an analog for compiler driven speculation? that may have helped, and is also probably worth thinking about

Re: X86 assembly doesn’t have to be scary

#17
post #11

I wonder if the history of x86 is holding us back in a big way. It started out being close to the metal but now it's an abstraction that can mislead you if you think processors are literally working the way x86 assembly describes. And surely the whole spectre issue could be lessened if we could be less reliant on CPUs having to guess what to keep in cache, which code paths are most likely, etc?

Speculation has nothing to do with x86 in particular, although it has something to do with its general approach to execution (as opposed to e.g. the Mill CPU).

Speculation is part of out of order execution, which is logic to execute code passages when their inputs are ready, as opposed to strictly in program order, while maintaining the program visible effects of executing in program order. It works the same in ARM, MIPS etc. Not doing OOO execution roughly halves CPU throughput on your average code. AFAIK OOO without speculation is possible, but loses maybe half of its efficacy.

Actual experts may want to correct my numbers.

Re: X86 assembly doesn’t have to be scary

#18
post #11

I wonder if the history of x86 is holding us back in a big way. It started out being close to the metal but now it's an abstraction that can mislead you if you think processors are literally working the way x86 assembly describes. And surely the whole spectre issue could be lessened if we could be less reliant on CPUs having to guess what to keep in cache, which code paths are most likely, etc?

I already posted about WebAssembly in this thread and I think you are correct. It looks completely different than anything else before. I can see functional languages targeting it directly.

Re: X86 assembly doesn’t have to be scary

#19
post #6

Loved the article. Then one can follow up with some MS-DOS classics. https://www.amazon.com/Peter-Nortons-Assembly-Language-Book/... https://www.amazon.com/Advanced-S-DOS-Programming-Microsoft-... https://www.amazon.com/Peter-Norton-Programmers-Bible-progra... https://www.amazon.de/PC-Intern-Programming-Encyclopedia-Dev...

I see your Norton and raise you an Abrash:

https://www.amazon.com/Zen-Assembly-Language-Knowledge-Progr...

https://www.amazon.com/Zen-Graphics-Programming-2nd-Applicat...

https://www.amazon.com/Zen-Code-Optimization-Ultimate-Softwa...

Zen of Asm is also online, I think a few of the other works, too.

http://www.jagregory.com/abrash-zen-of-asm/

Re: X86 assembly doesn’t have to be scary

#20
When I was about 14 I was enthralled with programming my new Commodore 64, first in BASIC, then 6510 assembly. I had the opportunity to accompany my mother to a one-day class on programming. Being just an intro on the subject, I was well ahead of what they would be discussing, but thought it would interesting to talk to some adults that were also into programming.

I was talking to a couple of guys about what I had been doing on my C=64, and when I mentioned the assembly stuff I was writing, one of them said, "How can you possibly write anything with only three registers?!" (just the accumulator and x/y registers). I was wondering what the big deal was since that was the only architecture I had known at that point. Every game and utility I had were only using three registers, so it was already proven to me that three were "enough".

It's funny how you can just adapt and work with whatever is available, and that becomes your norm. Especially when you don't even realize there are other options out there.

Those were the days!

Post reply on HN