Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

tasm assembly language create a program that will require password that is maske

ID: 3875796 • Letter: T

Question

tasm assembly language

create a program that will require password that is masked and will perform addition and subtraction

if incorrect, ask for another trial up to 3 times. If reached 3 times, display

"Exceeded number of trials"

the character entered should be masked

ask for at least 4 digit password

options:
a. Perform arithmetic operation
b. provide ascending letters from the letter of choice
c. exit


if choice is a
1. addition
2. subtraction

if choice is 1:
input 1st number: (validation, number only 0-9, if not display "invalid")

input 2nd number: validation

display the sum

if choice is 2:
same with number 1

after displaying, exit

if choice is b
ask for a letter (with validation, small letters only, do not accept capital letters and numbers) - if not display "INVALID"

if z, display "Z"
if 'b' display "B, C, D, E, ... Z"
if 's', display "S, T, U, ... Z"


for clear screen
mov al, 03
int 10h

Explanation / Answer

Password checking

.model small

.stack 100h

.data

                            arr dq 0000003h,00000002h

        n equ 2

                              USRNM   DB"Enter Username:$"

                                PWRD    DB "Enter Password:$"

                                Ara         DB 30h

                                ULIT      DB 30h

                                E                DB "Username and Password did not match!$"

                                PASSACC DB"Username and Password Accepted!$"

.Code

start:

                                mov ax,1h

                                mov ds,ax

ULIT2: mov ax,2h

                                int 10h

                                mov ah,2h

                                mov dx,0405h

                                int 10h

                                mov ah,9h

                                mov dx,offset USRNM

                                int 21h

                                mov ah,1h

                                int 21h

                                cmp al,61h

                                int 21h

                                cmp al,74h

                                int 21h

                                cmp al,75h

                                int 21h

                                cmp al,73h

                                int 21h

                                jle OK

                                ULIT1: jne ULIT2

                                ERR1:    mov cx,20

                                                                int 21h

                                                                cmp al,1fh

                                                                jle PASSWORD

                                OK:         inc Ara

                                PASSWORD:           mov ah,2h

                                                                                                mov dx,650h

                                                                                                int 10h

                                                                                                mov ah,9h

                                                                                                mov dx,offset PWRD

                                                                                                int 21h

                                                                                                mov ah,1h

                                                                                                int 21h

                                                                                                cmp al,43h

                                                                jne ERR2

                                                                int 21h

                                                                cmp al,4fh

                                                                jne ERR2

                                                                int 21h

                                                                cmp al,41h

                                                                jne ERR2

                                                                int 21h

                                                                cmp al,52h

                                                                jne ERR2

                                                                int 21h

                                                                cmp al,43h

                                                                jne ERR2

                                                                int 21h

                                                                cmp al,1fh

                                                                jle OK2

                                                                ERR2:   mov cx,20h

                                                                                                int 21h

                                                                                                cmp al,1fh

                                                                                                jle OKNBA

                                                                                                loop ERR2

                                                                OK2:      inc Ara

                                                                OKNBA: cmp Ara,32h

                                                                                                je OKNA

                                                                                                inc ULIT

                                                                                                mov ah,2h

                                                                mov dx,080ah

                                                                int 10h

                                                                mov ah,9h

                                                                mov dx,offset E

                                                                int 21h

                                                                cmp ULIT,3

                                                                jne ULIT1

                                                                mov ah,4ch

                                                                int 21h

                                                                ret

                                                                OKNA:   mov ah,2h

                                                                mov dx,080ah

                                                                int 10h

                                                                mov ah,9h

                                                                mov dx,offset PASSACC

                                                                int 21h

                                                                int 20h

Choice Menu:

       

        menu db 10d,13d,"**********MENU**********"

             db 10d,13d,"1. Addition"

             db 10d,13d,"2. Subtraction"

            

             db 10d,13d,"5. Exit"

             db 10d,13d,"Enter your Choice: "

        menu_len equ $-menu

        m1 db 10d,13d,"Addition: "

        l1 equ $-m1

        m2 db 10d,13d,"Substraction: "

        l2 equ $-m2

       

section .bss

        answer resb 8                            ;to store the result of operation

        choice resb 2

section .text

        global _start:

        _start:

        up: scall 4,1,menu,menu_len

                            scall 3,0,choice,2

                   

        cmp byte[choice],'1'

        je case1

        cmp byte[choice],'2'

        je case2

        cmp byte[choice],'3'

        je case3

                   

                   

        case1: scall 4,1,m1,l1

                call addition

                jmp up           

                                        

        case2:                     scall 4,1,m2,l2

                            call substraction

                            jmp up

        case5: mov eax,1

                               mov ebx,0

                int 80h           

addition:

        mov ecx,n

        dec ecx                  

        mov esi,arr

        mov eax,[esi]

up1:    add esi,8

        mov ebx,[esi]

        add eax,ebx

        loop up1               

        call display

ret

                   

                   

substraction:

                   

        mov ecx,n

        dec ecx                  

        mov esi,arr

        mov eax,[esi]

up2:    add esi,8

        mov ebx,[esi]

        sub eax,ebx

        loop up2               

        call display           

ret

                                        

display:

        mov esi,answer+7

        mov ecx,8

cnt:    mov edx,0

        mov ebx,16

        div ebx

        cmp dl,09h

        jbe add30

        add dl,07h

add30: add dl,30h

        mov [esi],dl

        dec esi

        dec ecx

        jnz cnt

        scall 4,1,answer,8

ret

endstar