Two 8086 Assembly Language Questions..

Hi Friends,

can anyone help me with this : Please check if it i s correct.

1>Write a 8086 assembly language subroutine that can be used for passward matching.

Interface/call this subroutine from a C program.

Here is my solution :

;ALGORITHM :

=> Initialise variables
=> accept password
=> check password
=> If password correct then display message
"You are allowed to access all facilities"
else display "Please try again"


;REGISTERS : Uses CS, DS, ES, AX, DX, CX, SI, DI

DATA SEGMENT

PASSWORD DB 'FAILSAFE' ; Source String

PASSWORD DB 'FEELSAFE' ; Destination String

MESSAGE DB 'You are allowed to access all facilities'

MESSAGE1 DB 'Please try again'


DATA ENDS

CODE SEGMENT

ASSUME CS : CODE, DS : DATA, ES : DATA

MOV AX, DATA

MOV DX, AX ; Initialise data segment register ; as destination
string is
; considered to be in extra
; segment

LEA SI, PASSWORD ; Load source pointer

LEA DI, DESTSTR ; Load destination pointer

MOV CX, 08 ; Load counter with string length

CLD ; Clear direction flag

REPE CMPSB ; Compare the 2 strings
; byte by byte

JNE NOTEQUAL ; If not equal, jump to
; NOTEQUAL

MOV AH, 09 ;else display message

MOV DX, OFFSET MESSAGE;

INT 21h ; Display the message

NOTEQUAL : MOV AX,4C00h ; interrupt function to halt

INT 21h

CODE ENDS

END START




__________________________________________________________________


The above code can be written in C and interfaced with parameter passing as
follows:


PUBLIC PASSWD

.MODEL small, C

.CODE

PASSWD PROC switch : word


MOV AX, DATA

MOV DX, AX ; Initialise data segment register ; as destination
string is
; considered to be in extra
; segment

LEA SI, PASSWORD ; Load source pointer

LEA DI, DESTSTR ; Load destination pointer

MOV CX, 08 ; Load counter with string length

CLD ; Clear direction flag

REPE CMPSB ; Compare the 2 strings
; byte by byte

JNE NOTEQUAL ; If not equal, jump to
; NOTEQUAL

MOV AH, 09 ;else display message

MOV DX, OFFSET MESSAGE;

INT 21h ; Display the message

NOTEQUAL : MOV AX,4C00h ; interrupt function to halt

INT 21h

PASSWD ENDP

END



The C program to test the above code is as follows

#include

int passwd(char pass[]);

main()

{
char pass[8];
int val=0;

printf("Enter password:");
scanf("%s" , pass);
fflush(stdin);

val = passwd(pass);

if(val=0)
printf("Please try again...");
else
printf("You are allowed to access all facilities...");

}

int passwd(char *s1)
{

char pass1[]= {"FAILSAFE"};
char pass2[]= {"FEELSAFE"};

char *s2, *s3;
s2=pass1;
s3=pass2;

printf("Checking Password.........");

while((*s1 == *s2) || (*s1 == *s3))
{
if((*s1 == '') || (*s2 == '') || (*s3 == ''))
return (0);

s1++;
s2++;
s3++;

}

return (1);
}



I am unable to find a solution for the following :


2>Write a program in 8086 assembly language that accept two floating point numbers from the screen in format:

ddddEsee

where,

dddd are four decimal digits

E is exponent symbol

s is sign

ee contains exponent value.

A decimal is assumed prior to four decimal digits.For example a number 45 in the above format will be:4500E+02.The program adds the two numbers if the exponent value is same,otherwise issues an error message"Exponent does not match".


Thanks,

Madhumita

Comments

  • : Hi Friends,
    :
    : can anyone help me with this : Please check if it i s correct.
    :
    : 1>Write a 8086 assembly language subroutine that can be used for passward matching.
    :
    : Interface/call this subroutine from a C program.
    :
    : Here is my solution :
    :
    : ;ALGORITHM :
    :
    : => Initialise variables
    : => accept password
    : => check password
    : => If password correct then display message
    : "You are allowed to access all facilities"
    : else display "Please try again"
    :
    : [code]
    : ;REGISTERS : Uses CS, DS, ES, AX, DX, CX, SI, DI
    :
    : DATA SEGMENT
    :
    : PASSWORD DB 'FAILSAFE' ; Source String
    :
    : PASSWORD DB 'FEELSAFE' ; Destination String
    :
    : MESSAGE DB 'You are allowed to access all facilities[b][red]$[/red][/b]'
    :
    : MESSAGE1 DB 'Please try again[b][red]$[/red][/b]'
    :
    [blue]Every message which goes to screen by function AH=9 INT 21H
    should terminate with a symbol '$'.[/blue]
    :
    : DATA ENDS
    :
    : CODE SEGMENT
    :
    : ASSUME CS : CODE, DS : DATA, ES : DATA
    :
    : MOV AX, DATA
    :
    : MOV D[b][red]S[/red][/b], AX ; Initialise data segment register
    ; as destination string is
    : ; considered to be in extra
    : ; segment [blue]Not DX, but DS, also load the same value into
    ES, because just ASSUME does not do it![/blue]
    [b][red]MOV ES, AX[/red][/b]
    :
    : LEA SI, PASSWORD ; Load source pointer
    :
    : LEA DI, DESTSTR ; Load destination pointer
    :
    : MOV CX, 08 ; Load counter with string length
    :
    : CLD ; Clear direction flag
    :
    : REPE CMPSB ; Compare the 2 strings
    : ; byte by byte
    :
    : JNE NOTEQUAL ; If not equal, jump to
    : ; NOTEQUAL
    :
    : MOV AH, 09 ;else display message
    :
    : MOV DX, OFFSET MESSAGE;
    :
    : INT 21h ; Display the message
    :
    : NOTEQUAL : MOV AX,4C00h ; interrupt function to halt
    :
    : INT 21h
    :
    : CODE ENDS
    :
    : END START
    : [/code]
    :
    :
    :
    : __________________________________________________________________
    :
    :
    : The above code can be written in C and interfaced with parameter passing as
    : follows:
    :
    :
    : PUBLIC PASSWD
    :
    : .MODEL small, C
    :
    : .CODE
    :
    : PASSWD PROC switch : word
    :
    :
    : MOV AX, DATA
    :
    : MOV DX, AX ; Initialise data segment register ; as destination
    : string is
    : ; considered to be in extra
    : ; segment
    :
    : LEA SI, PASSWORD ; Load source pointer
    :
    : LEA DI, DESTSTR ; Load destination pointer
    :
    : MOV CX, 08 ; Load counter with string length
    :
    : CLD ; Clear direction flag
    :
    : REPE CMPSB ; Compare the 2 strings
    : ; byte by byte
    :
    : JNE NOTEQUAL ; If not equal, jump to
    : ; NOTEQUAL
    :
    : MOV AH, 09 ;else display message
    :
    : MOV DX, OFFSET MESSAGE;
    :
    : INT 21h ; Display the message
    :
    : NOTEQUAL : MOV AX,4C00h ; interrupt function to halt
    :
    : INT 21h
    :
    : PASSWD ENDP
    :
    : END
    :
    :
    :
    : The C program to test the above code is as follows
    :
    : #include
    :
    : int passwd(char pass[]);
    :
    : main()
    :
    : {
    : char pass[8];
    : int val=0;
    :
    : printf("Enter password:");
    : scanf("%s" , pass);
    : fflush(stdin);
    :
    : val = passwd(pass);
    :
    : if(val=0)
    : printf("Please try again...");
    : else
    : printf("You are allowed to access all facilities...");
    :
    : }
    :
    : int passwd(char *s1)
    : {
    :
    : char pass1[]= {"FAILSAFE"};
    : char pass2[]= {"FEELSAFE"};
    :
    : char *s2, *s3;
    : s2=pass1;
    : s3=pass2;
    :
    : printf("Checking Password.........");
    :
    : while((*s1 == *s2) || (*s1 == *s3))
    : {
    : if((*s1 == '') || (*s2 == '') || (*s3 == ''))
    : return (0);
    :
    : s1++;
    : s2++;
    : s3++;
    :
    : }
    :
    : return (1);
    : }
    :
    :
    :
    : I am unable to find a solution for the following :
    :
    :
    : 2>Write a program in 8086 assembly language that accept two floating point numbers from the screen in format:
    :
    : ddddEsee
    :
    : where,
    :
    : dddd are four decimal digits
    :
    : E is exponent symbol
    :
    : s is sign
    :
    : ee contains exponent value.
    :
    : A decimal is assumed prior to four decimal digits.For example a number 45 in the above format will be:4500E+02.The program adds the two numbers if the exponent value is same,otherwise issues an error message"Exponent does not match".
    :
    :
    : Thanks,
    :
    : Madhumita
    :

  • I'm sorry, your last post appeared to be attempting to break the
    password bit code held in CMOS & the only reason to ever do that
    is if it's some one elses computer.
    Your new code post shows my mistake.
    You have two identical labels in your code.

    PASSWORD DB 'FAILSAFE' ; Source String
    PASSWORD DB 'FEELSAFE' ; Destination String

    Bitdog

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories