Task

Delete a file called "input.txt" and delete a directory called "docs".

This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.




 
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program deleteFic64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
.equ UNLINK, 35
 
.equ AT_REMOVEDIR, 0x200           // flag for delete directory
 
/******************************************/
/* Initialized data                       */
/******************************************/
.data
szMessDeleteDirOk:   .asciz "Delete directory Ok.\n"
szMessErrDeleteDir:  .asciz "Unable delete dir. \n"
szMessDeleteFileOk:  .asciz "Delete file Ok.\n"
szMessErrDeleteFile: .asciz "Unable delete file. \n"
 
szNameDir:          .asciz "Docs"
szNameFile:         .asciz "input.txt"
 
/******************************************/
/* UnInitialized data                     */
/******************************************/
.bss 
/******************************************/
/*  code section                          */
/******************************************/
.text
.global main 
main:                           // entry of program 
    // delete file
    mov x0,AT_FDCWD             // current directory
    ldr x1,qAdrszNameFile       // file name
    mov x8,UNLINK               // code call system delete file
    svc 0                       // call systeme 
    cmp x0,0                    // error ?
    blt 99f
    ldr x0,qAdrszMessDeleteFileOk // delete file OK 
    bl affichageMess
                               // delete directory
    mov x0,AT_FDCWD            // current directory
    ldr x1,qAdrszNameDir       // directory name
    mov x2,AT_REMOVEDIR
    mov x8,UNLINK              // code call system delete directory 
    svc 0                      // call systeme 
    cmp x0,0                   // error ?
    blt 98f
    ldr x0,qAdrszMessDeleteDirOk // display  message ok directory
    bl affichageMess
                               // end Ok
    b 100f
 
98:                            // display error message delete directory 
    ldr x0,qAdrszMessErrDeleteDir
    bl affichageMess
    b 100f
99:                            // display error message delete file 
    ldr x0,qAdrszMessErrDeleteFile
    bl affichageMess
    b 100f
100:                           // standard end of the program 
    mov x0,0                   // return code
    mov x8,EXIT                // request to exit program
    svc 0                      // perform the system call
qAdrszMessDeleteDirOk:        .quad szMessDeleteDirOk
qAdrszMessErrDeleteDir:       .quad szMessErrDeleteDir
qAdrszMessDeleteFileOk:       .quad szMessDeleteFileOk
qAdrszNameFile:               .quad szNameFile
qAdrszMessErrDeleteFile:      .quad szMessErrDeleteFile
qAdrszNameDir:                .quad szNameDir
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
 