naloga_10

This commit is contained in:
Gašper Dobrovoljc 2024-01-07 18:06:17 +01:00
parent 4089d9fb5f
commit 4b6ea9f800
No known key found for this signature in database
GPG Key ID: 0E7E037018CFA5A5
6 changed files with 316 additions and 0 deletions

166
naloga_10/naloga_10.txt Normal file
View File

@ -0,0 +1,166 @@
@ Vaja 1
.text
.org 0x20
max1: .word 48000
max2: .word 24000000
.global _start
_start:
mov r1, #0
adr r0, max1
ldr r2, [r0]
adr r0, max2
ldr r3, [r0]
loop1:
loop2:
add r1, #1
cmp r1, r2
blt loop2
cmp r1, r3
blt loop1
_end:
b _end
@ Vaja 2
.text
.org 0x20
tab: .space 8
.global _start
_start:
adr r0, tab
mov r1, #0
mov r2, #0xff
loop:
strb r2, [r0, r1]
add r1, #1
cmp r1, #7
bls loop
_end:
b _end
@ Vaja 3
.text
.org 0x20
tabela: .byte 192, 155, 224, 48, 0, 128, 99, 147, 177, 100
rezultat: .space 2
@ r0 - addr
@ r1 - > 100 count
@ r2 - index
@ r3 - tmp
@ r4 - sum
.global _start
_start:
adr r0, tabela
mov r1, #0
mov r2, #0
mov r4, #0
loop:
ldrb r3, [r0, r2]
add r4, r3
cmp r3, #100
addhi r1, #1
cmp r2, #9
add r2, #1
bls loop
adr r0, rezultat
strh r4, [r0]
_end:
b _end
@ Vaja 4
.text
.org 0x20
niz: .asciz "Zunaj je mraz, sneg in poledica."
.align
@ r0 - addr
@ r1 - count
@ r2 - tmp
.global _start
_start:
adr r0, niz
mov r1, #0
loop:
ldrb r2, [r0]
cmp r2, #' '
addeq r1, #1
cmp r2, #0
add r0, #1
bne loop
_end:
b _end
@ Vaja 5
.text
.org 0x20
tabela: .hword 1, 100, -255, 24, -88, 31, 56, 192, 155, -224, 0, 101, -199, 47
.align
@ r0 - adr
@ r1 - index
@ r2 - tmp
@ r3 - zero
.global _start
_start:
adr r0, tabela
mov r1, #0
mov r3, #0
loop:
ldrsh r2, [r0, r1]
cmp r2, #-100
strgeh r3, [r0, r1]
blt step
cmp r2, #100
strlth r3, [r0, r1]
blt step
step:
cmp r1, #24
add r1, #2
bls loop
_end:
b _end

28
naloga_10/vaja_01.s Normal file
View File

@ -0,0 +1,28 @@
.text
.org 0x20
max1: .word 48000
max2: .word 24000000
.global _start
_start:
mov r1, #0
adr r0, max1
ldr r2, [r0]
adr r0, max2
ldr r3, [r0]
loop1:
loop2:
add r1, #1
cmp r1, r2
blt loop2
cmp r1, r3
blt loop1
_end:
b _end

19
naloga_10/vaja_02.s Normal file
View File

@ -0,0 +1,19 @@
.text
.org 0x20
tab: .space 8
.global _start
_start:
adr r0, tab
mov r1, #0
mov r2, #0xff
loop:
strb r2, [r0, r1]
add r1, #1
cmp r1, #7
bls loop
_end:
b _end

37
naloga_10/vaja_03.s Normal file
View File

@ -0,0 +1,37 @@
.text
.org 0x20
tabela: .byte 192, 155, 224, 48, 0, 128, 99, 147, 177, 100
rezultat: .space 2
@ r0 - addr
@ r1 - > 100 count
@ r2 - index
@ r3 - tmp
@ r4 - sum
.global _start
_start:
adr r0, tabela
mov r1, #0
mov r2, #0
mov r4, #0
loop:
ldrb r3, [r0, r2]
add r4, r3
cmp r3, #100
addhi r1, #1
cmp r2, #9
add r2, #1
bls loop
adr r0, rezultat
strh r4, [r0]
_end:
b _end

28
naloga_10/vaja_04.s Normal file
View File

@ -0,0 +1,28 @@
.text
.org 0x20
niz: .asciz "Zunaj je mraz, sneg in poledica."
.align
@ r0 - addr
@ r1 - count
@ r2 - tmp
.global _start
_start:
adr r0, niz
mov r1, #0
loop:
ldrb r2, [r0]
cmp r2, #' '
addeq r1, #1
cmp r2, #0
add r0, #1
bne loop
_end:
b _end

38
naloga_10/vaja_05.s Normal file
View File

@ -0,0 +1,38 @@
.text
.org 0x20
tabela: .hword 1, 100, -255, 24, -88, 31, 56, 192, 155, -224, 0, 101, -199, 47
.align
@ r0 - adr
@ r1 - index
@ r2 - tmp
@ r3 - zero
.global _start
_start:
adr r0, tabela
mov r1, #0
mov r3, #0
loop:
ldrsh r2, [r0, r1]
cmp r2, #-100
strgeh r3, [r0, r1]
blt step
cmp r2, #100
strlth r3, [r0, r1]
blt step
step:
cmp r1, #24
add r1, #2
bls loop
_end:
b _end