-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintroduction NASM
82 lines (73 loc) · 2.05 KB
/
introduction NASM
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
1 Experiment No.0-Hello World!! in NASM
1 s e c t i o n . data
2
3 msg db ' He l lo World ' ,10 ; ass ign msg v a r i a b l e with your message ←֓
s t r in g
4 msglen : equ $−msg
5
6 s e c t i o n . t e x t
7 g l o b a l s t a r t
8
9 s t a r t :
10
11 mov eax , 4 ; invoke SYS WRITE ( kerne l opcode 4 )
12 mov ebx , 1 ; wr ite t o the STDOUT f i l e
13 mov ecx ,msg ; move the address o f our message s t r in g in t o ECX
14 mov edx , msglen ; move the address o f our message length in t o ECX
15 in t 80h
16
17 mov eax , 1 ; invoke SYS EXIT ( kerne l opcode 1 )
18 mov ebx , 0 ; return 0 s ta tus on e x i t − 'No Errors
19 in t 80h
20
21
22 ; ˜ $ nasm −f e l f −o h e l l ow or ld . o h e l l ow or ld . asm
23 ; ˜ $ ld −m e l f i 3 8 6 −o h e l l ow or ld h e l l ow or ld . o
24 ; ˜ $ . / hello w or ld
----------------------------------------------------------------------------------------------
2 (ALP) to display “Your name”& “Roll number” on
screen using macro
Aim :- Write an Assembly Language Program (ALP) to display “Your name”& “Roll
number” on screen using macro. Accept user input from keyboard for name and roll
number
1 s e c t i o n . data
2 msg1 db ' Enter your Name ' ,10 ; 10=Ah=0xA as next l i n e opera tor
3 len1 : equ $−msg1
4
5 msg2 db ' Enter your r o l l no . ' ,10
6 len2 : equ $−msg2
7
8 msg3 db ' Entered name & r o l l no . i s ' ,10
9 len3 : equ $−msg3
10
11 s e c t i o n . bss
12 name1 resb 10
13 r o l l n o resb 10
14
15 s e c t i o n . t e x t
16 g l o b a l s t a r t
17
18 s t a r t :
19
20 %macro rw 4
21 mov eax ,%1
22 mov ebx ,%2
23 mov ecx ,%3
24 mov edx ,%4
25 in t 80h
26 %endmacro
27
28 rw 4 ,1 ,msg1 , len1
29 rw 3 ,0 ,name1,10
30
31 rw 4 ,1 ,msg2 , len2
32 rw 3 ,0 , r o l ln o ,10
33
34 rw 4 ,1 ,msg3,10
35 rw 4 ,1 ,name1,10
36 rw 4 ,1 , r o l ln o ,10
37
38 mov eax , 1 ; The system c a l l f o r e x i t ( s y s e x i t )
39 mov ebx , 0 ; Ex it with return code o f 0 ( no e r r o r )
40 in t 80h ;
--------------------------------------------------------------------------------------------------