Assembly Language Step-by-Step: Programming with Linux

Assembly Language Step-by-Step: Programming with Linux

Language: English

Pages: 648

ISBN: 0470497025

Format: PDF / Kindle (mobi) / ePub


The eagerly anticipated new edition of the bestselling introduction to x86 assembly language

The long-awaited third edition of this bestselling introduction to assembly language has been completely rewritten to focus on 32-bit protected-mode Linux and the free NASM assembler. Assembly is the fundamental language bridging human ideas and the pure silicon hearts of computers, and popular author Jeff Dunteman retains his distinctive lighthearted style as he presents a step-by-step approach to this difficult technical discipline.

He starts at the very beginning, explaining the basic ideas of programmable computing, the binary and hexadecimal number systems, the Intel x86 computer architecture, and the process of software development under Linux. From that foundation he systematically treats the x86 instruction set, memory addressing, procedures, macros, and interface to the C-language code libraries upon which Linux itself is built.

  • Serves as an ideal introduction to x86 computing concepts, as demonstrated by the only language directly understood by the CPU itself
  • Uses an approachable, conversational style that assumes no prior experience in programming of any kind
  • Presents x86 architecture and assembly concepts through a cumulative tutorial approach that is ideal for self-paced instruction
  • Focuses entirely on free, open-source software, including Ubuntu Linux, the NASM assembler, the Kate editor, and the Gdb/Insight debugger
  • Includes an x86 instruction set reference for the most common machine instructions, specifically tailored for use by programming beginners
  • Woven into the presentation are plenty of assembly code examples, plus practical tips on software design, coding, testing, and debugging, all using free, open-source software that may be downloaded without charge from the Internet.

 

 

 

 

 

 

 

 

 

 

 

begin performing the task it represented. As soon as it finishes executing an instruction, the CPU goes out to memory and fetches the next machine instruction in sequence. Inside the CPU is a special register called the instruction pointer that quite literally contains the address of the next instruction to be fetched from memory and executed. Each time an instruction is completed, the instruction pointer is updated to point to the next instruction in memory. (There is some silicon magic afoot

on the CPU, and some number of its machine instructions would execute. However, after a set period of time (usually a small fraction of a second) Windows 95 would ‘‘preempt’’ that first program, and give control of the CPU to the second program on the list. That program would execute instructions for a few milliseconds until it too was preempted. Windows 95 would go down the list, letting each program run for a little while. When it reached the bottom of the list, it would start again at the top

that you can read and change one half of a 16-bit number without disturbing the other half. This means that if you place the word-sized hexadecimal value 76E9H into register AX, you can read the byte-sized value 76H from register AH, and 0E9H from register AL. Better still, if you then store the value 0AH into register AL and then read back register AX, you’ll find that the original value of 76E9H has been changed to 760AH. Being able to treat the AX, BX, CX, and DX registers as 8-bit halves can

shot. The value depends on the individual Linux system, how much memory you have, and what the Linux OS is doing elsewhere in memory. What matters is that a 32-bit hexadecimal value has been moved into ECX. This instruction did the work: mov ecx,EatMsg So what did we actually move? If you scroll up into the earlier part of the source code temporarily, you’ll see that EatMsg is a quoted string of ordinary characters reading ‘‘Eat at Joe’s!’’ and not a 32-bit number; but note the comment to the

had to keep track of the segment registers too; doing it the protected mode way means one less headache. (Don’t worry; there are plenty more!) Click Step Into By Instruction again, and register EDX will be given the value 0xe, or (in decimal) 14. This is the length of the character string EatMsg. At this point all the setup work has been done with respect to moving various values where they need to go. Click the button and execute the next instruction: int 80H It looks like nothing has

Download sample

Download