; MACRO LIBRARY FOR "SELECT" CONSTRUCT ; ; LABEL GENERATORS GENSLXI MACRO NUM ;; LOAD HL WITH ADDRESS OF CASE LIST LXI H,SELV&NUM ENDM ; GENCASE MACRO NUM,ELT ;; GENERATE JMP TO END OF CASES IF ELT GT 0 JMP ENDS&NUM ;;PAST ADDR LIST ENDIF ;; GENERATE LABEL FOR THIS CASE CASE&NUM&@&ELT: ENDM ; GENELT MACRO NUM,ELT ;; GENERATE ONE ELEMENT OF CASE LIST DW CASE&NUM&@&ELT ENDM ; GENSLAB MACRO NUM,ELTS ;; GENERATE CASE LIST SELV&NUM: ECNT SET 0 ;;COUNT ELEMENTS REPT ELTS ;;GENERATE DW'S GENELT NUM,%ECNT ECNT SET ECNT+1 ENDM ;;END OF DW'S ;; GENERATE END OF CASE LIST LABEL ENDS&NUM: ENDM ; SELNEXT MACRO ;; GENERATE THE NEXT CASE GENCASE %CCNT,%ECNT ;; INCREMENT THE CASE ELEMENT COUNT ECNT SET ECNT+1 ENDM ; SELECT MACRO VAR ;; GENERATE CASE SELECTION CODE SCNT SET 0 ;;COUNT "SELECTS" SELECT MACRO V ;;REDEFINITION OF SELECT SYMPSH %CCNT ;;SAVE PREVIOUS SELECT NUMBER SYMPSH %ECNT ;;AND ITS CASE COUNT CCNT SET SCNT ;;CREATE NEXT SELECT NUMBER SCNT SET SCNT+1 ;;UPDATE SELECT COUNT ;; SELECT ON V OR ACCUMULATOR CONTENTS IF NOT NUL V LDA V ;;LOAD SELECT VARIABLE ENDIF GENSLXI %CCNT ;;GENERATE THE LXI H,SELV# MOV E,A ;;CREATE DOUBLE PRECISION MVI D,0 ;;V IN D,E PAIR DAD D ;;SINGLE PREC INDEX DAD D ;;DOUBLE PREC INDEX MOV E,M ;;LOW ORDER BRANCH ADDR INX H ;;TO HIGH ORDER BYTE MOV D,M ;;HIGH ORDER BRANCH INDEX XCHG ;;READY BRANCH ADDRESS IN HL PCHL ;;GONE TO THE PROPER CASE ECNT SET 0 ;;ELEMENT COUNTER RESET SELNEXT ;;SELECT CASE 0 ENDM ;; INVOKE REDEFINED SELECT THE FIRST TIME SELECT VAR ENDM ; ENDSEL MACRO ;; END OF SELECT, GENERATE CASE LIST GENCASE %CCNT,%ECNT ;;LAST CASE GENSLAB %CCNT,%ECNT ;;CASE LIST ;; GET BACK PREVIOUS SELECT PARAMETERS (IF ANY) SYMPOP ECNT SYMPOP CCNT ENDM