Your First Program
Jo Van Hoey
Abstract
Jo Van Hoey
Abstract
Generations of programmers have started their programming careers by learning how to display hello, world on a computer screen. It is a tradition that was started in the seventies by Brian W. Kernighan in the book he wrote with Dennis Ritchie, The C Programming Language . Kernighan developed the C programming language at Bell Labs. Since then, the C language has changed a lot but has remained the language that every self-respecting programmer should be familiar with. The majority of “modern” and “fancy” programming languages have their roots in C. C is sometimes called a portable assembly language, and as an aspiring assembly programmer, you should get familiar with C. To honor the tradition, we will start with an assembler program to put hello, world on your screen. Listing 1-1 shows the source code for an assembly language version of the hello, world program, which we will analyze in this chapter. ;hello.asm section .data msg db "hello, world",0 section .bss section .text global main main: mov rax, 1 ; 1 = write mov rdi, 1 ; 1 = to stdout mov rsi, msg ; string to display in rsi mov rdx, 12 ; length of the string, without 0 syscall ; display the string mov rax, 60 ; 60 = exit mov rdi, 0 ; 0 = success exit code syscall ; quit
A significance statement is not available in the OpenAlex record.
A contribution statement is not available in the OpenAlex record.
Method details are not available in the OpenAlex metadata.
Findings are not separately available in the OpenAlex metadata.
Limitations are not available in the OpenAlex metadata.
Application details are not available in the OpenAlex metadata.
Generations of programmers have started their programming careers by learning how to display hello, world on a computer screen. It is a tradition that was started in the seventies by Brian W. Kernighan in the book he wrote with Dennis Ritchie, The C Programming Language . Kernighan developed the C programming language at Bell Labs. Since then, the C language has changed a lot but has remained the language that every self-respecting programmer should be familiar with. The majority of “modern” and “fancy” programming languages have their roots in C. C is sometimes called a portable assembly language, and as an aspiring assembly programmer, you should get familiar with C. To honor the tradition, we will start with an assembler program to put hello, world on your screen. Listing 1-1 shows the source code for an assembly language version of the hello, world program, which we will analyze in this chapter. ;hello.asm section .data msg db "hello, world",0 section .bss section .text global main main: mov rax, 1 ; 1 = write mov rdi, 1 ; 1 = to stdout mov rsi, msg ; string to display in rsi mov rdx, 12 ; length of the string, without 0 syscall ; display the string mov rax, 60 ; 60 = exit mov rdi, 0 ; 0 = success exit code syscall ; quit
Key concepts: Programmer, Listing (finance), Programming language, Computer science, Assembly language, Code (set theory), Honor, Software