Wednesday, December 1, 2021

Subtraction of two decimal digits in 8086 Microprocessor x86 Assembly Language

Subtraction of two decimal digits in 8086 Microprocessor x86 Assembly Language

This 8086 microprocessor assembly program subtracts two decimal digits and prints the output accordingly. If you want to know how can you print a single character in 8086 assembly language you can find it IN THIS LINK. If you have questions or any problems feel free to ask in the comments section.





TITLE THE_LAME_PROGRAMMER 
.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: 
        MOV AX, @DATA 
        MOV DS, AX 
         
        MOV DX, OFFSET DIGIT1 
        MOV AH, 09H 
        INT 21H 
         
        MOV AH, 01H 
        INT 21H 
        SUB AL, 30H 
        MOV BH, AL 
         
        MOV DX, OFFSET DIGIT2 
        MOV AH, 09H 
        INT 21H 
         
        MOV AH, 01H 
        INT 21H 
        SUB AL, 30H 
        MOV BL, AL 
         
        CMP BH, BL 
         
        JL MINUS 
         
        SUB BH, BL 
         
        MOV DX, OFFSET RESULT 
        MOV AH, 09H 
        INT 21H 
         
        MOV DL, BH 
        ADD DL, 30H 
        MOV AH, 02H 
        INT 21H 
         
        JMP EXIT 
         
   MINUS: 
        SUB BL, BH 
         
        MOV DX, OFFSET RESULT 
        MOV AH, 09H 
        INT 21H 
         
        MOV DL, '-' 
        MOV AH, 02H 
        INT 21H 
         
        MOV DL, BL 
        ADD DL, 30H 
        MOV AH, 02H 
        INT 21H 
         
   EXIT: 
        MOV AH, 04CH 
        INT 21H 
   END MAIN 


OUTPUT OF THE PROGRAM
Subtraction of decimal digits in 8086 assembly Language














Subtraction of decimal digits in 8086 assembly Language


Thursday, November 18, 2021

Find Cube | 8086 Microprocessor Assembly Language Program

 This x86 Assembly Language program takes users input in 8086 Microprocessor Assembly Language and prints the cube of it.

To run this x86 Assembly Code you need to Download emu8086 software. Copy the following 8086 microprocessor Assembly Language code and paste this code to emu8086 and hit the play button.

TITLE PUCHTAA
.MODEL SMALL
.STACK 100H
.DATA


    MSG DB 0AH, 0DH, "ENTER A NUMBER TO FIND CUBE OF IT: $"
    OUT1 DB 0AH, 0DH, "CUBE OF $"
    OUT2 DB " IS $"
    QUIT DB 0AH, 0DH, "CONTINUE? Y FOR YES ELSE FOR NO: $"
   
.CODE
   
    MAIN:
        MOV AX, @DATA
        MOV DS, AX
    AGAIN:
        LEA DX, MSG
        MOV AH, 09H
        INT 21H
       
       
        MOV AH, 01H
        INT 21H
       
        PUSH AX
       
        CMP AL, 39H
        JG AGAIN
        CMP AL, 30H
        JL AGAIN
       
        PUSH AX
        PUSH AX
       
        SUB AL, 30H
        MOV BL, AL
        MUL BL
        AAM
               
        MOV BX, AX ; BH = 06, BL, 04 ; IF ENTERED 08
       
        POP AX
       
        SUB AL, 30H
       
        MUL BL
       
        AAM
       
        MOV CL, AL ; FIRST RESULT
        MOV CH, AH ;CARRY
        POP AX
       
        SUB AL, 30H
        MOV BL, AL
        MOV AL, BH
        MUL BL
        AAM
       
        ADD AL, CH
        AAA
       
        MOV BX, AX
       
       
        LEA DX, OUT1
        MOV AH, 09H
        INT 21H
       
        POP DX
        MOV AH, 02H
        INT 21H
       
        LEA DX, OUT2
        MOV AH, 09H
        INT 21H
       
        MOV DL, BH
        ADD DL, 30H
        MOV AH, 02H
        INT 21H
       
        MOV DL, BL
        ADD DL, 30H
        MOV AH, 02H
        INT 21H
       
       
        MOV DL, CL
        ADD DL, 30H
        MOV AH, 02H
        INT 21H
       
              
        LEA DX, QUIT
        MOV AH, 09H
        INT 21H
       
        MOV AH, 01H
        INT 21H
        OR AL, 20H
        CMP AL, 'y'
        JE AGAIN
       
        MOV AH, 04CH
        INT 21H
  END MAIN


OUTPUT 

Find Cube | 8086 Microprocessor Assembly Language Program












TAGS:

  • assembly language
  • emu8086
  • assembly code
  • assembly language programming
  • x86 assembly
  • assembly language example
  • cube of number assembly language

Friday, November 12, 2021

8085/8086 Microprocessor Assembly Language Program to Find Square of a Number

This 8085/8086 microprocessor assembly language program asks users to input a number and finds out the square of a number and then prints it. This 8085/8086 microprocessor assembly language program has one more feature by which it doesn't accept any value other than decimal numbers and asks users if they want to quit the program or not 

TITLE PUCHTAA
.MODEL SMALL
.STACK 100H
.DATA


    MSG DB 0AH, 0DH, "ENTER A NUMBER TO SQUARE IT: $"
    OUT1 DB 0AH, 0DH, "SQUARE OF $"
    OUT2 DB " IS $"
    QUIT DB 0AH, 0DH, "CONTINUE? Y FOR YES ELSE FOR NO: $"
   
.CODE
   
    MAIN:
        MOV AX, @DATA
        MOV DS, AX
    AGAIN:
        LEA DX, MSG
        MOV AH, 09H
        INT 21H
               
        MOV AH, 01H
        INT 21H
       
        PUSH AX
       
        CMP AL, 39H
        JG AGAIN
        CMP AL, 30H
        JL AGAIN
       
        PUSH AX
       
        SUB AL, 30H
        MOV BL, AL
        MUL BL
        AAM
               
        MOV BX, AX
       
        LEA DX, OUT1
        MOV AH, 09H
        INT 21H
       
        POP DX
        MOV AH, 02H
        INT 21H
       
        LEA DX, OUT2
        MOV AH, 09H
        INT 21H
       
        MOV DL, BH
        ADD DL, 30H
        MOV AH, 02H
        INT 21H
       
        MOV DL, BL
        ADD DL, 30H
        MOV AH, 02H
        INT 21H
       
        LEA DX, QUIT
        MOV AH, 09H
        INT 21H
       
        MOV AH, 01H
        INT 21H
        OR AL, 20H
        CMP AL, 'y'
        JE AGAIN
       
        MOV AH, 04CH
        INT 21H
    END MAIN

Monday, October 18, 2021

Getting Started with Python Programming as an absolute beginner with Thonny IDE

 Hello Everyone ✊,

Getting started with python programming or python scripting might be complicated if you head in the wrong direction. As an absolute beginner with no prior experience in any programming language or just a little experience with HTML scripting, python programming seems a lot.

If you google getting started with python as an absolute beginner, you will get hundreds of thousands of results. That's complex. You need a good user-friendly IDE (Integrated Development Environment) and have python installed on your pc

All you need to do is download an IDE name (Thonny). It is the simplest IDE available for python programming as an absolute beginner. It offers a lot of features that are very useful and will improve your programming skills.

Go ahead and download it by click on (Thonny). after you have downloaded thonny, you need to install it by clicking setup. When you install thonny python programming language automatically installs with it, you don't need to install it separately.

Thonny offers various features like syntax highlighting for code and comments, tabbed programming for parallel coding, and much more. If you are working on a python programming project and you need to install any package, thonny also offers package installation very quickly. You don't need to visit any website to install any python package. all you need to do is just go to Tools >> Manage Package >> then the following window will appear

How_To_Install_Python_Packages_In_Thonny














On the right side, you will see the name of packages that can be installed right away; if you want to search any python package that is not listed, you can type in the search bar and hit search on PyPI. after you have searched all you need to do is to hit install. You just install a python package without using any complex pip command


One more important feature of thonny is debugging, which we will discuss in upcoming sections.


If you find this helpful, rate us and like us.

Friday, October 8, 2021

How To Print A Single Character in 8086 Assembly Language

 If you are getting started with 8086 assembly programming, you might encounter the elementary and very beginning program of your life, which is “how to print text in 8086 assembly language”. However, in most cases, the next step is to print a single character in the 8086 assembly language.


In an 8086 assembly language computer always works with registers of the microprocessor. in intel’s 8086 microprocessor, there are four basic general-purpose or data registers i.e.


Accumulator Register (AX)

Base Register (BX)

Counter Register (CX)

Data Register (DX)


Above mentioned registers are 16bit registers which means they consist of two bytes. These registers are further broken into ‘high byte’ and ‘low byte'. We can use them for any purpose we want. Look at the table below.



8086_General_Purpose_Registers


There are other types of registers as well, but for now, we will stick to them.



Now that we have an overview of Data registers, we can now write a simple assembly language program that prints single character output. 


First, we write our basic program template, which does nothing but is very important and will always be used in each assembly program.


TITLE SINGLE_CHARACTER_PRINTING

.MODEL SMALL

.STACK 100H

.DATA


;;THIS IS DATA SECTION



.CODE   


;THIS IS CODE SECTION

    MAIN:

        MOV AX, @DATA

        MOV DS, AX

        

        

            

        

        

        MOV AH, 04CH

        INT 21H

   END MAIN


If you don’t understand or want to understand more basics, you can follow this link for the instructions used in this program.


In the 8086 assembly language, a single character means one byte. Let’s say we want to print ‘A’ first, we need to move it to the data register, which is DX, and ‘A’ is one byte so that we will place it in the DL register. If you are confused, remember that if you want to print a single character, always move it to the ‘DL’ register.



MOV DL, ‘A’

MOV AH, 02H

INT 21H


Just add three lines in the above code, and you will see the output of the program. If you don't understand MOV AH, 02H and INT 21H, just go with it as at this point there is no need to get stuck to it. Just remember we write these three statements to display a single character. You just need to replace the ‘A’ in DL if you want to print something else.


Following is the complete code of above program


TITLE SINGLE_CHARACTER_PRINTING
.MODEL SMALL
.STACK 100H
.DATA

;;THIS IS DATA SECTION

.CODE   

;THIS IS CODE SECTION
    MAIN:
        MOV AX@DATA
        MOV DSAX
        
        MOV DL'A'
        MOV AH02H
        INT 21H
                        
        MOV AH04CH
        INT 21H
   END MAIN

You should see output of the program as 'A'


If you have any question or trouble you can always choose to click Ask for Help section mentioned above.

Monday, April 26, 2021

Create Your Own Random Password Generator Using Python [Free Source Code]

This program generates random password using simple python script. This script can be a good small python project to be shown in your class or to your colleagues.

 

To begin programming our random password generator, first, we need to import 'random module' from python 3. This is built in module and you don't need to install any package for that. Simply write

 

import random

 

Next we define list to store password, which will be generated by script.

 

password = []

 

Next step is to define lists of characters, numbers and symbols for password. Keep in mind that these are user generated lists you can customize them according to your preference.

 

letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c''d''e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

 

numbers = ['1','2','3','4','5','6','7','8','9','0']

 

characters = ['+','(',')','*','%','^','$','_','@','=']

 

 

Now that we have laid basic bricks for our code, we must know the length of password that user want’s to generate and number of characters or symbols or numbers user wants to add to its password. To do this we define three input statements which ask user for its preference regarding password.  Simply write

no_letters = int(input("How many letters would you like in your password?\n"))

no_numbers = int(input("How many number would you like?\n"))

no_characters = int(input("How many symbols would you like?\n"))

 

above three statements take input from user and store them in variables called no_letters, no_numbers and no_characters, [You can use your own naming scheme], and store them as int type.

Next we start generating password by simply looping through our lists [letters, numbers and characters]. Go ahead and write

for x in range(0,no_letters):

    password += random.choice(letters)

 

for x in range(0,no_numbers):

    password += random.choice(numbers)

 

for x in range(0,no_characters):

    password += random.choice(characters)

 

now that password has been generated but it will contain sequential characters, just for understanding the password is not random so we will shuffle it by writing

 

random.shuffle(password)

 

and then we store it in a new password like this.

 

random.shuffle(password)

 

new_password = ""

 

for char in password:

    new_password += char

 

and in the last we just simply print it by writing

 

print(f"Your password is {new_password}")

 

putting everything together. Below is the complete code of random password generator python project. This code should run just fine on your machine.

 

 



Source Code 👇
#-------------------------------------------------------------------



#This program generates password randomly


import random

password = []

letters = ['A','B','C','D','E','F','G','H','I','J','K','L',
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a',
'b','c''d''e','f','g','h','i','j','k','l','m','n','o','p',
'q','r','s','t','u','v','w','x','y','z']
numbers = ['1','2','3','4','5','6','7','8','9','0']
characters = ['+','(',')','*','%','^','$','_','@','=']


no_letters = int(input("How many letters would you like in your password?\n"))
no_numbers = int(input("How many number would you like?\n"))
no_characters = int(input("How many symbols would you like?\n"))


for x in range(0,no_letters):
    password += random.choice(letters)


for x in range(0,no_numbers):
    password += random.choice(numbers)


for x in range(0,no_characters):
    password += random.choice(characters)

random.shuffle(password)

new_password = ""

for char in password:
    new_password += char

print(f"Your password is {new_password}")

#-------------------------------------------------------------------
Output 👇
How many letters would you like in your password?
12
How many number would you like?
4
How many symbols would you like?
2
Your password is Tw5@4o1*b3ewiYQSzw



















If you faced any kind of difficulty in writing this code or executing it, feel free to write in comment section below.


Thursday, April 22, 2021

[Solved] Program To Check Leap Year In Python Using Functions


In this tutorial, we will learn how to calculate leap year with a simple python script. First, we need to understand the rules behind a year being a leap year to write the code. The steps to calculate leap year are following


  1. If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5.

  2. If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4.

  3. If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5.

  4. The year is a leap year (it has 366 days).

  5. The year is not a leap year (it has 365 days).


For more information and detailed examples, we can read This article. 


To write a python script, we will create a flowchart of the rules as mentioned earlier.


Leap_Year_Check_Python_Flowchart



After creating a flowchart, we can start writing python code.


Step 1: Ask User for Input

To allow users to input a value, we need to add an 'input' statement in our program. The 'input' statement displays a string and returns the text input by users, so we need to store it in a variable. We will define a variable named 'user_input', so our first statement becomes this.


user_input = input(“"Enter a Year: ")


However, the input statement returns any value input by the user as text. To handle this, we add the 'int' statement before the 'input' statement.



user_input = int(input(“"Enter a Year: "))


Step 2: Process the Input

Once the user has input, we have our value stored in a variable name 'user_input' we can process it as 'user_input'. First, we divide the 'user_input' by 4. Please keep in mind that we will use the modulus division method because we want to check if the remainder is 0 or not.

 If the remainder is 0, then we divide it by 100. However, before we check the remainder of the division of 100, if we re-read Rule 2 mentioned above, we can see if we do not check the remainder of the division of 100 for 0. However, for 1, we can skip step 3 and directly go to step 4. So our code becomes



if (year%4==0):

        if(year%100==1):

            print(f"{year} is a leap year!!") 



**notice the indentation? Keep it that way because python uses indentation to nest statements.


We have used two 'if' statements to check the leap year, but when both the 'if' statements are false, we will divide 'user_input' by 400 and check the remainder for 0. We add 'else statement for this purpose.


def leap_check(year):


    if (year%4==0):

        if(year%100==1):

            print(f"{year} is a leap year!!")    

        else:

            if(year%400==0):

                print(f"{year} is a leap year!!")


Then we declare everything else as not a leap year.



if (year%4==0):

        if(year%100==1):

            print(f"{year} is a leap year!!")    

        else:

            if(year%400==0):

                print(f"{year} is a leap year!!")

            else:

                print(f"{year} is not a leap year!!")

    else:

        print(f"{year} is not a leap year!!")



Now wrap up all the code in a function and call it in main.


def leap_check(year):


    if (year%4==0):

        if(year%100==1):

            print(f"{year} is a leap year!!")    

        else:

            if(year%400==0):

                print(f"{year} is a leap year!!")

            else:

                print(f"{year} is not a leap year!!")

    else:

        print(f"{year} is not a leap year!!")



Step 3: Display outputs

The 'print' function will display the and data already used in the 'if' statement.


user_year = int(input("Enter a Year: "))

leap_check(user_year)


If you find any difficulties in this code or tutorial, please click here or visit Ask For Help.


#Source Code 👇
#-------------------------------------------------------------------------------------
#Leap Year Check 

def leap_check(year):

    if (year%4==0):
        if(year%100==1):
            print(f"{year} is a leap year!!")    
        else:
            if(year%400==0):
                print(f"{year} is a leap year!!")
            else:
                print(f"{year} is not a leap year!!")
    else:
        print(f"{year} is not a leap year!!")


print("\t\t\n\nWelcome!! This programme checks if input year is leap year\n\n")


user_year = int(input("Enter a Year: "))
leap_check(user_year)

#-----------------------------------------------------------------------

OUTPUT 👇
Welcome!! This programme checks if input year is leap year Enter a Year: 2000 2000 is a leap year!!

Dont forget to share your feedback in comments section


Output of Leap Year Check Python Flowchart



Complete Video Tutorials