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.

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

Looking for Something at Site? Search Below

# check this code sab log (last assignment ka alternate solution only for learners)

[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

Printf:

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

mov dx, String

int 0x21

ret

Exit:

mov ax, 0x4c00     ; Terminating program

int 0x21

ret

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

CheckBit:

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

jnc Skip

Skip:

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]

CheckBit2:

shr dx, 1

jnc Skip2

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

Skip2:

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)

Views: 148

## HELP SUPPORT

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

## Latest Activity

13 minutes ago
27 minutes ago
+!!! Slow poison!!! liked Shanzay's discussion Mujhy Tum Yaad Aatay Ho....!!!
34 minutes ago
46 minutes ago
+!!! Slow poison!!! liked Shanzay's discussion Darta Hon.....!!!!
46 minutes ago
48 minutes ago
2 hours ago
2 hours ago

1

2

3