This program prints simple text on screen in 8086 assembly language. Click to download the code
Printing a text in assembly language is very easy.
In assembly language we need to build a logic and then write a
program. In this program we only need to print a simple message for which we
have written this code.
1.First we write the title of program so that we can understand
the purpose of program
TITLE TEXT_MESSAGE
2.Then we define the model, model is the part of program which
tells assembler which model we need to use for our program. In this program we
are using SMALL,but there are many like
TINY, SMALL and LARGE
.MODEL SMALL
3.Then we define the stack of program. STACK usually tells
assembler that how much bytes we need to use for our DATA SEGMENT (explained
later). In this program we have used 100 bytes in hexadecimal
.STACK 100H
4.Now comes the DATA SEGMENT, which, we define as .DATA. in DATA
SEGMENTwe store our variables and
temporary data. For example our temporary bytes. In this program we have stored
an array of characters containing our message.
That’s how you define a array of characters (string) in
assembly.
NAME
TYPE
“MESSAGES$”
MSG
DB
0AH, 0DH, "TEXT MESSAGE$"
MSG is the name of message you can have any name, DB is DEFINE
BYTE (will be explained further in variables section) and then our text
message. You notice 0AH and 0DH these bytes are for carriage return and line
feed, now the message which is in quotes, be careful for dollar sign ($), which
is string terminator, do not forget to add it after every message.
5.After setting up DATA SEGMENT, CODE SEGMENT starts, which tells
assembler that our program has been started. We define CODE SEGMENT same as we
defined DATA SEGMENT.
.CODE
In the code segment first we define a label from which our
program starts, in this program we have defined MAIN: with colon. Then we move
starting address of DATA SEGMENT by using AX register in to DS register (will
be explained later programs). First move address to AX register then mov it
back to DS register.
MOV AX, @DATA
MOV DS, AX
6.To print the message we need to move its address to DX register
there are two way to do it but we will use OFFSET command to do it. After moving
address to DX register we store 09H byte in AH register to tell assembler that
we want to print a string. Now we invoke interrupt service routine by using INT
21H
MOVDX, OFFSET MSG
MOVAH, 09H
INT 21H
7.Now that we have completed the task of string printing we need
to tell assembler that where to end the program for this we simply define another
label name EXIT: with colon and move 4CH byte in AH register and invoke INT 21H
after this we use END MAIN (without colon)
Welcome, 555 Timer is a versatile timer IC which can perform different operations and has thousands of applications in industry. Today we are going to learn that how can we use 555 timer as PWM generator. Pulse Width Modulation often refered to as PWM, is as the name suggests, is a type of modulation in which we vary the width of digital signal, be it voltage or current, while frequency of output signal remains constant. When the pulse is varied with the passage of time average output voltage change occurs. You can learn more about PWM in power electronics section where PWM finds numbers of applications.
Here in this circuit 555 timer is configured as Astable multi-vibrator with controlled signal, so when the control signal is changed output pulse is changed with constant frequency.
Required Parts:
555 Timer IC
Resistors 1k x 2
Resistor 10k
Resistor 540 Ohm
LED
Potentiometer 10k
Capacitor 4.7uf
Breadboard
9 Volt Battery
Please Click on images to view Larger. Breadboard Assembly:
Schematic Diagram:
Questions and suggestions are welcomed in comments sections.
This program adds two double digits numbers the easy way. Click to download source code
; CODE BEGINS
TITLE TWO_DIGIT_ADDITION
.MODEL SMALL
.STACK 100H
.DATA
DIGIT1 DB 0AH, 0DH, "ENTER FIRST DIGIT: $"
DIGIT2 DB 0AH, 0DH, "ENTER SECOND DIGIT: $"
RESULT DB 0AH, 0DH, "RESULT IS $"
.CODE
MAIN:
MOVAX, @DATA
MOVDS, AXLEADX, DIGIT1
MOVAH, 09H
INT 21H
MOVAH, 01H
INT 21H
SUBAL, 30H
MOVBH, ALMOVAH, 01H
INT 21H
SUBAL, 30H
MOVBL, AL; BH:BL FIRST NUMBER LEADX, DIGIT2
MOVAH, 09H
INT 21H
MOVAH, 01H
INT 21H
SUBAL, 30H
MOVCH, ALMOVAH, 01H
INT 21H
SUBAL, 30H
MOVCL, AL; CH:CL SECOND NUMBER ADDBL, CLMOVAL, BLMOVAH, 00H
AAAMOVCL, AL; LAST DIGIT OF ANSWER MOVBL, AHADDBL, BHADDBL, CHMOVAL, BLMOVAH, 00H
AAAMOVBX, AX;MOV BH, AH ;MOV BL, AL MOVDX, OFFSET RESULT
MOVAH, 09H
INT 21H
MOVDL, BHADDDL, 30H
MOVAH, 02H
INT 21H
MOVDL, BLADDDL, 30H
MOVAH, 02H
INT 21H
MOVDL, CLADDDL, 30H
MOVAH, 02H
INT 21H
EXIT:
MOVAH, 04CH
INT 21H
END MAIN