Sei sulla pagina 1di 7

Assembly Tech Guide

( Part 1 , Introduction ) By Hemendra Singh Email - Id : admin@hemendrasingh.com Website : www.hemendrasingh.com

Introduction :Assembly language is of course a low level programming language, but the most closest to the machine language, and probably one of the most strongest programming language ever. The main difficulty with assembly language is that you just cannot memorize all the instructions , as they are of very low level, and requires a great understanding of the machine, microprocessor, BIOS ( Basic Input Operating System), kernel ( set of libraries ), assembler, linker, operating system, etc. You can use assembly language to make programs and softwares for 8 bit , 16 bit , 32 bit and 64 bit microprocessors, which may be machine independent programs and softwares ( The main advantage of assembly language ). These machine independent programs don't require a runtime machine as required by JAVA ( a runtime environment like JRE Java Runtime Environment ), but are basically designed taking into account the architecture of operating system and the microprocessor. So, you can use assembly language to make your own operating systems from the scratch. You can even make embedded programs using assembly language. Here I would assume that you are already aware of the basics like numbering system,16 bit microprocessor architecture,interrupts, etc. We wold learn assembly language through coding. We would be using FASM ( Flat Assembler as the assembler ). So, lets start the journey...

Example 1 :- A sample program in assembly language to print a character. :org 100h ; Make a .Com file [ For Windows O.S. ] ; Code for initializing the Video BIOS [ Very Important ] mov ah,00h ;FUNCTION FOR SETTING THE VIDEO BIOS MODE mov al,3 ;SET MODE TO 25x80,16 colour palette ,3 pages, graphics mode int 10h ;CALL INTERRUPT 10H [VIDEO BIOS] ; Code for clearing the screen, equvalent to clrscr() in C,C++ mov ax,0600h ;AH=06(SCROLL),AL=00 (FULL SCREEN) mov bh,07h ;0=BLACK BAKGROUND,7=WHITE FOREGROUND mov cx,0000h ;UPPER LEFT ROW:COLUMN mov dx,2479h ;24TH ROW,79TH COLUMN int 10h ;EXECUTE INTERRUPT 10H [ VIDEO BIOS] mov ah,02h ;FUNCTION FOR SETTING THE CURSOR mov bh,0 ;STARTING PAGE NUMBER mov dh,0 ;STARTING ROW mov dl,0 ;STARTING COLUMN int 10h ;EXECUTE INTERRUPT 10H [ VIDEO BIOS] ; Print a character i.e. 'a' , without the quotes mov ah, 0EH ;Function number mov al,'a' ;Move a to the al register int 10h ;EXECUTE INTERRUPT 10H [ VIDEO BIOS] and print a ; Code equivalent to getch( ) in C,C++ mov ah,0 ;DIRECT KEYBOARD INPUT WITHOUT ECHO int 16h ;CALL INTERRUPT 16H[BIOS KEYBOARD] ret ; Return control to the O.S.

Output :-

Example 2 :- A sample program in assembly language to print Hello World. :org 100h ; Make `a .Com file [ For Windows O.S. ]

; Code for initializing the Video BIOS [ Very Important ] mov ah,00h ;FUNCTION FOR SETTING THE VIDEO BIOS MODE mov al,3 ;SET MODE TO 25x80,16 colour palette ,3 pages, graphics mode int 10h ;CAL INTERRUPT 10H[VIDEO BIOS] ; Code for clearing the screen, equvalent to clrscr() in C,C++ mov ax,0600h ;AH=06(SCROLL),AL=00(FULL SCREEN) mov bh,07h ;0=BLACK BAKGROUND,7=WHITE FOREGROUND mov cx,0000h ;UPPER LEFT ROW:COLUMN mov dx,2479h ;24TH ROW,79TH COLUMN int 10h ;EXECUTE INTERRUPT 10H[VIDEO BIOS] mov ah,02h ;FUNCTION FOR SETTING THE CURSOR mov bh,0 ;STARTING PAGE NUMBER mov dh,0 ;STARTING ROW mov dl,0 ;STARTING COLUMN int 10h ;EXECUTE INTERRUPT 10H[VIDEO BIOS ;/////////////Print "Hello World" without the quotes//////////// mov ah, 0EH mov al,'H' int 10h mov ah, 0EH mov al,'e' int 10h mov ah, 0EH mov al,'l' int 10h mov ah, 0EH mov al,'l' int 10h mov ah, 0EH mov al,'o' int 10h mov ah, 0EH mov al,' ' int 10h mov ah, 0EH

mov al,'W' int 10h mov ah, 0EH mov al,'o' int 10h mov ah, 0EH mov al,'r' int 10h mov ah, 0EH mov al,'l' int 10h mov ah, 0EH mov al,'d' int 10h ;/////////////Print "Hello World" without the quotes//////////// ; Code equivalent to getch( ) in C,C++ mov ah,0 ;DIRECT KEYBOARD INPUT WITHOUT ECHO int 16h ;CALL INTERRUPT 16H[BIOS KEYBOARD] ret ; Return control to the O.S.

Output :-

Potrebbero piacerti anche