Sprotne naloge 10
완료 조건
Due: 수요일, 3 1월 2024, 11:56 PM
1. Napišite program s programsko zanko, ki ima še eno vgnezdeno zanko. Notranja vgnezdena zanka naj se izvrši 48000-krat in v njej naj se 32-bitna vrednost v r1 vsakič poveča za 1. Zunanja zanka naj se izvede toliko krat, da bo vrednost v r1 na koncu programa enaka 24 000 000, če smo jo na začetku programa nastavili na 0.
2. 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).
3. Podana je tabela predznačenih števil:
TABELA: .byte 192,155,224,48,0,128,99,147,177,100
Napišite program, ki sešteje vsa števila v tabeli in zapiše rezultat v 16-bitno spremenljivko REZULTAT. Program naj tudi prešteje vsa števila večja od 100. Rezultat preštevanja naj bo na koncu izvajanja programa v registru R1.
Kaj je potrebno spremeniti, če so elementi tabele 16-bitna števila in je REZULTAT 32-bitna spremenljivka?
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. Write a program with an external loop that includes another inner (nested) loop. The internal nested loop should be executed 48 000 times and every time the 32-bit value in r1 should be incremented by 1. The external loop should be repeated so many times that the value at r1 at the end of the program (both loops) is equal to 24 000 000, if initial value was set to 0.
2. 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.
3. The following table of signed numbers is given:
TABLE: .byte 192,155,224,48,0,128,99,147,177,100
Write a program that calculates the sum of all numbers in the table and stores the solution to a 16-bit variable RESULT. In addition, count 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.
What changes if the elements of the table are 16-bit numbers, and RESULT is a 32-bit variable?
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.
2. 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).
3. Podana je tabela predznačenih števil:
TABELA: .byte 192,155,224,48,0,128,99,147,177,100
Napišite program, ki sešteje vsa števila v tabeli in zapiše rezultat v 16-bitno spremenljivko REZULTAT. Program naj tudi prešteje vsa števila večja od 100. Rezultat preštevanja naj bo na koncu izvajanja programa v registru R1.
Kaj je potrebno spremeniti, če so elementi tabele 16-bitna števila in je REZULTAT 32-bitna spremenljivka?
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. Write a program with an external loop that includes another inner (nested) loop. The internal nested loop should be executed 48 000 times and every time the 32-bit value in r1 should be incremented by 1. The external loop should be repeated so many times that the value at r1 at the end of the program (both loops) is equal to 24 000 000, if initial value was set to 0.
2. 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.
3. The following table of signed numbers is given:
TABLE: .byte 192,155,224,48,0,128,99,147,177,100
Write a program that calculates the sum of all numbers in the table and stores the solution to a 16-bit variable RESULT. In addition, count 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.
What changes if the elements of the table are 16-bit numbers, and RESULT is a 32-bit variable?
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.