当前位置: 代码迷 >> 汇编语言 >> dos下常驻内存时钟程序解决方法
  详细解决方案

dos下常驻内存时钟程序解决方法

热度:822   发布时间:2013-02-26 00:00:00.0
dos下常驻内存时钟程序
no stack segment ,后来我想改为com文件,但仍是LINK时有no stack segment 问题,你帮我看看要改哪里好吗?
原文件:
 
DATA SEGMENT
  BUFF DB 12 DUP(?)  
  CRLF DB 0DH,0AH,24H  
  TSTR DB "00:00:00"
   
  PROG_LEN EQU 1000 
DATA ENDS

CODE SEGMENT
  ASSUME CS:CODE,DS:DATA
MAIN PROC FAR
   
  MOV AX,DATA
  MOV DS,AX
  LEA DX,TIME
  MOV AX,SEG TIME
  MOV DS,AX
  MOV AL,1ch
  MOV AH,25H
  INT 21H
   
   
  MOV AH,31H
  MOV AL,0
  MOV DX,((PROG_LEN+15)/16)+16
  INT 21H  
   
MAIN ENDP
PRINT PROC NEAR
 MOV AX,DATA
 MOV DS,AX
 MOV AX, 0B800H
 MOV ES,AX
 LEA SI,TSTR
 MOV DI,0
 
 MOV CX,8
 CLD
 REP MOVSB
 
 
 ret
PRINT endp

TIME PROC far
 push ax
 push bx
 push cx
 push dx
 push si
 push di
 push bp
 push ds
 push es
 

 MOV AH,0
 MOV DI,0
M1: MOV AL,AH
 OUT 70H,AL
  IN AL,71H
  MOV BUFF[DI],AL
  INC DI 
  ADD AH,2
  CMP AH,6
  JNE M1
   
   
  MOV DI,0
  MOV BX,10
  XOR CX,CX 
  XOR AX,AX
  MOV BP,7
   
  MOV AL,BUFF[DI]
  M2: XOR DX,DX
   
  DIV BX
  PUSH DX
  CMP AX,0
  JNE M2
   
  MOV SI,BP
  M3: POP DX
  ADD DX,30H
  MOV TSTR[SI],DL
  DEC SI
  LOOP M3
  INC DI
  SUB BP,3
  CMP DI,3
  pop es
  pop ds
 pop bp
 pop di
 pop si
 pop dx
 pop cx
 pop bx
 pop ax
  
   
 iret
TIME endp

CODE ENDS
  END MAIN


------解决方案--------------------------------------------------------
Ctrl+F8启动
Assembly code
ASSUME CS:CSEG,DS:CSEGHEAD=1AHTAIL=1CHBUFHEAD=1EHBUFTAIL=3EHKEY=6500HCR=0DHLF=0AHCSEG SEGMENTOLD09H  DW 2 DUP(0)DATE    DB 6 DUP(0)ADR     DB 9,8,7,4,2,0BUF     DB 2 DUP(0),' ',0CRLF    DB CR,LF,0NEW09H: PUSHF        CALL DWORD PTR CS:OLD09H        STI        PUSH DS        PUSH ES        PUSH AX        PUSH BX        PUSH CX        PUSH DX        PUSH SI        PUSH DI        MOV AX,40H        MOV DS,AX        MOV BX,DS:[HEAD]        CMP BX,DS:[TAIL]        JZ L1        MOV AX,DS:[BX]        CMP AX,KEY        JZ L2     L1:POP DI        POP SI        POP DX        POP CX        POP BX        POP AX        POP ES        POP DS        IRET     L2:ADD BX,2        CMP BX,BUFTAIL        JNZ L3        MOV BX,BUFHEAD     L3:MOV DS:[HEAD],BX        MOV AX,CS        MOV DS,AX        MOV ES,AX        MOV CX,6        LEA SI,ADR        LEA DI,DATE        CLD     L4:LODSB        OUT 70H,AL        JMP $+2        IN AL,71H        STOSB        LOOP L4        MOV CX,4        MOV DI,6        LEA SI,DATE        CLD     L5:LODSB        MOV AH,AL        AND AL,0FH        ADD AL,30H        SHR AH,CL        ADD AH,30H        XCHG AH,AL        MOV WORD PTR BUF,AX        LEA BX,BUF        MOV AH,0EH     L6:MOV AL,[BX]        INT 10H        INC BX        OR BYTE PTR [BX],0        JNZ L6        DEC DI        JNZ L5        LEA BX,CRLF        MOV AH,0EH     L7:MOV AL,[BX]        INT 10H        INC BX        OR BYTE PTR [BX],0        JNZ L7        JMP L1START : NOP        MOV AX,CS        MOV DS,AX        MOV AX,3509H        INT 21H        MOV OLD09H,BX        MOV OLD09H+2,ES        LEA DX,NEW09H        MOV AX,2509H        INT 21H        MOV DX,OFFSET START+15        MOV CX,4        SHR DX,CL        ADD DX,10H        MOV AX,3100H        INT 21HCSEG ENDSEND START
  相关解决方案