#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    595
    Rep Power
    14

    ASM: compare two characters?


    Hi,

    I have a character and I need to know whether it is greater than or less than some other characters (for example, I need to know if the character is greater than/less than the letter 'a').

    How do I do this for the Motorola 68K processor?
  2. #2
  3. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    Originally Posted by n000b
    Hi,

    I have a character and I need to know whether it is greater than or less than some other characters (for example, I need to know if the character is greater than/less than the letter 'a').

    How do I do this for the Motorola 68K processor?
    This is a very beginner question, perhaps you should go read a tutorial on 68k asm.

    There also isn't much experience with asm for that architecture here.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    595
    Rep Power
    14
    I have tried Googling for a while with no result, could you please point me in the right direction?
  6. #4
  7. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    I can't seem to find anything either, other than a tip to try find a manual on ebay.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    595
    Rep Power
    14
    I'll have a look for something like that. Is it just one command that I need? If it is just one command then could you please tell me what it is and I'll go see how to use it
  10. #6
  11. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    Hrm, i just found an old book on writing a compiler that uses 6800..

    On the 68000 the condition flags are set whenever any data is
    moved or calculated. If the data is a 0000 (corresponding to a
    false condition, remember), the zero flag will be set. The code
    for "Branch on zero" is BEQ. So for our purposes here,


    BEQ <=> Branch if false
    BNE <=> Branch if true
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    595
    Rep Power
    14
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    595
    Rep Power
    14
    I thought that this might be how you do it but it doesn't work:

    Code:
    	org	$1000
    	move.l	#$7ffe,sp
    	
    	move.b	#$64,d2
    	move.b	#$68,d3
    	
    	sub.b	d3,d2
    	bne	aaa
    	bra	bbb
    
    
    	
    ; loop through and display a string ('smaller')
    aaa	move.l	#a,a4
    
    anext	move.b	(a4)+,d1
    	
    	cmp.b	#null,d1
    	beq	finish
    	
    	move.b	d1,d0
    	
    	move.b	#248,d7
    	trap	#14
    
    	bra	anext
    	
    	
    	
    ; loop through and display a string ('bigger')
    bbb	move.l	#b,a4
    
    bnext	move.b	(a4)+,d1
    	
    	cmp.b	#null,d1
    	beq	finish
    	
    	move.b	d1,d0
    	
    	move.b	#248,d7
    	trap	#14
    
    	bra	bnext
    	
    	
    	
    	
    	
    finish	move.b	#228,d7
    	trap	#14
    
    	
    	org	$1500
    a	dc.b	'smaller',null
    b	dc.b	'bigger',null
    null	equ	00	
    	end
    I'm basically subtracting one from the other and then using the branch if equal/not equal codes, but it's not working. What am I doing wrong?
    Last edited by n000b; May 22nd, 2006 at 08:50 PM.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    595
    Rep Power
    14
  18. #10
  19. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    Could you please post your solution then? We do get a fair few 68k assembler questions, and there isn't a whole lot of expertise on it in here. It might help a few other people.

    Comments on this post

    • n000b agrees
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    595
    Rep Power
    14
    I had to use the cmp.b instruction, and then use blt (less than), bgt (greater than), beq (equal) etc.

    Like this:

    Code:
    ; checks to see if d2 is greater than d1 and branches to "someplace" if it is
    cmp.b d1,d2
    bgt someplace

    Comments on this post

    • LinuxPenguin agrees : Thanks for coming back to post your solution, it's a great help to those who bother searching.

IMN logo majestic logo threadwatch logo seochat tools logo