-
Notifications
You must be signed in to change notification settings - Fork 16
/
c07-02.asm
84 lines (61 loc) · 1.1 KB
/
c07-02.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
[org 0x0100]
jmp start
message: db 'hello world'
length: dw 11
clrscr:
push es
push ax
push di
mov ax, 0xb800
mov es, ax
mov di, 0
nextloc:
mov word [es:di], 0x0720
add di, 2
cmp di, 4000
jne nextloc
pop di
pop ax
pop es
ret
printstr:
push bp
mov bp, sp
push es
push ax
push cx
push si
push di
mov ax, 0xb800
mov es, ax
mov di, 0
mov si, [bp + 6]
mov cx, [bp + 4]
mov ah, 0x07 ; only need to do this once
nextchar:
mov al, [si]
mov [es:di], ax
add di, 2
add si, 1
; dec cx
; jnz nextchar
; alternatively
loop nextchar
pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 4
start:
call clrscr
mov ax, message
push ax
push word [length]
call printstr
; wait for keypress
mov ah, 0x1 ; input char is 0x1 in ah
int 0x21
mov ax, 0x4c00
int 0x21