Xref: news2.mv.net comp.os.msdos.djgpp:7008 Newsgroups: comp.os.msdos.djgpp From: Nick Collier Subject: asm loading register problem Content-Type: text/plain; charset=us-ascii Message-ID: <320A42DC.7CB5@midway.uchicago.edu> Sender: news AT midway DOT uchicago DOT edu (News Administrator) Content-Transfer-Encoding: 7bit Organization: University of Chicago -- Academic Computing Services Mime-Version: 1.0 Date: Thu, 8 Aug 1996 19:41:16 GMT Lines: 82 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hey, I'm trying to convert the polygon scannning code from M. Abrash's Zen of Graphics programming to work with DJGPP, but am having problems with the ASM version of ScanEdge. When I run a program that uses it, I get the following: General Protection Fault at eip=00001d38 eax=00000000 ebx=000000c7 ecx=00000000 edx=00000001 esi=00000000 edi=c0118004 ebp=0004e5a0 esp=0004e582 cs=00a7 ds=00af es=00af fs=0087 gs=00bf ss=00af Call frame traceback EIPs: 0x00001d38 0x000019ee 0x000015ab 0x000022df eax, ebx, edx are all correct, that is, they contain the values assigned by the ASM code. The following is the edited code with the problem line marked: movl ARG7, %edi movl (%edi), %edi cmpl $1, ARG5 jz HLinePtrSet addl X_END, %edi HLinePtrSet: movl ARG4, %ebx subl ARG2, %ebx #edge height jle ToScanEdgeExit #guard against 0-length & horz movl %ebx,-4(%ebp) #Local Variable Height = Y2 - Y1 subl %ecx,%ecx #assume ErrorTerm starts at 0 # were moving right as we draw) movl $1, %edx #assume AdvanceAmt = 1 (move movl ARG3, %eax subl ARG1, %eax #DeltaX = X2 - X1 jz IsVertical #its a vertical edge--special IsVertical: movl ARG1, %eax #starting (and only) X #coordinate subl ARG6, %ebx #loop count = Height - SkipFirst jz ScanEdgeExit #no scan lines left after #skipping 1st VerticalLoop: -> ******movl %eax, (%edi) <-********************** addl HL_SIZE, %edi #point to the next HLine struc decl %ebx #count off this scan line jnz VerticalLoop jmp ScanEdgeDone The first polygon is vertical so the above contains all the relevant executed code. ARG7 refers to a double pointer - **EdgePtPtr - hence the double dereference. eax refers to the starting x coord. which is 0 in this case. ebx refers to the loop count which is 199, that is, the height of the screen as the first polygon is a screen size square. Why can't (%edi) be loaded with the value of %eax? I compiled the C version with -S and the output is similar to this ASM code. Loads, in this case, (%esi) with the value of %eax. Help is appreciated of course. Tia, Nick p.s. Once I get enough converted to be useful, I'll post it somewhere. -- ------------------------- Nick Collier 5237 S. Greenwood #2 ntcollie AT midway DOT uchicago DOT edu Chicago, IL 60615