program time to execute

Thread Starter

Leite33

Joined Nov 28, 2015
57
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:

djsfantasi

Joined Apr 11, 2010
5,913
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
 

Thread Starter

Leite33

Joined Nov 28, 2015
57
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
 

djsfantasi

Joined Apr 11, 2010
5,913
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?
 

Thread Starter

Leite33

Joined Nov 28, 2015
57
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)
 

Papabravo

Joined Feb 24, 2006
12,767
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?
 

djsfantasi

Joined Apr 11, 2010
5,913
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?
I was asking the OP hoping he would discover at least some of your reply.
 

Thread Starter

Leite33

Joined Nov 28, 2015
57
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.
 

Papabravo

Joined Feb 24, 2006
12,767
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.
 

djsfantasi

Joined Apr 11, 2010
5,913
But what do you think? Stripping the loop2 control to its basics...
Code:
       MVI B, 0EH
LOOP2: ...
       ...
       DCR B
       JNZ LOOP2:
       ...
Where ... means other code which we are ignoring for the moment. Can you describe for me what happens!
 

Thread Starter

Leite33

Joined Nov 28, 2015
57
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
 

djsfantasi

Joined Apr 11, 2010
5,913
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.
 

sailorjoe

Joined Jun 4, 2013
361
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.
 

Thread Starter

Leite33

Joined Nov 28, 2015
57
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?
 
Top