This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

What is the advantage of direct addressing in assembly code?

Hi,

I will write some assembly code in a project. On the assembly instruction manual, I notice that there is direct addressing mode (DP page mode). I have no idea what useful comparing to indirect addressing. Could you shed some light on this?

Thanks

  • by direct addressing you can refer directly to the variable in the instruction, this typically will imply less number of cycles and wider set of instructions can be used, 

    if using indirect adressing then first the address if brought in and then the value is read into a CPU register,

    depending on operations you may be able to directly operate using pointers,

    the compiler does optimization in selecting when to use direct or indirect when working on variables..  

    in a nutshell it is a trade off , but if you are already writing assembly that trade off will be very apparent to you.,.

  • Your reply makes senses generally for data in one page. For my project, we have 1024 integers (old data, stored in memory) to process through after each new data comes.  Because 1024 has many data pages, I wonder we have to add register as a counter for changing data pages. The extra overhead will cost more for direct addressing. Whether you have good ideas applying to direct addressing in this situation?

    Thanks,

  • Robert,

    you are correct in your understanding, In the case you pointed out i will recommend using indirect addressing

    regrads

    manish bhardwaj