RSSAmplifier

Blog

Programming from the Ground Up

An introduction to programming using linux assembly language

programminggroundup.blogspot.comRSS feed ↗23 posts

Latest posts

Chapter 1: Introduction

Welcome to Programming I love programming. I enjoy the challenge to not only make a working program, but to do so with style. Programming is like poetry. It conveys a message, not only to the computer, but to those who modify and use your program. With a program, you build your own world with your own rules. You create your world according to your conception of both the problem and the solution.…

Programming from the Ground Up

Jonathan Bartlett Edited by Dominick Bruno, Jr. Copyright © 2004 by Jonathan Bartlett Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is…

Appendix I: Personal Dedication

There are so many people I could thank. I will name here but a few of the people who have brought me to where I am today. The many family members, Sunday School teachers, youth pastors, school teachers, friends, and other relationships that God has brought into my life to lead me, help me, and teach me are too many to count. This book is dedicated to you all. There are some people, however, that I…

Appendix H: GNU Free Documentation License

0. PREAMBLE The purpose of this License is to make a manual, textbook, or other written document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered…

Appendix G: Document History

12/17/2002 - Version 0.5 - Initial posting of book under GNU FDL 07/18/2003 - Version 0.6 - Added ASCII appendix, finished the discussion of the CPU in the Memory chapter, reworked exercises into a new format, corrected several errors. Thanks to Harald Korneliussen for the many suggestions and the ASCII table. 01/11/2004 - Version 0.7 - Added C translation appendix, added the beginnings of an…

Appendix F: Using the GDB Debugger

Overview By the time you read this appendix, you will likely have written at least one program with an error in it. In assembly language, even minor errors usually have results such as the whole program crashing with a segmentation fault error. In most programming languages, you can simply print out the values in your variables as you go along, and use that output to find out where you went wrong.…

Appendix E: C Idioms in Assembly Language

This appendix is for C programmers learning assembly language. It is meant to give a general idea about how C constructs can be implemented in assembly language. If Statement In C, an if statement consists of three parts - the condition, the true branch, and the false branch. However, since assembly language is not a block structured language, you have to work a little to implement the block-like…

Appendix D: Table of ASCII Codes

To use this table, simply find the character or escape that you want the code for, and add the number on the left and the top. Table D-1: Table of ASCII codes in decimal +0 +1 +2 +3 +4 +5 +6 +7 0 NUL SOH STX ETX EOT ENQ ACK BEL 8 BS HT LF VT FF CR SO SI 16 DLE DC1 DC2 DC3 DC4 NAK SYN ETB 24 CAN EM SUB ESC FS GS RS US 32 ! " # $ % & ' 40 ( ) * + , - . / 48 0 1 2 3 4 5 6 7 56 8 9 : ; = > ? 64 @ A B…

Appendix C: Important System Calls

These are some of the more important system calls to use when dealing with Linux. For most cases, however, it is best to use library functions rather than direct system calls, because the system calls were designed to be minimalistic while the library functions were designed to be easy to program with. For information about the Linux C library, see the manual at…

Appendix B: Common x86 Instructions

Reading the Tables The tables of instructions presented in this appendix include: The instruction code The operands used The flags used A brief description of what the instruction does In the operands section, it will list the type of operands it takes. If it takes more than one operand, each operand will be separated by a comma. Each operand will have a list of codes which tell whether the…

Appendix A: GUI Programming

Introduction to GUI Programming The purpose of this appendix is not to teach you how to do Graphical User Interfaces. It is simply meant to show how writing graphical applications is the same as writing other applications, just using an additional library to handle the graphical parts. As a programmer you need to get used to learning new libraries. Most of your time will be spent passing data from…

Chapter 13: Moving on From Here

Overview Congratulations on getting this far. You should now have a basis for understanding the issues involved in many areas of programming. Even if you never use assembly language again, you have gained a valuable perspective and mental framework for understanding the rest of computer science. There are essentially three methods to learn to program: From the Bottom Up - This is how this book…

Chapter 12: Optimization

Optimization is the process of making your application run more effectively. You can optimize for many things - speed, memory space usage, disk space usage, etc. This chapter, however, focuses on speed optimization. When to Optimize It is better to not optimize at all than to optimize too soon. When you optimize, your code generally becomes less clear, because it becomes more complex. Readers of…

Chapter 11: High-Level Languages

Overview In this chapter we will begin to look at our first "real-world" programming language. Assembly language is the language used at the machine's level, but most people find coding in assembly language too cumbersome for everyday use. Many computer languages have been invented to make the programming task easier. Knowing a wide variety of languages is useful for many reasons, including…

Chapter 10: Counting like a Computer

Counting Counting like a Human In many ways, computers count just like humans. So, before we start learning how computers count, let's take a deeper look at how we count. How many fingers do you have? No, it's not a trick question. Humans (normally) have ten fingers. Why is that significant? Look at our numbering system. At what point does a one-digit number become a two-digit number? That's…

Chapter 9: Intermediate Memory Topics

How a Computer Views Memory Let's review how memory within a computer works. You may also want to re-read Chapter 2 . A computer looks at memory as a long sequence of numbered storage locations. A sequence of millions of numbered storage locations. Everything is stored in these locations. Your programs are stored there, your data is stored there, everything. Each storage location looks like every…

Chapter 8: Sharing Functions with Code Libraries

Overview By now you should realize that the computer has to do a lot of work even for simple tasks. Because of that, you have to do a lot of work to write the code for a computer to even do simple tasks. In addition, programming tasks are usually not very simple. Therefore, we neeed a way to make this process easier on ourselves. There are several ways to do this, including: Write code in a…

Chapter 7: Developing Robust Programs

This chapter deals with developing programs that are robust. Robust programs are able to handle error conditions gracefully. They are programs that do not crash no matter what the user does. Building robust programs is essential to the practice of programming. Writing robust programs takes discipline and work - it usually entails finding every possible problem that can occur, and coming up with an…

Chapter 6: Reading and Writing Simple Records

Overview As mentioned in Chapter 5 , many applications deal with data that is persistent - meaning that the data lives longer than the program by being stored on disk in files. You can shut down the program and open it back up, and you are back where you started. Now, there are two basic kinds of persistent data - structured and unstructured. Unstructured data is like what we dealt with in the…

Chapter 5: Dealing with Files

A lot of computer programming deals with files. After all, when we reboot our computers, the only thing that remains from previous sessions are the things that have been put on disk. Data which is stored in files is called persistent data, because it persists in files that remain on the disk even when the program isn't running.. The UNIX File Concept Each operating system has its own way of…

Chapter 4: All About Functions

Dealing with Complexity In Chapter 3 , the programs we wrote only consisted of one section of code. However, if we wrote real programs like that, it would be impossible to maintain them. It would be really difficult to get multiple people working on the project, as any change in one part might adversely affect another part that another developer is working on. To assist programmers in working…

Chapter 3: Your First Programs

In this chapter you will learn the process for writing and building Linux assembly-language programs. In addition, you will learn the structure of assembly-language programs, and a few assembly-language commands. As you go through this chapter, you may want to refer also to Appendix B and Appendix F . These programs may overwhelm you at first. However, go through them with diligence, read them and…

Chapter 2: Computer Architecture

Before learning how to program, you need to first understand how a computer interprets programs. You don't need a degree in electrical engineering, but you need to understand some basics. Modern computer architecture is based off of an architecture called the Von Neumann architecture, named after its creator. The Von Neumann architecture divides the computer up into two main parts - the CPU (for…