        .title  sys2
PRC_C_CMDBUFSIZ=4097
        .psect  $PDATA quad,pic,con,lcl,shr,noexe,nowrt
;
buf1:   .blkb   PRC_C_CMDBUFSIZ         ; first copy of recall-buffer
buf2:   .blkb   PRC_C_CMDBUFSIZ         ; second copy of recall-buffer
        .psect  $CODE quad,pic,con,lcl,shr,exe,nowrt
;***************************************
;
;  SYS2_RECALL ( CMDSTR , CMDLEN , NCMD )
;
;  recall commands
;
;***************************************
        .entry  sys2_recall,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
        movl    B^4(ap),r11
        cvtwl   (r11),r8                ; r8 = string length
        movl    B^4(r11),r11            ; r11 = string address
        movl    B^8(ap),r10             ; r10 = length address
        movl    #0,r9                   ; r9 = count
        movl    #CTL$AG_CLIDATA,r0
        movl    W^PPD$L_PRC(r0),r0
        movl    W^PRC_L_RECALLPTR(r0),r7
        moval   W^PRC_G_COMMANDS(r0),r0
        subl2   r0,r7
        moval   buf1,r1
        movc3   #PRC_C_CMDBUFSIZ,(r0),(r1)
        moval   buf1,r1
        moval   buf2,r2
        movc3   #PRC_C_CMDBUFSIZ,(r1),(r2)
        moval   buf2,r6
        addl2   r6,r7                   ; r7 = pointer in buf2
        subl3   #PRC_C_CMDBUFSIZ,r7,r6  ; r6 = start in buf1
100$:   subl2   #2,r7                   ; move back to trailing length
        cmpl    r7,r6                   ; if past start in buf1 done
        blss    200$
        tstw    (r7)                    ; if zero length done
        bleq    200$
        cvtwl   (r7),(r10)              ; save length
        subl2   (r10),r7
        movc3   (r10),(r7),(r11)        ; save string
        addl2   #4,r10                  ; increment length address
        addl2   r8,r11                  ; increment string address
        incl    r9                      ; increment count
        subl2   #4,r7                   ; skip 4 bytes (new in later VMS versions??)
        brb     100$
200$:   movl    r9,@B^12(ap)            ; save count
        ret
        .end
