Example: bankruptcy

PC Assembly Language - GitHub Pages

PC Assembly LanguagePaul A. CarterNovember 16, 2019 This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike International License. To view a copy of this license, Number Systems .. Computer Organization .. CPU .. 80x86 family of CPUs .. 16-bit Registers .. 32-bit registers .. Mode .. Protected Mode.. Protected Mode .. Assembly Language .. Language .. Language .. operands .. instructions .. and Output .. Creating a Program .. program .. dependencies .. the code .. the C code .. the object files .. an Assembly listing file .. Skeleton File .. 252 Basic Assembly Working with Integers.

languages such as C and C++. Learning to program in assembly language is an excellent way to achieve this goal. Other PC assembly language books still teach how to program the 8086 processor that the original PC used in 1981! The 8086 processor only supported real mode. In this mode, any program may address any memory or device in the computer ...

Tags:

  Language, Assembly, Assembly language, 8086

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of PC Assembly Language - GitHub Pages

1 PC Assembly LanguagePaul A. CarterNovember 16, 2019 This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike International License. To view a copy of this license, Number Systems .. Computer Organization .. CPU .. 80x86 family of CPUs .. 16-bit Registers .. 32-bit registers .. Mode .. Protected Mode.. Protected Mode .. Assembly Language .. Language .. Language .. operands .. instructions .. and Output .. Creating a Program .. program .. dependencies .. the code .. the C code .. the object files .. an Assembly listing file .. Skeleton File .. 252 Basic Assembly Working with Integers.

2 Representation .. extension .. s complement arithmetic.. program .. precision arithmetic .. Control Structures .. instructions .. loop instructions .. Translating Standard Control Structures .. statements .. loops.. while loops .. Example: Finding Prime Numbers .. 433 Bit Shift Operations .. shifts .. of shifts .. shifts .. shifts .. application .. Boolean Bitwise Operations .. of bit operations .. Avoiding Conditional Branches .. Manipulating bits in C .. bitwise operators of C .. bitwise operators in C .. Big and Little Endian Representations.

3 To Care About Little and Big Endian .. Counting Bits .. one .. two .. three .. 62 CONTENTSiii4 Indirect Addressing .. Simple Subprogram Example .. The Stack .. The CALL and RET Instructions .. Calling Conventions .. parameters on the stack .. variables on the stack .. Multi-Module Programs .. Interfacing Assembly with C .. registers .. of functions .. parameters .. addresses of local variables .. values .. calling conventions .. C functions from Assembly .. Reentrant and Recursive Subprograms .. subprograms .. of C variable storage types .. 915 Introduction.

4 Arrays .. elements of arrays .. advanced indirect addressing .. Arrays .. Array/String Instructions .. and writing memory .. prefix .. string instructions .. prefixes .. 1116 Floating Floating Point Representation .. binary numbers .. floating point representation .. Floating Point Arithmetic .. and division .. for programming .. The Numeric Coprocessor .. formula .. array from file .. primes .. 1357 Structures and C++ Structures .. alignment .. Fields .. structures in Assembly .. Assembly and C++ .. and Name Mangling .. functions .. and Polymorphism .. C++ features .. 171A 80x86 Non-floating Point Instructions.

5 Floating Point Instructions .. 179 PrefacePurposeThe purpose of this book is to give the reader a better understanding ofhow computers really work at a lower level than in programming languageslike Pascal. By gaining a deeper understanding of how computers work, thereader can often be much more productive developing software in higher levellanguages such as C and C++. Learning to program in Assembly languageis an excellent way to achieve this goal. Other PC Assembly Language booksstill teach how to program the 8086 processor that the original PC used in1981! The 8086 processor only supportedrealmode. In this mode, anyprogram may address any memory or device in the computer. This mode isnot suitable for a secure, multitasking operating system.

6 This book insteaddiscusses how to program the 80386 and later processors inprotectedmode(the mode that Windows and Linux runs in). This mode supports thefeatures that modern operating systems expect, such as virtual memory andmemory protection. There are several reasons to use protected mode:1. It is easier to program in protected mode than in the 8086 real modethat other books All modern PC operating systems run in protected There is free software available that runs in this lack of textbooks for protected mode PC Assembly programming is themain reason that the author wrote this alluded to above, this text makes use of Free/Open Source software:namely, the NASM assembler and the DJGPP C/C++ compiler.

7 Bothof these are available to download from the Internet. The text also dis-cusses how to use NASM Assembly code under the Linux operating sys-tem and with Borland s and Microsoft s C/C++ compilers under Win-dows. Examples for all of these platforms can be found on my web site: Youmustdownload the examplecode if you wish to assemble and run many of the examples in this aware that this text does not attempt to cover every aspect of assem-bly programming. The author has tried to cover the most important topicsthatallprogrammers should be acquainted author would like to thank the many programmers around the worldthat have contributed to the Free/Open Source movement. All the programsand even this book itself were produced using free software.

8 Specifically, theauthor would like to thank John S. Fine, Simon Tatham, Julian Hall andothers for developing the NASM assembler that all the examples in thisbook are based on; DJ Delorie for developing the DJGPP C/C++ compilerused; the numerous people who have contributed to the GNU gcc compileron which DJGPP is based on; Donald Knuth and others for developing theTEX and LATEX 2 typesetting languages that were used to produce the book;Richard Stallman (founder of the Free Software Foundation), Linus Torvalds(creator of the Linux kernel) and others who produced the underlying soft-ware the author used to produce this to the following people for corrections: John S. Fine Marcelo Henrique Pinto de Almeida Sam Hopkins Nick D Imperio Jeremiah Lawrence Ed Beroset Jerry Gembarowski Ziqiang Peng Eno Compton Josh I Cates Mik Mifflin Luke Wallis Gaku Ueda Brian Hewardvii Chad Gorshing F.

9 Gotti Bob Wilkinson Markus Koegel Louis Taber Dave Kiddell Eduardo Horowitz S ebastien Le Ray Nehal Mistry Jianyue Wang Jeremias Kleer Marc Janicki Trevor Hansen Giacomo Bruschi Leonardo Rodr guez M ujica Ulrich Bicheler Wu Xing Oleksandr BaranyukResources on the InternetAuthor s SourceForge Art of author welcomes any feedback on this Number SystemsMemory in a computer consists of numbers. Computer memory doesnot store these numbers in decimal (base 10). Because it greatly simplifiesthe hardware, computers store all information in a binary (base 2) let s review the decimal DecimalBase 10 numbers are composed of 10 possible digits (0-9). Each digit ofa number has a power of 10 associated with it based on its position in thenumber.

10 For example:234 = 2 102+ 3 101+ 4 BinaryBase 2 numbers are composed of 2 possible digits (0 and 1). Each digitof a number has a power of 2 associated with it based on its position in thenumber. (A single binary digit is called a bit.) For example1:110012= 1 24+ 1 23+ 0 22+ 0 21+ 1 20= 16 + 8 + 1= 25 This shows how binary may be converted to decimal. Table showshow the first few numbers are represented in shows how individual binary digits ( , bits) are s an example:1 The 2 subscript is used to show that the number is represented in binary, not decimal12 CHAPTER 1. INTRODUCTIOND ecimalBinaryDecimalBinary000008100010001 9100120010101010300111110114010012110050 1011311016011014111070111151111 Table : Decimal 0 to 15 in BinaryNo previous carryPrevious carry00110011+0+1+0+1+0+1+0+101101001ccc cFigure : Binary addition (c stands forcarry)110112+1000121011002If one considers the following decimal division:1234 10 = 123r4he can see that this division strips off the rightmost decimal digit of thenumber and shifts the other decimal digits one position to the right.


Related search queries