王爽《汇编语言》课程设计二

更新时间:2023-05-10 01:34:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

王爽《汇编语言》一书中课程设计二的代码

先运行代码1,再运行代码2,要利用虚拟机 代码1

assume cs:code

code segment

NewStart1:jmp short NewStart2

db '1) reset pc ',0

db '2) start system ',0

db '3) clock ',0

db '4) set clock ',0

s5 dw 8 dup (0)

s6 db "aaaa/aa/aa aa:aa:aa",0

NewStart2:mov bx,200h

mov ds,bx

mov bx,0b800h

mov es,bx

mov si,2

mov bp,160*10+30*2

mov cx,4

show:push cx

mov di,0

mov cx,16

show1:mov al,ds:[si]

mov es:[bp+di],al

add di,2

inc si

loop show1

pop cx

add bp,158

loop show

mov bx,66

mov word ptr ds:[bx],0

mov word ptr ds:[bx+2],0ffffh

ccc:mov ah,0

int 16h

cmp al,'1'

je reset

cmp al,'2'

王爽《汇编语言》一书中课程设计二的代码

je startsystem

cmp al,'3'

je clock

cmp al,'4'

je setclock

jmp ccc

reset:mov bx,200h

mov ds,bx

mov bx,66

jmp dword ptr ds:[bx]

startsystem:mov bx,0

mov es,bx

mov bx,7c00h

mov dl,80h

mov dh,0 mov ch,0

mov cl,1

mov al,1

mov ah,2 int 13h

mov bx,0

push bx

mov bx,7c00h

push bx

retf

setclock:jmp short setclock1

b db 'aaaaaaaaaaaaaa' setclock1:

push ax

push si

push ds

push dx

mov ax,200h

mov ds,ax

mov si,offset b

mov dx,0

call getstr

call str

王爽《汇编语言》一书中课程设计二的代码

pop dx

pop ds

pop si

pop ax

call cls

jmp near ptr NewStart1

clock:call cls

mov bx,200h

mov ds,bx

mov bx,0

mov es,bx

mov bx,66

push es:[9*4]

pop ds:[bx+10]

push es:[9*4+2]

pop ds:[bx+12]

cli

mov word ptr es:[9*4],offset int9 mov es:[9*4+2],ds

sti

s4:mov si,offset s6

mov al,32h

call s

mov [si],ah

mov [si+1],al

add si,2

mov al,9

mov cx,3

s1:mov bl,al

call s

mov [si],ah

mov [si+1],al

add si,3

mov al,bl

dec al

loop s1

mov si,offset s6

add si,11

mov al,4

mov cx,3

s2:mov bl,al

call s

王爽《汇编语言》一书中课程设计二的代码

mov [si],ah

mov [si+1],al

add si,3

mov al,bl

sub al,2

loop s2

mov bx,0b800h

mov es,bx

mov si,offset s6

mov di,160*6+40*2

mov cx,19

s3:mov bl,[si]

mov es:[di],bl

inc si

add di,2

loop s3

jmp short s4

s:push cx

out 70h,al

in al,71h

mov ah,al

mov cl,4

shr ah,cl

and al,00001111b

add ah,30h

add al,30h

pop cx

ret

cls:push es

push bx

push cx

mov bx,0b800h

mov es,bx

mov bx,0

mov cx,2000

s10:mov byte ptr es:[bx],' '

add bx,2

loop s10

pop cx

pop bx

pop es

ret

王爽《汇编语言》一书中课程设计二的代码

int9:push ax

push bx

push es

push cx

mov bx,200h

mov ds,bx

mov ax,0b800h

mov es,ax

mov bx,66

in al,60h

pushf

call dword ptr ds:[bx+10] cmp al,3bh

jne ok1

mov bx,160*6+40*2+1

mov cx,19

s7:inc byte ptr es:[bx]

add bx,2

loop s7

ok2:pop cx

pop es

pop bx

pop ax

iret

ok1:cmp al,01

jne ok2

mov ax,0

mov es,ax

mov bx,66

cli

push ds:[bx+10]

pop es:[9*4]

push ds:[bx+12]

pop es:[9*4+2]

sti

pop cx

pop es

pop bx

pop ax

mov bp,0b800h

王爽《汇编语言》一书中课程设计二的代码

mov es,bp

mov bx,160*6+40*2

mov cx,19

s8:mov byte ptr es:[bx],' '

add bx,2

loop s8

mov ax,200h

push ax

mov ax,0

push ax

retf

charstack:jmp short charstart

table dw charpush,charpop,charshow

charstart:push bx

push di

push es

cmp ah,2

ja sret

mov bl,ah

mov bh,0

add bx,bx

jmp word ptr table[bx]

charpush:mov bx,dx

mov [si][bx],al

inc dx

jmp sret

charpop:cmp dx,0

je sret

dec dx

mov bx,dx

mov al,[si][bx]

jmp sret

charshow:mov bx,0b800h

mov es,bx

mov di,160*6+40*2

王爽《汇编语言》一书中课程设计二的代码

charshows:cmp bx,dx

jne noempty

mov byte ptr es:[di],' ' jmp sret

noempty:mov al,[si][bx]

mov es:[di],al

mov byte ptr es:[di+2],' ' inc bx

add di,2

jmp charshows

sret:pop es

pop di

pop bx

ret

getstr:push ax

getstrs:mov ah,0

int 16h

cmp al,20h

jb nochar

mov ah,0

call charstack

mov ah,2

call charstack

jmp getstrs

nochar:cmp ah,0eh

je backspace

cmp ah,1ch

je enter

jmp getstrs

backspace:mov ah,1

call charstack

mov ah,2

call charstack

jmp getstrs

enter:mov al,0

王爽《汇编语言》一书中课程设计二的代码

call charstack

mov ah,2

call charstack

pop ax

ret

wrtc:push cx

out 70h,al

mov ah,b[bx]

sub ah,30h

mov cl,4

shl ah,cl

inc bx

mov al,b[bx]

sub al,30h

or al,ah

out 71h,al

inc bx

pop cx

ret

str:push ax

push bx

mov bx,0

mov al,32h

call wrtc

mov al,9

call wrtc

mov al,8

call wrtc

mov al,7

call wrtc

mov al,4

call wrtc

mov al,2

call wrtc

mov al,0

call wrtc

pop bx

pop ax

王爽《汇编语言》一书中课程设计二的代码

ret

start:push cs

pop es

mov bx,offset NewStart1

mov al,16

mov ch,0

mov cl,2

mov dl,0

mov dh,0

mov ah,3

int 13h

mov ax,4c00h

int 21h

code ends

end start

代码2

assume cs:code

code segment

NewStart1:jmp short NewStart2 dw 0,0

NewStart2:mov bx,200h

mov es,bx

mov bx,0

mov al,16

mov ch,0

mov cl,2

mov dl,0

mov dh,0

mov ah,2

int 13h

mov ax,0

mov es,ax

mov word ptr es:[7c04h],200h jmp dword ptr es:[7c02h]

start:push cs

pop es

王爽《汇编语言》一书中课程设计二的代码

mov bx,offset NewStart1

mov al,1

mov ch,0

mov cl,1

mov dl,0

mov dh,0

mov ah,3

int 13h

mov ax,4c00h int 21h

code ends

end start

本文来源:https://www.bwwdw.com/article/fhxe.html

Top