汇编语言小程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

16进制转化为10进制STACK SEGMENT STACK'STACK'

DW100H DUP(?)

TOP LABEL WORD

STACK ENDS

DATA SEGMENT

KEYBUFFER DB100

;DB ?

;DB 100 DUP(?)

DECIMAL DB 5 DUP(?)

STRING1 DB'PLEASE INPUT DECIMAL DATA:$' DATA ENDS

CODE SEGMENT

ASSUME CS:CODE,DS:DATA,ES:DATA,CS:STACK START:

MOV AX,DATA

MOV DS,AX

MOV ES,AX

MOV SS,AX

LEA SP,TOP

LEA DX,STRING1

MOV AH,09H

INT 21H

MOV AH,0AH

LEA DX,KEYBUFFER

;MOV AX,23456

INT 21H

;LEA SI,KEYBUFFER

MOV AX,DX

LEA DI,DECIMAL

CALL DISPAX

MOV AH,4CH

MOV AL,0

INT 21H

DISPAX PROC NEAR

PUSH AX

PUSH BX

PUSH CX

PUSH DX

PUSH DI

LEA DI,DECIMAL

CALL TRANS16TO10

MOV CX,5

LEA DI,DECIMAL+4

MOV AH,2

DISPAXD:

MOV DL,[DI]

ADD DL,30H

DEC DI

INT 21H

LOOP DISPAXD

POP DI

POP DX

POP CX

POP BX

POP AX

RET

DISPAX ENDP

TRANS16TO10 PROC NEAR PUSH AX

PUSH BX

PUSH CX

PUSH DX

PUSH DI

MOV BX,10

MOV CX,5

LOOP1:

XOR DX,DX

DIV BX

MOV[DI],DX

INC DI

LOOP LOOP1

LEA DX,DECIMAL

MOV AH,09H

INT 21H

POP DI

POP DX

POP CX

POP BX

POP AX

RET

TRANS16TO10 ENDP

CODE ENDS

END START

10进制转化为16进制STACK SEGMENT STACK'STACK'

DW100H DUP(?)

TOP LABEL WORD

STACK ENDS

DATA SEGMENT

KEYBUFFER DB100

DB?

DB 100 DUP(?)

STRING1 DB'please input decimal data: $' DATA ENDS

CODE SEGMENT

ASSUME CS:CODE,DS:DATA,ES:DATA,SS:STACK START:

MOV AX,DATA

MOV DS,AX

MOV ES,AX

MOV AX,STACK

MOV SS,AX

LEA SP,TOP

LEA DX,STRING1

MOV AH,09H

INT 21H

MOV AH,0AH

LEA DX,KEYBUFFER

INT 21H

LEA SI,KEYBUFFER+1

CALL TRANS10TO16

CALL DISPCR

CALL DISPAX

CALL DISPCR

MOV AX,BX

CALL DISPAX

MOV AH,4CH

MOV AL,0

INT 21H

DISPAL PROC NEAR

PUSH AX

PUSH CX

PUSH DX

PUSH AX

MOV CL,4

SHR AL,CL

CALL CHANG

MOV AH,02

MOV DL,AL

INT 21H

POP AX

AND AL,0FH

CALL CHANG

MOV AH,02

MOV DL,AL

INT 21H

POP DX

POP CX

POP AX

RET

DISPAL ENDP CHANG PROC NEAR CMP AL,10

JNGE CHANG1

ADD AL,7 CHANG1:

ADD AL,30H

RET

CHANG ENDP DISPAX PROC NEAR XCHG AL,AH

CALL DISPAL

XCHG AH,AL

CALL DISPAL

RET

DISPAX ENDP DISPCR PROC NEAR PUSH AX

PUSH DX

MOV AH,2

MOV DL,0AH

INT 21H

相关文档
最新文档