program time to execute

Discussion in 'Homework Help' started by Leite33, Jan 2, 2016.

  1. Leite33

    Thread Starter Member

    Nov 28, 2015
    57
    0
    Dear Friends
    I want some of your help again.
    i have the below program code that works on processor 8085 intel.
    upload_2015-12-17_3-21-1.png
    I have to calculate how much time will take it to execute if the frequency is 4MHZ and the time of the CALL D500M is 500msec.
    Now i want little your help here. First of all i search on net but i didnt find any good notes about how much time make all the above commands.
    For example i dont know about DB and MVI . I think MVI its 4*period of clock. So if frequency is 4MHZ then T of clock is 0,25 and MVI is 1. Am i right???
    Can someone give me some instructions? Also i am not sure how much times will called LOOP1 and LOOP2 so to calculate exactly my program how much time will take to execute
     
    Last edited by a moderator: Jan 2, 2016
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    Let's approach the loops. What three statements are used to define a loop on this code. Ignore anything else, just identify the three statements and to be simpler, let's look at loop1 first
     
  3. Leite33

    Thread Starter Member

    Nov 28, 2015
    57
    0
    ok my first loop is loop1 that calls function showx so if i make all the times in compination with T i have:
    XTHL -> 16T
    MVI B, 0Eh -> 7T
    MOV A,M ->4T
    OUT 3Eh->10T
    INX H ->6T
    MOV A,M->4T
    OUT 3Fh->10T
    INX H-> 6T
    DCR B-> 4T
    JNZ LOOP2-> 10T,7T
    CALL D500M; Delay 500msec 18T
    XTHL ->16T
    RET-> 10T

    So for this part i have: (16T+7T)+(4T+10T+4T+6T+10T+6T+4T) -3T+(18T+16T+10T)
    I am not sure what i have to do with Delay or its ok with my calculates. Also i am not sure if i know everything to calculate time. So this is my attemp for loop1 that calls ShowX
     
  4. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    But some of those commands are executed multiple times. How many times and what is the total time. That's what I was trying for you to determine with my questions, but you did not answer them.

    Let me try again. What three commands causes the instructions in showx to repeat? How many times do they repeat?
     
  5. Leite33

    Thread Starter Member

    Nov 28, 2015
    57
    0
    Hi friend . I am not sure how many times they repeat. Loop1 is the one that call command showx many times. And part of loop2 run many times but i am not sure at all. and then its delay 500msec.
    jnz loop1 (n-1 times,jump taken), (1 time, jump not taken)
     
  6. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    What does jnz mean? What does the statement immediately before the jnz do?
     
  7. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,791
    JNZ is "Jump If Non-ZERO"
    What does "If Non-Zero" mean?
    Glad you asked that -- It refers to a condition code bit called the Zero Bit. The Zero Bit is set to a 1 if the last result out of the ALU (Arithmetic Logic Unit) was a zero, that is all 8 bits are equal to zero. Non-Zero means the Zero Bit (aka Z bit) is not eqaul to 1. The only way a bit can be not equal to 1 is if it is zero. That means the last 8 bit result out of the ALU had at least one non-zero-bit.

    Before the LOOP is entered the value 10h, which means "10 hexdecimal" is loaded into the C register. 10h is equal to 16 decimal.

    So what does DCR C do?
     
  8. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    I was asking the OP hoping he would discover at least some of your reply.
     
  9. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,791
    He had almost 24 hours to respond. Trouble is, the information is getting hard to come by -- even online. Sorry.
     
  10. Leite33

    Thread Starter Member

    Nov 28, 2015
    57
    0
    Dear Friends.
    The homework is to calculate in this part the time that program need to execute. Its another part to describe what the program do. DCR C means reduce Counter C by 1. I thought its little more simle but now i am not sure at all.
     
  11. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,791
    So does it make sense that the C Register takes the values from the following sequence {10h, 0Fh, 0Eh,...,02h, 01h, 00h}?
    When it gets to 0 the jump is not taken.
     
  12. Leite33

    Thread Starter Member

    Nov 28, 2015
    57
    0
    I am not sure if i understand you. You mean that sometime the loop below stops?
     
  13. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    But what do you think? Stripping the loop2 control to its basics...
    Code (Text):
    1.        MVI B, 0EH
    2. LOOP2: ...
    3.        ...
    4.        DCR B
    5.        JNZ LOOP2:
    6.        ...
    Where ... means other code which we are ignoring for the moment. Can you describe for me what happens!
     
  14. Leite33

    Thread Starter Member

    Nov 28, 2015
    57
    0
    I am sorry its difficult explain in english.Can you describe what is going on with the above commands. In B we move data 0EH. DCR-> DONE if B=0. JNZ keep looping. I think i need some help in describe me
     
  15. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    OK, you have the idea of what the MOV command does.
    However, your idea of what DCR does is incorrect. DCR decrements a value and then continues (As you have said before. Why did you change your mind?)
    JNZ does something completely different, as Papabravo told you in post #7.

    I am beginning to think that you don't want to learn enough to solve your problem; rather you are waiting for someone to give you the answer. Convince me that I am wrong, by reading through the posts and answering once again my question posed in post #13.
     
  16. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    Not here, it ain't :)
    Detailed 8085 instruction set and execution times in Chapter 5 of the Family User's Manual.
    There was I time when I knew that book by heart...
     
  17. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,791
    That makes at least two of us who used to know it like the back of our hands.
     
  18. sailorjoe

    Member

    Jun 4, 2013
    361
    63
    And here's a chart that packs it all in on one page.
    http://pastraiser.com/cpu/i8085/i8085_opcodes.html

    Leite, you really need to understand how assembler programs work before you can answer the homework problem. People here have asked you questions to make sure you understand basic concepts so they can properly guide you to full understanding. Please, try to answer all the questions from the earlier posts.
     
  19. Leite33

    Thread Starter Member

    Nov 28, 2015
    57
    0
    Ok friends i will read again the whole notes and i will ask you again here. Thank you. One question more. What about DB command. Do we count its time to find the time of whole program? I mean does it need time to execute?
     
Loading...