flat assembler
Message board for the users of flat assembler.

Index > Main > [Solved]32 bit vs 64 bit vs AMD vs intel vs linux/window

Author
Thread Post new topic Reply to topic
zutokaza



Joined: 03 May 2015
Posts: 14
zutokaza 03 May 2015, 03:48
Hello everyone,

I am knew to assembly language. I have experience in many high level programming languages and see some similarities with Asm programming, but due to seeing many different types of hello worlds and terms I don't understand.....I decided to come to the experts.

Questions:

1. 32 bit vs 64 bit asm- Is there a major different in the different bit types? How hard would it be to convert 32 bit programming to 64 bit?

2.AMD vs Intel - I use these two CPU the most. Do I have to program in a different manner for different CPU types with assembly?

3. Linux and windows - I use both of these operating systems and am very familiar with both. Does the assembly programming differ for these two operating systems? Would assembly "Hello world" written in windows work on Linux?

4.The different assemblers. FASM vs. NASM vs. MASM. Is the code written different in each one?

Terms:
Mov- I read that it is a mnemonic. I understand the moving parts and simple mnemonics. Add, sub, and mul.

I don't understand:

1.eax

2.ebx

3.ecx,msg

4.edx,msg_size

5.int 0x80 (I'm guessing int is and integer, but what is 0x80?)

6.eax,1

7.xor ebx,ebx

8.msg db 'Hello world!',0xA (What does 'db' mean and '0xA.')

9.msg_size = $-msg

What is the difference between these "hello worlds"?

Code:
 ; fasm example of writing simple EXE program 

format MZ 

        push    cs 
        pop     ds 
        mov     ah,9 
        mov     dx,hello 
        int     21h 

        mov     ax,4C00h 
        int     21h 

hello db 'Hello world!',24h    
    

Code:
; fasm example of writing multi-segment EXE program 

format MZ 

entry main:start                        ; program entry point 
stack 100h                              ; stack size 

segment main                            ; main program segment 

  start: 
        mov     ax,text 
        mov     ds,ax 

        mov     dx,hello 
        call    extra:write_text 

        mov     ax,4C00h 
        int     21h 

segment text 

  hello db 'Hello world!',24h 

segment extra 

  write_text: 
        mov     ah,9 
        int     21h 
        retf        
     

Code:
; fasm demonstration of writing simple ELF executable

format ELF executable 3
entry start

segment readable executable

start:

        mov     eax,4
        mov     ebx,1
        mov     ecx,msg
        mov     edx,msg_size
        int     0x80

        mov     eax,1
        xor     ebx,ebx
        int     0x80

segment readable writeable

msg db 'Hello world!',0xA
msg_size = $-msg     


Lastly,
Any good resources on Assembly OS tutorials? I heard that Assembly is low on computer resources and think it would be the best language to make an OS. Otherwise, I'll be studying 32 bit assembly operating systems and Linux.

This will be it for now. I will ask more questions later.

Thank you for the help.

-Zuto


Last edited by zutokaza on 05 May 2015, 11:15; edited 1 time in total
Post 03 May 2015, 03:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20453
Location: In your JS exploiting you and your system
revolution 03 May 2015, 04:12
I guess we can take the question one at a time.

>1. 32 bit vs 64 bit asm- Is there a major different in the different bit types?

Yes. The internal registers sizes are different. Things like overflow and carry behave differently.

>How hard would it be to convert 32 bit programming to 64 bit?

It depends upon what your code does. Usually for any non-trivial code it is quite time consuming and finicky.

>2.AMD vs Intel - I use these two CPU the most. Do I have to program in a different manner for different CPU types with assembly?

Only if you are writing very finely tuned performance applications then you could do well to consider the underlying hardware mechanics (not just the CPU but also the system board and memory).

>3. Linux and windows - I use both of these operating systems and am very familiar with both. Does the assembly programming differ for these two operating systems?

The interfacing, architecture and calling conventions are different. You have to rewrite your OS related code to make it work correctly.

>Would assembly "Hello world" written in windows work on Linux?

Not without some help from something like WINE.

>4.The different assemblers. FASM vs. NASM vs. MASM. Is the code written different in each one?

Yup.

>1.eax

An internal CPU register. 32-bits

>2.ebx

An internal CPU register. 32-bits

>3.ecx,msg

The constant "msg" (a memory pointer) and the internal CPU register ecx. 32-bits

>4.edx,msg_size

The constant "msg_size" and the internal CPU register edx. 32-bits

>5.int 0x80 (I'm guessing int is and integer, but what is 0x80?)

Nope. INT mean interrupt. In this case software interrupt number 0x80. Please read the AMD and/or Intel manuals for descriptions of each instruction.

>6.eax,1

The constant "1" and the internal CPU register eax. 32-bits

>7.xor ebx,ebx

Zero the ebx register. Xor with itself will always give a zero result.

>8.msg db 'Hello world!',0xA (What does 'db' mean and '0xA.')

Define some text at the memory address "msg". DB = define byte(s). 0xA hexidecimal for 10 (a line feed (LF) character).

>9.msg_size = $-msg

How long is the message? $ means current address.
Post 03 May 2015, 04:12
View user's profile Send private message Visit poster's website Reply with quote
zutokaza



Joined: 03 May 2015
Posts: 14
zutokaza 03 May 2015, 21:01
revolution wrote:
I guess we can take the question one at a time.

>1. 32 bit vs 64 bit asm- Is there a major different in the different bit types?

Yes. The internal registers sizes are different. Things like overflow and carry behave differently.

>How hard would it be to convert 32 bit programming to 64 bit?

It depends upon what your code does. Usually for any non-trivial code it is quite time consuming and finicky.

>2.AMD vs Intel - I use these two CPU the most. Do I have to program in a different manner for different CPU types with assembly?

Only if you are writing very finely tuned performance applications then you could do well to consider the underlying hardware mechanics (not just the CPU but also the system board and memory).

>3. Linux and windows - I use both of these operating systems and am very familiar with both. Does the assembly programming differ for these two operating systems?

The interfacing, architecture and calling conventions are different. You have to rewrite your OS related code to make it work correctly.

>Would assembly "Hello world" written in windows work on Linux?

Not without some help from something like WINE.

>4.The different assemblers. FASM vs. NASM vs. MASM. Is the code written different in each one?

Yup.

>1.eax

An internal CPU register. 32-bits

>2.ebx

An internal CPU register. 32-bits

>3.ecx,msg

The constant "msg" (a memory pointer) and the internal CPU register ecx. 32-bits

>4.edx,msg_size

The constant "msg_size" and the internal CPU register edx. 32-bits

>5.int 0x80 (I'm guessing int is and integer, but what is 0x80?)

Nope. INT mean interrupt. In this case software interrupt number 0x80. Please read the AMD and/or Intel manuals for descriptions of each instruction.

>6.eax,1

The constant "1" and the internal CPU register eax. 32-bits

>7.xor ebx,ebx

Zero the ebx register. Xor with itself will always give a zero result.

>8.msg db 'Hello world!',0xA (What does 'db' mean and '0xA.')

Define some text at the memory address "msg". DB = define byte(s). 0xA hexidecimal for 10 (a line feed (LF) character).

>9.msg_size = $-msg

How long is the message? $ means current address.


Thank you.

For the "hello world" programs. What does the formats stand for? Format MZ and ELF.
Post 03 May 2015, 21:01
View user's profile Send private message Reply with quote
zutokaza



Joined: 03 May 2015
Posts: 14
zutokaza 05 May 2015, 11:14
Closed. I figured it all out. Thank you again Revolution. Smile
Post 05 May 2015, 11:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.