News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Top 10 64-bit ISAs by highest code density and lowest instruction count

Started by lucho, December 23, 2024, 04:23:04 AM

Previous topic - Next topic

lucho

During the translation of my assembly language examples to various instruction set architectures (ISAs), I've accumulated some statistics. The 3rd table in the listings of the examples shows the number of bytes used by my size-optimized code implementing each example and a grand total for each ISA. Here are the 10 ISAs with highest code density for all examples:

  • 811 bytes – AMD64/x64
  • 978 bytes – ARC64
  • 1154 bytes – ARM64
  • 1394 bytes – LoongArch64
  • 1432 bytes – PPC64
  • 1492 bytes – RISCV64
  • 1514 bytes – PA-RISC 2.0
  • 1558 bytes – S/390x
  • 1569 bytes – MMIX
  • 1824 bytes – Alpha AXP

Code density is important because the more work is done by all the bytes in the code cache, the more effective that cache is. And this is true, no matter what language the code in it is written in.

The 2nd table in the listings gives the number of instructions used to implement each example and a grand total for each ISA. Here are the 10 ISAs with lowest instruction count for all examples:

  • 271 – ARC64
  • 285 – ARM64
  • 295 – AMD64/x64
  • 346 – LoongArch64
  • 351 – S/390x
  • 356 – PPC64
  • 356 – PA-RISC 2.0
  • 367 – RISCV64
  • 369 – MIPS64
  • 393 – MMIX

Instruction count is important not only because it determines the time needed to do the job for a given pipeline implementation and clock frequency but also because it reflects the difficulty of writing code in each assembly language. And contrary to the popular belief that RISC ISAs allegedly need more instructions than CISC ISAs to do a given job, we can see that the top 2 ISAs with lowest instruction count are RISC, not CISC!

daydreamer

Isn't x86 real mode 16 bit smallest ,followed by 32 bit because size addresses 2 byte in 16 bit and 4 byte in 33 bit ?
The difficult part of writing small code in assembly is the fun part of size optimising to fit in 256b,1024b,4096b,64k demo
And pre pixelshaders demoscene could be fame of coding fantastic asm demo
I am too old to become expert in pixelshaders coding needed for modern demoscene
,so I my alternative is half century asm experience+ 25 years SSE experience
But that haven't stopped me enjoy 203 bytes .com file and 3.5kb SSE / ddraw trying to make demo

My knowledge gained from making SSE2 macros for ml 6.14, 1 byte prefixes on 3 byte SSE mnemonics make sse2 mnemonics,is helpful when size optimising
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

lucho

#2
Glad to meet you! :smiley:

This section is for non-x86 64-bit ISAs, but yes, for the x86, the fewer the size prefixes, the higher the code density. It is highest for either 16-bit real mode code using 16-bit data and 16-bit addresses, or 32-bit flat protected mode code using 32-bit data and 32-bit addresses. Mixing of code, data and address size lowers code density. And I've discovered that "flat real mode" not only lowers code density but also the speed compared with flat protected mode.

The best assembly language programmer I know is a programmatrice who wrote an entire operating system and a complex embedded software 100% in assembly language for an 8-bit Toshiba microprocessor in a popular MIDI player quarter a century ago. The best SSE programmer I know wrote a benign DOS virus that ceased being benign if one tries to remove it. Later, he managed to do complex audio signal processing with SSE assembly language code.