Franks version

This commit is contained in:
ceriel 1987-03-27 09:55:28 +00:00
parent 13c208de3b
commit 2aa64be3a6
3 changed files with 42 additions and 53 deletions

View file

@ -4,23 +4,23 @@
.sect .data
.sect .bss
! d0 contains set size
.sect .text
! d0 contains set size
! on exit d0 is zero for equal, non-zero for not equal
.cms:
move.l (sp)+,a2 ! return address
move.l sp,a0
move.l sp,a1
add d0,a1
move.w d0,d1
asr #1,d0
move.l (sp)+, d2 ! return address
move.l sp, a0 ! address of top block
lea 0(sp, d0.l), a1 ! address of lower block
move.l d0, d1
asr.l #2, d0
1:
cmp (a0)+,(a1)+
cmp.l (a0)+, (a1)+
bne 2f
sub.l #1, d0
bne 1b
2:
asl #1,d1
add d1,sp
move.l d0,-(sp)
jmp (a2)
asl.l #1, d1
add.l d1, sp ! two blocks popped
move.l d2, -(sp)
rts
.align 2

View file

@ -4,29 +4,26 @@
.sect .data
.sect .bss
! d0 : # bytes of 1 block
.sect .text
! on entry d0: # bytes of 1 block
! on exit d0: result
.cmu:
move.l sp,a0 ! top block
add.l #4,a0
move.l a0,a1
add.l d0,a1 ! lower block
move.l d0,d2
move.l (sp)+, d2 ! return address
move.l sp, a0 ! address of top block
lea 0(sp, d0.l), a1 ! address of lower block
move.l d0, d1
asr.l #2, d0
sub.l #1,d0
move.l #1,d1 ! greater
1:
cmp.l (a0)+, (a1)+
bne 2f
dbf d0,1b
clr.l d1 ! equal
sub.l #1, d0
bne 1b ! note: on equal carry is set
2:
bcc 3f
neg.l d1 ! less
neg.l d0 ! less
3:
asl.l #1,d2
move.l (sp)+,a0
add.l d2,sp ! new sp
jmp (a0)
asl.l #1, d1
add.l d1, sp ! new sp; two blocks popped
move.l d2, -(sp)
rts
.align 2

View file

@ -4,25 +4,17 @@
.sect .data
.sect .bss
! d0 : exchange size in bytes
.sect .text
! d0 : exchange size in bytes
.exg:
move.l (sp)+,d2
move.l sp,a1
sub.l d0,sp
move.l sp,a2
asr #1,d0
move.l d0,d1
lea 4(sp, d0), a0 ! address of bottom block
lea 4(sp), a1 ! address of top block
asr.l #2, d0
sub.l #1, d0
1:
move.l (a1)+,(a2)+
sub #1,d0
bgt 1b
move.l sp,a1
asr #1,d1
1:
move.l (a1)+,(a2)+
sub #1,d1
bgt 1b
move.l a1,sp
move.l d2,-(sp)
move.l (a1), d1
move.l (a0), (a1)+
move.l d1, (a0)+
dbf d0, 1b
rts
.align 2