Skip to content

Instantly share code, notes, and snippets.

@alexsunday
Created November 25, 2019 09:08
Show Gist options
  • Save alexsunday/f372946e8f7f6a803cb152cbb27e6409 to your computer and use it in GitHub Desktop.
Save alexsunday/f372946e8f7f6a803cb152cbb27e6409 to your computer and use it in GitHub Desktop.
assume cs:code, ds:data, ss:stack
data segment
db 'welcome to masm!'
data ends
stack segment stack
db 128 dup (0)
stack ends
; 在屏幕中间分别显示 绿色、绿底红色、白底蓝色 字符串 welcome to masm! 字符串16字节
; 绿色为2,绿底红色为 24H,白底蓝色 71H
; 屏幕共 25行,80 列,第1行为 B800 起始 第N行起始为 (n-1) * 2 * 80,中间为第12、13、14 行
; 屏幕共80列,则字符串起始为 2s + 16 = 80, s = 32, 则目标地址应为 (n - 1) * 2 * 80 + 32 * 2
; 内存地址空间中, B8000H ~ BFFFFH 共 32K的空间,为显示缓冲区
; 偶数低地址 存放显示字符 ASCII 码,奇数高地址存放 字符属性
; 字符属性占用1个字节,8位编号如下
; 0000 0000 / 7654 3210
; 7654 3210
; _rgb _rgb 背景 前景 第7位为闪烁、第三位为高亮
code segment
start:
mov ax, stack
mov ss, ax
mov sp, 128
mov ax, data
mov ds, ax
mov ax, 0B800H
mov es, ax
; 第12行
mov bx, 0
mov si, 0
mov cx, 16
cpLine:
; mov si, (12 - 1) * 2 * 80 + 32 * 2
mov al, ds:[bx]
mov es:[si + 720H], al
mov byte ptr es:[ si + 720H + 1], 2
mov al, ds:[bx]
mov es:[si + 7C0H], al
mov byte ptr es:[ si + 7C0H + 1], 24H
mov al, ds:[bx]
mov es:[si + 860H], al
mov byte ptr es:[ si + 860H + 1], 71H
inc bx
add si, 2
loop cpLine
mov ax, 4c00H
int 21H
code ends
end start
@alexsunday
Copy link
Author

图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment