View previous topic :: View next topic
|
Author |
Message |
janishyathi bonam
New User
Joined: 05 May 2020 Posts: 2 Location: USA
|
|
|
|
Hi!
I'm trying to LA R1,5000 and it says invalid displacement. Is there a limit to the value of the second operand? How can I achieve this? |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
Yes, there is a limit: 4095. There are at least three ways to achieve your goal.
- Two LA instructions, for example
Code: |
LA R1,2500
LA R1,2500(,R1) |
Dinosaurs like me would use this solution. The actual immediate values can be anything that adds to 5000; they do not have be 2500.
LHI instruction
This solution uses just 4 bytes.
LGFI instruction
This is hidden in Principles of Operation, but the sign of the immediate value is extended to bits 0 through 31 of the register. This solution uses 6 bytes. |
|
Back to top |
|
|
janishyathi bonam
New User
Joined: 05 May 2020 Posts: 2 Location: USA
|
|
|
|
Thank you!! |
|
Back to top |
|
|
Ravi GA
New User
Joined: 20 Mar 2020 Posts: 12 Location: India
|
|
|
|
janishyathi bonam wrote: |
Hi!
I'm trying to LA R1,5000 and it says invalid displacement. Is there a limit to the value of the second operand? How can I achieve this? |
LAY R1,5000 is one more way to load values greater than 4095. |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
Ravi GA wrote: |
... LAY R1,5000 is one more way to load values greater than 4095. |
Yes, indeed. I had forgotten about LAY. I would suggest you read Principles of Operation very carefully before using it. |
|
Back to top |
|
|
|