This program uses ASSEMBLY X86 INTEL Lab #3: Direct Addressing, output, and ASCI
ID: 3800695 • Letter: T
Question
This program uses ASSEMBLY X86 INTEL
Lab #3: Direct Addressing, output, and ASCII code Purpose: The purpose of this lab assignment is to further familiarize the student with the basic output mechanism of the MS-DOS Operating Sstem, the INT instruction, as well as the conversion of internal binary number, a printable decimal number and display it on the video screen, usingASCIT code, DOSBlos functions. Introduction In the following assignment you are going to print the mumber "W on the screen in decimal. The number can be onlybe printed on the screen as ASCII digits, in this case ASCII decimal digits. Since the number Win the binary we have to convert it to decimal, convert, each decimal digit to ASCII and then print it. The following algorithm should help you. ALGORITHM FOR CONVERTING A BINARY NUMBER (eg. IN A REGISTER OR MEMORY INTO ASCII DIGITS FOR PRINTING ON SCREEN In general, the algorithm for converting a number in one base into a new base is to repeatedly divide the number by the new base and writing down the remainders (which will be the digits). The answer is the remainder in reverse order (this was the first week lecture). Now for this lab we need to convert to the new base of 10 (decimal. Here is the algorithm for converting to Decimal 1. Set a counter to zero. 2. Get number into the dividend registers for proper size. 3- Divide the dividend by the 16 bit divisor of 10. 4. Add ASCII value of 0x30 to the remainder digit. This is how to convert to ASCII 5. Save remainder digit on stack. (use PUSH instruction) 6. Add to counter of digits saved on stack 7. Zero out remainder register. 8. Test the quotient (next dividend to see ifits zero.Explanation / Answer
DATA SEGMENT NUM DB 0FFH RES DB 10 DUP ('$') DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX MOV AH,0 MOV AL,NUM LEA SI,RES CALL HEX2DEC LEA DX,RES MOV AH,9 INT 21H MOV AH,4CH INT 21H CODE ENDS HEX2DEC PROC NEAR MOV CX,0 MOV BX,10 LOOP1: MOV DX,0 DIV BX ADD DL,30H PUSH DX INC CX CMP AX,9 JG LOOP1 ADD AL,30H MOV [SI],AL LOOP2: POP AX INC SI MOV [SI],AL LOOP LOOP2 RET HEX2DEC ENDP END START
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.