This assignment is for the assembly language class, so please use assembly langu
ID: 3677081 • Letter: T
Question
This assignment is for the assembly language class, so please use assembly language to do this assignment.
Please do not copy someone's code that is close to this assignment, if u can please use comment after each code to explain why u use it.
Please answer all the parts
Really appreciate for your help.
1.
a. Create a procedure (GetInput) that asks the user for N, j and k. Thisprocedure will not receive anything from the calling procedure. N, j and k will beunsigned values and will have to be passed back to the calling procedure viaregisters. N is a number between 0 and 50 and j < k. if N is greater than 50, askthe user for another number. If j >= k ask the user to re-enter those numbers.
b. Create a procedure (ArrayFill) that fills an array of doublewords with N (N <50) random integers, making sure the values fall within the range j…k inclusive.When calling the procedure, pass a pointer to the array that will hold the data,pass N, and pass the values of j and k. Preserve all register values between callsto the procedure.
Since we cannot generate an array on the fly, you may declare an array ofDWORDs that is 50 elements long.
c. Write a procedure (RandomColor) that randomly generates an integerbetween 0 and 9. Use this integer along with the hint below to pick what colorwill be used when displaying text. The probabilities for each color are:
Blue = 30% Red = 10% Green = 60%
HINT: If the integer is between 0-2 (inclusive), choose blue If the integer = 3, choose red If the integer is in the range 4-9 (inclusive), choose green.
d. Create a menu (MainMenu) that provides the following options.
1) Print Randomly Generated Arrays2) Repeat3) Quit
You must use cmp and jcond in the menu. DO NOT USE table-driven selection foryour menu.
Option 1 requires the user to enter the requested values.
Option 2 prints the randomly generated arrays again with previously enteredvalues. (You do not have to error check that there are previously entered values.)
Option 3 – cleanly exit. No segmentation faults etc.If the user enters an invalid option, redisplay the menu and ask for a valid option.
2. Create a program that uses all of the above procedures to print a randomlygenerated array of numbers in a randomly chosen color (as specified by theRun your program 10 times, do the probabilities hold? Provide the analysis toshow that the probabilities hold or not. Submit a pdf with your analysis.
1. Any output will be shown in the console window.
2. You may use any command Chapter 6 and below.
3. Your procedure(s) must be called from the main procedure.
Explanation / Answer
.Ltext0: .local _ZStL8__ioinit .comm _ZStL8__ioinit,1,1 .globl n .bss .align 4 n: 0000 00000000 .zero 4 .globl k .align 4 k: 0004 00000000 .zero 4 .globl j .align 4 j: 0008 00000000 .zero 4 .section .rodata .LC0: 0000 6B206973 .string "k is " 2000 .text .globl main main: .LFB971: .cfi_startproc 0000 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0001 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 0004 53 pushq %rbx 0005 4883EC08 subq $8, %rsp .cfi_offset 3, -24 .L2: 0014 83F832 cmpl $50, %eax 0017 7FF0 jg .L2 0009 E8000000 call _Z8getInputv 00 000e 8B050000 movl n(%rip), %eax 0000 0019 8B150000 movl j(%rip), %edx 0000 001f 8B050000 movl k(%rip), %eax 0000 0025 39C2 cmpl %eax, %edx 0027 7DE0 jge .L2 0029 8B1D0000 movl k(%rip), %ebx 0000 002f BE000000 movl $.LC0, %esi 00 0034 BF000000 movl $_ZSt4cout, %edi 00 0039 E8000000 call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc 00 003e 89DE movl %ebx, %esi 0040 4889C7 movq %rax, %rdi 0043 E8000000 call _ZNSolsEi 00 0048 B8000000 movl $0, %eax 00 004d 4883C408 addq $8, %rsp 0051 5B popq %rbx 0052 5D popq %rbp .cfi_def_cfa 7, 8 0053 C3 ret .cfi_endproc .LFE971: .section .rodata .LC1: 0006 656E7465 .string "enter the value of k " 72207468 65207661 6C756520 6F66206B .LC2: 001c 656E7465 .string "enter the value of j " 72207468 65207661 6C756520 6F66206A .LC3: 0032 656E7465 .string "enter the value of n " 72207468 65207661 6C756520 6F66206E .text .globl _Z8getInputv _Z8getInputv: .LFB972: .cfi_startproc 0054 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0055 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 0058 BE000000 movl $.LC1, %esi 00 005d BF000000 movl $_ZSt4cout, %edi 00 0062 E8000000 call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc 00 0067 BE000000 movl $k, %esi 00 006c BF000000 movl $_ZSt3cin, %edi 00 0071 E8000000 call _ZNSirsERi 00 0076 BE000000 movl $.LC2, %esi 00 007b BF000000 movl $_ZSt4cout, %edi 00 0080 E8000000 call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc 00 0085 BE000000 movl $j, %esi 00 008a BF000000 movl $_ZSt3cin, %edi 00 008f E8000000 call _ZNSirsERi 00 0094 BE000000 movl $.LC3, %esi 00 0099 BF000000 movl $_ZSt4cout, %edi 00 009e E8000000 call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc 00 00a3 BE000000 movl $n, %esi 00 00a8 BF000000 movl $_ZSt3cin, %edi 00 00ad E8000000 call _ZNSirsERi 00 00b2 5D popq %rbp .cfi_def_cfa 7, 8 00b3 C3 ret .cfi_endproc .LFE972: _Z41__static_initialization_and_destruction_0ii: .LFB976: 00d1 BF000000 movl $_ZStL8__ioinit, %edi 00 00d6 E8000000 call _ZNSt8ios_base4InitC1Ev 00 00db BA000000 movl $__dso_handle, %edx 00 00e0 BE000000 movl $_ZStL8__ioinit, %esi 00 00e5 BF000000 movl $_ZNSt8ios_base4InitD1Ev, %edi 00 00ea E8000000 call __cxa_atexit 00 .cfi_startproc 00b4 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 00b5 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 00b8 4883EC10 subq $16, %rsp 00bc 897DFC movl %edi, -4(%rbp) 00bf 8975F8 movl %esi, -8(%rbp) 00c2 837DFC01 cmpl $1, -4(%rbp) 00c6 7527 jne .L5 00c8 817DF8FF cmpl $65535, -8(%rbp) FF0000 00cf 751E jne .L5 .L5: 00ef C9 leave .cfi_def_cfa 7, 8 00f0 C3 ret .cfi_endproc .LFE976: _GLOBAL__sub_I_n: .LFB977: .cfi_startproc 00f1 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 00f2 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 00f5 BEFFFF00 movl $65535, %esi 00 00fa BF010000 movl $1, %edi 00 00ff E8B0FFFF call _Z41__static_initialization_and_destruction_0ii FF 0104 5D popq %rbp .cfi_def_cfa 7, 8 0105 C3 ret .cfi_endproc .LFE977: .section .init_array,"aw" .align 8 0000 00000000 .quad _GLOBAL__sub_I_n 00000000 .text .Letext0:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.