Page 1 of 1

ULP, use Byte instead of Long

Posted: Thu Apr 12, 2018 7:17 pm
by fhng11214

Code: Select all

    
.data
   
        .global romid1
romid:
        .byte 0x01
        .byte 0x02
        .byte 0x03
        .byte 0x04
        .byte 0x05
        .byte 0x06
        .byte 0x07
        .byte 0x08
        .byte 0x09
        .byte 0x0A
        .byte 0x0B
        .byte 0x0C

        

Code: Select all

move r0, romid1
ld r1, r0,0			// 0x0201, since register is 16bit so lower bits get stored.

ld r1,r0, 1			// 0x0201, can't off set by 1 byte
ld r1,r0, 4			// 0x0605, can only off set by 4 bytes (32bits) 

add r0, r0, 1		
ld r1, r0, 0		// 0x0605, by 4 bytes.
Data is only 8bits long so I am trying to down sizing by using Byte(8bits) instead of Long(32bits) for storing data. Is there a way to load byte size data since "ld r1,r0, 1 or 2" doesn't do anything and "add r0, r0, 1" moves 4 bytes. Does it even make sense down sizing from Long to Byte to save some memory space? Thx for your help.

Re: ULP, use Byte instead of Long

Posted: Fri Apr 13, 2018 4:12 am
by mikemoy
Why not just pack your 4 bytes into one 32 bit ?

Re: ULP, use Byte instead of Long

Posted: Fri Apr 13, 2018 10:56 am
by ESP_igrr
Internally the load instruction accepts offset in units of 32-bit word. There is no documented way of loading the higher 16 bits of a word from memory.

Re: ULP, use Byte instead of Long

Posted: Fri Apr 13, 2018 12:41 pm
by mikemoy
how about shift right 16 bits, then grab them.

Re: ULP, use Byte instead of Long

Posted: Fri Apr 13, 2018 6:04 pm
by fhng11214
Thanks,

Thought about packing them in a 32bis long but the registers, r0, r1, r2, r3 are 16bits long. And we can't offset by 1-3 bytes with ld instruction. Also, ld instruction loads 32bits at a time. What igrr said, can't load the higher 16 bits. Shifting doesn't help becuase it is a 16bits register, there is no upper 16bits.

That confirms it, no go, thanks.