flat assembler
Message board for the users of flat assembler.
Index
> Windows > Translation of MASM32 routine causing crash in FASM |
Author |
|
StakFallT 07 Feb 2006, 05:55
Basically as the subject implies, I've been working on an assembly demo.. Long story short, one of the routines in the project was a routine written in MASM32. I converted it with hardly any modifications to the routine; I mean their were modifications but next to none.. Anyhow I narrowed this crash in my project to this routine
Code: proc CreateLCDColors push ebx ; This function simply copies the darker version of the colors 0-6 in ; the palette to colors 7-13. SHADOWDARKNESS determines the darkness ; of the shadow. xor ecx, ecx mov edx, LCDBaseColors ;push LCDBaseColors ;pop edx mov ebx, edx ;ebx points to first background color add edx, [COLORBASE_SHADOW*4] ;edx points to first shadow color jmp Create_LCD_Colors_Check_ecx ; loop for every color index Create_LCD_Colors_Check_ecx: cmp ecx, [BASECOLORCOUNT*4] jl Create_LCD_Colors_Loop jge EndCreateLCDColorsProc Create_LCD_Colors_Loop: ; read color: mov al, [ebx+ecx] ; darken color: cmp al, [SHADOWDARKNESS] jl Create_LCD_xor_al jge Create_LCD_sub_al Create_LCD_xor_al: xor al, al jmp ContinueCreateLCDColors Create_LCD_sub_al: sub al, [SHADOWDARKNESS] jmp ContinueCreateLCDColors ContinueCreateLCDColors: ; put darkened color: mov [edx+ecx], al inc ecx jmp Create_LCD_Colors_Check_ecx EndCreateLCDColorsProc: ret endp The really tricky thing about debugging this is it does loop through it ok at least once.. Here's how I determined this routine to be the culprit.. Issued MessageBox call as the previous instruction before calling the routine, and one right after it.. Only 1 mb shown. ok so somewhere inside the routine.. remmed out the first mb (just before calling the routine, since now at this point I know it's in the routine somewhere).. Isued a MB as the first instructions in the Xor/Sub label blocks.. 1 mb shown.. Remmed them (the MBs) out.. Issued one just before the ret call, 1 shown mb shown.. So It's really whacky.. It seems to loop through but get hung up on the ret instruction.. Thinking about it I thought it might have been because I'm pushing ebx onto the stack at the begining and for some reason the ret isn't popping the items off the stack (I read an article somewhere that you can avoid using ret if you pop the proper amount of registers or bytes or something back off at the end).. But anyhow, that didn't fix it either.. so I'm kinda not sure how to debug this further.. Any help would really be greatly appreciated! -- StakFallT Oh I also am putting the zip file with the code attached to this thread so that if you guys (or girls ) need some of the surrounding code, you won't get hung up trying to figure out where the real culprit is.. Again, thanks MUCH
|
|||||||||||
07 Feb 2006, 05:55 |
|
vbVeryBeginner 07 Feb 2006, 10:33
Code: proc CreateLCDColors push ebx you pushed the ebx, but didn't pop it out. try pop it out first then only do ret. |
|||
07 Feb 2006, 10:33 |
|
StakFallT 07 Feb 2006, 13:00
I acctually tried that already on the outside chance that ret wasn't preserving the stack and it didn't work
|
|||
07 Feb 2006, 13:00 |
|
vbVeryBeginner 07 Feb 2006, 13:22
i just downloaded your code and ...
wow... there are quite a lot "mistake". i try check the source and do some conversion for u. |
|||
07 Feb 2006, 13:22 |
|
vid 07 Feb 2006, 13:46
i think my tutorial could help you...
(you switch chapters at top of the page) |
|||
07 Feb 2006, 13:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.