Lab 6
Lab 6
Lab 6
Code:
INCLUDE Irvine32.inc
.data
fib DWORD 0, 1
count DWORD 10
.code
main PROC
mov eax, 0
mov ebx, 1
mov ecx, 2
call WriteDec
call Crlf
call WriteDec
call Crlf
FibonacciLoop:
call WriteDec
call Crlf
inc ecx
cmp ecx, count
jl FibonacciLoop
exit
main ENDP
END main
Output:
Task3:
INCLUDE Irvine32.inc
.data
employeeCount DWORD 5
totalSalary DWORD 0
.code
main PROC
mov ecx, 0
inputLoop:
jge calculateTotal
call WriteString
call ReadInt
call WriteString
call ReadString
call WriteString
call ReadInt
call WriteString
call ReadInt
inc ecx
jmp inputLoop
calculateTotal:
mov ecx, 0
salaryLoop:
jge done
inc ecx
jmp salaryLoop
done:
call WriteString
call WriteString
call Crlf
exit
main ENDP
END main
Output:
Task 4:
INCLUDE Irvine32.inc
.data
.code
main PROC
mov ecx, 0
copyLoop:
test al, al
jz done
inc ecx
jmp copyLoop
done:
call WriteString
exit
main ENDP
END main
Output:
Task 5:
INCLUDE Irvine32.inc
.data
array DWORD 1, 2, 3, 4, 5
.code
main PROC
shr ecx, 1
reverseLoop:
cmp ecx, 0
jle done
dec ecx
jmp reverseLoop
done:
call WriteInt
call Crlf
exit
main ENDP
END main
Output:
Tas6 :
INCLUDE Irvine32.inc
.data
array DWORD 8, 5, 1, 2, 6
.code
main PROC
outerLoop:
dec ecx
mov ebx, 0
innerLoop:
jbe skipSwap
mov [array + ebx * TYPE array], esi
skipSwap:
inc ebx
jl innerLoop
cmp ecx, 0
jg outerLoop
call WriteInt
call Crlf
exit
main ENDP
END main
Output: