hello, can somebody please explain what this program is doing?
.= torg + 1000
main:
mov pc, sp
tst –(sp)
mov #list1, -(sp)
jsr pc, mystery
mov r0, res1
tst (sp)+
mov #list2, -(sp)
jsr pc, mystery
mov r0, res2
tst (sp)+
halt
mystery:
mov r1, -(sp)
mov r4, -(sp)
mov r5, -(sp)
clr r0
mov 10(sp), r4
mov r4, r5
loop:
mov r4, r1
jsr pc, next
mov r1, r4
beq return
mov r5, r1
jsr pc, next
jsr pc, next
mov r1, r5
beq return
cmp r4, r5
beq setret
br loop
setret:
inc r0
return:
mov (sp)+, r5
mov (sp)+, r4
mov (sp)+, r1
rts pc
next:
tst r1
beq abort
mov (r1), r1
abort:
rts pc
.= torg + 3000
list1: .word 3006, 3000, 3002, 3004, 0
res1: .word -1
.= torg + 3020
list2: .word 3030, 3026, 0, 3024, 3022
res2: .word -1
I can't understand this snippet, thanks in advance for everyone
mystery:
mov r1, -(sp)
mov r4, -(sp)
mov r5, -(sp)
clr r0
mov 10(sp), r4
mov r4, r5