/* -------------------------------------------------- Define required labels for EGTAPI -------------------------------------------------- */ .global main, Stop, CodeEnd .global DataStart, DataEnd .global i, s, b // i is int, s is short, b is byte /* -------------------------------------------------- Begin of the program instructions -------------------------------------------------- */ .text main: // I changed r1 after making the teaching material... movw r1, #:lower16:0x01020307 // r1 = 00000001 00000010 00000011 00000111 movt r1, #:upper16:0x01020307 // Hex: 0 1 0 2 0 3 0 7 // ------------------------------------------------- // Now we show the effect of strb, strh and str // ------------------------------------------------- // Store byte in r1 to b movw r0, #:lower16:b // Moves the address of memory movt r0, #:upper16:b // variable b into register r0 strb r1,[r0] // Move 1 byte from r1 to var // Store half of r1 to s movw r0, #:lower16:s // Moves the address of memory movt r0, #:upper16:s // variable s into register r0 strh r1,[r0] // Move 2 bytes from r1 to var // Store all of r1 to i movw r0, #:lower16:i // Moves the address of memory movt r0, #:upper16:i // variable i into register r0 str r1,[r0] // Move 4 bytes from r1 to var // Store half of r1 to s movw r0, #:lower16:s // Moves the address of memory movt r0, #:upper16:s // variable s into register r0 str r1,[r0] // Move 2 bytes from r1 to var Stop: CodeEnd: nop /* -------------------------------------------------- Begin of the permanent program variables -------------------------------------------------- */ .data DataStart: i: .4byte -4 // int typed variable s: .2byte -3 // short typed variable b: .byte -2 // byte typed variable DataEnd: .end