1

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?

Zero Piraeus
  • 56,143
  • 27
  • 150
  • 160
Huckle
  • 1,810
  • 3
  • 26
  • 40

2 Answers2

1

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.

TightTight
  • 36
  • 3
  • Thanks for that. I had eventually switched from using the 'Save/Restore cursor with attributes' commands for the 'Save/Restore cursor' command since I use only white-on-black text. Those worked for me. Now that I know this I can go back and fix it. – Huckle Apr 15 '13 at 02:28
0

Putty does not handle all of VT100 right. It sends garbage for all function keys other than F1/F2/F3 and does not handle a variety of the other interfacing correctly. I have yet to find a good program that actually does, so I'm happy that I have a few dumb terminals kicking around (but how silly is that?)

jtl3
  • 1
  • 1
    When I switch putty's function keys mode to "VT100+" I get `ESC O P` - `ESC O S` which should be what the VT100 sends for PF1 - PF4. – CB Bailey Aug 03 '14 at 10:20