Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

National Textile University, Faisalabad

Department of Computer Science

Name: SALEHA SHARMEEN

Class: BSAI-4TH

Registration No: 22-NTU-CS-1861

Lab Report: Procedure 2

Course Name: COAL


Submitted To: MR. NASIR MEHMOOD

Submission Date: 26-4-2024


TASK : 1
READ STRING

include irvine32.inc

.data
fileName BYTE 80 DUP(0)
.code
main PROC
mov edx,OFFSET fileName
mov ecx,SIZEOF fileName -1
call ReadString
CALL WriteSTring
Invoke ExitProcess,0
main endp
end main

READINT

include irvine32.inc

.data
dwordVal dword ?
.code
main PROC
call ReadInt ; input the integer
mov dwordVal,eax ; save in a variable
call writeint
Invoke ExitProcess,0
main endp
end main

DELAY AND CLEAR

include irvine32.inc
.code
main proc
call Clrscr
mov eax,500
call Delay
call DumpRegs
Invoke ExitProcess,0
main endp
end main
RANDOM 32

(random32 generates answer in hexadecimal so when we write call writeint it converts


hexa to integer form resulting in a very long number)
include irvine32.inc
.code
MAIN PROC
call random32
call writeint
Invoke ExitProcess,0
main endp
end main
(here we used randomize function to solve the issue of random32
generating same number again and again and write dec to get
unsigned decimal value)
include irvine32.inc
.code
MAIN PROC
call randomize
call random32
call writedec
Invoke ExitProcess,0
main endp
end main
RANDOM RANGE

(This will generate a random number in a given range)


include irvine32.inc
.code
MAIN PROC
call randomize
mov eax,50
call randomrange
call writeint
call crlf
call randomize
call random32
call writedec
Invoke ExitProcess,0
main endp
end main
AND OPERATOR
include irvine32.inc
.code
main PROC
mov al, 'a' ; AL = 01100001b
and al,11011111b ; AL = 01000001b
call writechar ;6th bit 0 tw uppercase 1 ho tw lowercase "and"
lower ko upper ma chnage krta hai
Invoke ExitProcess,0
main endp
end main
OR OPERATOR

include irvine32.inc
.code
main PROC
mov eax,0
mov al, 'A'
or al,00100000b
call writechar ;6th bit 0 tw uppercase 1 ho tw lowercase "or"
upper ko lower ma chnage krta hai
Invoke ExitProcess,0
main endp
end main
XOR OPERATOR

include irvine32.inc

.code
main PROC
mov eax,0
mov al, 00111011b
xor al,00001111b
call writebin
Invoke ExitProcess,0
main endp
end main
NOT OPERATOR

include irvine32.inc
.code
main PROC
mov eax,0
mov al, 00111011b
not al
call writebin
Invoke ExitProcess,0
main endp
end main
TEST OPERATOR

include irvine32.inc
.code
main proc
mov eax,0
mov al,0000001100b
test al,0000000011b
jnz ValueFound ; if not zero it will work
ValueFound:
mov eax,8
call writeint
jmp bypass ; to out from ValueFound label
jz ValueNotFound ;if zero it will work
ValueNotFound:
mov eax,7
call writeint
bypass:
exit
main endp
end main
CMP OPERATOR

include irvine32.inc
.code
main proc
mov al,5
cmp al,5 ; Zero flag set
call dumpregs
mov al,4
cmp al,5 ; Carry flag set
call dumpregs
mov al,6
cmp al,5 ; ZF = 0, CF = 0
call dumpregs
exit
main endp
end main
REMARKS:
In this lab we learnt the use of different operators like and, or,
not, xor, test and cmp. We also learnt taking input from the user.

You might also like