-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTcopy.c
66 lines (57 loc) · 1.53 KB
/
Tcopy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* LSI-11 linker
* ëÏÐÉÒÏ×ÁÎÉÅ ÏÂ'ÅËÔÎÙÈ ÍÏÄÕÌÅÊ × ÚÁÇÒÕÚÏÞÎÙÊ ÍÏÄÕÌØ.
*/
#include "LinkerDefs"
static unsigned TextLen, BssLen, LoadAddr;
void Tseta( adload )
unsigned adload; /* AÄÒÅÓ ÚÁÇÒÕÚËÉ */
{
LoadAddr = adload;
}
void Tinit()
{
TextLen = BssLen = 0;
}
void Tcopy( mp )
Module *mp;
{
char *buff;
unsigned int blen; /* äÌÉÎÁ ÐÅÒÅÄÁÎÎÏÇÏ ÂÌÏËÁ (ÂÁÊÔÙ) */
unsigned int clen; /* óÕÍÍÁÒÎÁÑ ÄÌÉÎÁ ÐÅÒÅÄÁÎÎÏÊ ÞÁÓÔÉ */
unsigned int totlen; /* ïÂÝÁÑ ÄÌÉÎÁ ÍÏÄÕÌÑ */
unsigned int ua;
mp->Mseek = TextLen;
mp->Mldbase = TextLen+LoadAddr; /* òÁÚÍÅÝÁÅÍ ËÏÄÙ É ÄÁÎÎÙÅ */
mp->Mbssoff = BssLen; /* òÁÚÍÅÝÁÅÍ ÂÕÆÅÒÁ */
totlen = mp->Mtextsize + mp->Mdatasize;
for( clen = 0; clen < totlen; clen += blen ){
ModRead( &buff, (int *) &blen );
if( clen+blen >= totlen ) blen = totlen-clen;
if( blen == 0 ) break;
OutWrite( buff, blen );
}
if( clen < totlen ) Error(1); /* óÌÉÛËÏÍ ËÏÒÏÔËÉÊ */
/* ðÒÏ×ÅÒËÁ ÎÅ ÐÅÒÅÐÏÌÎÅÎÉÅ ÌÏÇÉÞÅÓËÉÈ ÓÅÇÍÅÎÔÏ× */
/* óÕÍÍÁÒÎÏÅ ÐÅÒÅÐÏÌÎÅÎÉÅ ÐÒÏ×ÅÒÑÅÔÓÑ × Reloc() */
ua = TextLen + clen;
if( ua < TextLen ) Error(2);
TextLen = ua;
ua = BssLen + mp->Mbsssize;
if( ua < BssLen ) Error(2);
BssLen = ua;
/* îÅÞÅÔÎÙÈ ÄÌÉÎÎ ÎÅ ÄÏÌÖÎÏ ÂÙÔØ */
if( (BssLen|TextLen) & 1 ) Error(1);
}
void Tget( bp )
Statistics *bp;
{
bp->Sladdr = LoadAddr;
bp->Stlen = TextLen;
bp->Sdlen = 0;
bp->Sblen = BssLen;
}
unsigned Tabss()
{
return LoadAddr+TextLen;
}