I am trying to format a user input first and last name as "Lastname, Firstname" Thank you in Advance

This is what I have so far. I have 90% of what I am trying to do just can't figure out how to properly format into "Lastname, Firstname" I am super new to assembly so I apologize if it is not perfect

global  _main
extern  _printf
extern  _scanf
extern  _fgets
extern  _TrimRight
extern  ___acrt_iob_func
extern  _ExitProcess@4

section .bss
Name: resw 1    ; Reserve space for your first name and last name values


section .data
prompt: db 'Enter Name: ',0
output: db 'Your Name is: .', 0ah,0
frmt:   db '%d',0   ; Define your format strings here

section .text
_main:

        push   prompt       ;  push the prompt string and call printf
        call   _printf
        add    esp, 4       ;  restore the stack pointer

        ; scanf("%d", Name);
        push   Name         ;  push the scanf parameters and call scanf
        push   frmt
        call   _scanf       
        add    esp, 8       ;  restore the stack pointer

        
       
BEGIN:    

        
        push  ecx
        push  dword [Name]
        push  dword [Name]
        
        push  output
        call  _printf
        add   esp, 8
        pop   ecx

        ; exit the program
        xor    ecx, ecx
        call    _ExitProcess@4


from Recent Questions - Stack Overflow https://ift.tt/3t24aci
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation