hello this is my project to convert from arabic numerals to roman one's and vice versa but i have some problems in it ,dont know what 2 do ??/so pleassse help me 2 know or even 2 correct it
thanx alot
MODEL SMALL
.STACK 1000
ORG 100H
.DATA
INPUT LABEL BYTE
DB 20 DUP (?)
PARAMETER LABEL BYTE ;DEFINE A PARAMETER LIST
numM db 10,13,'1000 '
numD db 10,13,'500 '
numL db 10,13,'50 '
numX db 10,13,'10'
numV db 10,13,'5'
numI db 10,13,'1'
SHOWNAME DB 10,13,'MY NAME IS RASEEL$'
SHOWID DB 10,13,'MY ID 1060110$'
REQUEST DB 10,13,'IF U WANT TO CONVERT ROMAN TO ARABIC PRESS R,OR ARABIC TO ROMAN PRESS A$'
ENTER_ARABIC DB 10,13,'ENTER ARABIC NUMBER TO CONVERT$'
ENTER_ROMAN DB 10,13,'ENTER ROMAN NUMBER TO CONVERT$'
ROMAN_ARRAY_RESULT DB 50 DUP ?
ROMAN DB 50 DUP (?)
ARABIC DB 50 DUP(?)
INVALID_NUM DB 10,13,'YOU ENTERED AN INVALID NUMBER$'
PNTR DW 0
CUR_CHAR DB (?)
NXT DN (?)
.CODE
.386
.STARTUP
PROCEDURE PROC FAR ; A PROCEDURE FOR SEGMENT INITIALIZATION
MOV AX,@DATA ;INITIALIZE SEGMENT
MOV DS,AX ;REGISTERS
MOV ES,AX ;REGISTERS
JMP START
START :
CALL CLRSCR
MOV AH,02H ;SET CURSOR SUB SERVICE
MOV BH,00H ;PAGE NUMBER 0
MOV DX,0000
INT 10H
;make the boxes
mov bh,01h
mov cx,0000h
mov dx,1807h
int 10h
;make the boxes
mov bh,01h
mov cx,0048h
mov dx,184fh
int 10h
; make the boxes
mov bh,80h
mov cx,0210h
mov dx,0640h
int 10h
mov ah,02h ;setting crusor
mov bh,00 ;page number
mov dh,04 ;ROW NUMBER
mov dl,20 ;COLUMN NUMBER
int 10h
LEA DX,SHOWNAME
CALL DISPLAYMSG
LEA DX ,REQUEST
CALL DISPLAYMSG
CALL GETINPUT
CALL CHOICE
;CALL PROCEDURE FOR DISPLAYING INPUT REQUEST AND PNTREPTING INPUT
CHECK_NUM PROC NEAR ;check if this digit is anumber between 0-9
mov ax, num
cmp ax, 30h
jl INVALID
cmp ax, 39h
jg INVALID
xor ah,ah
endP
; ***************************************************************************;
CHECK_ROMAN PROC NEAR ;A PROCEDURE TO CHECH ROMAN ENTERED NUM VALIDITY
;MUST NOT BE MORE THAN 3999 OR LESS THAN 1
mov ax, num
cmp ax, 34h
jg INVALID
xor ah,ah
endP
INVALID:
LEA DX,INVALID_NUM
CALL SHOWMSG
;***************************************************************************************;
CHOICE PROC NEAR
xor bp,bp ; intialization of base pointer
CHOICE:
CALL GETINPUT
CMP al,'R' ; IF INPUT IS R=> CONVERT FROM ROMAN TO ARABIC
CALL CONVERT_ROMAN_ARABIC
CMP al,'A' ; IF INPUT IS A ==> CONVERT FROM ARABIC TO ROMAN
CALL CONVERT_ARABIC_ROMAN
loop CHOICE ; else start again
CHOICE ENDP
;************************************************************************************************************************
;****************************;
CLRSCR PROC NEAR ;PROCEDURE FOR CLEARING THE SCREEN
PUSHA ;PERSERVE GENERAL REGISTERS IN THE STACK
MOV AX,0600H ;SUB-SERVICE TO SCROLL SCREEN
MOV BH,30 ;COLOR ATTRIBUTES(BACKGROUND: BLUE,FOREGROUND:YELLOW)
MOV CX,0000 ;STARTING ROW:COLUMN
MOV DX,184FH ;ENDING ROW:COLUMN, CLEARING ENTIRE SCREEN
INT 10H ;GET BACK REGISTERS VALUE
POPA ;INTERRUPT FOR SCREEN HANDLER
RET ;RETURN TO OPERATING SYSTEM
CLRSCR ENDP
;****************************;
GETINPUT PROC NEAR
MOV AH,0AH ; TO IN FROM KB
LEA DX,INPUT
INT 21H
RET ;RETURN TO OPERATING SYSTEM
GETINPUT ENDP
;-------------------------------------------------------------;
DISPLAYMSG PROC NEAR ;MSG OFFSET MUST BE IN DX
MOV AH,09H ;OUTPUT TO SCREEN SUB-SERVICE
INT 21H ;OPERATING SYSTEM INTERRUPT
RET ;RETURN TO OPERATING SYSTEM
DISPLAYMSG ENDP
;------------------------------------
CONVERT_ARABIC_ROMAN PROC NEAR
LEA DX,ENTER_ARABIC
CALL SHOWMSG
MOV [SI],OFFSET ARABIC
MOV AH, 0AH
INT 21h
CALL CHECK_NUM
MOV SI,OFFSET ARABIC
MOV DI,OFFSET ROMAN_ARRAY_RESULT
MOV CX,50
CMP [SI],F9FH
JG INVALID
CMP [SI],1H
JL INVALID
CMP [SI],3F7H
JG PART1
CMP [SI],383H
JG PART2
CMP [SI],1F3H
JG PART3
CMP[SI],18FH
JG PART4
CMP [SI],63H
JG PART5
CMP[SI],59H
JG PART6
CMP [SI],31H
JG PART7
CMP [SI],27H
JG PART8
CMP [SI],9H
JG PART9
CMP [SI],8H
JG PART10
CMP [SI],4H
JG PART11
CMP [SI],3H
JG PART12
CMP [SI],1H
JG PART13
JMP PRINT_ROMAN
RET
END
PRINT_ROMAN:
MOV SI,OFFSET ROMAN_ARRAY_RESULT
MOV DI,2000 ; the result will be print in the center of the screen
mov AH,1Eh
PRINTLOOP:
LODSB
CMP AL,0
JE Finish
STOSW
JMP PRINTLOOP
INALID:
LEA DX,INVALID_NUM
CALL DISPLAYMSG
JMP EXIT
PART1:
MOV AL,'M'
MOV[DI],AL
INC DI
SUB [SI],3E8H
CMP [SI],3F7H
JG PART1
INC SI
PART2:
MOV AL,"CM"
MOV[DI],AL
INC DI
SUB [SI],384H
CMP [SI],383H
JG PART2
INC SI
PART3:
MOV AL,'D'
MOV [DI],AL
INC DI
SUB [SI],1F4H
CMP [SI],1F3H
JG PART3
INC SI
PART4:
MOV AL,"CD"
MOV[DI],AL
INC DI
SUB [SI],190H
CMP [SI],18FH
JG PART4
INC SI
PART5:
MOV AL,'C'
MOV [DI],AL
INC DI
SUB [SI],64H
CMP [SI],63H
JG PART5
INC SI
PART6:
MOV AL,"XC"
MOV [DI],AL
INC DI
SUB [SI],5AH
CMP [SI],59H
JG PART6
INC SI
PART7:
MOV AL,'L'
MOV [DI],AL
INC DI
SUB [SI],32H
CMP [SI],31H
JG PART7
INC SI
PART8:
MOV AL,"XL"
MOV [DI],AL
INC DI
SUB [SI],28H
CMP [SI],27H
JG PART8
INC SI
PART9:
MOV AL,'X'
MOV [DI],AL
INC DI
SUB [SI],0AH
CMP [SI],9H
JG PART9
INC SI
PART10:
MOV AL,"IX"
MOV [DI],AL
INC DI
SUB [SI],9H
CMP [SI],8H
JG PART 10
INC SI
PART11:
MOV AL,'V'
MOV [DI],AL
INC DI
SUB [SI],5H
CMP [SI],4H
JG PART11
INC SI
PART12:
MOV AL,'IV'
MOV[DI],AL
INC DI
SUB [S],4H
CMP [SI],3H
JG PART12
INC SI
PART13:
MOV AL,'I'
MOV [DI],AL
INC DI
SUB [SI],1H
CMP [SI],0H
JG PART13
INC SI
;-------------------------------------------------------------;
PROC CONVERT_ROMAN_ARABIC NEAR
LEA DX,ENTER_ROMAN
CALL SHOWMSG
CALL CHECK_ROMAN
mov bx, offset ROMAN
mov al, [bx + 1]
xor ah,ah
mov cx, ax
xor si,si
two_char:
mov AL, [bx + 2 + si]
MOV CUR_CHAR, AL
inc si
one_char:
mov AL, [bx + 2 + si]
MOV NXT, AL
inc si
;*********************************************
mov aL, CUR_CHAR
cmp aL, 4Dh ;compare M
je PART1
PART1:
add [word ptr PNTR],1000
dec si
jmp two_char
;*******************************************
cmp aL, 44h ;compare D
je PART2
PART2:
add [word ptr PNTR],500
dec si
jmp two_char
;**************************************************
cmp aL, 43h ;compare C
je PART3
PART3:
mov cL, NXT
cmp cL, 4Dh ;IF NXT IS M ADD 900
je PART4
PART4:
add [word ptr PNTR],900
jmp two_char
mov cL, NXT
cmp cL, 44h ;IF NXT IS D ADD 400
je PART5
PART5:
add [word ptr PNTR],400
jmp two_char
add [word ptr PNTR],100
dec si
jmp two_char
;********************************************************
cmp aL, 4Ch ;compare L
je PART6
PART6:
add [word ptr PNTR],50
dec si
jmp two_char
;***************************************************************
cmp aL, 58h ;compare X
je PART7
PART7:
mov cL, NXT
cmp al, 43h ;compare C
je PART8
PART8:
add [word ptr PNTR],90
jmp two_char
mov cL, NXT
cmp aL, 4Ch ;compare L
je PART9
PART9:
add [word ptr PNTR],40
jmp two_char
add [word ptr PNTR],10
dec si
jmp two_char
;*************************************************************
cmp aL, 56h ;compare V
je PART10
PART10:
add [word ptr PNTR],5
dec si
jmp two_char
;********************************************************************
cmp aL, 49h ;compare I
je PART11
PART11:
mov cL, NXT
cmp aL, 58h ;compare X
je PART12
PART12:
add [word ptr PNTR],9
jmp two_char
mov cL, NXT
cmp cL, 56h ;compare V
je PART13
PART13:
add [word ptr PNTR],4
jmp two_char
add [word ptr PNTR],1
dec si
jmp two_char
CALL PRINT_ARABIC
ret
endp
;*************************************************************************************************
PRINT_ARABIC PROC NEAR
LEA BX,[PNTR]
SUB SI,SI
LOOOP:
MOV DL,[BX+SI]
MOV AH,2 ; SUBROUTINE TO PRINT OUT WHAT IN DL
SUB DL,1; HERE IS THE ENCRYPTION
INT 21H
CMP DL,0
JE RETURN1
INC SI
JMP LOOOP; THE LOOP CONTINUES UNTIL DL=0
RETURN1:
RET
PRINT_ARABIC ENDP
;******************************************************************************
PROC FINISH NEAR
mov ah,4ch
int 21h
endp
;*******************************************************************************
END
;END OF MY PROJECT