-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.asm
More file actions
57 lines (42 loc) · 897 Bytes
/
input.asm
File metadata and controls
57 lines (42 loc) · 897 Bytes
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
; program to print an element at index 3 from the array
%macro print 2
; pushing register to stack, to retrieve thing back after printing
push eax
push ebx
push ecx
push edx
mov eax, 4 ; syscall number for write
mov ebx, 1 ; file descriptor (stdout)
mov ecx, %1 ; first arg ie. msg
mov edx, %2 ; second arg ie msg len
int 0x80
; retrieving register values
pop edx
pop ecx
pop ebx
pop eax
%endmacro
%macro exit 1
mov eax, 1
mov ebx, %1
int 0x80
%endmacro
section .data
msg db "Enter anything: "
msg_len equ $-msg
newline db 0xa
newline_length equ 1
section .bss
buffer resb 10
section .text
global _start
_start:
print msg, msg_len
mov eax, 3
mov ebx, 0
mov ecx, buffer
mov edx, 10
int 0x80
print buffer, 10
print newline, newline_length
exit 0