汇编 以16进制显示AX
汇编的贪吃蛇

汇编笔记

scturtle posted @ 2009年10月01日 03:36 in 各种实验 , 1588 阅读

串处理指令判断字符串相等

LEA SI, PSW1 ;源字符串
LEA DI, BUFF ;目的字符串
MOV CX, BX ;计数
CLD ;使DF=0,地址自动增量
REPE CMPSB ;比较字符串PSW1和BUFF
.IF ZERO? ;若字符串的相应字符相同
……

清屏幕

Clear PROC Near Uses AX BX CX DX ;清屏幕,并保护所用寄存器
        MOV CL, 0
        MOV CH, 0
        MOV DL, 79
        MOV DH, 24 ;(0,0)-(24,79)是屏幕的左上角和右下角
        MOV BH, 7
        MOV AL, 0 ;AL=滚动行数(0——清窗口)
        MOV AH, 6 ;AH=06H——向上滚屏
        INT 10H
        RET
Clear ENDP
BIOS显示彩色字符串
;在位置(5,20)的位置显示蓝色字符串
MOV BP, OFFSET MSG1 ;显示字符串首地址
MOV BL, 09H ;属性:蓝色
MOV CX, 0AH ;显示字符串长度:10
MOV AL, 0 ;写方式 (0~3)
MOV BH, 0 ;页号
MOV DH, 5 ;起始行
MOV DL, 20 ;起始列
MOV AH, 13H
INT 10H ;使用中断10H之功能13H来显示字符串

暂停,任意键关闭 DOS 和 BIOS

mov ah,1
int 21h

mov ah,0
int 16h

检测上下左右

 .IF AH==50H ;↓
        inc location
.ELSEIF AH==48H ;↑
        DEC location
.ELSEIF AH==4DH ;→
        inc location+1
.ELSEIF AH==4BH ;←
        DEC location+1
 .ENDIF

延时程序

WAITF PROC NEAR ;延时子程序
        PUSH AX
WAITF1:
        IN AL,61H
        AND AL,10H
        CMP AL,AH
        JE WAITF1
        MOV AH,AL
        LOOP WAITF1
        POP AX
        RET
WAITF ENDP

…………

;调用
MOV CX,33144
CALL WAITF

书上的以16进制显示BX寄存器内容的程序 改正一点地方

SHOWBX PROC near
        MOV CH,4
        MOV CL,4
rotate:
        ROL BX,CL
        MOV AL,BL
        AND AL,0FH
        ADD AL,30H
        CMP AL,3AH
        JL printit
        ADD AL,7H
printit:
        MOV DL,AL
        MOV AH,2
        INT 21H
        DEC CH
        JNZ rotate
        RET
SHOWBX ENDP

两个有用的输出宏

printchar macro char,len,row,lie,col ;输出字符到指定位置
 mov ah,2
 mov bh,0
 mov dh,row
 mov dl,lie
 int 10h
 mov bl,col
 mov bh,0
 mov al,char
 mov ah,09h
 mov cx,len
 int 10h
endm

printstr macro string,len,row,lie ;输出字符串到指定位置
 ;mov ah,13
 ;mov bp,seg string
 ;mov es,bp
 mov bp,offset string
 mov cx,len
 mov dh,row
 mov dl,lie
 mov bh,0
 mov ax,1300h
 mov bl,6
 int 10h
endm

 不堵塞的按键检测

in al,60h

 

 

 

 

 

 

HBSE 9th Question P 说:
2023年9月30日 14:43

Haryana 9th Important Question Paper 2024 for Hindi, English, Mathematics, Science, Social Science, These Practice Paper Importance for Those will attain the Upcoming Final Exam 2024. The best way to Download your Haryana Exam Preparation level is by Previous Question Paper.These Haryana Model Paper 2024 are Provided by the Board for the better Exam Preparation of Students and are HBSE 9th Question Paper 2024 also available in the official website, This Exam Paper Prepare by Senior Exports of Haryana Education Board,Haryana Model Paper 2024 help the Students to get a Clear idea about the Final Exam 2024.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter