TOOLS FOR STRUCTURED PROGRAMMING Structured programming is both a philosophy and a methodology for program and system design. As a philosophy, it requires effort to grasp the concepts, and practice to fully comprehend its capabilities. As a methology, it is a classic candidate for the development of software tools. Such a tool is now available for macro on the PDP-11 series. * A Structured Macro library for the PDP11. PAGE 2 STRUCTURED MACROS FOR THE PDP11 A library of macros is available for the PDP-11 which allow the user to write well structured control constructs. These constructs take the place of all branch instructions and local labels, and most loop counters and test instructions. They provide a more readable form of code, and greatly assist program understandability. The macro file is available as: LB:[1,1] PDPSML.MLB PDPSML was released several years ago, and has been used extensively. In the description below, brackets (< >) are used to denote optional parameters. PAGE 3 $$$SML The following macro initializes the use of the structured macro library. .LIBRARY /sys$library:pdpsml/ .MCALL $$SML $$SML PAGE 4 FOR - ENDF - FEXIT The following macros provide the construct of a counting loop. FOR VAR,FROM,TO<,BY<,SIGN<,JMP>>> Code to be executed in the loop. ENDF where: VAR is the loop index. FROM is the starting value for index. TO is the last value for which the the loop is executed. BY is the increment, which defaults to 1. SIGN (-) indicates decrementing of the loop. (Must be used in addition to negative value of BY.) JMP forces long jumps to be used. NOTE: INDEX VARIABLE IS NOT GUARANTEED TO BE A SPECIFIC VALUE AFTER FALLING THROUGH THE LOOP. FEXIT is used to prematurely exit from a FOR loop; however, its use is discouraged. PAGE 5 DOCASE - CASE - ENDC The following macros are used to provide a multiple-valued decision structure. DOCASE ARG CASE >>> Code for case true. CASE >>> Code for case true. ENDC where: B is present for byte mode. ARG is the decision index, which must not be an external reference. VAL1 is the lower limit for which the block is executed. VAL2 is the upper limit for which the block is executed, defaulting to VAL1. JMP forces a long jump to be used for exit of a case. JMPI forces a long jump to be used to get to the next case statement. NOTE: Only one case is executed, the first one for which the ARG falls within the bounds. If both VAL1 and VAL2 are missing, the always case is generated. PAGE 6 IF - ELSE - ENDI The following macros provide the TRUE/FALSE conditional construct. IF CONDITION<,JMP> Code to be executed if condition satisfied. ELSE Code to be executed if condition not satisfied. ENDI where: B is present for byte mode. CONDITION:= LOGICAL X,RELATION,Y ,STATUS Logical:= Logical variable (nonzero-TRUE, zero-FALSE) X:= Variable Y:= Variable RELATION:= EQ,NE,LT,LE,GT,GE,LO,LOS,HI,HIS,SET, CLEAR STATUS:= CC,CS,VC,VS,EQ,NE,LT,GT,GE,LO,LOS,HI, HIS,PL,MI,CARRY JMP forces long jump to be used. PAGE 7 UNTIL - ENDU - UEXIT The following macros proviie the loop construct with conditional testing at the bottom. UNTIL CONDITION<,JMP> Code to be executed while condition is not satisfied. ENDU where: B is present for byte mode. CONDITION:= LOGICAL X,RELATION,Y ,STATUS Logical:= Logical variable (nonzero-TRUE, zero-FALSE) X:= Variable Y:= Variable RELATION:= EQ,NE,LT,LE,GT,GE,LO,LOS,HI,HIS,SET, CLEAR STATUS:= CC,CS,VC,VS,EQ,NE,LT,GT,GE,LO,LOS,HI, HIS,PL,MI,CARRY JMP forces long jumps to be used. NOTE: The UNTIL loop is always executed at least once. UEXIT is used to prematurely exit from an UNTIL loop; however, its use is discouraged. PAGE 8 WHILE - ENDW - WEXIT The following macros provide the loop construct with conditional testing at the top. WHILE CONDITION<,JMP> Code to be executed while condition is satisfied. ENDW where: B is present for byte mode. CONDITION:= LOGICAL X,RELATION,Y ,STATUS Logical:= Logical variable (nonzero-TRUE, zero-FALSE) X:= Variable Y:= Variable RELATION:= EQ,NE,LT,LE,GT,GE,LO,LOS,HI,HIS,SET, CLEAR STATUS:= CC,CS,VC,VS,EQ,NE,LT,GT,GE,LO,LOS,HI, HIS,PL,MI,CARRY JMP forces long jump to be used. NOTE: The WHILE loop is never executed if the condition is false. WEXIT is used to prematurely exit from an WHILE loop; however, its use is discouraged.