Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

.data read_num_p: .asciiz “Num†.text read_num_loop: li $v0, 4 #prompt for nu

ID: 3535196 • Letter: #

Question

.data

read_num_p: .asciiz “Numâ€

.text

read_num_loop: li $v0, 4 #prompt for number and read input

la $a0, read_num_p

syscall

li $v0, 5

syscall

beqz $v0, read_num_end #test for exit

add $t0, $t0, $v0 #add num to total & incr counter

addi $t1, $t1, -1

b read_num_loop

read_num_end: move $v0, $t0 #Load values to be returned

The number of lines may not match the lines you need. Add lines if needed. Remember to do both the .data and .text sections.

Address (Hex) Machine Code (6 bit opcode space 5 bit $R space 5 bit $R space

(either) 5 bit $R space 11 bit (1 3 bit and 2 4 bit groups) or 16 bits in 4 bit groups)


0x0040 880C

0x

0x

0x

0x

0x

0x

0x

0x

0x

0x

0x

0x

0x

0x0040 880C


0x

0x

0x

0x

0x

0x

0x

0x

0x

0x

0x

0x

0x

Explanation / Answer

I was going to suggest "generate a listing" like 500-InternalServerError proposed, but after verifying it, that won't work - the listing contains only your instructions, not MASM-generated ones. What does work is the following:


1) Assemble with debug info:


ml /c /Zi file.asm

2) disassemble with dumpbin (or another disassembler):


dumpbin /disasm file.obj

For the example above, it produces:


$$000000:

00000000: 83 3D 00 00 00 00 cmp dword ptr [x],5

05

00000007: 76 04 jbe @C0001

00000009: 8B C2 mov eax,edx

0000000B: EB 02 jmp @C0003

@C0001:

0000000D: 8B DA mov ebx,edx