Question: ;[Assembly language] TITLE Use bit wise instructions INCLUDE Irvine32.inc .data zeroStr BYTE EAX is 0, 0ah, 0dh, 0 divStr BYTE Divisible by 4, 0ah, 0dh,

;[Assembly language]

TITLE Use bit wise instructions

INCLUDE Irvine32.inc

.data

zeroStr BYTE "EAX is 0", 0ah, 0dh, 0

divStr BYTE "Divisible by 4", 0ah, 0dh, 0

arr WORD 1, -2, -3, 4

.code

main PROC

; Question 1 (3pts)

; In the space below, without using CMP and without modifying EAX,

; write code in 3 different ways (use 3 different instructions)

; to check whether EAX is 0 and jump to label Zero if it is,

; otherwise jump to Q2.

mov eax, 0 ; change this value to test your code

jmp Q2

Zero :

mov edx, OFFSET zeroStr

call writeString

call crlf

Q2:

; Question 2

; You can use the following code to impress your friends,

; but first you need to figure out how it works.

mov al, 'A' ; al can contain any letter of the alphabet

xor al, ' ' ; the second operand is a space character

COMMENT !

a. (1pt) What does the code do to the letter in AL?

b. (2pts) Explain how it works.

!

; Question 3 (4 pts)

; Write code to check whether the data in AL is divisible by 4,

; jump to label DivBy4 if it is, or go to label Q4 if it's not.

; You should not have to use the DIV or IDIV instruction

DivBy4:

mov edx, OFFSET divStr

call writeString

call crlf

Q4:

; Question 4 (5 pts)

; Given an array arr as already defined in .data above,

; and ebx is initialized as shown below.

; Using ebx (not the array name), write ONE instruction

; to reverse the LSB of the last 2 elements of arr.

; Reverse means turn 0 to 1 or 1 to 0.

; Your code should work with all values in arr,

; not just the sample values above.

mov ebx, OFFSET arr

exit

main ENDP

END main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!