m_a_i_n --> _m_a_i_n

This commit is contained in:
ceriel 1991-03-06 14:26:16 +00:00
parent 76d79cf17a
commit b893ec7013
38 changed files with 57 additions and 72 deletions

View file

@ -8,7 +8,7 @@ The remaining way to interact, interrupts, will be treated
together with traps in chapter 9. together with traps in chapter 9.
.S2 "Program starting and stopping" .S2 "Program starting and stopping"
EM user programs start with a call to a procedure called EM user programs start with a call to a procedure called
m_a_i_n. _m_a_i_n.
The assembler and backends look for the definition of a procedure The assembler and backends look for the definition of a procedure
with this name in their input. with this name in their input.
The call passes three parameters to the procedure. The call passes three parameters to the procedure.
@ -45,7 +45,7 @@ The
is terminated by a zero pointer. is terminated by a zero pointer.
.P .P
An EM user program stops if the program returns from the first An EM user program stops if the program returns from the first
invocation of m_a_i_n. invocation of _m_a_i_n.
The contents of the function return area are used to procure a The contents of the function return area are used to procure a
wordsized program return code. wordsized program return code.
EM programs also stop when traps and interrupts occur that are EM programs also stop when traps and interrupts occur that are

View file

@ -545,7 +545,7 @@ stackpointer are set to 0x1000 and 0x8000 respectively.
.br .br
Other systems require other values. Other systems require other values.
.IP 2) .IP 2)
In 'head_em': before calling "_m_a_i_n", the environment In 'head_em': before calling "__m_a_i_n", the environment
pointer, argument vector and argument count will have to be pushed pointer, argument vector and argument count will have to be pushed
onto the stack. onto the stack.
Since this back-end is tested on a system without any knowledge Since this back-end is tested on a system without any knowledge

View file

@ -36,7 +36,7 @@ stackpointer are set to 0x1000 and 0x7ffe respectivally.
The latter because it could run on a 32K machine as well. The latter because it could run on a 32K machine as well.
Other systems require other values. Other systems require other values.
.IP 2) .IP 2)
In \fIhead_em\fP: before calling "_m_a_i_n", the environment In \fIhead_em\fP: before calling "__m_a_i_n", the environment
pointer, argument vector and argument count will have to be pushed pointer, argument vector and argument count will have to be pushed
onto the stack. onto the stack.
Since this back-end is tested on a system without any knowledge Since this back-end is tested on a system without any knowledge

View file

@ -182,8 +182,8 @@ combine() {
if (nhol) if (nhol)
printf(" hol %d,0,0\n", nhol); printf(" hol %d,0,0\n", nhol);
copy(name1); copy(name1);
printf(" exp $m_a_i_n\n"); printf(" exp $_m_a_i_n\n");
printf(" pro $m_a_i_n,%d\n", nlocals); printf(" pro $_m_a_i_n,%d\n", nlocals);
printf(" loc 123\n"); printf(" loc 123\n");
printf(" loc -98\n"); printf(" loc -98\n");
copy(name2); copy(name2);

View file

@ -17,8 +17,6 @@
* *
*/ */
/* Author: E.G. Keizer */
mes 2,_EM_WSIZE,_EM_PSIZE mes 2,_EM_WSIZE,_EM_PSIZE
exa environ exa environ
@ -27,8 +25,8 @@
_penvp _penvp
bss _EM_PSIZE,0,0 bss _EM_PSIZE,0,0
exp $m_a_i_n exp $_m_a_i_n
pro $m_a_i_n,0 pro $_m_a_i_n,0
loc 1336 ; EIOVFL | EIUND | ECONV | EFOVFL | EFUNFL loc 1336 ; EIOVFL | EIUND | ECONV | EFOVFL | EFUNFL
sim ; ignored sim ; ignored
lal _EM_WSIZE+_EM_PSIZE lal _EM_WSIZE+_EM_PSIZE

View file

@ -28,8 +28,8 @@ environ
_penvp _penvp
bss EM_PSIZE,0,0 bss EM_PSIZE,0,0
exp $m_a_i_n exp $_m_a_i_n
pro $m_a_i_n,0 pro $_m_a_i_n,0
#if EM_WSIZE==1 #if EM_WSIZE==1
ldc 1336 ; EIOVFL | EIUND | ECONV | EFOVFL | EFUNFL ldc 1336 ; EIOVFL | EIUND | ECONV | EFOVFL | EFUNFL
#else #else

View file

@ -24,8 +24,8 @@
bkillbss bkillbss
bss EM_PSIZE,0,0 bss EM_PSIZE,0,0
exp $m_a_i_n exp $_m_a_i_n
pro $m_a_i_n, 0 pro $_m_a_i_n, 0
lor 0 lor 0
lae MainLB lae MainLB

View file

@ -118,8 +118,8 @@ CodeBeginBlock(df)
if ( df->df_kind == D_MODULE) /* nothing */ ; if ( df->df_kind == D_MODULE) /* nothing */ ;
else if (df->df_kind == D_PROGRAM ) { else if (df->df_kind == D_PROGRAM ) {
C_exp("m_a_i_n"); C_exp("_m_a_i_n");
C_pro_narg("m_a_i_n"); C_pro_narg("_m_a_i_n");
C_ms_par((arith) 0); C_ms_par((arith) 0);
offset = CodeGtoDescr(df->prc_vis->sc_scope); offset = CodeGtoDescr(df->prc_vis->sc_scope);
CodeFil(); CodeFil();

View file

@ -241,7 +241,7 @@ stb_string(df, kind)
addc_db_str(':'); addc_db_str(':');
if (kind == D_MODULE) { if (kind == D_MODULE) {
adds_db_str(sprint(buf, "M%d;", df->prc_vis->sc_count)); adds_db_str(sprint(buf, "M%d;", df->prc_vis->sc_count));
C_ms_stb_pnam(db_str.base, N_FUN, proclevel, "m_a_i_n"); C_ms_stb_pnam(db_str.base, N_FUN, proclevel, "_m_a_i_n");
return; return;
} }
switch((int)kind) { switch((int)kind) {

View file

@ -29,7 +29,7 @@ extern int _gtty();
struct file **_extfl; struct file **_extfl;
int _extflc; /* number of external files */ int _extflc; /* number of external files */
char *_m_lb; /* LB of m_a_i_n */ char *_m_lb; /* LB of _m_a_i_n */
struct file *_curfil; /* points to file struct in case of errors */ struct file *_curfil; /* points to file struct in case of errors */
int _pargc; int _pargc;
char **_pargv; char **_pargv;

View file

@ -99,7 +99,7 @@ UNSIGN : .space 1 ! is it signed or unsigned arithmetic
TRAPVAL: .space 1 ! intermediate storage of the error number TRAPVAL: .space 1 ! intermediate storage of the error number
STACK: .space 1 ! contains the hardware stackpointer on STACK: .space 1 ! contains the hardware stackpointer on
! entering m_a_i_n for a neat return ! entering _m_a_i_n for a neat return
RESERVED: .space 112 ! used by the operating system RESERVED: .space 112 ! used by the operating system
@ -174,7 +174,7 @@ start:
lda #0 lda #0
ldx #1 ldx #1
jsr Push ! push argc jsr Push ! push argc
jsr _m_a_i_n ! start the real program jsr __m_a_i_n ! start the real program
lda #0x0FF lda #0x0FF
jsr WRCH ! send end of program to R423 jsr WRCH ! send end of program to R423

View file

@ -140,7 +140,7 @@ next3:
ADR R11, argc ADR R11, argc
LDR R11,[R11] LDR R11,[R11]
STMFD R12<,{R11} STMFD R12<,{R11}
BAL.L _m_a_i_n BAL.L __m_a_i_n
MOV R11,#0 MOV R11,#0
STMFD R12<,{R11} STMFD R12<,{R11}
MOV R11,#1 MOV R11,#1

View file

@ -1,9 +1,8 @@
.sect .text; .sect .rom; .sect .data; .sect .bss .sect .text; .sect .rom; .sect .data; .sect .bss
.define begtext,begdata,begbss,syscal .define begtext,begdata,begbss
.define hol0,.reghp,.limhp,.trppc,.ignmask .define hol0,.reghp,.limhp,.trppc,.ignmask
.define ERANGE,ESET,EHEAP,ECASE,EILLINS,EIDIVZ,EODDZ .define ERANGE,ESET,EHEAP,ECASE,EILLINS,EIDIVZ,EODDZ
.extern _end
ERANGE = 1 ERANGE = 1
ESET = 2 ESET = 2
@ -35,7 +34,7 @@ begtext:
push ax push ax
push bx push bx
push cx push cx
call _m_a_i_n call __m_a_i_n
push ax push ax
call __exit call __exit
.sect .data .sect .data

View file

@ -35,7 +35,7 @@
push h push h
lxi h,0 lxi h,0
push h push h
call _m_a_i_n call __m_a_i_n
.stop: jmp 0xfb52 .stop: jmp 0xfb52
.sect .bss .sect .bss

View file

@ -26,7 +26,7 @@ begtext:
push bx push bx
push cx push cx
xor bp,bp xor bp,bp
call _m_a_i_n call __m_a_i_n
int 0x81 int 0x81
.sect .data .sect .data
begdata: begdata:

View file

@ -43,7 +43,7 @@ begtext:
move.l a0,(8,sp) ! env move.l a0,(8,sp) ! env
! move.l a0, environ ! indir is 0 if no env; not 0 if env ! move.l a0, environ ! indir is 0 if no env; not 0 if env
! jsr (initfpu) ! call to dummy floating point init routine ! jsr (initfpu) ! call to dummy floating point init routine
jsr (_m_a_i_n) jsr (__m_a_i_n)
move.l d0,(sp) ! no stack cleanup needed move.l d0,(sp) ! no stack cleanup needed
EXIT: EXIT:
jsr (__exit) jsr (__exit)

View file

@ -1,9 +1,6 @@
The m68k2 back end is an EM code generator for the The m68k2 back end is an EM code generator for the
Motorola MC68000. It defines an integer to be 16 bits Motorola MC68000. It defines an integer to be 16 bits
and a pointer to be 32 bits. and a pointer to be 32 bits.
At present it does not support floating point operations.
(All EM floating point instructions are translated to the
68000 "trap" instruction.)
The m68k2 back end generates code for the ACK 68000 assembler. The m68k2 back end generates code for the ACK 68000 assembler.
(The mnemonics recognized by this assembler can be found in (The mnemonics recognized by this assembler can be found in
"as/mach3.c"). "as/mach3.c").
@ -32,17 +29,16 @@ on the kind of target 68000 system.
ACK a.out format to your a.out format (as defined in ACK a.out format to your a.out format (as defined in
"/usr/include/a.out.h"). The program "cv/cv.c" does "/usr/include/a.out.h"). The program "cv/cv.c" does
the job for UniSoft Unix. It probably need only be slightly the job for UniSoft Unix. It probably need only be slightly
modified for your system. Note that the program modified for your system.
generates no text or bss segments, but only a data segment.
If your target 68000 does not run Unix, but is e.g. a stand alone If your target 68000 does not run Unix, but is e.g. a stand alone
68000, you will need a program to download the ACK a.out file. 68000, you will need a program to download the ACK a.out file.
The program "dl/dl.c" produces Intel Hex format on standard output The program "dl/dl.c" produces Intel Hex format on standard output
from an a.out file. from an a.out file.
- The EM runtime start-off ("libsys/head_em.s") may have to be modified. - The EM runtime start-off ("libsys/head_em.s") may have to be modified.
It should call the procedure _m_a_i_n with parameters (argc,argv,envp). It should call the procedure __m_a_i_n with parameters (argc,argv,envp).
Usually, Unix will put these on top of the stack before starting Usually, Unix will put these on top of the stack before starting
the program. Note, however, that for 4-byte systems Unix will provide the program. Note, however, that for 4-byte systems Unix will provide
a 4-byte argc, while _m_a_i_n expects a 2-byte argc; so the value a 4-byte argc, while __m_a_i_n expects a 2-byte argc; so the value
must be shortened to 2 bytes. must be shortened to 2 bytes.

View file

@ -51,7 +51,7 @@ begtext:
! envp pointer. ! envp pointer.
add.l #2,sp !convert argc from 4-byte to 2-byte add.l #2,sp !convert argc from 4-byte to 2-byte
jsr _m_a_i_n jsr __m_a_i_n
add #010,sp add #010,sp
EXIT: EXIT:
move.w d0,-(sp) move.w d0,-(sp)

View file

@ -50,7 +50,7 @@ begtext:
! Now the stack contains an argc (4 bytes), argv-pointer and ! Now the stack contains an argc (4 bytes), argv-pointer and
! envp pointer. ! envp pointer.
jsr _m_a_i_n jsr __m_a_i_n
add #012,sp add #012,sp
EXIT: EXIT:
move.l d0,-(sp) move.l d0,-(sp)

View file

@ -1,5 +1,5 @@
.define filb .define filb
.define _m_a_i_n .define __m_a_i_n
.define curproc .define curproc
.define pd .define pd
.define nproc .define nproc
@ -25,7 +25,7 @@
! START OF THE PROGRAM ! START OF THE PROGRAM
!--------------------------------------------------------------------------- !---------------------------------------------------------------------------
_m_a_i_n: __m_a_i_n:
#ifdef __BSD4_2 #ifdef __BSD4_2
jsr getmask jsr getmask
#endif #endif

View file

@ -50,7 +50,7 @@ begtext:
! Now the stack contains an argc (4 bytes), argv-pointer and ! Now the stack contains an argc (4 bytes), argv-pointer and
! envp pointer. ! envp pointer.
jsr _m_a_i_n jsr __m_a_i_n
add #012,sp add #012,sp
EXIT: EXIT:
move.l d0,-(sp) move.l d0,-(sp)

View file

@ -25,7 +25,7 @@ begtext:
push bx push bx
push cx push cx
xor bp,bp xor bp,bp
call _m_a_i_n call __m_a_i_n
add sp,6 add sp,6
call __exit call __exit
.sect .data .sect .data

View file

@ -37,11 +37,11 @@ begtext:
move.l a1,-(sp) ! push environ move.l a1,-(sp) ! push environ
move.l a0,-(sp) ! push argv move.l a0,-(sp) ! push argv
move.w d0,-(sp) ! push argc move.w d0,-(sp) ! push argc
jsr _m_a_i_n jsr __m_a_i_n
add #010,sp add #010,sp
EXIT: EXIT:
move.w d0,-(sp) move.w d0,-(sp)
jsr _exit jsr __exit
L0: bra L0 L0: bra L0
.sect .data .sect .data

View file

@ -27,7 +27,7 @@ ECASE = 20
movd envp,tos movd envp,tos
movd argv,tos movd argv,tos
movd 1,tos movd 1,tos
jsr @_m_a_i_n jsr @__m_a_i_n
.stop: .stop:
movb 0x7f,tos movb 0x7f,tos
jsr @.putchar jsr @.putchar

View file

@ -44,7 +44,7 @@ ECASE = 024
tst -(r0) tst -(r0)
1: 1:
mov r0,4(sp) mov r0,4(sp)
jsr pc,_m_a_i_n jsr pc,__m_a_i_n
! next two lines for as long as tail needs printf ! next two lines for as long as tail needs printf
! mov r0,-(sp) ! mov r0,-(sp)
! jsr pc,*$_exit ! jsr pc,*$_exit

View file

@ -1,6 +1,5 @@
.define CERASE,CKILL,CSTOP,CSTART
.define .lino,.filn .define .lino,.filn
.define F_DUM,EXIT .define EXIT
.define begtext,begdata,begbss .define begtext,begdata,begbss
.define EARRAY,ERANGE,ESET,EIDIVZ,EHEAP,EILLINS,ECASE .define EARRAY,ERANGE,ESET,EIDIVZ,EHEAP,EILLINS,ECASE
.define hol0,.reghp,.limhp,.trpim,.trppc .define hol0,.reghp,.limhp,.trpim,.trppc
@ -14,13 +13,6 @@
CERASE = 010
CKILL = 030
CSTART = 021
CSTOP = 023
F_DUM = 0
LINO_AD = 0 LINO_AD = 0
FILN_AD = 4 FILN_AD = 4
@ -35,7 +27,7 @@ ECASE = 20
.sect .text .sect .text
begtext: begtext:
add.l #2,sp !convert argc from 4-byte to 2-byte add.l #2,sp !convert argc from 4-byte to 2-byte
jsr _m_a_i_n jsr __m_a_i_n
add #010,sp add #010,sp
EXIT: EXIT:
move.w d0,-(sp) move.w d0,-(sp)

View file

@ -34,7 +34,7 @@ ECASE = 20
.sect .text .sect .text
begtext: begtext:
jsr _m_a_i_n jsr __m_a_i_n
add #012,sp add #012,sp
EXIT: EXIT:

View file

@ -38,10 +38,10 @@ begtext:
pea (a0) pea (a0)
move.l d2,-(sp) move.l d2,-(sp)
move.l #0,a6 move.l #0,a6
jsr _m_a_i_n jsr __m_a_i_n
move.l d0,(sp) ! no stack cleanup needed move.l d0,(sp) ! no stack cleanup needed
EXIT: EXIT:
jsr _exit jsr __exit
.sect .data .sect .data
begdata: begdata:

View file

@ -40,10 +40,10 @@ begtext:
move.l d2,-(sp) move.l d2,-(sp)
move.l #0,a6 move.l #0,a6
jsr (fsoft_used) jsr (fsoft_used)
jsr (_m_a_i_n) jsr (__m_a_i_n)
move.l d0,(sp) ! no stack cleanup needed move.l d0,(sp) ! no stack cleanup needed
EXIT: EXIT:
jsr (_exit) jsr (__exit)
fsoft_used: fsoft_used:
start_float: start_float:

View file

@ -38,10 +38,10 @@ begtext:
pea (a0) pea (a0)
move.l d2,-(sp) move.l d2,-(sp)
move.l #0,a6 move.l #0,a6
jsr (_m_a_i_n) jsr (__m_a_i_n)
move.l d0,(sp) ! no stack cleanup needed move.l d0,(sp) ! no stack cleanup needed
EXIT: EXIT:
jsr (_exit) jsr (__exit)
.sect .data .sect .data
begdata: begdata:

View file

@ -28,7 +28,7 @@
pushl r0 pushl r0
pushl r2 pushl r2
pushl r1 pushl r1
calls $3,_m_a_i_n calls $3,__m_a_i_n
movl $Im2,ap movl $Im2,ap
movl r0,6(ap) movl r0,6(ap)
chmk (ap)+ chmk (ap)+

View file

@ -28,7 +28,7 @@
pushl r0 pushl r0
pushl r2 pushl r2
pushl r1 pushl r1
calls $3,_m_a_i_n calls $3,__m_a_i_n
movl $Im2,ap movl $Im2,ap
movl r0,6(ap) movl r0,6(ap)
chmk (ap)+ chmk (ap)+

View file

@ -28,7 +28,7 @@
pushl r0 pushl r0
pushl r2 pushl r2
pushl r1 pushl r1
calls $3,_m_a_i_n calls $3,__m_a_i_n
movl $Im2,ap movl $Im2,ap
movl r0,6(ap) movl r0,6(ap)
chmk (ap)+ chmk (ap)+

View file

@ -3,7 +3,7 @@
.define begtext,begdata,begbss,syscal .define begtext,begdata,begbss,syscal
.define hol0,.reghp,.limhp,.trppc,.ignmask .define hol0,.reghp,.limhp,.trppc,.ignmask
.define ERANGE,ESET,EHEAP,ECASE,EILLINS,EIDIVZ,EODDZ .define ERANGE,ESET,EHEAP,ECASE,EILLINS,EIDIVZ,EODDZ
.extern _end .extern endbss
ERANGE = 1 ERANGE = 1
ESET = 2 ESET = 2
@ -42,7 +42,7 @@ begtext:
push bx push bx
push cx push cx
xor bp,bp xor bp,bp
mov bx,_end mov bx,endbss
mov cx,9 mov cx,9
add bx,1024 add bx,1024
shr bx,cl shr bx,cl
@ -50,11 +50,11 @@ begtext:
call grow call grow
xor cx,cx xor cx,cx
push cx push cx
call _sbrk call __sbrk
mov (.limhp),ax mov (.limhp),ax
mov (.reghp),ax ! on Xenix, heap begins above stack! mov (.reghp),ax ! on Xenix, heap begins above stack!
pop ax pop ax
call _m_a_i_n call __m_a_i_n
push ax push ax
call __exit call __exit
.sect .data .sect .data

View file

@ -44,7 +44,7 @@
push bc push bc
ld bc,1 ld bc,1
push bc push bc
call _m_a_i_n call __m_a_i_n
jp 0x20 jp 0x20

View file

@ -44,7 +44,7 @@
push bc push bc
ld bc,1 ld bc,1
push bc push bc
call _m_a_i_n call __m_a_i_n
jp 0x20 jp 0x20

View file

@ -39,7 +39,7 @@ EBADMON = 25
push *RR14, envp push *RR14, envp
push *RR14, argv push *RR14, argv
push *RR14, $1 push *RR14, $1
calr _m_a_i_n calr __m_a_i_n
ldl RR14, $0xC00017FC ldl RR14, $0xC00017FC
sc $0 sc $0

View file

@ -219,7 +219,7 @@ struct rel { /* for relocation tables */
#define DATA_BYTES 9 #define DATA_BYTES 9
/* name of procedure to be called first */ /* name of procedure to be called first */
#define MAIN "m_a_i_n" #define MAIN "_m_a_i_n"
/* headers of datablocks written */ /* headers of datablocks written */
#define HEADREP 0 #define HEADREP 0