Two decimal operations indicated by non-compressed BCD code

xiaoxiao2021-03-06  105

X * Y / t stores the results in U, U 1, U 2, U 3Data segment x dup (?) y DUP (?) T DB 1 DUP (?) U DB 1 DUP (?) Z DW 2 DUP (?) I DW 2 DUP (?) J DW 2 DUP (?) K DB 1 DUP (?) M DB 1 DUP (?) N DB 1 DUP (?) Data Endscode Segment Assume Cs : Code, DS: DataStart: MOV AX, DATA MOV DS, AX MOV X, 0908H MOV Y, 0302H MOV T, 06H MOV CX, X MOV DX, Y MoV Al, Cl MoV BL, DL Mul BL; X First Multiplying results AAM MOV Z, AX; empty out AX MOV Al, CH MUL BL AAM MOV BX, Z MOV BL, BH MOV BH, 0 Add Ax, BX AAA; *********** ********* MOV I, AX MOV Al, DH MOV BL, CL Mul BL; X Second Bit Multiplied Result AAM MOV BX, I Add Ax, BX AAA MOV I, AX; *** **************************** MOV AL, CH MOV BL, DH MUL BL; X The third multiplication result AAM MOV BX, I MOV BL, BH MOV BH, 0 Add Ax, BX AAA MOV J, AX; *************; division MOV Al, AH MOV AH, 0 AAD DIV T MOV K, Al MOV BH, AH MOV AX, J MOV AH, BH AAD Div T MOV U, Al; Save Result 2 MOV BH, AH MOV AX, I MOV AH, BH AAD Div T MOV N, Al; MOV BH, AH MOV AX AH, BH AAD DIV T MOV M, Al Mov Al, M Mov DS: [0], Al Mov Al, N MOV DS: [1], Al Mov Al, U MOV DS: [2], Al M OV Al, K Mov DS: [3], Al Mov Ah, 4ch Int 21h Code endsend Start

Algorithm specific:

1. Among them, the algorithm of the first topic is completely, the basic idea of ​​the algorithm is this: We can easily get results for a non-compressed BCD code, and for two BCD code, we It can be regarded as a combination of four steps, analog multiplication calculation process: (The variable used is not the variable of the program)

1. Adjust the product results of a bit with AAM, then store the result into a number i, standby

2. The bit bit of the multiplier and the multiplicated high position will be multiplied by AAM, deposit J, call up the high 8 bits of I, deposit 8 bits of the register, 8 digits of the register that it is transferred Falling 0, then adds to the AAA to add to J.

3. Take the high position of the multiplication and the low level of the multiplier, multiply, and also do AAM adjustments, deposit K, add J and K, and deposit K. Do AAA adjustment.

4. Multiply the high 8 bits of the multiplier, multiply the high level of the multiplier, do AAM adjustment, store M, and store K high 8 bits into the low 8 bits of the register, and the register of the register is 8 high 8 Position 0, then add the ADD to the AAA adjustment, and the result is stored in M. At this point, we can know that the low 8 digits of I and K are the bit and ten positions of the result, while M saved is a hundred and thousands. The above is the multiplication algorithm, the following is division, the same reason, we use the simulation method:

1. Take the lower 8-bit value of M, and T (divisor) as a division of AAD adjustment, and the result is stored in a variable U, and the remainder is incorporated into the next operation.

2. Then store the al. Perform calculation, make AAD adjustment. The value is stored v, the remainder is incorporated into the next operation.

3. Then stocks Al from the lower 8 bits from K. Perform AAD adjustment operation. The value is stored in W, and the remainder is incorporated into the next operation.

4. Then stores Al. Perform AAD adjustment operation. The value is stored in X. Get a set of non-compressed BCDs composed of UVWX

转载请注明原文地址:https://www.9cbs.com/read-103930.html

New Post(0)