Skip to content

Commit 3352c1f

Browse files
authored
Add a newline to the hello, world! example to avoid confusion (#78)
* asm-1: added a newline after the "Hello, world!" * hello: added a newline after the "Hello, world!"
1 parent 575898c commit 3352c1f

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

content/asm_1.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ Let's write our first assembly program based on this code sample:
142142
```assembly
143143
;; Definition of the `data` section
144144
section .data
145-
;; String variable with the value `hello world!`
146-
msg db "hello, world!"
145+
;; String variable with the value `hello world!`.
146+
;; `10` is the ASCII code for the line feed character (LF), i.e., '\n'.
147+
msg db "hello, world!", 10
147148
148149
;; Definition of the text section
149150
section .text
@@ -158,8 +159,8 @@ _start:
158159
mov rdi, 1
159160
;; Set the second argument of `sys_write` to the reference of the `msg` variable.
160161
mov rsi, msg
161-
;; Set the third argument of `sys_write` to the length of the `msg` variable's value (13 bytes).
162-
mov rdx, 13
162+
;; Set the third argument of `sys_write` to the length of the `msg` variable's value (14 bytes).
163+
mov rdx, 14
163164
;; Call the `sys_write` system call.
164165
syscall
165166

hello/hello.asm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
;; Definition of the `data` section
22
section .data
3-
;; String variable with the value `hello world!`
4-
msg db "hello, world!"
3+
;; String variable with the value `hello world!`.
4+
;; `10` is the ASCII code for the line feed character (LF), i.e., '\n'.
5+
msg db "hello, world!", 10
56

67
;; Definition of the text section
78
section .text
@@ -16,8 +17,8 @@ _start:
1617
mov rdi, 1
1718
;; Set the second argument of `sys_write` to the reference of the `msg` variable.
1819
mov rsi, msg
19-
;; Set the third argument of `sys_write` to the length of the `msg` variable's value (13 bytes).
20-
mov rdx, 13
20+
;; Set the third argument of `sys_write` to the length of the `msg` variable's value (14 bytes).
21+
mov rdx, 14
2122
;; Call the `sys_write` system call.
2223
syscall
2324

@@ -26,4 +27,4 @@ _start:
2627
;; Set the first argument of `sys_exit` to 0. The 0 status code is success.
2728
mov rdi, 0
2829
;; Call the `sys_exit` system call.
29-
syscall
30+
syscall

0 commit comments

Comments
 (0)