• 过去的汇编代码


    1.阶乘

    SSEG SEGMENT STACK
       STK DB 20 DUP(0)
    SSEG ENDS
    
    CSEG SEGMENT
      ASSUME SS:SSEG
      ASSUME CS:CSEG
    ;入口参数ax,
    ;出口参数ax
    F PROC
      AND AX,AX
      JNZ  GO
       MOV AX,1
       RET
      GO:PUSH AX
       DEC AX
       CALL F
       POP BX
       MUL BX
       RET
    F ENDP
    ;输入函数;
    ;出口al
    INPUT PROC
      MOV AH,01
      INT 21H
      RET
    INPUT ENDP
    CHAR PROC 
      MOV CL,12
      SHR BX,CL
      MOV DL,BL
      CMP DL,9
      JBE  NO_ADD
      SUB  DL,10
      ADD  DL,'A'
      SUB DL,'0'
     NO_ADD: ADD DL,'0'
      MOV AH,02H
      INT 21H
      RET
    CHAR ENDP
    ;显示ax
    SHOW PROC 
       MOV BX,AX
       PUSH BX
       CALL CHAR
       POP BX
       PUSH BX
       MOV CL,4
       SHL BX,CL
       CALL CHAR
       POP BX
       PUSH BX
       MOV CL,8
       SHL BX,CL
       CALL CHAR
       POP BX
       MOV CL,12
       SHL BX,CL
       CALL CHAR
       RET
    SHOW ENDP 
      
    MAIN:MOV AX,SSEG
        MOV SS,AX
        MOV SP,SIZE STK
       
       CALL INPUT
       SUB AL,'0'
       MOV AH,0
       CALL F
       PUSH AX
       MOV DL,10
       MOV AH,02
       INT 21H
       POP AX
       CALL SHOW
      MOV AH,4CH
      INT 21H
    CSEG ENDS
      END MAIN
    

    2.21H的02功能会影响AL

    CSEG SEGMENT
    ASSUME CS:CSEG
    MAIN:
     MOV AX,3132H
     MOV DL,AH
     MOV AH,2
     INT 21H
     MOV DL,AL
     INT 21H
     MOV AX,4C00H
     INT 21H
    CSEG ENDS
     END MAIN
    

    3.多字节乘法思路:先用高级语言来描述思路,再用低级语言去实现

    #include
    using namespace std;
    int main(){
    	int a[3] = { 1, 2, 3 }, b[3] = { 4, 5, 6 }, c[7] = {0};
    	int i, j,k;
    	for (i = 0; i < 3; i++)
    		for (j = 0; j < 3; j++){
    		c[i + j] += a[i] * b[j];
    		for (k = i + j; c[k] > 10; k++){
    			c[k + 1] += c[k] / 10;
    			c[k] %= 10;
    		}
    		}
    	for (i = 7; i >0; i--)
    		cout << c[i] << " ";
    	cout << endl;
    	return 0;
    }
    

    4.打印九九乘法表

    SSEG SEGMENT STACK
        STK  DB 20 DUP(0)
    SSEG ENDS
    CSEG SEGMENT
           ASSUME  CS:CSEG
           ASSUME SS:SSEG
    CHAR PROC
        PUSH AX
        MOV AH,02H
        INT 21H
         POP AX
        RET
    CHAR  ENDP
    DISPLAY PROC
         ADD DL,'0'
         CALL CHAR
         RET
    DISPLAY ENDP
    SHOW  PROC
          PUSH AX
          MOV DL,10
          DIV   DL
          AND AL,AL
          JZ    ONE
          MOV DL,AL
          CALL DISPLAY
    ONE:  MOV DL,AH
          CALL DISPLAY
          POP AX
         RET
    SHOW ENDP
    MAIN:MOV  AX,SSEG
          MOV SS,AX
         MOV SP,SIZE  STK
         MOV AH,1
    OUTER:CMP AH,9
           JA   OVER
                  MOV AL,1
    INNER :CMP AL,AH
                 JA  INIT
                MOV DL,AH
                 CALL DISPLAY
                 MOV DL,'*'
                 CALL CHAR
                 MOV  DL,AL
                 CALL DISPLAY
                 MOV  DL,'='
                 CALL CHAR
                  PUSH AX
                  MUL AH
                  CALL SHOW 
                  POP AX
                 INC AL
                 MOV DL ,' '
                 CALL CHAR
                 JMP INNER
    INIT:MOV  DL,10
           CALL CHAR
             INC AH
             JMP OUTER
    OVER:MOV AX,4C00H
           INT 21H
    CSEG ENDS
        END MAIN
    
    

    5.画棋盘

    SSEG SEGMENT STACK
     STK DB 20 DUP(0)
    SSEG ENDS
    CSEG SEGMENT
      ASSUME CS:CSEG
      ASSUME SS:SSEG
    POINT PROC
      PUSH AX
      MOV AX,0C12H
      INT 10H
      POP AX
      RET
    POINT ENDP
    LINE_H PROC
      PUSH CX
      MOV CX,9
    AGAIN_0:INC CX 
      CMP CX,190
      JA OUT_0
      CALL  POINT
      JMP AGAIN_0
    OUT_0:  POP CX 
      RET  
    LINE_H ENDP
    LINE_V PROC
      PUSH DX
      MOV DX,9
    AGAIN_1:INC DX
       CMP DX,190
       JA OUT_1
       CALL POINT
       JMP AGAIN_1
    OUT_1:POP DX
      RET
    LINE_V ENDP
    MAIN:MOV AX,SSEG
        MOV SS,AX
         MOV AH,0
        MOV AL,04H
        INT 10H
        MOV BH,0
        MOV CX,100
        MOV DX,100
    AGAIN_100:INT 10H
        LOOP AGAIN_100    
        CALL POINT
        MOV DX,0
    AGAIN_2:ADD DX,10
        CMP DX,190
        JA  OUT_2
        CALL LINE_H
        JMP AGAIN_2
    OUT_2:MOV CX,0
    AGAIN_3:ADD CX,10
       CMP CX,190
        JA OUT_3
        CALL LINE_V
        JMP AGAIN_3
    OUT_3:MOV AH,01
        INT 21H
        MOV AH,4CH
       INT 21H
    CSEG ENDS
        END MAIN
    

    6.文件复制

                           DSEG SEGMENT
      F1 DB 20,20 DUP(0)
      F2 DB 20,20 DUP(0)
      N1 DW 0
      N2 DW 0
      B  DB 100 DUP(0)
    DSEG ENDS
    CSEG SEGMENT
      ASSUME DS:DSEG
      ASSUME CS:CSEG
    IN_NAME PROC
      PUSH AX
      PUSH BX
      MOV AH,0AH
      INT 21H
      MOV BX,DX
      INC BX
      MOV SI,BX
      INC SI
      MOV AL,[BX]
      MOV AH,0
      ADD SI,AX
      MOV AL,0
      MOV [SI],AL
      POP BX
      POP AX
      RET
    IN_NAME ENDP
    OPEN PROC
      MOV AX,3D02H
      INT 21H
      MOV [SI],AX
      RET
    OPEN ENDP
    MAIN:MOV AX,DSEG
      MOV          DS,AX
      LEA DX,F1
      CALL IN_NAME   
      MOV AH,02H
      MOV DL,10
      INT 21H
      MOV DL,13
      INT 21H
      LEA DX,F2
      CALL IN_NAME
      LEA DX,F1
      ADD DX,2
      LEA SI,N1
      CALL OPEN
      LEA DX,F2
      ADD DX,2
      LEA SI,N2
      CALL OPEN
      MOV BX,N1
      LEA DX,B
      MOV AH,3FH
      MOV CX,1
    AGAIN:  PUSH AX
      PUSH BX
      PUSH CX
      PUSH DX
      INT 21H
      MOV AL,B
      CMP AL,'#'
      JZ OVER
      MOV AH,40H
      MOV CX,1
      LEA DX,B
      MOV BX,N2
      INT 21H
      POP DX
      POP CX
      POP BX
      POP AX
      JMP AGAIN
     OVER:MOV BX,N1
      MOV AH,3EH
      INT 21H
      MOV BX,N2
      INT 21H 
      MOV AX,4C00H
     INT 21H
    CSEG ENDS
      END MAIN
    

    7.向有序表中插入一个数据

    DSEG SEGMENT 
     A DB 1,2,3,5,6,7,0
     ASIZE DB 6
     N DB 4
    DSEG ENDS
    SSEG SEGMENT STACK
     STK DB 20 DUP(0)
    SSEG ENDS
    CSEG SEGMENT
    ASSUME SS:SSEG
    ASSUME CS:CSEG
    ASSUME DS:DSEG
    ASSUME ES:DSEG
    MAIN:MOV AX,DSEG
     MOV DS,AX
     MOV ES,AX
     MOV SP ,SIZE STK
     MOV AX,SSEG
     MOV SS,AX
     
     LEA SI,A
     LEA BX,A
     ADD BL,ASIZE
     DEC BX
    AGAIN0:CMP SI,BX
     JA OVER0
     MOV AL,[SI]
     CMP N,AL
     JA GO
     JMP OVER0
    GO:INC SI
     JMP AGAIN0
    OVER0:MOV AL,ASIZE
     INC AL
     MOV ASIZE,AL
    AGAIN1:
     CMP BX,SI
     JL OVER1
     MOV AL,[BX]
     MOV [BX+1],AL
     DEC BX
     JMP AGAIN1
    OVER1:
     MOV AL,N
     MOV [SI],AL
     MOV AX,4C00H
     INT 21H
    CSEG ENDS
     END MAIN

    回顾大一大二,走了不少弯路。当年我一心学习GUI,想编出可视化程序,可是我依旧在dos黑框框下玩了一年半。
    学习MFC,API耽误了许多时间。老师们也不提示一下该学什么,我也不知道用好网络资源。
    有很多想编但是没编成的程序,如今看来只觉当年图样图西木破。
    但是,我一直在探索,在进步,对许多方面有所涉猎,虽然忘记许多,却依旧有一种淡淡的知道感。
    大学光阴就这么悄悄地溜走了。
    该删的就删了吧,该忘的就忘了吧,时光如同大河,浩浩荡荡,每一步有每一步的风景,不必留恋过去。
    现在有的将来还会有。
  • 相关阅读:
    【HTML】WebStorage
    【vue.js】vue项目使用Iconfont(阿里图标库)
    【CSS】水平居中和垂直居中
    【设计模式】责任链模式
    【设计模式】观察者模式
    【设计模式】策略模式
    【排序算法】(9)堆排序
    【排序算法】(5)基数排序
    【排序算法】(6)选择排序
    简单权限设计表
  • 原文地址:https://www.cnblogs.com/weiyinfu/p/5327789.html
Copyright © 2020-2023  润新知