Task

Demonstrate how to achieve movement of the terminal cursor:

 how to move the cursor one position to the left
 how to move the cursor one position to the right
 how to move the cursor up one line (without affecting its horizontal position)
 how to move the cursor down one line (without affecting its horizontal position)
 how to move the cursor to the beginning of the line
 how to move the cursor to the end of the line
 how to move the cursor to the top left corner of the screen
 how to move the cursor to the bottom right corner of the screen


For the purpose of this task, it is not permitted to overwrite any characters or attributes on any part of the screen (so outputting a space is not a suitable solution to achieve a movement to the right).



Handling of out of bounds locomotion
This task has no specific requirements to trap or correct cursor movement beyond the terminal boundaries, so the implementer should decide what behavior fits best in terms of the chosen language.   Explanatory notes may be added to clarify how an out of bounds action would behave and the generation of error messages relating to an out of bounds cursor position is permitted.




 
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program cursorMove64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
/* Initialized data */
.data
szMessStartPgm:            .asciz "Program start \n"
szMessEndPgm:              .asciz "Program normal end.\n"
szMessColorRed:            .asciz "Color red.\n"
szCodeInit:                .asciz "\033[0m"                    // color reinit
szCodeRed:                 .asciz "\033[31m"                   // color red
szCodeBlue:                .asciz "\033[34m"                   // color blue
szMessMove:                .asciz "\033[A\033[6CBlue Message up and 6 location right."
szMessMoveDown:            .asciz "\033[31m\033[BRed text location down"
szMessTopLeft:             .asciz "\033[;HTOP LEFT"
szCarriageReturn:          .asciz "\n"
 
/* UnInitialized data */
.bss 
 
/*  code section */
.text
.global main 
main: 
 
    ldr x0,qAdrszMessStartPgm                   // display start message
    bl affichageMess
    ldr x0,qAdrszCodeRed                        // color red
    bl affichageMess
    ldr x0,qAdrszMessColorRed
    bl affichageMess
    ldr x0,qAdrszCodeBlue
    bl affichageMess
    ldr x0,qAdrszMessMove
    bl affichageMess
    ldr x0,qAdrszMessMoveDown                   // move pointer down
    bl affichageMess
    ldr x0,qAdrszMessTopLeft
    bl affichageMess
    ldr x0,qAdrszCarriageReturn                 // start next line
    bl affichageMess
    ldr x0,qAdrszCodeInit                       // color reinitialize
    bl affichageMess
    ldr x0,qAdrszMessEndPgm                     // display end message
    bl affichageMess
 
100:                                            // standard end of the program
    mov x0,0                                    // return code
    mov x8,EXIT                                 // request to exit program
    svc 0                                       // perform system call
qAdrszMessStartPgm:        .quad szMessStartPgm
qAdrszMessEndPgm:          .quad szMessEndPgm
qAdrszCodeInit:            .quad szCodeInit
qAdrszCodeRed:             .quad szCodeRed
qAdrszCodeBlue:            .quad szCodeBlue
qAdrszMessColorRed:        .quad szMessColorRed
qAdrszMessMove:            .quad szMessMove
qAdrszCarriageReturn:      .quad szCarriageReturn
qAdrszMessMoveDown:        .quad szMessMoveDown
qAdrszMessTopLeft:         .quad szMessTopLeft
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
 