项目环境
- 编译环境:搭建一个nasm2.8的编译环境。
- 镜像文件:采用winhex_18.2刷入编码。
- 虚拟机:采用Bochs-2.4.5。
项目软件
运行结果
程序源码(.asm)
org 0x8400
;CS,DS,ES,SS默认的段基址为0000
;利用jmp指令跳过段数据的定义部分
jmp start
;其中0号默认为背景色
;[1,+]为前景色
;周炜翔,笔画数为8,8,12,取公倍数160,160,240
;si
color: db 0,255,255,255
db 2,0,0,0
;bx
startP: dw 0
dw 319
dw 63680
dw 0
;滚动条
dw 5109
dw 13110
dw 13111
dw 13112
dw 13113
dw 13114
dw 13115
dw 13116
dw 13117
dw 13118
;顶部菜单
dw 4800
dw 274
dw 289
dw 304
;顶部菜单栏
dw 2518
dw 1573
dw 1580
dw 3813
dw 1573
;子菜单
dw 8000
dw 9600
dw 11200
dw 12800
dw 14400
dw 16020
dw 4815
dw 4830
dw 8020
dw 8040
;ax
endP: dw 319
dw 63999
dw 63999
dw 63680
;滚动条
dw 63989
dw 19510
dw 19511
dw 19512
dw 19513
dw 19514
dw 19515
dw 19516
dw 19517
dw 19518
;顶部菜单栏
dw 5119
dw 5074
dw 5089
dw 5104
;顶部菜单栏
dw 2525
dw 1580
dw 3820
dw 3820
dw 3813
;子菜单
dw 8040
dw 9640
dw 11240
dw 12840
dw 14440
dw 16040
dw 8015
dw 8030
dw 16020
dw 16040
;主函数入口地址
start:
;进入13号320*200 256色的图形模式
mov ah,00h
mov al,13h
int 10h
mov si,color;赋值底色
call editcolor
;mov si,color;赋值黑色
call editcolor
;0xb800为显存的段基址
mov ax,0xa000
mov es,ax
call DrawRectangle
call DrawGundongtiao
call DrawTopmenu
call DrawTopmenuItem
call DrawSonmenuItem
e: jmp $
;编制自定义颜色
editcolor:
;设置颜色号接口0x3c8,RGB分量接口0x3c9
mov dx,0x3c8
mov al,[si]
out dx,al
mov dx,0x3c9
mov al,[si+1]
out dx,al
mov al,[si+2]
out dx,al
mov al,[si+3]
out dx,al
add si,4
ret
;横线
DrawLineOfH:
cmp bx,ax
ja DrawLineOfHExit
mov byte [es:bx], 2
inc bx
jmp DrawLineOfH
DrawLineOfHExit:
ret
;竖线
DrawLineOfV:
cmp bx,ax
ja DrawLineOfVExit
mov byte [es:bx], 2
add bx,320
jmp DrawLineOfV
DrawLineOfVExit:
ret
;外方框
DrawRectangle:
;整体框线1-----
mov bx,[ds:startP]
mov ax,[ds:endP]
call DrawLineOfH
;整体框线2|
mov bx,[ds:startP+2]
mov ax,[ds:endP+2]
call DrawLineOfV
;整体框线3-----
mov bx,[ds:startP+4]
mov ax,[ds:endP+4]
call DrawLineOfH
;整体框线4|
mov bx,[ds:startP+6]
mov ax,[ds:endP+6]
call DrawLineOfV
ret
;滚动条
DrawGundongtiao:
;滚动条丨
mov bx,[ds:startP+8]
mov ax,[ds:endP+8]
call DrawLineOfV
;里面线条
mov bx,[ds:startP+10]
mov ax,[ds:endP+10]
call DrawLineOfV
mov bx,[ds:startP+12]
mov ax,[ds:endP+12]
call DrawLineOfV
mov bx,[ds:startP+14]
mov ax,[ds:endP+14]
call DrawLineOfV
mov bx,[ds:startP+16]
mov ax,[ds:endP+16]
call DrawLineOfV
mov bx,[ds:startP+18]
mov ax,[ds:endP+18]
call DrawLineOfV
mov bx,[ds:startP+20]
mov ax,[ds:endP+20]
call DrawLineOfV
mov bx,[ds:startP+22]
mov ax,[ds:endP+22]
call DrawLineOfV
mov bx,[ds:startP+24]
mov ax,[ds:endP+24]
call DrawLineOfV
mov bx,[ds:startP+26]
mov ax,[ds:endP+26]
call DrawLineOfV
ret
;顶部菜单栏
DrawTopmenu:
mov bx,[ds:startP+28]
mov ax,[ds:endP+28]
call DrawLineOfH
mov bx,[ds:startP+30]
mov ax,[ds:endP+30]
call DrawLineOfV
mov bx,[ds:startP+32]
mov ax,[ds:endP+32]
call DrawLineOfV
mov bx,[ds:startP+34]
mov ax,[ds:endP+34]
call DrawLineOfV
ret
;顶部菜单项
DrawTopmenuItem:
mov bx,[ds:startP+36]
mov ax,[ds:endP+36]
call DrawLineOfH
mov bx,[ds:startP+38]
mov ax,[ds:endP+38]
call DrawLineOfH
mov bx,[ds:startP+40]
mov ax,[ds:endP+40]
call DrawLineOfV
mov bx,[ds:startP+42]
mov ax,[ds:endP+42]
call DrawLineOfH
mov bx,[ds:startP+44]
mov ax,[ds:endP+44]
call DrawLineOfV
ret
;顶部菜单项
DrawSonmenuItem:
mov bx,[ds:startP+46]
mov ax,[ds:endP+46]
call DrawLineOfH
mov bx,[ds:startP+48]
mov ax,[ds:endP+48]
call DrawLineOfH
mov bx,[ds:startP+50]
mov ax,[ds:endP+50]
call DrawLineOfH
mov bx,[ds:startP+52]
mov ax,[ds:endP+52]
call DrawLineOfH
mov bx,[ds:startP+54]
mov ax,[ds:endP+54]
call DrawLineOfH
mov bx,[ds:startP+56]
mov ax,[ds:endP+56]
call DrawLineOfH
mov bx,[ds:startP+58]
mov ax,[ds:endP+58]
call DrawLineOfV
mov bx,[ds:startP+60]
mov ax,[ds:endP+60]
call DrawLineOfV
mov bx,[ds:startP+62]
mov ax,[ds:endP+62]
call DrawLineOfV
mov bx,[ds:startP+64]
mov ax,[ds:endP+64]
call DrawLineOfV
ret