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 ; Hello World message.
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
Z2xvYmFsIF9zdGFydAoKOyBUaGUgZGF0YSBzZWN0aW9uIGlzIHVzZWQgZm9yIGRlY2xhcmluZyBpbml0aWFsaXplZCBkYXRhIG9yIGNvbnN0YW50cy4gCjsgVGhpcyBkYXRhIGRvZXMgbm90IGNoYW5nZSBhdCBydW50aW1lLiAKOyBZb3UgY2FuIGRlY2xhcmUgdmFyaW91cyBjb25zdGFudCB2YWx1ZXMsIGZpbGUgbmFtZXMgb3IgYnVmZmVyIHNpemUgZXRjLiBpbiB0aGlzIHNlY3Rpb24uCnNlY3Rpb24gLmRhdGEKCW1zZyAJCWRiICdIZWxsbyBXb3JsZCEnLCAweGEJCQk7IEhlbGxvIFdvcmxkIG1lc3NhZ2UuCgltc2dsZW4gCQllcXUgJCAtIG1zZwkJCQkJCTsgbGVuZ3RoIG9mIHRoZSBIZWxsbyBXb3JsZCBtZXNzYWdlLgoJbXlkYXRlIAkJZHcgIjA2LUphbi0yMDI0IDA3OjU1IEFNIiwgMHhhCTsgVG9kYXkncyBEYXRlLgoJbXlkYXRlbGVuC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