Knowledge (XXG)

GNU Assembler

Source 📝

644: 867: 59: 27: 245:
GAS supports a general syntax that works for all of the supported architectures. The general syntax includes assembler directives and a method for commenting. The default syntax is
1296: 1334: 733: 451:. GAS is often used as the assembler on Linux operating systems in conjunction with other GNU software. A modified version of GAS can also be found in the 829: 1140: 1561: 966: 775: 959: 1014: 649: 265:. While most of the available assembler directives are valid regardless of the target architecture, some directives are machine dependent. 802: 1327: 1004: 999: 954: 1571: 165: 1576: 949: 261:(also known as pseudo ops), which are keywords beginning with a period that behave similarly to preprocessor directives in the 1375: 1009: 662: 1566: 916: 448: 1320: 1284: 447:
Being the back-end for a popular compiler suite, namely GCC, the GNU Assembler is very widely used in compiling modern
50: 737: 982: 222: 121: 763:
A new pseudo-op .intel_syntax has been implemented to allow gas to parse i386 assembly programs with intel syntax.
1431: 1530: 1400: 1360: 1130: 944: 667: 262: 85: 833: 1525: 1075: 376: 258: 177: 758: 1243: 1135: 713: 1449: 1390: 1258: 987: 779: 426: 358: 309:
Single line comments have a few different formats varying on which architecture is being assembled for.
214: 1210: 181: 688: 233:
The first version of GAS was released in 1986–1987. It was written by Dean Elsner and supported the
1556: 1425: 1301: 1145: 718: 412: 173: 104: 58: 806: 1520: 1233: 1065: 1060: 992: 92: 1437: 1355: 1253: 1160: 1055: 909: 354: 109: 1268: 1200: 432: 406: 116: 1515: 1443: 1370: 1238: 1228: 1105: 558:# interrupt with location 0x80 (128), which invokes the kernel's system call procedure 866: 1505: 1488: 1483: 1473: 1408: 1385: 1248: 1150: 246: 210: 97: 1550: 1493: 1290: 1070: 939: 657: 218: 1380: 1365: 1263: 1085: 1080: 1034: 902: 422: 189: 185: 1115: 1045: 925: 314: 288:
As in C, multi-line comments start and end with mirroring slash-asterisk pairs:
169: 39: 26: 1478: 1468: 1175: 1169: 1120: 639: 196: 34: 1498: 1195: 1125: 1110: 368: 201: 630:# assign (current address - address of msg start) to symbol "len" 872: 1205: 1185: 1165: 1090: 1040: 889: 392: 133: 1095: 416: 402: 384: 372: 350: 1312: 1510: 1190: 1180: 1155: 436: 388: 380: 362: 334: 330: 322: 519:# 1 (file descriptor for stdout) -> EBX (1st argument to syscall) 1050: 885: 860: 472: 468: 452: 879: 1413: 1100: 456: 396: 346: 342: 326: 318: 268:
Since version 2.10, Intel syntax can be used through use of the
206: 1316: 898: 1535: 1030: 894: 338: 234: 504:# 4 (code for "write" syscall) -> EAX register 213:, and both runs on and assembles for a number of different 534:# 32-bit address of msg string -> ECX (2nd argument) 1459: 1399: 1348: 1277: 1221: 1023: 975: 932: 128: 115: 103: 91: 81: 49: 33: 884:: the portable GNU assembler –  188:, and various other software. It is a part of the 803:"Linux assemblers: A comparison of GAS and NASM" 1297:Free Software Foundation anti-Windows campaigns 1328: 910: 8: 19: 1335: 1321: 1313: 917: 903: 895: 865: 734:"The GNU Assembler - Assembler Directives" 549:# length of msg string -> EDX (3rd arg) 57: 18: 717: 707: 705: 679: 467:A standard "Hello, world!" program for 776:"AT&T Syntax versus Intel Syntax" 7: 1015:GNAT Modified General Public License 805:. IBM DeveloperWorks. Archived from 650:Free and open-source software portal 14: 1005:GNU Affero General Public License 1000:GNU Lesser General Public License 280:GAS supports two comment styles. 642: 573:# 1 ("exit") -> EAX 455:development tools package since 25: 1562:Free compilers and interpreters 687:Nick Clifton (17 August 2024). 1376:Low-level programming language 1010:GNU Free Documentation License 689:"GNU Binutils 2.43.1 released" 663:Binary File Descriptor library 16:Free and open-source assembler 1: 449:free and open source software 180:. It is used to assemble the 1285:GNU/Linux naming controversy 588:# 0 (with success) -> EBX 609:"Hello, world!\n" 1593: 983:GNU General Public License 801:Ram Narayan (2007-10-17). 223:GNU General Public License 205:, the standard name for a 122:GNU General Public License 1432:Microsoft Macro Assembler 77: 56:GNU Binutils 2.43.1  45: 24: 1361:Comparison of assemblers 967:History of free software 945:Free Software Foundation 668:Comparison of assemblers 477: 290: 1572:Linux programming tools 1577:Unix programming tools 263:C programming language 215:computer architectures 1450:Open Watcom Assembler 1391:x86 assembly language 712:"The GNU Assembler". 612:# inline ascii string 64:; 26 days ago 1567:GNU Project software 1531:Instruction listings 759:"GNU Assembler News" 182:GNU operating system 172:. It is the default 156:, commonly known as 1526:Calling conventions 1426:High Level Assembly 1343:x86 assembly topics 1302:Defective by Design 1269:Richard M. Stallman 257:GAS uses assembler 221:released under the 21: 1521:Processor register 1234:Benjamin Mako Hill 209:assembler. GAS is 1544: 1543: 1438:Netwide Assembler 1356:Assembly language 1310: 1309: 1254:Georg C. F. Greve 1161:GNU Privacy Guard 988:linking exception 168:developed by the 150: 149: 1584: 1337: 1330: 1323: 1314: 919: 912: 905: 896: 883: 882: 869: 864: 863: 861:Official website 846: 845: 843: 841: 836:on June 20, 2011 832:. Archived from 825: 819: 818: 816: 814: 798: 792: 791: 789: 787: 778:. Archived from 772: 766: 765: 755: 749: 748: 746: 745: 736:. Archived from 730: 724: 723: 721: 709: 700: 699: 697: 695: 684: 652: 647: 646: 645: 631: 628: 625: 622: 619: 616: 613: 610: 607: 604: 601: 598: 595: 592: 589: 586: 583: 580: 577: 574: 571: 568: 565: 562: 559: 556: 553: 550: 547: 544: 541: 538: 535: 532: 529: 526: 523: 520: 517: 514: 511: 508: 505: 502: 499: 496: 493: 490: 487: 484: 481: 433:exclamation mark 395:, Motorola, and 300: 297: 294: 271: 204: 146: 143: 141: 139: 137: 135: 72: 70: 65: 62:/ 17 August 2024 61: 29: 22: 1592: 1591: 1587: 1586: 1585: 1583: 1582: 1581: 1547: 1546: 1545: 1540: 1516:Program counter 1461: 1455: 1444:Turbo Assembler 1395: 1371:Instruction set 1344: 1341: 1311: 1306: 1273: 1239:Bradley M. Kuhn 1229:Alexandre Oliva 1217: 1019: 971: 928: 923: 878: 877: 859: 858: 855: 850: 849: 839: 837: 827: 826: 822: 812: 810: 809:on 3 March 2009 800: 799: 795: 785: 783: 782:on 20 June 2011 774: 773: 769: 757: 756: 752: 743: 741: 732: 731: 727: 711: 710: 703: 693: 691: 686: 685: 681: 676: 648: 643: 641: 638: 633: 632: 629: 626: 623: 620: 617: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 575: 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 465: 463:Example program 445: 302: 301: 298: 295: 292: 278: 269: 255: 247:AT&T syntax 243: 231: 200: 132: 73: 68: 66: 63: 17: 12: 11: 5: 1590: 1588: 1580: 1579: 1574: 1569: 1564: 1559: 1549: 1548: 1542: 1541: 1539: 1538: 1533: 1528: 1523: 1518: 1513: 1508: 1506:Memory address 1503: 1502: 1501: 1496: 1491: 1489:Interrupt flag 1486: 1484:Direction flag 1481: 1471: 1465: 1463: 1457: 1456: 1454: 1453: 1447: 1441: 1435: 1429: 1423: 1417: 1414:Flat Assembler 1411: 1405: 1403: 1397: 1396: 1394: 1393: 1388: 1386:Microassembler 1383: 1378: 1373: 1368: 1363: 1358: 1352: 1350: 1346: 1345: 1342: 1340: 1339: 1332: 1325: 1317: 1308: 1307: 1305: 1304: 1299: 1294: 1287: 1281: 1279: 1275: 1274: 1272: 1271: 1266: 1261: 1256: 1251: 1249:Federico Heinz 1246: 1241: 1236: 1231: 1225: 1223: 1219: 1218: 1216: 1215: 1208: 1203: 1198: 1193: 1188: 1183: 1178: 1173: 1163: 1158: 1153: 1151:GNU Archimedes 1148: 1143: 1138: 1133: 1128: 1123: 1118: 1113: 1108: 1103: 1098: 1093: 1088: 1083: 1078: 1073: 1068: 1063: 1058: 1053: 1048: 1043: 1038: 1027: 1025: 1021: 1020: 1018: 1017: 1012: 1007: 1002: 997: 996: 995: 993:font exception 990: 979: 977: 973: 972: 970: 969: 964: 963: 962: 957: 952: 942: 936: 934: 930: 929: 924: 922: 921: 914: 907: 899: 893: 892: 888:User Commands 875: 870: 854: 853:External links 851: 848: 847: 820: 793: 767: 750: 725: 719:10.1.1.32.4503 701: 678: 677: 675: 672: 671: 670: 665: 660: 654: 653: 637: 634: 597:# see previous 478: 464: 461: 444: 441: 440: 439: 429: 419: 409: 399: 365: 291: 277: 274: 254: 251: 242: 241:General syntax 239: 237:architecture. 230: 227: 211:cross-platform 148: 147: 130: 126: 125: 119: 113: 112: 107: 101: 100: 98:Cross-platform 95: 89: 88: 83: 79: 78: 75: 74: 69:17 August 2024 55: 53: 51:Stable release 47: 46: 43: 42: 37: 31: 30: 15: 13: 10: 9: 6: 4: 3: 2: 1589: 1578: 1575: 1573: 1570: 1568: 1565: 1563: 1560: 1558: 1555: 1554: 1552: 1537: 1534: 1532: 1529: 1527: 1524: 1522: 1519: 1517: 1514: 1512: 1509: 1507: 1504: 1500: 1497: 1495: 1494:Overflow flag 1492: 1490: 1487: 1485: 1482: 1480: 1477: 1476: 1475: 1472: 1470: 1467: 1466: 1464: 1458: 1451: 1448: 1445: 1442: 1439: 1436: 1433: 1430: 1427: 1424: 1421: 1420:GNU Assembler 1418: 1415: 1412: 1410: 1407: 1406: 1404: 1402: 1398: 1392: 1389: 1387: 1384: 1382: 1379: 1377: 1374: 1372: 1369: 1367: 1364: 1362: 1359: 1357: 1354: 1353: 1351: 1347: 1338: 1333: 1331: 1326: 1324: 1319: 1318: 1315: 1303: 1300: 1298: 1295: 1293: 1292: 1291:Revolution OS 1288: 1286: 1283: 1282: 1280: 1276: 1270: 1267: 1265: 1262: 1260: 1259:John Sullivan 1257: 1255: 1252: 1250: 1247: 1245: 1242: 1240: 1237: 1235: 1232: 1230: 1227: 1226: 1224: 1220: 1214: 1213: 1209: 1207: 1204: 1202: 1199: 1197: 1194: 1192: 1189: 1187: 1184: 1182: 1179: 1177: 1174: 1171: 1167: 1164: 1162: 1159: 1157: 1154: 1152: 1149: 1147: 1144: 1142: 1139: 1137: 1134: 1132: 1129: 1127: 1124: 1122: 1119: 1117: 1114: 1112: 1109: 1107: 1104: 1102: 1099: 1097: 1094: 1092: 1089: 1087: 1084: 1082: 1079: 1077: 1074: 1072: 1069: 1067: 1064: 1062: 1059: 1057: 1054: 1052: 1049: 1047: 1044: 1042: 1039: 1036: 1032: 1029: 1028: 1026: 1022: 1016: 1013: 1011: 1008: 1006: 1003: 1001: 998: 994: 991: 989: 986: 985: 984: 981: 980: 978: 974: 968: 965: 961: 960:Latin America 958: 956: 953: 951: 948: 947: 946: 943: 941: 940:GNU Manifesto 938: 937: 935: 931: 927: 920: 915: 913: 908: 906: 901: 900: 897: 891: 887: 881: 876: 874: 871: 868: 862: 857: 856: 852: 835: 831: 828:Red Hat Inc. 824: 821: 808: 804: 797: 794: 781: 777: 771: 768: 764: 760: 754: 751: 740:on 2012-02-22 739: 735: 729: 726: 720: 715: 708: 706: 702: 690: 683: 680: 673: 669: 666: 664: 661: 659: 658:GNU toolchain 656: 655: 651: 640: 635: 476: 474: 470: 462: 460: 458: 454: 450: 442: 438: 434: 430: 428: 424: 420: 418: 414: 410: 408: 405:(@) — 32-bit 404: 400: 398: 394: 390: 386: 382: 378: 374: 370: 366: 364: 360: 356: 352: 348: 344: 340: 336: 332: 328: 324: 320: 316: 312: 311: 310: 307: 306: 289: 286: 285: 281: 275: 273: 270:.intel_syntax 266: 264: 260: 252: 250: 248: 240: 238: 236: 228: 226: 224: 220: 219:free software 216: 212: 208: 203: 198: 193: 191: 187: 183: 179: 175: 171: 167: 163: 159: 155: 154:GNU Assembler 145: 131: 127: 123: 120: 118: 114: 111: 108: 106: 102: 99: 96: 94: 90: 87: 84: 80: 76: 60: 54: 52: 48: 44: 41: 38: 36: 32: 28: 23: 20:GNU Assembler 1419: 1381:Machine code 1366:Disassembler 1289: 1278:Other topics 1264:Nagarjuna G. 1222:Contributors 1211: 1186:GNU LilyPond 1146:GNU Electric 1071:Build system 838:. Retrieved 834:the original 823: 811:. Retrieved 807:the original 796: 784:. Retrieved 780:the original 770: 762: 753: 742:. Retrieved 738:the original 728: 692:. Retrieved 682: 466: 446: 423:vertical bar 308: 304: 303: 287: 283: 282: 279: 267: 256: 244: 232: 194: 190:GNU Binutils 186:Linux kernel 161: 157: 153: 151: 35:Developer(s) 1460:Programming 1116:GNU TeXmacs 1046:Linux-libre 926:GNU Project 315:hash symbol 305:Single-line 272:directive. 170:GNU Project 40:GNU Project 1557:Assemblers 1551:Categories 1479:Carry flag 1469:Call stack 1401:Assemblers 1176:GNU Health 1121:GNU Octave 873:Gas manual 830:"Using as" 744:2008-04-13 674:References 437:Renesas SH 284:Multi-line 259:directives 253:Directives 197:executable 82:Written in 1536:Registers 1499:Zero flag 1244:Brian Fox 1196:GNU Chess 1126:GNU Taler 1111:GNU Emacs 1066:findutils 1061:coreutils 714:CiteSeerX 694:18 August 411:A double 369:semicolon 217:. GAS is 199:is named 192:package. 166:assembler 164:, is the 142:/binutils 140:/software 110:Assembler 1409:A86/A386 1166:Gnuzilla 1081:binutils 1035:variants 1024:Software 976:Licenses 636:See also 393:picoJava 383:family, 375:family, 276:Comments 195:The GAS 184:and the 174:back-end 93:Platform 1212:more... 1096:GNUstep 933:History 840:Jan 10, 813:28 July 786:28 July 489:_start: 480:.global 417:AArch64 415:(//) — 403:at sign 373:AMD 29k 351:PowerPC 296:comment 229:History 129:Website 117:License 67: ( 1511:Opcode 1462:issues 1452:(WASM) 1446:(TASM) 1440:(NASM) 1434:(MASM) 1416:(FASM) 1349:Topics 1191:GNU Go 1181:GNUmed 1170:IceCat 1156:GNUnet 950:Europe 890:Manual 716:  606:.ascii 594:$ 0x80 555:$ 0x80 483:_start 435:(!) — 427:M680x0 425:(|) — 389:PDP-11 381:H8/300 371:(;) — 363:RISC-V 361:, and 359:M680x0 335:68HC12 331:68HC11 323:x86-64 317:(#) — 1474:Flags 1428:(HLA) 1422:(GAS) 1201:Gnash 1131:GNU R 1051:glibc 955:India 886:Linux 880:as(1) 600:.data 540:$ len 525:$ msg 486:.text 473:IA-32 469:Linux 453:macOS 443:Usage 413:slash 1206:Guix 1106:Jami 1101:GIMP 1091:GRUB 1056:Bash 1041:Hurd 842:2013 815:2014 788:2014 696:2024 603:msg: 585:%ebx 576:movl 570:%eax 561:movl 546:%edx 537:movl 531:%ecx 522:movl 516:%ebx 507:movl 501:%eax 492:movl 457:OS X 401:The 397:M32C 385:HPPA 355:MIPS 347:M32R 343:V850 327:i960 319:i386 225:v3. 207:Unix 152:The 138:.org 136:.gnu 105:Type 1141:GMP 1136:GSL 1086:GDB 1076:GCC 1031:GNU 627:msg 615:len 591:int 579:$ 0 564:$ 1 552:int 510:$ 1 495:$ 4 471:on 431:An 407:ARM 377:ARC 339:VAX 293:/* 235:VAX 178:GCC 176:of 160:or 158:gas 134:www 1553:: 761:. 704:^ 475:: 459:. 421:A 391:, 387:, 379:, 367:A 357:, 353:, 349:, 345:, 341:, 337:, 333:, 329:, 325:, 321:, 313:A 299:*/ 249:. 202:as 162:as 124:v3 1336:e 1329:t 1322:v 1172:) 1168:( 1037:) 1033:( 918:e 911:t 904:v 844:. 817:. 790:. 747:. 722:. 698:. 624:- 621:. 618:= 582:, 567:, 543:, 528:, 513:, 498:, 144:/ 86:C 71:)

Index


Developer(s)
GNU Project
Stable release
Edit this on Wikidata
C
Platform
Cross-platform
Type
Assembler
License
GNU General Public License
www.gnu.org/software/binutils/
assembler
GNU Project
back-end
GCC
GNU operating system
Linux kernel
GNU Binutils
executable
as
Unix
cross-platform
computer architectures
free software
GNU General Public License
VAX
AT&T syntax
directives

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.