Just started learning PEP/8 what would the correct way to convert numbers into roman numericals? for exemple How can input let say 6 and have it come out as VI in the output? I know what i did is far from being the correct way to do things as i only print out the roman letters when input specific numbers.

``````BR main

;******* main ()

nb: .BLOCK 2
I: .EQUATE 1
II: .EQUATE 2
III: .EQUATE 3
IV: .EQUATE 4
V: .EQUATE 5
X: .EQUATE 10
L: .EQUATE 50
C: .EQUATE 100
D: .EQUATE 500
M: .EQUATE 1000

char00: .byte 0x0049 ; I
char01: .byte 0x0056 ; V
char02: .byte 0x0058 ; X
char03: .byte 0x0043 ; C
char04: .byte 0x004C ; L
char05: .byte 0x0044 ; D
char06: .byte 0x004D ; M

msg1: .ASCII "Enter nomber from 1 à 3999: \x00" ;
msg2: .ASCII "Invalide number \x00"  ;

main:    STRO  msg1,d ;
DECI  nb,d
LDA nb,d
CPA I,i
BREQ valid1 ;if (number = 1)
CPA II,i
BREQ valid2 ;if (number = 2)
CPA III,i
BREQ valid3 ;if (number = 3)
CPA V,i
BREQ valid4 ;if (number = 5)
CPA X,i
BREQ valid5 ;if (number = 10)
CPA C,i
BREQ valid6 ;if (number = 50)
CPA L,i
BREQ valid7 ;if (number = 100)
CPA D,i
BREQ valid8 ;if (number = 500)
CPA M,i
BREQ valid9 ;if (number = 1000)
CPA 0,i;
BRLE invalid ;if (number <= 0) then print msg2 (invalid number)

valid1: CHARO char00,d ; 0x0049 is 'III' is Hexadicimal numbers
CHARO '\n',i
BR finish
valid2: CHARO char00,d ; 0x0049 is 'II' is Hexadicimal numbers
CHARO char00,d
CHARO '\n',i
BR finish
valid3: CHARO char00,d ; 0x0049 is 'III' is Hexadicimal numbers
CHARO char00,d
CHARO char00,d
CHARO '\n',i
BR finish
valid4: CHARO char01,d ; 0x0056 is 'V' is Hexadicimal numbers
CHARO '\n',i
BR finish
valid5: CHARO char02,d ; 0x0058 is 'X' is Hexadicimal numbers
CHARO '\n',i
BR finish
valid6: CHARO char03,d ; 0x0058 is 'C' is Hexadicimal numbers
CHARO '\n',i
BR finish
valid7: CHARO char04,d ; 0x0058 is 'L' is Hexadicimal numbers
CHARO '\n',i
BR finish
valid8: CHARO char05,d ; 0x0058 is 'D' is Hexadicimal numbers
CHARO '\n',i
BR finish
valid9: CHARO char06,d ; 0x0058 is 'M' is Hexadicimal numbers
CHARO '\n',i
BR finish
invalid: STRO msg2,d
CHARO '\n',i
br main ; branch to beginning

finish:  STOP
.End``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.