TITLE 'Example Pgm for CSCI 360, Programming in Assembler' *********************************************************************** * CSCI 360 Sample Program * * * * Function: This is a sample assembler program. It provides an * * example of what will be expected in documentation and * * programming style. * * * * Input: None (Documentation is required if the XREAD pseudo * * instruction is used) * * * * Output: None (Documentation is required if the XPRNT pseudo * * instruction is used). However, for this * * special program, see NOTES below. * * * * Entry Conds: None (This routine is not called as a subroutine) * * * * Exit Conds: None (This routine does not return parameters) * * * * Program Logic: * * * * 1) Calculate the sum of NUMONE and NUMTWO and place it in NUMTHREE * * 2) Double the value of NUMTWO and place the result in NUMFOUR * * 3) Triple the value of NUMTWO and place the result in NUMFIVE * * 4) Quadruple the value of NUMTWO and place the result in NUMSIX * * 5) Subtract -10 from NUMONE and place result in TEMP3 * * 6) Display the contents of all registers * * 7) Display the contents of the fullwords starting at TEMP1 * * 8) Force an adnormal end to the program by having it execute an * * invalid operation code. * * * * Register Usage: R5, R6, R7 -- Used as work registers * * R14 -- Return address (not used here) * * R15 -- Entry address and base reg for main routine * * * * NOTES: This is a sample program (sequence only, no IF or DO * * constructs). The program does LOAD, STORE, ADD, SUBTRACT, * * XDUMP (registers only), XDUMP of part of program memory * * (the working storage), and ends with a SOC1 abend * * (and dump) at label INVALID. * *********0*****6******************5************************************ EJECT , Note: EJECT statements are not printed in listing HW2 CSECT , Define the Control SECTion name USING HW2,15 Base register will be 15 * * 1) Calculate the sum of NUMONE and NUMTWO and place it in NUMTHREE * L 7,NUMTWO Get contents of NUMTWO to reg 7 L 6,NUMONE Get contents of NUMONE to reg 6 AR 6,7 Get sum of NUMONE and NUMTWO to reg 6 STORE ST 6,NUMTHREE NUMTHREE = NUMONE + NUMTWO * * 2) Double the value of NUMTWO and place the result in NUMFOUR * AR 7,7 Get 2 * contents of NUMTWO to req 7 ST 7,NUMFOUR NUMFOUR = 2 * ( NUMTWO ) * * 3) Triple the value of NUMTWO and place the result in NUMFIVE * SAME1 A 7,NUMTWO Get 3 * contents of NUMTWO to reg 7 ST 7,NUMFIVE NUMFIVE = 3 * ( NUMTWO ) * * 4) Quadruple the value of NUMTWO and place the result in NUMSIX * * * NOTE: The instruction at SAME2 has been created by using a DC * instruction rather than an ADD instruction. The result is * exactly the same as the immediately previous ADD, as can be * verified by checking the generated object code for both * instructions. "Object code - nothing else matters!" * * (This was done solely as a demonstration and is not to be * considered a recommended way to write assembler code. Also * note that this works ONLY because the previous instruction * ended on a fullword boundary, so the DC doesn't have to * skip two bytes to get the correct fullword alignment.) * SAME2 DC F'1517351012' Get 4 * contents of NUMTWO to reg 7 ST 7,NUMSIX NUMSIX = 4 * ( NUMTWO ) * * 5) Subtract -10 from NUMONE and place result in TEMP3 * L 5,NUMONE Get contents of NUMONE to reg 5 S 5,TEMP3+4 Subtract -10 from value of NUMONE ST 5,TEMP3 TEMP3 = NUMONE - (-10) ST 5,FINALNUM FINALNUM = NUMONE - (-10) * * 6) Display the contents of all registers * XDUMP , No operands means display registers * * 7) Display the contents of the fullwords starting at TEMP1 * XDUMP TEMP1,56 Display 14 words starting at TEMP1 * * 8) Force an adnormal end to the program by having it execute an * invalid operation code. Note that the previous instruction * ended on a fullword boundary, so this one does NOT have to * skip two bytes to get the correct fullword alignment. * INVALID DC F'0' Cause abnormal end (ABEND) & dump * TEMP1 DS F Fullword storage, no initial value TEMP2 DC 2F'529' Two words, each initial value +529 TEMP3 DC F'11,-10' Two words, initial values +11 & -10 VAL99 DC F'99' A fullword with initial value +99 * NEXTNUM DS F Fullword storage, no initial value NUMONE DC F'308' Fullword storage, initial value +308 NUMTWO DC F'-1107' Fullword storage, initial value -1107 NUMTHREE DS F To hold sum of NUMONE + NUMTWO NUMFOUR DS F To hold 2 * ( NUMTWO ) NUMFIVE DS F To hold 3 * ( NUMTWO ) NUMSIX DS F To hold 4 * ( NUMTWO ) FINALNUM DS F * END HW2 End assembly, define entry point