Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » MASM Console Problems - Beginner

This thread is locked; no one can reply to it. rss feed Print
MASM Console Problems - Beginner
Cody Harris
Member #4,406
March 2004
avatar

Well, I'm trying to get my feet wet with Assembly. I currently have this:

1.386
2.model flat,stdcall
3option casemap:none
4include \masm32\include\windows.inc
5include \masm32\include\kernel32.inc
6include \masm32\include\masm32.inc
7includelib \masm32\lib\masm32.lib
8includelib \masm32\lib\kernel32.lib
9include \masm32\include\user32.inc
10includelib \masm32\lib\user32.lib
11 
12.data
13 HelloWorld db "Hello World!", 0
14 prog db "pause", 0
15 
16.code
17start:
18 invoke StdOut, addr HelloWorld
19 invoke Sleep, 1000
20 invoke ExitProcess, 0
21end start

But I'd like to cut it back to only the bare essentials (C doesn't need all the Win32 stuff to make a basic console app).

Most tutorials that say they work, well just havn't on my computer.

Help!

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

ReyBrujo
Moderator
January 2001
avatar

Don't use MASM, go for NASM or TASM.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Cody Harris
Member #4,406
March 2004
avatar

I can't find any tutorials for NASM that actually seem to work.

I'd love it if you showed me one.

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

Steve Terry
Member #1,989
March 2002
avatar

I second NASM, but don't know of or have time to search for tutrials... sorry.

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

A J
Member #3,025
December 2002
avatar

i wonder why you would want to learn ASM at all ?

___________________________
The more you talk, the more AJ is right. - ML

ReyBrujo
Moderator
January 2001
avatar

Ah, positive AJ's comment of the day :-P

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Cody Harris
Member #4,406
March 2004
avatar

I've tried using Dr. Carters IO stuff, but I get this:

Quote:

nasmw -f win32 -d COFF_TYPE nasmtest.s && nasmw -f win32 -d COFF_TYPE asm_io.
asm && ld -o test.exe asm_io.o nasmtest.o

1%include "asm_io.inc"
2bits 32
3segment .data
4vbanner db "Hello There", 0
5 
6segment .bss
7 
8segment .text
9 global _asm_main
10 
11_asm_main:
12 push ebp
13 mov ebp,esp
14 pusha
15 mov eax,vbanner
16 call print_string
17 popa
18 mov eax,0
19 mov esp,ebp
20 pop ebp
21 ret

Generates:

Quote:

c:\mingw\bin\ld.exe: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00401000
asm_io.o(.text+0x10):asm_io.asm: undefined reference to `scanf'
asm_io.o(.text+0x2a):asm_io.asm: undefined reference to `printf'
asm_io.o(.text+0x41):asm_io.asm: undefined reference to `printf'
asm_io.o(.text+0x52):asm_io.asm: undefined reference to `getchar'
asm_io.o(.text+0x68):asm_io.asm: undefined reference to `putchar'
asm_io.o(.text+0x7d):asm_io.asm: undefined reference to `putchar'
asm_io.o(.text+0x14e):asm_io.asm: undefined reference to `printf'
asm_io.o(.text+0x174):asm_io.asm: undefined reference to `printf'
asm_io.o(.text+0x1a3):asm_io.asm: undefined reference to `printf'
asm_io.o(.text+0x1d0):asm_io.asm: undefined reference to `printf'
asm_io.o(.text+0x1ef):asm_io.asm: undefined reference to `printf'
asm_io.o(.text+0x207):asm_io.asm: more undefined references to `printf' follo

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

HoHo
Member #4,534
April 2004
avatar

What about HLA?

It even has a free downloadable book that I printed out, all of the ~1.8k pages of it :)

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Cody Harris
Member #4,406
March 2004
avatar

I'd like to actually learn some basic assembly logic in win32, and then try my hand at making a tiny TUI OS type thing.

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

ReyBrujo
Moderator
January 2001
avatar

Try this: Instead of _asm_main use _main, and instead of ld use gcc.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

HoHo
Member #4,534
April 2004
avatar

I think HLA is quite good for you then. You can have access to basic things like console or even winapi with relative ease and still program all other things in asm. If you really want you can probably do these simple things in pure asm too.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Cody Harris
Member #4,406
March 2004
avatar

No Good:

Quote:

$ nasmw -f win32 -d COFF_TYPE nasmtest.s && nasmw -f win32 -d COFF_TYPE asm_io.
asm && gcc -o test.exe asm_io.o nasmtest.o
nasmtest.o(.text+0x1a): In function `main':
: undefined reference to `printf'
/mingw/lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status

I'd really like to learn ASM first, then maybe move to HLA later.

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

ReyBrujo
Moderator
January 2001
avatar

Hmm... I am not sure what asm_io.asm is doing. Try adding -mconsole, -Wl,subsystem,console I think.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Cody Harris
Member #4,406
March 2004
avatar

I'm dumb (really).

I thought it was outputting to .o files, when it was really .obj files.

SOrry for the hastle :P.

Actually, I'd like to even further isolate it from C, go to pure ASM string calls.

Anybody know how to do this?

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

Go to: