Professional Documents
Culture Documents
COAL Lab 11 (22k-4136)
COAL Lab 11 (22k-4136)
Task 1:
INCLUDE Irvine32.inc
.data
.code
main PROC
call Scan_Str
exit
main ENDP
Scan_Str PROC
mov eax,edi
mov ebx,offset string1
sub eax,ebx
mov edx,offset prompt
call writestring
call writeDec
bottom:
ret
Scan_Str ENDP
END main
Task 2:
INCLUDE Irvine32.inc
.data
.code
Scan_Str PROC string1OFFSET:PTR BYTE,promptOFFSET:PTR BYTE,arham:BYTE
mov edi,string1OFFSET
mov eax,0
mov al,arham
mov ecx,LENGTHOF string1
cld
repne scasb
jnz bottom
dec edi
mov eax,edi
mov ebx,offset string1
sub eax,ebx
mov edx,promptOFFSET
call writestring
call writeDec
bottom:
ret
Scan_Str ENDP
main PROC
INVOKE Scan_Str,ADDR string1,ADDR prompt,'#'
exit
main ENDP
END main
Task 3:
INCLUDE Irvine32.inc
INCLUDE macros.inc
.data
.code
IsCompare PROC str1OFFSET:PTR BYTE,str2OFFSET:PTR BYTE,len:PTR DWORD
mov esi,str1OFFSET
mov edi,str2OFFSET
mov ecx,len
repe cmpsb
jnz notSame
mwrite "The strings are same"
jmp bottom
notSame:
mwrite "The strings are different"
bottom:
ret
IsCompare ENDP
main PROC
exit
main ENDP
END main
Task 4:
INCLUDE Irvine32.inc
INCLUDE macros.inc
.data
.code
Str_Reverse PROC str1OFFSET:PTR BYTE,str2OFFSET:PTR BYTE,len:PTR DWORD
mov esi,str1OFFSET
mov edi,str2OFFSET
mov ecx,len
sub ecx,2
L1:
mov al,[esi+ecx]
stosb
Loop L1
mov al,[esi]
stosb
mov edx,str2OFFSET
call writeString
ret
Str_Reverse ENDP
main PROC
exit
main ENDP
END main
Task 5:
INCLUDE Irvine32.inc
.data
arr BYTE 1,2,3,4,5,6,7,8,9,10
multiplier DWORD 5
prompt BYTE " ",0
.code
main PROC
cld
push LENGTHOF arr
push OFFSET arr
push multiplier
call crlf
call LOAD
exit
main ENDP
LOAD PROC
enter 0,0
mov ecx,[ebp+16]
mov esi,[ebp+12]
mov ebx,[ebp+8]
mov edi,esi
cld
L1:
Lodsb
mul ebx
Stosb
Loop L1
leave
ret
LOAD ENDP
END main
Task 6:
INCLUDE Irvine32.inc
INCLUDE macros.inc
.data
str1 BYTE "AADDDCFBBCEE",0
freqTable DWORD 256 DUP(0)
.code
Get_frequencies PROC str1OFFSET:PTR BYTE, freqTableOFFSET:PTR DWORD
mov ecx, 0
mov esi, str1OFFSET
top:
mov al, [esi]
cmp al, 0
je quit
inc ecx
inc esi
jmp top
quit:
ret
Get_frequencies ENDP
main PROC
INVOKE Get_frequencies, ADDR str1, ADDR freqTable
L2:
mov eax, [esi + edi]
cmp eax, 0
je jump
mov al, dl
call WriteChar
mWrite " = "
mov eax, [esi + edi]
call WriteDec
mWrite " , "
jump:
add edi, 4
inc dl
Loop L2
INVOKE ExitProcess, 0
main ENDP
END main