Machine code

Machine code is a computer program written in machine language. It uses the instruction set of a particular computer architecture.[1] It is usually written in binary.[2][3][4][5] Machine code is the lowest level of software. Other programming languages are translated into machine code so the computer can execute them.

An instruction tells the process what operation to perform. Each instruction is made up of an opcode (operation code) and operand(s). The operands are usually memory addresses or data. An instruction set is a list of the opcodes available for a computer. Machine code is what assembly code and other programming languages are compiled to or interpreted as.

Program builders turn code into another language or machine code. Machine code is sometimes called native code. This is used when talking about things that work on only some computers.[6]

Writing machine code

Front panel of an early minicomputer, with switches for entering machine code

Machine code can be written in different forms:

  • Using a number of switches. This generates a sequence of 1 and 0. This was used in the early days of computing. Since the 1970s, it is no longer used.
  • Using a Hex editor. This allows the use of opcodes instead of the number of the command.
  • Using an Assembler. Assembly languages are simpler than opcodes. Their syntax is easier to understand than machine language but harder than high level languages. The assembler will translate the source code into machine code on its own.
  • Using a High-level programming language allows programs that use code that is easier to read and write. These programs are translated into machine code. The translation can happen in many steps. Java programs are first optimized into bytecode. Then it is translated into machine language when it is used.

Typical instructions of machine code

There are many kinds of instructions usually found in an instruction set:

  • Arithmetical operations: Addition, subtraction, multiplication, division.
  • Logical operations: Conjunction, disjunction, negation.
  • Operations acting on single bits: Shifting bits to the left or right.
  • Operations acting on memory: copying a value from one register to another.
  • Operations that compare two values: bigger than, smaller than, equal.
  • Operations that combine other operations: add, compare, and copy if equal to some value(as one operation), jump to some point in the program if a register is zero.
  • Operations that act on program flow: jump to some address.
  • Operations that convert data types: e.g. convert a 32-bit integer to a 64-bit integer, convert a floating point value to an integer (by truncating).

Many modern processors use microcode for some of the commands. More complex commands tend to use it. This is often done with CISC architectures.

Instructions

Every processor or processor family has its own instruction set. Instructions are patterns of bits that correspond to different commands that can be given to the machine. Thus, the instruction set is specific to a class of processors using (mostly) the same architecture.

Newer processor designs often include all the instructions of an earlier one and may add more instructions. Sometimes, a newer design will discontinue or alter the meaning of an instruction code (typically because it is needed for new purposes), affecting code compatibility; even nearly completely compatible processors may show slightly different behavior for some instructions, which may or may not be a problem.

Systems may differ in other details, such as memory arrangement, operating systems, or peripheral devices. Because a program normally relies on such factors, different systems will typically not run the same machine code, even when the same type of processor is used.

Most instructions have one or more opcode fields. They specify the basic instruction type. Other fields may give the type of the operands, the addressing mode, and so on. There may also be special instructions that are contained in the opcode itself. These instructions are called immediates.[source?]

Processor designs can be different in other ways. Different instructions may or may not have the same length. Having all instructions with the same length can simplify the design.

Example

The MIPS architecture has instructions which are 32 bits long. This section has examples of code. The general type of instruction is in the op (operation) field. It is the highest 6 bits. J-type (jump) and I-type (immediate) instructions are fully given by op. R-type (register) instructions include the field funct. It determines the exact operation of the code. The fields used in these types are:

   6      5     5     5     5      6 bits
[  op  |  rs |  rt |  rd |shamt| funct]  R-type
[  op  |  rs |  rt | address/immediate]  I-type
[  op  |        target address        ]  J-type

rs, rt, and rd indicate register operands. shamt gives a shift amount. The address or immediate fields contain an operand directly.

Example: add the registers 1 and 2. Place the result in register 6. It is encoded:

[  op  |  rs |  rt |  rd |shamt| funct]
    0     1     2     6     0     32     decimal
 000000 00001 00010 00110 00000 100000   binary

Load a value into register 8. Take it from the memory cell 68 cells after the location listed in register 3:

[  op  |  rs |  rt | address/immediate]
   35     3     8           68           decimal
 100011 00011 01000 00000 00001 000100   binary

Jump to the address 1024:

[  op  |        target address        ]
    2                 1024               decimal
 000010 00000 00000 00000 10000 000000   binary

Other websites

References

  1. "What is machine language?". Webopedia. September 1996. Retrieved 2010-04-24.
  2. "What is Machine Code?". Wise Geek. Retrieved 2010-04-23.
  3. "What is machine code". Whatis.com. Archived from the original on 2010-05-04. Retrieved 2010-04-23.
  4. "Machine language - Definition and More from the Free Merriam-Webster Dictionary". Merriam-Webster. Retrieved 2010-04-24.[permanent dead link]
  5. "Machine language". Computer Hope. Retrieved 2010-04-24.
  6. "Managed, Unmanaged, Native: What Kind of Code Is This?". developer.com. Archived from the original on 2012-05-30. Retrieved 2008-09-02.

Read other articles:

Untuk kapal lain dengan nama serupa, lihat Yamato (kapal). Yamato sedang diuji coba, pada 20 Oktober 1941 dekat Selat Bungo Sejarah Kekaisaran Jepang Nama YamatoDipesan Maret 1937[1]Pembangun Arsenal Angkatan Laut KurePasang lunas 4 November 1937[2]Diluncurkan 8 Agustus 1940[2]Mulai berlayar 16 Desember 1941[2]Dicoret 31 Agustus 1945Nasib list error: <br /> list (help)Tenggelam 7 April 1945 di utara Okinawa (30°22′N 128°04′E / 30.367...

 

American biomedical researcher Robert GalloBornRobert Charles Gallo (1937-03-23) March 23, 1937 (age 86)Waterbury, Connecticut, United StatesEducationProvidence College (BS)Thomas Jefferson University (MD)Years active1963–presentKnown forCo-discoverer of HIVMedical careerProfessionMedical doctorInstitutionsNational Cancer InstituteSub-specialtiesInfectious disease and virologyResearchBiomedical researchAwardsLasker Award (1982, 1986)Charles S. Mott Prize (1984)Dickson Prize (...

 

Dollnstein. Dollnstein adalah kota yang terletak di distrik Eichstätt di Bayern, Jerman. Kota Dollnstein memiliki luas sebesar 40.55 km². Dollnstein pada tahun 2006, memiliki penduduk sebanyak 2.841 jiwa. lbsKota dan kotamadya di EichstättAdelschlag | Altmannstein | Beilngries | Böhmfeld | Buxheim | Denkendorf | Dollnstein | Egweil | Eichstätt | Eitensheim | Gaimersheim | Großmehring | Hepberg | Hitzhofen | Kindi...

SKS Samozaryadnyi Karabin sistemi Simonova Jenis Karabin Negara asal Uni Soviet Sejarah produksi Perancang Sergei Gavrilovich Simonov Tahun 1945 Spesifikasi Berat 3,85 kg Panjang 1.021 mm Panjang laras 521 mm Peluru 7.62 x 39 mm Mekanisme Piston gas, bolt miring Kecepatan peluru 735 m/s Jarak efektif 400 m Amunisi Klip 10-butir, magazen internal Alat bidik Depan tiang kuncup, belakang tangent SKS, singkatan dari Samozaryadnyi Karabin sistemi Simonova (Rusia: Само...

 

Artikel utama: Penggunaan Internet global Pengguna Internet per 100 jiwaSource: International Telecommunications Union.[1][2] Pengguna Internet tahun 2016 dalam bentuk persentase populasi negaraSource: International Telecommunications Union.[3] Jumlah pengguna Internet tahun 2012Source: International Telecommunications Union.[3] Berikut adalah daftar negara menurut jumlah pengguna Internet pada tahun 2021. Pengguna Internet adalah orang yang menggunakan Interne...

 

This template does not require a rating on Wikipedia's content assessment scale.It is of interest to multiple WikiProjects. Anthropology This template is within the scope of WikiProject Anthropology, a collaborative effort to improve the coverage of Anthropology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.AnthropologyWikipedia:WikiProject AnthropologyTemplate:WikiProject AnthropologyAnthropology...

American televangelist (born 1940) Not to be confused with John Hagy. John HageeHagee in Washington, D.C., July 2007BornJohn Charles Hagee (1940-04-12) April 12, 1940 (age 83)Baytown, Texas, U.S.EducationBSc, MScAlma materTrinity UniversityUniversity of North TexasOccupation(s)Pastor, authorOrganizationJohn Hagee MinistriesWebsitewww.jhm.org John Charles Hagee (born April 12, 1940) is an American pastor and televangelist. He founded John Hagee Ministries, which telecasts to the Uni...

 

追晉陸軍二級上將趙家驤將軍个人资料出生1910年 大清河南省衛輝府汲縣逝世1958年8月23日(1958歲—08—23)(47—48歲) † 中華民國福建省金門縣国籍 中華民國政党 中國國民黨获奖 青天白日勳章(追贈)军事背景效忠 中華民國服役 國民革命軍 中華民國陸軍服役时间1924年-1958年军衔 二級上將 (追晉)部队四十七師指挥東北剿匪總司令部參謀長陸軍�...

 

Award for film, television, radio and video game writing This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Writers Guild of America Awards – news · newspapers · books · scholar · JSTOR (July 2019) (Learn how and when to remove this template message) Writers Guild AwardsCurrent: 76th Writers Guild of America Aw...

Vous lisez un « article de qualité » labellisé en 2011. Paul Kane, Camping on the Prairie, huile sur papier imprimée en 1846. La scène montre Paul Kane (1810-1871) accompagné de son guide dans les Grandes Plaines du Dakota. American Progress. Représentation de la conquête de l'Ouest américain en 1872 par John Gast. La conquête de l'Ouest est le processus de colonisation, par des populations essentiellement d'origine européenne et le gouvernement des États-Unis au XIXe&...

 

Voce principale: Supercoppa italiana. Supercoppa italiana 1990 Competizione Supercoppa italiana Sport Calcio Edizione 3ª Organizzatore Lega Nazionale Professionisti Date 1º settembre 1990 Luogo  ItaliaNapoli Partecipanti 2 Formula gara unica Impianto/i Stadio San Paolo Risultati Vincitore Napoli(1º titolo) Secondo Juventus Statistiche Gol segnati 6 Pubblico 62 404 Maradona solleva la Supercoppa appena conquistata dai partenopei Cronologia della competizione 1989 1991 Manuale La ...

 

Dance of Inanna, Salome For other uses, see Seven veils (disambiguation). Dance of Salome. Armand Point, 1898[1] The Dance of the Seven Veils is Salome's dance performed before King Herod Antipas, in modern stage, literature and visual arts.[2] It is an elaboration on the New Testament story of the Feast of Herod and the execution of John the Baptist, which refers to Salome dancing before the king, but does not give the dance a name. The name Dance of the Seven Veils was chief...

Sultan AjiGenre Drama Fantasi Komedi Laga PembuatMNC PicturesSkenarioPena LangitCeritaPena LangitSutradara Ai Manaf Tema Patrosza Gufran Han Buyung Nayka Sutradara lagaTeam Pro (Eps. 1—34, 76—78)Pemeran Kevin Bzezovski Taroreh Jameela Salim Ucup Gembul Bilal Pitung Nikita Rizky Penggubah lagu temaFajar BandLagu pembukaAku Sultan oleh Fajar BandLagu penutupAku Sultan oleh Fajar BandPenata musikBobby AboNegara asalIndonesiaBahasa asliBahasa IndonesiaJmlh. musim1Jmlh. episode82 (dafta...

 

Typological classification of stone tools Not to be confused with industrial archaeology, the archaeology of (modern) industrial sites. Video of the extraction of a stone tool from a silex rock. Acheulean handaxes from Kent. The types shown are (clockwise from top) cordate, ficron, and ovate. In the archaeology of the Stone Age, an industry or technocomplex[1] is a typological classification of stone tools. An industry consists of a number of lithic assemblages, typically including a ...

 

German lawyer and politician Wilhelm KutscherKutscher as a college student, c. 1894–95OberpräsidentProvince of East PrussiaIn office4 October 1932 – 2 June 1933Preceded byErnst SiehrSucceeded byErich KochRegierungspräsidentRegierungsbezirk Hildesheim [de]In officeApril 1919 – July 1922Preceded byPaul Fromme [de]Succeeded byCarl von HalfernAdditional positions1912–1915Member of the Pomeranian Landtag1933–1945Member of the Prussian State C...

العلاقات البرازيلية الجنوب سودانية البرازيل جنوب السودان   البرازيل   جنوب السودان تعديل مصدري - تعديل   العلاقات البرازيلية الجنوب سودانية هي العلاقات الثنائية التي تجمع بين البرازيل وجنوب السودان.[1][2][3][4][5] مقارنة بين البلدين هذه مقارن�...

 

Large piece of cloth designed to mask backstage areas of a theater from spectators Different types of curtains. Theater drapes and stage curtains are large pieces of cloth that are designed to mask backstage areas of a theater from spectators. They are designed for a variety of specific purposes, moving in different ways (if at all) and constructed from various fabrics. Many are made from black or other darkly colored, light-absorbing material (In North America, for example, heavyweight velou...

 

Names of the Bus companies in the Philippines This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: List of bus companies of the Philippines – news · newspapers · books · scholar · JSTOR (April 2022) (Learn how and when to remove this message) Main articles: Transportation in the Philippines and Transportation in ...

2018 film by Adina Pintilie For other uses, see Touch me not. Touch Me NotRomanian film posterDirected byAdina PintilieWritten byAdina PintilieProduced by Bianca Oana Philippe Avril Adina Pintilie Starring Laura Benson Tómas Lemarquis CinematographyGeorge Chiper-LillemarkEdited byAdina PintilieMusic byIvo PaunovProductioncompanies Manekino Film 4 Proof Film Agitprop Les Films de l'Étranger Pink Productions Rohfilm Distributed by Alamode Film (Germany) Pilot Film (Czech Republic) Nour Films ...

 

遇昌(?—?),清朝官員,滿洲鑲白旗前造和英瀆造佟慶佐領人,以生員考取戶部貼寫筆帖式。 遇昌於乾隆六十年(1794年)任臺灣府知府。嘉慶三年(1798年)任按察使銜分巡台灣兵備道。 參考文獻 劉寧顏編,《重修台灣省通志》,台北市,台灣省文獻委員會,1994年。 官衔 前任:莫異蘭 汀州府知府乾隆五十六-五十九年(1791-1794年) 繼任:和靜 前任:袁秉義 台灣府...