博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

一个比较有趣的汇编程序[汇编]

Posted on 2011-04-03 18:35  Code_HXH  阅读(622)  评论(0编辑  收藏  举报
TITLE MASM Template (main.asm)

; Description:
;

;
Revision date:2010/3/26

INCLUDE Irvine32.
inc
.data

;//TODD to imply the string on here.
str1 byte "(1) x AND y",0
str2 byte
"(2) x OR y",0
str3 byte
"(3) NOT x",0
str4 byte
"(4) x XOR y",0
str5 byte
"(5) exit the programe.",0
str6 byte
"please input the number you want to take:",0
str7 byte
"input 1:",0
str8 byte
"input 2:",0
str9 dword
0

.code
main PROC
mov dh,10
mov dl,25
call Gotoxy ;//to move you located in
mov edx,offset str1
call WriteString ;//To show the string in the screen.
mov dh,11
mov dl,25
call Gotoxy
mov edx,offset str2
call WriteString
mov dh,12
mov dl,25
call Gotoxy
mov edx,offset str3
call WriteString
mov dh,13
mov dl,25
call Gotoxy
mov edx,offset str4
call WriteString
mov dh,14
mov dl,25
call Gotoxy
mov edx,offset str5
call WriteString
mov dh,15
mov dl,10
call Gotoxy
mov edx,offset str6
call WriteString
call readchar

.IF al ==
'1' ;//to choose the answer.
call XandY
.ELSEIF al ==
'2'
call XorY
.ELSEIF al ==
'3'
call NotX
.ELSEIF al ==
'4'
call XxorY
.ELSEIF al ==
'5'
exit
.ENDIF

exit
main ENDP

;//-------------------The Small Function
XandY PROC ;//th
call crlf
mov edx,offset str7
call WriteString
call readhex
mov str9,eax
call Crlf
mov edx,offset str8
call WriteString
call readhex
and eax,str9
call WriteHex
exit
XandY ENDP

XorY PROC uses edx
;//this is the operate of the XorY
call crlf
mov edx,offset str7
call WriteString
call readhex
mov str9,eax
call Crlf
mov edx,offset str8
call WriteString
call readhex
or eax,str9
call WriteHex
exit
XorY ENDP

NotX PROC
;//this is the operating of the NOTx
call crlf
mov edx,offset str7
call WriteString
call readhex
call Crlf
NOT eax
call WriteHex
exit
NotX ENDP

XxorY PROC
;//this is the operating of the x or y
call crlf
mov edx,offset str7
call WriteString
call readhex
mov str9,eax
call Crlf
mov edx,offset str8
call WriteString
call readhex
xor eax,str9
call WriteHex
exit
XxorY ENDP

exit
END main