/* ARM assembly Raspberry PI */ /* program Strip comments from a string */ /* REMARK 1 : this program use routines in a include file see task Include a file language arm assembly for the routine affichageMess conversion10 see at end of this program the instruction include */ /*******************************************/ /* Constantes */ /*******************************************/ .include "../constantes.inc" /*******************************************/ /* macros */ /*******************************************/ //.include "../../ficmacros32.inc" @ for developper debugging /*********************************/ /* Initialized data */ /*********************************/ .data szMessDebutPgm: .asciz "Program 32 bits start. \n" szCarriageReturn: .asciz "\n" szMessFinOK: .asciz "Program normal end. \n" szString1: .asciz "apples, pears # and bananas" szString2: .asciz "apples, pears ; and bananas" .align 4 /*********************************/ /* UnInitialized data */ /*********************************/ .bss .align 4 /*********************************/ /* code section */ /*********************************/ .text .global main main: ldr r0,iAdrszMessDebutPgm bl affichageMess @ start message ldr r0,iAdrszString1 mov r1,#'#' bl suppComment ldr r0,iAdrszString1 bl affichageMess ldr r0,iAdrszCarriageReturn bl affichageMess ldr r0,iAdrszString2 mov r1,#';' bl suppComment ldr r0,iAdrszString1 bl affichageMess ldr r0,iAdrszCarriageReturn bl affichageMess ldr r0,iAdrszMessFinOK bl affichageMess 100: mov r7,#EXIT @ program end svc #0 @ system call iAdrszMessDebutPgm: .int szMessDebutPgm iAdrszMessFinOK: .int szMessFinOK iAdrszCarriageReturn: .int szCarriageReturn iAdrszString1: .int szString1 iAdrszString2: .int szString2 /******************************************************************/ /* strip comment string */ /******************************************************************/ /* r0 contains string address */ /* r1 contains comment markers */ /* r0 returns length of string */ suppComment: push {r1-r3,lr} @ save registers mov r2,#0 @ indice string 1: ldrb r3,[r0,r2] cmp r3,#0 @ end string moveq r0,r2 beq 100f cmp r3,r1 addne r2,r2,#1 bne 1b mov r3,#0 strb r3,[r0,r2] mov r0,r2 100: pop {r1-r3,pc} /***************************************************/ /* ROUTINES INCLUDE */ /***************************************************/ .include "../affichage.inc"