我的老师为我们分配了此工作表,这确实给我带来了麻烦。我很难确切知道我应该从中乘以或除以索引指令,然后根据该值确定溢出。
例如,在字母E上有
imulw 12(%ebx, %edx, 8)
和更改的寄存器是dx:ax,因为操作数的大小为16位。答案是
0004:CA63
但是我很难理解0004的来源。
答案 0 :(得分:0)
您被问到计算机将要做什么。因此,请问计算机它将做什么(https://youtu.be/xaVgRj2e5_s?t=167):
# Linux:
# Name: computer.s (capital S if compiled in Windows)
# Compile: gcc -m32 -o computer computer.s
# Run: ./computer (Don't forget dot-slash!)
#if defined(__WIN32__)
#define main _main
#define printf _printf
#endif
.data
arr: .long 0x5, 0x7, 0x8, 0xD, 0x9, 0xC1A55ED, 0xDECADE, 0xFADEDBAD, 0x700300, 0x400800
fmt: .string "%c % 4X % 8X:%- 8X OF=%c\n"
.text
.global main
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp # Space for 6 DWORD à 4 byte
andl $-16, %esp # Align stack to 16
E: call init
lea 12(%ebx,%edx,8), %edi # Claculate the operand and store it in EDI
movl $arr, %ebx # Modify EBX to point to arr
imulw 12(%ebx, %edx, 8) # Do it
seto %cl # Store the overflow flag in CL
or $0x30, %cl # To ASCII
movzwl %ax, %eax # Clear garbage in EAX
movzwl %dx, %edx # Clear garbage in EDX
movl $fmt, 0(%esp) # Fill the stack with arguments for printf
movl $'E', 4(%esp)
movl %edi, 8(%esp)
movl %edx, 12(%esp)
movl %eax, 16(%esp)
movl %ecx, 20(%esp)
call printf # Call a C function
leave # Restore the stack
xor %eax, %eax # Return 0;
ret # Only valid when compiled with a compiler (GCC)
init:
movl $0x4F, %eax
movl $0x500, %ebx
movl $0x1, %ecx
movl $0x2, %edx
ret