Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beginner; mnemonics

Status
Not open for further replies.

TEKcisco

Technical User
Dec 22, 2005
7
US
I am new to assembly language, and I was wondering how mnemonics work? I understand what they do (like mov, jmp, and add), but I don't get how the computer nows what they are when you type them in that? How do you teach a board how to do this stuff?

move a, b
is move a to b (but how does the computer know that; get what I am saying?)
 
The computer "knows" what "mov a,b" means because the assembler program (MASM or TASM or A86 or whatever for the PC) converts the source text file into machine code that the computer can understand.

The mnemonic is a human readable form that is converted into some number for the computer to process.

For instance, for the Microchip PIC processor:

Code:
movlw 1   ;move the literal value 1 into W register
generates a numeric value of 0x3001

where 0x30xx is the movlw instruction

and 0xXX01 is the literal value 1.

The assembler program converts the text into the number that the computer can understand.
 
Thanks zeitghost for that information.

Ok, the assembly program generates the binary value 0000110000000001 (movlw 1), which in hexidecimal is 3001. You are saying that the assembly program is creating the low/high voltages to create the 0's and 1's

1) is this correct?

2) how does the assembly program know that 0x3001 means movlw
- computers can only follow "directions" (keyword - follow)
- if assembly code is the most "primative" langauage than how can you program what each hexidecimal value means.

3) how does the assembly program create the low/high voltages?


I know I probably dont need to know this to program in assembly, but I am a person that likes to know ask much as possible; in detail.
 
sorry, binary number is 0011000000000001, not 0000110000000001.
 
The assembler is just another program. It "translates" the memnonics into numerical instruction sequences that are hardwired in the chip. Early programmers it found much easier to remember what "movlv" does than what the instruction 30xxh does.
The assembler does not create the high-low voltages, the processor does that. The Processor executes the instruction sequence located at the memory address which is stored in the instruction counter, or Instruction Register, and then increments the Instruction Register appropiately. All that is pre-programmed into the chip at design time.

90% of all questions can be answer by the Help file! Try it and be amazed.
 
Thanks Prattaratt for the information.

So you are saying that all those mnemonics' hexidecimal/binary values are pre-programmed onto the chip itself. Is that the instruction sets like SSE1-4, MMX, 3DNOW!, 3DNOW! Professional?

So when I type in movlw 1, the processor reconizes it via the instruction set that it was pre-programmed with, it then processes the information that you gave it (in this case the W registry, and the value 1) according to the instruction set "set" up the movlw mnemonic, or hexidecimal/binary value. The processor then puts the value 1 into the W registry.
 
Not sure about 3DNow (Don't do much graphics work), but MMX and SSE are extensions to the basic Intel Processor instruction set, and they are hardwired into the chip also, same as the basic and FPU instruction sets, and are chip specific. If you try to use a MMX instruction on a 386 chip for example (not there that many out there any more) you will get an invalid opcode error, which means that the chip doesn't recognize the sequence of bytes as a legitimate instruction sequence.
Actually, what happens when you use a "direct assembler" (my term) is you type in movlw 1; the assembler then converts it to 3001 hex (or binary 001100000001) and stores it in a memory address.
The processor then, during the course of it's execution of the program you've typed in and assembled, comes to the memory location where the assembler stored the 3001, reads that instruction, and understands it to store 01 in the w register on the processor.


90% of all questions can be answer by the Help file! Try it and be amazed.
 
3DNOW! is basically an enhanced MMX instruction set, made by AMD, that improves the ability of the cpu to perform vector processing for the graphic intense applications. The 3DNOW! Professional is basically an enhanced 3DNOW!. AMD made this instruction set because 3D gaming was starting to become more and more popular; it is almost the same as SSE, but 3DNOW! came out one year prior. So its not just for grahics.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top