;++RAD50.MAR ; ; FACILITY: ; Fermilab Accelerator Control System. ; General macro library. ; ; ABSTRACT: ; Macros to generate Radix-50 symbol values and data constants. ; ; ENVIRONMENT: ; Input to generate a macro library. ; ;-- ; ; MODIFICATION HISTORY: ; ; AUTHOR: F. Nagy Creation date: 19-Jan-82 ; ; V02.00 25-May-82 FJN Change $.RAD50S to deal with 1-6 characters and ; be externally useable macro. ; V02.01 04-Nov-82 FJN Make sure .ERROR and .WARN retain message text ; ;+/$..R50 ; ; $..R50 symbol,char ; ; Internally used macro, converts a single character from ASCII to Radix-50. ; ; symbol symbol which is set equal to the Radix-50 value of the ; character. ; ; char character to be converted. ; ;- .MACRO $..R50 symbol,char symbol = 0 ;Initialize value ..a = ^A/char/ ;Get ASCII value of character .IF GREATER_EQUAL <..a-^A/\/> ;Is character lower case? ..a = ..a - ^X20 ;Yes, convert to upper case .ENDC ;..a>="\" .IF GREATER_EQUAL <..a-^A/A/> ;Is character > or = to "A", .IF LESS_EQUAL <..a-^A/Z/> ; and < or = to "Z" symbol = ..a - ^X40 ;Yes, return A=1,...,Z=26 (decimal) .MEXIT .ENDC ;..a<="Z" .ENDC ;..a>="A" .IF GREATER_EQUAL <..a-^A/0/> ;Is character > or = to "0", .IF LESS_EQUAL <..a-^A/9/> ; and < or = to "9" symbol = ^O36 + <..a - ^A/0/> ;Yes, return 0=36 (octal), etc. .MEXIT .ENDC ;..a<="9" .ENDC ;..a>="0" .IF EQUAL <..a-^X20> ;Is it a space? .MEXIT ;Yes, return 0 .ENDC ;..a=" " .IF EQUAL <..a-^A/$/> ;Is it a dollar sign? symbol = ^O33 ;Yes, return octal 33. .MEXIT .ENDC ;..a="$" .IF EQUAL <..a-^A/./> ;Is it a period (dot)? symbol = ^O34 ;Yes, return octal 34. .MEXIT .ENDC ;..a="." .WARN ; /char/ is not a legal Radix-50 character ; .ENDM $..R50 ;+/$..R50S ; ; $..R50S symbol,txt ; ; Internally used macro converts a 1-3 character text string into Radix-50 and ; returns the Radix-50 value in a symbol. ; ; symbol symbol in which the Radix-50 value is returned. ; ; txt 1-3 character text string which is to be converted to Radix-50. ; ;- .MACRO $..R50S symbol,txt symbol = 0 .IF GREATER <%LENGTH(txt)-3> .ERROR ; The text string has more than 3 characters - $..R50S ; .MEXIT .ENDC ;length(txt)>3 .IRPC ..c, ;Loop over all characters in text $..R50 ..r,<..c> ;Get Radix-50 value of character symbol = <^O50*symbol> + ..r ;Assemble Radix-50 value in symbol, ; shifting previous characters by ; multiplying by 50 (octal) .ENDR .IF LESS_THAN <%LENGTH(txt)-3> symbol = ^O50*symbol ;Shift value if 1-2 characters only .IF EQUAL <%LENGTH(txt)-1> symbol = ^O50*symbol ;Shift value if only 1 character .ENDC ;length(txt)=1 .ENDC ;length(txt)<3 .ENDM $..R50S ;+ $_RAD50L ; ; $.RAD50L text ; ; Generate a longword (.LONG) containing the Radix-50 value of a 1-6 ; character text string. ; ; text 1-6 character string to be stored as Radix-50. ; ;- .MACRO $.RAD50L text .IF LESS_EQUAL <%LENGTH(text)-3> ;Is text 1-3 characters? $..R50S ..rw, ;Convert into a single word .LONG ..rw ;Store as longword (upper 16-bits zero) .IF_FALSE ;No, 4-6 characters .IF GREATER <%LENGTH(text)-6> ;Is text over 6 characters? .ERROR ; The text string has more than 6 characters - $.RAD50L ; .MEXIT .ENDC ;length(text)>6 $..R50S ..rw,<%EXTRACT(0,3,text)> .WORD ..rw $..R50S ..rw,<%EXTRACT(3,3,text)> .WORD ..rw .ENDC ;length(text)<=3 .ENDM $.RAD50L ;+ $_RAD50S ; ; $.RAD50S sym,text ; ; Define a symbol to have the Radix-50 value of a 1-6 character ; text string. ; ; sym symbol to be defined with Radix-50 value. ; ; text 1-6 character string to be stored as Radix-50. ; ;- .MACRO $.RAD50S sym,text .IF LESS_EQUAL <%LENGTH(text)-3> ;Is text 1-3 characters? $..R50S sym, ;Convert into value (lower 16-bits) .IF_FALSE ;No, 4-6 characters .IF GREATER <%LENGTH(text)-6> ;Is text over 6 characters? .ERROR ; The text string has more than 6 characters - $.RAD50S ; .MEXIT .ENDC ;length(text)>6 $..R50S ..rw,<%EXTRACT(3,3,text)> sym = ..rw@16 ;4-6 characters into upper 16-bits $..R50S ..rw,<%EXTRACT(0,3,text)> sym = sym!..rw ;1-3 characters into lower 16-bits .ENDC ;length(text)<=3 .ENDM $.RAD50S ;+ $_RAD50W ; ; $.RAD50W text ; ; Generate a .WORD containing the Radix-50 value of a 1-3 character text ; string. ; ; text 1-3 character text string to be stored as a Radix-50 value. ; ;- .MACRO $.RAD50W text $..R50S ..rw, .WORD ..rw .ENDM $.RAD50W