Discussion in "Project Help" started by    Suro1996    May 12, 2016.
Thu May 12 2016, 01:01 am
#1
Hello, I am new to assembly programming and I am having difficulties with my project please help me .
The problem is to find the biggest number in the sequence which is stored in memory, the length of sequence is given.
I wrote a code that should work but it doesn't. . Numbers are saved from 0x70 to 0x74 in data memory.
mov r0,0x71 ;start of the sequence
mov r1,#4 ;length of sequence-1
N set r1
num set r0
mov A,num ;first element is saved in A
again:
push acc
subb A,@r0 ; second element is saved in r0
pop acc

jnc bob
jc small
mov r5,A
djnz N,again
jmp verj
small: mov A,r0
inc r0
clr c
ret
bob: inc r0
ret
verj: nop




[ Edited Thu May 12 2016, 03:21 am ]
Thu May 12 2016, 02:57 am
#2


Is this all the code you have ?

As it is, it will not run.
If you have more, please post all of it.


ExperimenterUK


No this is all I've got, the algorithm I think is correct but something is wrong in the code and I can't figure it out .
Thu May 12 2016, 02:58 am
#3


No this is all I've got, the algorithm I think is correct but something is wrong in the code and I can't figure it out .

Suro1996


How can you tell something is wrong if you don't have enough code to run ?

Which compiler are you using ?



I dont know why I cant do PUSH A,

Suro1996



I did a search and found this..
"
First, you should obtain a detailed understand of the 8051 hardware architecture.
One of the best documents on this subject is the original
Intel MCS(R) 51 Microcontroller Family User's Manual. This manual is available from the Intel Web Site.

Chapter 1: MCS 51 Family of Microcontrollers Architectural Overview answers your first question,
"What is the difference between ACC and A?". In the Addressing Modes section,
it clearly explains REGISTER SPECIFIC INSTRUCTIONS where the Accumulator is referred
as A and DIRECT ADDRESSING where ACC is used to specify the SFR address of the Accumulator.

Chapter 2: Programmer's Guide and Instruction Set provides a complete description of all CPU
instructions. Here you will see that some instructions are only available with DIRECT ADDRESSING.
For example, there is no instruction to PUSH the Accumulator.
However, you can PUSH the ACC SFR (which effectively does the same thing).
"
Frankly that does not make much sense to me.
The thing to remember is that the 8051 has many traps
like that when it comes to adressing modes.

To me the 8051 is a terrible micro to learn on !


[ Edited Thu May 12 2016, 03:06 am ]
Fri May 13 2016, 02:05 am
#4
Here is one way.
If you have the Keil compiler you can debug/test it.
Keil is free for small projects like this.

Attachment

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am