format elf64
section '.data'

Message db 'Fried',0
SearchTerm dq 'a'			; optional character to search for. instead of getting length of entire string.
ResultMessage db '%d',10,0
Result dq 1
formatofstring db '%d',0

section '.bss' writable


section '.text' executable
extrn stdin
extrn fgets
extrn printf
extrn scanf
public main

; -------------        
main:

        push rbp
        mov rbp, rsp

mov rdx, [stdin]	;rdx


; -------------
nop
;mov rax, Message
lea rdi, [Message]
;xor rcx, rcx
mov rcx, 55
mov rax, 0
;lodsb
cld				;rdi will decrement because direction flag is 0
repnz scasb
sub rcx, 55
neg rcx
dec rcx
;dec rcx
mov qword [Result], rcx

;mov rdx, [stdio]

;mov rdi, Result		;1
;mov rsi, formatofstring		;2
;mov rdx, rcx
;call sprintf


;mov rdx, [stdin]
; -------------
; want to make sure no other parameters are passed to printf:
mov rdx, 0
mov rcx, 0
mov r8, 0
mov r9, 0
xor esi, esi

; ------------
; print it?

mov rdi, ResultMessage
mov qword rsi, [Result]
xor eax, eax
call printf

; clear stack frame
        mov rsp, rbp
        pop rbp
ret
