global _start
; The data section is used for declaring initialized data or constants.
; This data does not change at runtime.
; You can declare various constant values, file names or buffer size etc. in this section.
section .data
msg db 'Hello World!', 0xA, 0 ; Hello World message.
; 0xA (10) is hex for (NL), carriage return
; 0 terminates the line
msglen equ $ - msg ; length of the Hello World message.
mydate dw "06-Jan-2024 07:55 AM", 0xA ; Today's Date.
mydatelen equ $ - mydate ; Length of mydate variable.
; The bss section is used for declaring variables.
section .bss
; The text section is used for keeping the actual code.
; This section must begin with the declarationglobal main,
; which tells the kernel where the program execution begins.
section .text
_start:
; Print message "Hello World".
mov edx, msglen ; message length
mov ecx, msg ; message to write
mov ebx, 01h ; file descriptor (stdout)
mov eax, 04h ; system call number (sys_write)
int 0x80 ; call kernel
; Print current system date.
mov edx, mydatelen ; message length
mov ecx, mydate ; message to write
mov ebx, 01h ; file descriptor (stdout)
mov eax, 04h ; system call number (sys_write)
int 0x80 ; call kernel
jmp exit
exit:
mov eax, 01h ; exit()
xor ebx, ebx ; errno
int 80h
Z2xvYmFsIF9zdGFydAoKOyBUaGUgZGF0YSBzZWN0aW9uIGlzIHVzZWQgZm9yIGRlY2xhcmluZyBpbml0aWFsaXplZCBkYXRhIG9yIGNvbnN0YW50cy4gCjsgVGhpcyBkYXRhIGRvZXMgbm90IGNoYW5nZSBhdCBydW50aW1lLiAKOyBZb3UgY2FuIGRlY2xhcmUgdmFyaW91cyBjb25zdGFudCB2YWx1ZXMsIGZpbGUgbmFtZXMgb3IgYnVmZmVyIHNpemUgZXRjLiBpbiB0aGlzIHNlY3Rpb24uCnNlY3Rpb24gLmRhdGEKCW1zZyAJCWRiICdIZWxsbyBXb3JsZCEnLCAweEEsIDAJCTsgSGVsbG8gV29ybGQgbWVzc2FnZS4gCgkJCQkJCQkJCQkJCTsgMHhBICgxMCkgaXMgaGV4IGZvciAoTkwpLCBjYXJyaWFnZSByZXR1cm4KCQkJCQkJCQkJCQkJOyAwIHRlcm1pbmF0ZXMgdGhlIGxpbmUKCW1zZ2xlbiAJCW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