Low-level programming language

A low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture; commands or functions in the language are structurally similar to a processor's instructions. Generally, this refers to either machine code or assembly language. Because of the low (hence the word) abstraction between the language and machine language, low-level languages are sometimes described as being "close to the hardware". Programs written in low-level languages tend to be relatively non-portable, due to being optimized for a certain type of system architecture.[1][2][3][4]

Low-level languages can convert to machine code without a compiler or interpretersecond-generation programming languages[5][6] use a simpler processor called an assembler—and the resulting code runs directly on the processor. A program written in a low-level language can be made to run very quickly, with a small memory footprint. An equivalent program in a high-level language can be less efficient and use more memory. Low-level languages are simple, but considered difficult to use, due to numerous technical details that the programmer must remember. By comparison, a high-level programming language isolates execution semantics of a computer architecture from the specification of the program, which simplifies development.[1]

Machine code

Front panel of a PDP-8/E minicomputer. The row of switches at the bottom can be used to toggle in a machine language program.

Machine code is the form in which code that can be directly executed is stored on a computer. It consists of machine language instructions, stored in memory, that perform operations such as moving values in and out of memory locations, arithmetic and Boolean logic, and testing values and, based on the test, either executing the next instruction in memory or executing an instruction at another location.

Machine code is usually stored in memory as binary data. Programmers almost never write programs directly in machine code; instead, they write code in assembly language or higher-level programming languages.[1]

Although few programs are written in machine languages, programmers often become adept at reading it through working with core dumps or debugging from the front panel.

Example of a function in hexadecimal representation of x86-64 machine code to calculate the nth Fibonacci number, with each line corresponding to one instruction:

89 f8
85 ff
74 26
83 ff 02
76 1c
89 f9
ba 01 00 00 00
be 01 00 00 00
8d 04 16
83 f9 02
74 0d
89 d6
ff c9
89 c2
eb f0
b8 01 00 00
c3

Assembly language

Second-generation languages provide one abstraction level on top of the machine code. In the early days of coding on computers like TX-0 and PDP-1, the first thing MIT hackers did was to write assemblers.[7] Assembly language has little semantics or formal specification, being only a mapping of human-readable symbols, including symbolic addresses, to opcodes, addresses, numeric constants, strings and so on. Typically, one machine instruction is represented as one line of assembly code, commonly called mnemonics.[8] Assemblers produce object files that can link with other object files or be loaded on their own.

Most assemblers provide macros to generate common sequences of instructions.

Example: The same Fibonacci number calculator as above, but in x86-64 assembly language using AT&T syntax:

fib:
    movl %edi, %eax            ; put the argument into %eax
    testl %edi, %edi           ; is it zero?
    je .return_from_fib        ; yes - return 0, which is already in %eax
    cmpl $2, %edi              ; is 2 greater than or equal to it?
    jbe .return_1_from_fib     ; yes (i.e., it's 1 or 2) - return 1
    movl %edi, %ecx            ; no - put it in %ecx, for use as a counter
    movl $1, %edx              ; the previous number in the sequence, which starts out as 1
    movl $1, %esi              ; the number before that, which also starts out as 1
.fib_loop:
    leal (%rsi,%rdx), %eax     ; put the sum of the previous two numbers into %eax
    cmpl $2, %ecx              ; is the counter 2?
    je .return_from_fib        ; yes - %eax contains the result
    movl %edx, %esi            ; make the previous number the number before the previous one
    decl %ecx                  ; decrement the counter
    movl %eax, %edx            ; make the current number the previous number
    jmp .fib_loop              ; keep going
.return_1_from_fib:
    movl $1, %eax              ; set the return value to 1
.return_from_fib:
    ret                        ; return

In this code example, the registers of the x86-64 processor are named and manipulated directly. The function loads its 32-bit argument from %edi in accordance to the System V application binary interface for x86-64 and performs its calculation by manipulating values in the %eax, %ecx, %esi, and %edi registers until it has finished and returns. Note that in this assembly language, there is no concept of returning a value. The result having been stored in the %eax register, again in accordance with System V application binary interface, the ret instruction simply removes the top 64-bit element on the stack and causes the next instruction to be fetched from that location (that instruction is usually the instruction immediately after the one that called this function), with the result of the function being stored in %eax. x86-64 assembly language imposes no standard for passing values to a function or returning values from a function (and in fact, has no concept of a function); those are defined by an application binary interface, such as the System V ABI for a particular instruction set.

Compare this with the same function in C:

unsigned int fib(unsigned int n)
{
    if (!n)
    {
        return 0;
    }
    else if (n <= 2)
    {
        return 1;
    }
    else
    {
        unsigned int f_nminus2, f_nminus1, f_n;       
        for (f_nminus2 = f_nminus1 = 1, f_n = 0; ; --n)
        {
            f_n = f_nminus2 + f_nminus1;
            if (n <= 2)
            {
                return f_n;
            }
            f_nminus2 = f_nminus1;
        }
    }
}

This code is similar in structure to the assembly language example but there are significant differences in terms of abstraction:

  • The input (parameter n) is an abstraction that does not specify any storage location on the hardware. In practice, the C compiler follows one of many possible calling conventions to determine a storage location for the input.
  • The local variables f_nminus2, f_nminus1, and f_n are abstractions that do not specify any specific storage location on the hardware. The C compiler decides how to actually store them for the target architecture.
  • The return function specifies the value to return, but does not dictate how it is returned. The C compiler for any specific architecture implements a standard mechanism for returning the value. Compilers for the x86 architecture typically (but not always) use the %eax register to return a value, as in the assembly language example (the author of the assembly language example has chosen to use the System V application binary interface for x86-64 convention but assembly language does not require this).

These abstractions make the C code compilable without modification on any architecture for which a C compiler has been written. The x86 assembly language code is specific to the x86-64 architecture and the System V application binary interface for that architecture.

Low-level programming in high-level languages

During the late 1960s and 1970s, high-level languages that included some degree of access to low-level programming functions, such as PL/S, BLISS, BCPL, extended ALGOL and NEWP (for Burroughs large systems/Unisys Clearpath MCP systems), and C, were introduced. One method for this is inline assembly, in which assembly code is embedded in a high-level language that supports this feature. Some of these languages also allow architecture-dependent compiler optimization directives to adjust the way a compiler uses the target processor architecture.

Although a language like C is high-level, it does not fully abstract away the ability to manage memory like other languages.[9] In a high-level language like Python the programmer cannot directly access memory due to the abstractions between the interpreter and the machine. Thus C can allow more control by exposing memory management tools through tools like memory allocate (malloc).[10]

Furthermore, as referenced above, the following block of C is from the GNU Compiler and shows the inline assembly ability of C. Per the GCC documentation this is a simple copy and addition code. This code displays the interaction between a generally high level language like C and its middle/low level counter part Assembly. Although this may not make C a natively low level language these facilities express the interactions in a more direct way.[11]

int src = 1;
int dst;   

asm ("mov %1, %0\n\t"
    "add $1, %0"
    : "=r" (dst) 
    : "r" (src));

printf("%d\n", dst);

References

  1. ^ a b c "3.1: Structure of low-level programs". Workforce LibreTexts. 2021-03-05. Retrieved 2023-04-03.
  2. ^ "What is a Low Level Language?". GeeksforGeeks. 2023-11-19. Retrieved 2024-04-27.
  3. ^ "Low Level Language? What You Need to Know | Lenovo US". www.lenovo.com. Retrieved 2024-04-27.
  4. ^ "Low-level languages - Classifying programming languages and translators - AQA - GCSE Computer Science Revision - AQA". BBC Bitesize. Retrieved 2024-04-27.
  5. ^ "Generation of Programming Languages". GeeksforGeeks. 2017-10-22. Retrieved 2024-04-27.
  6. ^ "What is a Generation Languages?". www.computerhope.com. Retrieved 2024-04-27.
  7. ^ Levy, Stephen (1994). Hackers: Heroes of the Computer Revolution. Penguin Books. p. 32. ISBN 0-14-100051-1.
  8. ^ "Machine Language/Assembly Language/High Level Language". www.cs.mtsu.edu. Retrieved 2024-04-27.
  9. ^ Kernighan, Brian W.; Ritchie, Dennis M. (2014). The C programming language. Prentice-Hall software series (2. ed., 52. print ed.). Upper Saddle River, NJ: Prentice-Hall PTR. ISBN 978-0-13-110362-7.
  10. ^ "malloc(3) - Linux manual page". man7.org. Retrieved 2024-04-21.
  11. ^ "Extended Asm (Using the GNU Compiler Collection (GCC))". gcc.gnu.org. Retrieved 2024-04-27.

Read other articles:

فتح عينيكمعلومات عامةتاريخ الصدور 2005اللغة الأصلية العربيةالبلد  مصرالطاقمالمخرج عثمان أبو لبنالكاتب محمد حفظيالبطولة مصطفى شعباننيللي كريمخالد صالحطلعت زكرياصناعة سينمائيةالمنتج دانا للإنتاج والتوزيع الفنيأوسكار - النصر - الماسةالتوزيع أوسكار - النصر - الماسةتعديل...

English footballer Fran Kirby Kirby with England in 2018Personal informationFull name Francesca Kirby[1]Date of birth (1993-06-29) 29 June 1993 (age 30)[1]Place of birth Reading, England[2]Height 5 ft 2 in (1.57 m)[1]Position(s) Forward, attacking midfielder[1]Team informationCurrent team ChelseaNumber 14Youth career2001–2010 ReadingSenior career*Years Team Apps (Gls)2012–2015 Reading 43 (68)2015– Chelsea 98 (61)International c...

1988 single by Michael Jackson For the Polo G song, see Bad Man (Smooth Criminal). Smooth CriminalSingle by Michael Jacksonfrom the album Bad B-sideSmooth Criminal (instrumental)ReleasedNovember 14, 1988 (1988-11-14)[1]RecordedNovember 1986–April 1987[2]StudioWestlake (studio D), Los AngelesGenre Pop[3] R&B[3] Length4:18LabelEpicSongwriter(s)Michael JacksonProducer(s) Quincy Jones Michael Jackson (co.) Michael Jackson singles chronology...

خليل الحية معلومات شخصية الميلاد 1960 (العمر 63 سنة)غزة ،  فلسطين الجنسية فلسطيني الديانة مسلم، أهل السنة والجماعة الحياة العملية المدرسة الأم الجامعة الإسلامية في غزة  المهنة عضو المكتب السياسي لحركة حماس. رئيس المكتب الاعلامي لحركة حماس نائب بالمجلس التشريعي الفلسطين...

Daging lemur dari spesies yang terancam punah, dijajakan di Madagaskar Daging semak yang telah dikeringkan dan siap dimasak, diantaaranya tikus tebu, tikus besar berkantung, dan antelope kecil Cephalophus rufilatus Daging semak adalah daging yang diburu dari hewan liar. Istilah ini digunakan di Afrika, Asia, dan Amerika Latin. Hewan yang dimaksud bervariasi, umumnya mamalia, termasuk primata. Istilah ini juga digunakan dalam menggambarkan perburuan hewan langka di benua Afrika. Perburuan Dagi...

Wakil Bupati Luwu TimurPetahanaAkbar Andi Leluasasejak 5 Oktober 2023KediamanRumah Jabatan Wakil BupatiMasa jabatan5 tahunDibentuk27 Agustus 2005Pejabat pertamaSaldy Mansyur Berikut ini adalah daftar Wakil Bupati Luwu Timur dari masa ke masa. No Wakil Bupati[1] Mulai menjabat Akhir menjabat Prd. Ket. Bupati 1 H.Saldy Mansyur 27 Agustus 2005 27 Agustus 2010 1 H.Andi Hatta Marakarma MP 2 Ir. H.Muhammad Thorig Husler 27 Agustus 2010 27 Agustus 2015 2 Lowong 30 Agustus 2015 17 Februa...

Theory that Adolf Hitler only had one testicle Adolf Hitler with Eva Braun and their dogs at the Berghof, Bavaria in June 1942. The possibility that Adolf Hitler had only one testicle has been a fringe subject among historians and academics researching the Nazi leader. The rumor may be an urban myth, possibly originating from the contemporary British military song Hitler Has Only Got One Ball. Hitler's doctor Erwin Giesing [de] and his personal physician Theodor Morell disregarde...

Family of business software products Microsoft Power PlatformDeveloper(s)MicrosoftInitial release2018; 5 years ago (2018)Operating systemMicrosoft WindowsTypeBusiness intelligence, app development, app connectivity, robotic process automationLicenseProprietary softwareWebsitemicrosoft.com/power-platform/ Microsoft Power Platform is a line of business intelligence, app development, and app connectivity software applications.[1][2] Microsoft developed the Power...

Soviet politician, statesman and diplomat (1890–1986) In this name that follows Eastern Slavic naming conventions, the patronymic is Mikhaylovich and the family name is Molotov. Vyacheslav MolotovВячеслав МолотовMolotov in 19453rd Premier of the Soviet UnionIn office19 December 1930 – 6 May 1941Preceded byAlexei RykovSucceeded byJoseph StalinFirst Deputy Premier of the Soviet UnionIn office16 August 1942 – 29 June 1957PremierJoseph StalinGeorgy Malen...

Universitas Hang TuahDidirikan12 Mei 1987RektorLaksamana Muda TNI (Purn) Prof. Dr. Ir. Supartono, MM., CIQaRAlamatJalan Arief Rachman Hakim No. 150 Sukolilo, Surabaya, Jawa Timur, Indonesia KampusPerguruan Tinggi SwastaNama julukanUHTSitus webhangtuah.ac.id Universitas Hang Tuah biasa disingkat sebagai UHT adalah sebuah perguruan tinggi swasta di Kota Surabaya yang berada di bawah naungan Yayasan Nala TNI Angkatan Laut. Sejarah Didorong oleh cinta tanah air dan tanggungjawab terhadap kehidupa...

Indian entertainment company AGS Entertainment Pvt. LtdTypePrivateIndustryEntertainment (motion pictures, movie theatres)Founded2006HeadquartersChennai, Tamil Nadu, India, ChennaiTamilnaduKey peopleKalpathi S. Aghoram Kalpathi S. Ganesh Kalpathi S. Suresh Revenue1.5 BillionOwnerKalpathi S. Aghoram, Kalpathi S. Ganesh, Kalpathi S. SureshNumber of employees133 EmployeesParentKalpathi InvestmentsWebsiteAgs cinemas AGS Entertainment is an Indian film production, distribution company, and multiple...

American voice actor Casey MongilloBornHartford, Connecticut, U.S.[1]OccupationVoice actorYears active2006–presentWebsitewww.caseymongillo.com Casey Mongillo is an American voice actor, who has played roles in animation and video games. Mongillo is best known for portraying lead character Shinji Ikari in the Netflix English dub of Neon Genesis Evangelion in 2019, and has also played Emporio Alniño in JoJo's Bizarre Adventure: Stone Ocean, Shou Suzuki in Mob Psycho 100, and...

スフォリアテッラ スフォリアテッラ スフォリアテッラまたはスフォッリャテッラ (sfogliatella)は、イタリア、ナポリ地方の名物の焼き菓子。その名称はイタリア語でひだを何枚も重ねたという意味を持つ。アマルフィ地方の修道院が発祥であるとの説がある。スフォリアテッレ(sfogliatelle)は複数形。 貝殻をかたどったひだが何層もあるパイ状の生地の中にリコッタチーズ...

Duke of Lower Pannonia Ljudevit/LiudewitDuke of Lower Pannonia[1][b]Reignc. 810 – c. 823SuccessorRatimirDied823Dalmatia Ljudevit (pronounced [ʎûdeʋit]) or Liudewit (Latin: Liudewitus), often also Ljudevit Posavski, was the Duke of the Slavs in Lower Pannonia[1][b] from 810 to 823. The capital of his realm was in Sisak (today in Croatia). As the ruler of the Pannonian Slavs,[2] he led a resistance to Frankish domination. Having lost the war against Fran...

حادثة إطلاق النار في غراند بسام 2016 المعلومات البلد ساحل العاج  الموقع غراند بسام  ساحل العاج الإحداثيات 5°12′00″N 3°44′00″W / 5.2°N 3.7333333333333°W / 5.2; -3.7333333333333  التاريخ 13 مارس 2016 نوع الهجوم قتل جماعي، إطلاق النار الأسلحة بنادق هجومية، قنابل يدوية الخسائر الوفيات...

British discount store chain PoundstretcherTypeSubsidiaryIndustryRetailFounded1981; 42 years ago (1981)FoundersPaul Appell & Stephen FearnleyHeadquartersKirby Muxloe, England, UKNumber of locations350[1][2]Key peopleOwnerAziz TayubParentCrown Crest GroupSubsidiariesBargain BuysPoundstretcher ExtraWebsitepoundstretcher.co.uk A former Poundstretcher Extra location A Poundstretcher location bearing a briefly-used logo Poundstretcher (previously styled as £-...

Abderrahmane FarèsPresiden Aljazair PertamaMasa jabatan3 Juli 1962 – 20 September 1962PendahuluBenyoucef BenkheddaPenggantiFerhat Abbas Informasi pribadiLahir(1911-01-30)30 Januari 1911Amalou, Provinsi BéjaïaMeninggal13 Mei 1991(1991-05-13) (umur 80)Zemmouri, AljazairPartai politikFLNSunting kotak info • L • B Abderrahmane Farès (Arab: عبدالرحمن فارس) (30 Januari 1911 – 13 Mei 1991) adalah Ketua Eksekutif Sementara Aljazair da...

Title in the Peerage of the United Kingdom Dukedom of WestminsterQuarterly: 1st and 4th, Azure a Portcullis with chains pendant Or on a Chief of the last between two united Roses of York and Lancaster a Pale charged with the Arms of King Edward the Confessor (City of Westminster); 2nd and 3rd, Azure a Garb Or (Grosvenor).[1]Creation date27 February 1874Created byQueen VictoriaPeeragePeerage of the United KingdomFirst holderHugh Grosvenor, 3rd Marquess of WestminsterPresent holderHugh ...

Indian politician A major contributor to this article appears to have a close connection with its subject. It may require cleanup to comply with Wikipedia's content policies, particularly neutral point of view. Please discuss further on the talk page. (March 2023) (Learn how and when to remove this template message) In this Indian name, the name Ponnuswamy is a patronymic, and the person should be referred to by the given name, Sivagnanam. Mylai Ponnuswamy SivagnanamSivagnanam on a 2006 stamp...

Darla K. AndersonAnderson pada Oktober 2010LahirDarla Kay AndersonGlendale, California, ASTempat tinggalNoe Valley, San Francisco, California, AS[1]PekerjaanProduserTempat kerjaPixar Animation Studios (1993–2018)Suami/istriKori Rae (2004, 2008–sekarang)[1] Darla Kay Anderson adalah seorang produser film Amerika Serikat yang dulunya berkarya di Pixar Animation Studios.[2] Ia merupakan anggota badan direktur nasional untuk Producers Guild of America.[3] Refer...