-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenericFuntions.asm
More file actions
84 lines (73 loc) · 1.53 KB
/
genericFuntions.asm
File metadata and controls
84 lines (73 loc) · 1.53 KB
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
; --------------------------------------------------------------;
; ;
; Exemplo de funções genéricas ;
; para operações triviais em assembly ;
; Autor: Gabriel Matheus ;
; github.com/gmsj ;
; ;
; --------------------------------------------------------------;
org 0x7c00
jmp 0x0000:start
initVideo:
mov al, 13h
mov ah, 0
int 10h
ret
putPixel:
; mov al, Cor do Pixel
; mov cx, X (0 a 319)
; mov dx, Y (0 a 199)
mov ah, 0ch
int 10h
ret
putchar: ; Label para printar
mov ah, 0eh
int 10h
ret
getchar: ; Label para ler do teclado, após a execução dessa interrupção o caractere lido estará armazenado em AL
mov ah,0
int 16h
ret
newline: ; Label para pular linha e voltar para o inicio após ler o enter
mov al, 10 ; Line Feed
call putchar
mov al, 13 ; Carriage Return
call putchar
jmp start
delChar: ; Label para deletar e voltar um espaco após ler o delete
mov al, 0x08
call putchar
mov al, ''
call putchar
mov al, 0x08
call putchar
jmp start
stoi:
xor cx, cx
xor ax, ax
.loop1:
push ax
lodsb
mov cl, al
pop ax
cmp cl, 0 ; check EOF
je .endloop1
sub cl, 48 ; '9'-'0' = 9
mov bx, 10
mul bx ; 999*10 = 9990
add ax, cx ; 9990+9 = 9999
jmp .loop1
.endloop1:
ret
start: ; Main do programa
call getchar
cmp al, 0x08
je delChar
cmp al, 0x0d
je newline
call putchar
jmp start
times 510 - ($ - $$) db 0
dw 0xaa55
; Backspace 0x08
; Enter 0x0d