Program+1+-+Add+Two+Registers

=Program #1 - Add two registers=

The S/370 has sixteen general purpose registers, which can be used for basic arithmetic, among other uses.

Here we will load two numbers into register 1, and register 2, then add register 1 to register 2.

Enter the following commands into the Hercules console //( The '#' ... and following text are comments that you do not need to enter (Hercules will ignore the input)//

r 2000= 41 10 00 04 # initialize gpr #1 with 4 r 2004= 41 20 00 03 # initialize gpr #2 with 3 r 2008= 1A 21 # add gpr 1 to gpr 2 r 200A=47 00 00 00 # The IBM 'NOP' instruction r 200E=47 00 00 00 # ""

u 2000.20

You should have :


 * R00002000: || 41100004 || LA || 1,4(0,0) || load_address ||
 * R00002004: || 41200003 || LA || 2,3(0,0) || load_address ||
 * R00002008: || 1A21 || AR || 2,1 || load_register ||

Now enter :


 * s+** # turns single step mode on


 * r 01=08 #** We are setting up an EC Mode PSW
 * r 06=2000 #** Set the restart PSW address

Now enter the hercules command **restart**

Then press 3 times, and you should see :

PSW=00080000 00002000 INST=41100004 LA 1,4(0,0) R:00000004:K:06=00002000 00082000 0000200E 00000000 ........... GR00=00000000 **GR01=00000000** **GR02=00000000** GR03=00000000 GR04=00000000 GR05=00000007 GR06=00000000 GR07=00000000 GR08=00000000 GR09=00000000 GR10=00000000 GR11=00000000 GR12=40002002 GR13=00000000 GR14=00000000 GR15=00000000

PSW=00080000 00002004 INST=41200003 LA 2,3(0,0) R:00000003:K:06=00 00002000 00082000 0000200E 000000 ........... GR00=00000000 **GR01=00000004** **GR02=00000000** GR03=00000000 GR04=00000000 GR05=00000007 GR06=00000000 GR07=00000000 GR08=00000000 GR09=00000000 GR10=00000000 GR11=00000000 GR12=40002002 GR13=00000000 GR14=00000000 GR15=00000000

PSW=00080000 00002008 INST=1A21 AR 2,1 GR00=00000000 **GR01=00000004** **GR02=00000003** GR03=00000000 GR04=00000000 GR05=00000007 GR06=00000000 GR07=00000000 GR08=00000000 GR09=00000000 GR10=00000000 GR11=00000000 GR12=40002002 GR13=00000000 GR14=00000000 GR15=00000000

PSW=00082000 0000200A INST=47000000 BC 0,0(0,0) GR00=00000000 **GR01=00000004** **GR02=00000007** GR03=00000000 GR04=00000000 GR05=00000007 GR06=00000000 GR07=00000000 GR08=00000000 GR09=00000000 GR10=00000000 GR11=00000000 GR12=40002002 GR13=00000000 GR14=00000000 GR15=00000000

As you can see GPR 2 contains the result of the AR 2,1 instruction.