Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Framework for strlen question
- B main
- ; you'll need a few more string declarations here to get the answer `looking right'.
- text1 DEFB "Hello World. Goodbye Universe\0"
- text2 DEFB "1234567890 are the ten decimal digits\0"
- nulltxt DEFB "\0"
- ALIGN
- main ADR R0, text1 ; get address of starting byte of string
- MOV R2, #0 ; Initialise the counter in Register 2
- ADR R3, nulltxt ; load R3 with null for comparison later on
- again LDRB R1, [R0] ; this loads into r1 the byte whose address is currently in R0
- LDRB R4, [R3]
- CMP R1, R4 ; performs comparison to check if R1 is null
- BEQ end ; if equal, must have come to end of string - branch to end
- ADD R2, R2, #1 ;add 1 to counter if not the null
- ADD R0, R0, #1 ;add 1 to the byte address
- B again
- end MOV R0, R2 ;move counter value
- SWI 4 ;print out counter value
- SWI 2 ;end program
Add Comment
Please, Sign In to add comment