p set_discard_mode
; --- D --- index 
:
    cmp #$44    ; D ?
    bne :+
    jsr do_line_feed      ; same as LF
    jmp done_escape
; --- M --- reverse index
:
  cmp #$4d    ; M ?
  bne @not_M
  ldx $d6     ; get crsr row
  cpx scroll_region_start     ; top of scroll reg?
  bne :+
  jsr cursor_off    ; yes -> scroll down
  jsr scroll_down_scrollregion  
  jsr cursor_on
  jmp done_escape
:
  cpx #$00    ; top of screen?
  bne :+
  jmp done_escape    ; yes -> do nothing
:     
  dex    