Problem: Computes the number in the ffff:0006 unit multiplied by 3, and the result is stored in the DX.
Answer:
One: Analysis of ideas:
1. Whether the result of the operation will exceed the range that DX can store. The book in the ffff:0006 unit is a byte-type data, 8-bit, which ranges between 0 and 2 of eight parties, and the maximum is 2 of 8, or 255. Then the value after multiplying it with 3 is 255X3=765=02FDH. And the maximum value that DX can store is 2 of 16 square, namely 65535=0FFFFH, it is obvious that 02FDH is less than 0FFFFH. So the conclusion is that it can be stored in DX.
2. Multiply it by 3, equal to add it 3 times, you can consider using a loop. You can put the value of the ffff:0006 unit in AX first, but the data in ffff:0006 is 8-bit, and Ax is 16-bit. Therefore, the high-level ax should be zeroed out. Second, to Loop 3 times, put 3 into CX.
Two: source code writing:
Assume CS:CODESG CODESG segment//Put data in ffff:0006 unit into AX in MOV BX,0FFFFH mov ds,bx mov ax,[0006h]///next to put Ax in the high-clear 0 mov ah,0h// This puts the contents of the 0ffff:0006 into the AX//loop number 3 into CX in MOV cx,3h//first put 0 into DX in mov dx,0h//Loop 3 times S:add Dx,ax loop S//program normal return mov ax,4c00h int 21h CODESG ends End
Three: Compile the connection process as follows:
Run Masm.exe, and then enter the source code path
Microsoft (R) Macro assembler Version 5.00 Copyright (C) Microsoft Corp 1981-1985, 1987. All rights reserved. Source filename [. ASM]: c:/assembly/mycode.asm Object filename [mycode. OBJ]: Source listing [NUL. LST]: Cross-Reference [NUL. CRF]: 50428 + 450452 Bytes symbol space free 0 Warning Errors 0 Severe Errors
Run Link.exe input the obj file that needs to be connected
Microsoft (R) Overlay Linker Version 3.60 Copyright (C) Microsoft Corp 1983-1987. All rights reserved. Object Modules [. OBJ]: Mycode Run File [Mycode. EXE]: List File [NUL. MAP]: Libraries [. LIB]: link:warning l4021:no Stack Segment
Three: The debugging process is as follows
ax=0065 bx=ffff cx=0000 dx=0000 sp=fffe bp=0000 si=0000 di=0000 ds=ffff es=0100 ss=0100 CS=0100 IP=000A NV up EI PL NZ NA PO NC 0100:000a B90300 MOV CX, 00003h-t ax=0065 bx=ffff cx=0003 dx=0000 sp=fffe bp=0000 si=0000 di=0000 ds=ffff ES=0100 S s=0100 cs=0100 ip=000d NV up EI PL NZ NA PO NC 0100:000d BA0000 MOV DX, 00000h-t ax=0065 bx=ffff cx=0003 dx=0000 Sp=fffe bp=0000 si=0000 di=0000 ds=ffff es=0100 ss=0100 cs=0100 ip=0010 NV up EI PL NZ NA PO NC 0100:0010 03d0 ADD DX, Ax-t ax=00 BX=FFFF cx=0003 dx=0065 sp=fffe bp=0000 si=0000 di=0000 ds=ffff es=0100 ss=0100 cs=0100 IP=0012 NV up EI PL NZ NA PE NC 0100:0012 E2FC LOOP 010h -t AX=0065 BX=FFFF CX=0002 DX=0065 SP=FFFE BP=0000 SI=0000 DI=0000 DS=FFFF ES=0100 SS=0100 CS=01 XX ip=0010 NV up EI PL NZ NA PE NC 0100:0010 03d0 ADD DX, ax-t ax=0065 bx=ffff cx=0002 dx=00ca sp=fffe bp=0000 si=0000 DI =0000 ds=ffff es=0100 ss=0100 cs=0100 ip=0012 NV up EI PL NZ NA PE NC 0100:0012 e2fc LOOP 010h-t ax=0065 bx=ffff cx=0001 DX=00CA Sp=fffe bp=0000si=0000 di=0000 ds=ffff es=0100 ss=0100 cs=0100 ip=0010 NV up EI PL NZ NA PE NC 0100:0010 03d0 ADD DX, ax-t ax=0065 bx=ff FF cx=0001 dx=012f sp=fffe bp=0000 si=0000 di=0000 ds=ffff es=0100 ss=0100 cs=0100 ip=0012 NV up EI PL NZ NA PO NC 0100:00 12 E2FC LOOP 010h -t AX=0065 BX=FFFF CX=0000 DX=012F SP=FFFE BP=0000 SI=0000 DI=0000 DS=FFFF ES=0100 SS=0100 CS=0100 IP=00 + NV up EI PL NZ NA PO NC 0100:0014 b8004c MOV AX, 04c00h-t ax=4c00 bx=ffff cx=0000 dx=012f sp=fffe bp=0000 si=0000 di=0 DS=FFFF es=0100 ss=0100 cs=0100 ip=0017 NV up EI PL NZ NA PO NC 0100:0017 CD21 INT 021h-p ax=4c00 bx=ffff cx=0000 dx= 012F sp=fff8 bp=0000 si=0000 di=0000 ds=ffff es=0100 ss=0100 cs=f400 ip=0204 NV up DI PL NZ NA PO NC f400:0204 CF IRET
You can see that the result is 012fh from the process. If we want to skip the first few steps to jump directly to the loop out of execution, you can first see the loop out of the memory cell address should be how much, as in the case of cs:0010, you can use the instruction G 0010, when the ENTER key is pressed, the program will execute to add Dx,ax stop, Wait for us to start debugging. If you want the loop to run once, you can use the P command to achieve the goal. Of course, G 0014 can also be used to achieve the same purpose.