Author Topic: 6805 branch and compare instruction conditions/results  (Read 375 times)

0 Members and 1 Guest are viewing this topic.

Offline Scratch.HTF

  • Regular Contributor
  • *
  • Posts: 81
  • Country: au
6805 branch and compare instruction conditions/results
« on: August 23, 2019, 02:12:43 am »
I am in the process of converting code from a Motorola 6805 series (MC68705P3) microcontroller to another architecture, but I am having trouble identifying what conditions (or what registers) are compared in the Branch and Compare instructions (also for Compare, where the result is stored):

eor   #$20   // Exclusive OR Memory with A
bne   L013C   // Branch if Not Equal

lda   X0014   // Load A from Memory
bne   L015C   // Branch if Not Equal

cmp   #$01   // Arithmetric Compare A with Memory
beq   L01AE   // Branch if Equal
If it runs on Linux, there is some hackability in it.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 6868
Re: 6805 branch and compare instruction conditions/results
« Reply #1 on: August 23, 2019, 03:26:23 am »
The questions you ask suggest that you haven't familiarised yourself with the architecture yet; give the first half of this a quick read first:

http://bitsavers.trailing-edge.com/components/motorola/6805/6805_Users_Manual_2ed_1983.pdf

Then use the instruction set reference in the second half for the details on what each of the instructions do.
 
The following users thanked this post: Scratch.HTF

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3286
  • Country: us
Re: 6805 branch and compare instruction conditions/results
« Reply #2 on: August 23, 2019, 04:12:31 am »
The branches are conditional based on bits in the “condition code register” that were set as the result of some previous ALU operation (xor, add, sub, etc)


The CMP instruction works like subtract, but does not store the result.  It ONLY sets bits in the CC register.

 

Online thinkfat

  • Supporter
  • ****
  • Posts: 1160
  • Country: de
    • Matthias' Hackerstübchen
Re: 6805 branch and compare instruction conditions/results
« Reply #3 on: August 23, 2019, 03:12:13 pm »
bne/eq branches based on the 'zero' flag. The zero flag is set in the result of an operation is 0.

Beq branches if the zero flag is set, bne not.



Gesendet von meinem Nokia 6.1 mit Tapatalk

Everybody likes gadgets. Until they try to make them.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf