0% found this document useful (0 votes)
6 views

Assembly langyage imp points

The document provides an overview of microcontroller and microprocessor concepts, focusing on registers, their functions, and assembly language instructions. It explains the use of specific registers like AX and DX for arithmetic operations, data handling, and file management, as well as the importance of memory segmentation and optimization in programming. Additionally, it covers the use of DOS interrupts for input/output operations and the significance of the CMP and XOR instructions in assembly language.

Uploaded by

akhtarwaheed902
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Assembly langyage imp points

The document provides an overview of microcontroller and microprocessor concepts, focusing on registers, their functions, and assembly language instructions. It explains the use of specific registers like AX and DX for arithmetic operations, data handling, and file management, as well as the importance of memory segmentation and optimization in programming. Additionally, it covers the use of DOS interrupts for input/output operations and the significance of the CMP and XOR instructions in assembly language.

Uploaded by

akhtarwaheed902
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

microcontroller eg (emu 8086)

microprocessor with eg
registers
passes
mnemonics
db
dd
dw
.srack 100h
.model small

ax (act as default operand in mul, div, in, out instructions )


\-> arithmetic operation, logical and stirng instructions
\-> use to trnsfer data in IO operations
---------------------------------------------------------------
dx (data register, often paired with ax for operations including larger values)
\-> for 32 bit reuslts in multiplication it stores result
\-> for dividion it hold remainder (ax holds quotient)
\-> hold the port address during IO operations
----------------------------------------------------------------
port address-> every input output device is assigned a sepecific
address called port address
----------------------------------------------------------------
extended accumulator register eax(micro register): eax 32 bits (4 bytes)
-----------------------------------------------------------------
->09h for dispaly a string
-> 02h for output single character
-> 01h for input single character
->4ch for terminate the program
------------------------------------------------------------------
->file handling(creating file)
-> 3ch for file creation
(open exiting file)
-> 3dh serive number , which is used to open an existing file or create a new file.
->0 read only
-> 1 write only
->2 for read and write
-----------------------------------------------
1. fileName db 'Out.txt', 0
This line defines a string (sequence of bytes) in memory, representing the file
name Out.txt, and appends a null terminator (0). It's used for working with file
operations, such as opening or creating a file.
-----------------------------------------------------------------------------
Why Use .CODE?
Organization:
It separates program instructions from data and stack declarations, making the
program easier to read and manage.
------------------------------------------------------------------------------
1. *Use of Registers*:
- Registers like AX, BX, CX, and DX are used for temporary data storage during
operations. For instance:
- *AX* is commonly used for arithmetic operations.
- *DX* is used to pass string data (like file names or error messages) to DOS
interrupts.

2. *Memory Locations*:
- Specific memory locations are allocated for variables like stock quantities
and transaction details. For example:
- Each item's stock is stored in a predefined memory segment, which allows for
easy access and updates.

3. *Segmentation*:
- The project uses *code, data, and stack segments* to organize memory
effectively:
- *Code Segment*: Contains the instructions for program execution.
- *Data Segment*: Stores static data like item names and inventory quantities.
- *Stack Segment*: Used for temporary storage of return addresses and local
variables during function calls.

4. *Optimization*:
- Care is taken to minimize memory usage by reusing registers and using
operations efficiently.
- Data is moved to and from memory only when necessary, reducing overhead.

5. *Error Prevention*:
- Memory bounds are carefully managed to avoid overwriting critical data or
causing crashes.

This careful approach to memory management ensures the program runs efficiently and
avoids common pitfalls like memory leaks or corruption. Let me know if you’d like
to refine or expand this explanation further!
-----------------------------------------------------------------------------------
--
the AH register determines the function number, while other registers (like AL, DX,
etc.) are used to pass additional parameters depending on the function.

If you replace AH with AL in the instruction MOV AH, 09h (i.e., use MOV AL, 09h),
the behavior will not work as intended because the DOS interrupt handler checks the
value in AH to determine what function to execute.
-----------------------------------------------------------------------------------
-----

In assembly language, the CMP instruction is used to compare two values. In this
case, AL is being used because the value of AL contains the user's input or
selection, which is typically stored in this register after being read from the
keyboard or another input device.

Why Compare Only AL?


User Input Storage in AL:

When a user enters input via a DOS interrupt (e.g., INT 21h with AH = 01h or AH =
08h), the input character is returned in the AL register.

---------------------------------------------------------------

XOR in Assembly
In assembly language, XOR is used for bitwise operations, where each bit in the
operands is compared and the result is stored in the destination operand.

For XOR is a logical operation that compares two bits and returns 1 if they are
different, and 0 if they are the same.
MOV AL, 2 tells DOS to seek from the end of the file.
XOR CX, CX clears CX to 0, meaning no offset from the end.
XOR DX, DX clears DX to 0, which also helps with the seek operation (it doesn't
carry any old data that could interfere).
MOV AH, 42h ; Function 42h: Seek in the file
MOV AL, 2 ; Seek from the end of the file
Once the interrupt is triggered, DOS will:
Use BX to identify the file.
Use DX to know where the data (string) is located.
Use CX to know how many bytes to write.

You might also like