103 lines
3.8 KiB
Plaintext
103 lines
3.8 KiB
Plaintext
/* ARM assembly AARCH64 Raspberry PI 3B */
|
|
/* program createXml64.s */
|
|
/* install package libxml++2.6-dev */
|
|
/* link with gcc option -I/usr/include/libxml2 -lxml2 */
|
|
|
|
/*******************************************/
|
|
/* Constantes file */
|
|
/*******************************************/
|
|
/* for this file see task include a file in language AArch64 assembly*/
|
|
.include "../includeConstantesARM64.inc"
|
|
|
|
/*********************************/
|
|
/* Initialized data */
|
|
/*********************************/
|
|
.data
|
|
szMessEndpgm: .asciz "Normal end of program.\n"
|
|
szFileName: .asciz "file1.xml"
|
|
szFileMode: .asciz "w"
|
|
szMessError: .asciz "Error detected !!!!. \n"
|
|
|
|
szVersDoc: .asciz "1.0"
|
|
szLibRoot: .asciz "root"
|
|
szLibElement: .asciz "element"
|
|
szText: .asciz "some text here"
|
|
szCarriageReturn: .asciz "\n"
|
|
/*********************************/
|
|
/* UnInitialized data */
|
|
/*********************************/
|
|
.bss
|
|
.align 4
|
|
|
|
/*********************************/
|
|
/* code section */
|
|
/*********************************/
|
|
.text
|
|
.global main
|
|
main: // entry of program
|
|
ldr x0,qAdrszVersDoc
|
|
bl xmlNewDoc // create doc
|
|
mov x19,x0 // doc address
|
|
mov x0,#0
|
|
ldr x1,qAdrszLibRoot
|
|
bl xmlNewNode // create root node
|
|
cbz x0,99f
|
|
mov x20,x0 // node root address
|
|
mov x0,x19
|
|
mov x1,x20
|
|
bl xmlDocSetRootElement
|
|
mov x0,#0
|
|
ldr x1,qAdrszLibElement
|
|
bl xmlNewNode // create element node
|
|
mov x21,x0 // node element address
|
|
ldr x0,qAdrszText
|
|
bl xmlNewText // create text
|
|
mov x22,x0 // text address
|
|
mov x0,x21 // node element address
|
|
mov x1,x22 // text address
|
|
bl xmlAddChild // add text to element node
|
|
mov x0,x20 // node root address
|
|
mov x1,x21 // node element address
|
|
bl xmlAddChild // add node elemeny to root node
|
|
ldr x0,qAdrszFileName
|
|
ldr x1,qAdrszFileMode
|
|
bl fopen // file open
|
|
cmp x0,#0
|
|
blt 99f
|
|
mov x23,x0 // File descriptor
|
|
mov x1,x19 // doc
|
|
mov x2,x20 // root
|
|
bl xmlElemDump // write xml file
|
|
cmp x0,#0
|
|
blt 99f
|
|
mov x0,x23
|
|
bl fclose // file close
|
|
mov x0,x19
|
|
bl xmlFreeDoc
|
|
bl xmlCleanupParser
|
|
ldr x0,qAdrszMessEndpgm
|
|
bl affichageMess
|
|
b 100f
|
|
99: // error
|
|
ldr x0,qAdrszMessError
|
|
bl affichageMess
|
|
100: // standard end of the program
|
|
mov x0,0 // return code
|
|
mov x8,EXIT // request to exit program
|
|
svc 0 // perform the system call
|
|
|
|
qAdrszMessError: .quad szMessError
|
|
qAdrszMessEndpgm: .quad szMessEndpgm
|
|
qAdrszVersDoc: .quad szVersDoc
|
|
qAdrszLibRoot: .quad szLibRoot
|
|
qAdrszLibElement: .quad szLibElement
|
|
qAdrszText: .quad szText
|
|
qAdrszFileName: .quad szFileName
|
|
qAdrszFileMode: .quad szFileMode
|
|
qAdrszCarriageReturn: .quad szCarriageReturn
|
|
/********************************************************/
|
|
/* File Include fonctions */
|
|
/********************************************************/
|
|
/* for this file see task include a file in language AArch64 assembly */
|
|
.include "../includeARM64.inc"
|