Just getting back to assemby after 10+ years away from it and trying
to learn a bit about x86 programming. My last experience was with a
Z80 so I am finding a lot of great things like MASM and HLA.
I was using the snippet below to test printing messages from an asm
function. How does one print <CRLF>? Adding 0x0D0A to the string does
not work, nor does '\n'.
I copied the MessageBox invocation from another example and I have all
the same includes and tried to run it under Vc++. But as you can see
it is commented as it was reported as an undefined symbol.
Lastly if one is developing for the IA-32 platform using an XP pc,
what are the assemblers and/or IDEs of choice at this time?
Thanx,
gtb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.486
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
helloString db "Hello World! ",0
.code
fn1 proc
;invoke MessageBox, NULL, addr helloString, addr helloString, MB_OK
invoke StdOut, addr helloString
ret
fn1 endp
end
> helloString db "Hello World!", 0Ah,0
It's a byte string, so 0x0D0A will be truncated to 0x0A. However, your
sentiment is correct:
helloString db "Hello World! ", 13, 10, 0
-- or --
helloString db "Hello World! ", 0dh, 0ah, 0
>I copied the MessageBox invocation from another example and I have all
>the same includes and tried to run it under Vc++. But as you can see
>it is commented as it was reported as an undefined symbol.
MessageBox and friends are in user32.inc. Add:
include \masm32\include\user32.inc
-- and --
includelib \masm32\lib\user32.lib
>Lastly if one is developing for the IA-32 platform using an XP pc,
>what are the assemblers and/or IDEs of choice at this time?
Choice of who? ;) I use masm and vim, the World's Greatest Editor.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
Has to do with the terminal who is interpreting the stream your program prints:
- On Unixes, you only need a Line Feed.
- On DOS-based terminals (*DOS, windows and frinds), Line Feed just pushes
the cursor one step down, and Carriage Return puts it in the 1st column.
- On MasOS X, Carriage Return handles everything.
However, simply putting 0x0A0D in a byte string declaration won't work for
most assemblers. You have to separate the control codes:
db "something", 0Ah, 0Dh, 0
OR
db "something", 0x0A, 0x0D, 0
JJ
Might I now ask what are the idioms for printing register or memory
values?
Also I am using Visual C++ as I had it handy and figure that most asm
functions I develop would be called from C anyway. So I am using MASM
constructs, macros I suppose and just compiling and running my
programs as usual. It works but I confess I don't know what I or MASM
are doing.
Is there a way to see the actual code that MASM generates?
Can one run a debugger when running an asm function called from C/C++?
Thanx,
gtb
CR pushes the cursor one step down and LF puts it in the 1st colum?
Dirk
> Is there a way to see the actual code that MASM generates?
With this question, you are just demonstrating to yourself
that MASM is *not* an Assembler.
Betov.
But surely the question has an answer! (not a user, but try "/l
myprog.lst") Then you can see the code that Masm actually generated - in
zero clicks!!!
Best,
Frank
No. The other way!
" Hello"
| |
| Hello_ |
| |
LF:
| |
| Hello |
| _ |
CR:
| |
| Hello |
|_ |
"something":
| |
| Hello |
|something_ |
JJ
If you are going to call your MASM code from C, you can just call printf.
If not, you can get the MASM distribution from www.masm32.com; he includes
a run-time library that has a lot of these functions.
>Is there a way to see the actual code that MASM generates?
The /FAsc parameter to ml.exe gets you the maximum listing.
>Can one run a debugger when running an asm function called from C/C++?
Sure. VC++ has a "disassembly" view that shows you each instruction.
I believe I just told you to use /FAsc. That is wrong; that's for Visual
C++. For MASM, you want /Fl /Sa.
No, the other way around, as João said.
-hpa
Ok thanks.
Dirk