Step by step how to Add/Subtract/Multiply/Divide In Assembly Language.

Addition + Subtraction + Multiplication + Division In Assembly Language x86

equation code in assembly language processor x86

Welcome back,
Before we are start I want to tell you we are using Irvine Libraries and 86x processor to perform such operations as mentioned above !

Things which are discussed below in this content are listed below:

  • Addition in assembly language x86 => 8086
  • Subtraction in assembly language x86 => 8086
  • Multiplication in assembly language x86 => 8086
  • Division in assembly language x86 => 8086
I'm using Irvine Library on visual studio 2010 Professional to run assembler to execute my code!
If you want to setup this platform visit => VS 2010 Pro + Irvine Lib FULL !

FOR BETTER UNDERSTANDING:

"Processor has only register in use i.e. eax which is use to display so u may   hold data in other registers but make sure to place your final result in the eax register to make your program error free, this whole game of assembly is passing values to the free register and right register where eax is accumulator"

Addition in assembly language code:

Suppose value is: 8+2 => 10 
Addition in assembly language code

Subtraction in assembly language code:

Suppose value is: 8-2 => 10
Subtraction in assembly language code

Multiplication in assembly language code:

Suppose value is: 8*2 => 10
multiplication in assembly language code

Division in assembly language code:

Addition + Multiplication and Division Together, Focus "PASSING VALUES"

Suppose equation is: (3*4) + (6/2) + (5*2) = 25 

mov 3 to eax and mov 4 to ebx and use mul ebx to put 12 in eax
now mov eax to ecx as shown in code !
mov 6 to eax and mov 2 to ebx and div ebx to put answer in eax
now use add ecx,eax means answer of 3 * 4 + 6 / 2 is in ecx register
eax is free now put 5 in eax and 2 in ebx again !
again use mul ebx and add eax which is 5 * 2 = 10 into ecx to get your answer which is 25 !
division in assembly language code