diff --git a/Kernel/cpu-6800/lowlevel-6800.S b/Kernel/cpu-6800/lowlevel-6800.S index a8a117078e..36626120b3 100644 --- a/Kernel/cpu-6800/lowlevel-6800.S +++ b/Kernel/cpu-6800/lowlevel-6800.S @@ -111,15 +111,11 @@ outd: -; -; We are called from SWI. The stack holds 7 bytes of return -; information, A holds the syscall number on entry, B the arg count -; Arguments are left to right ordered. ; ; On enry our frame looks like this ; ; 12-> more arguments -; 11-10 last arg +; 11-10 first argument ; 9-8 return PC for caller to syscall ; 7-6 UserPC ; 5-4 X @@ -129,30 +125,23 @@ outd: ; ; unix_syscall_entry: - sts @tmp ; No ABX so we have to do a bit of work - addb @tmp+1 - stab @tmp+1 - bcc noinc - inc @tmp -noinc: - ldx @tmp - inx ; Because we are not using TSX + tsx sts _udata+U_DATA__U_SYSCALL_SP staa _udata+U_DATA__U_CALLNO - ldaa 7,x - ldab 8,x + ldaa 9,x + ldab 10,x staa _udata+U_DATA__U_ARGN stab _udata+U_DATA__U_ARGN+1 - ldaa 5,x - ldab 6,x + ldaa 11,x + ldab 12,x staa _udata+U_DATA__U_ARGN+2 stab _udata+U_DATA__U_ARGN+3 - ldaa 3,x - ldab 4,x + ldaa 13,x + ldab 14,x staa _udata+U_DATA__U_ARGN+4 stab _udata+U_DATA__U_ARGN+5 - ldaa ,x - ldab 1,x + ldaa 15,x + ldab 16,x staa _udata+U_DATA__U_ARGN+6 stab _udata+U_DATA__U_ARGN+7 ldaa #1 @@ -514,16 +503,15 @@ to_rts: _memset: tsx - ldaa 4,x ldab 5,x - stab @tmp ; destination - ldaa 2,x ; length - ldab 3,x - ldx 6,x ; destination + stab @tmp ; pattern + ldaa 6,x ; length + ldab 7,x + ldx 2,x ; destination bsr snextblock tsx - ldaa 7,x - ldab 8,x + ldaa 2,x + ldab 3,x jmp __cleanup6 snextblock: @@ -559,21 +547,21 @@ clearloop: _memcpy: tsx - ldaa 6,x - ldab 7,x + ldaa 2,x + ldab 3,x staa @tmp ; destination stab @tmp+1 - ldaa 2,x ; length - oraa 3,x + ldaa 6,x ; length + oraa 7,x beq nocopy - ldaa 2,x - ldab 3,x + ldaa 6,x + ldab 7,x ldx 4,x ; src bsr nextblock tsx nocopy: - ldaa 6,x - ldab 7,x + ldaa 2,x + ldab 3,x jmp __cleanup6 nextblock: diff --git a/Kernel/cpu-6800/stdarg.h b/Kernel/cpu-6800/stdarg.h index a0b3636533..dc36919da3 100644 --- a/Kernel/cpu-6800/stdarg.h +++ b/Kernel/cpu-6800/stdarg.h @@ -1,17 +1,22 @@ /* - * This is a bit strange because our argments are left to right on - * the stack. + * stdarg.h - variable arguments + * + * From the ack cc + * + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". */ +/* $Id$ */ + #ifndef _STDARG_H #define _STDARG_H -typedef unsigned char *va_list; - -#define __typesize(__type) (sizeof(__type) == 1 ? sizeof(int) : sizeof(__type)) +typedef char* va_list; -#define va_start(__ap, __last) ((__ap) = (va_list)(&(__last))) -#define va_end(__ap) +#define __vasz(x) ((sizeof(x)+sizeof(int)-1) & ~(sizeof(int) -1)) -#define va_arg(__ap, __type) (*((__type *)(void *)(__ap -= __typesize(__type)))) +#define va_start(ap, parmN) (ap = (va_list)&parmN + __vasz(parmN)) +#define va_arg(ap, type) (*((type *)(void *)((ap += __vasz(type)) - __vasz(type)))) +#define va_end(ap) #endif diff --git a/Kernel/cpu-6800/usermem_std-6800.S b/Kernel/cpu-6800/usermem_std-6800.S index 7f5fe3f9e9..2ba60134f8 100644 --- a/Kernel/cpu-6800/usermem_std-6800.S +++ b/Kernel/cpu-6800/usermem_std-6800.S @@ -11,18 +11,18 @@ __uputc: tsx - ldab 5,x - ldx 2,x + ldab 3,x + ldx 4,x jsr map_proc_always stab 0,x jsr map_kernel jmp __cleanup4 __uputw: - ldaa 4,x tsx - ldab 5,x - ldx 2,x + ldaa 2,x + ldab 3,x + ldx 4,x jsr map_proc_always staa 0,x stab 1,x @@ -49,9 +49,9 @@ __ugetw: __uzero: tsx - ldaa 2,x - ldab 3,x - ldx 4,x + ldaa 4,x + ldab 5,x + ldx 2,x jsr map_proc_always ; Optimize, unroll etc ? pshb @@ -84,13 +84,13 @@ __uget: ; We can optimize this a lot by abusing the stack etc but ; start simple. Take care as tmp/to/from are kernel mapped tsx - ldx 2,x + ldx 6,x stx @tmp tsx ldx 4,x ; to stx @to tsx - ldx 6,x ; from + ldx 2,x ; from stx @from ugetl: ldx @from @@ -117,13 +117,13 @@ __uput: ; We can optimize this a lot by abusing the stack etc but ; start simple. Take care as tmp/to/from are kernel mapped tsx - ldx 2,x - stx @tmp + ldx 6,x + stx @tmp tsx ldx 4,x stx @to tsx - ldx 6,x ; from + ldx 2,x ; from stx @from uputl: ldx @from diff --git a/Library/include/6800/stdarg.h b/Library/include/6800/stdarg.h index a0b3636533..dc36919da3 100644 --- a/Library/include/6800/stdarg.h +++ b/Library/include/6800/stdarg.h @@ -1,17 +1,22 @@ /* - * This is a bit strange because our argments are left to right on - * the stack. + * stdarg.h - variable arguments + * + * From the ack cc + * + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". */ +/* $Id$ */ + #ifndef _STDARG_H #define _STDARG_H -typedef unsigned char *va_list; - -#define __typesize(__type) (sizeof(__type) == 1 ? sizeof(int) : sizeof(__type)) +typedef char* va_list; -#define va_start(__ap, __last) ((__ap) = (va_list)(&(__last))) -#define va_end(__ap) +#define __vasz(x) ((sizeof(x)+sizeof(int)-1) & ~(sizeof(int) -1)) -#define va_arg(__ap, __type) (*((__type *)(void *)(__ap -= __typesize(__type)))) +#define va_start(ap, parmN) (ap = (va_list)&parmN + __vasz(parmN)) +#define va_arg(ap, type) (*((type *)(void *)((ap += __vasz(type)) - __vasz(type)))) +#define va_end(ap) #endif diff --git a/Library/libs/crt0_6800.s b/Library/libs/crt0_6800.s index 5d0b89de44..586b7ee8a7 100644 --- a/Library/libs/crt0_6800.s +++ b/Library/libs/crt0_6800.s @@ -11,10 +11,10 @@ head: .word $80A8 .byte 2 ; 6800 series .byte 0 ; Needs only 6800 features - .byte >head ; Load page + .byte 1 ; Load at 0x100 .byte 0 ; No hints - .word __code_size - .word __data_size + .word __data-0x0100 ; Code + .word __data_size ; Data .word __bss_size .byte head ; Load page + .byte 1 ; Load at 0x0100 .byte 0 ; No hints - .word __code_size - .word __data_size - .word __bss_size + .word __data - 0x0100 ; Code size + .word __data_size ; Data size + .word __bss_size ; And BSS .byte