汇编实验9.docx

上传人:b****5 文档编号:6861870 上传时间:2023-01-11 格式:DOCX 页数:18 大小:52.73KB
下载 相关 举报
汇编实验9.docx_第1页
第1页 / 共18页
汇编实验9.docx_第2页
第2页 / 共18页
汇编实验9.docx_第3页
第3页 / 共18页
汇编实验9.docx_第4页
第4页 / 共18页
汇编实验9.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

汇编实验9.docx

《汇编实验9.docx》由会员分享,可在线阅读,更多相关《汇编实验9.docx(18页珍藏版)》请在冰豆网上搜索。

汇编实验9.docx

汇编实验9

山东大学实验报告

2016年月日

姓名刘方铮,学号201411130001系年级计算机科学与技术系2014级

科目汇编语言题目字符图形程序,屏幕窗口程序和画栅栏程序

实验源程序清单

字符图形程序:

datasegment

array1db0,1,2,3,4,5,6,7,8,9

rowdb0

coldb0

colordb0fh

array2db'pleasepayattention:

press"ESC"toexit&press"del"toclearscreen','$'

array3db'CHARACTER:

','$'

array4db'COLOR:

','$'

dataends

prognamsegment

assumecs:

prognam,ds:

data

mainprocfar

start:

pushds

movax,0

pushax

movax,data

movds,ax

leadx,array2

movah,9

int21h

movrow,1

movcol,24

movbx,26

l0:

callreset

moval,7ch

movbh,0

movcx,1

movah,0ah

int10h

incrow

decbx

jnzl0

movrow,2

movcol,0

movdi,0

callreset

leadx,array3

movah,9

int21h

movrow,3

movcol,0

l1:

callreset

movax,di

addal,30h

movbh,0

movcx,1

movah,0ah

int10h

inccol

callreset

movbh,0

movcx,1

movah,0ah

moval,array1[di]

int10h

incdi

cmpdi,9

jal2

addcol,6

cmpcol,22

jbl1

addrow,2

movcol,0

JMPl1

l2:

addrow,4

movcol,0

callreset

leadx,array4

movah,9

int21h

incrow

movcol,0

movdi,1

l3:

callreset

movbx,di

addbl,60h

movbh,0

movcx,1

movah,0ah

moval,bl

int10h

inccol

callreset

subbl,60h

movbh,0

movcx,1

movah,9

moval,0dbh

int10h

incdi

cmpdi,9

jal4

addcol,6

cmpcol,22

jbl3

addrow,2

movcol,0

JMPl3

l4:

movrow,1

movcol,26

callreset

draw:

movah,0

int16h

cmpah,48h

jeup

cmpah,50h

jedown

cmpah,4dh

jeright

cmpah,4bh

jeleft

cmpah,53h

jel5

cmpah,01h

jnznum

ret

l5:

callclear

movrow,1

movcol,26

callreset

jmpdraw

num:

cmpal,30h

jnbl6

jmpdraw

l6:

cmpal,39h

jal7

andax,00ffh

subax,30h

movdi,ax

moval,array1[di]

movbh,0

movcx,1

movbl,color

movah,09h

int10h

jmpdraw

l7:

cmpal,61h

jbl8

cmpal,69h

jal8

subal,60h

movcolor,al

l8:

jmpdraw

up:

decrow

jzup1

jmpl9

up1:

incrow

jmpl9

down:

incrow

cmprow,25

jadown1

jmpl9

down1:

decrow

jmpl9

left:

deccol

cmpcol,26

jbleft1

jmpl9

left1:

inccol

jmpl9

right:

inccol

cmpcol,78

jaright1

jmpl9

right1:

deccol

l9:

callreset

jmpdraw

mainendp

resetprocnear

movah,2

movbh,0

movdh,row

movdl,col

int10h

ret

resetendp

clearprocnear

pushax

pushbx

pushcx

pushdx

movah,6

moval,0

movch,1

movcl,26

movdh,25

movdl,79

movbh,7

int10h

popdx

popcx

popbx

popax

ret

clearendp

prognamends

endstart

运行结果:

屏幕窗口程序:

;****************************************************************

datassegment

curydb15;光标初始位置

curxdb50

lxdb10;记录左窗口当前光标位置,初始化为左窗口初始位置

lydb15

rxdb50;记录右窗口当前光标位置,初始化为右窗口初始位置

rydb15

dwxdb15;记录下窗口当前光标位置,初始化为下窗口初始位置

dwydb22

ulrowdb0

ulcoldb0

lrrowdb0

lrcoldb0

windownumdb1

datasends

;-----------------------------------------------------------------宏指令clear清屏

clearmacroa,b,c,d

moval,0;初始化窗口

movbh,7;卷入行属性

movch,a;左上角行号

movcl,b;左上角列号

movdh,c;右下角行号

movdl,d;右下角列号

movah,6

int10h;BIOS调用,屏幕初始化

endm

;-------------------------------------------------------------宏指令scroll向上卷动一行

scrollmacrocont,ulrow,ulcol,lrrow,lrcol

moval,cont;上卷行数

movbh,70h;卷入行属性

movch,ulrow;左上角行号

movcl,ulcol;左上角列号

movdh,lrrow;右下角行号

movdl,lrcol;右下角列号

movah,6

int10h;BIOS调用,上卷

endm

;--------------------------------------------------------------宏指令postc光标定位

postcmacroy,x

movbh,0;页号

movdh,y;行

movdl,x;列

movah,2

int10h;BIOS调用,置光标位置

endm

;---------------------------------------------------------------在当前窗口和下窗口显示

displaymacro

movbh,0

movcx,1

movah,0ah;在当前的窗口打印字符

int10h

postcdwy,dwx

movbh,0

movcx,1

movah,0ah;在下窗口输出

int10h

endm

;----------------------------------------------------------------接收字符并判断

getcharmacro

input:

;输入键盘上的字符

movah,0

int16h;BIOS调用,从键盘读字符

cmpah,4bh;判断输入字符是否为左向键

jnzno_left

postcly,lx

movwindownum,2

jmpinput

no_left:

cmpah,4dh

jnzno_right;判断输入字符是否为右向键

postcry,rx

movwindownum,1

jmpinput

no_right:

cmpah,01;判断输入字符是否为ESC

jzexit

display;嵌套调用

incdwx

cmpdwx,65;判断下窗口是否上卷

jleisright

scroll1,19,15,22,65

movdwx,15

isright:

cmpwindownum,1;判断是否在右窗口

jnzdispleft

dispright:

;判断右窗口是否上卷

incrx

cmprx,70

jlerightexit

scroll1,6,50,15,70

movrx,50

rightexit:

;右窗口输出

postcry,rx

jmpinput

displeft:

;判断左窗口是否上卷

inclx

cmplx,30

jleleftexit

scroll1,6,10,15,30

movlx,10

leftexit:

;左窗口输出

postcly,lx

jmpinput

exit:

endm

;---------------------------------------------------------------

codessegment

assumecs:

codes,ds:

datas

start:

mainprocfar

pushds

subax,ax

pushax

movax,datas

movds,ax

clear0,0,24,79

scroll10,5,10,15,30

scroll10,5,50,15,70

scroll4,18,15,22,65

postccury,curx

getchar

ret

mainendp

;-----------------------------------------------------------------

codesends

;****************************************************************

endstart

运行结果:

画栅栏程序:

esc_keyequ1bh

stack_segsegmentstack

db32dup(?

stack_segends

DATA_SEGSEGMENT

msg0db'Afterdrawingthelines,pressESCtoexitorotherkeystocontinue',0ah,0dh,'$'

msg1db'Enterstartingpointx:

',0ah,0dh,'$'

msg2db'Enterstartingpointy:

',0ah,0dh,'$'

msg3db'Enterendingpointx:

',0ah,0dh,'$'

msg4db'Enterendingpointy:

',0ah,0dh,'$'

msg5db'Entercolumndistance:

',0ah,0dh,'$'

msg6db'Enterrowdistance:

',0ah,0dh,'$'

buffdb4,?

4dup(?

start_xdw?

start_ydw?

end_xdw?

end_ydw?

coldw?

rowdw?

DATA_SEGENDS

displaymacromsg

movah,09h

movdx,offsetmsg

int21h

endm

get_argmacroarg

movah,0ah

movdx,offsetbuff

int21h

dec2bin

movarg,ax

endm

draw_linemacrosx,sy,ex,ey,col,row

movdx,start_x

_dl0:

movcx,start_y

moval,3

movah,0ch

_dl1:

int10h

inccx

cmpcx,end_y

jbe_dl1

adddx,row

cmpdx,end_x

jbe_dl0

movcx,start_y

_dl2:

movdx,start_x

moval,3

movah,0ch

_dl3:

int10h

incdx

cmpdx,end_x

jbe_dl3

addcx,col

cmpcx,end_y

jbe_dl2

endm

set_mode_color_textmacro

movah,0

moval,3

int10h

endm

set_mode_color_graphicsmacro

movah,0

moval,4

int10h

endm

get_keymacro

movah,0h

int16h

endm

crlfmacro

movah,02h

movdl,0ah

int21h

movdl,0dh

int21h

endm

dec2binmacro

local_d2b

movcl,buff[1]

movch,0

movsi,offsetbuff+2

movax,0

movdh,10d

movbh,0

_d2b:

movbl,[si]

andbl,0fh

muldh

addax,bx

incsi

loop_d2b

endm

CODE_SEGSEGMENT

ASSUMECS:

CODE_SEG,DS:

DATA_SEG

mainprocfar

pushds

xorax,ax

pushax

movax,data_seg

movds,ax

again:

set_mode_color_text

displaymsg0

displaymsg1

get_argstart_x

crlf

displaymsg2

get_argstart_y

crlf

displaymsg3

get_argend_x

crlf

displaymsg4

get_argend_y

crlf

displaymsg5

get_argcol

crlf

displaymsg6

get_argrow

set_mode_color_graphics

draw_linestart_x,start_y,end_x,end_y,col,row

get_key

cmpal,esc_key

jeexit

jmpagain

exit:

ret

mainendp

CODE_SEGENDS

ENDmain

运行结果:

问题及收获

本次实验在设计中也遇到了一些问题,像在进行界面设计的时候,设计区域边界和区域内布局比较难确定,设计不好就影响界面的美观;编码过程中光标位置的重置容易忘记,是在调试过程中才发现出来的;编码过长,内存占用比较多。

掌握了屏幕窗口程序的基本设计方法,领略了宏的设计和使用方法,实验的整体思路比较简单,但如若想编出复杂的屏幕程序,需要对BIOS调用有一个大致的了解,只有这样才能灵活的去运用,这也就启迪我多去阅读和积累相关的知识,只有知识积累到一定程度才能编出好的程序。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1