; Build/run from examples/: ; ../utils/mcpu-as -o block-copy.o block-copy.s ; ../utils/mcpu-ld --stack-size=512 -o block-copy block-copy.o ; ../utils/mcpu-run --int-reg=r64@0x00028 block-copy ; ; Expected output: 22 ; ; LibCPU block-copy example. ; ; 1. Copy a 32-byte object from DATA to a local STACK object with BMOVI. ; 2. Use BMOV with a runtime byte count to perform an overlapping move ; inside that STACK object. BMOV has memmove semantics. ; 3. Read the moved value back through LOADP. Expected result: 22. .data .align 8 source_object: .integer 64, 11 .integer 64, 22 .integer 64, 33 .integer 64, 44 .text _start_life: ; Source PTR64 -> DATA object. LEA r64@0x00000, source_object ; Reserve 32 bytes for a local object and obtain its STACK PTR64. ADJSP -32 LEASP r64@0x00008, 0 ; Fixed-size structure copy: DATA -> STACK. BMOVI r64@0x00008, r64@0x00000, 32 ; Overlapping move inside the local object: ; bytes [0..15] -> [8..23]. memmove semantics are required. PADDI r64@0x00010, r64@0x00008, 8 LDI r64@0x00018, 16 BMOV r64@0x00010, r64@0x00008, r64@0x00018 ; The third 64-bit slot now contains the old second slot: 22. PADDI r64@0x00020, r64@0x00008, 16 LOADP r64@0x00028, r64@0x00020 ADJSP 32 HALT