汇编语言程序设计

汇编语言程序设计,第1张

这个是16位打字游戏的代码 可以运行的哦~

Init_game macro op1,op2,op3,op4,op5,op6

mov cx,00h

mov dh,op1

mov dl,op2

op6:

mov ah,02h

mov bh,00h

int 10h

push cx

mov ah,0ah

mov al,op3

mov bh,00h

mov cx,01h

int 10h

pop cx

inc cx

inc op4

cmp cx,op5

jne op6

endm

clear_screen macro op1,op2,op3,op4

mov ah,06h

mov al,00h

mov bh,07h

mov ch,op1

mov cl,op2

mov dh,op3

mov dl,op4

int 10h

mov ah,02h

mov bh,00h

mov dh,00h

mov dl,00h

int 10h

endm

menu macro op1,op2,op3

mov ah,02h

mov bh,00h

mov dh,op1

mov dl,op2

int 10h

mov ah,09h

lea dx,op3

int 21h

endm

data segment

linjiang db "Made by lin jiang$"

no db "NO:021411$"

meg db "Let us have a game!!Come on!!$"

meg1 db "Select Menu$"

meg2 db "Please select the game speed,ESC to quit$"

meg3 db "1Very slow Too easy,speed up!$"

meg4 db "2Slow Everybody can deal$"

meg5 db "3Nomal I think you can deal!$"

meg6 db "4Fast A challengePay attention!$"

meg7 db "5Very Fast Too hard,Have a try$"

meg8 db "6Fastest Are you crazy$"

meg9 db "Select the number among 1-6 and press ENTER to start!$"

meg10 db "Game Speed Select:$"

hotkey db "When you are playing games:$"

hotkey1 db "ESC to return to menu$"

hotkey2 db "SPACE to pause the game$"

hotkey3 db "Press any key to play games$"

hotkey4 db "Are you ready$"

failmeg db "The letter is arrive the bottom, You are lost ! :($"

failmeg0 db "Press ENTER to go on$"

failmeg1 db "Game is over!$"

failmeg2 db "Press ENTER to return menu and press ESC to exit!$"

failmeg3 db "Bye-Bye!Thank for your playing!!$"

failmeg4 db "Press any key to quit$"

speed dw 00d,1200d,800d,600d,400d,200d,100d

letters db "jwmilzoeucgpravskntxhdyqfb"

db "iytpkwnxlsvxrmofzhgaebudjq"

db "nwimzoexrphysfqtvdcgljukda"

letters_bak db "jwmilzoeucgpravskntxhdyqfb"

db "iytpkwnxlsvxrmofzhgaebudjq"

db "nwimzoexrphysfqtvdcgljukda"

letter_counter db 0

life_flag db 78 dup(0)

position_flag db 78 dup(0)

present_position db 1

data ends

stack segment para stack 'stack'

db 64 dup(0)

stack ends

code segment

main proc far

assume cs:code,ds:data,ss:stack

start:

mov ax,data

mov ds,ax

mov letter_counter,00h

mov present_position,1

lea si,position_flag

mov ah,00h

mov cx,00h

init_postion_flag:

mov [si],ah

inc si

inc cx

cmp cx,78d

jne init_postion_flag

lea di,letters

lea si,letters_bak

mov cx,00h

init_letters:

mov ah,[si]

mov [di],ah

inc si

inc di

inc cx

cmp cx,78d

jne init_letters

mov ah,00h

lea si,life_flag

mov cx,00h

init_life_flag:

mov [si],ah

inc si

inc cx

cmp cx,78d

jne init_life_flag

mov cx,00h

mov ah,01h

or ch,00010000b

int 10h

clear_screen 00d,00d,24d,79d

Init_game 00d,00d,0ah,dl,80d,nextsign1

Init_game 24d,00d,0ah,dl,80d,nextsign2

Init_game 00d,00d,0ah,dh,25d,nextsign3

Init_game 00d,79d,0ah,dh,25d,nextsign4

menu 01d,15d,meg ;菜单信息的宏展开

menu 01h,61d,linjiang

menu 03d,20d,meg1

menu 03d,68d,no

menu 05d,15d,meg2

menu 07d,15d,meg3

menu 09d,15d,meg4

menu 11d,15d,meg5

menu 13d,15d,meg6

menu 15d,15d,meg7

menu 17d,15d,meg8

menu 19d,15d,meg9

menu 22d,15d,meg10

input: mov ah,02h

mov bh,00h

mov dh,22d

mov dl,33d

int 10h

mov ah,0ah

mov al," "

mov bh,00h

mov cx,01h

int 10h

mov ah,01h

int 21h

retry: cmp al,"1"

je speed1

cmp al,"2"

je speed2

cmp al,"3"

je speed3

cmp al,"4"

je speed4

cmp al,"5"

je speed5

cmp al,"6"

je speed6

cmp al,1bh

je to_over0

jmp input

to_over0:jmp over

speed1: mov ah,01h

int 21h

cmp al,0dh

jne otherkey

mov ax,speed+2

mov speed,ax

jmp begin

speed2: mov ah,01h

int 21h

cmp al,0dh

jne otherkey

mov ax,speed+4

mov speed,ax

jmp begin

speed3: mov ah,01h

int 21h

cmp al,0dh

jne otherkey

mov ax,speed+6

mov speed,ax

jmp begin

speed4: mov ah,01h

int 21h

cmp al,0dh

jne otherkey

mov ax,speed+8

mov speed,ax

jmp begin

speed5: mov ah,01h

int 21h

cmp al,0dh

jne otherkey

mov ax,speed+10

mov speed,ax

jmp begin

speed6: mov ah,01h

int 21h

cmp al,0dh

jne otherkey

mov ax,speed+12

mov speed,ax

jmp begin

otherkey: ; 处理重复输入的代码段

push ax

mov ah,02h

mov bh,00h

mov dh,22d

mov dl,34d

int 10h

mov ah,0ah

mov al," "

mov bh,00h

mov cx,01h

int 10h

mov ah,02h

mov bh,00h

mov dh,22d

mov dl,33d

int 10h

pop ax

mov dx,ax

mov ah,02h

int 21h

jmp retry

begin:

clear_screen 01d,01d,23d,78d

menu 08d,20d,hotkey

menu 10d,20d,hotkey1

menu 12d,20d,hotkey2

menu 14d,20d,hotkey4

menu 16d,20d,hotkey3

mov ah,07h

int 21h

clear_screen 01d,01d,23d,78d

Init_game 23d,01d,01h,dl,78d,nextsign5

mov ah,02h ;光标初始化

mov bh,00h

mov dh,01h

mov dl,01h

int 10h

mov cx,00h

lea si,letters

nextletter: ; 初始化屏幕上方的字母

mov ah,02h

mov dl,[si]

int 21h

inc si

inc cx

cmp cx,78d

je nextcycle

jmp nextletter

from_front: ; 相关循环的算法

sub present_position,78d

jmp gobackto_si

find_zero:cmp letter_counter,78d

je recycle

cmp present_position,78d

je from_one

mov ah,00h

nextsi: add present_position,01h

inc si

cmp [si],ah

je gobackto_di

cmp present_position,78d

je from_one

jmp nextsi

from_one:mov present_position,01h

jmp gobackto_si

recycle:mov letter_counter,00h

mov present_position,01d

lea si,position_flag

mov cx,00h

mov ah,00h

clearsi: mov [si],ah

inc cx

cmp cx,78d

je nextcycle

inc si

jmp clearsi

nextcycle:

lea di,letters

lea si,position_flag

add present_position,31d

cmp present_position,78

ja from_front

gobackto_si:

add si,word ptr present_position

dec si

mov ah,[si]

cmp ah,01h

je find_zero

gobackto_di:

mov ah,01h

mov [si],ah

add di,word ptr present_position

dec di

mov dl,present_position

mov ah,02h ; 字母下落的代码段部分

mov bh,00h

mov dh,01h

int 10h

mov cx,00h

nextrow:push cx ; 新的一行

mov cx,00h

out_cycle: ; 延迟

push cx

mov cx,00h

in_cycle:

add cx,01h

cmp cx,50000d

jne in_cycle

push dx

mov ah,06h

mov dl,0ffh

int 21h

pop dx

jz pass ; 如果键盘缓冲区部分为空,则跳转

cmp al,1bh ; 如果键入ESC,则返回主菜单

je to_start1

cmp al," " ;如果键入SPACE,则游戏暂停

je pause

cmp al,[di] ;输入字母正确!跳转!

je disappear

pass:

pop cx

inc cx

cmp cx,speed

je print

jmp out_cycle

pause: push dx ;暂停处理

mov ah,06h

mov dl,0ffh

int 21h

pop dx

cmp al," "

jne pause

jmp pass

to_start1: ;返回主菜单

jmp start

print:

mov ah,0ah

mov al," "

mov bh,00h

mov cx,01h

int 10h

inc dh

mov ah,02h

mov bh,00h

int 10h

mov ah,0ah

mov al,[di]

mov bh,00h

mov cx,01h

int 10h

pop cx

inc cx

cmp cx,21d

je print_next_letter

jmp nextrow ; 下一行

disappear: ; 击中字母后的相关处理

pop cx

pop cx

mov ah,0ah

mov al," "

mov bh,00h

mov cx,01h

int 10h

jmp hit

print_next_letter: ; 处理原位置的空缺

lea si,life_flag

add si,word ptr present_position

dec si

mov ah,[si]

cmp ah,1

je fail

mov ah,0ah

mov al," "

mov bh,00h

mov cx,01h

int 10h

inc dh

mov ah,02h

mov bh,00h

int 10h

mov ah,0ah

mov al," "

mov bh,00h

mov cx,01h

int 10h

mov ah,1

mov [si],ah

hit: mov ah,02h

mov bh,00h

mov dh,01h

mov dl,present_position

int 10h

mov al,[di] ; 出现下一个新字母的数法

add al,7

cmp al,7ah

ja convey_letter

mov ah,0ah

mov bh,00h

mov cx,01h

int 10h

mov [di],al

add letter_counter,01h

jmp nextcycle

convey_letter:

sub al,7ah

add al,61h

mov ah,0ah

mov bh,00h

mov cx,01h

int 10h

mov [di],al

add letter_counter,01h

jmp nextcycle

fail: mov ah,0ah ;游戏失败后的相关处理

mov al," "

mov cx,01h

int 10h

inc dh

mov ah,02h

mov bh,00h

int 10h

mov ah,0ah

mov al,[di]

mov bh,00h

mov cx,01h

int 10h

mov ah,02h

mov bh,00h

mov dh,12d

mov dl,17d

int 10h

push dx

mov ah,09h

lea dx,failmeg

int 21h

pop dx

add dh,2

mov ah,02h

mov bh,00h

int 10h

mov ah,09h

lea dx,failmeg0

int 21h

re: mov ah,07h

int 21h

cmp al,0dh

jne re

clear_screen 01,01,23,78

mov ah,02h

mov bh,00h

mov dh,11d

mov dl,20d

int 10h

push dx

mov ah,09h

lea dx,failmeg1

int 21h

pop dx

inc dh

inc dh

mov ah,02h

mov bh,00h

int 10h

mov ah,09h

lea dx,failmeg2

int 21h

notkey:

mov ah,07h

int 21h

cmp al,0dh

je to_start

cmp al,1bh

je over

jmp notkey

to_start:

clear_screen 00,00,24,79

jmp start

over: clear_screen 01,01,23,78

mov ah,02h

mov bh,00h

mov dh,11d

mov dl,15h

int 10h

mov ah,09h

lea dx,failmeg3

int 21h

mov ah,02h

mov bh,00h

mov dh,13d

mov dl,15h

int 10h

mov ah,09h

lea dx,failmeg4

int 21h

mov ah,07h

int 21h

mov ah,07h

int 21h

clear_screen 00,00,24,79

mov ax,4c00h

int 21h

main endp

code ends

end start

1王爽-汇编语言(第二版)这是16位汇编打好基础,2Intel汇编语言程序设计:从16位实模式下BIOS、DOS实模式文本及图形程序设计到32位保护模式的Windows程序设计,这本书比上面那本介绍的更全面,但却未必适合你,建议你先看王爽汇编然后再看这本

3IBMPC汇编语言程序设计,清华大学的这本算是正统的本科教材了,内容中规中矩,也有不少网友推荐本书适合自学

480x86汇编语言程序设计,这本书像国内版的Intel汇编语言程序设计,内容都差不多,从16位实模式到32位保护模式编程,是王爽汇编的进阶教程放在王爽汇编之后和第二本书中挑一本学

5罗云彬Windows环境下32位汇编语言程序设计,这本书就是汇编版的windows程序设计,适合汇编爱好者进阶windows编程用的,放到最后吧!学完这本后面的发展方向就很丰富了

编码不容易,望能帮到楼主。楼主好好看

CRLFMACRO;宏定义,实现回车换行

MOVAH,2

MOVDL,0DH

INT21H

MOVAH,2

MOVDL,0AH

INT21H

ENDM

DSEGMENT

SCOREDB76,69,84,90,73,88,89,63,100,80;数组接收分数

SDB5DUP();预留5个位置存储每个分数段的人数

WORDSDB"THENUMBERBETWEEN60~69IS:$"

WORDS1DB"THENUMBERBETWEEN70~79IS:$"

WORDS2DB"THENUMBERBETWEEN80~89IS:$"

WORDS3DB"THENUMBERBETWEEN90~99IS:$"

WORDS4DB"THENUMBERBETWEEN100IS:$"

DENDS

CODESEGMENT

ASSUMECS:CODE,DS:D

BG:

MOVAX,D

MOVDS,AX

CALLCOUNT;调用子程序

MOVAH,9;输出每个分数段的人数

LEADX,WORDS

INT21H

MOVAH,2

MOVDL,S

ADDDL,30H

INT21H

CRLF

MOVAH,9

LEADX,WORDS1

INT21H

MOVAH,2

MOVDL,S1

ADDDL,30H

INT21H

CRLF

MOVAH,9

LEADX,WORDS2

INT21H

MOVAH,2

MOVDL,S2

ADDDL,30H

INT21H

CRLF

MOVAH,9

LEADX,WORDS3

INT21H

MOVAH,2

MOVDL,S3

ADDDL,30H

INT21H

CRLF

MOVAH,9

LEADX,WORDS4

INT21H

MOVAH,2

MOVDL,S4

ADDDL,30H

INT21H

CRLF

MOVAH,4CH

INT21H

COUNT:;子程序入口

MOVCX,10;循环10次

MOVSI,0

LOP:

INT3

MOVAL,SCORE[SI]

CMPAL,70

JBNUMBER6;比较进入不同的标号进行计算每个分数段人数

CMPAL,80

JBNUMBER7

CMPAL,90

JBNUMBER8

CMPAL,100

JENUMBER10

JMPNUMBER9

NUMBER6:;不同标号之下的作用是计算每个分数段人数并存于预留的位置中

MOVBL,S

INCBL

MOVS,BL

JMPL

NUMBER7:

MOVBL,S1

INCBL

MOVS1,BL

JMPL

NUMBER8:

MOVBL,S2

INCBL

MOVS2,BL

JMPL

NUMBER9:

MOVBL,S3

INCBL

MOVS3,BL

JMPL

NUMBER10:

MOVBL,S4

INCBL

MOVS4,BL

JMPL

L:

INCSI

LOOPLOP

RET;子程序结束,放回主程序

CODEENDS

ENDBG

汇编语言是一种用于电子计算机、微处理器、微控制器或其他可编程设备的低级语言,也称为符号语言。在汇编语言中,用助记符代替机器指令的 *** 作码,用地址符号或标号代替指令或 *** 作数的地址。同时,因为资源的稀缺性,计算机运行的效率也成为那个时代工程师追求的目标。为了更高效地使用计算机,人们设计了高级编程语言,以满足人们对高效简洁编程语言的追求。在编程语言被机器语言和汇编语言更新之后,人们发现了限制程序普及的关键因素——程序的可移植性。有必要设计一个可以独立于计算机硬件在不同机器上运行的程序。这样可以避免很多重复的编程过程,提高效率。同时,这种语言应该接近数学语言或人类自然语言。20世纪50年代,计算机还很匮乏的时候,第一个高级编程语言诞生了。那时候计算机的成本很贵,但是每天的计算量是有限的。如何有效利用计算机有限的计算能力,成为当时人们面临的问题。

没有系统预定义的Id,都是程序中定义并使用的。

Res格式中记录了定义好的Id,

程序调用Windows的API来加载/处理资源(用Hinstance来指定 hDlg)中指定Id的资源(控件)

因为必须明确指定从哪个model中加载,而在一个Model中是不允许有同名的同种类资源的,所以Windows不会找不到正确的资源。

以上就是关于汇编语言程序设计全部的内容,包括:汇编语言程序设计、几本汇编语言书籍的不同_汇编语言哪本书比较好、汇编语言程序设计方法_汇编语言程序设计教程等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9309196.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存