Neobvezne dodatne naloge za utrjevanje
Zahteve zaključka
Rok za oddajo: sreda, 3. januar 2024, 23.56
1. Podana je tabela, v kateri je 14 8-bitnih vrednosti:
TABELA: .byte 1,100,255,24,88,31,56,192,155,224, 0, 101, 199, 47
a) Napišite program, ki v zanki vse elemente tabele, ki so pozitivni, postavi na -1.
b) Napišite program, ki v zanki vse elemente tabele, ki so pozitivni, negira (npr. iz 10 spremeni na -10).
c) Napišite program, ki v zanki vse elemente tabele, ki so vecji ali enaki -48 in manjši od 48 (predznačeno!) postavi na 0.
2. Z uporabo pogojnih skokov napišite programa, ki ustreza naslednjemu navodilu:
IF A<10 THEN B=B-1
IF A=10 THEN B=B+1
IF A>10 THEN B=B+2
A in B sta 16-bitni predznačeni spremenljivki.
3. Z uporabo pogojnih skokov napišite program, ki ustreza naslednjemu navodilu:
IF A=10 THEN
B=B+1
ELSE B=B+2
A in B sta 16-bitni predznačeni spremenljivki.
4. Nalogi 2. in 3. rešite s pogojnim izvajanjem ukazov.
5. Z uporabo pogojnega izvajanja ukazov napišite program za iskanje največjega skupnega delitelja (Evklidov algoritem) na
naslednji način (podoben potek algoritma smo obravnavali na vajah) :
ZANKA: PRIMERJAJ r1 in r2
IF r1 > r2 THEN R1=R1-R2 ELSE
IF r1 < r2 THEN R2=R2-R1
IF r1 != r2 THEN GOTO ZANKA
6. Rezervirajte prostor za tabelo 15 32-bitnih elementov. Nato v programski zanki elemente izmenično postavljajte na 1, 0 in -1 (prvi element na 1, drugi na 0, tretji na -1, četrti spet na 1, ...). Program naredite tako, da v register pred zanko naložite konstanto 1 in ga po vsakem vpisu v tabelo zmanjšate za 1. Ko vpišete vrednost -1, register spet postavite na 1 itn.
----------------------------------------------------
----------------------------------------------------
1. The following table is given, containing 14 8-bit long values:
TABLE: .byte 1,100,255,24,88,31,56,192,155,224, 0, 101, 199, 47
a) Write a program in ARM assembly in which, inside a loop, all positive elements of the table are set to -1.
b) Write a program in ARM assembly in which, inside a loop, all positive elements of the table are negated (i.e. 10 -> -10).
c) Write a program in ARM assembly in which, inside a loop, all elements that are contained in the interval [-48,48[ are set to 0..
2. Implement the following IF-THEN expression using conditional branches:
a) IF A<10 THEN B=B-1
b) IF A=10 THEN B=B+1
c) IF A>10 THEN B=B+2
A and B are 16-bits signed variables.
3. Using conditional branches, implement the following code in ARM assembly:
IF A=10 THEN
B=B+1
ELSE
B=B+2
A and B are 16-bits signed variables..
4. Solve the 2nd and 3rd problem with the aid of conditional instruction execution.
5. Using conditional instruction execution write a program for finding the great common divisor (GCD) of two unsigned numbers according to the Euclide algorithm:
LOOP: @ compare r1 and r2
IF r1 > r2 THEN
R1=R1-R2
ELSE
IF r1 < r2 THEN
R2=R2-R1
IF r1 != r2 THEN
GOTO LOOP
6. Reserve the memory space for a table containing 15 32-bits elements. Within a program loop set sequentially the elements to the values 1, 0 and -1 respectively (eg. the first element of the table is set to 1, the second to 0, the third to -1, the fourth to 1, etc.). Write the program in the way so that by writting in a register, before entering the loop, the value 1, at each loop cycle, this value would be decreased by one. When the value -1 is reached, the same register should be reset to the value 1, and so on...
TABELA: .byte 1,100,255,24,88,31,56,192,155,224, 0, 101, 199, 47
a) Napišite program, ki v zanki vse elemente tabele, ki so pozitivni, postavi na -1.
b) Napišite program, ki v zanki vse elemente tabele, ki so pozitivni, negira (npr. iz 10 spremeni na -10).
c) Napišite program, ki v zanki vse elemente tabele, ki so vecji ali enaki -48 in manjši od 48 (predznačeno!) postavi na 0.
2. Z uporabo pogojnih skokov napišite programa, ki ustreza naslednjemu navodilu:
IF A<10 THEN B=B-1
IF A=10 THEN B=B+1
IF A>10 THEN B=B+2
A in B sta 16-bitni predznačeni spremenljivki.
3. Z uporabo pogojnih skokov napišite program, ki ustreza naslednjemu navodilu:
IF A=10 THEN
B=B+1
ELSE B=B+2
A in B sta 16-bitni predznačeni spremenljivki.
4. Nalogi 2. in 3. rešite s pogojnim izvajanjem ukazov.
5. Z uporabo pogojnega izvajanja ukazov napišite program za iskanje največjega skupnega delitelja (Evklidov algoritem) na
naslednji način (podoben potek algoritma smo obravnavali na vajah) :
ZANKA: PRIMERJAJ r1 in r2
IF r1 > r2 THEN R1=R1-R2 ELSE
IF r1 < r2 THEN R2=R2-R1
IF r1 != r2 THEN GOTO ZANKA
6. Rezervirajte prostor za tabelo 15 32-bitnih elementov. Nato v programski zanki elemente izmenično postavljajte na 1, 0 in -1 (prvi element na 1, drugi na 0, tretji na -1, četrti spet na 1, ...). Program naredite tako, da v register pred zanko naložite konstanto 1 in ga po vsakem vpisu v tabelo zmanjšate za 1. Ko vpišete vrednost -1, register spet postavite na 1 itn.
----------------------------------------------------
----------------------------------------------------
1. The following table is given, containing 14 8-bit long values:
TABLE: .byte 1,100,255,24,88,31,56,192,155,224, 0, 101, 199, 47
a) Write a program in ARM assembly in which, inside a loop, all positive elements of the table are set to -1.
b) Write a program in ARM assembly in which, inside a loop, all positive elements of the table are negated (i.e. 10 -> -10).
c) Write a program in ARM assembly in which, inside a loop, all elements that are contained in the interval [-48,48[ are set to 0..
2. Implement the following IF-THEN expression using conditional branches:
a) IF A<10 THEN B=B-1
b) IF A=10 THEN B=B+1
c) IF A>10 THEN B=B+2
A and B are 16-bits signed variables.
3. Using conditional branches, implement the following code in ARM assembly:
IF A=10 THEN
B=B+1
ELSE
B=B+2
A and B are 16-bits signed variables..
4. Solve the 2nd and 3rd problem with the aid of conditional instruction execution.
5. Using conditional instruction execution write a program for finding the great common divisor (GCD) of two unsigned numbers according to the Euclide algorithm:
LOOP: @ compare r1 and r2
IF r1 > r2 THEN
R1=R1-R2
ELSE
IF r1 < r2 THEN
R2=R2-R1
IF r1 != r2 THEN
GOTO LOOP
6. Reserve the memory space for a table containing 15 32-bits elements. Within a program loop set sequentially the elements to the values 1, 0 and -1 respectively (eg. the first element of the table is set to 1, the second to 0, the third to -1, the fourth to 1, etc.). Write the program in the way so that by writting in a register, before entering the loop, the value 1, at each loop cycle, this value would be decreased by one. When the value -1 is reached, the same register should be reset to the value 1, and so on...