Hello. I have a question for my Intro to Assembly Language class that I am havin
ID: 662281 • Letter: H
Question
Hello. I have a question for my Intro to Assembly Language class that I am having troubles doing. Your help will be really appreciated. Thank you in advance!
Q#6. Using bit-wise Boolean operations (AND, OR, XOR, NOT, TEST), and NO arithmetic operations (ADD, SUB, MUL, NEG, CMP, ...), write a program that receives a signed number in the AX register, and alters this (returning answer in AX) as follows using ONLY four bit-wise Boolean operations:
1. If the number is negative, say -n, then replace it with the non-negative number n-1, and then
2. If the number is divisible by 8, then add 6 to it, and then
3. If it is even, add one to it, but if it is odd, subtract one from it.
Explanation / Answer
for the third part for checking even or odd:
; Mask off low order bit determines even (=0) or odd (=1) ; mov ax,number ; load number to ax and ax,1 ; mask off low order bit of number (0=even,1=odd) ; xor ax,1 ; complement low order bit (1=even,0=odd) ; ; the result is numeric 0=odd, 1=even now manipulate results according to the rquirement.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.