Hacker News new | ask | show | jobs
by itsmemattchung 687 days ago
Hats off! Wish I had the the grit and determination at 16 to write something like this

> A 'special' CPU register that holds the memory address of the next instruction

Though it's been years since (grad school) I dealt with any assembly, for some reason I recall this being the EIP register? These days, I rarely touch low level language and yet, I have such a deep and profound love for them.

3 comments

You're welcome. It wasn't as easy as it looks now, but i managed to pull it off at this age.

> I have such a deep and profound love for them.

Oh god, i wish i included more about registers but it isn't the main focus- And thank you for clarifying which REG it is, It's added to the book!

It depends upon the manufacturer. Motorola used PC (program counter), Intel used IP (instruction pointer). I think it's only the x86 that has multiple names, depending upon the size: IP for 16 bits, EIP for 32 bits, RIP for 64 bits.
RIP with 64-bit x86
Better to start with 64bit registers these days, it's rare to find a 32 bit system when you are just starting out learning assembly.

The "Write great code" series of books is a must read for those interested in low and "high" level concepts.

> Better to start with 64bit registers these days, it's rare to find a 32 bit system when you are just starting out learning assembly.

x86-64 ("x64") versions of Windows can run x86-32 binaries.

Of course, but most if not all of the binaries on the system will be 64bit. Someone just starting out may struggle to find a 32 bit binary.
Your comment suggests that you don't work on a Windows PC very often: it is the common situation to find quite many older applications on the PC that are 32 bit. Just to give one example: until Visual Studio 2019, Visual Studio was still a 32 bit application.

Actually, there even today exist quite some vocal Windows users who would love to run some really old 16 bit applications on their 64 bit Windows PC (but Microsoft stopped supporting running 16 bit binaries on 64 bit Windows versions).

These are not mutually exclusive positions, but afaik visual studio isn't part of the os. As another commenter mentioned, the builds are all 64bit as well. Sure you can always find a 32bit app to install, but the point is a beginner may not do that and be disappointed when the registers they see on their machine don't match what they read about.
Especially in today's hardware (/software?), all the bins on the system are 64bit even if it's a 32bit binary, the remaining bits get filled by 0s so that the system treats it as a 64bit bin.