On Tue, Jun 3, 2014 at 7:57 AM, Steve Hobson <[email protected]>
wrote:

> >From: "Rob van der Heij" <[email protected]>
> >Sent: Tuesday, June 03, 2014 1:00 AM
> >
> >Must have muissed something here.
> >A 3-instruction loop to sum bytes.
> >
> >         LA 6,X+offset (last byte of area to be summed)
> >         SR 2,2
> >         SR 4,4
> >Loop IC 4,0(0,6)
> >         AR 2,4
> >         BCT 6,Loop
> >
> >And you can use BCTR to save a few µS.
>
> Sorry to be picky but unless the string starts at location zero I think
> you need:
>
>          LA 6,X      (address of area to be summed)
>          LA 7,offset (offset to last byte of area to be summed)
>          SR 2,2
>          SR 4,4
> Loop IC 4,0(7,6)
>          AR 2,4
>          BCT 7,Loop
>
>
> Best regards, Steve Hobson
> CICS Strategy, HLASM Development, Master Inventor
> Hursley Laboratories, MP 189, Room A4126, UK
> Tie: 246894 International: +44 1962 81 6894
>
> Je me presse de rire de tout, de peur d'être obligé d'en pleurer
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>

Both of the examples assume that the data value is _unsigned_, or is less
than or equal to 127 (0x7F). If this is not true, then I will insert a
slightly different solution:

         LA 6,X      (address of area to be summed)
         LA 7,offset (offset to last byte of area to be summed)
         SR 2,2
*       SR  4,4   Not needed because LB does sign extension.
Loop LB 4,0(7,6) Not sure when this came in.
         AR 2,4
         BCT 7,Loop

-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! <><
John McKown

Reply via email to