Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly 370 > Re: PACK with e...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 7 Topic 273 of 328
Post > Topic >>

Re: PACK with explicit zero length for second operand

by "John Small" <zjsmallz@[EMAIL PROTECTED] > Mar 23, 2006 at 12:08 PM

On Wed, 22 Mar 2006 12:35:47 UTC, glen herrmannsfeldt 
<gah@[EMAIL PROTECTED]
> wrote:

> John Small wrote:
> > On Wed, 22 Mar 2006 03:40:58 UTC, bo774@[EMAIL PROTECTED]
 (Kelly 
> > Bert Manning) wrote:
> 
> >>does that end up unpacking a single byte at the specified
displacement?
> >>PARM5D	DS	0H	
> >>	BCTR	R14,0	R14 = HEX LTH	
> >>	EX	R14,PARM5EX	PACK WAIT TIME	
> (snip)
> 
> >>PARM5EX	PACK	DWORD+6(2),0(0,R15) USE 1ST 2 BYTES ONLY	
> 
> > R14 gets ORed with the second byte of the assembled PACK instruction. 
> > As assembled this 2nd byte would be X'10', the first nibble being the 
> > "length - 1" of the target and the second nibble the "length - 1" of 
> > the source.
> 
> > If R14 has a value of 2 then the effective length of the source is 3 
> > and the ORed second byte is X'12'.  And 3 characters will fit exactly 
> > into 2-byte packed field.
> 
> But there is BCTR so R14 should be 1 when it gets to the EX.
> 

You are right about R14 not being 2.

I was responding to the OP's text "If R14 has a value of 2 wouldn't 
the effective length of the target field be 3 bytes..." and not 
looking at the code.

The OP's problem seemed to be that he thought that R14, as used in 
this code, would determine the run-time target length and possibly 
overrunning the DWORD field.  And my response was an attempt to say 
that R14, as used in this code, is intended to affect the run-time 
source length.

Upon further thought, the code snippet in the original post does not 
ensure that R14 is positive.  If R14 is negative or zero upon entry to
the code snippet then it could affect both of the run-time lengths, 
depending on the low-order byte of R14 after the BCTR.  So a 
non-positive value in R14 could cause overruns in the DWORD field.  
For example, a value of 0 in R14 upon entry to the code snippet...
   - would be changed to -1 by the BCTR
   - the -1 in R14 would cause the EX'd PACK instruction (after the 
run-time OR of the 2nd byte of the PACK instruction) to be the 
equivalent of:
      PACK DWORD+6(16),0(16,R15)

So if the OP was trying to find a bug in this code that was causing 
overruns, then the bug may be that this code does not ensure that R14 
has a valid length (1-16 on entry, 0-15 after the BCTR) for a source 
field.

-- 

John Small

(remove the z's for email address)
 




 7 Posts in Topic:
PACK with explicit zero length for second operand
bo774@[EMAIL PROTECTED]   2006-03-22 03:40:58 
Re: PACK with explicit zero length for second operand
"John Small" &l  2006-03-22 11:28:07 
Re: PACK with explicit zero length for second operand
glen herrmannsfeldt <g  2006-03-22 04:35:47 
Re: PACK with explicit zero length for second operand
"John Small" &l  2006-03-23 12:08:25 
Re: PACK with explicit zero length for second operand
bo774@[EMAIL PROTECTED]   2006-03-23 15:10:47 
Re: PACK with explicit zero length for second operand
"John Small" &l  2006-03-24 11:43:42 
Re: PACK with explicit zero length for second operand
"robin" <rob  2006-03-26 13:03:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 20:27:47 CDT 2008.