Skip to content

Instantly share code, notes, and snippets.

@alexsunday
Created December 1, 2019 08:25
Show Gist options
  • Save alexsunday/bf8e783e6384dbc11f2ce646230582ac to your computer and use it in GitHub Desktop.
Save alexsunday/bf8e783e6384dbc11f2ce646230582ac to your computer and use it in GitHub Desktop.
assume cs:code,ds:data,ss:stack
data segment
db 'Hello, World',0
data ends
stack segment stack
db 128 dup(0)
stack ends
code segment
start:
mov ax, stack
mov ss, ax
mov sp, 128
mov ax, data
mov ds, ax
mov dh, 8
mov dl, 3
mov cl, 00000010B
mov si, 0
call show_str
jmp quit
show_str:
; 显示字符串,show_str 在指定位置,使用指定颜色,显示0结尾的字符串
; dh 行号,dl 列号,cl 颜色 ds:si 指向字符串首地址
; 0 行 第0列 偏移为 0
; 1 行 第0列 偏移为 160 第 N 行 m 列,偏移为 160 * n + 2 * m
mov ax, 0B800H
mov es, ax
; 计算首地址 di
mov al, dh
mov ah, 160
mul ah
push ax
mov al, dl
mov ah, 2
mul ah
pop di
add di, ax
mov ah, cl
mov cx, 0
show_byte:
mov al, ds:[si]
mov es:[di], ax
mov cl, al
jcxz show_end
inc si
add di, 2
jmp show_byte
show_end:
ret
quit:
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