Question: ( Can someone help me translate this to asm please ) #include #include #include windows.h using namespace std; const int Biggy _ Size =

(Can someone help me translate this to asm please)
#include
#include
#include "windows.h"
using namespace std;
const int Biggy_Size =256; // as instructed on the homework
// line using Bresenham's line drawing algorithm
void drawLine(int startX, int startY, int endX, int endY, char(&bits)[Biggy_Size][Biggy_Size]){
001086F0 push ebp
001086F1 mov ebp,esp
001086F3 sub esp,10Ch
001086F9 push ebx
001086FA push esi
001086FB push edi
001086FC lea edi,[ebp-4Ch]
001086FF mov ecx,13h
00108704 mov eax,0CCCCCCCCh
00108709 rep stos dword ptr es:[edi]
0010870B mov ecx,offset _6168DFA1_BJJLab2@cpp (011A0F4h)
00108710 call @__CheckForDebuggerJustMyCode@4(01017B7h)
int DeltaX = abs(endX - startX);
00108715 mov eax,dword ptr [endX]
00108718 sub eax,dword ptr [startX]
0010871B push eax
0010871C call _abs (0101267h)
00108721 add esp,4
00108724 mov dword ptr [DeltaX],eax
int DeltaY = abs(endY - startY);
00108727 mov eax,dword ptr [endY]
0010872A sub eax,dword ptr [startY]
0010872D push eax
0010872E call _abs (0101267h)
00108733 add esp,4
00108736 mov dword ptr [DeltaY],eax
int sx =(startX < endX)?1 : -1;
00108739 mov eax,dword ptr [startX]
0010873C cmp eax,dword ptr [endX]
0010873F jge __$EncStackInitStart+51h (010874Dh)
00108741 mov dword ptr [ebp-10Ch],1
0010874B jmp __$EncStackInitStart+5Bh (0108757h)
0010874D mov dword ptr [ebp-10Ch],0FFFFFFFFh
00108757 mov ecx,dword ptr [ebp-10Ch]
0010875D mov dword ptr [sx],ecx
int sy =(startY < endY)?1 : -1;
00108760 mov eax,dword ptr [startY]
00108763 cmp eax,dword ptr [endY]
00108766 jge __$EncStackInitStart+78h (0108774h)
00108768 mov dword ptr [ebp-10Ch],1
00108772 jmp __$EncStackInitStart+82h (010877Eh)
00108774 mov dword ptr [ebp-10Ch],0FFFFFFFFh
0010877E mov ecx,dword ptr [ebp-10Ch]
00108784 mov dword ptr [sy],ecx
int err = DeltaX - DeltaY;
00108787 mov eax,dword ptr [DeltaX]
0010878A sub eax,dword ptr [DeltaY]
0010878D mov dword ptr [err],eax
int e2;
while (true){
00108790 mov eax,1
00108795 test eax,eax
00108797 je __$EncStackInitStart+0FFh (01087FBh)
bits[startY][startX]=0; // Set pixel to black for the line
00108799 mov eax,dword ptr [startY]
0010879C shl eax,8
0010879F add eax,dword ptr [bits]
001087A2 mov ecx,dword ptr [startX]
001087A5 mov byte ptr [eax+ecx],0
if (startX == endX && startY == endY) break;
001087A9 mov eax,dword ptr [startX]
001087AC cmp eax,dword ptr [endX]
001087AF jne __$EncStackInitStart+0BFh (01087BBh)
001087B1 mov eax,dword ptr [startY]
001087B4 cmp eax,dword ptr [endY]
001087B7 jne __$EncStackInitStart+0BFh (01087BBh)
001087B9 jmp __$EncStackInitStart+0FFh (01087FBh)
e2=2* err;
001087BB mov eax,dword ptr [err]
001087BE shl eax,1
001087C0 mov dword ptr [e2],eax
if (e2>-DeltaY){
001087C3 mov eax,dword ptr [DeltaY]
001087C6 neg eax
001087C8 cmp dword ptr [e2],eax
001087CB jle __$EncStackInitStart+0E3h (01087DFh)
err -= DeltaY;
001087CD mov eax,dword ptr [err]
001087D0 sub eax,dword ptr [DeltaY]
001087D3 mov dword ptr [err],eax
startX += sx;
001087D6 mov eax,dword ptr [startX]
001087D9 add eax,dword ptr [sx]
001087DC mov dword ptr [startX],eax
}
if (e2< DeltaX){
001087DF mov eax,dword ptr [e2]
001087E2 cmp eax,dword ptr [DeltaX]
001087E5 jge __$EncStackInitStart+0FDh (01087F9h)
err += DeltaX;
001087E7 mov eax,dword ptr [err]
001087EA add eax,dword ptr [DeltaX]
001087ED mov dword ptr [err],eax
startY += sy;
001087F0 mov eax,dword ptr [startY]
001087F3 add eax,dword ptr [sy]
001087F6 mov dword ptr [startY],eax
}
}
001087F9 jmp __$EncStackInitStart+94h (0108790h)
}
001087FB pop edi
001087FC pop esi
001087FD pop ebx
001087FE add esp,10Ch
00108804 cmp ebp,esp
00108806 call __RTC_CheckEsp (01015A0h)
0010880B mov esp,ebp
0010880D pop ebp
0010880E ret

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!