Assume you have an 8bit unsigned global variable G Write ass

Assume you have an 8-bit unsigned global variable G. Write assembly code that implements the following: if (G lessthanorequalto 50) isLess(); else isMore():

Solution

To describe the wanted algorithm,a flow chart is to be drawn primarily.To implement assembly code we bring G into Register R0 using LDRB to load an unsigned byte, subtract 50, then branch to next if G is less than or equal to 50.An unsigned conditional branch is used as the data format is unsigned.

LDR R2, =G1    ; R2 = &G1

    LDRB R0, [R2] ; R0 = G1

    CMP R0, #50    ; is G1 > 50?

    BLS next       ; if not, skip to end

    MOV R1, #50    ; R1 = 50

    STRB R1, [R2] ; G1 = 50

next

unsigned char G1;

if(G1>50){

G1 = 50;

}

 Assume you have an 8-bit unsigned global variable G. Write assembly code that implements the following: if (G lessthanorequalto 50) isLess(); else isMore():Sol

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site