Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] 'Comparison' in assembly language

Status
Not open for further replies.

amit251291

Member level 1
Joined
Jul 18, 2012
Messages
38
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,558
Hello,

I want to prepare a assembly program which will compare more than 2 numbers. Actually i want to send a message to particular mobile number if speed exceeds more than say 6 km/hr

suppose that there are 3 digit numbers (till 999). now if speed exceeds above 6 km/hr then it should jump to "Message sending routine". after executing that it should come back to the comparison. how should i implement in program?
So if i consider only unit's place then it should be compared with '6'.. if number at unit's place is greater than '6' then it will jump to "Message sending routine". How to do this?? i need example of a such program..

thank you :)
 

Assembler for what ?

Z80 / 8080 / 8085 / PIC 8 bit / Pic 16 bit / Pic 32 bit / 8051 / MSP 430 / ARM / IBM-470 / Cray.

I would sugest that you define the processor as 1st step, then somebody can help
 

Maybe subtract your desired number (which is 6), then do:

BEQ (branch if equal to zero)
BNE (if not equal)
BMI (if minus)
BLT (if less than)
BGT (if greater than)

The 'branch' command jumps forward or backward the stated number of bytes (in two's complement).
 
Assembler for what ?

Z80 / 8080 / 8085 / PIC 8 bit / Pic 16 bit / Pic 32 bit / 8051 / MSP 430 / ARM / IBM-470 / Cray.

I would sugest that you define the processor as 1st step, then somebody can help

oh sorry i forgot that... its AT89C51 controller..

- - - Updated - - -

Maybe subtract your desired number (which is 6), then do:

BEQ (branch if equal to zero)
BNE (if not equal)
BMI (if minus)
BLT (if less than)
BGT (if greater than)

The 'branch' command jumps forward or backward the stated number of bytes (in two's complement).

can you please give me some more info? :eek:
 

The Branch command works the opposite of an IF structure.

It tests for a condition in the register, and if the condition is satisfied then it will cause execution to branch around your message routine. The number of bytes it skips forward or backward must be less than 127.

That is how it worked with my VIC-20 assembly code (using the 6502 microprocessor). Your AT89C51 may use a different command.

You can also put your message routine in a separate block of memory, and JUMP to its address. Then Jump back. Of course this requires that you keep careful track of your memory locations.
 

89C51 Have the folowing "comparasion"instructions or in other words a "if" something hapens do something

JZ / JNZ / JC / JNC / JB / JNB / JBC / CJNE

I "beat"that CJNE is the one that will help you

The CJNE instruction compares the first two operands and branches to the specified destination if their values are not equal. If the values are the same, execution continues with the next instruction.

Take a look on this link

https://www.keil.com/support/man/docs/is51/is51_cjne.htm
 

89C51 Have the folowing "comparasion"instructions or in other words a "if" something hapens do something

JZ / JNZ / JC / JNC / JB / JNB / JBC / CJNE

I "beat"that CJNE is the one that will help you

The CJNE instruction compares the first two operands and branches to the specified destination if their values are not equal. If the values are the same, execution continues with the next instruction.

Take a look on this link

https://www.keil.com/support/man/docs/is51/is51_cjne.htm

Yes... i have done something like this,

Code:
        CJNE A,#06H,GREATER      //check if A is greater than 06. If equal then it will fall through
	LJMP GET_THIRD        // execute "get_third" routine only if it is equal
GREATER:JNC SEND_SMS        // if they aren't equal then it will check for A>06 (i.e for 0 carry bit) and if C=0 then it will jump to "send_sms" routine 
	LJMP GET_THIRD  // execute "get_third" routine only if it A<06


is this correct implementation?
 

Apear to be, but only you will knew after a simulation and testing . Also note that in todays world normally microprocessor software are implemented in high level languages like C or Pascal, assembler is used only when performance is at premium, othwetrise C will b easyer and will with faster implementation time. The fact is that in 90% of the time a microprocessor is waiting for something to happen
 

Apear to be, but only you will knew after a simulation and testing . Also note that in todays world normally microprocessor software are implemented in high level languages like C or Pascal, assembler is used only when performance is at premium, othwetrise C will b easyer and will with faster implementation time. The fact is that in 90% of the time a microprocessor is waiting for something to happen

okay.. :) thank you :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top