{"id":3928,"date":"2013-08-31T05:04:55","date_gmt":"2013-08-30T19:04:55","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=3928"},"modified":"2020-04-28T09:40:37","modified_gmt":"2020-04-27T23:40:37","slug":"assembler-for-macosx-64bit-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/assembler-for-macosx-64bit-tutorial\/","title":{"rendered":"Assembler for MacOSX 64bit Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/MacOsX\/Assembler\/Assembler_MacTerminal.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Assembler for MacOSX 64bit Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/MacOsX\/Assembler\/Assembler_MacTerminal.jpg\" title=\"Assembler for MacOSX 64bit Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Assembler for MacOSX 64bit Tutorial<\/p><\/div>\n<p>Assembler programming is a very early form of software code, dating back as far as 1954, that sits, in the spectrum of computer language sophistication, between computer machine code and the compiled source codes of modern programming languages (which comparatively read like a story \u2026 good luck with Assembler stories \u2026 gobbleLITTLELESSgook?!), predating BASIC and FORTRAN. The Wikipedia page about compilers puts this in historical perspective \u201c<\/p>\n<blockquote><p>The first compiler was written by Grace Hopper, in 1952, for the A-0 programming language. The FORTRAN team led by John Backus at IBM is generally credited as having introduced the first complete compiler in 1957.<\/p><\/blockquote>\n<p>\u201d Let\u2019s see some information about Assembler, from Wikipedia, below.<\/p>\n<blockquote><p>An assembly language is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture&#8217;s machine code instructions. Each assembly language is specific to a particular computer architecture, in contrast to most high-level programming languages, which are generally portable across multiple architectures, but require interpreters or compiling.<\/p>\n<p>Assembly language is converted into executable machine code by a utility program referred to as an assembler; the conversion process is referred to as assembly, or assembling the code.<\/p>\n<p>Assembly language uses a mnemonic to represent each low-level machine operation or opcode. Some opcodes require one or more operands as part of the instruction, and most assemblers can take labels and symbols as operands to represent addresses and constants, instead of hard coding them into the program. Macro assemblers include a macroinstruction facility so that assembly language text can be pre-assigned to a name, and that name can be used to insert the text into other code. Many assemblers offer additional mechanisms to facilitate program development, to control the assembly process, and to aid debugging.\n<\/p><\/blockquote>\n<p>Our tutorial today builds on the previous <a target=_blank href=\"#aptapt\" title=\"Assembler Primer Tutorial\">Assember Primer Tutorial<\/a> where we showed Hello World using Assembler in a 32bit Windows environment, but for today we move to a Mac laptop Terminal bash environment for 64bit and uses the great NASM Assembler.<\/p>\n<p>The tutorial shows some simple Assembler code in action for the following pretty specific environment.<\/p>\n<ul>\n<li>Operating System: Mac OS X Version 10.7.5<\/li>\n<li>Xcode: Version 4.5.2 (4G2008a)<\/li>\n<li>Model Name:\tMacBook Pro<\/li>\n<li>Model Identifier:\tMacBookPro8,1<\/li>\n<li>Processor Name:\tIntel Core i5<\/li>\n<li>Processor Speed:\t2.4 GHz<\/li>\n<li>Number of Processors:\t1<\/li>\n<li>Total Number of Cores:\t2<\/li>\n<\/ul>\n<p>Several streamlining operations would be good for your own usage, such as making &#8220;ld&#8221; be in your path ( so that you don&#8217;t need to use the big long path used in this tutorial &#8230; arrived at this via &#8230; find \/ -name &#8216;ld&#8217; 2&gt; \/dev\/null ) and using more switches so that you don&#8217;t link to that default .\/a.out etcetera etcetera.   This is a very introductory tutorial, so please consult with the links below for more information, and it tends to be that with Assembler programming you need to know your environment and when seeking advice off the search engines, be careful to look for advice as much in common with your own environment as is feasibly possible.   Hope you&#8217;ve enjoyed this tutorial, and will leave you with some links below.   See you on the flip side.   Won&#8217;t zip (though used zip for this tutorial &#8230; chortle, chortle), because we&#8217;ll be back here tomorrow.  Chow.  Be going now.   See ya&#8217; later alligator. <\/p>\n<p>Link to Assembler information &#8230; <a target=_blank title='Assembler programming information' href='http:\/\/en.wikipedia.org\/wiki\/Assembler_(computing)'>from Wikipedia from which quote above comes<\/a>.<br \/>\nLink to NASM SDK download website <a target=_blank title='Assembler programming information' href='http:\/\/nasm.us\/'>here<\/a> which installs an Assembler compiler for 64bit Mac, amongst other platforms (thanks so much).<br \/>\nLink to downloadable Assembler programming source code which you can rename to <a target=_blank title='helloworld.s Assembler programming source code' href='http:\/\/www.rjmprogramming.com.au\/MacOsX\/Assembler\/helloworld.s_GETME'>helloworld.s<\/a> inspired by the great tutorial <a target=_blank title='Mac OS X 64 bit Assembly System Calls' href='http:\/\/thexploit.com\/secdev\/mac-os-x-64-bit-assembly-system-calls\/'>Mac OS X 64 bit Assembly System Calls<\/a>.<\/p>\n<hr \/>\n<p id='aptapt'>Previous <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/DOS\/Assembler\/\" title=\"Assembler Primer Tutorial\">Assember Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/DOS\/Assembler\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Assembler Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/DOS\/Assembler\/MASM_Assembler.jpg\" title=\"Assembler Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Assembler Primer Tutorial<\/p><\/div>\n<p>Assembler programming is a very early form of software code, dating back as far as 1954, that sits, in the spectrum of computer language sophistication, between computer machine code and the compiled source codes of modern programming languages (which comparatively read like a story \u2026 good luck with Assembler stories \u2026 gobbleLITTLELESSgook?!), predating BASIC and FORTRAN. The Wikipedia page about compilers puts this in historical perspective \u201c<\/p>\n<blockquote><p>The first compiler was written by Grace Hopper, in 1952, for the A-0 programming language. The FORTRAN team led by John Backus at IBM is generally credited as having introduced the first complete compiler in 1957.<\/p><\/blockquote>\n<p>\u201d Let\u2019s see some information about Assembler, from Wikipedia, below.<\/p>\n<blockquote><p>An assembly language is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture&#8217;s machine code instructions. Each assembly language is specific to a particular computer architecture, in contrast to most high-level programming languages, which are generally portable across multiple architectures, but require interpreters or compiling.<\/p>\n<p>Assembly language is converted into executable machine code by a utility program referred to as an assembler; the conversion process is referred to as assembly, or assembling the code.<\/p>\n<p>Assembly language uses a mnemonic to represent each low-level machine operation or opcode. Some opcodes require one or more operands as part of the instruction, and most assemblers can take labels and symbols as operands to represent addresses and constants, instead of hard coding them into the program. Macro assemblers include a macroinstruction facility so that assembly language text can be pre-assigned to a name, and that name can be used to insert the text into other code. Many assemblers offer additional mechanisms to facilitate program development, to control the assembly process, and to aid debugging.\n<\/p><\/blockquote>\n<p>The tutorial shows some simple Assembler code in action for a <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/DOS\/Assembler\/'>Hello World program<\/a> after seeing some slides regarding the install of MASM 32bit compiler of Assembler code.    Please take care if you go ahead installing MASM 32bit Assembler compiler, and, as mentioned several times with the install, do not proceed if there are even warning messages from the install, or, pretty obviously, if you do not have 32bit Windows as your operating system.<\/p>\n<p>Link to Assembler information &#8230; <a target=_blank title='Assembler programming information' href='http:\/\/en.wikipedia.org\/wiki\/Assembler_(computing)'>from Wikipedia from which quote above comes<\/a>.<br \/>\nLink to MASM32 SDK download website <a target=_blank title='Assembler programming information' href='http:\/\/www.masm32.com\/index.htm'>here<\/a> which installs an Assembler compiler for 32bit Windows.<br \/>\nLink to downloadable Assembler programming source code which is word for word from <a target=_blank title='Outputting Hello World in MASM using WIN32 Functions' href='http:\/\/stackoverflow.com\/questions\/4568306\/outputting-hello-world-in-masm-using-win32-functions'>Outputting Hello World in MASM using WIN32 Functions<\/a> and rename to <a target=_blank title='test.asm Assembler programming source code' href='http:\/\/www.rjmprogramming.com.au\/DOS\/Assembler\/test.asm_GETME'>test.asm<\/a><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d3529' onclick='var dv=document.getElementById(\"d3529\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=42\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d3529' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d3928' onclick='var dv=document.getElementById(\"d3928\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=42\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d3928' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Assembler programming is a very early form of software code, dating back as far as 1954, that sits, in the spectrum of computer language sophistication, between computer machine code and the compiled source codes of modern programming languages (which comparatively &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/assembler-for-macosx-64bit-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[47,108,132,707,723,725,997,1319],"class_list":["post-3928","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-64-bit","tag-assembler","tag-bash","tag-linux","tag-mac","tag-mac-os-x","tag-programming","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/3928"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=3928"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/3928\/revisions"}],"predecessor-version":[{"id":48850,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/3928\/revisions\/48850"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=3928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=3928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=3928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}