王爽《汇编语言》课程设计二.docx
《王爽《汇编语言》课程设计二.docx》由会员分享,可在线阅读,更多相关《王爽《汇编语言》课程设计二.docx(12页珍藏版)》请在冰豆网上搜索。
![王爽《汇编语言》课程设计二.docx](https://file1.bdocx.com/fileroot1/2023-1/8/fa52a9e7-e3a1-4980-bba8-f0e965f9b082/fa52a9e7-e3a1-4980-bba8-f0e965f9b0821.gif)
王爽《汇编语言》课程设计二
先运行代码1,再运行代码2,要利用虚拟机
代码1
assumecs:
code
codesegment
NewStart1:
jmpshortNewStart2
db'1)resetpc',0
db'2)startsystem',0
db'3)clock',0
db'4)setclock',0
s5dw8dup(0)
s6db"aaaa/aa/aaaa:
aa:
aa",0
NewStart2:
movbx,200h
movds,bx
movbx,0b800h
moves,bx
movsi,2
movbp,160*10+30*2
movcx,4
show:
pushcx
movdi,0
movcx,16
show1:
moval,ds:
[si]
moves:
[bp+di],al
adddi,2
incsi
loopshow1
popcx
addbp,158
loopshow
movbx,66
movwordptrds:
[bx],0
movwordptrds:
[bx+2],0ffffh
ccc:
movah,0
int16h
cmpal,'1'
jereset
cmpal,'2'
jestartsystem
cmpal,'3'
jeclock
cmpal,'4'
jesetclock
jmpccc
reset:
movbx,200h
movds,bx
movbx,66
jmpdwordptrds:
[bx]
startsystem:
movbx,0
moves,bx
movbx,7c00h
movdl,80h
movdh,0
movch,0
movcl,1
moval,1
movah,2
int13h
movbx,0
pushbx
movbx,7c00h
pushbx
retf
setclock:
jmpshortsetclock1
bdb'aaaaaaaaaaaaaa'
setclock1:
pushax
pushsi
pushds
pushdx
movax,200h
movds,ax
movsi,offsetb
movdx,0
callgetstr
callstr
popdx
popds
popsi
popax
callcls
jmpnearptrNewStart1
clock:
callcls
movbx,200h
movds,bx
movbx,0
moves,bx
movbx,66
pushes:
[9*4]
popds:
[bx+10]
pushes:
[9*4+2]
popds:
[bx+12]
cli
movwordptres:
[9*4],offsetint9
moves:
[9*4+2],ds
sti
s4:
movsi,offsets6
moval,32h
calls
mov[si],ah
mov[si+1],al
addsi,2
moval,9
movcx,3
s1:
movbl,al
calls
mov[si],ah
mov[si+1],al
addsi,3
moval,bl
decal
loops1
movsi,offsets6
addsi,11
moval,4
movcx,3
s2:
movbl,al
calls
mov[si],ah
mov[si+1],al
addsi,3
moval,bl
subal,2
loops2
movbx,0b800h
moves,bx
movsi,offsets6
movdi,160*6+40*2
movcx,19
s3:
movbl,[si]
moves:
[di],bl
incsi
adddi,2
loops3
jmpshorts4
s:
pushcx
out70h,al
inal,71h
movah,al
movcl,4
shrah,cl
andal,00001111b
addah,30h
addal,30h
popcx
ret
cls:
pushes
pushbx
pushcx
movbx,0b800h
moves,bx
movbx,0
movcx,2000
s10:
movbyteptres:
[bx],''
addbx,2
loops10
popcx
popbx
popes
ret
int9:
pushax
pushbx
pushes
pushcx
movbx,200h
movds,bx
movax,0b800h
moves,ax
movbx,66
inal,60h
pushf
calldwordptrds:
[bx+10]
cmpal,3bh
jneok1
movbx,160*6+40*2+1
movcx,19
s7:
incbyteptres:
[bx]
addbx,2
loops7
ok2:
popcx
popes
popbx
popax
iret
ok1:
cmpal,01
jneok2
movax,0
moves,ax
movbx,66
cli
pushds:
[bx+10]
popes:
[9*4]
pushds:
[bx+12]
popes:
[9*4+2]
sti
popcx
popes
popbx
popax
movbp,0b800h
moves,bp
movbx,160*6+40*2
movcx,19
s8:
movbyteptres:
[bx],''
addbx,2
loops8
movax,200h
pushax
movax,0
pushax
retf
charstack:
jmpshortcharstart
tabledwcharpush,charpop,charshow
charstart:
pushbx
pushdi
pushes
cmpah,2
jasret
movbl,ah
movbh,0
addbx,bx
jmpwordptrtable[bx]
charpush:
movbx,dx
mov[si][bx],al
incdx
jmpsret
charpop:
cmpdx,0
jesret
decdx
movbx,dx
moval,[si][bx]
jmpsret
charshow:
movbx,0b800h
moves,bx
movdi,160*6+40*2
movbx,0
charshows:
cmpbx,dx
jnenoempty
movbyteptres:
[di],''
jmpsret
noempty:
moval,[si][bx]
moves:
[di],al
movbyteptres:
[di+2],''
incbx
adddi,2
jmpcharshows
sret:
popes
popdi
popbx
ret
getstr:
pushax
getstrs:
movah,0
int16h
cmpal,20h
jbnochar
movah,0
callcharstack
movah,2
callcharstack
jmpgetstrs
nochar:
cmpah,0eh
jebackspace
cmpah,1ch
jeenter
jmpgetstrs
backspace:
movah,1
callcharstack
movah,2
callcharstack
jmpgetstrs
enter:
moval,0
movah,0
callcharstack
movah,2
callcharstack
popax
ret
wrtc:
pushcx
out70h,al
movah,b[bx]
subah,30h
movcl,4
shlah,cl
incbx
moval,b[bx]
subal,30h
oral,ah
out71h,al
incbx
popcx
ret
str:
pushax
pushbx
movbx,0
moval,32h
callwrtc
moval,9
callwrtc
moval,8
callwrtc
moval,7
callwrtc
moval,4
callwrtc
moval,2
callwrtc
moval,0
callwrtc
popbx
popax
ret
start:
pushcs
popes
movbx,offsetNewStart1
moval,16
movch,0
movcl,2
movdl,0
movdh,0
movah,3
int13h
movax,4c00h
int21h
codeends
endstart
代码2
assumecs:
code
codesegment
NewStart1:
jmpshortNewStart2
dw0,0
NewStart2:
movbx,200h
moves,bx
movbx,0
moval,16
movch,0
movcl,2
movdl,0
movdh,0
movah,2
int13h
movax,0
moves,ax
movwordptres:
[7c04h],200h
jmpdwordptres:
[7c02h]
start:
pushcs
popes
movbx,offsetNewStart1
moval,1
movch,0
movcl,1
movdl,0
movdh,0
movah,3
int13h
movax,4c00h
int21h
codeends
endstart