;1. x AND y
;2. x OR y
;3. x NOT y
;4. x XOR y
;5. EXIT

INCLUDE Irvine32.inc

.data
strAND	BYTE "1. X AND Y",0
strOR	BYTE "2. X OR Y",0
strNOT	BYTE "3. X NOT Y",0
strXOR	BYTE "4. X XOR Y",0
strEXIT	BYTE "5. EXIT",0
strX	BYTE "Enter value X : ",0
strY	BYTE "Enter value Y : ",0
num		DWORD ?
valX	DWORD ?
valY	DWORD ?

.code
MAIN PROC
	call	Clrscr
	
	mov		edx,OFFSET strAND
	call	WriteString
	call	Crlf
	
	mov		edx,OFFSET strOR
	call	WriteString
	call	Crlf
	
	mov		edx,OFFSET strNOT
	call	WriteString
	call	Crlf
	
	mov		edx,OFFSET strXOR
	call	WriteString
	call	Crlf
	
	mov		edx,OFFSET strEXIT
	call	WriteString
	call	Crlf
	
	call	ReadInt
	mov		num,eax
	
	cmp		num,1
	je		calland
	cmp		num,2
	je		callor
	cmp		num,3
	je		callnot
	cmp		num,4
	je		callxor
	jmp		quitprogram
	
calland:
	call	EnterX
	call	EnterY
	call	ANDProc
	jmp		quitprogram
callor:
	call	EnterX
	call	EnterY
	call	ORProc
	jmp		quitprogram
callnot:
	call	EnterX
	call	NOTProc
	jmp		quitprogram
callxor:
	call	EnterX
	call	EnterY
	call	XORProc
	jmp		quitprogram
	
quitprogram:
	exit
MAIN ENDP

ANDProc	PROC
	mov		eax,valX
	and		eax,valY
	call	WriteInt
	call	Crlf
	call	WriteBin
	ret
ANDProc	ENDP

ORProc	PROC
	mov		eax,valX
	or		eax,valY
	call	WriteInt
	call	Crlf
	call	WriteBin
	ret
ORProc	ENDP

NOTProc	PROC
	mov		eax,valX
	not		eax
	call	WriteInt
	call	Crlf
	call	WriteBin
	ret
	ret
NOTProc	ENDP

XorProc	PROC
	mov		eax,valX
	xor		eax,valY
	call	WriteInt
	call	Crlf
	call	WriteBin
	ret
XORProc	ENDP

EnterX	PROC
	mov		edx,OFFSET strX
	call	WriteString
	call	ReadInt
	mov		valX,eax
	ret
EnterX	ENDP

EnterY	PROC
	mov		edx,OFFSET strY
	call	WriteString
	call	ReadInt
	mov		ValY,eax
	ret
EnterY	ENDP

END main

bool 연산 결과를 10진수와 2진수로 화면에 출력합니다.

점심 먹고 소화시킬 겸 간단히 풀이 연습~♪

Posted by 공돌이pooh
,