Edit Plus

BASIC ASSEMBLY LANGUAGE FORMAT

OBJECTIVE
To understand the basic concept and functionality of Assembly Language.
THEORY
ASSEMBLY LANGUAGE
  Assembly language is a machine specific programming language with a one-to-one correspondence between its statements and the computer’s native machine language. There are many different types of assembly language, each specific to a processor or processor family. IBM-PC assembly language refers to instruction recognized by a number of different microprocessors in the Intel family: 8086, 8088, 80186, 80286, 80386, 80486, and Pentium.

USES:
·         Assembly language is used most often when either communicating with the operating system or directly accessing computer hardware.

·          Secondly, assembly language is used to optimize certain critical areas of application programs to speed up their runtime execution.

ASSEMBLER
                 An assembler is a program that converts source code programs from the assembly language into machine language. The assembler can optionally generate a source- listing file with line numbers, memory addresses, source code statements and a cross-reference listing of symbols and variables used in a program.
The most popular assemblers for the Intel family are MASM (Microsoft Assembler), TASM (Turbo Assembler).

LINKER
                A companion program that combines individual files created by an assembler into a single executable file


ASSEMBLY PROGRAM SYNTAX
·         Assembly language program consists of statements.
·         A statement is either an instruction to be executed when the program runs or a directive for the assembler.
·         A program normally consists of three parts or segments.

DATA SEGMENT
·         Variables are declared in the data segment.
·         Each variable is assigned space in memory and may be initialized.
 Exp:
·         A DW 3501H
It sets memory for a variable called A, and initialize it to 3501H.
DW - Define word (16 bits = 2 memory locations)
·         A DW (?) ; un- initialized variable
CODE SEGMENT
·         Program instructions are placed in the code segment. Instructions are actually organized into units called procedures. Every procedure starts with a line.
Exp:
·         Main Proc;
 Main is the name of procedure and PROC is the directive identify the start of the procedure
·          Main Endp;
Main is again the name of the procedure and Endp is the direcitive              ; identifies the end of the procedure
STACK SEGMENT
·         The stack segment is used for temporary storage of addresses and data. If no stack segment is declared, an error message is generated, so there must be a stack segment even if the program doesn’t utilize the stack.
·         These segments begin with the directives .stack, .code, and .data

PROGRAM SYNTAX
TITLE first program syntax
.Model Small               ;Specifies the memory model used
.Stack 100H                ;allocate 100H memory locations for stack
.Data                           ;start of the data segment
; Data definitions here
A DB ?
……..
.Code                          ;start of the code segment
Main Proc                    ;start of the first procedure
; instructions here
……
Main Endp                  ;end of the first procedure
; Other procedures here
End Main                    ;end of the complete assembly program


BASIC DIRECTIVES
Following are the description of commonly used directives;
The .MODEL directive specifies the memory model for an assembler module that uses the simplified segment directives. The .MODEL directive must precede .CODE, .DATA, and .STACK. Note that near code is branched to (jumped to) by loading the IP register only, while far code is branched to by loading both CS and IP. Similarly, near data is accessed with just an offset, while far data must be accessed with a full segment:offset address. In short, far means that full 32-bit segment:offset addresses are used, while near means that 16-bit offsets can be used. The format of the .MODEL directive is:
.MODEL memorymodel [[, langtype]] [[, stackoption]]
The memorymodel can be TINY, SMALL, COMPACT, MEDIUM, LARGE, HUGE, or FLAT. The langtype can be C, BASIC, FORTRAN, PASCAL, SYSCALL, or STDCALL. The stackoption can be NEARSTACK or FARSTACK.

TINY
One segment. Thus both program code and data together must fit within the same 64 Kb segment. Both code and data are near.

SMALL
Program code must fit within a single 64 Kb segment, and data must fit within a separate 64 Kb segment. Both code and data are near.

MEDIUM
More than one code-segment. One data-segment. Thus code may be greater than 64K.

COMPACT
One code-segment. More than one data-segment. Thus data may be greater than 64K.

LARGE
More than one code-segment. More than one data-segment. No array larger than 64K. Thus both code and data may be greater than 64K.

HUGE
More than one code-segment. More than one data-segment. Arrays may be larger than 64K. Thus both code and data may be greater than 64K.

FLAT
No segmentation, all code and data can reach any location up to 4 Gb.

All program models but TINY result in the creation of exe-format programs. The TINY model creates com-format programs.

.STACK:  Defines the size of stack used in program
.DATA:  Defines the data segments for data used in the program. Mark the beginning of the data segment
.CODE:  Identifies the code segment which contains all the statements. Also .code marks the beginning of the code segment.
PROC:  Beginning of the procedure
ENDP:  End of the procedure
END:   End of assembly language program
BASIC MOV INSTRUCTION:
We already defined in the Lab#1
RESTRICTIONS:
·         Move between memory to memory is not allowed.
·         A number directly inside a segment register is not allowed.
·         Segment to segment registers, move is not allowed.

The INTerrupt Instruction

Pentium processor has two memory architectures: real and protected. In real mode a Pentium works like fast 8086 processor. Real mode uses 16 bit addresses. The Real mode is also called as 16-bit mode, because all 20 bit physical address is constructed by 16 bit address.  MS-DOS Operating system was the first operating system to implement Real-Address mode on IBM personal computer.
The INT instruction is the instruction which does the most work in any assembler program. INT instruction calls a DOS interrupt service routine (like a function) to perform a special task.
                     INT   InterruptNumber
Where Interrupt Number ranges from 00H to 0FFH (i.e., from 0 to 255).
MS-DOS Operating system provides many common services through INT 21h. INT 21h MS-DOS services are procedures that provide input-output, file handling, and memory management. They are also called “MS-DOS function calls.”
The execution of an INT instruction causes an Interrupt Service Routine (ISR) associated with the InterruptNumber to be executed. Many of the ISRs have multiple sub-functions. To specify which sub-function is to be executed under a particular InterruptNumber, the AH register is assigned a sub-function number before the execution of the INT instruction. Example:
                MOV AH , 08H
                INT 21H
causes sub-function number 08H of Interrupt number 21H to be executed. In addition, some sub-functions require other values to be passed to the ISR in particular registers. Example: Sub-function 09H of Interrupt 21H displays a $-terminated string on the screen. The sub-function requires the offset of that string to be passed in the DX register:
                MOV DX , OFFSET STRING
                MOV AH , 09H
                INT 21H

Note: DPMI (DOS Protected Mode Interface) is an interface allowing a DOS program to run in protected mode and to access extended memory under a multitasking operating system like Microsoft Windows 3.0 and later.

DOS FUNCTION CALLS (INT 21H)

DOS function calls preserve the contents of all the registers except the AX register and any other register or registers in which they explicitly return data.

TERMINATE PROGRAM AND RETURN TO DOS

Every time you want to terminate the program and return to DOS, you have to put the following codes:
Assembly Language
C Language
Meaning
mov  AX ,  4C00H
int   21h
exit(0)
Program terminates normally
mov AX,    4C01h
int    21h
exit(1)
Program terminates with error code 1.

CHARACTER INPUT WITH ECHO

To take single input character thru a keyboard, you have to put the following codes:
The Codes
The Result
mov AH, 01h
int   21h
The program is waiting for the input. Once a user presses a key, the ASCII Code of the input character is returned in the AL register and the input character is displayed as well.
NOTE: This service makes the program waits for the input. The user just needs to press the intended key WITHOUT pressing "enter" key.

CHARACTER INPUT WITHOUT ECHO

MOV  AH ,  08H
INT  21H
 The code of the input character is returned in the AL register.

CHARACTER OUTPUT

To display a character, you have to use the DOS function 02h.
The Initial requirement
The result
AH = 02h
DL = Character or ASCII Code
The character stored in DL will be displayed.

Example:
The following code fragment will display a string 'Hey'.
.code
Main proc
mov DL, 'H'
mov AH, 2
int 21h
mov DL, 'e'
mov AH, 2
int 21h
mov AH, 2
mov DL, 'y'
int 21h
mov ah,4ch
int 21h
main endp
end main
ASSEMBLY  AND EXECUTION PROCESS:
Before you can run the program, though, you have to convert the source code into an executable (able to be run or executed) form. This requires two additional steps, assembling and linking. However, Microsoft has merged MASM and LINK program in one called ML. Source directory must contain assembly source program and LINK.EXE. The assembly process will be simply:
Sourcedirectory> ML source.asm
The ML command will generate .exe file, which may be executed.
  In our lab, we may used a utility called Edit plus to give a Graphical User Inter (GUI) for generating .exe file. We need to configure editplus as detailed below:
1.      Start Editplu by double clicking editplus icon or by menu driven method.
2.     Click in the item "Preference" under the menu "Tool". Then, select the item "Setting & Syntax" under the group "Categories". And, press the button "Add".



3.      Fill in the input line "Description" with Assembler, the input line "File extension" with asm, the input line "Syntax file:" with Z:\MASM\masm.stx.
4.      Press the button "Apply" and also press the button "OK".
5.      Create a new file.































6.      Copy the source codes in the Example–1 and save it in files prog1.asm.
7.      Assemble the file prog1.asm by clicking the item "Assemble EXE format" under the menu "Tool". Look at the messages in the screen. If there are some errors in your source code, fix them all.
8.      Link the file by clicking the item "Link EXE format" under the menu "Tool". Look at the messages in the screen. If there is an error, contact your instructor.
9.      Go to the MS-DOS prompt by clicking the item "DOS" under the menu "Tool".
10.  Run the program, by typing in the command line: prog1.exe 8
11.  Observe in your directory, by typing: dir prog1.* 8 
What files do you have as the result of the above processes?

12.  Close the DOS window and go back to the editor. Now, try to trace the execution of the program step by step by clicking the item "Debug EXE program" under the menu "Tool".

34 comments:

  1. Great set of tips from the master himself. Excellent ideas. Anyone wishing to take their blogging forward must read these tips. Thank you .<a href="EditPlus 5.3 Crack Build 3080 With Serial Key 2020 Free Download
    </a>

    ReplyDelete
    Replies
    1. Programming Language Help And Guide: Edit Plus >>>>> Download Now

      >>>>> Download Full

      Programming Language Help And Guide: Edit Plus >>>>> Download LINK

      >>>>> Download Now

      Programming Language Help And Guide: Edit Plus >>>>> Download Full

      >>>>> Download LINK hp

      Delete
  2. Great set of tips from the master himself. Excellent ideas. Anyone wishing to take their blogging forward must read these tips. Thank you .EditPlus Crack 5.3 Build 3080 With Serial Key Free Download

    ReplyDelete
  3. why is always show the output is can not run the application, how to fix it

    ReplyDelete
  4. Pakistan no.1 Article in my Installcrack.com site Now just 1 click to download!
    EditPlus Crack
    Sylenth1 Crack
    DriverPack Solution Crack

    ReplyDelete


  5. Pretty great post. I simply stumbled upon your blog and wanted to mention that I have really loved surfing around your blog posts. Great set of tips from the master himself. Excellent ideas. Thanks for Awesome tips Keep it
    editplus-crack
    daemon-tools-pro-crack
    smartdraw-crack

    ReplyDelete
  6. Amazing blog! I really like the way you explained such information about this post with us. And blog is really helpful for us this website
    edit-plus-crack

    ReplyDelete


  7. I am very impressed with your post because this post is very beneficial for me and provide a new knowledge…
    editplus-crack
    airmail-crack

    ReplyDelete
  8. This site have particular software articles which emits an impression of being a significant and significant for you individual, able software installation.This is the spot you can get helps for any software installation, usage and cracked.
    kickasscrack.com
    avs-video-editor-crack
    editplus-crack
    nero-burning-rom-crack

    ReplyDelete
  9. This site have particular software articles which emits an impression of being a significant and significant for you individual, able software installation.This is the spot you can get helps for any software installation, usage and cracked.
    editplus-crack
    pgware-gamegain-crack
    greasemonkey-crack
    sony vegas pro
    manycam pro full Keygen

    ReplyDelete
  10. So nice I am enjoying for that post as for u latest version of this Security tool. You can visit this website Click here..
    editplus-crack

    ReplyDelete
  11. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. wahabtech.net I hope to have many more entries or so from you.
    Very interesting blog.
    EditPlus Crack

    ReplyDelete
  12. I'm really impressed with your writing skills, as smart as the structure of your


    Latest Software Free Download



    weblog. Is this a paid topic



    Ecd audio converter crack



    do you change it yourself? However, stopping by with great quality writing, it's hard to see any good blog today.



    Anytans -crack





    Winrar -crack





    Snooker pro -crack




    antibrowserspy pro crack



    ReplyDelete

  13. Pretty great post. I simply stumbled upon your blog and wanted to mention that I have really loved surfing around your blog posts. Great set of tips from the master himself. Excellent ideas. Thanks for Awesome tips Keep it
    editplus-crack
    <a href="https://opcracks.com/truecaller-premium-crack/>opcracks.com</a>

    ReplyDelete
  14. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.
    Very interesting blog.
    wonderlandpc.com
    EditPlus Crack

    ReplyDelete
  15. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. You can Latest Software Crack Free Download With Activation Key, Serial Key & Keygen I hope to have many more entries or so from you. Download Crack Softwares Free Download
    full latest version 2022 blog.
    PreSonus Notion Crack
    CLA-76 Compressor Crack
    Ozone Imager Crack
    1Keyboard Crack
    4Front TruePianos Latest VST Crack
    EditPlus Crack

    ReplyDelete
  16. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.
    Very interesting blog.
    EditPlus Crack
    CyberLink PowerDirector portable Crack
    Deep Freeze Standard crack

    ReplyDelete
  17. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. vstpirate.net I hope to have many more entries or so from you.
    Very interesting blog.
    EditPlus Crack

    ReplyDelete
  18. I am very impressed with your post because this post is very beneficial for me and provide a new knowledge…
    editplus-crack-with-product-code
    download-superantispyware-crack
    skype-crack
    reimage-repair-pc-license-key

    ReplyDelete

  19. Guest blogging is crucial for SEO that's why this post Crack Pro Software provides a free best blog and article submission sites list with instant approval
    editplus-crack

    ReplyDelete
  20. Very Nice Blog this amazing Software.
    Thank for sharing Good Luck!

    I am very impressed with your post because this post is very beneficial for me and provide a new knowledge…

    I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot.

    EditPlus Crack
    Driver Magician Crack
    USB Disk Security Crack
    PC Reviver Crack
    EditPlus Crack
    Wise Care 365 Pro Crack

    ReplyDelete
  21. Great set of tips from the master himself. Excellent ideas. Thanks for Awesome tips Keep it up
    editplus-build-crack

    ReplyDelete
  22. Programming Language Help And Guide: Edit Plus >>>>> Download Now

    >>>>> Download Full

    Programming Language Help And Guide: Edit Plus >>>>> Download LINK

    >>>>> Download Now

    Programming Language Help And Guide: Edit Plus >>>>> Download Full

    >>>>> Download LINK co

    ReplyDelete
  23. This comment has been removed by the author.

    ReplyDelete