diff --git a/second/Makefile b/second/Makefile index 150d1b6..74209d3 100644 --- a/second/Makefile +++ b/second/Makefile @@ -35,14 +35,14 @@ second.o: $(OBJS) ld.script MMU030_asm.o: MMU030_asm.S $(AS) $(ASFLAGS) -m68030 -o $@ $^ -enter_kernel030.o: enter_kernel030.S - $(AS) $(ASFLAGS) -m68030 -o $@ $^ +enter_kernel030.o: enter_kernel030.S copymem.i + $(AS) $(ASFLAGS) -m68030 -o $@ $< MMU040_asm.o: MMU040_asm.S $(AS) $(ASFLAGS) -m68040 -o $@ $^ -enter_kernel040.o: enter_kernel040.S - $(AS) $(ASFLAGS) -m68040 -o $@ $^ +enter_kernel040.o: enter_kernel040.S copymem.i + $(AS) $(ASFLAGS) -m68040 -o $@ $< .c.o: $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^ diff --git a/second/copymem.i b/second/copymem.i new file mode 100644 index 0000000..94c629a --- /dev/null +++ b/second/copymem.i @@ -0,0 +1,25 @@ +/* + * + * (c) 2004 Laurent Vivier + * + */ + +.macro copymem src, dst, size + cmpa.l \src, \dst + bgt.s 1f +0: + move.b (\src)+,(\dst)+ + subq.l #1,\size + bge.s 0b + + bra 4f + +1: + adda.l \size, \src + adda.l \size, \dst +2: + move.b -(\src),-(\dst) + subq.l #1,\size + bge.s 2b +4: +.endm diff --git a/second/enter_kernel030.S b/second/enter_kernel030.S index ad15db6..9fb91dc 100644 --- a/second/enter_kernel030.S +++ b/second/enter_kernel030.S @@ -4,6 +4,8 @@ * */ + .include "copymem.i" + .align 4 .global enter_kernel030 @@ -37,10 +39,7 @@ enter_kernel030: move.l %a2, %a1 -copy_loop: - move.b (%a0)+, (%a2)+ - subq.l #1, %d0 - bge.s copy_loop + copymem %a0, %a2, %d0 /* jump into kernel */ diff --git a/second/enter_kernel040.S b/second/enter_kernel040.S index 1486dc3..942c996 100644 --- a/second/enter_kernel040.S +++ b/second/enter_kernel040.S @@ -4,6 +4,8 @@ * */ + .include "copymem.i" + .align 4 .global enter_kernel040 @@ -35,10 +37,7 @@ enter_kernel040: move.l %a2, %a1 -copy_loop: - move.b (%a0)+, (%a2)+ - subq.l #1, %d0 - bge.s copy_loop + copymem %a0, %a2, %d0 /* jump into kernel */