72 lines
965 B
NASM
72 lines
965 B
NASM
;------------------------------------------
|
|
; int slen(String message)
|
|
; String length calculation function
|
|
slen:
|
|
push ebx
|
|
mov ebx, eax
|
|
|
|
nextchar:
|
|
cmp byte [eax], 0
|
|
jz finished
|
|
inc eax
|
|
jmp nextchar
|
|
|
|
finished:
|
|
sub eax, ebx
|
|
pop ebx
|
|
ret
|
|
|
|
|
|
|
|
;------------------------------------------
|
|
; void sprint(String message)
|
|
; String printing function
|
|
sprint:
|
|
push edx
|
|
push ecx
|
|
push ebx
|
|
push eax
|
|
call slen
|
|
|
|
mov edx, eax
|
|
pop eax
|
|
|
|
mov ecx, eax
|
|
mov ebx, 1
|
|
mov eax, 4
|
|
int 80h
|
|
|
|
pop ebx
|
|
pop ecx
|
|
pop edx
|
|
ret
|
|
|
|
|
|
|
|
;------------------------------------------
|
|
; void sprintLF(String message)
|
|
; String printing with line feed function
|
|
sprintLF:
|
|
call sprint
|
|
|
|
push eax
|
|
mov eax, 0Ah
|
|
push eax
|
|
|
|
mov eax, esp
|
|
call sprint
|
|
pop eax
|
|
pop eax
|
|
ret
|
|
|
|
|
|
|
|
;------------------------------------------
|
|
; void exit()
|
|
; Exit program and restore resources
|
|
quit:
|
|
mov ebx, 0
|
|
mov eax, 1
|
|
int 80h
|
|
ret
|