This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM64: LDR (register) SXTX extend

Hi,

What's the purpose of the SXTX extend? I understand the concept of sign extension when, say, the source register is 32-bit and the target is 64-bit.

In this case, however, both registers are 64-bit. So what's the point? What can you do with SXTX that you cannot do using other LDR (register) variants?

Thanks,

Nikita

Parents
  • But how is this relevant to my question? IIUC, SXTX doesn't work with 32-bit operands.

    For example:

    .text
    .global _start
    
    _start:
        ldr x1, =buf3
        movn x2, #0             // x2 = -1
        ldr x0, [x1, x2, sxtx]  // x0 = [buf3 + (-1)]
    
        ldr x1, =buf3
        movn x2, #0             // x2 = -1
        ldr x0, [x1, w2, sxtx]  // invalid
    
    
    .data
    buf0: .byte 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18
    buf1: .byte 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28
    buf2: .byte 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38
    buf3: .byte 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48
    buf4: .byte 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58
    buf5: .byte 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68
    buf6: .byte 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78

    My guess above is about the first case.

Reply
  • But how is this relevant to my question? IIUC, SXTX doesn't work with 32-bit operands.

    For example:

    .text
    .global _start
    
    _start:
        ldr x1, =buf3
        movn x2, #0             // x2 = -1
        ldr x0, [x1, x2, sxtx]  // x0 = [buf3 + (-1)]
    
        ldr x1, =buf3
        movn x2, #0             // x2 = -1
        ldr x0, [x1, w2, sxtx]  // invalid
    
    
    .data
    buf0: .byte 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18
    buf1: .byte 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28
    buf2: .byte 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38
    buf3: .byte 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48
    buf4: .byte 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58
    buf5: .byte 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68
    buf6: .byte 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78

    My guess above is about the first case.

Children