# Converting Assembler Operators to Binary

• 06-04-2002
sean
Converting Assembler Operators to Binary
I'm making an assembler that runs off of CGI and hence, the processing will all be done in 100% C. I have a list of the equivalents of the Instructions in Assembler, and a guide on how to translate the operands in into binary (they have to be imbedded in the instruction). Operators how ever, are a different story. Anyone? There's no list in my book.
• 06-04-2002
*
There are only operands and operators. Operands are also called mnemonics (pronouned new-MON-ix).

Binary is not a thing. It is a numbering system, like hex or decimal. It is not a what, but a HOW you look at RAM.

If I look at a location in RAM in decimal I might see 0. If I look at it in hex, it might see 0x00, and if I look at it in binary I might see 00000000.

All the same thing no matter how you look at it.

Thus, to create assembly, you simply, using specific rules about your processor, create a 32-bit number whose bits reflect those that tell the processor what mnemonic it is, and then what its operands are. You might have to create a couple of other 8, 16, or 32-bit numbers to go with it, depending on the processor syntax for the given mnemonic.

If you want to see what bit pattern an assembly instruction (again, a mnemonic, or operand) requires, you should get a processor book from the maker of that chip (eg. Motorola or Intel), or get a book at the bookstore about that chip.. eg. 8088, or 80386, etc.)

So to recount: Let's _suppose_ you had an LDA mnemonic for "Loading a value into an Address location". It might be assembler like this:

Code:

...
NOP
LDA  #5,bx                      ;put a 5 into register bx
LDA  #10,ax                    ;put a 10 into register ax
MUL bx,ax                        ;multiply the 2, putting result into bx
...

In binary, you have to know how the processor knows what a register is (and hence what index applies to what register). You have to know how many bits are used to tell the CPU which mnemonic it's looking at.

For example, Let's say all mnemonics require 6 bits to tell the CPU what the mnemonic is. You need 3 bits each for each registor (your imaginary processor only supports 7 registers), you need a sign bit, and a value for the operators.

LDA #5,bx might look like this:

11101000000000000000000101010011

Which, in decimal is: 3892314451, or
in hex is: 0x00E8000153.
• 06-04-2002
sean
I know what binary is. I know how to convert. I've done the exact same thing with the assembly insructions, but I have no list for the operators. That's all I'm looking for.
• 06-04-2002
VirtualAce
Assembly operators??

There aren't any. Granted you can use the +, -, *, and / in assembly programs but that is usually because the assembler allows you to.

Perhaps you are not using the right term.

There are instructions and operands or opcodes and operands, R/M byte, and several other terms are used to describe an assembly statement. Look them up in an Intel manual.
• 06-04-2002
Sebastiani
...:sigh:
Boy are you deaf as a horse? If you had been listening to *guest's reply you would have realized that therein lies the answer to your question. Do you want to find the pattern? Just look at it:)
• 06-05-2002
Nick
I'm not sure what exactly you want but if the intel manuals don't have it...

http://www.intel.com/design/Pentium4/manuals/index.htm
• 06-05-2002
Shiro
>I'm not sure what exactly you want but if the intel manuals
>don't have it...

If it is an Intel which Sean is talking about. Another interesting link on microprocessors:

http://casl.csa.iisc.ernet.in/Comput...cture/Manuals/
• 06-05-2002
sean
Well my book calls them Operators. examples: The aforementioned arithmetic operators, HIGH, INDEX, LENGTH, LOW,OFFSET, MASK, PTR, SEG, SHL, SHR, SHORT, SIZE, THIS, TYPE, WIDTH. i'm also looking for the directives. Examples: ALIGN ENDP EVEN LABEL PROC IF ELSE .ERR .ERR1 ALIGN EQU EVEN LABEL ORG. DB DW DD DF DQ DT .CREF .LIST PAGE SUBTTL TITLE .XCREF .XLIST .LALL .LFCOND .SALL SFCOND TFCOND .XALL, and there are a lots of others which I can't be bothered typing in.
• 06-05-2002
Shiro
Seems you're using an Intel isn't it? I suggest you download the Intel manuals. There's lots of info in it. Or else take a look at this site:

• 06-06-2002
sean
No. The book is for IBM PCs It was written when DOS was state of the art. It's just your average Microsoft system
• 06-06-2002
*
In assembly language jargon, they are called operators or opcodes. The associated arguments are called operands.

An operator is also called a 'mnemonic' because it is an abbreviated instruction. For example 'LDA' stands for "LoaD effective Address'. Likewise, 'NOP' stands for 'No OPcode'.

First the last time, you need to get a book that is for the specific processor or family of processors you want to work with. Usually from the chip maker. This is an engineering book, not something you get at Amazon.com It will not only have all the engineering technical information, waitstates, cycle timing, buslining, etc., but it will also have every possible assembly instruction and what its associated bit pattern is, based on what operands are associated with it.

For example, for the Pentium IV, here is the link to Intel's site that you want to get a hardcopy of the instruction set (opcode) reference manual.

http://developer.intel.com/design/pe...als/245471.htm