8086 Introduction to assembly language-helloworld

Source: Internet
Author: User

Attachment Download:

http://pan.baidu.com/s/1i5R9qO9 Password:rfgk

80x86 microprocessor assembly language programming. Learning any programming language is unavoidable to cross the HelloWorld, the machine-oriented assembly language and process/object-oriented high-level languages, the encoding process of registers, memory allocation and other details need programmers to care, and high-level language programs such as C, C + +, Even if you don't know exactly how printf is implemented, just master the use of the method ( encapsulated as a module ). The C language HelloWorld program is simple enough to have only one line to execute the statement:

printf ("hello,world!"); //display "hello,world!" in the screen buffer A string of characters

And the assembly language of the HelloWorld, also very concise, but let a lot of beginners touch the mind; play a simple metaphor, above the printf (...) Like a pistol, the string "hello,world!" Like a bullet, a "bullet" in printf can complete the firing function. Of course you can also change other bullets .....  assembly language to implement the output string to the screen buffer and display, the work needed to do is not so intuitive and easy to understand.  Assembly language programming, for the "register", register is a computer CPU inside a super-cache ( faster than memory, but the capacity is very small), the data of various operations by "instructions", also known as assembly instructions, such as add AX,BX This means that the register AX is added to the BX value, and the result is stored in the AX;AX/BX, which belongs to the 8086 Universal data register. More assembly knowledge will be explained in a later space.

  hello.asm Source program

1 ;80x86 Assembly Language < Introductory program >2 ;ypp.201709283 ;file name Hello.asm4 5 dseg SEGMENT6MESS DB'hello,world!', 0dh,0ah,24h7 dseg ENDS8 9 sseg SEGMENT PARA STACKTenDw theDUP (?) One sseg ENDS A  - cseg SEGMENT -AssumeCS:CSEG,DS:dseg the BEGIN:  MOVax,dseg -         MOVDs,ax -         MOVDx,offset MESS -         MOVAH,9 +  -         INT21H +         MOVah,4ch A         INT21H at cseg ENDS - END BEGIN -    

The first thing a beginner needs to know is that the assembly language program consists of two basic elements: opcode, operand

operation code , indicating the operation to be carried out, such as add, subtract, multiply, divide ....

operands, manipulated objects, can be numbers, strings, storage units (variables), etc.

This article does not explain the details of the code too much, because it requires a lot of pre-knowledge to pave the way to better understand this piece of code.

Pre-knowledge includes binary system conversion, CPU memory unit addressing, 14 16-bit register groups, memory segmentation, interrupt mechanism, and more

The above code is edited or copied into Notepad, saved as an. asm file, which is the assembly language of the source file, the middle of the operation to be compiled, the generated. obj file is the target file, after linking, to form the final executable file. exe, the whole process is similar to the high-level language operation process.

There are many tools, but the classic Masm5.0 is recommended,

Note: Write the assembly language of the 80x86 platform, do not operate on the WIN-VISTA\7\8.1\10 system, because the 16-bit program will have compatibility issues.

This article is edited, compiled, linked, and run on the Windows XP SP3 operating system.

Masm5.0 Download:http://pan.baidu.com/s/1hsjCcRi Password:syqo

MASM no installation, unzip to a disk root directory, into DOS operation

win+r input cmd into DOS, first with the DOS command into the MASM5.0 file directory, while hello.asm source files are copied to the same path.

Assembly command Format > MASM xxx.asm carriage return Note: DOS is case insensitive

Continuous carriage return, indicating the use of the default file name, four return down, will generate the Hello.obj file, if the error should change the source file after the reassembly,

0 Warning Errors ..... Indicates no error.

After no errors, the next step is "link", command format >link XXX

Note: The link to specify the filename, is just the generated hello.obj can omit the suffix, name do not omit! Or you'll get an error.

Link Hello enter three times after the carriage return, normally generates Hello.exe that is the final form of the program, directly enter Hello to run the program (do not double-click to run, or the DOS window flashes and can not see the results of execution)

The HelloWorld string was successfully output, and the program was completed.

Source file hello.asm- hello.objfile Hello.exe

This is the whole process.

In addition, from ASM to obj in assembly language, this process is called " Assembly Assembly"; In high-level languages it is called " compiling compile".

Some tutorials will be missing the stack segment sseg, no stack segment in the MASM will also error, will prompt no stack segment to pay attention to.

==========================================================

Sweep attention to the public number [cracker House], timely access to more programming, reverse/crack technology such as soft-text information

        

8086 Introduction to assembly language-helloworld

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.