.TITLE PICT .IDENT "V1.0" .NLIST ME,BEX,CND .ENABL LC .sbttl Author's Credits ; Author: Henry R. Tumblin ; Date: 03-Apr-79 ; Version: 1.0 ; Module Name: PICT ; For: Systems/Utility Subroutines ; Residence: DB1:[1,20]PICT.MAC ; Machine/System: PDP-11/70 IAS V2.0 ; Type/Language: Subroutine/Assembler(MACRO-11) ; Abstract: This subroutine will convert a ; single precision integer to ; ASCII with leading zeros preserved. ; This gives the effect of a PICTURE ; variable. ; ; Subroutines used: ; $SAVAL - Register save routine. ; $CBDSG - Convert binary to signed decimal. ; Edits: ;No. Date By Reason ;--- --------- ----- ------------------------------------------------ ; none .sbttl Module Description ; FORTRAN CALL IS: ; CALL PICT(SRC,DST,LEN) ; WHERE: ; SRC -- THE SOURCE NUMBER ; DST -- THE DESTINATION NUMBER ; LEN -- THE LENGTH OF THE OUTPUT FIELD .sbttl Start code section. .GLOBL PICT .PSECT PICT,I,RO,REL ; Define for Read/Only psect ; .PSECT PICT,I,RW,REL ; Define for Read/Write psect PICT: CALL $SAVAL ; Save our registers SUB #10.,SP ; Get scratch area on stack MOV SP,R0 ; Point to it in R0 MOV @2(R5),R1 ; Get the number to convert CLR R2 ; Zero suppress for now. CALL $CBDSG ; Convert to ASCII ; Now fill in the output area. R0 points to the ; end of the converted string. So, first fill the output field ; with zeros then move the number into place in the string. MOV 4(R5),R2 ; Point to output area MOV @6(R5),R3 ; Get length count BEQ 100$ ; EQ - then exit 10$: MOVB #'0,(R2)+ ; Fill with zeros SOB R3,10$ ; Loop till thru. ; Now move the completed string in to place. ; Check for a minus sign also . MOV SP,R1 ; Reset pointer to converted string MOV 4(R5),R2 ; Reset pointer to output area CMPB #'-,(R1) ; Is the number negative? BNE 20$ ; NE - then skip it MOVB (R1)+,(R2) ; Move into place. 20$: MOV R0,R4 ; Calculate length SUB R1,R4 ; of converted string BEQ 100$ ; EQ - then leave MOV R4,R3 ; Save count of characters MOV @6(R5),R4 ; Get length of DST area SUB R3,R4 ; Get length of output string ADD R4,R2 ; Set pointer in DST area 30$: MOVB (R1)+,(R2)+ ; Move into place SOB R3,30$ ; Loop till thru 100$: ADD #10.,SP ; Clean up stack RETURN ; And leave .END