Assembly Language Step-By-Step: Programming with DOS and Linux

Total Page:16

File Type:pdf, Size:1020Kb

Assembly Language Step-By-Step: Programming with DOS and Linux Assembly Language Step-by-Step: Programming with DOS and Linux, Second Edition by Jeff Duntemann ISBN:0471375233 John Wiley & Sons © 2000 (613 pages) A “Lost World” journey into 16-bit assembler programming concepts and techniques. <?xml version="1.0" encoding="ISO-8859-1"?> Table of Contents Assembly Language Step-by-Step—Programming with DOS and Linux, Second Edition Foreword Introduction - "Why Would You Want to Do That?" Another Pleasant Valley Saturday Understanding What Computers Chapter 1 - Really Do Chapter 2 - Alien Bases Getting Your Arms around Binary and Hexadecimal Chapter 3 - Lifting the Hood Discovering What Computers Actually Are The Right to Assemble The Process of Making Assembly Language Chapter 4 - Programs NASM-IDE: A Place to Stand Give me a lever long enough, and a Chapter 5 - place to stand, and I will move the Earth. An Uneasy Alliance The x86 CPU and Its Segmented Memory Chapter 6 - System Following Your Instructions Meeting Machine Instructions up Close Chapter 7 - and Personal Chapter 8 - Our Object All Sublime Creating Programs that Work Dividing and Conquering Using Procedures and Macros to Battle Chapter 9 - Complexity Bits, Flags, Branches, and Tables Easing into Mainstream Chapter 10 - Assembly Programming Chapter 11 - Stringing Them Up Those Amazing String Instructions The Programmer's View of Linux Tools and Skills to Help You Write Chapter 12 - Assembly Code under a True 32-Bit OS Coding for Linux Applying What You've Learned to a True Chapter 13 - Protected Mode Operating System Conclusion - Not the End, But Only the Beginning Appendix A - Partial 8086/8088 Instruction Set Reference Appendix B - Segment Register Assumptions for Real Mode Segmented Model Appendix C - Web URLs for Assembly Programmers Appendix D - Segment Register Assumptions Appendix E - What's on the CD-ROM? Index List of Figures List of Tables Back Cover The bestselling guide to assembly language--now updated and expanded to include coverage of Linux. This new edition of the bestselling guide to assembly programming now covers DOS and Linux! The Second Edition begins with a highly accessible overview of the internal operations of the Intel-based PC and systematically covers all the steps involved in writing, testing, and debugging assembly programs. Expert author Jeff Duntemann then presents working example programs for both the DOS and Linux operating systems using the popular free assembler NASM. He also inlcudes valuable infomation on how to use procedures and macros, plus rare explanations of assembly-level coding for Linux, all of which combine to offer a comprehensive look at the complexitites of assembly programming for Intel processors. Providing you with the foundation to create executable assembly language programs, this book: Explains how to use NASM-IDE, a simple program editor and assembly-oriented development environment Details the most used elements of the 86-family instruction set Teaches about DEBUG, the single most useful tool you have as an assembly language programmer Examines the operations that machine instructions force the CPU to perform Discusses the process of memory addressing Covers coding for Linux About the Author Jeff Duntemann is the Editor-in-Chief of Visual Developer magazine, former editor of Turbo Technix and PC Techniques, the "Structured Programming" columnist for Dr. Dobb’s Journal, and has written and edited more than twenty programming books. Assembly Language Step-by-Step—Programming with DOS and Linux, Second Edition Jeff Duntemann Wiley Computer Publishing John Wiley & Sons, Inc. NEW YORK • CHICHESTER • WEINHEIM • BRISBANE • SINGAPORE • TORONTO Publisher: Robert Ipsen Editor: Cary Sullivan Managing Editor: Micheline Frederick Text Design & Composition: North Market Street Graphics Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where John Wiley & Sons, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL LETTERS. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration. Copyright © 2000 by Jeff Duntemann. All rights reserved. Published by John Wiley & Sons, Inc. Published simultaneously in Canada. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212) 850-6008, E-Mail: <PERMREQ @ WILEY.COM>. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold with the understanding that the publisher is not engaged in professional services. If professional advice or other expert assistance is required, the services of a competent professional person should be sought. Library of Congress Cataloging-in-Publication Data: Duntemann, Jeff. Assembly language step-by-step : programming with DOS and Linux / Jeff Duntemann.—2nd ed. p. cm. Rev. ed. of: Assembly language, © 1992. ISBN 0-471-37523-3 (paper/CD-ROM : alk. paper) 1. Assembler language (Computer program language)I. Duntemann, Jeff. Assembly language.II. Title. QA76.73.A8 D88 2000 005.265—dc21 00-020611 10 9 8 7 6 5 4 3 2 1 To the eternal memory of Kathleen M. Duntemann, Godmother 1920–1999 who gave me books when all I could do was put teeth marks on them. There are no words for how much I owe you! Acknowledgments First of all, to the authors of the software that I am honored to provide by their permission on this book's CD-ROM: Robert Anderton, author of NASM-IDE: www.inglenook.co.uk/nasmide/ Anthony Williams, author of ALINK: http://alink.home.dhs.org/ And, of course, the NASM team: Julian "Jules" Hall, Simon Tatham, H. Peter Anvin, John Fine, Kendall Bennet, Gary Clark, and Andrew Crabtree: www.web-sites.co.uk/nasm/ Because of their generosity, there is "nothing else to buy." Everything you need to program in assembly is right here on the CD-ROM for this book. Abundant thanks also go to Bill Schindler, for teaching me the ways of the C library, and Michael Abrash, who has always has been the rock upon whom my knowledge of assembly language itself has been anchored. Finally, to Carol, as always, for the sacramental friendship that has challenged me, shaped me, and redeemed me every day of our 30 years together and 23 years as spouses. Foreword Time passes. It was exactly 10 years ago this summer, back in July 1989, when I turned in the manuscript of a book called Assembly Language from Square One. The book was well received, but its publisher went belly-up only a few months after its introduction. That may have been a blessing, because the book was too short, had a few more errors in it than it should have had, and was printed on horrible cheap paper that ripped with almost no provocation and is now turning sickly yellow. So, I leapt on the chance to do the book over and publish it with a real publisher, the most venerable John Wiley & Sons, who (as their T-shirts say) has been totally awesome since 1809. It was thoroughly rewritten and became a new book with a new title, and went on the shelves in September of 1992. Time passes, but in a world where the life of a computer book may well be eight months or less, Wiley kept the first edition of Assembly Language Step-by-Step in print for eight years, from 1992 to 2000. In that time it has probably sold more copies than any other single assembly language book, and I've received hundreds of letters of advice, corrections, suggestions, and simple, "Hey, this is cool!" compliments. Thanks to you all for taking the time to write. It means a lot to me. It's unclear how long this second edition will remain in print, but as long as people keep buying it (and telling me it's been useful to them), I suspect that either this edition or one to follow will remain available. Time passes. And before we get into the book proper, there's something else I wanted to relate. On July 8, 1999, my sister Gretchen Duntemann Roper found that Kathleen Duntemann had died peacefully in her sleep in Chicago, almost 10 years to the day since I had completed Assembly Language from Square One, which was also dedicated to her. She kept both books on her coffee table and would show them to anyone who came to visit, even though she never had a computer and probably never understood what assembly language was. She was my aunt and godmother, my father's sole sibling, who sang my ABCs to me and demanded that I be admitted to Adler Planetarium in Chicago when I was six, even though the rules at that time demanded that children be seven to attend the sky show. "Name the planets for the nice man," she told me, and I did, and when I had gone through all the planets I started in on the constellations. I got in, because she believed in me. And she was there through every other major milestone in my life: First Communion, Confirmation, wedding, my father's illness and death, years and years of Christmases and Thanksgivings and birthdays, always with treats for the dog and stories to tell, with a quick Irish wit and a generous heart-and truly I cannot and will not ever forget her.
Recommended publications
  • Hacker's Handbook for Ringzer0 Training, by Steve Lord
    Hacker’s Handbook For Ringzer0 Training, by Steve Lord This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Copyright ©2021 Raw Hex Ltd. All Rights Reserved. Retro Zer0 is a trademark of Ring Zer0 Training. Raw Hex is a trademark of Raw Hex Ltd. All other trademarks are the property of their respective owners. Raw Hex Ltd reserve the right to make changes or improvements to equipment, software and documentation herein described at any time and without notice. Notice: Please be advised that your Retro Zer0 has no warranty, and that tampering with the internal hardware and software of your Ring Zer0 is widely encouraged as long as you do so with appropriate regard to safety. Contents 1 Preface 5 1.1 Safety ........................... 6 1.2 Understanding This Document ............ 6 2 Before You Start 7 2.1 Check You Have Everything .............. 7 2.2 Back Up The SD Card ................. 8 2.3 Connecting Up Your Retro Zer0 ............ 8 2.4 Powering Up ....................... 10 2.5 Resetting Your Retro Zer0 . 10 2.6 Powering Down ..................... 10 3 First Steps 11 3 4 CONTENTS 3.1 Testing The Keyboard . 11 3.2 Using CP/M ....................... 12 3.3 Would You Like To Play A Game? . 14 3.4 MultiCPM Extras ..................... 17 3.5 Useful Tools ....................... 19 3.6 What’s On The Card? . 20 3.7 Putting It All Together . 23 3.8 Where To Read More . 25 4 Being Productive With Retro Zer0 27 4.1 WordStar .........................27 4.2 Supercalc .........................30 4.3 DBase ...........................32 4.4 Microsoft BASIC .....................32 4.5 Turbo Pascal .......................34 4.6 Forth 83 .........................36 4.7 ZDE ............................38 4.8 Z80 Assembler .....................39 4.9 Hi-Tech C .........................43 4.10 XLisp ...........................46 CONTENTS 5 4.11 Installing New Software .
    [Show full text]
  • 2. Assembly Language Assembly Language Is a Programming Language That Is Very Similar to Machine Language, but Uses Symbols Instead of Binary Numbers
    2. Assembly Language Assembly Language is a programming language that is very similar to machine language, but uses symbols instead of binary numbers. It is converted by the assembler into executable machine- language programs. Assembly language is machine-dependent; an assembly program can only be executed on a particular machine. 2.1 Introduction to Assembly Language Tools Practical assembly language programs can, in general, be written using one of the two following methods: 1- The full-segment definition form 2- The simplified segment definition form In both methods, the source program includes two types of instructions: real instructions, and pseudo instructions. Real instructions such as MOV and ADD are the actual instructions that are translated by the assembler into machine code for execution by the CPU. Pseudo instructions, on the other hand, don’t generate machine code and are only used to give directions to the assembler about how it should translate the assembly language instructions into machine code. The assembler program converts the written assembly language file (called source file) into machine code file (called object file). Another program, known as the linker, converts the object file into an executable file for practical run. It also generates a special file called the map file which is used to get the offset addresses of the segments in the main assembly program as shown in figure 1. Other tools needed in assembling coding include a debugger, and an editor as shown in figure 2 Figure 2. Program Development Procedure There are several commercial assemblers available like the Microsoft Macro Assembler (MASM), and the Borland Turbo Assembler (TASM).
    [Show full text]
  • NASM – the Netwide Assembler
    NASM – The Netwide Assembler version 2.14rc7 © 1996−2017 The NASM Development Team — All Rights Reserved This document is redistributable under the license given in the file "LICENSE" distributed in the NASM archive. Contents Chapter 1: Introduction . 17 1.1 What Is NASM?. 17 1.1.1 License Conditions . 17 Chapter 2: Running NASM . 19 2.1 NASM Command−Line Syntax . 19 2.1.1 The −o Option: Specifying the Output File Name . 19 2.1.2 The −f Option: Specifying the Output File Format . 20 2.1.3 The −l Option: Generating a Listing File . 20 2.1.4 The −M Option: Generate Makefile Dependencies. 20 2.1.5 The −MG Option: Generate Makefile Dependencies . 20 2.1.6 The −MF Option: Set Makefile Dependency File. 20 2.1.7 The −MD Option: Assemble and Generate Dependencies . 20 2.1.8 The −MT Option: Dependency Target Name . 21 2.1.9 The −MQ Option: Dependency Target Name (Quoted) . 21 2.1.10 The −MP Option: Emit phony targets . 21 2.1.11 The −MW Option: Watcom Make quoting style . 21 2.1.12 The −F Option: Selecting a Debug Information Format . 21 2.1.13 The −g Option: Enabling Debug Information. 21 2.1.14 The −X Option: Selecting an Error Reporting Format . 21 2.1.15 The −Z Option: Send Errors to a File. 22 2.1.16 The −s Option: Send Errors to stdout ..........................22 2.1.17 The −i Option: Include File Search Directories . 22 2.1.18 The −p Option: Pre−Include a File . 22 2.1.19 The −d Option: Pre−Define a Macro .
    [Show full text]
  • NASM — the Netwide Assembler Version 2.09.04
    NASM — The Netwide Assembler version 2.09.04 -~~..~:#;L .-:#;L,.- .~:#:;.T -~~.~:;. .~:;. E8+U *T +U' *T# .97 *L E8+' *;T' *;, D97 `*L .97 '*L "T;E+:, D9 *L *L H7 I# T7 I# "*:. H7 I# I# U: :8 *#+ , :8 T, 79 U: :8 :8 ,#B. .IE, "T;E* .IE, J *+;#:T*" ,#B. .IE, .IE, © 1996−2010 The NASM Development Team — All Rights Reserved This document is redistributable under the license given in the file "LICENSE" distributed in the NASM archive. Contents Chapter 1: Introduction . .15 1.1 What Is NASM? . .15 1.1.1 Why Yet Another Assembler?. .15 1.1.2 License Conditions . .15 1.2 Contact Information . .16 1.3 Installation. .16 1.3.1 Installing NASM under MS−DOS or Windows . .16 1.3.2 Installing NASM under Unix . .17 Chapter 2: Running NASM . .18 2.1 NASM Command−Line Syntax . .18 2.1.1 The −o Option: Specifying the Output File Name . .18 2.1.2 The −f Option: Specifying the Output File Format . .19 2.1.3 The −l Option: Generating a Listing File . .19 2.1.4 The −M Option: Generate Makefile Dependencies . .19 2.1.5 The −MG Option: Generate Makefile Dependencies . .19 2.1.6 The −MF Option: Set Makefile Dependency File . .19 2.1.7 The −MD Option: Assemble and Generate Dependencies. .19 2.1.8 The −MT Option: Dependency Target Name. .20 2.1.9 The −MQ Option: Dependency Target Name (Quoted) . .20 2.1.10 The −MP Option: Emit phony targets. .20 2.1.11 The −F Option: Selecting a Debug Information Format .
    [Show full text]
  • C++ Builder 2010 Professional Getting Started
    C++ Builder 2010 Professional Getting started. Kjell Gunnar Bleivik: http://www.kjellbleivik.com/ October 18. 2010. Fixed broken link. Status: Most probably finished. Look at the date in case more should be added. Follow me on Twitter and join my C++ Builder group on Facebook: Twitter: http://twitter.com/kbleivik FaceBook: http://www.facebook.com/people/Kjell-Gunnar-Bleivik/1244860831 Mini network: http://www.digitalpunkt.no/ 1. Installing C++Builder 2010, the help system etc. I ordered my upgrade of Borland C++ Builder Prosessional 2010 on September 21 2009 so I could choose an additional free product. I choose Delphi PHP 2.0, since I am fairly used to PHP. In order to install C++ Builder 2010, I had to upgrade my 2009 version. I have made an 2009 and 2010 upgrade shortcut on my desktop. You should find your upgrade program: | your start menu or in | the all program category | CodeGear RAD studio 2009 | Check for updates | Program | When finished upgrading the 2009 Builder, I could run the C++ Builder 2010 Setup program. In addition, I installed the additional first three programs that I also find in the Install Folder. Look at the screendumps below, so you get it correct. • Help_Setup Program • dbpack_setup Program • boost_setup Program • Additional_Products HTML document. • ERStudio_Interbase HTML document 2. Getting started with C++ Builder 2010 Professional. If you learn to use the welcome page efficiently, that may be all you need. On the “documentation” menu, you should start with, yes “Getting started” and then “RAD Studio Help” and so on. As an example click: | Documentation | … and try to locate this http://docs.embarcadero.com/products/rad_studio/ page with Wiki pages, PDF documents, zipped code examples for download, PDF documents since C++Builder 6 (scroll down to the bottom) and CHM http://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help files.
    [Show full text]
  • Optimizing Subroutines in Assembly Language an Optimization Guide for X86 Platforms
    2. Optimizing subroutines in assembly language An optimization guide for x86 platforms By Agner Fog. Copenhagen University College of Engineering. Copyright © 1996 - 2012. Last updated 2012-02-29. Contents 1 Introduction ....................................................................................................................... 4 1.1 Reasons for using assembly code .............................................................................. 5 1.2 Reasons for not using assembly code ........................................................................ 5 1.3 Microprocessors covered by this manual .................................................................... 6 1.4 Operating systems covered by this manual................................................................. 7 2 Before you start................................................................................................................. 7 2.1 Things to decide before you start programming .......................................................... 7 2.2 Make a test strategy.................................................................................................... 9 2.3 Common coding pitfalls............................................................................................. 10 3 The basics of assembly coding........................................................................................ 12 3.1 Assemblers available ................................................................................................ 12 3.2 Register set
    [Show full text]
  • X86 Disassembly Exploring the Relationship Between C, X86 Assembly, and Machine Code
    x86 Disassembly Exploring the relationship between C, x86 Assembly, and Machine Code PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Sat, 07 Sep 2013 05:04:59 UTC Contents Articles Wikibooks:Collections Preface 1 X86 Disassembly/Cover 3 X86 Disassembly/Introduction 3 Tools 5 X86 Disassembly/Assemblers and Compilers 5 X86 Disassembly/Disassemblers and Decompilers 10 X86 Disassembly/Disassembly Examples 18 X86 Disassembly/Analysis Tools 19 Platforms 28 X86 Disassembly/Microsoft Windows 28 X86 Disassembly/Windows Executable Files 33 X86 Disassembly/Linux 48 X86 Disassembly/Linux Executable Files 50 Code Patterns 51 X86 Disassembly/The Stack 51 X86 Disassembly/Functions and Stack Frames 53 X86 Disassembly/Functions and Stack Frame Examples 57 X86 Disassembly/Calling Conventions 58 X86 Disassembly/Calling Convention Examples 64 X86 Disassembly/Branches 74 X86 Disassembly/Branch Examples 83 X86 Disassembly/Loops 87 X86 Disassembly/Loop Examples 92 Data Patterns 95 X86 Disassembly/Variables 95 X86 Disassembly/Variable Examples 101 X86 Disassembly/Data Structures 103 X86 Disassembly/Objects and Classes 108 X86 Disassembly/Floating Point Numbers 112 X86 Disassembly/Floating Point Examples 119 Difficulties 121 X86 Disassembly/Code Optimization 121 X86 Disassembly/Optimization Examples 124 X86 Disassembly/Code Obfuscation 132 X86 Disassembly/Debugger Detectors 137 Resources and Licensing 139 X86 Disassembly/Resources 139 X86 Disassembly/Licensing 141 X86 Disassembly/Manual of Style 141 References Article Sources and Contributors 142 Image Sources, Licenses and Contributors 143 Article Licenses License 144 Wikibooks:Collections Preface 1 Wikibooks:Collections Preface This book was created by volunteers at Wikibooks (http:/ / en.
    [Show full text]
  • Different Emulators to Write 8086 Assembly Language Programs
    Different Emulators to write 8086 assembly language programs Subject: IWM Content • Emu8086 • TASM(Turbo Assembler) • MASM(Microsoft Macro Assembler) • NASM(Netwide Assembler) • FASM(Flat Assembler) Emu8086 • Emu8086 combines an advanced source editor, assembler, disassembler, software emulator with debugger, and step by step tutorials • It permit to assemble, emulate and debug 8086 programs. • This emulator was made for Windows, it works fine on GNU/Linux (with the help of Wine). • The source code is compiled by assembler and then executed on Emulator step-by-step, allowing to watch registers, flags and memory while program runs. how to run program on Emu8086 • Download Emu8086 through this link : https://download.cnet.com/Emu8086-Microprocessor- Emulator/3000-2069_4-10392690.html • Start Emu8086 by running Emu8086.exe • Select “Examples" from "File" menu. • Click “Emulate” button (or press F5). • Click “Single Step” button (or press F8) and watch how the code is being executed. Turbo Assembler(Tasm) • Turbo Assembler (TASM) is a computer assembler developed by Borland which runs on and produces code for 16- or 32-bit x86 DOS or Microsoft Windows. • The Turbo Assembler package is bundled with the Turbo Linker, and is interoperable with the Turbo Debugger. • Turbo Assembler (TASM) a small 16-bit computer program which enables us to write 16 bit i.e. x86 programming code on 32-bit machine. It can be used with any high level language compliers like GCC compiler set to build object files. So that programmers can use their daily routine machines to write 16-bit code and execute on x86 devices. how to run program using TASM • Download TASM through this link : https://techapple.net/2013/01/tasm-windows-7-windows-8-full- screen-64bit-version-single-installer/ • Start TASM by running tasm.exe • It will open DOSBOX.
    [Show full text]
  • First Osborne Group (FOG) Records
    http://oac.cdlib.org/findaid/ark:/13030/c8611668 No online items First Osborne Group (FOG) records Finding aid prepared by Jack Doran and Sara Chabino Lott Processing of this collection was made possible through generous funding from the National Archives’ National Historical Publications & Records Commission: Access to Historical Records grant. Computer History Museum 1401 N. Shoreline Blvd. Mountain View, CA, 94043 (650) 810-1010 [email protected] August, 2019 First Osborne Group (FOG) X4071.2007 1 records Title: First Osborne Group (FOG) records Identifier/Call Number: X4071.2007 Contributing Institution: Computer History Museum Language of Material: English Physical Description: 26.57 Linear feet, 3 record cartons, 5 manuscript boxes, 2 periodical boxes, 18 software boxes Date (bulk): Bulk, 1981-1993 Date (inclusive): 1979-1997 Abstract: The First Osborne Group (FOG) records contain software and documentation created primarily between 1981 and 1993. This material was created or authored by FOG members for other members using hardware compatible with CP/M and later MS and PC-DOS software. The majority of the collection consists of software written by FOG members to be shared through the library. Also collected are textual materials held by the library, some internal correspondence, and an incomplete collection of the FOG newsletters. creator: First Osborne Group. Processing Information Collection surveyed by Sydney Gulbronson Olson, 2017. Collection processed by Jack Doran, 2019. Access Restrictions The collection is open for research. Publication Rights The Computer History Museum (CHM) can only claim physical ownership of the collection. Users are responsible for satisfying any claims of the copyright holder. Requests for copying and permission to publish, quote, or reproduce any portion of the Computer History Museum’s collection must be obtained jointly from both the copyright holder (if applicable) and the Computer History Museum as owner of the material.
    [Show full text]
  • Lab # 1 Introduction to Assembly Language
    Assembly Language LAB Islamic University – Gaza Engineering Faculty Department of Computer Engineering 2013 ECOM 2125: Assembly Language LAB Eng. Ahmed M. Ayash Lab # 1 Introduction to Assembly Language February 11, 2013 Objective: To be familiar with Assembly Language. 1. Introduction: Machine language (computer's native language) is a system of impartible instructions executed directly by a computer's central processing unit (CPU). Instructions consist of binary code: 1s and 0s Machine language can be made directly from java code using interpreter. The difference between compiling and interpreting is as follows. Compiling translates the high-level code into a target language code as a single unit. Interpreting translates the individual steps in a high-level program one at a time rather than the whole program as a single unit. Each step is executed immediately after it is translated. C, C++ code is executed faster than Java code, because they transferred to assembly language before machine language. 1 Using Visual Studio 2012 to convert C++ program to assembly language: - From File menu >> choose new >> then choose project. Or from the start page choose new project. - Then the new project window will appear, - choose visual C++ and win32 console application - The project name is welcome: This is a C++ Program that print "Welcome all to our assembly Lab 2013” 2 To run the project, do the following two steps in order: 1. From build menu choose build Welcome. 2. From debug menu choose start without debugging. The output is To convert C++ code to Assembly code we follow these steps: 1) 2) 3 3) We will find the Assembly code on the project folder we save in (Visual Studio 2012\Projects\Welcome\Welcome\Debug), named as Welcome.asm Part of the code: 2.
    [Show full text]
  • Practical C++ Programming Copyright 2003 O'reilly and Associates Page 1 I/O Packages
    Chapter - 16 File Input/ Output Practical C++ Programming Copyright 2003 O'Reilly and Associates Page 1 I/O Packages There are 3 different I/O packages available to the C++ programmer: • The C++ streams package. This package is used for most I/O. • The unbuffered I/O package. Used primarily for large file I/O and other special operations. • The C stdio package. Many older, C-- programs use this package. (A C-- program is a C program that has been updated to compile with a C++ compiler, but uses none of the new features of the new language.) This package is useful for some special operations. Practical C++ Programming Copyright 2003 O'Reilly and Associates Page 2 C++ I/O C++ provides four standard class variables for standard I/O. Variable Use std::cin Console in (standard input) std::cout Console output (standard output) std::cerr Console error (standard error) std::clog Console log Normally std::cin reads from the keyboard, and std::cout, cerr, and clog go to the screen. Most operating systems allow I/O redirection my_prog <file.in my_prog >file.out Practical C++ Programming Copyright 2003 O'Reilly and Associates Page 3 File I/O File I/O is accomplished using the <fstream.h> package. Input is done with the ifstream class and output with the ofstream class. Example: ifstream data_file; // File for reading the data from data_file.open("numbers.dat"); for (i = 0; i < 100; ++i) data_file >> data_array[i]; data_file.close(); Open can be consolidated with the constructor. ifstream data_file("numbers.dat"); The close will automatically be done by the destructor.
    [Show full text]
  • HUMBUG® 68000 Version
    HUMBUG® 68000 Version by Peter A. Stark Copyright © 1986 - 1990 by Peter A. Stark Star-K Software Systems Corporation P. O. Box 209 Mt. Kisco, N. Y. 10549 All rights reserved Copyright © 1986 - 1990 by Peter A. Stark All Star-K computer programs are licensed on an "as is" basis without warranty. Star-K Software Systems Corporation shall have no liability or responsibility to customer or any other person or entity with respect to any liability, loss or damage caused or alleged to be caused directly or indirectly by computer equipment or programs sold by Star-K, including but not limited to any interruption of service, loss of business or anticipatory profits or consequential damages resulting from the use or operation of such computer or computer programs. Good data processing procedure dictates that the user test the program, run and test sample sets of data, and run the system in parallel with the system previously in use for a period of time adequate to insure that results of operation of the computer or program are satisfactory. SOFTWARE LICENSE A. Star-K Software Systems Corp. grants to customer a non-exclusive, paid up license to use on customer's computer the Star-K computer software received. Title to the media on which the software is recorded (cassette and/or disk) or stored (ROM) is transferred to customer, but not title to the software. B. In consideration of this license, customer shall not reproduce copies of Star-K software except to reproduce the number of copies required for use on customer's computer and shall include the copyright notice on all copies of software reproduced in whole or in part.
    [Show full text]