Create a file: Difference between revisions

add task to ARM64 assembly Raspberry Pi
(add task to ARM64 assembly Raspberry Pi)
Line 16:
echos > \output.txt
mkdir \docs</lang>
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<lang AArch64 Assembly>
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program createDirFic64.s */
 
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
.equ MKDIRAT, 0x22 // Linux Syscall create directory
.equ CHGDIR, 0x31 // Linux Syscall change directory
 
/*******************************************/
/* Initialized data */
/*******************************************/
.data
szMessCreateDirOk: .asciz "Create directory Ok.\n"
szMessErrCreateDir: .asciz "Unable create directory. \n"
szMessErrChangeDir: .asciz "Unable change directory. \n"
szMessCreateFileOk: .asciz "Create file Ok.\n"
szMessErrCreateFile: .asciz "Unable create file. \n"
szMessErrCloseFile: .asciz "Unable close file. \n"
szNameDir: .asciz "Dix1"
szNameFile: .asciz "file1.txt"
/*******************************************/
/* UnInitialized data */
/*******************************************/
.bss
/*******************************************/
/* code section */
/*******************************************/
.text
.global main
main: // entry of program
// create directory
mov x0,AT_FDCWD
ldr x1,qAdrszNameDir // directory name
mov x2,0775 // mode (in octal zero is important !!)
mov x8,MKDIRAT // code call system create directory
svc 0 // call systeme
cbnz x0,99f // error ?
// display message ok directory
ldr x0,qAdrszMessCreateDirOk
bl affichageMess
// change directory
ldr x0,qAdrszNameDir // directory name
mov x8, #CHGDIR // code call system change directory
svc #0 // call systeme
cbnz x0,98f // error ?
// create file
mov x0,AT_FDCWD // current directory
ldr x1,qAdrszNameFile // directory name
mov x2,O_CREAT|O_WRONLY // flags
mov x3,0644 // this zone is Octal number (0 before)
mov x8,OPEN // code call system open file
svc #0 // call systeme
cmp x0,#0 // error ?
ble 97f
mov x19,x0 // save File Descriptor
// display message ok file
ldr x0,qAdrszMessCreateFileOk
bl affichageMess
// close file
mov x0,x19 // Fd
mov x8,CLOSE // close file
svc 0
cbnz x0,96f // error ?
mov x0,0 // return code Ok
b 100f // end Ok
96: // display error message close file
ldr x0,qAdrszMessErrCloseFile
bl affichageMess
mov x0,1 // return code error
b 100f
97: // display error message create file
ldr x0,qAdrszMessErrCreateFile
bl affichageMess
mov x0,1 // return code error
b 100f
98: // display error message change directory
ldr x0,qAdrszMessErrChangeDir
bl affichageMess
mov x0,1 // return code error
b 100f
99: // display error message create directory
ldr x0,qAdrszMessErrCreateDir
bl affichageMess
mov x0,1 // return code error
b 100f
100: // standard end of the program
mov x8,EXIT // request to exit program
svc 0 // perform the system call
qAdrszMessCreateDirOk: .quad szMessCreateDirOk
qAdrszMessErrCreateDir: .quad szMessErrCreateDir
qAdrszMessErrChangeDir: .quad szMessErrChangeDir
qAdrszMessCreateFileOk: .quad szMessCreateFileOk
qAdrszNameFile: .quad szNameFile
qAdrszMessErrCreateFile: .quad szMessErrCreateFile
qAdrszMessErrCloseFile: .quad szMessErrCloseFile
qAdrszNameDir: .quad szNameDir
/********************************************************/
/* File Include fonctions */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
 
</lang>
=={{header|Ada}}==
Notes: