windows assembly?

closed account (Dy7SLyTq)
so back when i first began programming, i told myself i was going to make a programming language. of course back then i couldnt, because i hadnt even learned how to write/read from file or that nested ifs were legal. now though, i feel like i know enough to do it. im not the best programmer (in terms of the code i write not how much i know) so i want to use this to solidify that knowledge and teach me to program better. the pdf im reading through recommends knowing assembly though, and i dont know a single command. so anyways, im running windows 7 64-bit. what are some good assembly tutorials?

edit: and if i want the compiler to generate an exe where would i learn to do that?
Last edited on
I had read a little bit into assembly, and it really depends on which processor you're targeting, not the OS. As soon as you start writing assembly, your program will be platform specific. I don't know any compilers for asm files, so I can't help you there. I do remember that compiling assembly code requires you to manually go through a few steps.

You can inline assembly code into C++, for which I believe you use the asm{} block. Inlining might be a good first step before diving into pure assembly programs.
Last edited on
closed account (Dy7SLyTq)
well i guess ill just write my compiler on my current machine. its an intel core i5
I know zilch on this, but there are plenty of libraries out there to help you out.

I'd take a look at Lex and Yacc before anything else...
closed account (G309216C)
Hi,

That way you are targeting INTEL processor there are plenty more targets such as AMD and more.

AS Daleth did suggest inline assembly is better before stepping into pure Assembly.

If you wish to target multi-processor platform I suggest you understanding about using asm in both of the targets for example:

To move a value into a register, in Intel we do this:
 
mov eax, 10  


in AMD I think they do this:
 
mov 10, eax


these are significant changes in a assembler point of view if we were to assemble the code above (AMD one) in a Intel platform the assembler would give us error and vice versa.

Therefore you should use the assembly inline therefore you can do a quick if() & else statement and execute the correct assembly. Or you can create a executable using assembly in the both platform then add it to resources of a C++ or other application then drop it during run time then execute it.

Thanks!
closed account (Dy7SLyTq)
thanks space worm. do you have any tutorials you could provide me with?
Another thing, clang (as well as LLVM) - a really, really good, cross platform, C/C++/Obj-C/Obj-C++ compiler used by Apple and many BSD distros - is written in C++!

Honestly, I can't think of anything you'd have to have assembly for when writing a compiler. But, like I said earlier, I don't really know anything about writing compilers. Just thought I'd throw that out there.
You probably ought to learn x86-64 assembly. Where the OS comes in is when you use system calls. This might be necessary for writing kernel modules: drivers etc. And possibly some conventions, like calling conventions. I'm sorry I don't know the exact details how the conventions might differ on different OS's, but it would not be a major difference. A search leads me to believe, that for x86, windows and linux follow the same conventions, but not for x86-64.

You can compile assembly with gcc. You can also generate assembly from a C or C++ source file by using gcc/g++'s -s option, or maybe it's -S, I can't remember.

@spaceworm, I think you're thinking of AT&T vs Intel.

There are two versions of x86-64 assembly that I think only differ in syntax. There is AT&T's version, and Intels. It doesn't really matter which you use. GCC generates AT&T syntax by default.

AT&T syntax looks like this.
mov $10, %eax

Intel like this.
mov eax, 10

It won't matter if it's an AMD or Intel processor, so long as it is x86-64 assembly, and an x86-64 cpu.
Last edited on
closed account (Dy7SLyTq)
so guys, thanks for all the knowledge, but are there any good tutorials to learn this?
closed account (Dy7SLyTq)
thanks
closed account (NUj6URfi)
Try let's build a compiler by someone Crenshaw. It uses pascal so you need windows and dev-pascal or a way I don't know of. I printed it out at kinko's. It is a free pdf. Printing it a kinko's is one of the best 50 bucks I have ever spent.
closed account (Dy7SLyTq)
thanks toad but
a) i already downloaded all the tutorials i need
b) i dont want to learn pascal (i probably wont use it since the places i want to work at dont use it)
c) i can learn the basics of two languages at once but assembly seems too difficult to attempt that
d) i would print it at home if i wanted it printed but im just going to use my laptop
You don't really need to know any Assembly to write a compiler. After all, a compiler is simply a translator. Some compilers translate to Assembly; others translate to C, then hand the output to a C compiler. From an engineering point of view, this is very sensible: you avoid writing a ton of code generation code, you maintain platform agnosticism, and you can take advantage of the optimization transformations other people have written before.

Another alternative is to use LLVM, which is what I'm doing. In broad terms, your code generation phase consists of making calls to the LLVM API, then at the end LLVM gives you back an intermediate representation of the program (generally, from the point of view of your C++ code, it's just an object). You can then give this back to LLVM, which will generate the machine code for your target platform of choice; at this point, you can choose to JIT the code, in which case LLVM will give you back a pointer which you can cast to a function pointer and call directly. You can also perform transformations on the IR that can, among other things, fold constants (e.g. transform 1+2 into 3) and move operations from memory to registers.
closed account (Dy7SLyTq)
ok if you guys dont think i need to learn assembly(saves me a headache). thanks helios ill look into llvm
closed account (Dy7SLyTq)
one last question guys:

what does this mean:

***********
*
*
*
*
************
*
*
*
*
*
***********

except it was more rounded. its not an e even though it kind of looks like it
closed account (Dy7SLyTq)
yes thats it thank you
That's lunate epsilon.
Last edited on
Topic archived. No new replies allowed.