Closed
Description
AVR assembler instruction ldd
is defined only for registers Y
and Z
, but not for X
.
asm!()
macro accepts it.
I tried this code:
#[no_mangle]
extern "C" fn main() {
unsafe {
::core::arch::asm!("
ldd {tmp}, X+0
ldd {tmp}, X+1
",
tmp = out(reg) _,
in("X") &0xAABB_u16,
);
}
}
I expected to see this happen: compilation error.
Instead, this happened: rustc produces a binary with a corrupted code.
000000a6 <main>:
a6: a0 e0 ldi r26, 0x00 ; 0
a8: b1 e0 ldi r27, 0x01 ; 1
aa: 88 81 ld r24, Y
ac: 89 81 ldd r24, Y+1 ; 0x01
ae: 08 95 ret
Pointer (0x0100) to a value is loaded into register X
(r26:r27
) following by reads from *Y
.
Meta
rustc --version --verbose
:
rustc 1.70.0-nightly (22f247c6f 2023-03-13)
binary: rustc
commit-hash: 22f247c6f3ed388cb702d01c2ff27da658a8b353
commit-date: 2023-03-13
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7
Steps to reproduce:
repo: https://github.com/Slickis/rustc-ldd-x
git clone https://github.com/Slickis/rustc-ldd-x
cd rustc-ldd-x
make lss