Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

roman number to decimal number

Status
Not open for further replies.

khairulnisa

New Member
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
 
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.
 
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.
 
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
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    79.6 KB · Views: 134
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.
 
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?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top