We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

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

Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

# 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

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?

Views: 144

.

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

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

## Latest Activity

4 minutes ago
ρяιηcε and Alisha Noor joined + M.Tariq Malik's group

### MGT301 Principles of Marketing

4 minutes ago
5 minutes ago
21 minutes ago
Amir sohail joined + M.Tariq Malik's group

22 minutes ago
25 minutes ago
35 minutes ago
35 minutes ago
1 hour ago
1 hour ago

1 hour ago

1

2

3