Reputation: 8958
I'm learning assembly (NASM) and using the Linux system calls.
I'm having a problem with the following code. I am attempting to call sys_mkdir
. A directory "Hello World" should be created. But, instead it's creating the following Hello World?asmtest??
. Why is this? How is the title
being included and how do I remove the ?
.
SECTION .data
msg: db "Hello World", 10
len: equ $-msg
title: db "asmtest", 7
mode: dd 755
SECTION .text
global main
main:
; Make a directory
mov ecx,mode
mov ebx,msg
mov eax,39
int 0x80
; Print Hello World to screen
mov edx,len
mov ecx,msg
mov ebx,1
mov eax,4
int 0x80
; Exit
mov ebx,0
mov eax,1
int 0x80
Upvotes: 1
Views: 1168
Reputation: 16361
In this case, the function call that you are accessing is a system call. While it's not part of the C standard library, the handling of strings in this call (and many like it) are very "C like", meaning that byte strings are always null terminated.
In your case, since you define two strings (with some special characters in between, like "10" and "7"), it will use everything from the very first character found at the memory location that msg
points to and keep going until it happens to find a null byte (00
).
If you replace your , 10
with , 0
the sys_mkdir
will function properly, but you will have to adjust that byte for your print function to work properly.
Upvotes: 5