Thread: Assemblers - Which uses what?

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    719

    Assemblers - Which uses what?

    i'm so damn confused about assembly languages. an it's so hard to find resources or assembler tutorials. IS there a standard syntax (for each instruction set)? do each have their own? are -asm32 compilers specific to windows and the 32 refers not to the cpu register size, but the win32 api?

    can someone please try to break it down for me? maybe kind of classify them a bit or something. it just seems like the subject of assemblers is just one big scattered mess.



    even though these questions don't really concern my specific computer, i will tell you what i'm running anyway. i'm sure the question might be asked.

    Windows ME - Intel P3

    edit: oh yeah. if i wanted to search for some tutorials or examples, what "language" is this? (i know it's assembly, but i think you get the point)

    Code:
    org	100h
    
    mov	di,screen_data
    xor	al,al
    mov	cx,80*50*2
    rep	stosb
    
    ......
    Last edited by misplaced; 04-12-2005 at 03:19 AM.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    I use nasm.
    Dr. Paul Carter has a very good tutorial and add-ons for nasm here ya go
    http://www.drpaulcarter.com/pcasm/
    [edit]
    As far as the 32 issue. That means your are using 32bit mode.
    Last edited by prog-bman; 04-12-2005 at 04:06 AM.
    Woop?

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    Every assembler will probably have slightly different looking syntax but there are two main different kinds that you are thinking of. Intel and AT&T. The snippet you posted is Intel. NASM, MASM, FASM and TASM all use Intel but are all slightly different. The gcc assembler (not sure what it is called) uses AT&T syntax.
    On the rare occasion that I write an assembly program, I use MASM32 (the 32 btw means that this version of MASM is capable of 32bit programs therefore allowing winapi calls) with the RadASM IDE.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Code:
    org	100h
    
    mov	di,screen_data
    xor	al,al
    mov	cx,80*50*2
    rep	stosb
    
    ......
    Code:
    org	100h
    This code's entry point is 100 bytes from the start of the segment. This is signature of old school DOS COM files.

    Code:
    mov di,screen_data
    This moves a 16-bit pointer in screen_data to di. It is 16-bit because it is only using DI which is a 16 bit register. However that code might not do anything constructive since the appropriate full pointer load in16-bit assembler - which this has to be since it is a COM binary - is to use lds or les. I also would reckon this comes from MASM source since MASM auto-assumes the segment for all pointer loads is ES (ASSUME ES) by default. NASM, FASM, and TASM make no such assumptions.

    Code:
    xor	al,al
    mov	cx,80*50*2
    rep	stosb
    The first line zeroes out al by using the xor reg,reg operation. To figure this out read about binary operators.

    The next line moves a value into cx or the count register in preparation for a rep sto(x) or rep mov(x) - a string operation or a memory copy operation. Since this is using 80*50*2 I would say this is for 80x50 color text mode. The 2 is simply because each cell in the mode requires two bytes to represent this value:

    value=foreground_color+(background_color*15);

    The line rep stosb is this:

    rep will execute the opcode immediately following it for cx number of times. The direction of the count (increment or decrement) is found by checking the DF flag or the direction flag. There are 2 opcodes to clear and set the direction flag.

    I would say this function does a complete memory copy to a text mode 80x50 color screen.


    There is a standard in assembly language. In fact there are 2 machine-level standards in PCs. Mac or Intel x86. AMD can be considered x86 except it does not support SSE/SSE2/or MMX2 - it does support MMX version 1.0 but they paid a hefty price for this support.

    Now there are more syntaxes than just intel x86, but even AT&T syntax on an x86 platform is still x86. No matter what the assembler does - it always ends up as Intel syntax x86 code.

    All of the popular assemblers have already been mentioned previously in this thread. I recommend NASM.

    A similar bit of code to copy a mode 13h back buffer to the screen would look like this:

    Code:
    cld
    les   di,[Buffer_ptr]
    
    push  ds
    
    lds   si,[Screen_ptr]
    mov  cx,32000d
    rep   movsw
    
    pop  ds
    Last edited by VirtualAce; 04-12-2005 at 11:00 AM.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    i know what it does . i just don't know how to make it do what i want to do. i am read only when it comes to asm.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I know what it does . i just don't know how to make it do what i want to do.
    I'm totally lost on this statement.

    If you knew what it did, you would know how to 'make it do what you want it to do.'

    That's like saying you know what the accelerator pedal does in a car, but you just wanna know how to get the car to accelerate.

    edit: oh yeah. if i wanted to search for some tutorials or examples, what "language" is this? (i know it's assembly, but i think you get the point)
    I rest my case. Anyone in assembly would know that's x86. No offense but if I'm going to help you, it's not going to help me if you continue to tell me you know what you are doing....when I know you don't.

    No offense intended but here where I'm coming from. If I don't know about something then I'll admit it. All I ask is the same respect and consideration from you. I'll help you more than you probably will ever want or could put up with, but all I ask is that you are honest with me. ASM is cool and I'd love for you to be the best that you can be at it, but you must establish the fact that you probably don't know as much as you think you do about it.
    Last edited by VirtualAce; 04-13-2005 at 02:51 PM.

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    Quote Originally Posted by Bubba
    I'm totally lost on this statement.
    If you knew what it did, you would know how to 'make it do what you want it to do.'

    That's like saying you know what the accelerator pedal does in a car, but you just wanna know how to get the car to accelerate.

    choose a language you've never learned. perl, fortran, kylix, whatever...don't look anything up...now write a short program in it. can't do it can ya? now open a source file of that langauge and tell me you don't have any idea what it's doing.



    i have fasm, fasmw, masm, lzasm, and nasm on my computer.

    some tutorial examples compile. others don't. the ones that do typically don't compile with any other assembler i have.

    one assembler will choke on something like
    Code:
    .data MySeg
    and another runs just fine.


    all the tutorials i read are x86. i didn't ask what instruction set it was, what if there were different syntax's and, if so, what they are called.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    The point here is that there is a common instruction set for Intel based chips, but each assembler has a different syntax. It's similar to how C was before the compiler vendors started to standardize.

    You'll use the same instructions if you use NASM, MASM or TASM, but you'll be lucky to use source code on all 3 without changing it

  9. #9
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    i must admit, i didn't read the entirety of bubba's post until just now. i quit reading after he started explaining what each instruction meant.


    i'm sorry. i do appreciate the help and you did answer my question. i was either tired or lazy at the time and overlooked it.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compilers.. assemblers.. linkers..
    By hauzer in forum C Programming
    Replies: 4
    Last Post: 10-27-2008, 05:17 AM
  2. help compiling genome assemblers
    By bluegirl in forum C Programming
    Replies: 1
    Last Post: 03-29-2006, 03:25 PM