MASM Console Problems - Beginner
Cody Harris

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!

ReyBrujo

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

Cody Harris

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

I'd love it if you showed me one.

Steve Terry

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

A J

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

ReyBrujo

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

Cody Harris

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

HoHo

What about HLA?

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

Cody Harris

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.

ReyBrujo

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

HoHo

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.

Cody Harris

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.

ReyBrujo

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

Cody Harris

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?

Thread #519685. Printed from Allegro.cc