+ Reply to Thread
Results 1 to 7 of 7

Thread: roman number to decimal number

  1. #1
    khairulnisa Newbie
    Join Date
    Jul 2008
    Posts
    9

    Default roman number to decimal number

    how to convert the single digit roman no.

    i have done the basic code.

    but how if i want to make a loop or branch?

    START ORG $1000

    MOVE.B D6,D1
    CMP.B #$69,D1
    BEQ TRUEA
    CMP.B #$76,D1
    BEQ TRUEB
    CMP.B #$78,D1
    BEQ TRUEC
    MOVE.B #$FF,D1
    ORG $2000

    TRUEA MOVE.B #$1,D3
    ORG $3000
    TRUEB MOVE.B #$5,D3
    ORG $4000
    TRUEC MOVE.B #$10,D3
    ORG $5000
    END START

    END START


  2. #2
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,791

    Default

    I don't have experience of 8051 but looking at your code, something like,
    Code:
    START ORG $1000
    
        MOVE.B  #$1,D3	;preload with 1
        MOVE.B  D6,D1
        CMP.B   #"i",D1	;compare to i
        BEQ     Done	;if same then we're done
        MOVE.B  #$5,D3	;preload with 5
        CMP.B   #"v",D1	;compare with V
        BEQ     Done
        MOVE.B  #$10,D3	;preload with 10
        CMP.B   #"x",D1	;compare with x
        BNE     Error
    Done
    	;got value
    Error
    	;something wrong
    
        END START
    
    Should work.

    You should also consider setting bit 5 of D3 so it is not case sensitive.

    Mike.

  3. #3
    khairulnisa Newbie
    Join Date
    Jul 2008
    Posts
    9

    Default

    actually it is not 8051..
    but its 68k..

    the code that you give didnt work..
    but thanks for the reply

  4. #4
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,791

    Default

    If it's 68k then it should have worked unless the compiler doesn't accept "A" instead of 0x41. You did put some code where the two comments were didn't you?

    Mike.

  5. #5
    khairulnisa Newbie
    Join Date
    Jul 2008
    Posts
    9

    Default

    i didnt understand about your command.
    for the code that i ve write above,
    it should be like this..
    when i enter 49 in the D6,
    it should copy 49 in D1 and show the answer 1 in D3
    Attached Images

  6. #6
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,791

    Default

    Swap the "i", "v" & "x" for (0x)69, 76, & 78 and see if it makes more sense then.

    Where do you think your code goes to after it executes 1 instruction at location $2000?

    Mike.

  7. #7
    khairulnisa Newbie
    Join Date
    Jul 2008
    Posts
    9

    Default

    ok2..
    your code have work..

    but can u explain it for me?
    after we compare,
    and then done,
    should it been save in other address?

+ Reply to Thread

Similar Threads

  1. Looking for IC number...
    By MARCIS in forum Datasheet/Parts Requests
    Replies: 8
    Latest: 27th September 2008, 09:49 AM
  2. Number of PMs.
    By Pommie in forum Feedback/Comments
    Replies: 11
    Latest: 18th September 2008, 03:13 AM
  3. Number
    By jpanhalt in forum Feedback/Comments
    Replies: 7
    Latest: 22nd June 2008, 10:23 AM
  4. i need a led number
    By mohd qaisi in forum Datasheet/Parts Requests
    Replies: 2
    Latest: 1st November 2006, 10:26 PM
  5. wrong number genorator or disconected number genorator
    By colin886 in forum Electronic Projects Design/Ideas/Reviews
    Replies: 4
    Latest: 29th March 2006, 01:26 AM

Tags for this Thread