Assembly 如何验证部件中的5位管脚? .data 描述字节“该程序将检查引脚是否符合规定的指南”,0dh,0ah 介绍字节“------------------------------------”,0dh,0ah 字节“请输入一个验证准则的五位PIN:”,0dh,
如何验证部件中的5位管脚?Assembly 如何验证部件中的5位管脚? .data 描述字节“该程序将检查引脚是否符合规定的指南”,0dh,0ah 介绍字节“------------------------------------”,0dh,0ah 字节“请输入一个验证准则的五位PIN:”,0dh,,assembly,x86,nasm,masm,Assembly,X86,Nasm,Masm,如何验证部件中的5位管脚? .data 描述字节“该程序将检查引脚是否符合规定的指南”,0dh,0ah 介绍字节“------------------------------------”,0dh,0ah 字节“请输入一个验证准则的五位PIN:”,0dh,0ah 字节“------------------------------------”,0dh,0ah 宾·德沃德? msg1字节“引脚有效”,0dh,0ah msg2字节“引脚无效”,0dh,0ah .代码 主进程 mov edx,偏移量介
.data
描述字节“该程序将检查引脚是否符合规定的指南”,0dh,0ah
介绍字节“------------------------------------”,0dh,0ah
字节“请输入一个验证准则的五位PIN:”,0dh,0ah
字节“------------------------------------”,0dh,0ah
宾·德沃德?
msg1字节“引脚有效”,0dh,0ah
msg2字节“引脚无效”,0dh,0ah
.代码
主进程
mov edx,偏移量介绍;edx简介
通话记录;显示介绍
调用Crlf;新线
调用ReadInt
mov引脚,eax;从用户获取PIN码
呼叫验证
调用ExitProcess,0
主端
验证程序
偏置销
如果([esi]>=5)&&([esi]=2)&([esi]=4)&([esi]=1)&([esi]=3)&([esi]不在汇编中进行编码。对于家庭作业,研究一些编译器的输出,以获得等效的C代码(例如,gcc-fverbose asm-O-S
,如果使用…)我希望我不必在汇编中编写这段代码,这会使一切变得更容易。你仍然可以用C编写一些例程,看看一个好的编译器正在用它编写的汇编代码。我不明白这个问题。你需要什么?
.data
descr byte "This program will check if the PIN is valid with the stated guidelines",0dh,0ah
intro byte "-------------------------------------",0dh,0ah
byte "Please enter a five digit PIN that validates the guidelines:",0dh,0ah
byte "-------------------------------------",0dh,0ah
PIN dword ?
msg1 byte "PIN is valid",0dh,0ah
msg2 byte "PIN is not valid",0dh,0ah
.code
main PROC
mov edx,OFFSET intro ;intro into edx
call WriteString ;display intro
call Crlf ;new line
call ReadInt
mov PIN,eax ;get PIN from user
call validate
invoke ExitProcess,0
main ENDP
validate PROC
mov si,OFFSET PIN
.IF ([esi]>=5) && ([esi]<=9) ;if 1st digit is within 5-9
add esi, TYPE PIN
.ELSE
mov edx,OFFSET msg2
call WriteString
.IF([esi]>=2) && ([esi]<=5) ;if 2nd is within 2-5
add esi, TYPE PIN
.ELSE
mov edx,OFFSET msg2
call WriteString
.IF([esi]>=4) && ([esi]<=8) ;if 3rd is within 4-8
add esi, TYPE PIN
.ELSE
mov edx,OFFSET msg2
call WriteString
.IF([esi]>=1) && ([esi]<=4) ;if 4th is within 1-4
add esi, TYPE PIN
.ELSE
mov edx,OFFSET msg2
call WriteString
.IF([esi]>=3) && ([esi]<=6) ;if 5th is within 3-6
mov edx,OFFSET msg1
call WriteString
.ELSE
mov edx,OFFSET msg2
call WriteString
.ENDIF
validate ENDP
end main