Question
hey I need help in this assignment that is to be done in Azure in visual studio CODE INCLUDE Irvine32.inc .data myMessage BYTE MASM Project05,0dh,0ah,0
hey I need help in this assignment that is to be done in Azure in visual studio
CODE
INCLUDE Irvine32.inc .data myMessage BYTE "MASM Project05",0dh,0ah,0
.code main PROC call Clrscr
mov edx,OFFSET myMessage call WriteString call WaitMsg
exit main ENDP
END main
INSTRUCTION
This assignment will ask you to determine the total number of set bits (i.e. bits that have the value of 1) in the binary representation of the first letter of your first name. You should have the first letter of your first name in UPPER case in your Data Segment.
You will probably want to have a loop that runs 8 times to be able to check all eight bits of the character you are testing.
You will probably want to use a rotate instruction (ROR) to rotate all bits through the carry flag (CF), testing the carry flag after each of the eight rotates.
Once you have the count within an internal register (say bl) you will want to print out that value by taking into account the following:
When you print out your answer you will want to be sure you have converted your answer to ASCII.
For example:
The OR instruction can be used to convert a byte containing an integer between 0 and 9 into an ASCII digit. To do this, you must set bits 4 and 5. If, for example, AL = 05h, you can OR it with 30h to convert it to the ASCII code for the digit 5 (35h).
00000101 05h
OR 00110000 30h
00110101 35h, 5
The assemble language instructions to do this are as follows:
mov bl,5 ; binary value
or bl,30h ; convert to ASCII
Take a REAL CLOSE LOOK at the picture at the slide for the ROR instruction and realize that the rightmost bit is being shifted into the CF bitthis is where we do our testing with the JC or the JNC instructions.See slides 22-24 in chapter 6 of the PowerPoint slides provided on Blackboard for information on the JC and JNC instructions.
Here are some ideas for this assignment
ROR instruction. Lets see how many bits are set in the first letter of your first name.
- JC instruction Jump if the Carry Bit is Set
- JNC instruction Jump if the Carry Bit is NOT Set
- Lets rotate out first character 8 times and see how many times the Carry Bit is set.
- Lets count how many times and then print out that answer.
- You will probably do your counting within a register, such as the BL register with a command such as inc bl.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started