835
883
{if LasTSec<>sec_none then
836
884
AsmWriteLn('_'+target_asm.secnames[LasTSec]+#9#9'ENDS');}
837
if tai_section(hp).sec<>sec_none then
886
if tai_section(hp).sectype<>sec_none then
888
if tai_section(hp).sectype in [sec_data,sec_rodata,sec_bss] then
889
cur_CSECT_class:= '[RW]'
890
else if tai_section(hp).sectype in [sec_code] then
893
cur_CSECT_class:= '[RO]';
895
s:= tai_section(hp).name^;
897
InternalError(2004101001); {Nameless sections should not occur on MPW}
898
ReplaceForbiddenChars(s);
840
AsmWriteLn(#9+target_asm.secnames[tai_section(hp).sec]);
902
AsmWriteLn(#9+secnames[tai_section(hp).sectype]+' '+cur_CSECT_name+cur_CSECT_class);
842
lastfileinfo.line:=-1;
904
lastfileinfo.line:=-1;
845
LasTSec:=tai_section(hp).sec;
907
LasTSec:=tai_section(hp).sectype;
869
930
{TODO: ? PadTabs(s,#0) }
876
AsmWrite(ait_const2str[hp.typ]+tostr(tai_const(hp).value));
880
found:=(not (tai(hp.next)=nil)) and (tai(hp.next).typ=consttyp);
884
s:=','+tostr(tai_const(hp).value);
888
until (not found) or (l>line_length);
893
s:= tai_const_symbol(hp).sym.name;
894
ReplaceForbiddenChars(s);
896
AsmWrite(#9'dc.l'#9);
897
if tai_const_symbol(hp).sym.typ = AT_FUNCTION then
936
internalerror(200404291);
940
if assigned(tai_const(hp).sym) then
941
internalerror(200404292);
942
AsmWrite(ait_const2str[ait_const_32bit]);
943
if target_info.endian = endian_little then
945
AsmWrite(tostr(longint(lo(tai_const(hp).value))));
947
AsmWrite(tostr(longint(hi(tai_const(hp).value))));
912
if not macos_direct_globals then
913
AsmWriteLn(const_storage_class);
916
(* TODO: the following might need to be included. Temporaily we
919
if tai_const_symbol(hp).offset>0 then
920
AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
921
else if tai_const_symbol(hp).offset<0 then
922
AsmWrite(tostr(tai_const_symbol(hp).offset));
925
if tai_const_symbol(hp).offset <> 0 then
926
InternalError(2002110101);
931
AsmWriteLn(#9'dc.l'#9'"'+single2str(tai_real_32bit(hp).value)+'"');
933
AsmWriteLn(#9'dc.d'#9'"'+double2str(tai_real_64bit(hp).value)+'"');
951
AsmWrite(tostr(longint(hi(tai_const(hp).value))));
953
AsmWrite(tostr(longint(lo(tai_const(hp).value))));
958
ait_const_uleb128bit,
959
ait_const_sleb128bit,
963
ait_const_rva_symbol,
964
ait_const_indirect_symbol :
966
AsmWrite(ait_const2str[hp.typ]);
970
if assigned(tai_const(hp).sym) then
972
if assigned(tai_const(hp).endsym) then
974
if (tai_const(hp).endsym.typ = AT_FUNCTION) and use_PR then
977
s:=tai_const(hp).endsym.name;
978
ReplaceForbiddenChars(s);
982
if tai_const(hp).endsym.typ = AT_FUNCTION then
991
inc(l,5); {Approx 5 extra, no need to be exactly}
994
if (tai_const(hp).sym.typ = AT_FUNCTION) and use_PR then
997
s:= tai_const(hp).sym.name;
998
ReplaceForbiddenChars(s);
1002
if tai_const(hp).sym.typ = AT_FUNCTION then
1009
inc(l,5); {Approx 5 extra, no need to be exactly}
1011
if tai_const(hp).value > 0 then
1012
s:= '+'+tostr(tai_const(hp).value)
1013
else if tai_const(hp).value < 0 then
1014
s:= '-'+tostr(tai_const(hp).value)
1025
s:= tostr(tai_const(hp).value);
1030
if (l>line_length) or
1032
(tai(hp.next).typ<>consttyp) then
1042
AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
1043
d:=tai_real_64bit(hp).value;
1044
{ swap the values to correct endian if required }
1045
if source_info.endian <> target_info.endian then
1046
swap64bitarray(t64bitarray(d));
1047
AsmWrite(#9'dc.b'#9);
1053
AsmWrite(tostr(t64bitarray(d)[i]));
1061
AsmWriteLn(target_asm.comment+'value: '+single2str(tai_real_32bit(hp).value));
1062
sin:=tai_real_32bit(hp).value;
1063
{ swap the values to correct endian if required }
1064
if source_info.endian <> target_info.endian then
1065
swap32bitarray(t32bitarray(sin));
1066
AsmWrite(#9'dc.b'#9);
1071
AsmWrite(tostr(t32bitarray(sin)[i]));
936
1078
{NOTE When a single quote char is encountered, it is
980
1122
end; { end for j:=0 ... }
982
1124
{ do last line of lines }
983
if counter < tai_string(hp).len then
984
AsmWrite(#9'dc.b'#9);
986
for i:=counter to tai_string(hp).len-1 do
988
{ it is an ascii character. }
989
if (ord(tai_string(hp).str[i])>31) and
990
(ord(tai_string(hp).str[i])<128) and
991
(tai_string(hp).str[i]<>'''') and
992
(tai_string(hp).str[i]<>'\') then
1000
AsmWrite(tai_string(hp).str[i]);
1002
end { if > 31 and < 128 and " }
1010
AsmWrite(tostr(ord(tai_string(hp).str[i])));
1012
end; { end for i:=0 to... }
1125
if counter < tai_string(hp).len then
1126
AsmWrite(#9'dc.b'#9);
1128
for i:=counter to tai_string(hp).len-1 do
1130
{ it is an ascii character. }
1131
if (ord(tai_string(hp).str[i])>31) and
1132
(ord(tai_string(hp).str[i])<128) and
1133
(tai_string(hp).str[i]<>'''') and
1134
(tai_string(hp).str[i]<>'\') then
1142
AsmWrite(tai_string(hp).str[i]);
1144
end { if > 31 and < 128 and " }
1152
AsmWrite(tostr(ord(tai_string(hp).str[i])));
1154
end; { end for i:=0 to... }
1020
1162
if tai_label(hp).l.is_used then
1022
1164
s:= tai_label(hp).l.name;
1023
ReplaceForbiddenChars(s);
1024
1165
if s[1] = '@' then
1167
ReplaceForbiddenChars(s);
1029
1173
//Procedure entry points:
1030
1174
if not macos_direct_globals then
1032
AsmWriteLn(#9'toc');
1033
AsmWrite(#9'tc'#9); AsmWrite(s);
1034
AsmWrite('[TC], '); AsmWrite(s);
1035
AsmWriteLn(const_storage_class);
1037
AsmWrite(#9'csect'#9); AsmWrite(s);
1038
AsmWriteLn(const_storage_class);
1176
WriteDataHeader(s, tai_label(hp).is_global, true);
1180
ReplaceForbiddenChars(s);
1042
1181
AsmWrite(#9'csect'#9); AsmWrite(s);
1043
1182
AsmWriteLn('[TC]');
1095
1232
ait_stab_function_name: ;
1099
{ only reset buffer if nothing has changed }
1100
if AsmSize=AsmStartSize then
1105
if LasTSec<>sec_none then
1106
AsmWriteLn('_'+target_asm.secnames[LasTSec]+#9#9'ends');
1109
AsmWriteLn(#9'end');
1112
AsmCreate(tai_cut(hp).place);
1114
{ avoid empty files }
1115
while assigned(hp.next) and (tai(hp.next).typ in [ait_cut,ait_section,ait_comment]) do
1117
if tai(hp.next).typ=ait_section then
1119
lasTSec:=tai_section(hp.next).sec;
1125
if lasTSec<>sec_none then
1126
AsmWriteLn(#9+target_asm.secnames[lasTSec]);
1127
{ AsmWriteLn('_'+target_asm.secnames[lasTSec]+#9#9+
1128
'SEGMENT'#9'PARA PUBLIC USE32 '''+
1129
target_asm.secnames[lasTSec]+'''');
1131
AsmStartSize:=AsmSize;
1236
InternalError(2004101101); {Smart linking is done transparently by the MPW linker.}
1135
1240
if tai_marker(hp).kind=InlineStart then
1136
1241
inc(InlineLevel)
1364
1464
$Log: agppcmpw.pas,v $
1365
Revision 1.34 2004/03/17 12:03:31 olle
1366
* bugfix for multiline string constants
1368
Revision 1.33 2004/03/02 00:57:01 olle
1369
+ adding missing log msg: misc fixes
1371
Revision 1.32 2004/03/02 00:36:33 olle
1373
Revision 1.31 2004/02/27 10:21:05 florian
1375
+ refaddr to treference added
1376
+ refsymbol to treference added
1377
* top_local stuff moved to an extra record to save memory
1379
* tppufile.get/putint64/aint implemented
1381
Revision 1.30 2004/02/04 15:28:24 olle
1382
* made more in phase with agppcgas.pas
1384
Revision 1.29 2004/01/12 00:08:03 olle
1385
* gen of conditional instr updated according to agppcgas
1386
* gen of PPCAsm command fixed
1388
Revision 1.28 2003/11/12 16:05:40 florian
1389
* assembler readers OOPed
1390
+ typed currency constants
1391
+ typed 128 bit float constants if the CPU supports it
1393
Revision 1.27 2003/10/25 10:37:26 florian
1394
* fixed compilation of ppc compiler
1396
Revision 1.26 2003/10/01 20:34:49 peter
1397
* procinfo unit contains tprocinfo
1398
* cginfo renamed to cgbase
1399
* moved cgmessage to verbose
1400
* fixed ppc and sparc compiles
1402
Revision 1.25 2003/09/12 12:30:27 olle
1403
* max lenght of symbols increased to 255
1404
* emitted strings can now contain backslashes
1406
Revision 1.24 2003/09/03 19:35:24 peter
1407
* powerpc compiles again
1409
Revision 1.23 2003/08/24 21:40:12 olle
1412
Revision 1.21 2003/08/18 11:47:15 olle
1413
+ added asm directive ALIGNING OFF to avoid unexpected aligning by the assembler
1415
Revision 1.20 2002/10/01 05:17:27 olle
1418
Revision 1.19 2003/04/06 21:01:40 olle
1419
+ line numbers are now emitted in the assembler code
1420
* bug in export and import directive fixed
1421
* made code more in sync with aggas.pas
1423
Revision 1.18 2003/01/13 17:17:50 olle
1424
* changed global var access, TOC now contain pointers to globals
1425
* fixed handling of function pointers
1427
Revision 1.17 2003/01/08 18:43:57 daniel
1428
* Tregister changed into a record
1430
Revision 1.16 2002/11/28 10:56:07 olle
1431
* changed proc ref from .xxx[PR] (refering to its section)
1432
to .xxx (refering to its label) to allow for multiple ref to a proc.
1434
Revision 1.15 2002/11/17 16:31:59 carl
1435
* memory optimization (3-4%) : cleanup of tai fields,
1436
cleanup of tdef and tsym fields.
1437
* make it work for m68k
1439
Revision 1.14 2002/11/07 15:50:23 jonas
1440
* fixed bctr(l) problems
1442
Revision 1.13 2002/11/04 18:24:53 olle
1443
* globals are located in TOC and relative r2, instead of absolute
1444
* symbols which only differs in case are treated as a single symbol
1445
+ tai_const_symbol supported
1446
* only refs_full accepted
1448
Revision 1.12 2002/10/23 15:31:01 olle
1449
* branch b does not jump to dotted symbol now
1451
Revision 1.11 2002/10/19 23:52:40 olle
1452
* import directive changed
1454
Revision 1.10 2002/10/10 19:39:37 florian
1455
* changes from Olle to get simple programs compiled and assembled
1457
Revision 1.9 2002/10/07 21:19:53 florian
1460
Revision 1.8 2002/10/06 22:46:20 florian
1461
* fixed function exporting
1463
Revision 1.7 2002/10/02 22:14:15 florian
1464
* improve function imports
1466
Revision 1.6 2002/09/27 21:09:49 florian
1467
+ readed because previous version was broken
1469
Revision 1.2 2002/08/31 12:43:31 florian
1470
* ppc compilation fixed
1472
Revision 1.1 2002/08/20 21:40:44 florian
1473
+ target macos for ppc added
1474
+ frame work for mpw assembler output
1465
Revision 1.44 2005/02/14 17:13:10 peter
1468
Revision 1.43 2005/02/08 22:46:00 olle
1469
* fixed erroneous asm line directive