Hi eneryone,
Im trying to learn about assemply 8085 in order to make a project i have.
First of all which emulator to use? I work in linux and I currently istalled GNUSim8085.
Also, maybe somewhere I can find some simple examples?
The project is about making an array saved in specific places in the memory with specific number in it. So i started with learning the loop for. I tried, with my little MIPS experience to assemply this C code:
int B = 0;
int A = 0;
for( A=0; A<5 ; A++ )
B = B + 1;
MVI A,00
MVI C,0AH
LXI D,0100H
LOOP: STAX D
INX D
INR A
DCR C
JNZ LOOP
HLT
makes this code:
for( i=0;i<10;i++ )
{
a=i;
}
and the array is saved in memory at 0100H - 0109H.
That's the first part completed. Now i have to do the equation n=i^2-1 (i from the for loop) in order to save n in every row of my array.
Any help appreciated!
---------- Post updated 15-05-12 at 07:33 AM ---------- Previous update was 14-05-12 at 05:02 PM ----------
A first idea is to add i with itself at a loop and then decrease the result with dcr.
But i have problems with the coding part.. Anyone ?
As the 8085 doesnt have a multiply instruction you will have to add i to itself i times every time you go throgh the loop...here is a sample routine when i==3...
MVI B,03H
MVI A,0H
MOV D,B
I2: ADD B
DCR D
JNZ I2
SUB 01H
RET
One last question on this.. Kind of stuck in that:
What is the routine, if my equation is n = 1 - i^2 ?
I'm a little new handling minus numbers in hex.
Maybe, something with MSB bit which is the sign (+/-) when we have a minus number?
:wall:
The 8085 uses 2s complement to represent negative numbers...so knowing that negate i^2 by inverting it and adding 1 to it followed by adding 1 again to represent the equation "n=1-i^2"...and in the final step display the result by taking the 2s complement of n.