Write an Assembly Language program that generates a random n
Write an Assembly Language program that generates a random number between 0 to 9, then ask user to choose a number from 0 to 9. If the user chooses the same number as the random number, output “You
Win! Congratulations! It took you x tries!\" (where x is how many times the user tried to get the correct number). If user choose a smaller number to the random number, output \"Your guess is too low, try again If user choose a larger number to the random number, output \"Your guess is too high, try again!\". If user choose a number smaller than 0 or greater than 9, output \"Invalid input, try again. and this is not count as a try. The game keeps repeating till the user chooses the correct number. A Sample Scenario: Guess a number (0 to 9): Your guess is too low, try again! Guess a number (0 to 9) Your guess is too high, try again! Guess a number (0 to 9 100 Invalid input, try again! Guess a number (0 to 9 You Win! Congratulations It took you 3 tries!Solution
686P
 .XMM
 .model flat
 INCLUDELIB LIBCMT
 INCLUDELIB OLDNAMES
 CONST SEGMENT
 $SG6822 DB \'Enter a number between 0-9\', 00H
 ORG $+1
 $SG6823 DB \'%d\', 00H
 ORG $+1
 $SG6826 DB \'you win!\', 00H
 ORG $+3
 $SG6827 DB \'You loose Want to try again enter 1 to exit enter 0 Try \'
 DB \'again!\', 00H
 ORG $+1
 $SG6828 DB \'%d\', 00H
 CONST ENDS
 PUBLIC ___local_stdio_printf_options
 PUBLIC ___local_stdio_scanf_options
 PUBLIC __vfprintf_l
 PUBLIC __vcrt_va_start_verify_argument_type<char const * const>
 PUBLIC _printf
 PUBLIC __vfscanf_l
 PUBLIC _scanf
 PUBLIC _main
 PUBLIC `__local_stdio_printf_options\'::`2\'::_OptionsStorage
 PUBLIC `__local_stdio_scanf_options\'::`2\'::_OptionsStorage
 EXTRN ___acrt_iob_func:PROC
 EXTRN ___stdio_common_vfprintf:PROC
 EXTRN ___stdio_common_vfscanf:PROC
 EXTRN __time64:PROC
 EXTRN _srand:PROC
 EXTRN _rand:PROC
 ; COMDAT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA
 _BSS SEGMENT
 `__local_stdio_printf_options\'::`2\'::_OptionsStorage DQ 01H DUP (?)
 _BSS ENDS
 ; COMDAT ?_OptionsStorage@?1??__local_stdio_scanf_options@@9@4_KA
 _BSS SEGMENT
 `__local_stdio_scanf_options\'::`2\'::_OptionsStorage DQ 01H DUP (?)
 _BSS ENDS
 ; Function compile flags: /Odtp
 _TEXT SEGMENT
 _ta$ = -16 ; size = 4
 _n$ = -12 ; size = 4
 _un$ = -8 ; size = 4
 _f$ = -4 ; size = 4
 _main PROC
 push ebp
 mov ebp, esp
 sub esp, 16 ; 00000010H
 push 0
 call _time
 add esp, 4
 push eax
 call _srand
 add esp, 4
 call _rand
 cdq
 mov ecx, 10 ; 0000000aH
 idiv ecx
 mov DWORD PTR _n$[ebp], edx
 mov DWORD PTR _f$[ebp], 1
 $LN2@main:
 cmp DWORD PTR _f$[ebp], 0
 jle SHORT $LN3@main
 push OFFSET $SG6822
 call _printf
 add esp, 4
 lea edx, DWORD PTR _un$[ebp]
 push edx
 push OFFSET $SG6823
 call _scanf
 add esp, 8
 mov eax, DWORD PTR _un$[ebp]
 cmp eax, DWORD PTR _n$[ebp]
 jne SHORT $LN4@main
 push OFFSET $SG6826
 call _printf
 add esp, 4
 jmp SHORT $LN5@main
 $LN4@main:
 push OFFSET $SG6827
 call _printf
 add esp, 4
 lea ecx, DWORD PTR _ta$[ebp]
 push ecx
 push OFFSET $SG6828
 call _scanf
 add esp, 8
 cmp DWORD PTR _ta$[ebp], 1
 jne SHORT $LN6@main
 jmp SHORT $LN2@main
 jmp SHORT $LN5@main
 $LN6@main:
 jmp SHORT $LN3@main
 $LN5@main:
 jmp SHORT $LN2@main
 $LN3@main:
 xor eax, eax
 mov esp, ebp
 pop ebp
 ret 0
 _main ENDP
 _TEXT ENDS
 ; Function compile flags: /Odtp
 _TEXT SEGMENT
 __Time$ = 8 ; size = 4
 _time PROC
 push ebp
 mov ebp, esp
 mov eax, DWORD PTR __Time$[ebp]
 push eax
 call __time64
 add esp, 4
 pop ebp
 ret 0
 _time ENDP
 _TEXT ENDS
 ; Function compile flags: /Odtp
 ; COMDAT _scanf
 _TEXT SEGMENT
 __Result$ = -8 ; size = 4
 __ArgList$ = -4 ; size = 4
 __Format$ = 8 ; size = 4
 _scanf PROC ; COMDAT
 push ebp
 mov ebp, esp
 sub esp, 8
 call __vcrt_va_start_verify_argument_type<char const * const>
 lea eax, DWORD PTR __Format$[ebp+4]
 mov DWORD PTR __ArgList$[ebp], eax
 mov ecx, DWORD PTR __ArgList$[ebp]
 push ecx
 push 0
 mov edx, DWORD PTR __Format$[ebp]
 push edx
 push 0
 call ___acrt_iob_func
 add esp, 4
 push eax
 call __vfscanf_l
 add esp, 16 ; 00000010H
 mov DWORD PTR __Result$[ebp], eax
 mov DWORD PTR __ArgList$[ebp], 0
 mov eax, DWORD PTR __Result$[ebp]
 mov esp, ebp
 pop ebp
 ret 0
 _scanf ENDP
 _TEXT ENDS
 ; Function compile flags: /Odtp
 ; COMDAT __vfscanf_l
 _TEXT SEGMENT
 __Stream$ = 8 ; size = 4
 __Format$ = 12 ; size = 4
 __Locale$ = 16 ; size = 4
 __ArgList$ = 20 ; size = 4
 __vfscanf_l PROC ; COMDAT
 push ebp
 mov ebp, esp
 mov eax, DWORD PTR __ArgList$[ebp]
 push eax
 mov ecx, DWORD PTR __Locale$[ebp]
 push ecx
 mov edx, DWORD PTR __Format$[ebp]
 push edx
 mov eax, DWORD PTR __Stream$[ebp]
 push eax
 call ___local_stdio_scanf_options
 mov ecx, DWORD PTR [eax+4]
 push ecx
 mov edx, DWORD PTR [eax]
 push edx
 call ___stdio_common_vfscanf
 add esp, 24 ; 00000018H
 pop ebp
 ret 0
 __vfscanf_l ENDP
 _TEXT ENDS
 ; Function compile flags: /Odtp
 ; COMDAT _printf
 _TEXT SEGMENT
 __Result$ = -8 ; size = 4
 __ArgList$ = -4 ; size = 4
 __Format$ = 8 ; size = 4
 _printf PROC ; COMDAT
 push ebp
 mov ebp, esp
 sub esp, 8
 call __vcrt_va_start_verify_argument_type<char const * const>
 lea eax, DWORD PTR __Format$[ebp+4]
 mov DWORD PTR __ArgList$[ebp], eax
 mov ecx, DWORD PTR __ArgList$[ebp]
 push ecx
 push 0
 mov edx, DWORD PTR __Format$[ebp]
 push edx
 push 1
 call ___acrt_iob_func
 add esp, 4
 push eax
 call __vfprintf_l
 add esp, 16 ; 00000010H
 mov DWORD PTR __Result$[ebp], eax
 mov DWORD PTR __ArgList$[ebp], 0
 mov eax, DWORD PTR __Result$[ebp]
 mov esp, ebp
 pop ebp
 ret 0
 _printf ENDP
 _TEXT ENDS
 ; Function compile flags: /Odtp
 ; COMDAT ??$__vcrt_va_start_verify_argument_type@QBD@@YAXXZ
 _TEXT SEGMENT
 __vcrt_va_start_verify_argument_type<char const * const>, COMDAT PROC
 push ebp
 mov ebp, esp
 pop ebp
 ret 0
 __vcrt_va_start_verify_argument_type<char const * const> ENDP
 _TEXT ENDS
 ; Function compile flags: /Odtp
 ; COMDAT __vfprintf_l
 _TEXT SEGMENT
 __Stream$ = 8 ; size = 4
 __Format$ = 12 ; size = 4
 __Locale$ = 16 ; size = 4
 __ArgList$ = 20 ; size = 4
 __vfprintf_l PROC ; COMDAT
 push ebp
 mov ebp, esp
 mov eax, DWORD PTR __ArgList$[ebp]
 push eax
 mov ecx, DWORD PTR __Locale$[ebp]
 push ecx
 mov edx, DWORD PTR __Format$[ebp]
 push edx
 mov eax, DWORD PTR __Stream$[ebp]
 push eax
 call ___local_stdio_printf_options
 mov ecx, DWORD PTR [eax+4]
 push ecx
 mov edx, DWORD PTR [eax]
 push edx
 call ___stdio_common_vfprintf
 add esp, 24 ; 00000018H
 pop ebp
 ret 0
 __vfprintf_l ENDP
 _TEXT ENDS
 ; Function compile flags: /Odtp
 ; COMDAT ___local_stdio_scanf_options
 _TEXT SEGMENT
 ___local_stdio_scanf_options PROC ; COMDAT
 push ebp
 mov ebp, esp
 mov eax, OFFSET `__local_stdio_scanf_options\'::`2\'::_OptionsStorage
 pop ebp
 ret 0
 ___local_stdio_scanf_options ENDP
 _TEXT ENDS
 ; Function compile flags: /Odtp
 ; COMDAT ___local_stdio_printf_options
 _TEXT SEGMENT
 ___local_stdio_printf_options PROC ; COMDAT
 push ebp
 mov ebp, esp
 mov eax, OFFSET `__local_stdio_printf_options\'::`2\'::_OptionsStorage
 pop ebp
 ret 0
 ___local_stdio_printf_options ENDP
 _TEXT ENDS
 END





