<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Solid Snake</title>
	<atom:link href="http://thesolidsnake.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thesolidsnake.wordpress.com</link>
	<description>A carefree programmer&#039;s blog</description>
	<lastBuildDate>Sat, 28 Jan 2012 08:39:00 +0000</lastBuildDate>
	<language>id</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thesolidsnake.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Solid Snake</title>
		<link>http://thesolidsnake.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thesolidsnake.wordpress.com/osd.xml" title="The Solid Snake" />
	<atom:link rel='hub' href='http://thesolidsnake.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Menyelesaikan Sliding Puzzle Dengan Algoritma A*</title>
		<link>http://thesolidsnake.wordpress.com/2012/01/28/menyelesaikan-sliding-puzzle-dengan-algoritma-a/</link>
		<comments>http://thesolidsnake.wordpress.com/2012/01/28/menyelesaikan-sliding-puzzle-dengan-algoritma-a/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 08:36:38 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[Algoritma]]></category>
		<category><![CDATA[A Star]]></category>
		<category><![CDATA[Sliding Puzzle]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=705</guid>
		<description><![CDATA[Pada tulisan ini, saya akan menggunakan algoritma A* seperti pada tulisan sebelumnya.  Kali ini algoritma tersebut tidak dipakai untuk mencari jarak terpendek, melainkan untuk menyelesaikan sliding puzzle berukuran 3&#215;3.  Sliding puzzle adalah sebuah permainan puzzle dimana pemain harus menggeser kotak-kotak yang ada agar memenuhi konfigurasi tertentu.  Sebagai contoh, berikut ini adalah sliding puzzle 15 yang [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=705&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Pada tulisan ini, saya akan menggunakan algoritma A* seperti pada tulisan <a title="Pencarian Jarak Terpendek Dengan Algoritma A*" href="http://thesolidsnake.wordpress.com/2012/01/23/pencarian-jarak-terpendek-dengan-algoritma-a/" target="_blank">sebelumnya</a>.  Kali ini algoritma tersebut tidak dipakai untuk mencari jarak terpendek, melainkan untuk menyelesaikan sliding puzzle berukuran 3&#215;3. <strong> Sliding puzzle</strong> adalah sebuah permainan puzzle dimana pemain harus menggeser kotak-kotak yang ada agar memenuhi konfigurasi tertentu.  Sebagai contoh, berikut ini adalah sliding puzzle 15 yang telah berhasil diselesaikan:</p>
<div class="wp-caption aligncenter" style="width: 250px"><img class=" " title="15-puzzle" src="http://upload.wikimedia.org/wikipedia/commons/9/91/15-puzzle.svg" alt="15-puzzle" width="240" height="240" /><p class="wp-caption-text">15 Sliding Puzle</p></div>
<p>Tampilan awal program saya akan terlihat seperti:</p>
<div id="attachment_710" class="wp-caption aligncenter" style="width: 310px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/gambar11.jpg"><img class="size-medium wp-image-710" title="Tampilan Awal Program" src="http://thesolidsnake.files.wordpress.com/2012/01/gambar11.jpg?w=300&#038;h=273" alt="Tampilan Awal Program" width="300" height="273" /></a><p class="wp-caption-text">Tampilan Awal Program</p></div>
<p>Program akan menggunakan sebuah file gambar yang telah tersimpan di package <strong>co.id.jocki.gambar</strong> dengan nama <strong>gambar.jpg</strong>.  Gambar ini akan dibagi ke dalam kotak-kotak sejumlah 8 kotak ditambah 1 kotak kosong.  Posisi kotak-kotak tersebut kemudian diacak.  Begitu tombol &#8220;<strong>Solve</strong>&#8221; di-klik, program Java ini akan mencari solusi dengan langkah minimum, kemudian menampilkan solusi tersebut dalam bentuk animasi hingga mencapai output seperti berikut ini:</p>
<div id="attachment_711" class="wp-caption aligncenter" style="width: 310px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/gambar2.jpg"><img class="size-medium wp-image-711" title="Tampilan Akhir Program" src="http://thesolidsnake.files.wordpress.com/2012/01/gambar2.jpg?w=300&#038;h=274" alt="Tampilan Akhir Program" width="300" height="274" /></a><p class="wp-caption-text">Tampilan Akhir Program</p></div>
<p>UML Class Diagram untuk program yang saya buat adalah sebagai berikut:</p>
<div id="attachment_712" class="wp-caption aligncenter" style="width: 310px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/class_diagram.png"><img class="size-medium wp-image-712" title="UML Class Diagram" src="http://thesolidsnake.files.wordpress.com/2012/01/class_diagram.png?w=300&#038;h=118" alt="UML Class Diagram" width="300" height="118" /></a><p class="wp-caption-text">UML Class Diagram</p></div>
<p>Algoritma A* yang dipakai oleh program ini terdapat dalam class <strong>Algoritma</strong>.  Seperti yang diketahui, algoritma A* membutuhkan nilai fungsi <strong>g(x)</strong> dan fungsi <strong>h(x)</strong>.  Pada kode program, fungsi <strong>g(x)</strong> dihitung oleh method <strong>hitungNilaiG(PapanKotak p)</strong> dan fungsi <strong>h(x)</strong> dihitung oleh method <strong>hitungNilaiH(PapanKotak p)</strong>.</p>
<p>Nilai fungsi <strong>g(x)</strong> adalah berapa jumlah langkah yang dibutuhkan dari awal hingga mencapai <strong>PapanKotak</strong> dengan posisi masing-masing kotak seperti saat ini.  Karena program akan mencari penyelesaian sliding puzzle dengan langkah tersingkat, maka semakin kecil nilai fungsi <strong>g(x)</strong> akan semakin baik.  Setiap <strong>PapanKotak</strong> memiliki sebuah parent yang mewakili langkah sebelumnya (sebuah <strong>PapanKotak</strong> sebelum mencapai <strong>PapanKotak</strong> ini).  Dengan demikian, program dapat menghitung nilai fungsi <strong>g(x)</strong> dengan proses rekursif.</p>
<p>Nilai fungsi <strong>h(x)</strong> adalah sebuah perkiraan seberapa jauh puzzle mendekati penyelesaian.   Program ini akan menghitung nilai <strong>h(x)</strong> dengan memeriksa jumlah kotak yang berada di posisi yang salah.  Semakin banyak jumlah kotak yang berada di posisi yang salah, maka mungkin saja masih banyak langkah yang harus ditempuh.  Semakin sedikit jumlah kotak yang berada di posisi yang salah, maka mungkin saja puzzle sudah hampir mendekati penyelesaian.</p>
<p>Setiap PapanKotak yang akan diproses disimpan di sebuah priority queue.  Java telah menyediakan class <strong>java.util.PriorityQueue&lt;E&gt;</strong> yang dapat langsung dipakai.  Tentu saja, program harus membuat sebuah <strong>Comparator</strong> baru untuk memberitahu Java supaya setiap elemen di queue diurutkan berdasarkan nilai fungsi <strong>g(x)</strong> + <strong>h(x)</strong>.</p>
<p>Program akan melakukan proses berulang hingga menemukan sebuah <strong>PapanKotak</strong> di priority queue yang berisi solusi (angka 1 berurut hingga 8).  Untuk menemukan langkah-langkah yang dibutuhkan dari awal hingga mencapai <strong>PapanKotak</strong> solusi tersebut, program tinggal membaca parent (step sebelumnya yang juga diwakili sebuah <strong>PapanKotak)</strong> secara rekursif hingga kembali ke <strong>PapanKotak</strong> paling awal.</p>
<p>Kode program dapat di-download di link <a href="https://docs.google.com/open?id=0B-_rVDnaVRCbYTgwODNjOGQtMGQyNC00MTRmLWFhOWEtMjRhMjkxZGJlODU1" target="_blank">Google Docs berikut</a>.  Pastikan untuk men-klik tombol &#8220;<strong>Download Original</strong>&#8221; di kanan atas.  File zip tersebut merupakan sebuah direktori yang berisi project NetBeans.  Untuk menjalankan program tersebut dibutuhkan minimal JDK 7.  Bila memakai JDK sebelum versi 7, ganti setiap diamond operator yang ada ke cara lama.  Misalnya:</p>
<pre>PapanKotak lstHasil = new ArrayList&lt;&gt;();</pre>
<p>menjadi</p>
<pre>PapanKotak lstHasil = new ArrayList&lt;PapanKotak&gt;();</pre>
<p>Bagi yang ingin langsung menjalankan program tanpa source-code, file JAR dapat di-download di link <a href="https://docs.google.com/open?id=0B-_rVDnaVRCbOTBmMzZjNWItNzcwYi00YzE0LTk1NGEtMzZmNmEzZDkyMGFh" target="_blank">Google Docs ini</a>.</p>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/algoritma/'>Algoritma</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/a-star/'>A Star</a>, <a href='http://thesolidsnake.wordpress.com/tag/sliding-puzzle/'>Sliding Puzzle</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/705/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=705&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2012/01/28/menyelesaikan-sliding-puzzle-dengan-algoritma-a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/commons/9/91/15-puzzle.svg" medium="image">
			<media:title type="html">15-puzzle</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/gambar11.jpg?w=300" medium="image">
			<media:title type="html">Tampilan Awal Program</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/gambar2.jpg?w=300" medium="image">
			<media:title type="html">Tampilan Akhir Program</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/class_diagram.png?w=300" medium="image">
			<media:title type="html">UML Class Diagram</media:title>
		</media:content>
	</item>
		<item>
		<title>Pencarian Jarak Terpendek Dengan Algoritma A*</title>
		<link>http://thesolidsnake.wordpress.com/2012/01/23/pencarian-jarak-terpendek-dengan-algoritma-a/</link>
		<comments>http://thesolidsnake.wordpress.com/2012/01/23/pencarian-jarak-terpendek-dengan-algoritma-a/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 17:21:12 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[Algoritma]]></category>
		<category><![CDATA[A Star]]></category>
		<category><![CDATA[Pathfinding]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=700</guid>
		<description><![CDATA[~ Happy chinese new year ~ Malam ini penuh dengan semarak kembang api yang tidak berhenti dari tadi.  Maklum saja, beberapa menit lagi, tahun Kelinci akan berganti menjadi tahun Naga.  Sembari menikmati dentuman kembang api, saya menyempatkan diri untuk menulis mencurahkan isi hati.  Topik yang saya pilih kali ini adalah mengenai algoritma.  Banyak sekali software [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=700&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>~ <strong>Happy chinese new year</strong> ~ Malam ini penuh dengan semarak kembang api yang tidak berhenti dari tadi.  Maklum saja, beberapa menit lagi, tahun Kelinci akan berganti menjadi tahun Naga.  Sembari menikmati dentuman kembang api, saya menyempatkan diri untuk menulis mencurahkan isi hati.  Topik yang saya pilih kali ini adalah mengenai algoritma.  Banyak sekali software engineer yang terbiasa mengimplementasikan business logic, tapi tidak berkutik bila dihadapi dengan &#8216;soal-soal algoritma&#8217; (termasuk saya!).  Yang saya maksud &#8216;soal-soal algoritma&#8217; disini adalah persoalan dimana si programmer harus mencari jarak terpendek dari satu node ke node lainnya.</p>
<p>Sebagai contoh, saya mengambil gambar-gambar dari scenario Wombat dan ingin menghasilkan program seperti berikut ini:</p>
<div id="attachment_701" class="wp-caption aligncenter" style="width: 465px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/tampilan.jpg"><img class="size-full wp-image-701" title="Tampilan Hasil Akhir Program" src="http://thesolidsnake.files.wordpress.com/2012/01/tampilan.jpg?w=455&#038;h=527" alt="Tampilan Hasil Akhir Program" width="455" height="527" /></a><p class="wp-caption-text">Tampilan Hasil Akhir Program</p></div>
<p>Pada program tersebut, terdapat sebuah binatang Wombat, sebuah daun, dan batu-batu sebagai penghalang.  Wombat dapat berpindah-pindah dari satu kotak ke kotak lainnya, asalkan tidak dihalangi oleh batu.  Pertanyaannya adalah bagaimana supaya Wombat dapat mencari jalan untuk menuju ke daun dengan melewati jumlah kotak seminimal mungkin (mencari jarak terpendek)???</p>
<p>Salah satu cara untuk menyelesaikannya adalah dengan menggunakan <strong>algoritma A*</strong> (baca: A star).  Pada algoritma ini, setiap kotak yang mungkin akan dilalui oleh Wombat harus dihitung nilai cost-nya.  Nilai cost tersebut umumnya disebut fungsi <strong>f(x)</strong>.  Nilai f(x) merupakan penjumlahan dari fungsi g(x) dan fungsi h(x).  Secara matematika ditulis <strong>f(x) = g(x) + h(x)</strong>.</p>
<p>Nilai fungsi <strong>g(x)</strong> adalah nilai cost dari node awal hingga ke node yang saat ini akan dihitung cost-nya.</p>
<p>Nilai fungsi <strong>h(x)</strong> adalah sebuah nilai heuristic (sebuah perkiraan) yang menerka cost yang dibutuhkan untuk mencapai node tujuan mulai dari node yang saat ini akan dihitung cost-nya.</p>
<p>Saya akan membuat sebuah program Java sederhana, dengan class diagram seperti berikut ini:</p>
<div id="attachment_702" class="wp-caption aligncenter" style="width: 465px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/uml_class_diagram.png"><img class="size-full wp-image-702" title="UML Class Diagram" src="http://thesolidsnake.files.wordpress.com/2012/01/uml_class_diagram.png?w=455&#038;h=242" alt="UML Class Diagram" width="455" height="242" /></a><p class="wp-caption-text">UML Class Diagram</p></div>
<p>Implementasi algoritma A* dapat dilihat pada class <strong>Algoritma</strong>.  Project NetBeans yang berisi implementasi kode program yang ada dapat di-download di <a href="https://docs.google.com/open?id=0B-_rVDnaVRCbMzhhNTE2OTQtODNiMS00Zjk3LTlhNWItYWY3NzBjYzliNjE4" target="_blank">sini</a>.  Source code pada project tersebut sudah diberi dokumentasi sehingga dapat dipelajari dengan mudah.  Saya membuat kode program dengan menggunakan NetBeans 7.1.  Selain itu, agar program dapat di-compile, gunakan minimal Java 7, karena saya menggunakan <em>diamond operator</em> yang hanya ada sejak Java 7.  Untuk men-download JAR program tanpa perlu men-download source, silahkan klik di <a href="https://docs.google.com/open?id=0B-_rVDnaVRCbZTQ0ZDIwM2QtNzE5NS00NWZiLWI4NDEtOTFmZDQwYjNmZmEy" target="_blank">sini</a>.</p>
<p>Jam 00.00 telah berlalu.  Dentuman kembang api pun mereda.  Dan sungguh kebetulan, hujan ikut turun membahasi bumi.  Malam pun kembali sepi dan dingin..</p>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/algoritma/'>Algoritma</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/a-star/'>A Star</a>, <a href='http://thesolidsnake.wordpress.com/tag/pathfinding/'>Pathfinding</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/700/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/700/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/700/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=700&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2012/01/23/pencarian-jarak-terpendek-dengan-algoritma-a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/tampilan.jpg" medium="image">
			<media:title type="html">Tampilan Hasil Akhir Program</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/uml_class_diagram.png" medium="image">
			<media:title type="html">UML Class Diagram</media:title>
		</media:content>
	</item>
		<item>
		<title>Memanggil DLL dari PHP</title>
		<link>http://thesolidsnake.wordpress.com/2012/01/14/memanggil-dll-dari-php/</link>
		<comments>http://thesolidsnake.wordpress.com/2012/01/14/memanggil-dll-dari-php/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 18:08:36 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[PHP Framework & API]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Active Template Library]]></category>
		<category><![CDATA[Component Object Model]]></category>
		<category><![CDATA[Dynamic-link Library]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=689</guid>
		<description><![CDATA[Pada suatu hari, seorang mahasiswa yang sedang menyusun skripsi menanyakan pada saya apakah mungkin mengakses DLL dari kode program PHP.  Sebuah pertanyaan yang tidak terduga, karena saya sama sekali tidak pernah dan tidak berpikiran untuk melakukan hal tersebut.  Hal ini karena PHP adalah bahasa pemograman yang berada di banyak platform, gratis, dan sangat populer di [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=689&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Pada suatu hari, seorang mahasiswa yang sedang menyusun skripsi menanyakan pada saya apakah mungkin mengakses <strong>DLL</strong> dari kode program <strong>PHP</strong>.  Sebuah pertanyaan yang tidak terduga, karena saya sama sekali tidak pernah dan tidak berpikiran untuk melakukan hal tersebut.  Hal ini karena <strong>PHP</strong> adalah bahasa pemograman yang berada di banyak platform, gratis, dan sangat populer di <em><strong>Linux</strong></em>.  Sementara teknologi <strong>DLL</strong> adalah teknologi yang sangat terikat pada <em><strong>Microsoft Windows</strong></em> serta Visual Studio-nya.  Menurut saya, pertanyaan &#8216;<em>membaca DLL</em>&#8216; akan lebih selaras bila dipadukan dengan teknologi <strong>ASP.NET</strong> dengan bahasa C# ataupun VB, dibandingkan dengan PHP.</p>
<p>Kembali ke pertanyaan semula, apakah mungkin memanggil DLL dari PHP? Setelah melakukan pencarian di PHP Manual, saya menemukan bagian <strong>COM and .Net (Windows)</strong> yang dapat diakses di <a href="www.php.net/manual/en/book.com.php" target="_blank">www.php.net/manual/en/book.com.php</a>.  PHP memang mendukung <strong>Component Object Model (COM)</strong> dan<strong> .NET</strong>.  Lalu apa hubungan <strong>COM</strong> dan <strong>DLL</strong>?</p>
<ul>
<li><strong>DLL (Dynamic-link Library)</strong> adalah implementasi <em>shared-library</em> di platform Windows.  Programmer membuat fungsi yang dapat dipanggil ulang di program berbeda.</li>
<li><strong>COM (Component Object Model)</strong> adalah sebuah metodologi yang mengatur bagaimana menerapkan komponen program yang dapat dipakai ulang di program berbeda.</li>
<li><strong>COM</strong> tidak mengatur struktur bahasa yang dipakai (menurut referensi MSDN, COM sering salah kaprah diangagp sebagai OOP).</li>
<li>Implementasi <strong>COM</strong> umumnya dalam bentuk file <strong>DLL</strong>.</li>
<li>Tidak semua <strong>DLL</strong> dibuat berdasarkan aturan <strong>COM</strong>, atau dengan kata lain tidak semua <strong>DLL</strong> adalah <strong>COM</strong>.</li>
</ul>
<p>Jadi  jawaban untuk mahasiswa tersebut adalah: bila <strong>DLL</strong> dibuat dengan menggunakan teknologi <strong>COM</strong>, maka <strong>DLL</strong> tersebut dapat diakses di <strong>PHP</strong>.  Bila DLL tersebut adalah DLL sederhana, maka DLL tersebut tidak dapat diakses di PHP.</p>
<p>Lalu bagaimana bila ingin tetap mengakses DLL sederhana di PHP?  Ada sebuah extension PHP yang dikhususkan untuk Windows yang bernama <a href="http://winbinder.org" target="_blank"><strong>WinBinder</strong></a>.  Dengan <a href="http://winbinder.org" target="_blank">WinBinder</a>, programmer PHP dapat memanggil semua APIs Windows dengan PHP, membuat program GUI berbasis PHP, bahkan memanggil DLL sederhana (tanpa COM) dengan PHP.</p>
<p>Pada artikel ini, saya akan menggunakan teknologi sebagai berikut:</p>
<ul>
<li><strong>Visual C++</strong> di <strong>Visual Studio 2010</strong> untuk menghasilkan <strong>DLL</strong> yang mengikuti spesifikasi <strong>COM</strong>.</li>
<li>Memakai <strong>ATL (Active Template Library)</strong> di <strong>Visual C++</strong> untuk membuat <strong>COM</strong>.  <strong>ATL</strong> <span style="text-decoration:underline;"><strong>bukan</strong></span> bagian dari <strong>COM</strong> ataupun bahasa <strong>C++</strong> melainkan sebuah framework sebagai bagian dari <strong>Visual C++</strong> untuk mempermudah pembuatan COM.</li>
<li><strong>PHP</strong> untuk mengakses <strong>DLL</strong> yang dihasilkan oleh <strong>Visual C++</strong></li>
</ul>
<p>Untuk membuat COM di Visual C++ dengan bantuan ATL, pilih menu<strong> File</strong>, <strong>New</strong>, <strong>Project</strong> di Visual Studio 2010.  Kemudian pada <strong>Visual C++</strong>, pilih <strong>ATL Project</strong>.  Beri nama pada project tersebut, misalnya LatihanCOM.  Tentukan juga lokasi folder untuk penyimpanan project tersebut.  Kemudian klik tombol <strong>OK</strong>.</p>
<div id="attachment_690" class="wp-caption aligncenter" style="width: 465px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/gambar1.jpg"><img class="size-full wp-image-690" title="Membuat Project ATL Baru" src="http://thesolidsnake.files.wordpress.com/2012/01/gambar1.jpg?w=455&#038;h=346" alt="Membuat Project ATL Baru" width="455" height="346" /></a><p class="wp-caption-text">Membuat Project ATL Baru</p></div>
<p>Akan muncul ATL Project Wizard yang terdiri atas dua langkah.  Klik tombol <strong>Next</strong> pada wizard tersebut.  Pastikan pada <strong>Application Type</strong>, pilihan <strong>Dynamic-link library (DLL)</strong> terpilih.  Kemudian klik tombol <strong>Finish</strong> untuk membuat project.</p>
<div id="attachment_691" class="wp-caption aligncenter" style="width: 465px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/gambar2.png"><img class="size-full wp-image-691" title="ATL Project Wizard" src="http://thesolidsnake.files.wordpress.com/2012/01/gambar2.png?w=455&#038;h=181" alt="ATL Project Wizard" width="455" height="181" /></a><p class="wp-caption-text">ATL Project Wizard</p></div>
<p>Setelah project selesai dibuat, buka panel <strong>Class View</strong>.  Bila panel ini tertutup, pilih menu <strong>View</strong>, <strong>Class View (Ctrl+Shift+C)</strong> untuk menampilkannya.  Klik kanan pada nama project, <em>LatihanCOM</em>, kemudian pilih <strong>Add</strong>, <strong>Class&#8230;</strong>  Pada window <strong>Add Class</strong> yang muncul, pilih <strong>ATL Simple Object</strong>.  Kemudian klik tombol <strong>Add</strong> untuk melanjutkan.</p>
<div id="attachment_692" class="wp-caption aligncenter" style="width: 465px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/gambar3.jpg"><img class="size-full wp-image-692" title="Tampilan Dialog Add Class" src="http://thesolidsnake.files.wordpress.com/2012/01/gambar3.jpg?w=455&#038;h=149" alt="Tampilan Dialog Add Class" width="455" height="149" /></a><p class="wp-caption-text">Tampilan Dialog Add Class</p></div>
<p>Pada tampilan <strong>ATL Simple Object Wizard</strong> yang muncul, ketik nama <strong>Perhitungan</strong> di <strong>Short name</strong>.  Nama lain akan di-isi secara otomatis.  Pastikan bahwa di bagian <strong>COM</strong>, nama <strong>Interface</strong> adalah <strong>IPerhitungan</strong>.  Kemudian isi <strong>ProgID</strong> dengan nama <strong>Jocki.Perhitungan</strong>.  Window tersebut harus terlihat seperti berikut ini:</p>
<div id="attachment_693" class="wp-caption aligncenter" style="width: 465px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/gambar4.jpg"><img class="size-full wp-image-693" title="ATL Simple Object Wizard" src="http://thesolidsnake.files.wordpress.com/2012/01/gambar4.jpg?w=455&#038;h=245" alt="ATL Simple Object Wizard" width="455" height="245" /></a><p class="wp-caption-text">ATL Simple Object Wizard</p></div>
<p>Klik tombol <strong>Finish</strong> untuk menyelesaikan wizard.</p>
<p>Buka panel <strong>Class View</strong> dan cari COM Interface yang bernama <strong>IPerhitungan</strong>.  Interface ini dibuat secara otomatis oleh Visual C++ sehingga yang perlu kita lakukan hanya menambahkan <strong>method</strong> yang akan dipanggil oleh program lain.  Klik kanan pada <strong>IPerhitungan</strong>, kemudian pilih <strong>Add</strong>, <strong>Add Method&#8230;</strong></p>
<div id="attachment_694" class="wp-caption aligncenter" style="width: 465px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/gambar5.png"><img class="size-full wp-image-694" title="Menambah Method Pada COM Interface" src="http://thesolidsnake.files.wordpress.com/2012/01/gambar5.png?w=455&#038;h=323" alt="Menambah Method Pada COM Interface" width="455" height="323" /></a><p class="wp-caption-text">Menambah Method Pada COM Interface</p></div>
<p>Pada dialog <strong>Add Method Wizard</strong> yang muncul, kita akan membuat sebuah method sederhana.  Method ini akan menerima parameter berupa dua buah bilangan bulat, kemudian mengembalikan hasil jumlah dua bilangan tersebut.  Pada method name, beri nama <strong>HitungJumlah</strong>.  Kemudian tambahkan dua parameter input dengan mengikuti langkah ini:</p>
<ol>
<li>Beri centang pada checkbox <strong>in</strong> di <strong>Parameter attributes</strong>.</li>
<li>Ketik <strong>int</strong> di <strong>Parameter type</strong>.</li>
<li>Ketik <strong>nilai1</strong> di <strong>Parameter name</strong>.</li>
<li>Klik tombol <strong>Add</strong>.</li>
<li>Beri centang pada checkbox <strong>in</strong> di <strong>Parameter attributes</strong>.</li>
<li>Ketik <strong>int</strong> di Parameter type.</li>
<li>Ketik <strong>nilai2</strong> di Parameter name.</li>
<li>Klik tombol <strong>Add</strong>.</li>
</ol>
<p>Setelah menambahkan parameter, tambahkan nilai kembalian dengan mengikuti langkah ini:</p>
<ol>
<li>Ketik <strong>int</strong>* di Parameter type.  Jangan lupa menambahkan<strong> *</strong> setelah <strong>int</strong> karena variabel ini akan merujuk ke hasil kembalian (pointer).  Bila tidak ada <strong>*</strong> setelah <strong>int</strong>, wizard tidak akan memberikan pilihan untuk mencentang checkbox <strong>out</strong> dan <strong>retval</strong> di langkah berikutnya.</li>
<li>Beri tanda centang checkbox <strong>out</strong> dan checkbox <strong>retval</strong>.</li>
<li>Ketik <strong>hasil</strong> pada <strong>Parameter name</strong>.</li>
<li>Klik tombol <strong>Add</strong>.</li>
</ol>
<p>Tampilan wizard akan terlihat seperti berikut ini:</p>
<div id="attachment_696" class="wp-caption aligncenter" style="width: 465px"><a href="http://thesolidsnake.files.wordpress.com/2012/01/capture.jpg"><img class="size-full wp-image-696" title="Tampilan Add Method Wizard" src="http://thesolidsnake.files.wordpress.com/2012/01/capture.jpg?w=455&#038;h=161" alt="Tampilan Add Method Wizard" width="455" height="161" /></a><p class="wp-caption-text">Tampilan Add Method Wizard</p></div>
<p>Klik tombol <strong>Finish</strong> untuk menyelesaikan wizard.</p>
<p>Cari baris kode program seperti berikut ini di file <strong>Perhitungan.cpp</strong>:</p>
<pre>STDMETHODIMP CPerhitungan::HitungJumlah(int nilai1, int nilai2, int* hasil)
{
// TODO: Add your implementation code here

return S_OK;
}</pre>
<p>Kode program ini merupakan implementasi dari method yang akan dipanggil oleh PHP nantinya.  Ganti baris yang diawali dengan<strong> //TODO</strong> sehingga kode programnya akan terlihat seperti berikut ini:</p>
<pre>STDMETHODIMP CPerhitungan::HitungJumlah(int nilai1, int nilai2, int* hasil)
{<strong> *hasil = nilai1 + nilai2;</strong>

return S_OK;
}</pre>
<p>Langkah terakhir sebelum menghasilkan DLL adalah melakukan sedikit perubahan pada settingan project.  Buka panel <strong>Solution Explorer</strong>.  Bila panel ini tertutup, pilih menu <strong>View</strong>, <strong>Solution Explorer (Ctrl+Alt+L)</strong>.  Klik kanan pada nama project, <strong>LatihanCOM</strong>, kemudian pilih <strong>Properties</strong>.  Pada baris <strong>Per-user Redirection</strong>, ganti nilai <strong>No</strong> menjadi <strong>Yes</strong>.  Hal ini dilakukan untuk menghindari hal-hal yang berkaitan dengan masalah hak akses user.  Dengan mengaktifkan <strong>Per-user Redirection</strong>, DLL yang dihasilkan hanya akan tersedia oleh user Windows yang sedang aktif saat ini saja.</p>
<p>Untuk membuat <strong>DLL</strong>, pilih menu <strong>Build</strong>, <strong>Build Solution (Ctrl+Shift+B)</strong>.  File DLL yang dihasilkan terletak di folder Debug di lokasi penyimpanan project.  Sebagai contoh, jika saya menyimpan project di Desktop, maka file DLL yang dihasilkan adalah <strong>C:\Users\JockiHendry\Desktop\LatihanCOM\Debug\LatihanCOM.dll</strong>.  Visual C++ 2010 telah melakukan registrasi DLL secara otomatis sehingga kita tidak perlu repot-repot lagi.</p>
<p>Sekarang, kita akan melakukan pengujian apakah DLL tersebut dapat dipanggil dengan baik.  Buat sebuah file PHP dengan isi seperti berikut ini:</p>
<pre>&lt;?php
   $perhitungan = new COM("Jocki.Perhitungan");
   $hasil = $perhitungan-&gt;HitungJumlah(11,22);
   print "Hasil dari method di COM DLL adalah $hasil";
?&gt;</pre>
<p>Bila kode program PHP di atas dijalankan, hasilnya adalah:</p>
<pre>Hasil dari method di COM DLL adalah 33</pre>
<p>Apa langkah berikutnya?</p>
<ul>
<li>Ingin memanggil COM yang berada di komputer lain?  Pelajari <strong>Distributed COM (DCOM)</strong> lebih lanjut.</li>
<li>Tidak ingin memakai teknologi COM melainkan ingin memakai simple DLL?  Lihat solusi yang ditawarkan oleh <a href="http://winbinder.org" target="_blank">Winbinder</a>.</li>
<li>Walaupun Microsoft tidak menghentikan dukungan atas COM, teknologi tersebut sudah kadaluarsa dan kini digantikan oleh penerusnya.  Ingin beralih ke .NET?  Pelajari lebih lanjut tentang <strong>.NET Component</strong>.</li>
</ul>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/php/php-framework-api/'>PHP Framework &amp; API</a>, <a href='http://thesolidsnake.wordpress.com/category/net-technology/visual-studio/'>Visual Studio</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/active-template-library/'>Active Template Library</a>, <a href='http://thesolidsnake.wordpress.com/tag/component-object-model/'>Component Object Model</a>, <a href='http://thesolidsnake.wordpress.com/tag/dynamic-link-library/'>Dynamic-link Library</a>, <a href='http://thesolidsnake.wordpress.com/tag/visual-c/'>Visual C++</a>, <a href='http://thesolidsnake.wordpress.com/tag/visual-studio-2010/'>Visual Studio 2010</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/689/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/689/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/689/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/689/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/689/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/689/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/689/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/689/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/689/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/689/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/689/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/689/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/689/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/689/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=689&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2012/01/14/memanggil-dll-dari-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/gambar1.jpg" medium="image">
			<media:title type="html">Membuat Project ATL Baru</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/gambar2.png" medium="image">
			<media:title type="html">ATL Project Wizard</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/gambar3.jpg" medium="image">
			<media:title type="html">Tampilan Dialog Add Class</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/gambar4.jpg" medium="image">
			<media:title type="html">ATL Simple Object Wizard</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/gambar5.png" medium="image">
			<media:title type="html">Menambah Method Pada COM Interface</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2012/01/capture.jpg" medium="image">
			<media:title type="html">Tampilan Add Method Wizard</media:title>
		</media:content>
	</item>
		<item>
		<title>Membuat bootstrap loader untuk UFD</title>
		<link>http://thesolidsnake.wordpress.com/2011/11/25/membuat-bootstrap-loader-untuk-ufd/</link>
		<comments>http://thesolidsnake.wordpress.com/2011/11/25/membuat-bootstrap-loader-untuk-ufd/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 16:43:31 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[Assembly]]></category>
		<category><![CDATA[bootstrap loader]]></category>
		<category><![CDATA[FAT32]]></category>
		<category><![CDATA[NASM]]></category>
		<category><![CDATA[real mode]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=685</guid>
		<description><![CDATA[Pada beberapa mata kuliah seperti sistem operasi dan sistem berkas, dosen mungkin harus mendemokan beberapa komponen low-level yang tidak tersedia pada sistem operasi modern.  Seperti yang diketahui, seluruh sistem operasi modern zaman sekarang beroperasi pada CPU protected mode.  Hal ini berarti hanya kode program saja yang berada di ring 0, sementara kode program yang dibuat [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=685&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Pada beberapa mata kuliah seperti sistem operasi dan sistem berkas, dosen mungkin harus mendemokan beberapa komponen low-level yang tidak tersedia pada sistem operasi modern.  Seperti yang diketahui, seluruh sistem operasi modern zaman sekarang beroperasi pada CPU <strong>protected mode</strong>.  Hal ini berarti hanya kode program saja yang berada di ring 0, sementara kode program yang dibuat user tidak akan mendapatkan akses ring 0 (kecuali bila diizinkan oleh sistem operasi).  Beberapa instruksi assembly seperti <strong>IN</strong>, <strong>OUT</strong>, dan beberapa <strong>INT</strong> umumnya dibatasi oleh sistem operasi.  Sebagai contoh, Windows akan menolak instruksi IN/OUT pada program user mode tetapi mengizinkannya pada driver.  Sementara di Linux, IN/OUT diperbolehkan bila sebelumnya terdapat pemanggilan <strong>ioperm()</strong> dan program di-akses dengan hak akses superuser.</p>
<p>Bagaimana bila seseorang ingin tetap menjalankan programnya di CPU <strong>real-mode</strong>?  Ia harus membuat sistem operasi sendiri!  Atau untuk sebuah eksperimen sederhana, ia dapat membuat sebuah <strong>bootstrap loader</strong> yang akan menjalankan sebuah program <strong>real mode</strong> begitu komputer dinyalakan!  Dan untuk eksperimen seperti ini, media <strong>UFD (USB Flash Drive)</strong> adalah pilihan yang tepat.  Kebanyakan BIOS di motherboard zaman sekarang sudah mendukung emulasi disk untuk <strong>UFD</strong>, sehingga mendukung proses boot dari <strong>UFD</strong>.</p>
<p>Ini adalah percobaan yang saya lakukan dengan menggunakan sebuah UFD berukuran 4 GB yang menggunakan file system <strong>FAT32</strong>.  UFD tersebut hanya mengandung sebuah partisi.  Saya menyalin <strong>boot sector</strong> dari partisi pertama.  Struktur boot sector untuk FAT32 dapat dilihat di <a href="http://en.wikipedia.org/wiki/FAT32" target="_blank">http://en.wikipedia.org/wiki/FAT32</a>.  Berikut ini kode program assembly (dalam <strong>NASM</strong>) yang membentuk<strong> boot sector</strong> di UFD saya beserta dengan <strong>bootstrap loader</strong> buatan sendiri:</p>
<pre>[BITS 16]
[ORG 0x7C00]

	jmp	mulai
	nop

	; ------------------------------------------------------
	; Informasi Boot Sector
	; ------------------------------------------------------

	db 'SOS-JCH '					; OEM name
	db 00, 0x2					; Bytes per sector
	db 0x8						; Sector per cluster
	db 0x20, 00					; Reserved sector count
	db 0x2						; Number of FAT
	db 00, 00, 00,00
	db 0xF8						; Media descriptor (F8 = Fixed disk)
	db 00, 00
	db 0x3E, 00					; Sectors per track
	db 0x7C, 00					; Number of heads
	db 00, 00, 00, 00				; Count of hidden sectors
	db 0xA2, 0xA7, 0x77, 00				; Total sectors
	db 0xDB, 0x1D, 00, 00				; Sectors per FAT
	db 00, 00					; Mirroring flags
	db 00, 00					; Version
	db 0x02, 00, 00, 00				; Cluster number of root directory start
	db 0x01, 00					; Sector number of FS Information Sector
	db 0x06, 00					; First sector number of a copy of three FAT32 boot sectors
	db 00, 00, 00, 00
	db 00, 00, 00, 00
	db 00, 00, 00, 00
	db 00, 00
	db 0x29						; Extended boot signature
	db 0xA5, 0x82, 0x1D, 0x86			; Volume ID
	db 'Latihan    '				; Volume Label
	db 'FAT32   '					; File system type

	; ------------------------------------------------------
	; Starting point
	; ------------------------------------------------------
mulai:

	; ------------------------------------------------------
	; Inisialisasi
    	; ------------------------------------------------------
	cli
	xor ax, ax
	mov ss, ax
	mov sp, 0x7C00
	mov ds, ax
	mov es, ax
	sti

	; ------------------------------------------------------
	; Menyalin FAT dan menyimpannya ke lokasi offset 0x7E00
	; ------------------------------------------------------ 

	mov word [ds:dap_jumlah_sector], 1
	mov word [ds:dap_dest_segment], ds
 	mov word [ds:dap_dest_offset], 0x7E00
	mov dword [ds:dap_lba_lo], 94 

	call bacasector

	mov eax, [0x7E08]
	mov [fat_next_cluster], eax

	; ------------------------------------------------------
	; Menyalin RootDirectoryEntry ke lokasi offset 0x8000
	; ------------------------------------------------------
	mov word [ds:dap_jumlah_sector], 8
 	mov word [ds:dap_dest_offset], 0x8000
	mov dword [ds:dap_lba_lo], 0x3C14
	call bacasector

	; ------------------------------------------------------
	; Mencari File Dengan Nama KERNEL.BIN
	; ------------------------------------------------------
proses_cluster_berikutnya:

	mov si, 0x8000

pencarian_file_kernel:

	push si
	lea di,	[nama_file_kernel]
	cld
	mov cx, 11
	repe cmpsb
	jz file_kernel_ditemukan

	;
	; File kernel tidak ditemukan pada entry ini.
  	; Lanjut ke entry direktori berikutnya.
	;

	pop si
	add si, 32
	cmp si, 0x9000
	jbe pencarian_file_kernel

	;
	; File kernel tidak ditemukan di cluster ini
	; Periksa apakah masih ada cluster berikutnya.
	;

	mov eax, [fat_next_cluster]
	and eax, 0x0ffffff0
	cmp eax, 0x0ffffff0
	jz hang

	mov di, 0x8000
	call bacacluster
	call bacafat32

	jmp proses_cluster_berikutnya

file_kernel_ditemukan:

	;------------------------------------------------------------
	; Baca File Kernel dan Salin Di Lokasi Memori 0x8000
	;------------------------------------------------------------
	pop si
	mov ax, word [si+0x14]
	shl eax, 16
	mov ax, [si+0x1A]
	mov [fat_next_cluster], eax
	mov di, 0x8000

baca_cluster_kernel_berikutnya:
	call bacacluster
	call bacafat32
	mov eax, [fat_next_cluster]
	and eax, 0x0ffffff0
	cmp eax, 0x0ffffff0
	jz start_kernel

	add di, 0x1000
	mov eax, [fat_next_cluster]
	jmp baca_cluster_kernel_berikutnya

	;------------------------------------------------------------
	; Mulai eksekusi kernel
	;------------------------------------------------------------
start_kernel:
	jmp 0x8000

hang:
	jmp hang

bacafat32:
	;
	; Baca sebuah sektor FAT32 ke lokasi 0x7E00
	; Perhitungan berdasarkan nilai memori [fat_next_cluster]
	;

	; Mengisi fat_next_cluster dengan nilai
	; entry fat berikutnya
	; Rumus: sector = 62 + 32 + fat_next_cluster / 128
	;	 offset = (fat_next_cluster % 128 ) * 4

	xor eax, eax
	xor edx, edx
	mov ax, [fat_next_cluster]
	mov dx, [fat_next_cluster+2]
	mov cx, 128
	div cx 

	push dx  	; remainder, untuk offset nanti

	add eax, 94;
	mov word [ds:dap_jumlah_sector], 1
	mov word [ds:dap_dest_offset], 0x7E00
	mov dword [ds:dap_lba_hi], 0
	mov dword [ds:dap_lba_lo], eax
	call bacasector

	pop dx
	shl dx, 2
	add edx, 0x7E00
	mov ecx, [edx]
	mov [fat_next_cluster], ecx

	ret

bacacluster:
	;
	; Baca cluster data berikutnya.
	; eax = nomor cluster
	;  di = offset tujuan
	; Rumus menghitung sector dari cluster:
	;  s = 62 + 15318 + ((c-2)*8)
	;
	dec eax
	dec eax
	mov ecx, 8
	mul ecx
	xor ecx, ecx
	add eax, 15380
	adc edx, ecx
	mov dword [ds:dap_lba_hi], edx
	mov dword [ds:dap_lba_lo], eax
	mov word [ds:dap_jumlah_sector], 8
 	mov word [ds:dap_dest_offset], di
	call bacasector
	ret

bacasector:
	mov ah, 0x42
	mov dl, 0x80
	mov si, dap
	int 0x13
	ret

dap			db	0x10, 0x00
dap_jumlah_sector	dw	0x0001
dap_dest_offset		dw	0x0000
dap_dest_segment	dw	0x007C
dap_lba_lo		dd	0x00000000
dap_lba_hi		dd	0x00000000

pesan_salah_fat32	db	'Kernel tidak ditemukan.',0
nama_file_kernel	db	'KERNEL  BIN'
fat_next_cluster	dd	0x00000000

times 510-($-$$) db 0
dw 0xAA55</pre>
<p>Directive <strong>[BITS 16]</strong> memberi tahu NASM bahwa output dari assembly ini adalah kode program <strong>real mode</strong> 16-bit.  Pada saat BIOS selesai menyalin boot sector, ia akan memindahkan IP pada 0x7C00 sehingga instruksi yang akan dikerjakan adalah 0x7C00.  Itu sebabnya terdapat directive <strong>[ORG 0x7C00]</strong>.</p>
<p>Assembly di atas jauh dari sederhana, sehingga masih banyak perbaikan yang dapat dilakukan.  Salah satunya adalah saya menganggap <strong>1 cluster</strong> terdiri atas <strong>8 sector</strong> dan <strong>1 sector</strong> terdiri atas <strong>512 bytes</strong>.  Hal ini berlaku pada UFD saya, tetapi mungkin berbeda pada UFD yang di-format secara berbeda.  Selain itu, saya menganggap sector yang menampung informasi <strong>Root Directory</strong> dimulai dari lokasi sector ke <strong>15.318</strong>.  Saya juga menganggap jarak dari <strong>MBR</strong> ke <strong>boot sector</strong> adalah <strong>62</strong> sector.  Kode assembly yang lebih baik akan menyertakan proses perhitungan (berdasarkan informasi field di boot sector) sehingga bootstrap loader menjadi fleksibel.</p>
<p>Kode assembly yang ada pada dasarnya akan memeriksa linked list di FAT32 dan membaca seluruh cluster yang berisi informasi <strong>Root Directory</strong>.  Bootstrap loader akan mencari file bernama <strong>KERNEL.BIN</strong>.  Bila file ini ketemu, isi dari file tersebut akan disalin ke lokasi memori 0&#215;8000, dan eksekusi akan dilanjutkan pada lokasi memori tersebut.</p>
<p>Kode assembly di atas dapat diproses menjadi sebuah boot sector dengan menggunakan NASM:<br />
<code><br />
nasm -o boot.bin boot.asm<br />
</code><br />
Output dari perintah di atas adalah sebuah file berukuran 512 bytes dan diakhir dengan 0x55AA.  Semuanya memenuhi persyaratan sebuah boot sector.  Langkah berikutnya adalah men-copy file tersebut ke boot sector partisi pertama di UFD.  Hal ini dapat dilakukan dengan perintah dd di Linux:<br />
<code><br />
$ sudo dd if=boot.bin of=/dev/sdb1 bs=512 count=1<br />
</code><br />
Sebelum mulai restart komputer dan mengatur prioritas boot device di BIOS, pastikan terlebih dahulu bahwa <strong>boot flag</strong> pada partisi /dev/sdb1 telah di-set menjadi true.  Untuk mengatur flag tersebut, seseorang bisa menggunakan perintah <strong>fdisk</strong> di Linux.</p>
<p>Sekarang, pada saat ingin mencoba kode program <strong>real mode</strong>, seorang programmer assembly hanya perlu menyimpan program tersebut dengan nama <strong>KERNEL.BIN</strong>.  Setelah itu, copy file KERNEL.BIN ke root directory flash disk.  Kini, setiap kali komputer di-boot melalui flash disk, file KERNEL.BIN akan dikerjakan.</p>
<p>Perlu diingat bahwa program real-mode memiliki memori yang terbatas.  Akses memori hanya dibatasi pada range 1 MB (bila gate A20 aktif, menjadi 1.114.096 bytes).  Area memori ini sudah termasuk yang dipakai untuk Interrupt Descriptor Table (IDT), buffer I/O, dsb sehingga yang tersedia bagi program lebih sedikit lagi.   Untuk memakai memori lebih dari 1 MB, programmer harus beralih ke <strong>protected mode</strong> (itu sebabnya semua sistem operasi modern bekerja pada protected mode).</p>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/computer-hardware/assembly/'>Assembly</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/bootstrap-loader/'>bootstrap loader</a>, <a href='http://thesolidsnake.wordpress.com/tag/fat32/'>FAT32</a>, <a href='http://thesolidsnake.wordpress.com/tag/nasm/'>NASM</a>, <a href='http://thesolidsnake.wordpress.com/tag/real-mode/'>real mode</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/685/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/685/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/685/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=685&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2011/11/25/membuat-bootstrap-loader-untuk-ufd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>
	</item>
		<item>
		<title>Menghindari Google Dengan robots.txt</title>
		<link>http://thesolidsnake.wordpress.com/2011/11/20/menghindari-google-dengan-robots-txt/</link>
		<comments>http://thesolidsnake.wordpress.com/2011/11/20/menghindari-google-dengan-robots-txt/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 06:35:52 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[robots.txt]]></category>
		<category><![CDATA[web crawler]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=682</guid>
		<description><![CDATA[Google sangat bermanfaat bagi banyak orang, memudahkan orang untuk menemukan situs yang dibutuhkannya secara cepat.  Akan tetapi, ada kalanya Google bisa jadi berbahaya, terutama bagi pemilik situs.  Setiap harinya, program komputer yang disebut Web crawler atau Web robots akan mengunjungi halaman-halaman yang ada di web.  Program pintar tersebut akan membaca isi HTML, mencari hyperlink dalam [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=682&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Google sangat bermanfaat bagi banyak orang, memudahkan orang untuk menemukan situs yang dibutuhkannya secara cepat.  Akan tetapi, ada kalanya Google bisa jadi berbahaya, terutama bagi pemilik situs.  Setiap harinya, program komputer yang disebut Web crawler atau Web robots akan mengunjungi halaman-halaman yang ada di web.  Program pintar tersebut akan membaca isi HTML, mencari hyperlink dalam HTML, lalu mengunjungi setiap HTML yang ada dalam hyperlink, dan seterusnya..  Halaman-halaman yang telah dibacanya akan disimpan dalam bentuk index.  Dan index inilah yang  dipakai bila seseorang melakukan pencarian nantinya.</p>
<p>Bagaimana bila ada halaman tertentu yang tidak penting tetapi ikut ter-index?  Atau ada halaman yang bisa di-akses secara publik, tetapi tidak ingin dipublikasikan di Google?</p>
<p>Salah satu cara yang dapat dilakukan adalah dengan membuat file <strong>robots.txt</strong> di folder root dari situs.  File ini harus dapat diakses dengan link seperti <strong>www.domain.com/robots.txt</strong></p>
<p>Sebagai contoh, isi file <a title="Robots untuk www.facebook.com" href="http://www.facebook.com/robots.txt" target="_blank">www.facebook.com/robots.txt</a> adalah:</p>
<pre># Notice: if you would like to crawl Facebook you can
# contact us here: http://www.facebook.com/apps/site_scraping_tos.php
# to apply for white listing. Our general terms are available
# at http://www.facebook.com/apps/site_scraping_tos_terms.php

User-agent: baiduspider
Disallow: /ac.php
Disallow: /ae.php
Disallow: /album.php
Disallow: /ap.php
Disallow: /feeds/
Disallow: /l.php
Disallow: /o.php
Disallow: /p.php
Disallow: /photo.php
Disallow: /photo_comments.php
Disallow: /photo_search.php
Disallow: /photos.php

User-agent: Googlebot
Disallow: /ac.php
Disallow: /ae.php
Disallow: /album.php
Disallow: /ap.php
Disallow: /feeds/
Disallow: /l.php
Disallow: /o.php
Disallow: /p.php
Disallow: /photo.php
Disallow: /photo_comments.php
Disallow: /photo_search.php
Disallow: /photos.php

User-agent: msnbot
Disallow: /ac.php
Disallow: /ae.php
Disallow: /album.php
Disallow: /ap.php
Disallow: /feeds/
Disallow: /l.php
Disallow: /o.php
Disallow: /p.php
Disallow: /photo.php
Disallow: /photo_comments.php
Disallow: /photo_search.php
Disallow: /photos.php

... (bagian selanjutnya tidak ditampilkan)</pre>
<p>Dengan demikian, setiap kali web crawler dari Baidu, Google, dan MSN (serta lainnya yang tidak ditampilkan di atas) mengunjungi situs, mereka tidak akan mengakses bagian dalam <strong>Disallow</strong> seperti <strong>/photo.php</strong>, <strong>/album.php</strong>, <strong>/feeds</strong> dan sebagainya.</p>
<p>Untuk menghasilkan file <strong>robots.txt</strong> secara otomatis, seseorang dapat memakai generator seperti yang ada di <a href="http://www.mcanerin.com/EN/search-engine/robots-txt.asp" target="_blank">http://www.mcanerin.com/EN/search-engine/robots-txt.asp</a></p>
<p>Satu hal yang harus diperhatikan adalah <strong>robots.txt</strong> hanya berfungsi sebagai rekomendasi bagi web crawler saja!!  Ada beberapa web crawler yang tidak mengindahkan isi <strong>robots.txt</strong>, terutama web crawler yang memiliki &#8216;niat buruk&#8217;.  Crawler seperti ini biasanya disebut <strong>bad bots</strong>.  Bahkan ada <strong>bad bots</strong> yang dirancang khusus untuk mencari lokasi yang tertuang dalam <strong>robots.txt</strong> (yang seharusnya tidak boleh dikunjungi). Jadi, <strong>robots.txt</strong> tidak untuk melindungi halaman yang sensitif.  Bila ada halaman yang sangat sensitif yang tidak ingin dilihat oleh orang lain, cara yang paling jitu tetap dengan authentication seperti username dan password, sehingga <strong>bad bots</strong> yang tidak mengetahui username &amp; password tidak dapat melihat konten tersebut.</p>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/web-programming/miscellaneous/'>Miscellaneous</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/robots-txt/'>robots.txt</a>, <a href='http://thesolidsnake.wordpress.com/tag/web-crawler/'>web crawler</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/682/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/682/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/682/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/682/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/682/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/682/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/682/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/682/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/682/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/682/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/682/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/682/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/682/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/682/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=682&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2011/11/20/menghindari-google-dengan-robots-txt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>
	</item>
		<item>
		<title>URL Rewriting Di Apache HTTP Server</title>
		<link>http://thesolidsnake.wordpress.com/2011/11/19/url-rewriting-di-apache-http-server/</link>
		<comments>http://thesolidsnake.wordpress.com/2011/11/19/url-rewriting-di-apache-http-server/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 08:48:09 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[PHP Framework & API]]></category>
		<category><![CDATA[Apache HTTP Servers]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[URL Rewriting]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=678</guid>
		<description><![CDATA[Seorang programmer PHP membuat file latihan.php di folder web-nya.  Untuk mengakses file tersebut, pengguna harus mengetikkan URL seperti http://www.domain.com/latihan.php. Dengan demikian, URL selalu berisi informasi yang dipetakan terhadap file fisik.  Hal ini tidak berlaku di JEE: user mengakses sebuah Servlet bukan berdasarkan nama class, tetapi berdasarkan nilai element urlPatterns di WebServlet annotation. Seandainya programmer PHP [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=678&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Seorang programmer PHP membuat file <strong>latihan.php</strong> di folder web-nya.  Untuk mengakses file tersebut, pengguna harus mengetikkan URL seperti<strong> http://www.domain.com/latihan.php</strong>. Dengan demikian, URL selalu berisi informasi yang dipetakan terhadap file fisik.  Hal ini tidak berlaku di JEE: user mengakses sebuah Servlet bukan berdasarkan nama class, tetapi berdasarkan nilai element <strong>urlPatterns</strong> di <strong>WebServlet</strong> annotation.</p>
<p>Seandainya programmer PHP tersebut membuat file <strong>post.php</strong> yang diakses seperti ini:</p>
<pre><strong>http://www.domain.com/post.php?tahun=2012&amp;bulan=11&amp;tanggal=01</strong></pre>
<p>Kemudian ia merasa bahwa URL tersebut terlalu panjang, alangkah sederhananya bila URL tersebut diakses seperti:</p>
<pre><strong>http://www.domain.com/2012/10/01</strong></pre>
<p>Apa yang harus ia lakukan tanpa membuat file baru?  Proses yang harus ia lakukan dikenal sebagai <strong>URL rewriting</strong>.  Bila ia memakai Apache HTTP Server, ia dapat menggunakan Apache <strong>mod_rewrite</strong> yang menyediakan fungsi tersebut.</p>
<p>Sebelum menggunakan Apache <strong>mod_rewrite</strong>, pastikan terlebih dahulu modul tersebut sudah di-load, dengan memeriksa isi file konfigurasi Apache.  Sebagai informasi, nama file konfigurasi Apache HTTP Server adalah <strong>httpd.conf</strong> (pada server Linux, biasanya terdapat di direktori <strong>/etc</strong>).  Pastikan baris berikut tidak di-comment (tidak diawali tanda #):</p>
<pre>LoadModule rewrite_module modules/mod_rewrite.so</pre>
<p>Bila si programmer tidak memiliki akses pada folder sensitif, ia dapat membuat sebuah file PHP dengan isi seperti berikut:</p>
<pre>&lt;?php
phpinfo();
?&gt;</pre>
<p>Setelah menjalankan PHP tersebut di-browser, sang programmer dapat memeriksa bagian<strong> apache2handler</strong> di baris <strong>Loaded Modules</strong>.  Bila terdapat tulisan <strong>mod_rewrite</strong>, maka ia dapat menggunakan fitur<strong> URL Rewriting</strong> dari Apache HTTP Server.</p>
<p>Langkah berikutnya yang harus dilakukan adalah menambahkan directive untuk keperluan <strong>mod_rewrite</strong>.  Hampir semua directive dapat diletakkan di file konfigurasi<strong> httpd.conf</strong>, akan tetapi bila si programmer tidak memiliki akses untuk mengubah <strong>httpd.conf</strong>, ia terpaksa harus meletakkannya pada file<strong> .htaccess</strong>. Ada beberapa directive yang tidak dapat diletakkan di <strong>.htaccess</strong>, misalnya <strong>RewriteLog</strong> dan <strong>RewriteLogLevel</strong> yang memungkinkan log yang berisi informasi mengenasi proses URL rewriting yang terjadi.</p>
<p>Selain itu, pastikan <strong>AllowOverride</strong> bernilai <strong>All</strong> pada directive <strong>Directory</strong> yang berisi lokasi direktori fisik.  Bila <strong>AllowOverride</strong> bernilai <strong>None</strong>, maka file<strong> .htaccess</strong> akan diabaikan oleh Apache HTTP Server.</p>
<p>Langkah terakhir, si programmer membuat file<strong> .htaccess</strong> di direktori utama, yang isinya seperti berikut ini:</p>
<pre>RewriteEngine On
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})$ /post.php?tahun=$1&amp;bulan=$2&amp;tanggal=$3</pre>
<p>Directive <strong>RewriteRule</strong> di atas mengandung dua bagian, yaitu bagian <strong>Pattern</strong> dan bagian <strong>Substitution</strong>.</p>
<p>Bagian <strong>Pattern</strong> berisi <strong>regular expression</strong> yang akan dicocokkan dengan URL yang diberikan oleh pengguna.  Pada regex, <strong>[0-9]{4}/</strong> menunjukkan bahwa wajib terdapat empat digit angka (contoh pola yang memenuhi: 1994/, 2004/; contoh pola yang salah: abcd/, 19/).  Lalu<strong> [0-9]{2}/</strong> menunjukkan bahwa wajib terdapat dua digit angka (contoh pola yang memenuhi: 10/, 11/, dan sebagainya).  Dengan demikian, secara keseluruhan, contoh nilai yang memenuhi regex di bagian <strong>Pattern</strong> ini adalah: <strong>2011/11/01</strong></p>
<p>Bagian <strong>Substitution</strong> berisi resources yang sesungguhnya akan diakses. Resources dapat berupa lokasi file ataupun URL lain.  Pada contoh, bila pola URL di pattern dipenuhi, maka yang akan diakses adalah <strong>/post.php</strong>.  Nilai <strong>$1</strong> akan digantikan dengan nilai ekspresi dalam tanda kurung yang pertama kali dijumpai di bagian <strong>Pattern</strong>.  Begitu juga nilai <strong>$2</strong> akan digantikan dengan nilai ekspresi dalam tanda kurung yang kedua, dan seterusnya.</p>
<p>Dengan demikian, bila user yang memasukkan URL:</p>
<pre>http://www.domain.com/2011/11/30</pre>
<p>maka halaman yang sesungguhnya diakses adalah:</p>
<pre>http://www.domain.com/post.php?tahun=2011&amp;bulan=11&amp;tanggal=30</pre>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/php/php-framework-api/'>PHP Framework &amp; API</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/apache-http-servers/'>Apache HTTP Servers</a>, <a href='http://thesolidsnake.wordpress.com/tag/mod_rewrite/'>mod_rewrite</a>, <a href='http://thesolidsnake.wordpress.com/tag/url-rewriting/'>URL Rewriting</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/678/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=678&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2011/11/19/url-rewriting-di-apache-http-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>
	</item>
		<item>
		<title>Memakai VIM di Windows 7</title>
		<link>http://thesolidsnake.wordpress.com/2011/11/04/memakai-vim-di-windows-7/</link>
		<comments>http://thesolidsnake.wordpress.com/2011/11/04/memakai-vim-di-windows-7/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 13:41:26 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[text editor]]></category>
		<category><![CDATA[VIM]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=667</guid>
		<description><![CDATA[Suatu hari, saya ingin melakukan perubahan konfigurasi domain GlasshFish yang ter-install di Windows 7.  Seperti kebanyakan aplikasi multiplatform lain, konfigurasi GlassFish tersimpan dalam sebuah file yang bisa di-edit oleh administrator-nya. Kebanyakan aplikasi multiplatform tidak menyimpan konfigurasi di registry, sehingga pengguna tidak dapat mengedit melalui tools GUI seperti regedit.  Hal ini masuk akal, karena registry hanya [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=667&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Suatu hari, saya ingin melakukan perubahan konfigurasi domain GlasshFish yang ter-install di Windows 7.  Seperti kebanyakan aplikasi multiplatform lain, konfigurasi GlassFish tersimpan dalam sebuah file yang bisa di-edit oleh administrator-nya. Kebanyakan aplikasi multiplatform tidak menyimpan konfigurasi di registry, sehingga pengguna tidak dapat mengedit melalui tools GUI seperti regedit.  Hal ini masuk akal, karena registry hanya berlaku di Windows.  Cara yang paling efektif dan efisien memang dengan menuliskannya ke dalam sebuah file, karena seluruh platform lain seperti Linux, MacOS, &amp; UNIX, dapat membaca dan menulis isi file.</p>
<p>&#8220;<em>Mengedit file</em>&#8221; terdengar sangat sederhana, tetapi bagi saya, hal ini menjadi sedikit merepotkan di <strong>Windows 7,</strong> terutama bila ingin langsung mengedit sebuah file secara langsung tanpa meninggalkan <strong>Command Prompt</strong>.  Selama ini, saya tidak pernah menemukan masalah dalam mengedit file saat berada di console UNIX dan turunannya, karena hampir semua sistem operasi tersebut menyertakan editor teks <strong>VI</strong> atau <strong>VIM</strong>. Sejujurnya, saya sedikit kebingungan bila memakai VI, tetapi tidak sulit untuk men-upgrade-nya menjadi <strong>VIM (Vi IMproved)</strong>.</p>
<p>Seandainya, saya sedang berada di <strong>Command Prompt</strong> Windows 7 (misalnya, untuk memanggil tools asadmin bawaan GlashFish), lalu saya ingin mengedit file konfigurasi domain.  Hal pertama yang saya pikirkan adalah <strong>notepad.exe</strong>, sebuah editor sederhana bawaan Windows dari berbagai generasi.  Di <strong>Command Prompt</strong>, saya bisa mengetikkan seperti berikut ini:<br />
<code><br />
C:\&gt;<strong>notepad domain.xml</strong><br />
</code><br />
Akan muncul program <strong>Notepad</strong> beserta isi file domain.xml seperti berikut ini:</p>
<p><a href="http://thesolidsnake.files.wordpress.com/2011/11/gambar0.jpg"><img class="aligncenter size-full wp-image-668" title="Tampilan Notepad" src="http://thesolidsnake.files.wordpress.com/2011/11/gambar0.jpg?w=455&#038;h=111" alt="Tampilan Notepad" width="455" height="111" /></a></p>
<p>Kenapa setiap baris jadi saling sambung menyambung seperti itu? Di platform <strong>UNIX</strong> dan turunannya (Linux, MacOS X, dan sebagainya), pemisah baris hanya satu karakter, yaitu karakter <strong>LF (Line Feed)</strong> yang diwakili karakter ASCII 10 (simbol <strong>&#8216;\n&#8217;</strong>).  Sementara itu, di platform <strong>Windows</strong>, pemisah baris terdiri atas dua karakter, yaitu karakter <strong>CF (Carriage Return)</strong> yang diwakili karakter ASCII 13 (simbol<strong> &#8216;\r&#8217;</strong>) baru diikuti dengan <strong>LF (Line Feed)</strong>.  Notepad tidak menemukan karakter <strong>&#8216;\r\n&#8217;</strong> sehingga tidak akan ada pemisah baris.</p>
<p>Masih ada sebuah solusi, yaitu editor dalam <strong>Command Prompt</strong> yang bernama <strong>edit.exe</strong>.  Sungguh tidak disangka editor yang populer di zaman <strong>DOS</strong> seperti ini masih ada di generasi <strong>Windows 7</strong>.  Untuk memakai <strong>edit.exe</strong>, saya memberikan perintah seperti berikut ini:<br />
<code><br />
C:\&gt;<strong>edit domain.xml</strong><br />
</code><br />
Akan muncul tampilan seperti berikut ini:</p>
<p><a href="http://thesolidsnake.files.wordpress.com/2011/11/gambar11.jpg"><img class="aligncenter size-full wp-image-669" title="Tampilan Edit.exe" src="http://thesolidsnake.files.wordpress.com/2011/11/gambar11.jpg?w=455&#038;h=233" alt="Tampilan Edit.exe" width="455" height="233" /></a></p>
<p>Sekarang file sudah dapat dibaca dan ditampilkan dengan rapi.  Akan tetapi, <strong>edit.exe</strong> memiliki banyak kelemahan dalam mengedit file.  Salah satunya adalah harus sering menggeser layar (tidak ada fitur <em>word-wrap</em>) dan tidak ada<em> syntax highlighting</em>. Bagaimana bisa fitur editor di Windows kalah dari editor<strong> VIM</strong> bawaan sistem operasi <em>gratis</em> seperti <strong>Linux</strong>?</p>
<p>Saya akhirnya memutuskan untuk menginstall <strong>VIM versi Windows</strong> di Windows 7 saya.  VIM dapat didownload di<a title="Situs Resmi VIM" href="http://www.vim.org/" target="_blank"> situs resmi</a>-nya.  Untuk platform <strong>Windows</strong>, sudah tersedia installer yang dapat melakukan proses instalasi secara otomatis.</p>
<p>Setelah meng-install <strong>VIM</strong>, saya menambahkan direktori instalasi VIM di <em>environment variables</em> <strong>Path</strong> sehingga saya dapat langsung memanggil editor tersebut di <strong>Command Prompt</strong>.  Caranya adalah dengan membuka tab <strong>Advanced</strong> di <strong>System Properties</strong>.  Kemudian klik pada tombol <strong>Environment Variables&#8230;</strong> Pada dialog yang muncul, cari<strong> Path</strong> di bagian <strong>System Variables</strong>, kemudian klik <strong>Edit&#8230;</strong>  Saya menambahkan <strong>C:\Program Files\Vim\vim73</strong> di bagian paling akhir (pisahkan dengan direktori sebelumnya dengan menggunakan tanda &#8220;<strong>;</strong>&#8220;).</p>
<p>Karena saya terbiasa memanggil VIM dengan mengetik <strong>vi</strong> di <strong>Linux</strong>, maka saya menambahkan symbolic link <strong>vi</strong> yang merujuk ke <strong>vim.exe</strong>. Caranya adalah dengan membuka <strong>Command Prompt</strong> sebagai superuser (tahan <strong>Ctrl+Shift</strong>) pada saat men-klik shortcut <strong>Command Prompt</strong>, lalu berikan perintah seperti berikut ini:</p>
<pre>C:\&gt;<strong>cd "C:\Program Files\Vim\vim73"</strong>
C:\Program Files\Vim\vim73&gt;<strong>mklink vi.exe vim.exe</strong>
symbolic link created for vi.exe &lt;&lt;===&gt;&gt; vim.exe</pre>
<p>Sekarang, saya dapat mengedit file konfigurasi GlassFish tersebut dengan memberikan perintah seperti berikut ini:<br />
<code><br />
C:&gt;<strong>vi domain.xml</strong><br />
</code><br />
Akan muncul tampilan seperti berikut:</p>
<p><a href="http://thesolidsnake.files.wordpress.com/2011/11/gambar21.jpg"><img class="aligncenter size-full wp-image-670" title="Tampilan VIM" src="http://thesolidsnake.files.wordpress.com/2011/11/gambar21.jpg?w=455&#038;h=232" alt="Tampilan VIM" width="455" height="232" /></a></p>
<p>Kali ini, saya akan mendapatkan tampilan yang familiar seperti di Linux.  Tidak seperti di <strong>edit.exe</strong>, <strong>VIM</strong> secara otomatis melakukan <em>word-wrap</em> dan memberikan <em>syntax highlighting</em> (pewarnaan) sehingga lebih mudah mencari bagian yang akan di-edit.  Pertama kali memakai <strong>VIM</strong> memang bisa jadi rumit (tidak ada menu, perintah diberikan dengan mengetikkan huruf seperti <strong>:wq</strong> untuk <em>save dan keluar</em>).  Akan tetapi bila sudah terbiasa, <strong>VIM</strong> bisa menjadi sebuah editor yang sangat powerful.  Misalnya dengan memberikan perintah <strong>:set nu!</strong> dan <strong>:set wrap!</strong>, saya dapat mengaktifkan line number dan word wrap sehingga tampilan VIM terlihat seperti:</p>
<p><a href="http://thesolidsnake.files.wordpress.com/2011/11/gambar31.jpg"><img class="aligncenter size-full wp-image-671" title="Tampilan VIM line number &amp; warp on" src="http://thesolidsnake.files.wordpress.com/2011/11/gambar31.jpg?w=455&#038;h=231" alt="Tampilan VIM line number &amp; wrap on" width="455" height="231" /></a></p>
<p><strong>VIM</strong> memiliki banyak fitur menyenangkan lainnya, dan tentu saja, jauh lebih powerful dibanding <strong>edit.exe </strong>dan<strong> Notepad.exe</strong> bawaan Windows terutama bagi programmer.   Selain itu, VIM juga lebih ringan dan gratis bila dibanding editor berbasis GUI (misalnya editor komersial UltraEdit).  Dengan adanya VIM di Windows, akhirnya saya bisa sedikit lebih betah memakai console di Windows (entah mengapa masih merasa tidak seperti di Linux).</p>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/operating-system/windows-7/'>Windows 7</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/command-prompt/'>command prompt</a>, <a href='http://thesolidsnake.wordpress.com/tag/linux/'>Linux</a>, <a href='http://thesolidsnake.wordpress.com/tag/text-editor/'>text editor</a>, <a href='http://thesolidsnake.wordpress.com/tag/vim/'>VIM</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/667/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=667&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2011/11/04/memakai-vim-di-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2011/11/gambar0.jpg" medium="image">
			<media:title type="html">Tampilan Notepad</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2011/11/gambar11.jpg" medium="image">
			<media:title type="html">Tampilan Edit.exe</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2011/11/gambar21.jpg" medium="image">
			<media:title type="html">Tampilan VIM</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2011/11/gambar31.jpg" medium="image">
			<media:title type="html">Tampilan VIM line number &#38; warp on</media:title>
		</media:content>
	</item>
		<item>
		<title>Memakai nasm Di Linux</title>
		<link>http://thesolidsnake.wordpress.com/2011/11/02/memakai-nasm-di-linux/</link>
		<comments>http://thesolidsnake.wordpress.com/2011/11/02/memakai-nasm-di-linux/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 10:41:46 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[Assembly]]></category>
		<category><![CDATA[CPUID]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[NASM]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=662</guid>
		<description><![CDATA[Pada tulisan sebelumnya yang berjudul Assembly di Linux Dengan GAS, saya memperlihatkan penggunaan GNU Assembler di Linux.  GNU Assembler (GAS) hampir tersedia di kebanyakan instalasi Linux, sehingga programmer tinggal memakainya saja.  Tapi untuk memakai GAS, seseorang harus mempelajari assembly dengan syntax AT&#38;T.  Bagi yang terbiasa dengan syntax Intel, pada awalnya mungkin akan sering mengalami sindrom [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=662&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Pada tulisan sebelumnya yang berjudul <a title="Assembly di Linux Dengan GAS" href="http://thesolidsnake.wordpress.com/2011/10/30/assembly-di-linux-dengan-gas/" target="_blank">Assembly di Linux Dengan GAS</a>, saya memperlihatkan penggunaan <strong>GNU Assembler</strong> di Linux.  <strong>GNU Assembler (GAS)</strong> hampir tersedia di kebanyakan instalasi Linux, sehingga programmer tinggal memakainya saja.  Tapi untuk memakai GAS, seseorang harus mempelajari assembly dengan syntax AT&amp;T.  Bagi yang terbiasa dengan syntax Intel, pada awalnya mungkin akan sering mengalami sindrom &#8220;<em>operand tertukar</em>&#8221; (hal ini karena letak <strong>operand</strong> di syntax AT&amp;T terbalik dengan yang ada di dokumentasi Intel).  Sebagai contoh, perhatikan syntax Intel berikut:<br />
<code><br />
mov al, bl<br />
</code><br />
Baris di atas akan memintahkan isi register BL ke register AL.  Untuk melakukan hal yang sama pada syntax AT&amp;T, programmer harus memberikan perintah seperti:<br />
<code><br />
movb %bl, %al<br />
</code><br />
Urutan <strong>operand</strong> yang <span style="text-decoration:underline;">terbalik</span> seperti ini bisa jadi membingungkan bagi programmer yang sudah terbiasa memakai syntax Intel.</p>
<p>Salah satu solusinya adalah dengan meng-install <strong>Netwide Assembler (NASM)</strong> yang sangat populer di Linux.  Source NASM yang terbaru pada tulisan ini dibuat dapat di-download di <a title="NASM" href="http://www.nasm.us/" target="_blank">situs resmi NASM</a>.  Setelah men-<em>download</em> dan men-<em>extract</em> source NASM, kerjakan script <strong>configure</strong>.  Berikan perintah <strong>make</strong> dan <strong>make install</strong> untuk meng-install <strong>NASM</strong> pada lokasi default.</p>
<p>Untuk melihat dukungan format NASM, berikan perintah seperti berikut:</p>
<pre>$ nasm -hf
...
valid output formats for -f are (`*' denotes default):
* bin       flat-form binary files (e.g. DOS .COM, .SYS)
ith       Intel hex
srec      Motorola S-records
aout      Linux a.out object files
aoutb     NetBSD/FreeBSD a.out object files
coff      COFF (i386) object files (e.g. DJGPP for DOS)
elf32     ELF32 (i386) object files (e.g. Linux)
elf64     ELF64 (x86_64) object files (e.g. Linux)
as86      Linux as86 (bin86 version 0.3) object files
obj       MS-DOS 16-bit/32-bit OMF object files
win32     Microsoft Win32 (i386) object files
win64     Microsoft Win64 (x86-64) object files
rdf       Relocatable Dynamic Object File Format v2.0
ieee      IEEE-695 (LADsoft variant) object file format
macho32   NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (i386) object files
macho64   NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (x86_64) object files
dbg       Trace of all info passed to output stage
elf       ELF (short name for ELF32)
macho     MACHO (short name for MACHO32)
win       WIN (short name for WIN32)</pre>
<p>Pada Linux, format yang dipakai adalah <strong>elf</strong>.  Perhatikan bahwa NASM mendukung format <strong>bin</strong> yang akan menghasilkan <strong>flat-form</strong> binary file (mirip seperti file COM di zaman DOS).  Format <strong>bin</strong> seperti ini dapat dipakai untuk menghasilkan kode untuk bootloader dan berbagai keperluan lain dalam membuat sebuah sistem operasi baru.</p>
<p>Berikut ini adalah program yang sama seperti pada tulisan <a title="Assembly di Linux Dengan GAS" href="http://thesolidsnake.wordpress.com/2011/10/30/assembly-di-linux-dengan-gas/" target="_blank">Assembly di Linux Dengan GAS</a>, hanya saja kali ini memakai <strong>Intel syntax</strong> dan ditujukan untuk <strong>NASM</strong>:</p>
<pre>section .data
output_vendor:
db  `Vendor ID Prosesor adalah 'xxxxxxxxxxxx'\n`
output_vendor_length    equ     $-output_vendor

output_brand:
db  `Prosesor Brand String adalah 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n`
output_brand_length    equ    $-output_brand

output_no_brand:
db  `Tidak ada informasi Processor Brand String\n`
output_no_brand_length    equ    $-output_no_brand

section .text
global _start
_start:
mov    eax, 0
cpuid
mov    edi, output_vendor
mov    [edi+27], ebx
mov    [edi+31], edx
mov    [edi+35], ecx
mov    eax, 4
mov    ebx, 1
mov    ecx, output_vendor
mov    edx, output_vendor_length
int    0x80

mov    eax, 0x80000000
cpuid
cmp    eax, 0x80000004
jl    no_brand

mov    eax, 0x80000002
cpuid
mov    edi, output_brand
mov    [edi+30], eax
mov    [edi+34], ebx
mov    [edi+38], ecx
mov    [edi+42], edx

mov    eax, 0x80000003
cpuid
mov    [edi+46], eax
mov    [edi+50], ebx
mov    [edi+54], ecx
mov    [edi+58], edx

mov    eax, 0x80000004
cpuid
mov    [edi+62], eax
mov    [edi+66], ebx
mov    [edi+70], ecx
mov    [edi+74], edx
mov    [edi+77], byte 0x20

mov    eax, 4
mov    ebx, 1
mov    ecx, output_brand
mov    edx, output_brand_length
int    0x80
jmp    selesai

no_brand:
mov    eax, 4
mov    ebx, 1
mov    ecx, output_no_brand
mov    edx, output_no_brand_length
int     0x80

selesai:
mov    eax, 1
mov     ebx, 0
int    0x80</pre>
<p>Untuk menjalankan program tersebut, berikan perintah seperti berikut ini:</p>
<pre>$ nasm -f elf cpuinfo.asm
$ ld -o cpuinfo cpuinfo.o
$ ./cpuinfo
Vendor ID Prosesor adalah 'GenuineIntel'
Prosesor Brand String adalah 'Pentium(R) Dual-Core CPU       T4400  @ 2.20GHz '</pre>
<p>Nilai option &#8220;<strong>-f elf</strong>&#8221; menunjukkan bahwa NASM akan menghasilkan output dalam format <strong>ELF</strong> yang dipakai oleh Linux.  Pembuat program assembler yang terbiasa menggunakan IA-32 pun dapat tetap memakai Intel syntax di platform Linux.</p>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/computer-hardware/assembly/'>Assembly</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/cpuid/'>CPUID</a>, <a href='http://thesolidsnake.wordpress.com/tag/linux/'>Linux</a>, <a href='http://thesolidsnake.wordpress.com/tag/nasm/'>NASM</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/662/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=662&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2011/11/02/memakai-nasm-di-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>
	</item>
		<item>
		<title>Menyimpan Bit Dengan Latch</title>
		<link>http://thesolidsnake.wordpress.com/2011/11/02/menyimpan-bit-dengan-latch/</link>
		<comments>http://thesolidsnake.wordpress.com/2011/11/02/menyimpan-bit-dengan-latch/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 18:10:13 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[Memory]]></category>
		<category><![CDATA[clock cycle]]></category>
		<category><![CDATA[D latch]]></category>
		<category><![CDATA[digital logic]]></category>
		<category><![CDATA[SR latch]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=656</guid>
		<description><![CDATA[Sirkuit yang outputnya tergantung pada input sebelumnya disebut sebagai sequential circuit.  Ketergantungan dengan input sebelumnya membuat sequential circuit memiliki sifat memori.  Salah satu contoh sequential circuit yang ditunjukkan dalam tulisan ini adalah apa yang disebut sebagai latches. Berikut ini adalah diagram sirkuit SR latch: SR latch adalah sirkuit sederhana yang terdiri atas dua buah NOR [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=656&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:left;">Sirkuit yang outputnya tergantung pada input sebelumnya disebut sebagai <strong>sequential circuit</strong>.  Ketergantungan dengan input sebelumnya membuat sequential circuit memiliki sifat <strong>memori</strong>.  Salah satu contoh <strong>sequential circuit</strong> yang ditunjukkan dalam tulisan ini adalah apa yang disebut sebagai <strong>latches</strong>. Berikut ini adalah diagram sirkuit <strong>SR latch</strong>:</p>
<p><img class="aligncenter" title="SR latch" src="http://upload.wikimedia.org/wikipedia/commons/c/c6/R-S_mk2.gif" alt="Diagram animasi SR latch" width="300" height="219" /></p>
<p><strong>SR latch</strong> adalah sirkuit sederhana yang terdiri atas dua buah <strong>NOR gate</strong>. Sirkuit ini membutuhkan dua input, yaitu <strong>S (Set)</strong> dan <strong>R (Reset)</strong>.  <strong>SR latch</strong>menghasilkan dua output, yaitu <strong>Q</strong> dan <strong>Q&#8217;</strong>.</p>
<p>Bila nilai <strong>S</strong> adalah 0 dan <strong>R</strong> adalah 1, maka nilai <strong>Q</strong> adalah 0.  Hal ini karena <strong>R</strong> adalah 1 dan <strong>NOR gate</strong> akan selalu menghasilkan 0 bila salah satu input bernilai 1.  Sebaliknya, nilai <strong>Q&#8217;</strong> adalah 1.</p>
<p>Bila nilai <strong>S</strong> adalah 1 dan <strong>R</strong> adalah 0, maka keluaran <strong>Q&#8217;</strong> selalu 0 sehingga <strong>Q</strong> bernilai 1.</p>
<p>Bila <strong>S</strong> bernilai 0 dan <strong>R</strong> bernilai 0, maka output dari <strong>Q</strong> dan <strong>Q&#8217;</strong> akan bergantung pada nilai saat ini:</p>
<ul>
<li>Nilai <strong>Q</strong> adalah 1 dan <strong>Q&#8217;</strong> adalah 0.  Lalu, <strong>SR latch</strong> mendapat input <strong>S</strong> berupa 0 dan <strong>R</strong> berupa 0, maka nilai <strong>Q</strong> menjadi 1 dan nilai <strong>Q&#8217;</strong> menjadi 0.</li>
</ul>
<ul>
<li>Nilai <strong>Q</strong> adalah 0 dan <strong>Q&#8217;</strong> adalah 1.  Lalu, <strong>SR latch</strong> mendapat input <strong>S</strong> berupa 0 dan <strong>R</strong> berupa 0, maka nilai <strong>Q</strong> menjadi 0 dan nilai <strong>Q&#8217;</strong> menjadi 1.</li>
</ul>
<p>Hal ini menunjukkan bahwa:</p>
<ul>
<li>Bila <strong>Set (S)</strong> bernilai 1 dan <strong>Reset (R)</strong> bernilai 0, maka nilai <strong>Q</strong> akan menjadi <strong>0</strong>.</li>
<li>Bila <strong>Set (S)</strong> bernilai 0 dan <strong>Reset (R)</strong> bernilai 1, maka nilai <strong>Q</strong> akan menjadi <strong>1</strong>.</li>
<li>Bila <strong>Set (S)</strong> bernilai 0 dan <strong>Reset (R)</strong> bernilai 0, maka nilai <strong>Q</strong> akan selalu sama seperti nilai sebelumnya.</li>
</ul>
<p>Dengan demikian, sebuah <strong>SR latch</strong> dapat dipakai untuk menyimpan nilai sebuah bit.  Untuk mengatur nilai bit, seseorang perlu memberikan <strong>SR = 10</strong> atau <strong>SR = 01</strong>.  Untuk mempertahankan nilai bit tersebut, nilai <strong>S</strong> tetap 0 dan nilai <strong>R</strong> tetap 0, maka bit <strong>Q</strong> akan selalu memiliki nilai yang sama selama listrik masih mengalir.  Ini adalah konsep dasar dari sebuah sel 1-bit dalam memori RAM.</p>
<p><strong>Sequential circuit</strong> umumnya beroperasi pada <strong>synchronous mode</strong>.  Pada modus ini, seluruh sirkuit dalam sistem mengubah <strong>state</strong>-nya secara bersamaan pada waktu yang telah ditentukan, melalui penggunaan <strong>clock signal</strong>.  Sebuah<strong> clock signal</strong> adalah sinyal yang memiliki state<strong> 1 (ON)</strong> dan <strong>0 (OFF)</strong>, seperti yang ditunjukkan pada gambar berikut:</p>
<p><a href="http://thesolidsnake.files.wordpress.com/2011/11/gambar1.jpg"><img class="aligncenter size-full wp-image-657" title="Clock Signal" src="http://thesolidsnake.files.wordpress.com/2011/11/gambar1.jpg?w=455&#038;h=133" alt="Clock Signal" width="455" height="133" /></a></p>
<p>Sebuah <strong>clock cycle</strong> adalah waktu diantara dua buah <strong>rising edge</strong> (sisi sinyal dari 0 menjadi 1) yang berurutan.  <strong>Clock rate</strong> atau <strong>frequency</strong> adalah jumlah <strong>clock cycle</strong> selama 1 detik dalam satuan <strong>Hertz (Hz)</strong>.  Dengan demikian, <strong>frequency</strong> 1 GHz menunjukkan bahwa dalam 1 detik terdapat 1 x 10<sup>9</sup> <strong>clock cycle</strong>.  Jadi, waktu yang dibutuhkan untuk sebuah <strong>clock cycle</strong> adalah 1 / (1 x 10<sup>9</sup>) = 1 x 10<sup>-9</sup> detik atau 1 ns (nano detik).</p>
<p>Untuk membuat <strong>SR latch</strong> tersinkronisasi dengan keseluruhan sirkuit lainnya dalam sistem, maka diagram dapat dimodifikasi menjadi seperti pada gambar berikut:</p>
<p><a href="http://thesolidsnake.files.wordpress.com/2011/11/gambar2.jpg"><img class="aligncenter size-full wp-image-658" title="SR latch dengan clock signal" src="http://thesolidsnake.files.wordpress.com/2011/11/gambar2.jpg?w=455&#038;h=206" alt="SR latch dengan clock signal" width="455" height="206" /></a></p>
<p>Sekarang, input pada <strong>SR latch</strong> akan memiliki efek bila terdapat sinyal 1 (ON) dari <strong>clock</strong>.</p>
<p><strong>D latch</strong> adalah jenis <strong>SR latch</strong> yang menghindari kombinasi <strong>S=1</strong> dan <strong>R=1</strong>.  Caranya adalah dengan menggunakan sebuah inverter, seperti yang terlihat di gambar berikut:</p>
<p><a href="http://thesolidsnake.files.wordpress.com/2011/11/gambar3.jpg"><img class="aligncenter size-full wp-image-659" title="D latch" src="http://thesolidsnake.files.wordpress.com/2011/11/gambar3.jpg?w=455" alt="D latch"   /></a></p>
<p>Langkah untuk memberi nilai <strong>Q</strong> pada <strong>D latch</strong> sama seperti pada <strong>SR latch</strong>.  Setelah itu, nilai <strong>Q</strong> pada <strong>D latch</strong> akan terus dipertahankan dengan selama sinyal dari <strong>clock</strong> adalah sinyal 0 (OFF).</p>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/computer-hardware/memory/'>Memory</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/clock-cycle/'>clock cycle</a>, <a href='http://thesolidsnake.wordpress.com/tag/d-latch/'>D latch</a>, <a href='http://thesolidsnake.wordpress.com/tag/digital-logic/'>digital logic</a>, <a href='http://thesolidsnake.wordpress.com/tag/sr-latch/'>SR latch</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/656/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=656&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2011/11/02/menyimpan-bit-dengan-latch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/commons/c/c6/R-S_mk2.gif" medium="image">
			<media:title type="html">SR latch</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2011/11/gambar1.jpg" medium="image">
			<media:title type="html">Clock Signal</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2011/11/gambar2.jpg" medium="image">
			<media:title type="html">SR latch dengan clock signal</media:title>
		</media:content>

		<media:content url="http://thesolidsnake.files.wordpress.com/2011/11/gambar3.jpg" medium="image">
			<media:title type="html">D latch</media:title>
		</media:content>
	</item>
		<item>
		<title>Memakai System Call Linux Di Assembly</title>
		<link>http://thesolidsnake.wordpress.com/2011/10/31/memakai-system-call-linux-di-assembly/</link>
		<comments>http://thesolidsnake.wordpress.com/2011/10/31/memakai-system-call-linux-di-assembly/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 12:54:45 +0000</pubDate>
		<dc:creator>Solid Snake</dc:creator>
				<category><![CDATA[Assembly]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[system programming]]></category>

		<guid isPermaLink="false">http://thesolidsnake.wordpress.com/?p=651</guid>
		<description><![CDATA[Untuk memanggil system call Linux, programmer assembly harus mengetahui nomor definisi system call yang disebut system call numbers.  Informasi ini dapat diperoleh dengan membaca file /usr/include/asm/unistd_32.h.  Berikut ini adalah contoh isi file tersebut: #ifndef _ASM_X86_UNISTD_32_H #define _ASM_X86_UNISTD_32_H /* * This file contains the system call numbers. */ #define __NR_restart_syscall      0 #define __NR_exit          1 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=651&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Untuk memanggil <strong>system call Linux</strong>, programmer assembly harus mengetahui nomor definisi system call yang disebut <strong>system call numbers</strong>.  Informasi ini dapat diperoleh dengan membaca file <strong>/usr/include/asm/unistd_32.h</strong>.  Berikut ini adalah contoh isi file tersebut:</p>
<pre>#ifndef _ASM_X86_UNISTD_32_H
#define _ASM_X86_UNISTD_32_H

/*
* This file contains the system call numbers.
*/

#define __NR_restart_syscall      0
#define __NR_exit          1
#define __NR_fork          2
#define __NR_read          3
#define __NR_write          4
#define __NR_open          5
#define __NR_close          6
#define __NR_waitpid          7
#define __NR_creat          8
#define __NR_link          9
#define __NR_unlink         10
#define __NR_execve         11
...
#define __NR_inotify_init1    332
#define __NR_preadv        333
#define __NR_pwritev        334
#define __NR_rt_tgsigqueueinfo    335
#define __NR_perf_event_open    336</pre>
<p>Isi file di atas menunjukkan bahwa pada sistem operasi Linux tersebut, terdapat 337 <strong>system call</strong> yang dapat dipanggil oleh programmer assembly, mulai dari 0 hingga 336. Setelah menemukan <strong>system call number</strong>, langkah berikutnya adalah menentukan apa saja yang dibutuhkan untuk memanggil <strong>system call</strong> tersebut.  Salah satu cara yang dapat dilakukan adalah dengan memanggil perintah <strong>man</strong>.  Walaupun ditujukan bagi programmer C, informasi yang ditampilkan oleh <strong>man</strong> cukup berguna bagi programmer assembly yang ingin memanggil <strong>system call</strong> tersebut.  Sebagai contoh, bila programmer ingin melihat informasi untuk <strong>system call</strong> ber-nomor <strong>4</strong> (didefinisikan sebagai <strong>__NR_write</strong>), maka ia dapat memberikan perintah:</p>
<pre>$ <strong>man 2 write</strong>
NAME
write - write to a file descriptor

SYNOPSIS
#include &lt;unistd.h&gt;

ssize_t write(int fd, const void *buf, size_t count);

...</pre>
<p>Untuk mengerjakan <strong>system call</strong> di Linux, programmer assembly menggunakan <strong>INT</strong> dengan nomor interrupt 0&#215;80.  Sebelum memberikan <strong>INT 0&#215;80</strong>, nomor <strong>system call</strong> (sesuai dengan yang ada di file <strong>unistd_32.h</strong>) harus diletakkan terlebih dahulu di register <strong>EAX</strong>, sehingga kernel Linux dapat mengetahui <strong>system call</strong> apa yang akan dikerjakan.  Selain itu, bila ada, nilai parameter harus diberikan pada register tertentu dengan urutan seperti berikut ini:</p>
<ul>
<li>Nilai parameter pertama di-isi pada register <strong>EBX</strong></li>
</ul>
<ul>
<li>Nilai parameter kedua di-isi pada register <strong>ECX</strong></li>
</ul>
<ul>
<li>Nilai parameter ketiga di-isi pada register <strong>EDX</strong></li>
</ul>
<ul>
<li>Nilai parameter keempat di-isi pada register <strong>ESI</strong></li>
</ul>
<ul>
<li>Nilai parameter kelima di-isi pada register <strong>EDI</strong></li>
</ul>
<ul>
<li>Bila jumlah parameter lebih dari lima, <strong>EBX</strong> mengandung pointer ke lokasi memori yang berisi input parameter secara berurutan.</li>
</ul>
<p>Pada system call <strong>write</strong>, informasi yang diberikan oleh <strong>man pages</strong> menunjukkan bahwa dibutuhkan tiga parameter, yaitu <strong>fd</strong>, <strong>*buf</strong>, dan <strong>count</strong>.  Dengan demikian:</p>
<ul>
<li>Register <strong>EBX</strong> mengandung file descriptor (<strong>fd</strong>)</li>
<li>Register <strong>ECX</strong> mengandung pointer ke string yang akan ditampilkan (<strong>*buf</strong>)</li>
<li>Register <strong>EDX</strong> mengandung informasi jumlah karakter di string tersebut (<strong>count)</strong></li>
</ul>
<p>Nilai kembalian dari sebuah system call akan ditampung di register <strong>EAX</strong>.</p>
<p>Contoh kode program assembly secara lengkapnya akan menjadi:</p>
<pre>$ <strong>vi test.s</strong>
.section .data
tulisan:
.ascii "Ini program pertama saya.\n"

.section .text
.globl _start
_start:
movl $4, %eax           # System call nomor 4 (write)
movl $1, %ebx           # Parameter 1: file descriptor = 1 (stdout)
movl $tulisan, %ecx     # Parameter 2: string yang dicetak
movl $26, %edx          # Parameter 3: jumlah karakter (26 huruf)
int $0x80               # Memanggil kernel Linux

movl $1, %eax           # System call nomor 1 (exit)
movl $0, %ebx           # Parameter 1: status code
int $0x80               # Memanggil kernel Linux

$ <strong>as -o test.o test.s</strong>
$ <strong>ld -o test test.o</strong>
$ <strong>./test</strong>
Ini program pertama saya.</pre>
<br />Filed under: <a href='http://thesolidsnake.wordpress.com/category/computer-hardware/assembly/'>Assembly</a> Tagged: <a href='http://thesolidsnake.wordpress.com/tag/linux/'>Linux</a>, <a href='http://thesolidsnake.wordpress.com/tag/system-programming/'>system programming</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesolidsnake.wordpress.com/651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesolidsnake.wordpress.com/651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesolidsnake.wordpress.com/651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesolidsnake.wordpress.com/651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesolidsnake.wordpress.com/651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesolidsnake.wordpress.com/651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesolidsnake.wordpress.com/651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesolidsnake.wordpress.com/651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesolidsnake.wordpress.com/651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesolidsnake.wordpress.com/651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesolidsnake.wordpress.com/651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesolidsnake.wordpress.com/651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesolidsnake.wordpress.com/651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesolidsnake.wordpress.com/651/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesolidsnake.wordpress.com&amp;blog=4840535&amp;post=651&amp;subd=thesolidsnake&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesolidsnake.wordpress.com/2011/10/31/memakai-system-call-linux-di-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">SolidSnake</media:title>
		</media:content>
	</item>
	</channel>
</rss>
