ULP, use Byte instead of Long

fhng11214
Posts: 8
Joined: Wed Nov 01, 2017 10:35 pm

ULP, use Byte instead of Long

Postby fhng11214 » Thu Apr 12, 2018 7:17 pm

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.

mikemoy
Posts: 627
Joined: Fri Jan 12, 2018 9:10 pm

Re: ULP, use Byte instead of Long

Postby mikemoy » Fri Apr 13, 2018 4:12 am

Why not just pack your 4 bytes into one 32 bit ?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: ULP, use Byte instead of Long

Postby ESP_igrr » Fri Apr 13, 2018 10:56 am

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.

mikemoy
Posts: 627
Joined: Fri Jan 12, 2018 9:10 pm

Re: ULP, use Byte instead of Long

Postby mikemoy » Fri Apr 13, 2018 12:41 pm

how about shift right 16 bits, then grab them.

fhng11214
Posts: 8
Joined: Wed Nov 01, 2017 10:35 pm

Re: ULP, use Byte instead of Long

Postby fhng11214 » Fri Apr 13, 2018 6:04 pm

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.

Who is online

Users browsing this forum: Bing [Bot] and 129 guests