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