1. vaja rešitve
@-------------------------------------
@ naloga 1
@-------------------------------------
.data
S1: .byte 15
S2: .byte 10
.text
.org 0x20
.align
.global __start
@ nepredznaceni, pogojni skoki
__start: ldr r4,=S1
ldr r5,=S2
ldrb r1,[r4] @S1->r1
ldrb r2,[r5] @S2->r2
cmp r1, r2 @r1 > r2
bhi vecjas1 @ da
sub r2, r2, r1
strb r2, [r5]
b __end
vecjas1: sub r1, r1, r2 @ odstejem
strb r1, [r4]
__end: b __end
@-------------------------------------
@ predznaceni, pogojni skoki
__start: ldr r4,=S1
ldr r5,=S2
ldrsb r1,[r4] @S1->r1
ldrsb r2,[r5] @S2->r2
cmp r1, r2 @r1 > r2
bgt vecjas1 @ da
sub r2, r2, r1
strb r2, [r5]
b __end
vecjas1: sub r1, r1, r2 @ odstejem
strb r1, [r4]
@-------------------------------------
@ predznaceni, pogojni izvajanje ukazov
__start: ldr r4,=S1
ldr r5,=S2
ldrsb r1,[r4] @S1->r1
ldrsb r2,[r5] @S2->r2
cmp r1, r2 @r1 > r2
suble r2, r2, r1
strleb r2, [r5]
vecjas1: subgt r1, r1, r2 @ odstejem
strgtb r1, [r4]
@-------------------------------------
@nepredzn., pogojno izvajanje ukazov
@ nepredznaceni, pogojni izvajanje ukazov
__start: ldr r4,=S1
ldr r5,=S2
ldrb r1,[r4] @S1->r1
ldrb r2,[r5] @S2->r2
cmp r1, r2 @r1 > r2
subls r2, r2, r1
strlsb r2, [r5]
vecjas1: subhi r1, r1, r2 @ odstejem
strhib r1, [r4]
@-------------------------------------
@naloga 2
@-------------------------------------
@-------------------------------------
@nepredznac.
.data
tabela: .byte 23,54,2,76,53,57,5,1,0,11
.text
.org 0x20
.align
.global __start
__start:
/*
mov r1, #53
mov r1, #60
*/
mov r1, #2
ldr r0, =tabela
zanka: ldrb r2, [r0]
add r0, r0, #1
cmp r2, r1
/*
bne zanka
bls zanka
*/
bhs zanka
@-------------------------------------
@predznac.
.data
tabela: .byte byte 0,-5,2,-4,11,12,32,-10,-11,-22
.text
.org 0x20
.align
.global __start
__start:
/*
mov r1, $11
mov r1, #30
*/
mov r1, #-11
ldr r0, =tabela
zanka: ldrb r2, [r0]
add r0, r0, #1
cmp r2, r1
/*
bne zanka
ble zanka
*/
bge zanka
@-------------------------------------
@ naloga 3a
@-------------------------------------
.data
tabela: .byte 1,100,255,24,88,31,56,192,155,224,48,0,128,99,147,177
rez: .space 1
.text
.org 0x20
.align
.global __start
__start:
ldr r0, =tabela @ kazalec
ldr r4, =rez
mov r1, #16 @ stevec zanke
mov r2, #0 @ stevec
zanka: ldrsb r3, [r0] @predzn!
cmp r3, #90 @ >90 ?
addgt r2, r2, #1 @ stevec++
add r0, r0, #1
subs r1, r1, #1
bne zanka
strb r2, [r4] @ rez <- stevec(r2=2)
@-------------------------------------
@ naloga 3b
@-------------------------------------
.data
tabela: .byte 1,100,255,24,88,31,56,192,155,224,48,0,128,99,147,177
rez: .space 1
.text
.org 0x20
.align
.global __start
__start:
ldr r0, =tabela @ kazalec
ldr r4, =rez
mov r1, #16 @ stevec zanke
mov r2, #0 @ stevec
zanka: ldrb r3, [r0]
cmp r3, #100 @ >100 ?
addhi r2, r2, #1 @ stevec++
add r0, r0, #1
subs r1, r1, #1
bne zanka
strb r2, [r4] @ rez <- stevec(r2=7)
@-------------------------------------
@naloga 3c
@-------------------------------------
.data
tabela: .byte 1,100,255,24,88,31,56,192,155,224,48,0,128,99,147,177
rez: .space 1
.text
.org 0x20
.align
.global __start
__start:
ldr r0, =tabela @ kazalec
ldr r4, =rez
mov r1, #16 @ stevec zanke
mov r2, #0 @ stevec
zanka: ldrb r3, [r0]
cmp r3, #48 @ <48 ?
blo preskoci
cmp r3, #57 @ >57 ?
bhi preskoci
add r2, r2, #1 @ stevec++
preskoci: add r0, r0, #1
subs r1, r1, #1
bne zanka
strb r2, [r4] @ rez <- stevec(r2=2