2013-04-18 21:51:22Morris
[組合語言][練習] 產生20個隨機字串
題目意思:這二十個字串要包含數字或英文字母
TITLE
;displays 20 random strings, each consisting of 10 capital
;letter {A...Z}
;call Crlf == '\n'
INCLUDE Irvine32.inc
.data
.code
start PROC
mov ecx, 20
loopi:
push ecx
mov ecx, 10
loopj:
mov eax, 62 ; RandomRange[0, eax-1]
call RandomRange ; result in eax
cmp eax, 10 ; 0 <= eax < 10 is number
jae letter ; eax >= 10 is letter
add eax, 48 ; eax += '0'
jmp print
letter:
cmp eax, 36 ; 10 <= eax < 10+26 is upper
jae lower ; eax >= 36
add eax, 55 ; eax = eax-10+'A'
jmp print
lower:
add eax, 61 ; eax = eax-36+'a'
print:
call WriteChar
loop loopj
pop ecx
call Crlf
loop loopi
invoke ExitProcess, 0
start ENDP
end start
; if(eax < 10)
; printf("%c", eax+'0');
; else if(eax < 36)
; printf("%c", eax-10+'A');
; else
; printf("%c", eax-36+'a');
jae是啥阿