为什么这里非要加mov al,30h?

不穿格子衫的Frank 2016-11-02 08:30:23
DATAS SEGMENT
five db 5;此处输入数据段代码
DATAS ENDS

STACKS SEGMENT
db 128 dup (?);此处输入堆栈段代码
STACKS ENDS

CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov al,five
add al,3

add al,30h
mov dl,al
mov ah,2
int 21h
MOV AH,4CH
INT 21H
CODES ENDS
END START
...全文
646 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
uid123 2016-11-02
  • 打赏
  • 举报
回复
请参考MOV的八大用法
输入成绩,显示出学生的学号 成绩及名次DATAS SEGMENT GRADE DB 50 DUP (?) RANK DB 50 DUP (?) STR1 DB 'please input the mark of class:','$' str2 db 13,10,'$' str3 db 'Num mark rank','$' str4 db ' ','$' str5 db 'input the number of the class(00~99):','$' NUM dw ? DATAS ENDS STACKS SEGMENT ;此处输入堆栈段代码 STACKS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKS START: MOV AX,DATAS MOV DS,AX call total call input call bijiao call print MOV AH,4CH INT 21H input proc mov cx,num mov si,0 mov dx,offset str1 mov ah,9 int 21h call huanhang D1: mov ah,1 int 21h sub al,30h cbw push cx mov cx,10 mul cx add bx,ax mov ah,1 int 21h sub al,30h cbw add bx,ax mov ax,bx pop cx mov bx,offset grade mov [bx+si],ax inc si call huanhang loop d1 ret input endp huanhang proc mov dx,offset str2 mov ah,9 int 21h ret huanhang endp bijiao proc mov si,0 sub num,1 d0: mov dl,1 mov bx,0 mov al,grade[si] d3: cmp al,grade[bx] jl d4 jmp d2 d4: inc dl jmp d2 d2: inc bx cmp bx,num jng d3 mov rank[si],dl inc si cmp si,num jng d0 ret bijiao endp print proc mov dx,offset str3 mov ah,9 int 21h call huanhang mov si,0 n2: push si inc si mov ax,si mov dh,10 div dh mov bl,ah add al,30h mov ah,2 mov dl,al int 21h add bl,30h mov ah,2 mov dl,bl int 21h call kongge pop si push si mov al,grade[si] mov dh,10 cbw div dh mov bl,ah add al,30h mov ah,2 mov dl,al int 21h add bl,30h mov ah,2 mov dl,bl int 21h call kongge pop si mov al,rank[si] cbw mov dh,10 div dh mov bl,ah add al,30h mov ah,2 mov dl,al int 21h add bl,30h mov ah,2 mov dl,bl int 21h jmp n0 n0:
;name: ELECTRONIC CLOCK data segment mess1 db 'Press C or c to correct the time',0ah,0dh db 'Press R or r to SET the RING time',0ah,0dh db 'Press ESC button to exit',0ah,0dh,'$' tn db 'Please input the new time (hh:mm:ss):',0dh,0ah,'$' tM db 'Please input the RING time (hh:mm:SS):',0dh,0ah,'$' mess2 db 'Time is:',0ah,0dh,'$' t_buff db 40 ;在数据段开一段时间显示缓冲区 db ? db 40 dup (?) HOR1 DB 'S' MIN1 DB 'S' SEC1 DB 'S' hor db ? min db ? sec db ? fg db 0 data ends stack segment db 100 dup(?) stack ends code segment assume cs:code,ss:stack,ds:data ;确定各个逻辑段的类型 start: call clear ;调用清屏子程序 display: ;时间显示部分 mov ax,data mov ds,ax mov bx,offset t_buff ;送t_buff的偏移地址到BX mov ah,2ch ;调用DOS时间调用功能,功能号:2cH,小时,分钟,秒数分别保存在CH,CL,DH中 int 21h mov al,ch ;小时数设定 mov ah,0 call bctd ;调用进制转换子程序 CALL ASC ;---------------------------------------------------------- mov al,':' ;显示分隔符号 mov [bx],al inc bx ;------------------------------------------------------- mov ah,2ch int 21h mov al,cl ;分钟数设定 mov ah,0 call bctd CALL ASC ;------------------------------------------------------------------------- mov al,':' ;显示分隔符号 mov [bx],al inc bx ;------------------------------------------------------------------------- mov ah,2ch ;秒设定 int 21h mov al,dh mov ah,0 call bctd CALL ASC ;---------------------------------------------------------------------- mov al,'$' ;将字符串的结束位送至显示缓冲区的最后一位 mov [bx],al ;------------------------------------------------------------------------------ push bx ;置光标位置 ,AH=2,BH=0,DH跟DL分别为行号与列号,并入栈保护BX mov ah,2 mov bh,0 mov dh,3 mov dl,8 int 10h pop bx lea dx,t_buff ;送t_buff偏移地址到DX,并调用DOS显示功能,功能号为9 mov ah,9 int 21h push bx ;置光标位置 mov ah,2 mov bh,0 mov dh,0 mov dl,0 int 10h pop bx lea dx,mess1 mov ah,9 int 21h push bx ;置光标位置 mov ah,2 mov bh,0 mov dh,3 mov dl,0 int 10h pop bx lea dx,mess2 mov ah,9 int 21h ;------------------------------------------------- mov ah,2ch ;调用DOS时间调用功能,功能号:2cH,小时,分钟,秒数分别保存在CH,CL,DH中 int 21h CMP CH,HOR1 JNZ nxt ;判断闹钟是否到时,如果到时调用07H输出响声 CMP CL,MIN1 JNZ nxt CMP DH,SEC1 JNZ nxt MOV DL,07H MOV AH,02H INT 21H ;----------------------------- nxt: call delay1 mov ah,1 ;调用键盘I/O中断功能号1,获取键值到AL int 16h cmp al,'c' ;是c键,转到时间修改程序 je Cor cmp al,'C' ;是C键,转到时间修改程序 je Cor CMP AL,'R' JE RING CMP AL,'r' JE RING cmp al,1bh jz quit ;是ESC键,退出程序 JMP DISPLAY quit:mov ah,4ch ;程序终止功能号 int 21h ret RING: call INPUT2 JMP START Cor: call correct ;调用时间修改子程序 ;------------------------------- bctd proc near ;二进制转BCD码子程序 ;AX输入参数 ;AX输出参数,存放调整过的BCD码 mov dx,ax mov ax,0 mov cx,16 ;设循环次数 bctd1: clc ;清进位标志C rcl dx,1 ;通过进位的循环右移 adc al,al ;带进位法 daa ;法的十进制调整 xchg al,ah ;交换高、低八位 adc al,al daa xchg al,ah loop bctd1 ;循环次数保存在CX里 ret bctd endp ;------------------------------------------- clear proc near push ax ;入栈保护现场 push bx push cx push dx mov ax,0600h ;ah=06(滚动)al=00(全屏空白) mov bh,0fh ;设置背景颜色(2)和前景颜色(e) sub cx,cx mov dx,5f5fh int 10h pop dx ;出栈恢复现场 pop cx pop bx pop ax ret clear endp ;----------------------------------------- delay1 PROC ;精确延迟时间子程序 MOV DX,04ffh ;循环次数 up: XOR CX,CX a: NOP LOOP a DEC DX JNZ up RET delay1 ENDP ;---------------------------- correct proc ;时间修改子程序 call input ;调用键盘输入子程序输入数据 mov ch,hor mov cl,min mov dh,sec and dl,0h mov ah,2dh int 21h jmp start ret correct endp ;---------------------------------- input2 proc ;闹钟设置子程序 push ax ;入栈保护数据 push bx push cx push dx pushf mov dx,offset tm ;显示设置闹钟的格式提示 mov ah,09h int 21h mov dx,offset t_buff ;数据缓冲区的数据输入 mov ah,0ah int 21h and dx,0h lea bx,t_buff inc bx inc bx mov dh,[bx] sub dh,30h inc bx mov dl,[bx] sub dl,30h mov cl,10 mov al,dh mul cl add al,dl mov ch,al mov hor1,al inc bx inc bx mov dh,[bx] sub dh,30h inc bx mov dl,[bx] sub dl,30h mov cl,10 mov al,dh mul cl add al,dl mov cl,al mov min1,al inc bx inc bx mov dh,[bx] sub dh,30h inc bx mov dl,[bx] sub dl,30h mov cl,10 mov al,dh mul cl add al,dl mov dh,al mov sec1,al popf ;出栈恢复数据 pop dx pop cx pop bx pop ax ret input2 endp ;---------------------------------- input proc ;键盘输入子程序 push ax ;入栈保护数据 push bx push cx push dx pushf mov dx,offset tn ;显示修改时间的格式提示 mov ah,09h int 21h mov dx,offset t_buff ;数据缓冲区的数据输入 mov ah,0ah int 21h and dx,0h lea bx,t_buff inc bx inc bx mov dh,[bx] sub dh,30h inc bx mov dl,[bx] sub dl,30h mov cl,10 mov al,dh mul cl add al,dl mov ch,al mov hor,al inc bx inc bx mov dh,[bx] sub dh,30h inc bx mov dl,[bx] sub dl,30h mov cl,10 mov al,dh mul cl add al,dl mov cl,al mov min,al inc bx inc bx mov dh,[bx] sub dh,30h inc bx mov dl,[bx] sub dl,30h mov cl,10 mov al,dh mul cl add al,dl mov dh,al mov sec,al popf ;出栈恢复数据 pop dx pop cx pop bx pop ax ret input endp ;---------------------------- ASC PROC PUSH AX AND AL,0F0H ;选取AL高四位 MOV CL,4 ;设置右循环的次数 ROL AL,CL ;右循环 OR AL,30H ;30H得到ACSII码 MOV [BX],AL ;将得到的结果送到T_BUFF缓冲区 INC BX ;BX自1,指针指向下一个缓冲区的下一个地址 POP AX AND AL,0FH ;选取低四位 OR AL,30H MOV [BX],AL ;将转换后的低四位值送入缓冲区的第二个地址 INC BX RET ASC ENDP ;---------------------------------- code ends end start
1计算器 DATA SEGMENT STRING DB 'PLEASE PRESS NUMBER 1,2,3,4,5:',0DH,0AH,'$' BUFF DB 10 DB ? DB 10 DUP(?) ARRAY1 DB 'PLEASE INPUT THE FIRST NUMBER:',0DH,0AH,'$' ARRAY2 DB 'PLEASE INPUT THE SECOND NUMBER:',0DH,0AH,'$' ARRAY3 DB 10 DB ? DB 10 DUP(?) ARRAY DW 2 DUP(?) RESULT DB 4 DUP(?),'$' DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START:MOV AX,DATA MOV DS,AX MOV AH,00H MOV AL,06H INT 10H MOV DX,OFFSET ARRAY1 MOV AH,9 INT 21H MOV DX,OFFSET BUFF MOV AH,0AH INT 21H CALL ABC MOV ARRAY,AX MOV DX,OFFSET ARRAY2 MOV AH,9 INT 21H MOV DX,OFFSET BUFF MOV AH,0AH INT 21H CALL ABC MOV ARRAY+2,AX MOV AH,09H MOV DX,OFFSET STRING INT 21H MOV DX,OFFSET ARRAY3 MOV AH,0AH INT 21H MOV BX,DX MOV AL,[BX+2] CMP AL,'1' JZ A1 CMP AL,'2' JZ A2 CMP AL,'3' JZ A3 CMP AL,'4' JZ A4 CMP AL,'5' JZ A5 A1: MOV AX,ARRAY MOV BX,ARRAY+2 ADD AL,BL ADC AH,0 CALL DEF JMP LAST A2: MOV AX,ARRAY MOV BX,ARRAY+2 CMP AL,BL JAE K0 JMP K1 K0:SUB AL,BL CALL DEF JMP LAST K1:PUSH AX MOV AH,02H MOV DL,'-' INT 21H POP AX SUB BL,AL MOV AL,BL CALL DEF JMP LAST A3: MOV AX,ARRAY MOV BX,ARRAY+2 MUL BL CALL DEF JMP LAST A4: MOV AX,ARRAY MOV BX,ARRAY+2 DIV BL MOV AH,0 CALL DEF JMP LAST A5:JMP LAST ABC PROC MOV CL ,2 MOV CH,0 MOV BX,OFFSET BUFF+2 PUSH BX PUSH CX L0: SUB [BX],30H INC BX LOOP L0 POP CX POP BX MOV AH,0 MOV AL,0 MOV SI,10 L1: MUL SI ADD AL,[BX] ADC AH,0 INC BX LOOP L1 RET ABC ENDP DEF PROC MOV SI,OFFSET RESULT SUB DX,DX MOV BX,1000 DIV BX ADD AL,30H MOV [SI],AL MOV AX,DX MOV BL,100 DIV BL ADD AL,30H MOV [SI+1],AL MOV AL,AH SUB AH,AH MOV BL,10 DIV BL ADD AL,30H MOV [SI+2],AL ADD AH,30H MOV [SI+3],AH MOV DX,OFFSET RESULT MOV AH,9 INT 21H RET DEF ENDP LAST: MOV AH,4CH INT 21H CODE ENDS END START

27,375

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 单片机/工控
社区管理员
  • 单片机/工控社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧