¿ªÔÆÌåÓý

Register Add - Quick Question


 

Is there a better way than this to add 8 to R1?

? ? ? ? ?LA? ? R0,8
? ? ? ? ?AR? ? R1,R0? ? ? ? ? Add 8 to R1

Thanks A


 

Yes!?

LA R1,8(R1)

Joe


On Thu, Apr 16, 2020 at 1:09 PM adriansutherland67 <adrian@...> wrote:
Is there a better way than this to add 8 to R1?

? ? ? ? ?LA? ? R0,8
? ? ? ? ?AR? ? R1,R0? ? ? ? ? Add 8 to R1

Thanks A


 

Mostly!

LA works as long as the answer fits in 24 bits so it's no good for
adding 8 to a negative value in R1 for example.

An alternative solution is:

A R1,=F'8'

If memory is really tight, you could use this and possibly save two bytes:

AH R1,=H'8'


Regards,
Peter Coghlan.


Yes!

LA R1,8(R1)

Joe


On Thu, Apr 16, 2020 at 1:09 PM adriansutherland67 <
adrian@...> wrote:

Is there a better way than this to add 8 to R1?

LA R0,8
AR R1,R0 Add 8 to R1

Thanks A



 

This form of LA:

LA Rx,D2(Rx)?

is only good to add up to 4095 to a register. Past that you have to use other instructions. And as Peter noted, the left 8 bits will be zeroed in AM24.

Joe

On Thu, Apr 16, 2020 at 1:30 PM Peter Coghlan <groups@...> wrote:
Mostly!

LA works as long as the answer fits in 24 bits so it's no good for
adding 8 to a negative value in R1 for example.

An alternative solution is:

? ? ? ? ?A? ? ?R1,=F'8'

If memory is really tight, you could use this and possibly save two bytes:

? ? ? ? ?AH? ? R1,=H'8'


Regards,
Peter Coghlan.


>
> Yes!
>
> LA R1,8(R1)
>
> Joe
>
>
> On Thu, Apr 16, 2020 at 1:09 PM adriansutherland67 <
> adrian@...> wrote:
>
> > Is there a better way than this to add 8 to R1?
> >
> >? ? ? ? ? LA? ? R0,8
> >? ? ? ? ? AR? ? R1,R0? ? ? ? ? Add 8 to R1
> >
> > Thanks A
> >
> >
> >
>
>




 

You are gentlemen ... thank you!

It is for a 24 bit address.

A


 

On Thu, Apr 16, 2020 at 06:30 PM, Peter Coghlan wrote:
save two bytes:

AH R1,=H'8'
Peter ... You have taught me what F meant!


 

On Thu, 16 Apr 2020 at 14:56, adriansutherland67
<adrian@...> wrote:

You are gentlemen ... thank you!

It is for a 24 bit address.
A couple of points...

In modern (i.e. z) architectural variants, there are new immediate
instructions that may help with this. Notably there is AHI (Add
Halfword Immediate), which adds a 16-bit signed number from within the
instruction to a register. These are not in S/370, but in practice
they are in Hercules as a retrofitted feature.

The topic of addressing arithmetic in S/370 and successors is worth
becoming familiar with, and will probably help you understand why some
things are done the way they are. Essentially this arithmetic is
unsigned binary, with either one or two 32-bit register and one 12-bit
immediate inputs, and an output that is either 24-bits (in original
370 24-bit mode) or 31-bits (in XA mode and above). It has also been
extended to 64-bits in zArch (and the 12-bit input can be 20-bit in
some instructions), but that's a larger change. Overflows are ignored.

An interesting thing about this arithmetic is that, although it's
unsigned, it can still subtract - this is a surprise to many people
until they think about how twos complement number representation is
defined.

There is a whole section in the Principles of Operation on this.
Higher end machine models typically had a separate addressing adder
just for this purpose, since it is such a common operation.

Tony H.


 

On Fri, Apr 17, 2020 at 05:04 PM, Tony Harminc wrote:
immediate
instructions
It was the lack of these that freaked me out a bit!

To be honest I am just doing the minimum in assembler before passing on to c where the heavy lifting is done.

For example assembler can make a new frame up the stack and detect an overrun. Can flip to an auxiliary stack so it can call a C MORESTAK ... but C handles finding a new stack bin, etc.

If folks are interested! :-)


 

Regarding 24 bit addressing with 32 bit arithmetic. ?When addressing memory in 24 bit mode, only the low 24 bits of the 32 bit generated address are used.
I worked in Poughkeepsie in the early '70s adding MP support to MVS. ?I can remember one incident when Kingston assembled the first fully configured 168 MP that had the maximum memory of 8 Meg on each side for a total of 16 Meg in MP mode. ?Kingston notified MVS development that they had some available machine time on the machine since it had successfully executed all the initial diagnostics. ?Some of the MVS development guys took their disk packs and drove over the river up to Kingston and loaded the disk drives and hit the load button.
The lights blinked for several seconds - then went dead. ?Second attempt resulted in same thing. ?They then took a memory dump, and found nothing in memory. ?They took their disk packs and went back home. ?They discovered that the IPL bootstrap program would determine the memory size of the machine by going into a loop zeroing out 256 bytes of memory at a time expecting to get an addressing exception when it found the end of memory. ?Problem was that with 16 Meg the addressing exception never occurred. ?The 32 bit address went above 16 Meg, but only the low 24 bits were used so the loop clearing memory ended up zeroing out low core and wiped itself out coming from the other direction. ?Very amusing at the time.


 

Wonder how the VM guys handled this new system.


On Sun, Jan 15, 2023, 15:30 James Oswald via <oswaldjb=[email protected]> wrote:
Regarding 24 bit addressing with 32 bit arithmetic.? When addressing memory in 24 bit mode, only the low 24 bits of the 32 bit generated address are used.
I worked in Poughkeepsie in the early '70s adding MP support to MVS.? I can remember one incident when Kingston assembled the first fully configured 168 MP that had the maximum memory of 8 Meg on each side for a total of 16 Meg in MP mode.? Kingston notified MVS development that they had some available machine time on the machine since it had successfully executed all the initial diagnostics.? Some of the MVS development guys took their disk packs and drove over the river up to Kingston and loaded the disk drives and hit the load button.
The lights blinked for several seconds - then went dead.? Second attempt resulted in same thing.? They then took a memory dump, and found nothing in memory.? They took their disk packs and went back home.? They discovered that the IPL bootstrap program would determine the memory size of the machine by going into a loop zeroing out 256 bytes of memory at a time expecting to get an addressing exception when it found the end of memory.? Problem was that with 16 Meg the addressing exception never occurred.? The 32 bit address went above 16 Meg, but only the low 24 bits were used so the loop clearing memory ended up zeroing out low core and wiped itself out coming from the other direction.? Very amusing at the time.


 

Probably the same way MVS 3.8J did - checked to see if the address was 16M and bailed out of the loop.

Laddie




On Sunday, January 15, 2023, 3:46 PM, Bertram Moshier <herc370390vm@...> wrote:

Wonder how the VM guys handled this new system.

On Sun, Jan 15, 2023, 15:30 James Oswald via <oswaldjb=[email protected]> wrote:
Regarding 24 bit addressing with 32 bit arithmetic.? When addressing memory in 24 bit mode, only the low 24 bits of the 32 bit generated address are used.
I worked in Poughkeepsie in the early '70s adding MP support to MVS.? I can remember one incident when Kingston assembled the first fully configured 168 MP that had the maximum memory of 8 Meg on each side for a total of 16 Meg in MP mode.? Kingston notified MVS development that they had some available machine time on the machine since it had successfully executed all the initial diagnostics.? Some of the MVS development guys took their disk packs and drove over the river up to Kingston and loaded the disk drives and hit the load button.
The lights blinked for several seconds - then went dead.? Second attempt resulted in same thing.? They then took a memory dump, and found nothing in memory.? They took their disk packs and went back home.? They discovered that the IPL bootstrap program would determine the memory size of the machine by going into a loop zeroing out 256 bytes of memory at a time expecting to get an addressing exception when it found the end of memory.? Problem was that with 16 Meg the addressing exception never occurred.? The 32 bit address went above 16 Meg, but only the low 24 bits were used so the loop clearing memory ended up zeroing out low core and wiped itself out coming from the other direction.? Very amusing at the time.


 

DOS/VS had an identical bug in it too as I recall.

--
"Fish" (David B. Trout)
Software Development Laboratories

mail: fish@...