Created
December 1, 2019 08:25
-
-
Save alexsunday/bf8e783e6384dbc11f2ce646230582ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Author
alexsunday
commented
Dec 1, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment