We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.


+ Link For Assignments, GDBs & Online Quizzes Solution


+ Link For Past Papers, Solved MCQs, Short Notes & More

Looking for Something at Site? Search Below

[org 100h]

jmp Cube  ; jump at Label Start

String: db "This Program Calculates the Cube of Number 5 in the AX and Store the Results in DX By Shifting and ADD INSTRUCTIONS$"

Num: dw 5            ; Number to find the Cube

Variable: dw 0         ; Variable to store a copy of the Number

Result: dw 0           ; To store 5*5's result

Result2: dw 0         ; to store Result* variable


  mov ah, 9            ; Printf function just like C, printing String

  mov dx, String 

  int 0x21



  mov ax, 0x4c00     ; Terminating program

  int 0x21




Cube:  call Printf


  mov cx, 8         ; loop to run 8 time

  mov ax, [Num]  ; Moving Entered number to AX Register

  mov dx, [Num]  ; Moving copy of the Number in DX register for Later Multiplication


  mov [Variable], dx       ; and then DX to the Spare Variable to store the copy of the Num



  shr dx, 1      ; checking least significant bit by shifting right

  jnc Skip

  add [Result], bx    ; Adding result with the help of ADD instruction



  shl bx, 1               ; checking most significant bit

  dec cx 

jnz CheckBit    ; going back and repeat if bit not zero



  ; complation of 5*5 (but without MUL)

  ; Now going to multiply Result * 5 again to find the Cube (by shifting process again)

  mov cx, 8

  mov bx, [Result]

  mov dx, [Variable]



  shr dx, 1

  jnc Skip2


  add [Result2], bx


  add dx, [Result2]      ; Adding results of Cube in the DX register



  shl bx, 1

  dec cx


  jnz CheckBit2

  call Exit

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Views: 148


This is a member-supported website. Your contribution is greatly appreciated!

Today Top Members 

© 2020   Created by +M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service