Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a 32 bit Masm Assembly language program to do the following starting with

ID: 3536445 • Letter: W

Question

Write a 32 bit Masm Assembly language program to do the following starting with the following declaration

val dword 22

str byte "aBc", 0


a) Using bit operation, determine whether val is even or odd. Do not change val. If you use shift, they should be logical shift





b. Write a loop that processes the string str

byte-by-byte, changing each lowercase letter into the corresponding capital

letter using bit operations. If the letter is already

capital, leave it alone. (Hint:

there are several ways to do this; explore the Boolean ops! How many bits must

change per byte?) Print the changed value of str.

Explanation / Answer

a) DATA SEGMENT X DW 27H MSG1 DB 19,13,'NUMBER IS EVEN$' MSG2 DB 10,13,'NUMBER IS ODD$' DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV AX,X TEST AX,01H JNZ EXIT LEA DX,MSG1 MOV AH,09H INT 21H JMP LAST ;Test for Even/Odd number. ;If it is Even go to Exit label. ;(alternate logic) ;MOV BL,2 ;DIV BL ;CMP AH,0H ;JNZ EXIT ;Declare it is Even number. EXIT: LEA DX,MSG2 ;Declare it is Odd number. MOV AH,09H INT 21H LAST: MOV AH,4CH INT 21H CODE ENDS END START b) READ MACRO MSG MOV AH,0AH LEA DX,MSG INT 21H ENDM PRINT MACRO MSG MOV AH,09H LEA DX,MSG INT 21H ENDM DATA SEGMENT CR EQU 0DH LF EQU 0AH MSG1 DB "ENTER THE STRING IN LOWERCASE:$" MSG2 DB CR,LF,"THE UPPERCASE STRING IS :$" BUFF DB 255 DB 0 DB 255 DUP ('$') DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX PRINT MSG1 READ BUFF MOV SI,OFFSET BUFF+2 MOV CL,BYTEPTR[SI-1] MOV CH,00H LP1: MOV AH,[SI] MOV AL,61H JB LP1 CMP AL,7BH JNB LP1 SUB AL,20H MOV [SI],AL LP2: INC SI LOOP SP1 PRINT MSG2 PRINT MSG2 PRINT BUFF+2 MOV AH,4CH INT 21H CODE ENDS END START

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote