![]() |
[MASM32] Working with arrays
Hi!
I am working on a system managing key presses in a MASM application. The problem is that I must be doing something wrong with the array that keeps the press status of each key. (bool g_keys[256] // Position 0x20 means VK_SPACE i e.) The "input_set_key" function always returns a non-zero value like my memset hasn't done anything with the array. What can be the problem? I can't see it... Thanks alot for your helpfulness! /Klarre :
|
Re: [MASM32] Working with arrays
After finding the "Memory" debug window in Visual Studio, it was pretty simply to solve the bug. The functions is now looking like this and seems to work fine.
:
; ------------------------------------------------------------------------------ |
Re: [MASM32] Working with arrays
:
IsKeyPressed proc Key:DWORDAlso, a word to the wise. Don't use MSVCRT in ASM, it completely destroys the purpose of using ASM. The converting is fairly easy too: malloc -> GlobalAlloc memset -> stosb/stosw/stosd/stosq |
Re: [MASM32] Working with arrays
Thanks for your input Irwin. I removed the msvcrt dependency from my project and changed the malloc function call to HeapAlloc since I read on MSDN that GlobalAlloc wasn't recommended.
Another question you may be able to answear on: Is it possible to link a program using the Visual Studio linker without linking with msvcrt.lib? I have set the entry point to main, but still got two linker errors I can't get rid of. So I guess it is impossible, right? :
Error 1 error LNK2001: unresolved external symbol __RTC_Shutdown main.obj |
Re: [MASM32] Working with arrays
Quote:
Also, you can completely remove any CRT dependency from an application by adding the /NODEFAULTLIB linker flag, then coupling it with the /entry:main (or whatever your entry function is called). |
Re: [MASM32] Working with arrays
Ah, I see. Going to read up a little bit about the alloc functions.
I am using the /NODEFAULTLIB linker flag and have set the entry point. But this will not get rid of the linker errors... |
Re: [MASM32] Working with arrays
Quote:
|
Re: [MASM32] Working with arrays
The source file:
:
int main() { return 0; }The linker command line (debug configuration): :
/OUT:"G:\workspace\linktest\linktest\Debug\linktest.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\linktest.exe.intermediate.manifest" /NODEFAULTLIB /SUBSYSTEM:CONSOLE /ENTRY:"main" /MACHINE:X86 /ERRORREPORT:PROMPT:
1>Linking...The linker command line (release configuration): :
/OUT:"G:\workspace\linktest\linktest\Release\linktest.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"Release\linktest.exe.intermediate.manifest" /NODEFAULTLIB /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /ENTRY:"main" /MACHINE:X86 /ERRORREPORT:PROMPT:
1>Linking... |
Re: [MASM32] Working with arrays
Oh, I meant in a C++ project, which I forgot to mention in the earlier posts.
|
Re: [MASM32] Working with arrays
Oh, the problems aren't in your linking flags but rather your compiler flags. Just add /GS- to your compiler flags.
Good luck :) Also, it's fine; I also code in C(++) :P |
| All times are GMT -5. The time now is 1:06 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC