Well, I'm trying to get my feet wet with Assembly. I currently have this:
1 | .386 |
2 | .model flat,stdcall |
3 | option casemap:none |
4 | include \masm32\include\windows.inc |
5 | include \masm32\include\kernel32.inc |
6 | include \masm32\include\masm32.inc |
7 | includelib \masm32\lib\masm32.lib |
8 | includelib \masm32\lib\kernel32.lib |
9 | include \masm32\include\user32.inc |
10 | includelib \masm32\lib\user32.lib |
11 | |
12 | .data |
13 | HelloWorld db "Hello World!", 0 |
14 | prog db "pause", 0 |
15 | |
16 | .code |
17 | start: |
18 | invoke StdOut, addr HelloWorld |
19 | invoke Sleep, 1000 |
20 | invoke ExitProcess, 0 |
21 | end 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!
Don't use MASM, go for NASM or TASM.
I can't find any tutorials for NASM that actually seem to work.
I'd love it if you showed me one.
I second NASM, but don't know of or have time to search for tutrials... sorry.
i wonder why you would want to learn ASM at all ?
Ah, positive AJ's comment of the day :-P
I've tried using Dr. Carters IO stuff, but I get this:
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" |
2 | bits 32 |
3 | segment .data |
4 | vbanner db "Hello There", 0 |
5 | |
6 | segment .bss |
7 | |
8 | segment .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:
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
What about HLA?
It even has a free downloadable book that I printed out, all of the ~1.8k pages of it
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.
Try this: Instead of _asm_main use _main, and instead of ld use gcc.
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.
No Good:
$ 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.
Hmm... I am not sure what asm_io.asm is doing. Try adding -mconsole, -Wl,subsystem,console I think.
I'm dumb (really).
I thought it was outputting to .o files, when it was really .obj files.
SOrry for the hastle .
Actually, I'd like to even further isolate it from C, go to pure ASM string calls.
Anybody know how to do this?