Comment

Comment by tpmoney

I'm not sure the example template was supposed to be canonical, vs demonstrating multiple output destructuring. Certainly the actual instruction definition in the checker library seems to understand that there could be two possible inputs:

https://github.com/odin-lang/Odin/blob/4247507dd5e31c9fd8716...

But I'm also not entirely sure why the example should not have compiled. It seems to me that the idea here is to be able to define a typed set of something equivalent to a function that inlines some assembly, but nothing about that inherently requires that the number of input or output parameters to the template match the parameters in the underlying assembly calls. There's no reason (in my mind anyway) why this shouldn't be a perfectly valid template:

    // Returns the extended feature flags obtained by calling CPUID
    // with EAX=7 and ECX=1
    cpu_extended_feature_flags :: asm() -> (a, b, c, d: u32) [
        a = %eax,
        b = %ebx,
        c = %ecx,
        d = %edx,
    ] {
        mov %eax 0x7
        mov %ecx 0x1
        cpuid
    }
parent tpmoney 2 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton