Assembly 8085


 
Thread Tools Search this Thread
Top Forums Programming Assembly 8085
# 1  
Old 05-10-2012
Assembly 8085

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:
Code:
int B = 0;
int A = 0;
for( A=0; A<5 ; A++ )
	B = B + 1;

my effort is this code:
Code:
;for

	MOV	#^00,B
for	MOV	#^00,A

loop	CMP	#^05,A
	BEQ	end_for

	ADD	#^01,B
	ADD	#^01,A
	JMP	loop
end_for	HLT

But i get errors in line 3. Anyway if anyone can help me please do so. I'm willing to learn and search with some help. Thanks.

Ps: What about gcc -S example.c ? What type of code i get in example.s?
# 2  
Old 05-10-2012
You get what errors in line 3?
# 3  
Old 05-10-2012
Quote:
Originally Posted by Corona688
You get what errors in line 3?
Yes, sorry..
I get:
unfinished code in line 3.

Smilie

Last edited by giampoul; 05-10-2012 at 05:03 PM..
# 4  
Old 05-13-2012
Code:
	MVI	A,0
	MOV	A,B

loop	CMP	05,A
	BEQ	end_for

	ADD	01,B
	ADD	01,A
	JMP	loop
end_for	HLT

I think this must be better..
Error in line 4: Invalid command.
# 5  
Old 05-15-2012
I found something with some help...
This:
Code:
        MVI A,00 
        MVI C,0AH 
        LXI D,0100H 
LOOP:   STAX D 
        INX D 
        INR A 
        DCR C 
        JNZ LOOP 
        HLT

makes this code:
Code:
for( i=0;i<10;i++ ) 
{ 
   a[i]=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 ----------

Quote:
Originally Posted by giampoul
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!
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 ?
# 6  
Old 05-15-2012
Quote:
Originally Posted by giampoul
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...
Code:
        MVI B,03H
	MVI A,0H
	MOV D,B
I2:	ADD B
	DCR D
	JNZ I2
	SUB 01H
	RET


Last edited by shamrock; 05-15-2012 at 05:05 PM..
This User Gave Thanks to shamrock For This Post:
# 7  
Old 05-17-2012
Quote:
Originally Posted by shamrock
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...
Code:
        MVI B,03H
	MVI A,0H
	MOV D,B
I2:	ADD B
	DCR D
	JNZ I2
	SUB 01H
	RET

With Virtual 8085 I get 2 errors.
line 2: only 8-bit second operand.
I changed that with:
Code:
MVI A,00H

line 7: Invalid register specified.

Ok, i think that do the job!
Code:
	MVI B,03H
	MVI A,00H
	MOV D,B
I2:	ADD B
	DCR D
	JNZ I2
	DCR A
	MOV B,A
	STA 0001h
	HLT

Thanks for your help !

Last edited by giampoul; 05-17-2012 at 02:35 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Understanding Assembly Code

As the title suggests, I want to better understand the following assembly code: section .text global main ; must be declared for linker (gcc) main: ; tell linker entry point mov edx, len ; message length mov ecx, msg ; message to write... (2 Replies)
Discussion started by: Azrael
2 Replies

2. Homework & Coursework Questions

Sparc Assembly

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am having a hard time with this assignement i cant get the pfib value to print out the fib sequence. ... (1 Reply)
Discussion started by: kenjiro310
1 Replies

3. Programming

vga assembly question

Im trying to make a vga program for linux Im wondering if anyone knows of a simple document on the subject or if someone could show me some basics. What system calls should I use what parameters should I give them. How do I draw a line of pixels green after in vga mode. I prefer nasm but I can use... (2 Replies)
Discussion started by: Errigour
2 Replies

4. What is on Your Mind?

Can assembly language be dispensed with ?

Hi. I learned C in high school and am proficient in it:D. At the college while learning microcontrollers there was a short course on assembly language which I skipped:p but had no trouble as most of the application programming had to be done in C. Should I go back n learn assembly language as I... (9 Replies)
Discussion started by: priyadarshianu
9 Replies

5. Programming

Why Assembly Language?

Hi guys, Assembly language is a low level language designed in 1950's, both system and application programs were written in assembly at that time. There is no question of assembly being very effecient compared to the other high level languages. But it is very cumbersome to write programs in... (9 Replies)
Discussion started by: gabam
9 Replies

6. Programming

Fibonacci (assembly)

When i run this with gcc filename.s -o filename. It is giving fatal error: Unknown opcode at define registers. Anyhelp will be appreciated .section ".data" prompt: .asciz "\nThis program prints the Fibonacci sequence" prompt2: .asciz "\nEnter a limit on the largest number to be displayed:"... (2 Replies)
Discussion started by: Learnerabc
2 Replies

7. Programming

Help with assembly code

I want make simple assembly code for some thing like this a^6+6a^2+2a and range of a is between -3 to 3. I tried but it is not working properly. As this is my first assembly program that I am going to try, I want some help with it. I found this example online but i dont want this kind of... (2 Replies)
Discussion started by: Learnerabc
2 Replies

8. Programming

Need assembly code for C program

Dear Buddies, I need assembly code for a compiled c program in unix. Kindly help me.... Thanking you in advance. (1 Reply)
Discussion started by: karthik537
1 Replies

9. Shell Programming and Scripting

Unix assembly help

Hey guys, well I'm extremely knew to Unix so any help advice is very appreciated. What I am trying to do is assemble a source code (Programming from the Ground Up: Chapter 3: Your First Programs) The source code named "FINDING A MAXIMUM VALUE" is the code I am trying to link and run, but I... (1 Reply)
Discussion started by: ac09
1 Replies

10. UNIX for Dummies Questions & Answers

Assembly vs C programming

I am currently looking into an os on developed on an x86 platformwhich contains certain assembly code written in .s files(NASM- compatible ) instead of using C I was wondering why C could not be used to do low level stuff instead? Do anyone have any idea or could enligthen me?Appreciate any help... (0 Replies)
Discussion started by: duoshock
0 Replies
Login or Register to Ask a Question