Skip to content

Conversation

@LinusU
Copy link
Contributor

@LinusU LinusU commented Nov 27, 2025

Documentation: https://www.felixcloutier.com/x86/fbld

⚠️ Claude Sonnet 4.5 wrote the code,

and I've tried my best to verify it against the documentation, but at the end of the day I don't have a great way to verify that the implementation is 100% correct 😅

I also tried finding any bcd functions built into Rust, that would actually emit code that uses this instruction (e.g. f64::from_bcd([u8; 10]) would have been nice 😁) but couldn't find any. So this contains code to actually do the BCD decoding.

Maybe this is not desirable? I'm very open to any other approaches!

Also, if you want me to do any changes to the code I'm happy to, it's a bit "chatty" now with the comments? But it did help me understand what's going on...

I'm also wondering if upping the multipler for each iteration is the way to go, or multiplying the result by 10 every time would be better 🤔

evmar added a commit that referenced this pull request Jan 10, 2026
@evmar
Copy link
Owner

evmar commented Jan 10, 2026

I just pushed a little README with how I write tests for these kinds of things, in case you want to try it. I'm also fine with merging this as is if you like though.

Reading https://en.wikipedia.org/wiki/Intel_BCD_opcodes (never really worked with BCD), the only thing I notice is the mention of the special "indefinite" value. It might be worth adding a todo!() on that just so it doesn't surprise you later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants