Wednesday, September 15, 2010

Assembly idiom?

I want to write an assembly expression program to perform the logical AND operation on two operands. One operand should be the word (16 bits) held surrounded by memory locations 1000 and 1001.

The other operand should be the word held in memory locations 1002 and 1003. Place the results contained by location 1004 and 1005. What should this look like?

Assembly idiom?

You don't voice what CPU chip, however (at the most primative level) the general form of the code will be as follows :-



LDw #1000, regA ; nouns word from location 1000 to register A



LDw #1002, regB ; load word from location 1002 to register B



AND regA,regB,regC ; AND words contained by A & B to form result in C



LDw regC, #1004 ;store word from C to memory location 1004



This uses CPU Registers A, B & C. If the CPU supports direct memory address you could write :-



ANDw #1000, #1002, #1004



(w means word operation, # ability absolute address - the exact syntax will depend on the Assembler and CPU architecture)

No comments:

Post a Comment