Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
26 views5 pages

Topics of MPMC Unit 2

The document provides an overview of assembler directives in 8086 programming, detailing various commands used to control the assembly process, such as data declaration and segment declaration directives. It also explains the role of assemblers, the importance of assembly language for performance-critical applications, and outlines the tools necessary for assembly language program development. Key concepts, examples, and resources for learning assembly language are also included.

Uploaded by

korapatiusharani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Topics of MPMC Unit 2

The document provides an overview of assembler directives in 8086 programming, detailing various commands used to control the assembly process, such as data declaration and segment declaration directives. It also explains the role of assemblers, the importance of assembly language for performance-critical applications, and outlines the tools necessary for assembly language program development. Key concepts, examples, and resources for learning assembly language are also included.

Uploaded by

korapatiusharani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
Assembler Directives in 8086 Programming Assembler directives are commands given to the assembler to control the assembly process. They are not translated into machine code but guide the assembler in interpreting and processing the assembly language source code. Here are some of the most commonly used assembler directives in 8086 programming: Data Declaration Directives: * DB (Define Byte): © Declares one or more bytes of memory. o Syntax: label DB value1, valued, ... o Example: MSG DB ‘Hello, World!" «@ DW (Define Word): © Declares one or more words (2 bytes) of memory. 4/2 =. ° Syntax: label DW valuet, value2, ... ot o Example: COUNT DW 10 « DD (Define Doubleword): o Declares one or more doublewords (4 bytes) of memory. o Syntax: label DD value, valued, ... o Example: LARGE_NUMBER DD 12345678h Segment Declaration Directives: « SEGMENT: © Defines the beginning of a logical segment of memory. © Syntax: segment_name SEGMENT « ENDS: o Defines the end of a logical segment of memory. o Syntax: segment_name ENDS. o Example: DATA_SEGMENT SEGMENT MSG DB 'Hello, World!' DATA_SEGMENT ENDS Other Important Directives: e ASSUME: o Specifies the segments to be associated with the segment registers. o Syntax: ASSUME CS:code_segment, DS:data_segment, SS:stack_segment, ES:extra_segment « ORG: © Sets the origin or starting address of the next instruction or data. eo Syntax: ORG address e EQU: © Assigns a numeric value to a symbolic name. © Syntax: symbol EQU value e END: © Marks the end of the assembly program. © Syntax: END Example of a Simple 8086 Program: DATA_SEGMENT SEGMENT MSG DB ‘Hello, World!', ODh, OAh, '$' DATA_SEGMENT ENDS CODE_SEGMENT SEGMENT ASSUME CS:CODE_SEGMENT, DS: DATA_SEGMENT START: MOV AX, DATA_SEGMENT MOV DS, AX MOV DX, OFFSET MSG MOV AH, 09h INT 21h MOV AH, 4Ch INT 21h CODE_SEGMENT ENDS END START Explanation: 4 . Data Segment: Defines a data segment named DATA_SEGMENT and declares a 2, message string. Code Segment: Defines a code segment named CODE_SEGMENT and assumes it for the CS register. 3. Start of the Program: The START label marks the beginning of the program's execution 4. 5. Displaying the Message: Loading Data Segment: Loads the address of the DATA_SEGMENT into the DS register. © Moves the offset of the MSG string into the DX register. © Sets the function code in AH to 09h (display string). © Calls the DOS interrupt 21h to display the message. . Program Termination: © Sets the function code in AH to 4Ch (terminate program). © Calls the DOS interrupt 21h to exit the program. By understanding and effectively using these assembler directives, you can write well-structured and efficient 8086 assembly language programs. Writing Simple Programs with an Assembler: A Beginner's Guide What is an Assembler? An assembler is a software program that translates assembly language instructions into machine code, which is the language understood by computers. Assembly language is a low-level programming language that provides more control over the hardware than high-level languages like C++ or Python. Why Use Assembly Language? e Performance-critical applications: For tasks that require maximum speed and efficiency, assembly language can be used to optimize code. * Device drivers and kernel development: These components often need direct hardware access, which assembly language provides. « Reverse engineering and security analysis: Understanding assembly language is essential for analyzing the inner workings of software and systems. Getting Started 1. Choose an Assembler: co NASM (Netwide Assembler): A popular, open-source assembler that supports a variety of architectures. co MASM (Microsoft Macro Assembler): A commercial assembler primarily used for x86 and x64 architectures. ° TASM (Turbo Assembler): Another popular assembler for x86 and x64 architectures. 2. Write Assembly Code: Assembly language instructions are mnemonic codes that represent machine instructions. Here's a simple example of an assembly program to add two numbers: section .data muml db 5 num2 db 3 section .text global _start _start: mov al, [num1] add al, [num2] mov [result], al mov rax, 60 mov rdi, 0 syscall 3. Assemble the Code: Use the command-line interface to run the assembler on your assembly file: nasm -f elf64 my_program.asm 4. Link the Object File: Link the object file produced by the assembler with the system libraries to create an executable file: ld my_program.o -o my program 5. Run the Program: Execute the generated executable file: ./my_program Key Concepts in Assembly Language « Registers: Small storage locations within the CPU used to hold data and instructions. * Memory: A large storage area where data is stored. Instructions: The basic operations performed by the CPU, such as adding, subtracting, moving data, and branching. ¢ Assembly Language Syntax: Each assembly language has its own syntax, but most follow a similar structure: label: instruction operandl, operand2 co label: A symbolic name for a memory location. co instruction: The operation to be performed. © operand, operand2: The data or memory locations involved in the operation. Learning Resources Online Tutorials: Many online resources offer tutorials and examples for learning assembly language. « Assembly Language Books: Books like "Assembly Language Step-by-Step” by Kip Irvine are excellent for beginners. e Practice and Experimentation: The best way to learn assembly language is to practice writing and debugging code. Remember: Assembly language is a complex and low-level language. It requires a deep understanding of computer architecture and hardware. However, it offers unparalleled control and efficiency. Would you like to delve deeper into a specific aspect of assembly language programming, such as working with registers, memory, or control flow? Assembly Language Program Development Tools Assembly language programming requires a specific set of tools to effectively write, assemble, link, and debug code. Here are the primary tools involved in this process: 1. Text Editor: © Used to create and edit assembly language source code files. e Examples: © Notepad (Windows) © TextEdit (macOS) © Vim, Emacs (cross-platform, powerful text editors) 2. Assembler: © Translates assembly language instructions into machine code (binary instructions). © Examples: © NASM (Netwide Assembler): A popular, open-source assembler that supports various architectures. TASM (Turbo Assembler): A commercial assembler for x86 processors. MASM (Microsoft Macro Assembler): Another commercial assembler for x86 processors. 3. Linker: * Combines multiple object files (generated by the assembler) into a single executable file. Resolves references between different modules and libraries. © Examples: o GNUId: A versatile linker used in many environments. © Microsoft Linker: The linker included in Microsoft's development tools. 4. Debugger: © Helps in identifying and fixing errors in assembly code. © Allows you to step through code execution, examine registers, memory, and variables. © Examples: © GDB (GNU Debugger): A powerful, open-source debugger. 2 WinDbg: A Windows-specific debugger. LLDB: Amodern debugger for macOS and Linux. 5. Simulator/Emulator: © Simulates the behavior of a target processor and system. © Enables testing and debugging assembly code without requiring physical hardware * Examples: © QEMU: A versatile emulator that can simulate various hardware architectures. © MARS (MIPS Assembler and Runtime Simulator): A simulator specifically for MIPS architecture. Additional Tools: © Disassembler: Converts machine code back into assembly language, aiding in reverse engineering and code analysis. © IDE (Integrated Development Environment): A software application that provides a comprehensive development environment, often including a text editor, assembler, linker, debugger, and other tools. Choosing the Right Tools: The choice of tools depends on several factors: Target architecture: The specific processor and system you are programming for. © Operating system: The platform you are using for development. © Project requirements: The complexity of the project and the level of control needed © Personal preference: Your familiarity with different tools and their features.

You might also like