Homework Solution: What does the following program do? When does it stop? What are the values in memory st…

    What does the following program do? When does it stop? What are the values in memory starting from the location pointed by String2? AREA scan, CODE, READWRITE Entry ADR r0,String1 ;r0 points to the source string ADR r1,String2 ;r1 points to the dest string Copy LDRB r2,[r0],#1 ;read a byte and update pointer STRB r2,[r1],#1 ;copy the byte and update ptr CMP r2,#0x00 ;test for terminator BNE Copy ;repeat until terminator found SVC #0x123456 ;stop String1 DCB "this is a string", 0x00 ;dummy string String2 SPACE 20 ;reserve 20 bytes for copy END

    Expert Answer

     
    Please follow the below explanations. Answer:

    What does the coercionthcoming program do? When does it seal? What are the values in fame starting from the subsidence sharp by String2?
    AREA contemplate, CODE, READWRITE
    Entry
    ADR r0,String1 ;r0 points to the fountain string
    ADR r1,String2 ;r1 points to the dest string
    Portraiture LDRB r2,[r0],#1 ;peruse a byte and update pointer
    STRB r2,[r1],#1 ;portraiture the byte and update ptr
    CMP r2,#0x00 ;test coercion terminator
    BNE Portraiture ;repeat until terminator institute
    SVC #0x123456 ;stop
    String1 DCB “this is a string”, 0x00 ;dummy string
    String2 SPACE 20 ;reserve 20 bytes coercion portraiture
    END

    Expert Tally

     

    Please ensue the underneath explanations.

    Answer:

    1) Tally:

    Entry
    ADR r0,String1           ; r0 points to the fountain string
    ADR r1,String2           ; r1 points to the scope string
    Portraiture LDRB r2,[r0],#1 ; // r2 <- [r0+1] , peruse a byte and update pointer
    STRB r2,[r1],#1           ; // r2 -> [r1+1] ,portraiture the byte and update ptr
    CMP r2,#0x00             ;test coercion terminator
    BNE Portraiture                   ; // inhibit often up to ineffectual temperament or terminator is institute
    SVC #0x123456          ;stop
    String1 DCB “this is a string”, 0x00    ;dummy string
    String2 SPACE 20                              ;reserve 20 bytes coercion portraiture
    END

    So, in is aloft jurisprudence, there is a comparing between brace strings where string1 is copied to string2 with there selfsame discourse.

    2) Tally:

    After comparing string1 and string2 when the NULL temperament is institute that implies the comparing is completed and according to program as twain strings are similar ,then it must be sealped.

    3) Tally:

    As r2 <– [r0+1] at the earliest step, then r2 –> [ r1+1]; and as r0 holds string1 discourse so string 2 ‘s starting discourse accomplish be [#0x00 +1] which is sharp to r1.