Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Table 1 shows the machine code format for a number of instructions (LDI, SUBI, S

ID: 3583826 • Letter: T

Question

Table 1 shows the machine code format for a number of instructions (LDI, SUBI, STS). i. Using this table, write the machine code (in hexadecimal) for the assembly code shown in Listing 1. ii. Describe what is meant by Little-Endian byte order and what is the alternative byte ordering format? iii. Draw a table showing how the machine code from part(i) would be stored in program memory beginning at location 0x0000. iv. Rewrite the program, given in Listing 1, to use indirect addressing to specify the location (0x240) to store register R16's contents.

Explanation / Answer

LDI //Loads a constant directly to register 16

SUBI // Subtracts 3 from register and holds the resultant in register 16.

STS // Use to store one byte from a Register to the data space.

ii) Little endian : systems use to hold the least significant byte first. GIF images can be considered to hold little endian values.

Big-Endian: systems use to hold the most significant byte first. JPEG formet can be consider to contain big-endian values.

Middle-Endian: systems use to hold first most significant word , having every word with least significant byte first.

iii)

LDI R16, 0x0000 ; first location

ST x, R16

loop for continually data saving into memory :

INC R16 ; Increment counter which increments by one value

ST x, R16 ; This for storing data into memory location

iv)

Using indirect storing data:

ST x+,rR16     ; use for storing indirect

INC R16       ; increment counter

CPI R16,0x240 ;checking the last location to continue loop,if its last, stop otherwise loop

BRNE loop     ; if we haven't, loop again