Sprotne naloge 10

1. Rezervirajte prostor za tabelo osmih 8-bitnih elementov. Nato v programski zanki vse elemente postavite na FF(16).

Namig: Uporabite posredno naslavljanje brez odmika. Bazni register usmerite na začetek tabele in ga v zanki povečujte. V vsakem obhodu zanke v trenutni element vpišite FF(16).


2. Podana je tabela, v kateri je 10 nepredznačenih 8-bitnih vrednosti:
TABELA: .byte 1,100,255,24,88,31,56,192,155,224

Napišite program, ki v zanki sešteje vse elemente tabele in rezultat zapiše v 16-bitno spremenljivko REZULTAT.

Nalogo rešite še za primer, če bi bila števila v tabeli 16-bitna in nepredznačena, rezultat pa 32-biten.


3. Podana je tabela:
TABELA: .byte 192,155,224,48,0,128,99,147,177,100

Napišite program, ki v tabeli prešteje vsa števila večja od 100 predznačeno. Rezultat naj bo na koncu izvajanja programa v registru R1.

4. Napišite program, ki prešteje število presledkov v nizu "Zunaj je mraz, sneg in poledica.", ki je zaključen z ničlo. Rezultat naj bo v R1.

5. Podana je tabela, v kateri je 14 16-bitnih vrednosti:

TABELA: .hword 1,100,-255,24,-88,31,56,192,155,-224,0,101,-199,47

Napišite program, ki v zanki vse elemente tabele, ki so večji ali enaki -100 in manjši od 100 postavi na 0.

---------------------------------------------------------------------------------------------
1. Reserve the memory space for a table of eight 8-bit elements. Then in the program loop, set all the elements to the value of FF(16).

Tip: Use indirect addressing without offset. Point the base register to the beginning of the table and increase it in the loop. At every repetition of the loop, write FF(16) into the current element.


2. A table is given containing 10 unsigned 8-bit values:
TABLE: .byte 1,100,255,24,88,31,56,192,155,224

Write a program that sums up all of the table elements in a loop and writes the result to the 16-bit variable RESULT.

Solve the task also for the case if the numbers in the table are 16-bit and unsigned and the result is 32-bit.


3. The following table is given:
TABLE: .byte 192,155,224,48,0,128,99,147,177,100

Write a program that counts all numbers in the table that are greater than 100 signed. The result should be at the end of the program execution in the R1 register.

4. Write a program in assembly language that counts the number of spaces in a string "Outside is cold, wet and slippery.", terminated by zero. Result should be in R1 register.

5. A table is given with 14 16-bit values:

TABELA: .hword 1,100,-255,24,-88,31,56,192,155,-224,0,101,-199,47

Write a program with a loop that sets all table elements that are greater than or equal to -100 and less than 100 to the value of 0.