puttyansi-escapevt10068hc12

Does PuTTy work correctly with ANSI/VT100 escape sequences?


I'm writing a program for a class in HC12 Assembly for the Freescale MC9S12C32 processor. I'm using PuTTy as the terminal attached to the device via serial(-over-USB). For this assignment, we are supposed to use VT100/ANSI escape sequences to move the cursor to an arbitrary location and write the current time and then return it so the user can type and have their input echo'd back.

I'm using the below sequence to save the cursor, move it, and return it. Yet for some reason PuTTy just places the cursor in the upper-left and fails to return it.

ESC         EQU   $1B ; ASCII ESC
SAVECUR     EQU   $37 ; ASCII 7
RESTCUR     EQU   $38 ; ASCII 8

SaveCursor  PSHA
            LDAA  #ESC             ; Use Escape Sequence
            JSR   putchar
            LDAA  #'['
            JSR   putchar
            LDAA  #SAVECUR         ; To save cursor location
            JSR   putchar
            PULA
            RTS

GotoClkPos  PSHA
            LDAA  #ESC             ; Move Cursor
            JSR   putchar
            LDAA  #'['
            JSR   putchar
            LDAA  #$05             ; To Row 5
            JSR   putchar
            LDAA  #';'
            JSR   putchar
            LDAA  #$05             ; Column 5
            JSR   putchar
            LDAA  #'H'
            JSR   putchar
            PULA
            RTS

RestCursor  PSHA
            LDAA   #ESC            ; Use Escape Sequence
            JSR    putchar
            LDAA   #'['
            JSR    putchar
            LDAA   #RESTCUR        ; To Restore Cursor
            JSR    putchar
            PULA
            RTS

Am I coding the escape sequences wrong or does PuTTy not handle them as I expect?


Solution

  • Your escape sequences are wrong. You should remove the '[' from SaveCursor and RestCursor (save cursor=ESC+'7', restore=ESC+'8'). GotoClkPos seems OK though.

    PuTTY handles VT100-commands just fine. Although I'm having trouble getting some commands to work, like hide cursor.