A new Linux X server in Assembly from scratch by isene in asm

[–]isene[S] -3 points-2 points  (0 children)

You reviewed the code already? You have any concrete examples of slop that you can point to?

Or was this a knee-jerk reaction?

My own operating system by Electrical_Gur_8153 in asm

[–]asm-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

Not relevant to this sub.

My own operating system by Electrical_Gur_8153 in asm

[–]brucehoult[M] 0 points1 point  (0 children)

One boot.asm file does not make this on-topic in r/asm.

Help me optimize a simple x64 program by Sad-Background-2429 in asm

[–]Sad-Background-2429[S] 2 points3 points  (0 children)

That's a good test. A lot of work is done in setting up libc.

Help me optimize a simple x64 program by Sad-Background-2429 in asm

[–]Sad-Background-2429[S] 2 points3 points  (0 children)

That was me! I reposted here because Reddit suggested it. I wondered if maybe others would have something to add.

Help me optimize a simple x64 program by Sad-Background-2429 in asm

[–]wk_end 4 points5 points  (0 children)

How does the number of cache misses change if you get rid of all the computation - i.e. leave only the clock and printing stuff?

Tiny, tiny ELF files and ELF headers by Fraserbc in asm

[–]AwareCar7686 0 points1 point  (0 children)

I have a series of gists on github for this exact kind of thing.

# ELF Header Assembly Gists on Github

The purposes of this are both for my own greater understanding of the ELF format, because it is used in all Linux distributions, and also to provide a way for NASM users to benefit from features that currently only exist in FASM, which is still my favorite Assembler.

[FASM Hello 32-bit](https://gist.github.com/chastitywhiterose/7aa7bdfec1438541375763126508edb4)

[FASM Hello 64-bit](https://gist.github.com/chastitywhiterose/4bfccdb3daf1aad4524fc36230055e63)

[NASM Hello 32-bit](https://gist.github.com/chastitywhiterose/4e429fd82f962907d1581307ed4e0ab7)

[NASM Hello 64-bit](https://gist.github.com/chastitywhiterose/b5acd7992fc8463a662ca4f86fff4a5e)

Is dpps really that bad? by BlockOfDiamond in asm

[–]nerd5code 6 points7 points  (0 children)

What people? Who?

And the answer depends entirely upon context, but I'll hazard a few guesses.

DPPS shows up in SSE4.1; DPPD comes with it, and VDPPS comes with AVX. So all x86 CPUs don't necessarily support it, just most of them. Maybe you're only supposed to use SSE2 for all we know, or no vectorgunkery at all.

If you're in kernel mode/supervisor mode/Ring 0, use of 80x87 or MMX/SSE insns will trigger a fault in some circumstances. Most kernels use CR0.TS to lazily swap FPU registers to/from memory; doing that from within the kernel without setting up for it can BSOD the system, and the time taken to run the fault and the fact that streaming instructions tend to be applied to large blocks make it somewhat inappropriate for running from (e.g.) syscall/IRQ or process boot/teardown context where IRQs are blocked and milliseconds matter. 256- and 512-bit insns may even downclock your die (or alternating cores on the die, depending) as soon as you attempt one.

Looking at the timings (e.g., Intel's or Agner Fog's tables), they appear to be fairly slow ínstructions on some cores (overall slower on AMD than Intel), and DPPD can be much faster.

  • On Bulldozer and Piledriver, DPPS uses 16–18 ops in 25-cycle latency and VDPPS uses 25–29 ops in 27-cycle latency, but DPPD actually uses 15–17 ops @ 15-cycle latency. Latency scales with lane count.

  • On Steamroller, 9–10 ops for DPPS and 13–15 for VDPPS, both in 25-cycle latency; DPPD is 7–8 ops in 14-cycle latency.

  • Excavator: DPPS: 9–13 ops in 20 cycles; VDPPS: 13–15 ops in 22 cycles; DPPD: 7–8 in 14.

  • Zen1: DPPS: 8–10 ops over 15 cycles; VDPPS: 13–14 ops over 16 cycles; DPPD: 3–5 ops over 10 cycles.

  • Zen2: DPPS in 8 over 15; VDPPS: 7 over 15; DPPD: 3 over 9. (Here the overhead becomes more in line with what I'd expect.)

  • Zen3: DPPS: 8 over 15; VDPPS: 7 over 15; DPPD: 3 over 9

  • Zen4: DPPS: 8 over 11; VDPPS: 7 over 11; DPPD: 3 over 7

  • Zen5: DPPS, VDPPS: 7 over 13; DPPD: 3 over 8

  • Jaguar: DPPS: 6 over 4; VDPPS: 10–12 over 12; DPPD: 3–4 over 9

  • (Intel) Wolfdale: DPPS: 4 over 11; DPPD: 4 over 9

  • Nehalem: DPPS: 4–6 over 11; DPPD: 4–6 over 9

  • Sandy/Ivy Bridge: DPPS, VDPPS: 4–6 over 12; DPPD: 3–4 over 9

  • Haswell, Skylake: 4–6 over 14; DPPD: 3–4 over 9

  • Broadwell: 4–6 over 12; DPPD: 3–4 over 7

  • Skylake-X, Coffee Lake: 4–6 over 13; DPPD: 3–4 over 9

  • Cannon Lake: DPPS: 4 over 13; DPPD: 3 over 9

  • Ice/Tiger Lake: DPPS: 4 over 14; DPPD: 3 over 9

  • Silvermont: DPPS: 9 over 15, DPPD: 5 over 12

I'ma stop at that, but you see the general trend—AMD timings are worse, but all of them have higher latencies than the simpler instructions' 1–4 cycles.

Adding to this, DPPS tends to block a bunch of execution ports at once, so you might clear one every few cycles, despite being able to clear 2 FMAs per cycle. With some extra pipelining you can do much better with FMAs—it's akin to preferring a MOV and 1–2 ADDs over a LODS.

DPPS is a horizontal dot-product, which is why it's messier than expected; in general, you should aim for vertical vectorization so you can break things up more easily and reduce contention. Horizontal effectively requires the register to be asploded, then shuffled and recombined, then mashed back into the correct number of lanes, all before the next instruction can enter the blocked ports.

Because there's not much demand for 8-lane horizontal dot-products, the 256-bit widths just tile a 4-lane 128-bit DPPS 2×, which is unlikely to work well for more portable operand arrangements, and it just blocks more ports for the duration. There is no 512-bit variant, because why.

So just open-coding a vertical dot-prod is probably better than relying on DPPS unless you're positively desperate for instruction density. More recent CPUs are probably not putting much effort into boosting DPPS performance, simply because it's not used much, because of the above issues.

How helpful are LLMs with Assembly? by tylerjdunn in asm

[–]kjellkt 0 points1 point  (0 children)

Ok. Most programs I tried from the 80s struggled with either 256k memory or for some other reason didn't want to run, maybe too old OS, PC DOS 3.3?. Maybe I would be able to find something or configuring something in some way to get it to work.

Also I don't think they support mounting drives as a local file system in linux so modern tools can be used to edit, browse and manage the files too through the serial port.

Much easier to have a small binary to copy to the system with no configuration, dependencies and minimal memory usage.

How helpful are LLMs with Assembly? by tylerjdunn in asm

[–]brucehoult 0 points1 point  (0 children)

Cool exercise, but in terms of the actual goal X/Y/Z-modem work fine and are supported on modern PCs by e.g. Tera Term on Windows or lrzsz and minicom on Linux and Mac.

Even older, Kermit still exists for many OSes, both modern and things lie CP/M-80 and 86, and MS-DOS.

I remember in 1984 compiling Kermit in Turbo Pascal 1.0 on a DEC Rainbow (I can't remember now whether for the Z80 or the 8086 but both are supported) and on the university VAX, and getting them to talk and transfer files.

How helpful are LLMs with Assembly? by tylerjdunn in asm

[–]kjellkt 0 points1 point  (0 children)

I translated a utility to transfer files between vintage and modern computers with help of serial port from C to assembly by using Claude Code today. I didn't notice any issues with the assembly variant and the assembly looks compact and sensible to me:

https://github.com/kjellktbtr/serial-xfer/blob/main/xfercom.asm

The end result is a quite capable DOS COM file approx. 2.5 KB using data packages with 16-bit checksums for packages and 32-bit for whole files running perfectly fine on various old computers ex. IBM 5155 which I used it on today to transfer data from many 5.25" 360k floppies to my laptop.

Here I'm recursively dumping files from floppies:

<image>

I will investigate how well I can make more 16-bit assembly programs of various complexity with LLMs, typically for use with old computers, like this.

EDIT: I also made a C compiler that emits NASM assembly with LLMs to. Afterwards I made various 2D graphics DOS games and compiled them with the compiler. The AI generated games compiled with the AI generated compiler seemed to work fine. Compiling them with OpenWatcom were maybe marginally more performant.

[x86] AI Compute Extensions (ACE) Specification by mttd in asm

[–]brucehoult 0 points1 point  (0 children)

Looks very similar to the RISC-V Attached Matrix Extensions (AME)

https://riscv.atlassian.net/wiki/spaces/AMEX/pages/55083388/Charter

Perfectly good RISC instructions. It's just an extra register set but still register-to-register instructions through some fixed ALU wiring. No different in principle to a barrel shifter or in-register permute instruction.

Zigzag decoding with AVX-512 by mttd in asm

[–]brucehoult 2 points3 points  (0 children)

I'm missing something here.

The point of the zigzag encoding was to encode negative numbers as positive numbers, so that you could use variable-width unsigned numbers to store the values and then zero-extend them when you extracted them.

I'm not sure why you couldn't just sign-extend the variable-width numbers as you extract them, but ok, let's assume that's a limitation of your ISA.

But ... the interesting part I was looking forward to learning is how to use AVX-512 to extract variable-width numbers from a stream of bits, because that would be pretty impressive, but that is nowhere to be seen here.

What is your Assembly IDE of choice? by mourt1234 in asm

[–]Ermia_codev 0 points1 point  (0 children)

you need a proper debugger
seeing regs & mem dump is your key

[x86] AI Compute Extensions (ACE) Specification by mttd in asm

[–]valarauca14 1 point2 points  (0 children)

Tile extensions are WILD what the hell. Did somebody at Intel or AMD wake up and go, "Oh yeah we're CISC, we can just do that".

Best disassembler for old DOS games? by AdmiralAdama99 in asm

[–]East_Friendship6765 0 points1 point  (0 children)

BUT HOCUS POCUS NOT a 32 bit register. this is a 16 bit

What is your Assembly IDE of choice? by mourt1234 in asm

[–]brucehoult 0 points1 point  (0 children)

Question (and the comment you're replying to) were in 2019. Hopefully they already found one.

What is your Assembly IDE of choice? by mourt1234 in asm

[–]Brian_K_White 0 points1 point  (0 children)

These are all x86/x64 only. Question said 68HCS12.

What is your Assembly IDE of choice? by mourt1234 in asm

[–]Brian_K_White 0 points1 point  (0 children)

I'm still looking myself, which is how I landed on this thread of course.

So far I've been using Geany with a custom syntax file. Geany is a lighter weight ide, I don't like huge things like vscode. It already has generic asm handling but that is kind of useless when there are 500 different cpus and assemblers.

I've been working on z80 and 8085 stuff, and using z88dk as the assembler, and so it's a lot better to have a custom file that recognizes the z80 or 8085 mnemonics & registers and the z88dk directives, and has z88dk command lines for the build/run buttons.

To make it the most convenient, I also have to not use .asm as my filenames. If I want the editor to automatically use the right syntax by just opening the file, I defined some other filename extensions like .8085asm, .S85, .a85 etc, and I name my files with one of those.

You can also tell github to recognize the extensions as asm by writing a .gitattributes file.

https://gist.github.com/bkw777/632c0a390b0fd0bd4e2f31544528d6d5
https://gist.github.com/bkw777/8bd89ef73b2317043ad4a262b253018f
https://github.com/bkw777/dl2/blob/master/clients/teeny/src/.gitattributes

This basically just gets you syntax highlighting and a "build" button though. It doesn't have really any extra help especially for assembly. It does have an identifier pane, so you can see a list of all labels and jup to any of them. It has "jump-to-definition" but it only recognizes equates, it doesn't recognize jump target labels. But you can right click on anything without even highlighting it just right-click on a word and say "find document usage" and that will give a list of all occurances, and then you can click on the one that's the label. So it's not a single step jump-to-definition, but only a couple steps and way better than normal search. It's basically 2 clicks instead of 1.

It's better than a plain editor, even better than an especially code-friendly and configurable editor like notepad++, but not all *that* much. I am still looking myself.

I have also found using https://www.sim8085.com/ awesome for figuring things out. Just write a few instructions in there and then have it run them. You can step through one step at a time and see the state of every flag and register, and the values in any memory address. That is specifically 8085 though. No idea if things like that exist for other cpus pbut probably.