flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
silkodyssey 27 Oct 2003, 02:05
You can try something like
Code: hStmt dd ? SQLStmt db 'Select * from table',0 SizeOfSQLStmt = $-SQLStmt invoke SQLExecDirect, hStmt, addr SQLStmt, SizeOfSQLStmt $ is the current offset in the program so $-SQLStmt is the size of the string. _________________ silkodyssey |
|||
![]() |
|
scientica 27 Oct 2003, 11:31
Or if you like to have a little macro to add a ".size" for you, I use this macro in some of my files. (I use it for two reasons, the ".size" which is the size of the stinrg (including the null-terminator!), second I can easily see if a string isn't used.)
Code: ;N.B! The display line contains a function which is not (yet) part of the official release, simply removing "`name,'" is enoguth to allow compile on the offical release. (If you want to use the ` feature you'll need to find fasm ersion 1.49.9 on the board) macro sz name, [data]{ common if ~ used name display '<W> ',`name,' is never used',13,10 ; displays a message if the string isn't used any where in the code. else name db data .size = $-name end if } ; Use like this: hStmt dd ? sz SQLStmt, 'Select * from table',0 invoke SQLExecDirect, hStmt, SQLStmt, SQLStmt.size ; the addr is superfluous in fasm, unless you use the "special" invoke macro which uses the pushd macro. If you inted to use a lot of these strings then I strongly sugest you use a macro (like above), macros actually makes life eaiser some times. ![]() _________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn |
|||
![]() |
|
Kain 27 Oct 2003, 18:12
jcan you not use the $ current offset operator right on the invokation?
Code: invoke SQLExecDirect, hStmt, addr SQLStmt, $-SQLStmt seems to me like it would make a more compact code. also, is $ operator similar to offset and addr for any object? sorry, just started learning assembly 3 days ago from anything i can find on the web. |
|||
![]() |
|
eet_1024 27 Oct 2003, 19:05
No. $ is the current address pointer. To calculate size, you must create a numeric constant (using =, not equ) after the string, but before anything else advances the pointer.
Code: push $ ; These place two different values onto the stack push $ |
|||
![]() |
|
Kain 27 Oct 2003, 23:56
eet_1024 wrote: No. $ is the current address pointer. To calculate size, you must create a numeric constant (using =, not equ) after the string, but before anything else advances the pointer. i see. thanks for the correction. while reviewing the fasmw docs, i found an example struc similar to scientica's macro. Code: struc db [data] { common label .data byte db data .size = $-.data } page 63 Quote: With such definition for example msg db ’Hello!’,13,10 will define also |
|||
![]() |
|
Todd 28 Oct 2003, 02:30
Thanks for the replies, thats exactly what I was looking for. I actually ended up using 'strlen' from crtdll.dll, but I may give these other suggestions a try. I still don't quite understand macros, but they seem like they could be a very handy thing to know.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.