Using the Z register in assembler

I can get the version of a (recent) Optiboot with:
printf("Optiboot version: 0x%04x\r\n", pgm_read_word(0x7FFE));
but trying the same trick in assembler doesn't read the correct address
(I don't know exactly what address it does read, that's the problem):

    __asm__ volatile (
    "ldi r31, 0x7f \n\t"
    "ldi r30, 0xfe \n\t"
    "ld r0, Z \n\t"
    "mov %0, r0 \n\t"
    : "=r" (VERSION_store) :
    );

Does anyone know how to use the Z register to read from the boot loader code?

Thanks - Will

"ld r0, Z \n\t"
"mov %0, r0 \n\t"

with "ld", You're reading RAM. You need to use "lpm" to read from the flash.
(RAM at 7FFE doesn't exist; who knows what you'll get)
(also note that the normal Uno Fuse settings do no allow lpm in the application to read from the "boot section")