Skip to main content

Create Simple Division Program In Assembly Language

Hi Friends,



Welcome Again To My Blog. Friends, Today I am going to Share Another Assembly language Example Program, Where I Programmed My Program To Take One Input From User, Then Check If Its Completely Divisible By 3 And 5 Both Number And Also Print Back Then Result over The Terminal.

Super Simple To Understand.
I hope, you will enjoy it. and yes! you can also download my all assembly codes from my Github Repo. Github Repo Link Given At Last, Of This Post.

By The Way, If you Are new And Don't Know How To Start, Compile Or Run?
Then, Don't Follow up Our Previous Blog post. Here, it's The List.

1. Hello World In Assembly
2. Find String Length In Assembly Language
3. Subroutine Demo In Assembly language
4. Some Subroutine Functionality Example
5. User Input Example In Assembly Language
6. Variable Decleration/Include function In Assembly
7. Convert Integer Into ASCII in Assembly Language
8. Arthematic Functions In Assembly Language
9. Calculator In Assembly Language



Here, its my code

Simple Division Program in Assembly Language




;  Write A Program, That Takes User Input And Tell,
;  Input Number is Divisible By 3 And 5
;
; author: Suraj Singh Bisht
; Email : surajsinghbisht054@gmail.com
;
%include 'CalculateArguments_without_start.asm'
; ====================================================
;              [ Includable File]
; Functions:
;       _strlen
;       _exit
;       _print
;       _printline
;
; Don't Forget To Create A Space in .bss Section 
;       SECTION bss:
;        save    resb    255;
;
;              [ Includable File]
; Functions:
;       _printsingle
;       _printdigit
;
;
; Function:
;       _asciitointeger
;
; ====================================================
;
; Don't forget to add this into .bss section
;       digitprintersave        resb    255;



; section .bss
SECTION .bss
 digitprintersave        resb    255;
 space resb 255 ; Blank Space

; section data
SECTION .data
 string00  db  0Ah, "[+] Enter Your Number   : ", 0h  ;
 string11  db 0Ah, "[+] User Entered Number : ", 0h  ;
 string12  db 0Ah, "[+] Is Divisible By "
 string13  db " : ",0h
 stringT   db " True.",0Ah, 0h
 stringF   db " False.",0Ah, 0h


; section text
SECTION .text
 global _start ; Linker



checkdivisionby:
 ; Input :
 ; EAX = Number
 ; EBX = Dividend
 ;
 ; Output:
 ; EAX =  0 or 1+ Remainder
 ;
 push ecx ; Save Register
 push edx ;
 push ebx ;
 xor edx, edx
 div ebx  ; Perfrom Division
 pop ebx  ;

 mov eax, string12;
 call _print;

 mov eax, ebx;
 call _printdigit;

 mov eax, string13
 call _print;

 cmp edx, 0 ; Compare Remainder
 jne _notdivisible;

_yesdivisible:
 mov eax, stringT
 call _print

 mov eax, 1
 jmp _checkdivisionreturn ;

_notdivisible:
 mov eax, stringF
 call _print

 mov eax, 0

_checkdivisionreturn:
 pop edx  ; POP Registers
 pop ecx
 ret

calculateUserinputDivision:
 ; print string
 mov eax, string00  ;
 call _print   ;

 ; Take User input
 mov eax, 3   ; Invoke SYS_READ
 mov ebx, 1   ; stdin
 mov ecx, space   ; user space
 mov edx, 255   ; Size
 int 80h    ; kernel interpt


 ; print string
 mov eax, string11  ;
 call _print   ;

 ; perform ascii to integer conversion subroutine
 mov eax, space
 call _asciitointeger
 call _printdigit
 push eax
 mov ebx, 3
 call checkdivisionby
 pop eax
 mov ebx, 5
 call checkdivisionby


 ret    ; Return

_start:
 call calculateUserinputDivision  ;
 jmp _exit     ; Exit Routine


Please Check Github For Latest Error Free Examples Codes. Click here

Related Post

Top Visited

Big List Of Google Dorks For Sqli Injection

how to install burp suite in Linux/Ubuntu 16.04

Create Simple Packet Sniffer Using Python

Python Beautiful Soup Module - Tutorial - Part 2

Create Ping Sweeping Script Using Python

how to configure burpsuite with firefox?

Latest Google Dorks List

List of Keyboard Shortcuts Keys for GNOME Desktop (Kali linux / Linux / Ubuntu/*nix )

What is Burp Suite And its Features?

What is the use of Pseudo header in TCP/UDP packets?