【开发流程】
【demo1】
use32
START:
pusha
call demo1
popa
iret
;print string at specified coordinate, e.g y=10 and x=2
demo1:
pusha
mov esi,hello_text
mov ebx, 10
mov ecx, 2
call print_string
popa
ret
;print string
;input:
; esi: address to string
; ebx: y position to print
; ecx: x position to print
print_string:
pusha
xor eax, eax
imul edi, ebx, 80*2
add edi, ecx
add edi, ecx
mov ah, 0x0F
.next_char:
lodsb
cmp al, 0
je .end
mov word [gs:edi], ax
add edi, 2
jmp .next_char
.end:
popa
ret
hello_text db 'Hello world!',0
【demo2】
use32
START:
pusha
call demo2
popa
iret
cursor_x equ 0x02004B10
cursor_y equ 0x02004B12
;print string at current cursor position which is readed from OS
demo2:
pusha
mov esi,hello_text
movzx ebx, word [fs:cursor_y]
movzx ecx, word [fs:cursor_x]
call print_string
add word [fs:cursor_y], 1
popa
ret
;print string
;input:
; esi: address to string
; ebx: y position to print
; ecx: x position to print
print_string:
pusha
xor eax, eax
imul edi, ebx, 80*2
add edi, ecx
add edi, ecx
mov ah, 0x0F
.next_char:
lodsb
cmp al, 0
je .end
mov word [gs:edi], ax
add edi, 2
jmp .next_char
.end:
popa
ret
hello_text db 'Hello world!',0