; Macros for IBM Mainframe Assembly Language (BAL) ; Instructions ; MVC .macro mvc first,sec,third xl_=%locate(<(>,first) ;L-paren in FIRST xr_=%locate(<)>,first) ;R-paren in FIRST len_x=%length(first) ;Length of FIRST yr_=%locate(<)>,sec) ;R-paren in SEC yl_=%locate(<(>,sec) ;L-paren in SEC len_y=%length(sec) ;Length of SEC len_z=%length(third) ;Length of THIRD zl_=%locate(<(>,third) ;L-paren in THIRD xl_p=xl_+1 ;Position of L-paren xdif_=xr_-xl_-1 ;Size of length yl_p=yl_+1 ;Position of L-paren ydif_=yr_-yl_ ;Size of length zl_p=zl_+1 ;Position of L-paren zdif_=len_z-zl_ ;Size of length pushr #^m ;Save registers .if ne len_x-xr_ .if ne len_y-yr_ ;Operands like abc(3),10(6) movc3 #%extract(xl_p,xdif_,first), - %extract(0,yl_p,sec)r%extract(yl_p,ydif_,sec), - %extract(0,xl_,first) .if_false ;Operands like abc(3),xyz movc3 #%extract(xl_p,xdif_,first),sec,%extract(0,xl_,first) .endc .if_false .if ne zl_-len_z ;Operands like 12(10,6),4(3) movc3 #%extract(xl_p,xdif_,first), - %extract(0,zl_p,third)r%extract(zl_p,zdif_,third), - %extract(0,xl_p,first)r'sec .if_false ;Operands like 12(10,6),xyz movc3 #%extract(xl_p,xdif_,first), - third,%extract(0,xl_p,first)r'sec .endc .endc popr #^m ;Restore registers .endm mvc ; ; BR .macro br first $exit_s ;Ignore the argument, just exit .endm br ; ; B .macro b first brw first ;Word displacement branch .endm b ; ; ; Directives ; ; PICKIT .macro pickit let ;Auxiliary macro for DC one_=%locate(let,) .endm pickit ; ; END .macro end %extract(0,4,<.end>) start ;Make .end start .endm end ; ; CSECT .macro csect .psect ibm,long ;Make own psect .show meb ;Turn on expansion .entry start,^m<> ;Entry point at START .endm csect ; ; DS .macro ds first len_=%length(first) ;Length of FIRST sz_=len_-1 ;Length of number pickit %extract(sz_,1,first) ;Determine type .if eq one_ ;Fullword storage .blkl %extract(0,sz_,first) .endc .if eq one_-1 ;Character storage .blkb %extract(0,sz_,first) .endc .endm ds ; ; IBM Macros (approximately) ; ; OPEN .macro open file,dcb,reclen,access xl_=%locate(access,) ;Determine type of access brw sk'dcb'access ;Skip over the data .align long .noshow meb .if eq xl_ ;Setup to read the file dcb: $fab dcb'_rec: $rab fab=dcb, ubf=dcb'_buf, usz=80 .if_false ;Setup to write the file dcb: $fab rat=cr, mrs=reclen dcb'_rec: $rab fab=dcb, rbf=dcb'_buf, rsz=reclen .endc .show meb dcb'_buf: .blkb 80 ;Buffer for file dcb'_size=reclen sk'dcb'access: movab file+4,dcb+fab$l_fna movb file,dcb+fab$b_fns .if eq xl_ $open fab=dcb ;Open existing file to read .if_false $create fab=dcb ;Create file to write .endc $connect rab=dcb'_rec ;Associate RAB .endm open ; ; CLOSE .macro close dcb $close fab=dcb ;Close the file .endm close