1. vaja rešitve
Требуемые условия завершения
@-------------------------------------
@ naloga 1
@-------------------------------------
.text
.org 0x20
S1: .byte 15
S2: .byte 10
.align
.global __start
@ nepredznaceni, pogojni skoki
__start: adr r4,S1
adr 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: adr r4,S1
adr 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: adr r4,S1
adr 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: adr r4,S1
adr 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.
.text
.org 0x20
tabela: .byte 23,54,2,76,53,57,5,1,0,11
.align
.global __start
__start:
/*
mov r1, #53
mov r1, #60
*/
mov r1, #2
adr r0, tabela
zanka: ldrb r2, [r0]
add r0, r0, #1
cmp r2, r1
/*
bne zanka
bls zanka
*/
bhs zanka
@-------------------------------------
@predznac.
.text
.org 0x20
tabela: .byte byte 0,-5,2,-4,11,12,32,-10,-11,-22
.align
.global __start
__start:
/*
mov r1, $11
mov r1, #30
*/
mov r1, #-11
adr r0, tabela
zanka: ldrb r2, [r0]
add r0, r0, #1
cmp r2, r1
/*
bne zanka
ble zanka
*/
bge zanka
@-------------------------------------
@ naloga 3a
@-------------------------------------
.text
.org 0x20
tabela: .byte 1,100,255,24,88,31,56,192,155,224,48,0,128,99,147,177
rez: .space 1
.align
.global __start
__start:
adr r0, tabela
mov r1, #16
mov r2, #0
zanka: ldrsb r3, [r0]
add r0, r0, #1
cmp r3, #100
addgt r2, r2, #1
subs r1, r1, #1
bne zanka
strb r2, rez
@-------------------------------------
@ naloga 3b
@-------------------------------------
.text
.org 0x20
tabela: .byte 1,100,255,24,88,31,56,192,155,224,48,0,128,99,147,177
rez: .space 1
.align
.global __start
__start:
adr r0, tabela
mov r1, #16
mov r2, #0
zanka: ldrb r3, [r0]
add r0, r0, #1
cmp r3, #100
addhi r2, r2, #1
subs r1, r1, #1
bne zanka
strb r2, rez
@-------------------------------------
@ naloga 3c
@-------------------------------------
.text
.org 0x20
tabela: .byte 1,100,255,24,88,31,56,192,155,224,48,0,128,99,147,177
rez: .space 1
.align
.global __start
__start:
adr r0, tabela
mov r1, #16
mov r2, #0
zanka: ldrb r3, [r0]
cmp r3, #48
blo preskoci
cmp r3, #57
bhi preskoci
add r2, r2, #1
preskoci: add r0, r0, #1
subs r1, r1, #1
bne zanka
strb r2, rez
Последнее изменение: понедельник, 14 октября 2024, 23:45