This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdio.asm
113 lines (90 loc) · 1.64 KB
/
stdio.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
global clearscreen
clearscreen:
push bp
mov bp, sp
pusha
mov ah, 0x07 ; tells BIOS to scroll down window
mov al, 0x00 ; clear entire window
mov bh, [bp+4] ; white on black
mov cx, 0x00 ; specifies top left of screen as (0,0)
mov dh, [bp+6] ; 18h = 24 rows of chars
mov dl, [bp+8] ; 4fh = 79 cols of chars
int 0x10 ; calls video interrupt
popa
mov sp, bp
pop bp
ret
global movecursor
movecursor:
push bp
mov bp, sp
pusha
mov dx, [bp+4] ; get the argument from the stack. |bp| = 2, |arg| = 2
mov ah, 0x02 ; set cursor position
mov bh, 0x00 ; page 0 - doesn't matter, we're not using double-buffering
int 0x10
popa
mov sp, bp
pop bp
ret
global scanc
scanc:
push bp
mov bp, sp
mov ah, 00h
int 16h
mov sp, bp
pop bp
ret
global cursorpos
cursorpos:
push bp
mov bp, sp
push ax
push bx
mov ah, 0x03
mov bh, 0
int 10h
pop bx
pop ax
mov sp, bp
pop bp
ret
global offsetcursor
offsetcursor:
push bp
mov bp, sp
push ax
push dx
call cursorpos
mov ah, [bp+4]
mov al, [bp+5]
add dh, ah
add dl, al
push dx
call movecursor
pop dx
pop dx
pop ax
mov sp, bp
pop bp
ret
global offsetcursornegative
offsetcursornegative:
push bp
mov bp, sp
push ax
push dx
call cursorpos
mov ah, [bp+4]
mov al, [bp+5]
sub dh, ah
sub dl, al
push dx
call movecursor
pop dx
pop dx
pop ax
mov sp, bp
pop bp
ret