1827946 Members
2930 Online
109973 Solutions
New Discussion

Pa Risc2.0 Assembly

 
dalla-santa_1
New Member

Pa Risc2.0 Assembly

I have a problem with a cast. A program is
doing something roughly like this:

#define NUM 45
short n;
n = 45;

if (n == NUM)

Ok, things are a bit more complex but...
In the asm gerenated, we load the 45 in N
from the stack frame where it was saved:

LDH -60(%r30),%r22 ;offset 0x40
EXTRW,S %r22,31,16,%r1 ;offset 0x44

Then we extract the short value. My question
is: Is the EXTRW,S ... a MUST be instruction?
Isn't the LDH instruction expected to
clear out the remaining bytes of the register?

Reason I ask is that I have one program
that fails the 'if' test though the value
in memory is correct. However, the generated
asm does not include the EXTRW instruction.

Thank you

dalla
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: Pa Risc2.0 Assembly

The EXTRW,S is needed if "n" contains a negative value. If "n" was unsigned short, it wouldn't be needed.