Include Irvine32.inc
INCLUDELIB Irvine32.lib

INCLUDELIB kernel32.lib
INCLUDELIB User32.Lib

.const
	L = 20; String length

.data
	randomStringArray WORD L DUP(0), 0; Array for random strings of length 10
;	arrayD   WORD   37h, 36h, 4ah, 4bh, 34h, 55h, 41h, 58h, 4eh, 45h, 53h, 5ah, 53h, 54h, 45h, 53h, 4dh, 34h, 51h, 41h
	seedD WORD 53h,54h,55h,56h,36h,37h,34h,35h,49h,4ah,4bh,4ch,5ah,33h,43h,44h,38h,39h,41h,46h,47h,4dh,4eh,42h,57h,58h,59h,48h,45h,50h,51h,52h
	randomseed BYTE 53h,54h,55h,56h,36h,37h,34h,35h,49h,4ah,4bh,4ch,5ah,33h,43h,44h,38h,39h,41h,46h,47h,4dh,4eh,42h,57h,58h,59h,48h,45h,50h,51h,52h
.code

start:
;SN檢查2
	call Randomize
L1:
	push ecx							; save outer loop count
	mov ecx, 20						; loop counter = 10
	mov [ebp+8], OFFSET randomStringArray	; string index
	mov esi, OFFSET randomseed
	mov ebx, 0
L2:
	mov eax, 32							; generate int of 0 - 25
	call RandomRange					; generates random int in specified range
	movzx eax, byte ptr [esi+eax]
	mov[ebp+ebx+8], eax				; store the character at index esi
	inc ebp
	inc ebx								; increase index to next character position
loop L2									; end loop 2
	movzx eax, word ptr [esi+18]
	mov [ebp+26], al
	lea edx, dword ptr ss:[ebp-0Ch]
	pop ecx
	mov ebp, edx
	sub ebp, 8
;	mov [ebp+8], OFFSET arrayD
	push ebx
	lea ebx,dword ptr ss:[ebp+8]
;	push esi
	push edi
	mov ecx,10h
	mov esi, OFFSET seedD
	lea edi,dword ptr ss:[ebp-5Ch]  
	rep movsd  
	mov edx,ebx
	mov dword ptr ss:[ebp-60h],eax  
	movsw   
	lea ecx,dword ptr ds:[edx+2]
	mov esi,0  
	mov edi,esi
	mov edi,edi
label52044080:
	movzx ecx,word ptr ds:[ebx+edi*2]
	lea eax,dword ptr ds:[ecx-61h]  
	cmp ax,19h
	ja label52044093               
label52044093:
	xor eax,eax
label52044095:
	cmp word ptr ss:[ebp+eax*2-5Ch],cx
	je label520440A4     
	inc eax 
	cmp eax,20h
	jb label52044095     
	jmp label520440B2    
label520440A4:
	cmp esi,14h
	jae label520440C2
	mov byte ptr ss:[ebp+esi-18h],al
	inc esi 
label520440B2:
	inc edi 
	cmp edi,edx
	jb label52044080     
	cmp esi,14h
	jne label520441A0
label520440C2:
	movzx ecx,byte ptr ss:[ebp-18h] 
	movzx eax,byte ptr ss:[ebp-17h] 
	movzx edx,byte ptr ss:[ebp-12h] 
	shl ecx,5  
	or ecx,eax 
	movzx eax,byte ptr ss:[ebp-16h] 
	shl ecx,5  
	or ecx,eax 
	movzx eax,byte ptr ss:[ebp-15h] 
	shl ecx,5  
	or ecx,eax 
	movzx eax,byte ptr ss:[ebp-14h] 
	shl ecx,5  
	or ecx,eax 
	movzx eax,byte ptr ss:[ebp-13h] 
	shl ecx,5  
	or ecx,eax 
	mov eax,edx
	shr eax,3  
	movzx esi,byte ptr ss:[ebp-0Ch]  
	shl edx,5  
	shl ecx,2  
	or ecx,eax 
	cmp ecx, 03C5FCECh
	jne L1
	movzx eax,byte ptr ss:[ebp-11h] 
	or edx,eax 
	movzx eax,byte ptr ss:[ebp-10h] 
	shl edx,5  
	or edx,eax 
	movzx eax,byte ptr ss:[ebp-0Fh]  
	shl edx,5  
	or edx,eax 
	movzx eax,byte ptr ss:[ebp-0Eh]  
	shl edx,5  
	or edx,eax 
	movzx eax,byte ptr ss:[ebp-0Dh] 
	shl edx,5  
	or edx,eax 
	mov eax,esi
	shr eax,1  
	shl esi,5  
	shl edx,4  
	or edx,eax 
	pop ebx
	cmp edx, 0D4BB986Bh
	jne L1
	mov edx, ebp
	add edx, 8
	mov ecx, 20
L3:	
	call WriteString
	add edx, 2
loop L3	
label520441A0:
	ret
end start 

Assembly Online Compiler

Write, Run & Share Assembly code online using OneCompiler's Assembly online compiler for free. It's one of the robust, feature-rich online compilers for Assembly language. Getting started with the OneCompiler's Assembly compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Assembly and start coding.

About Assembly

Assembly language(asm) is a low-level programming language, where the language instructions will be more similar to machine code instructions.

Every assembler may have it's own assembly language designed for a specific computers or an operating system.

Assembly language requires less execution time and memory. It is more helful for direct hardware manipulation, real-time critical applications. It is used in device drivers, low-level embedded systems etc.

Syntax help

Assembly language usually consists of three sections,

  1. Data section

    To initialize variables and constants, buffer size these values doesn't change at runtime.

  2. bss section

    To declare variables

  3. text section

    _start specifies the starting of this section where the actually code is written.

Variables

There are various define directives to allocate space for variables for both initialized and uninitialized data.

1. To allocate storage space to Initialized data

Syntax

variable-name    define-directive    initial-value 
Define DirectiveDescriptionAllocated Space
DBDefine Byte1 byte
DWDefine Word2 bytes
DDDefine Doubleword4 bytes
DQDefine Quadword8 bytes
DTDefine Ten Bytes10 bytes

2. To allocate storage space to un-initialized data

Define DirectiveDescription
RESBReserve a Byte
RESWReserve a Word
RESDReserve a Doubleword
RESQReserve a Quadword
RESTReserve a Ten Bytes

Constants

Constants can be defined using

1. equ

  • To define numeric constants
CONSTANT_NAME EQU regular-exp or value

2. %assign

  • To define numeric constants.
%assign constant_name value

3. %define

  • To define numeric or string constants.
%define constant_name value

Loops

Loops are used to iterate a set of statements for a specific number of times.

mov ECX,n
L1:
;<loop body>
loop L1

where n specifies the no of times loops should iterate.

Procedures

Procedure is a sub-routine which contains set of statements. Usually procedures are written when multiple calls are required to same set of statements which increases re-usuability and modularity.

procedure_name:
   ;procedure body
   ret