Any good assembly language tutorials?

Pages: 12
closed account (Dy7SLyTq)
are you sure nasm and masm are different? i know nasm uses intel syntax and i thought masm did too. oh well. and your right gcc by default uses at&t syntax, but i think that can be switched, and if it cant it only applies to the asm keyword. i learned from the dr. paul carter website that you can assemble an asm file then compile it with a c file using gcc
Yes, I am sure that NASM and MASM are different. Here is an example:

MASM Syntax:

test db 12h

mov dx, offset test
  ; MASM requires the "offset" keyword here, due to 
  ; this being 16-bit address

mov al, test
  ; MASM remembers variable types


NASM Syntax:

test db 12h

mov dx, test
  ; 32 bit address so its fine

mov al, byte [test]
  ; need to specify the size of the move, as well as
  ; that you are moving the contents of "test"
closed account (9wqjE3v7)
@a k n maybe I am misunderstanding you, though processor state is saved by the OS scheduler upon jumping between different user mode programs. The user shouldn't be concerned about manipulating different registers since the compiler is a seperate running process. Its data would be restored upon resuming execution.
Last edited on
ok so i have Masm32 editor on my computer, so which editor has the easiest syntax to understand? also would making a side scroller in asm be easier than C++?

I downloaded Nasm but its just a cmd promp i dont know what to do.

also why do they use so much different syntax? you would think that all computers having the same assembly code would make it easier to find devs for.
Last edited on
closed account (9wqjE3v7)
Because there is no standard, unlike higher level languages (c++, java ect). The only guide is the instruction set manual.
Last edited on
Yep you got it a little wrong ,
i am talking about behaving with the compiler and not the OS , if you are going to mess up a register inside inline assembly then you got to restore it too by either saving them on the stack and manually restoring them or by specifying what registers you are going to mess up (more info on the HOWTO i gave).

@nt
I'm pretty sure the MASM uses the intel syntax just like NASM , what's different is microsoft added some extra stuff making simpler things complicated . except the "macro" and "preprocessor" stuff the syntax is pretty similar.
For the record , gas (gnu assembler) uses the AT&T syntax by default which you can change with a directive.
closed account (9wqjE3v7)
^Ah, I thought I did, thanks.
Ok so im using MASM32 to write asm but it says it cant find kernal32.inc and i cant find it anywhere on the web so what do i do?
closed account (9wqjE3v7)
kernel32.inc should be included in one of the directories of your install. Is it with the other .inc files?
ya its there but it says it cant open it for some reason. My assembly file is on my desktop does that matter? so i need to add any variables to the enviornment path?


I tried running a sample program and that worked fine. but my program wont run, i click Project>run program and nothing happens
Last edited on
closed account (9wqjE3v7)
Where was the sample program? Move and set the path of your .asm file within the 'projects' directory.
Last edited on
it was in C:\masm32\examples

Im not sure what you mean by the second part
closed account (9wqjE3v7)
Try moving your file to C:\masm32\projects instead of the desktop.
still get the error, heres the code if it helps any

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.386
.model flat, stdcall
option casemap :none

include \masm32\include\windows.inc
include \masm32\include\kernal32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\kernal32.lib
includelib \masm32\lib\masm32.lib

.data
       msg db "Hello World", 0
       cpt db "MY FIRST ASSEMBLY PROGRAM", 0

.code
start:
    invoke MessageBox, NULL, addr msg, addr cpt, MB_OK
    invoke ExitProcess, NULL

end start
Last edited on
closed account (9wqjE3v7)
You have spelt kernel wrong, there should be an 'e' as opposed to an 'a'. :P
lololol ok that would help, but now it says Error A2006: undefined symbol : Message Box
_

does it mean the _ in MB_OK? thats what the guy has in the tutorial and it compiles for him and hes using Masm32 as well.
Last edited on
ok i just copied some other code in and it works now but my cmd window just flashes and i cant see the message, whats the assembly version of cin.get()?
Topic archived. No new replies allowed.
Pages: 12