first commit

This commit is contained in:
2025-05-27 16:03:52 +08:00
commit 2d22d07f60
223 changed files with 5842 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,55 @@
DATA SEGMENT
CHAR DB 'A'
HINT1 DB 'Please enter a string: $'
HINT2 DB 10, 27H, 'A', 27H, ' occured time: $'
TIMES DB 0
MAXLEN DB 100
LEN DB 0
TABLE DB 100 DUP (0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AH, 9
MOV DX, OFFSET HINT1
INT 21H
LEA DX, MAXLEN
MOV AH, 0AH
INT 21H
CALL CNT
MOV AH, 9
MOV DX, OFFSET HINT2
INT 21H
MOV AL, TIMES
ADD AL, '0'
MOV DL, AL
MOV AH, 02
INT 21H
MOV AH,4CH
INT 21H
CNT PROC NEAR
MOV CX, 0
MOV CL, LEN
MOV SI, -1
MOV AL, CHAR
LP:
INC SI
CMP AL, TABLE[SI]
JNZ BACK
INC TIMES
BACK:
LOOP LP
RET
CNT ENDP
CODE ENDS
END START

View File

@@ -0,0 +1,105 @@
<mxfile host="Electron" modified="2023-04-11T14:21:32.543Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.1.2 Chrome/106.0.5249.199 Electron/21.4.3 Safari/537.36" etag="QNq7u-1bCWMLLsHMlqsS" version="21.1.2" type="device">
<diagram name="第 1 页" id="Hp0mWjxMjnIu5b5PPHpT">
<mxGraphModel dx="1098" dy="820" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="Hisepnijn4ny8SH6L1L8-29" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-1" target="Hisepnijn4ny8SH6L1L8-2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-1" value="程序开始" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="320" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-2" target="Hisepnijn4ny8SH6L1L8-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-2" value="载入数据段" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-31" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-3" target="Hisepnijn4ny8SH6L1L8-4">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-3" value="输出提示信息" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-44" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-4" target="Hisepnijn4ny8SH6L1L8-37">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-4" value="读取字符串" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-48" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-6" target="Hisepnijn4ny8SH6L1L8-17">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-6" value="将字符串当前位数加1" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-11" value="N" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-10" target="Hisepnijn4ny8SH6L1L8-6">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-46" value="Y" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-10" target="Hisepnijn4ny8SH6L1L8-37">
<mxGeometry x="-0.8824" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-10" value="循环次数是否用尽?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="640" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-19" value="Y" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-17" target="Hisepnijn4ny8SH6L1L8-20">
<mxGeometry relative="1" as="geometry">
<mxPoint x="440" y="740" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-49" value="N" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-17" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry x="-0.9167" relative="1" as="geometry">
<Array as="points">
<mxPoint x="340" y="800" />
<mxPoint x="80" y="800" />
<mxPoint x="80" y="660" />
</Array>
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-17" value="字符串的当前位与指定字符比较是否一样" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-50" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-20" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="500" y="800" />
<mxPoint x="80" y="800" />
<mxPoint x="80" y="660" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-20" value="结果加1" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-35" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-25" target="Hisepnijn4ny8SH6L1L8-27">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-25" value="输出答案" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="480" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-27" value="程序结束" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="560" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-42" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-28" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-28" value="指定循环次数为字符串长度" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="560" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-45" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-37" target="Hisepnijn4ny8SH6L1L8-28">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-47" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-37" target="Hisepnijn4ny8SH6L1L8-25">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-37" value="调用CNT子程序" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="200" y="480" width="120" height="40" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

View File

@@ -0,0 +1,105 @@
<mxfile host="Electron" modified="2023-04-11T14:22:21.464Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.1.2 Chrome/106.0.5249.199 Electron/21.4.3 Safari/537.36" etag="kXFsj5GcRiazvZ2mTRHP" version="21.1.2" type="device">
<diagram name="第 1 页" id="Hp0mWjxMjnIu5b5PPHpT">
<mxGraphModel dx="1098" dy="820" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="Hisepnijn4ny8SH6L1L8-29" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-1" target="Hisepnijn4ny8SH6L1L8-2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-1" value="程序开始" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="320" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-2" target="Hisepnijn4ny8SH6L1L8-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-2" value="载入数据段" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-31" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-3" target="Hisepnijn4ny8SH6L1L8-4">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-3" value="输出提示信息" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-44" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-4" target="Hisepnijn4ny8SH6L1L8-37">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-4" value="读取字符串" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-48" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-6" target="Hisepnijn4ny8SH6L1L8-17">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-6" value="将字符串当前位数加1" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-11" value="N" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-10" target="Hisepnijn4ny8SH6L1L8-6">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-46" value="Y" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-10" target="Hisepnijn4ny8SH6L1L8-37">
<mxGeometry x="-0.8824" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-10" value="循环次数是否用尽?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="640" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-19" value="Y" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-17" target="Hisepnijn4ny8SH6L1L8-20">
<mxGeometry relative="1" as="geometry">
<mxPoint x="440" y="740" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-49" value="N" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-17" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry x="-0.9167" relative="1" as="geometry">
<Array as="points">
<mxPoint x="340" y="800" />
<mxPoint x="80" y="800" />
<mxPoint x="80" y="660" />
</Array>
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-17" value="字符串的当前位与指定字符比较是否一样" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-50" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-20" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="500" y="800" />
<mxPoint x="80" y="800" />
<mxPoint x="80" y="660" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-20" value="结果加1" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-35" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-25" target="Hisepnijn4ny8SH6L1L8-27">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-25" value="输出答案" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="360" y="480" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-27" value="程序结束" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="360" y="560" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-42" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-28" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-28" value="指定循环次数为字符串长度" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="560" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-45" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-37" target="Hisepnijn4ny8SH6L1L8-28">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-47" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-37" target="Hisepnijn4ny8SH6L1L8-25">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-37" value="调用CNT子程序" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="200" y="480" width="120" height="40" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
Lab/Lab2/material/1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
Lab/Lab2/material/2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@@ -0,0 +1,155 @@
![cover](cover.png)
# 一、实验目的
1. 了解汇编语言子程序的概念。
2. 掌握汇编语言子程序的定义、调用和返回。
3. 掌握设计汇编语言子程序及过程的基本方法。
4. 清楚调用指令CALL及返回指令RET执行时堆栈内容及指针的变化。
5. 掌握子程序和主程序间的参数传递方法。
# 二、实验内容
试编写一个有主程序和子程序结构的程序模块。
主程序要求从键盘接收一串字符并存于字节数组TABLE中显示字符CHAR出现的次数。
子程序在以TABLE为首地址的字节数组中查找CHAR统计出现的次数。
# 三、流程图
![graph](graph.drawio.svg)
# 四、实验过程与分析
![1](1.png)
将源代码放入MASM路径下编译。
没有警告和报错。
![2](2.png)
LINK链接程序。
![3](3.png)
出现提示信息。
![4](4.png)
输入字符串,按下回车。
程序打印出指定字符“**A**”出现的次数。
# 五、实验总结
在本实验中,我了解了汇编语言子程序的概念,掌握了汇编语言子程序的定义、调用和返回,以及设计汇编语言子程序及过程的基本方法。
# 六、思考题
> 子程序和主程序之间的参数传递是通过什么方式实现的?
通常情况下,主、子程序之间传递参数可以通过以下四种方式实现:
1. 寄存器传送参数
2. 存储单元传送参数
3. 堆栈传送参数或参数地址
4. 多模块之间的参数传递
**本实验程序使用寄存器传递参数。**
> 在DEBUG环境下观察执行CALL指令时CS、IP寄存器是否变化。
![5](5.png)
执行CALL指令的时候
- 如果是段内近调用不会改变CS但是IP会改变。本实验程序是这种情况如图所示可见CS不变IP变
- 如果是远调用CS和IP都会改变。
> 在DEBUG环境下观察执行CALL、RET时堆栈的变化。
![6](6.png)
![7](7.png)
由执行CALL前后SP值的变化和对应地址记录的值可知由于是近调用将IP压入栈中记录SP记录了要返回的IP=0017H。
由于DEBUG环境无法输入字符串很难观测RET指令执行时的情况。实际上RET时SP会回退原来CS和IP的值会退栈然后赋值给当前的CS和IP。
# 源代码附录
```assembly
DATA SEGMENT
CHAR DB 'A'
HINT1 DB 'Please enter a string: $'
HINT2 DB 10, 27H, 'A', 27H, ' occured time: $'
TIMES DB 0
MAXLEN DB 100
LEN DB 0
TABLE DB 100 DUP (0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV DX, OFFSET HINT1 ; 将HINT1的偏移地址赋给DX准备输出
MOV AH, 9 ; 输出
INT 21H
LEA DX, MAXLEN ; 0AH功能会获取DS:[DX](已定义为MAXLEN)作为输入缓冲区最大容量
MOV AH, 0AH ; 调用0AH功能将输入的字符串长度存入DS:[DX+1](已定义为LEN)
INT 21H ; 将字符串存入从DS:DX+2开始的空间(已定义为TABLE)
CALL CNT ; 统计字符“A”的数量结果在TIMES中
MOV DX, OFFSET HINT2 ; 将HINT2的偏移地址赋给DX准备输出
MOV AH, 9 ; 输出
INT 21H
MOV AL, TIMES
ADD AL, '0' ; TIMES += '0' (将数字信息转换成字符)
MOV DL, AL
MOV AH, 02H ; 显示单个字符
INT 21H
MOV AH,4CH
INT 21H
CNT PROC NEAR
MOV CX, 0
MOV CL, LEN
MOV SI, -1 ; SI是遍历TABLE的下标
MOV AL, CHAR ; 要比较的字符移到AL中(CMP不能比较两个内存单元)
LP:
INC SI
CMP AL, TABLE[SI]
JNE BACK ; 不相等则跳过INC TIMES重新循环
INC TIMES
BACK:
LOOP LP ; LOOP先将CX -= 1然后判断是否为0为0就退出循环
RET
CNT ENDP
CODE ENDS
END START
```

Binary file not shown.

BIN
Lab/Lab2/material/3.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

BIN
Lab/Lab2/material/4.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

BIN
Lab/Lab2/material/5.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
Lab/Lab2/material/6.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
Lab/Lab2/material/7.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

56
Lab/Lab2/material/code.asm Executable file
View File

@@ -0,0 +1,56 @@
DATA SEGMENT
CHAR DB 'A'
HINT1 DB 'Please enter a string: $'
HINT2 DB 10, 27H, 'A', 27H, ' occured time: $'
TIMES DB 0
MAXLEN DB 100
LEN DB 0
TABLE DB 100 DUP (0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV DX, OFFSET HINT1 ; 将HINT1的偏移地址赋给DX准备输出
MOV AH, 9 ; 输出
INT 21H
LEA DX, MAXLEN ; 0AH功能会获取DS:[DX](已定义为MAXLEN)作为输入缓冲区最大容量
MOV AH, 0AH ; 调用0AH功能将输入的字符串长度存入DS:[DX+1](已定义为LEN)
INT 21H ; 将字符串存入从DS:DX+2开始的空间(已定义为TABLE)
CALL CNT ; 统计字符“A”的数量结果在TIMES中
MOV DX, OFFSET HINT2 ; 将HINT2的偏移地址赋给DX准备输出
MOV AH, 9 ; 输出
INT 21H
MOV AL, TIMES
ADD AL, '0' ; TIMES += '0' (将数字信息转换成字符)
MOV DL, AL
MOV AH, 02H ; 显示单个字符
INT 21H
MOV AH,4CH
INT 21H
CNT PROC NEAR
MOV CX, 0
MOV CL, LEN
MOV SI, -1 ; SI是遍历TABLE的下标
MOV AL, CHAR ; 要比较的字符移到AL中(CMP不能比较两个内存单元)
LP:
INC SI
CMP AL, TABLE[SI]
JNE BACK ; 不相等则跳过INC TIMES重新循环
INC TIMES
BACK:
LOOP LP ; LOOP先将CX -= 1然后判断是否为0为0就退出循环
RET
CNT ENDP
CODE ENDS
END START

BIN
Lab/Lab2/material/cover.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

105
Lab/Lab2/material/graph.drawio Executable file
View File

@@ -0,0 +1,105 @@
<mxfile host="Electron" modified="2023-04-11T14:22:18.173Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.1.2 Chrome/106.0.5249.199 Electron/21.4.3 Safari/537.36" etag="ppF0kxKw4kt9IrtH2h0O" version="21.1.2" type="device">
<diagram name="第 1 页" id="Hp0mWjxMjnIu5b5PPHpT">
<mxGraphModel dx="1098" dy="820" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="Hisepnijn4ny8SH6L1L8-29" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-1" target="Hisepnijn4ny8SH6L1L8-2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-1" value="程序开始" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="320" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-2" target="Hisepnijn4ny8SH6L1L8-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-2" value="载入数据段" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-31" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-3" target="Hisepnijn4ny8SH6L1L8-4">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-3" value="输出提示信息" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-44" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-4" target="Hisepnijn4ny8SH6L1L8-37">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-4" value="读取字符串" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="400" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-48" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-6" target="Hisepnijn4ny8SH6L1L8-17">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-6" value="将字符串当前位数加1" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-11" value="N" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-10" target="Hisepnijn4ny8SH6L1L8-6">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-46" value="Y" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-10" target="Hisepnijn4ny8SH6L1L8-37">
<mxGeometry x="-0.8824" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-10" value="循环次数是否用尽?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="640" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-19" value="Y" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-17" target="Hisepnijn4ny8SH6L1L8-20">
<mxGeometry relative="1" as="geometry">
<mxPoint x="440" y="740" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-49" value="N" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-17" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry x="-0.9167" relative="1" as="geometry">
<Array as="points">
<mxPoint x="340" y="800" />
<mxPoint x="80" y="800" />
<mxPoint x="80" y="660" />
</Array>
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-17" value="字符串的当前位与指定字符比较是否一样" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="280" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-50" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-20" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="500" y="800" />
<mxPoint x="80" y="800" />
<mxPoint x="80" y="660" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-20" value="结果加1" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="440" y="720" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-35" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-25" target="Hisepnijn4ny8SH6L1L8-27">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-25" value="输出答案" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="360" y="480" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-27" value="程序结束" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="360" y="560" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-42" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-28" target="Hisepnijn4ny8SH6L1L8-10">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-28" value="指定循环次数为字符串长度" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="120" y="560" width="120" height="40" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-45" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-37" target="Hisepnijn4ny8SH6L1L8-28">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-47" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="Hisepnijn4ny8SH6L1L8-37" target="Hisepnijn4ny8SH6L1L8-25">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="Hisepnijn4ny8SH6L1L8-37" value="调用CNT子程序" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="200" y="480" width="120" height="40" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 22 KiB

BIN
Lab/Lab2/实验2 查找字符.doc Executable file

Binary file not shown.