اخواني الكرام:
احاول عمل برنامج للتحويلبين انظمة الاعداد حيث يقوم المستخدم باختيار النظام ومن ثم يدخل رقم ويقوم البرنامج بعرض القيمة بالنظام العشري، الست عشري. مثلا يتم ادخال الرقم الثنائي 110 ويتم عرض القيمة 6 بالعشري والقيمة 6 ست عشري. البرنامج مشاي تمام مع جميع الصيغ ماعدا الثنائي. المشكلة هي كيف اقرأ الرقم بالثنائي ومن ثم تحويله الى عشري وست عشري. البرنامج بالكود المرفق علما بأني استخدم 32-bit.
وشكرا لمروركم
مشكلتي تحديدا في هذه الدالة
INCLUDE irvine32.inc .data num DWORD 5 binCounter DWORD ? binVal BYTE 17 DUP(0) prompt BYTE "Welcome to the Binary/Decimal/Hex Converter", 0 invalid BYTE "Invalid value, please try again", 0 hexPrompt BYTE "Enter the hexadecial number and press enter key: ",0 DecPrompt BYTE "Enter the decimal number and press enter key: ",0 binPrompt BYTE "Enter the binary number and press enter key: ",0 numInHex BYTE "The number in hexadecimal format: ",0 numInDec BYTE "The number in decimal format: ",0 numInBin BYTE "The number in binary format: ",0 menu BYTE "Press number corresponding to the ation you would like to take.",0DH,0AH BYTE "1. If you would like to convert a decimal to binary and hexadecimal.",0DH,0AH BYTE "2. If you would like to convert a binary nuber to decimal and hexadecimal.",0DH,0AH BYTE "3. If you would like to convert a hexadecimal number to decimal and binary.",0DH,0AH BYTE "4. If you would like to quit the application.",0DH,0AH .code main PROC mov edx, OFFSET prompt call WriteString another: call Crlf mov edx,OFFSET menu call WriteString call ReadDec cmp eax,4 je stop cmp eax,3 je fromHex cmp eax,2 je fromBin cmp eax,1 je fromDec mov edx,OFFSET invalid call WriteString ;call Crlf jmp another fromHex: mov edx,OFFSET hexPrompt call WriteString call ReadHex call print_dec call print_bin jmp another fromDec: mov edx,OFFSET decPrompt call WriteString call ReadDec call print_hex call print_bin jmp another fromBin: mov edx,OFFSET binPrompt call WriteString call ReadBin call print_dec call print_hex jmp another stop: call Crlf exit main ENDP ;----------------------------------------------- ReadBin PROC ; ; THE PROBLEM IS IN THIS PROCEDURE ;----------------------------------------------- push ecx push eax push esi push edx mov edx,OFFSET binVal ;point to the beginning of the binary string mov ecx,SIZEOF binVal mov esi,0 call ReadString ;input a string from the keyboard mov binCounter,eax ;number of characters mov ecx,binCounter ;MOV CX,16 ; number of digits XOR BX,BX MOV AH,1 L1: mov al,binVal[esi] CMP AL,0DH JE END_INPUTB AND AL,0FH ; convert to digit SHL BX,1 OR BL,AL ; insert in BL LOOP L1 END_INPUTB: MOV AX,BX POP DX POP CX POP BX RET ReadBin ENDP ;----------------------------------------------- print_hex PROC ; ;----------------------------------------------- mov edx,OFFSET numInHex call WriteString call WriteHex call Crlf ret print_hex ENDP ;----------------------------------------------- print_dec PROC ; ;----------------------------------------------- mov edx,OFFSET numInDec call WriteString call WriteDec call Crlf ret print_dec ENDP ;----------------------------------------------- print_bin PROC ; ;----------------------------------------------- mov edx,OFFSET numInBin call WriteString call WriteBin call Crlf ret print_bin ENDP
END main