EASy68K  
It is currently Mon Sep 25, 2017 8:40 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Nov 19, 2008 10:05 am 
Offline

Joined: Wed Nov 19, 2008 9:29 am
Posts: 5
Location: Wedel, Germany
Try this:

START ORG $0400

lea $800a,a0
lea $800a,a1
cmpa a0,a1
beq equal
nop
equal MOVE.B #9,D0
TRAP #15 Halt Simulator

END START

The CMPA sets the carry flag, not the zero flag. The BEQ is not executed. :shock:

START ORG $0400

lea $7fff,a0
lea $7fff,a1
cmpa a0,a1
beq equal
nop
equal
MOVE.B #9,D0
TRAP #15 Halt Simulator

END START

Works as expected. :D

Joerg


Top
 Profile  
 
PostPosted: Thu Nov 20, 2008 1:02 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1046
Joerg wrote:
Try this:
START ORG $0400
lea $800a,a0
lea $800a,a1
cmpa a0,a1
beq equal
nop
equal MOVE.B #9,D0
TRAP #15 Halt Simulator

END START

The CMPA sets the carry flag, not the zero flag. The BEQ is not executed. :shock:

Joerg

Strange as it may appear this is the correct behavior. The CMPA instruction sign extends word length source operands. So in your example the actual compare performed is:

$800A - $FFFF800A

Note that only the source operand is sign extended not both.

This should and does set the Carry flag.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 4:08 pm 
Offline

Joined: Wed Nov 19, 2008 9:29 am
Posts: 5
Location: Wedel, Germany
Thank you,

it's never to late to learn something new about the 68k i'm afraid.

Joerg


Top
 Profile  
 
PostPosted: Tue May 28, 2013 11:40 pm 
Offline

Joined: Wed Apr 25, 2012 12:43 pm
Posts: 7
Code:
START   ORG   $0400
 movea   #$800a,a0
 movea   #$800a,a1
 cmpa   a0,a1
 beq   equal
 nop
equal   MOVE.B   #9,D0
 TRAP   #15    Halt Simulator

 END   START


That is because lea is always long size an cmpa (without .size) is by default word size. If you use movea instead lea, it works like you expected


Top
 Profile  
 
PostPosted: Wed May 29, 2013 12:34 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1046
The movea instruction defaults to .w and performs a sign extend when loading the address registers. The move instructions result in $FFFF800A in the address registers. The cmpa instruction compares two negative word values.

_________________
Prof. Kelly


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group