Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
102
Task/String-length/ARM-Assembly/string-length.arm
Normal file
102
Task/String-length/ARM-Assembly/string-length.arm
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program stringLength.s */
|
||||
|
||||
/* 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 */
|
||||
/* for constantes see task include a file in arm assembly */
|
||||
/************************************/
|
||||
/* Constantes */
|
||||
/************************************/
|
||||
.include "../constantes.inc"
|
||||
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
sMessResultByte: .asciz "===Byte Length=== : @ \n"
|
||||
sMessResultChar: .asciz "===Character Length=== : @ \n"
|
||||
szString1: .asciz "møøse€"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
|
||||
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
sZoneConv: .skip 24
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main: @ entry of program
|
||||
ldr r0,iAdrszString1
|
||||
bl affichageMess @ display string
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
ldr r0,iAdrszString1
|
||||
mov r1,#0
|
||||
1: @ loop compute length bytes
|
||||
ldrb r2,[r0,r1]
|
||||
cmp r2,#0
|
||||
addne r1,#1
|
||||
bne 1b
|
||||
|
||||
mov r0,r1 @ result display
|
||||
ldr r1,iAdrsZoneConv
|
||||
bl conversion10 @ call decimal conversion
|
||||
ldr r0,iAdrsMessResultByte
|
||||
ldr r1,iAdrsZoneConv @ insert conversion in message
|
||||
bl strInsertAtCharInc
|
||||
bl affichageMess
|
||||
|
||||
ldr r0,iAdrszString1
|
||||
mov r1,#0
|
||||
mov r3,#0
|
||||
2: @ loop compute length characters
|
||||
ldrb r2,[r0,r1]
|
||||
cmp r2,#0
|
||||
beq 6f
|
||||
and r2,#0b11100000 @ 3 bytes ?
|
||||
cmp r2,#0b11100000
|
||||
bne 3f
|
||||
add r3,#1
|
||||
add r1,#3
|
||||
b 2b
|
||||
3:
|
||||
and r2,#0b11000000 @ 2 bytes ?
|
||||
cmp r2,#0b11000000
|
||||
bne 4f
|
||||
add r3,#1
|
||||
add r1,#2
|
||||
b 2b
|
||||
4: @ else 1 byte
|
||||
add r3,#1
|
||||
add r1,#1
|
||||
b 2b
|
||||
|
||||
6:
|
||||
mov r0,r3
|
||||
ldr r1,iAdrsZoneConv
|
||||
bl conversion10 @ call decimal conversion
|
||||
ldr r0,iAdrsMessResultChar
|
||||
ldr r1,iAdrsZoneConv @ insert conversion in message
|
||||
bl strInsertAtCharInc
|
||||
bl affichageMess
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc #0 @ perform the system call
|
||||
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
iAdrsMessResultByte: .int sMessResultByte
|
||||
iAdrsMessResultChar: .int sMessResultChar
|
||||
iAdrszString1: .int szString1
|
||||
iAdrsZoneConv: .int sZoneConv
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
.include "../affichage.inc"
|
||||
Loading…
Add table
Add a link
Reference in a new issue