LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-15-2004, 09:57 AM   #1
programmershous
Member
 
Registered: Mar 2004
Distribution: Diverse
Posts: 77

Rep: Reputation: 15
Lightbulb Assembly Programming Page


Hello all,

I wrote a page about Assembly language programming.
I need your advice about it and what else I could add that could be usefull ?

Here it is :
http://www.ifrance.com/programmershouse/ASS-EN.HTML

--------------------

ASSEMBLY :

It is a difficult to code language.
It is very close to the "machine language".
Its single interest is to control directly and exactly what the processor is doing.
It is used to optimize programs on processors with little memory, or to write the BIOS.
The code is not portable from a processor to another from a different trend.

INTEL INSTRUCTIONS :
CALL "address" : Calls a program.
CMP, TEST "register or address" : Compars both arguments.
JMP "address" : Calls a program.
JNE or JE "address" : Jump if (Non) Equal
JZ or JNZ "address" : Jump if (Non) Zero
LEA arg1,arg2 : Loads arg1 with value pointed by arg2
MOV arg1,arg2 : Puts arg2 in arg1
PUSH "hexa number or register" : Push register into stack
POP "hexa number or register" : Pop stack into register
SUB, ADD, MUL arg1,arg2 : results into arg1

COMPILER :
Allows to go from the code (.asm) to executable (.exe).
The best compilers are :
MASM32

MY FIRST PROGRAM IN INTEL ASSEMBLY :

; Data
Data Segment
Message DB "Hello The World ! $"
Data EndS

; Le code
Code Segment
Assume Cs : Code, Ds : Data

Main Proc
; Printing of the message
Mov Ah, 09h
Mov Dx, Offset Message
Int 21h

; end of the program,
; then return to MS-DOS
Mov Ah, 0C00h
Int 21h
Main EndP
Code EndS
End Main

LINKS :
 
Old 07-15-2004, 04:56 PM   #2
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
Quote:
The best compilers are :
MASM32
What about NASM, GNU assembler? I cant be the only one who feels they
are superior to Microsoft Assembler.

Quote:
The code is not portable from a processor to another from a different trend.
Id word this like:
The code is not portable from one architechure to another.

This page is obviously microsoft product centric, no?

Last edited by jinksys; 07-15-2004 at 05:02 PM.
 
Old 07-15-2004, 06:22 PM   #3
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
by programmershous
I need your advice about it and what else I could add that could be usefull ?

depends on your audience and purpose, sorry if this seems a bit harsh but i just wanted to be thorough.

your intel(x86) instruction set is a bit lacking even for an 8086. if this is the processor family you are concentrating on then i suggest you add more instructions, list the contents of the flags register and the control registers, discuss real mode vs protected mode and talk about the x87 fpu. you could if you wished go into a discussion about some of the more recent extensions to the family like mmx or the other one(does vector operations fast but forgotton name)

you could also do some general discussion on things like cisc vs risc, pipelining, cache size, etc. a page explaining that processor speeds are not comparable between architectures and speed isnt everything would be really nice but is probably off your topic.

to be honest you appear to be a bit of a newbie to assembly and the processors you are trying to document are very very complicated(heard of gdt, idt, or ring 0-3?). perhaps you should try a simpler processor something like a pic microcontroller or a z80

if your attempting to learn assembly then may i suggest you try something like corewars or one of the programming robot games, because most of these use types of assembly and you will learn 'how' to program assembly without having to worry about all the features of a general purpose processor. cos once you have a grasp of all the concepts the x86 will be much easier to understand.

by jinksys
What about NASM, GNU assembler? I cant be the only one who feels they
are superior to Microsoft Assembler.


for x86 ive only ever used nasm so i cant really comment but i find superior to be quite a loose word and feel it needs some clarification maybe if the good and bad points of both were listed instead.

as for the gnu assembler i cant do AT&T syntax cos the src, dest thing does my head in but im sure people who grew up with it say the same about dest, src

by jinksys
This page is obviously microsoft product centric, no?

a) executable (.exe).
b) MASM32
c) Int 21h

by the looks of it i'd say yes but more out of naiveity(sp?) than intent.
 
Old 07-16-2004, 03:39 AM   #4
programmershous
Member
 
Registered: Mar 2004
Distribution: Diverse
Posts: 77

Original Poster
Rep: Reputation: 15
Thumbs up

Web Page Updated !
Thanks for the comments ! :-)

I added :

It is important to know the Registers : EFLAGS, Segments, General etc.
To know more about 80X86 Architecture : click on THIS

MMX are extensions of X86 Assembly but they are usefull only for multimedia and intensive graphical applications. They are not used for "normal" applications. MMX are quite a "marketing" extensions, because RISC processors take more advantage of the hardware. x86 are poorly designed CISC. To know more about RISC vs CISC : click on THIS

Real mode vs Protected mode :
The 80x86 chip can be in those different modes by selecting the Mode Flag Register.
Microsoft OS, Linux and the Hardware Drivers use Real mode to have full control but it is dangerous because nothing is protected (memory, disks, screen etc.).
"Normal" Programs use Protected Mode, which is safe from hardware failures.
These modes are also found on other processors.

The best assembly compilers for x86 are : MASM32, AS86 and NASM.
The best assembly compiler for SUN and MOTOROLA is : GAS

+some code for GAs and NASM
+LINKS :
Assembly HOWTO
http://linuxassembly.org/resources.html
The Art Of Assembly http://webster.cs.ucr.edu/Page_asm/ArtOfAsm.html
x86 assembly FAQ http://www2.dgsys.com/~raymoon/faq/
Usenet: news://comp.lang.asm

rem :
*The assembly page is not intented only for x86, but thats the most used processor.
*I am not newbie in assembly but I just wanted to write a page FOR newbies without going deep into details... and sometimes I make mistakes, and I dont know everything. Thats why you are very helpfull. (sometimes I need to reread docs or books to be sure about what I am talking about).

Last edited by programmershous; 07-16-2004 at 11:51 AM.
 
Old 07-16-2004, 12:11 PM   #5
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
Quote:
Microsoft OS, Linux and the Hardware Drivers use Real mode to have full control but it is dangerous because nothing is protected (memory, disks, screen etc.).
Windows and Linux are 32 bit, and thus run in protected mode, not real mode. They use
vm8086 mode to access bios functions, but their native state is protected mode.

. . . . actually I just looked at your page and it seems your post is different from your actual
page. You actually have:

Quote:
Real mode vs Protected mode :
The 80x86 chip can be in those different modes by selecting the Mode Flag Register.
Microsoft OS, Linux and the Hardware Drivers use protected mode to have full control but it is dangerous because nothing is protected (memory etc.).
"Normal" Programs use Real Mode, which is safe from hardware failures.
I hope this is a wording error because why would it be called protected mode if nothing is
protected ? Normal programs run in 32 bit protected mode, which protects the operating
system from application failures. Remember that protected mode is the native state of the
processor, real mode is just kept so compatibility remains.
 
Old 07-17-2004, 08:17 AM   #6
programmershous
Member
 
Registered: Mar 2004
Distribution: Diverse
Posts: 77

Original Poster
Rep: Reputation: 15
sorry you are right : I have all mixed up, I am a bit tired.
By the way :
do you know when a driver needs to access in real mode ? is it only needed for bios ?
what do you mean with compatibility ?
 
Old 07-17-2004, 04:17 PM   #7
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
When in 32bit protected mode all code runs in 32bit mode, but should
code need to run in 32bit mode (to access bios, or run 16 bit code),
there is the vm8086 mode. You usually dont need to access the bios
once in 32bit mode very often.

The native state of the processor is 32bit protected mode, but intel
still has it start up in real mode since they want their chips to be
backward compatible, therefore chips made today will still run
old realmode code (ie: DOS).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Network programming in assembly Ephracis Programming 11 09-26-2013 01:56 PM
assembly programming Ephracis Programming 5 05-08-2005 02:04 AM
How to start Assembly Programming ? indian Programming 17 04-19-2005 10:51 PM
Programming Assembly with Power PC chutsu General 2 03-28-2005 12:36 AM
assembly programming in linux chriscoelphoto Linux - Newbie 2 05-02-2004 05:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration