You must develop the following SIMMAC language programs to be run on your SIMMAC
ID: 670365 • Letter: Y
Question
You must develop the following SIMMAC language programs to be run on your SIMMAC machine:
1) Write three programs in the machine language of the SIMMAC that will total the numbers stored in 20 different locations and place the result in a single location.
2) Write a program in the machine language of the SIMMAC that will decrement the value stored in location 201 (must be at least 100) by one until the result is zero. Store the result in location 202.
3) Write a program in the machine language of the SIMMAC that will increment the value stored in location 301 by two until the value has been increased by 200. Store the result in location 302.
Each line of any SIMMAC program must have the following format:
Opcode Operand
You will be responsible for turning in the system design document, source code of your version of SIMMAC (this code must be appropriately commented & readable), an executable version of your SIMMAC, and the output generated from your SIMMAC programs running on your versionSIMMC
Explanation / Answer
1)
movl $20, -8(%rbp)
movl $0, %eax
2)
jg .L3
movl $0, %eax
3)
movl $1, -84(%rbp) movl $2, -8(%rbp) movl $3, -76(%rbp) movl $4, -72(%rbp) movl $5, -68(%rbp) movl $6, -64(%rbp) movl $7, -6(%rbp) movl $8, -56(%rbp) movl $9, -52(%rbp) movl $10, -48(%rbp) movl $11, -44(%rbp) movl $12, -4(%rbp) movl $13, -36(%rbp) movl $14, -32(%rbp) movl $15, -28(%rbp) movl $16, -24(%rbp) movl $17, -2(%rbp) movl $18, -16(%rbp) movl $19, -12(%rbp)movl $20, -8(%rbp)
movl $0, -4(%rbp) movl -80(%rbp), %eax movl -84(%rbp), %edx addl %eax, %edx movl -76(%rbp), %eax addl %eax, %edx movl -72(%rbp), %eax addl %eax, %edx movl -68(%rbp), %eax addl %eax, %edx movl -64(%rbp), %eax addl %eax, %edx movl -60(%rbp), %eax addl %eax, %edx movl -56(%rbp), %eax addl %eax, %edx movl -52(%rbp), %eax addl %eax, %edx movl -48(%rbp), %eax addl %eax, %edx movl -44(%rbp), %eax addl %eax, %edx movl -40(%rbp), %eax addl %eax, %edx movl -36(%rbp), %eax addl %eax, %edx movl -32(%rbp), %eax addl %eax, %edx movl -28(%rbp), %eax addl %eax, %edx movl -24(%rbp), %eax addl %eax, %edx movl -20(%rbp), %eax addl %eax, %edx movl -16(%rbp), %eax addl %eax, %edx movl -12(%rbp), %eax addl %eax, %edx movl -8(%rbp), %eax addl %edx, %eax movl %eax, -4(%rbp)movl $0, %eax
2)
movl $100, -8(%rbp)jmp .L2 .L3: subl $1, -8(%rbp) .L2: cmpl $0, -8(%rbp)
jg .L3
movl -8(%rbp), %eax movl %eax, -4(%rbp)movl $0, %eax
3)
movl $0, -8(%rbp) jmp .L2 .L3: addl $2, -8(%rbp) .L2: cmpl $200, -8(%rbp) jle .L3 movl -8(%rbp), %eax movl %eax, -4(%rbp) movl $0, %eaxRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.