Introduction to embedded systems Microprocessors 4.10 For integer division M/D,
ID: 664486 • Letter: I
Question
Introduction to embedded systems Microprocessors 4.10 For integer division M/D, D neq 0 and M being an n-bit word, yielding a quotient Q and remainder R. one algorithm that mimics long division is the following: Step 1: Initialize Q = 0, R = 0 Step 2: FOR j = n - 1 to 0 DO 2.1 R 2R + M(j) 2.2 IF R>=D THEN a. R R - D b. Q(j) = M(j) FNDIF In this algorithm, M(j) means the bit of N in the j-th position. a. Write an assembly code for the above algorithm and test it. Assume M is a 16-bit word. b. Use your code as a function in a program to convert a 16-bit unsigned binary word into a BCD number.Explanation / Answer
DATA SEGMENT BIN DW 01A9H BCD DB 2 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV AX,BIN MOV CL,64H DIV CL MOV BCD+1,AL MOV AL,AH MOV AH,00H MOV CL,0AH DIV CL MOV CL,04 ROR AL,CL ADD AL,AH MOV AH,4CH INT 21H CODE ENDS END START
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.