Files
2024-08-31 12:07:21 +03:00

30 lines
1008 B
NASM

bits 32 ; assembling for the 32 bits architecture
; declare the EntryPoint (a label defining the very first instruction of the program)
global start
; declare external functions needed by our program
extern exit ; tell nasm that exit exists even if we won't be defining it
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
; our data is declared here (the variables needed by our program)
segment data use32 class=data
; ...
s1 dw 1,10,32
l1 equ ($-s1)/2
s2 dw 0FF23h,0AF21h,0B25h
l2 equ ($-s2)/2
s resb l1+l2
e db 10
; our code starts here
segment code use32 class=code
start:
; ...
mov ax,256
mov bl,1
div bl
; exit(0)
push dword 0 ; push the parameter for exit onto the stack
call [exit] ; call exit to terminate the program