0

I am trying to create a login form for my OS. Like Kali Linux's SSH login. User will be shown but password won't be shown. I use int 16h / ah=0 to read key press. But I don't know taking one line input (like input() in Python) and joining two strings. I saw topics that explains joining two strings but I did not find any topics about taking one line input in Assembly. I use NASM to compile.

My code:

bits 16
org 0x7c00

mov si, loginmsg
call ps
call nl
mov si, usermsg
call ps
call nl

call inputstring

jmp $


;INPUT FUNCTION
inputstring:
    inputchar:
        mov ah, 00h
        int 16h
        ;I do not know what to do
    ret






;VARIABLES
loginmsg db 'Please login to continue...', 0
loginfailmsg db 'Wrong user or password!'
loginsuccessmsg db 'Successfuly logged in.'
usermsg db 'User: ', 0
passmsg db 'Password: ', 0
defuser db 'root'
defpass db 'root'
entereduser times 16 db 0
enteredpass times 16 db 0
indexuser db 0
indexpass db 0


;FUNCTIONS:

;BACKSPACE
bs:
    pusha
    mov al, 8 ;BACKSPACE
    mov ah, 0eh
    int 10h
    mov al, 32 ;SPACE
    mov ah, 0eh
    int 10h
    mov al, 8 ;BACKSPACE
    mov ah, 0eh
    int 10h
    popa
    ret

;NEWLINE
nl:
    pusha
    mov al, 0ah ;10
    mov ah, 0eh
    int 10h
    mov al, 0dh ;13
    mov ah, 0eh
    int 10h
    popa
    ret

;PRINTSTRING
ps:
    pusha
    ps_test:
    lodsb
    cmp al, 0h
    je ps_eof
    mov ah, 0eh
    int 10h
    jmp ps_test
    ps_eof:
    popa
    ret

times 510 - ($ - $$) db 0
dw 0xaa55
lurker
  • 56,987
  • 9
  • 69
  • 103
Nafe Bon
  • 33
  • 7
  • I could not find reading one line. I wrote that in my question. And I do not know how to concatenate two strings in NASM. – Nafe Bon Jan 11 '20 at 13:22
  • Do you mean "concatenate" strings? – lurker Jan 11 '20 at 13:24
  • Yes, my English is not good. – Nafe Bon Jan 11 '20 at 13:26
  • 1
    No worries. I figured that's what you meant. :) You can find examples of string concatenation questions in assembly on SO by searching for `[assembly] concatenate strings`. Here's one example Q&A: [Concatenate two strings](https://stackoverflow.com/questions/38828212/assembly-concatenate-two-strings). – lurker Jan 11 '20 at 13:29

0 Answers0