hey all,

im trying to compare two strings 8 characters long, the first was predefined and the second was entered by the user. i tried used (cmpsb) instruction and byte by byte comparison, but both failed

its for a project that requires a student to enter their number and password, then outputs the courses a student should take.

i've figured the the BX register is not loaded the right value, also im not sure my variable declaration for input is right.

please take a look at the highlighted code

thanks in advnace

.MODEL SMALL
.STACK 100H
.DATA

st1	db 13,10,"You are a first-year student; you should register MATH 141, COMP142, ENGC 101.$"
st2	db 13,10,"You are a second-year student; you should register ENCS 234, COMP 231, ENEE 231.$"
st3	db 13,10,"You are a third-year student; you should register ENCS 331, COMP 333, ENEE 331.$"
st4	db 13,10,"You are a fourth-year student; you should register ENCS 432, COMP 433, MATH 331.$"
st5	db 13,10,"You are a fifth-year student; you should register ENCS 535, ENCS 536, ENCS 539.$"

mess1	db 13,10,"Enter Student Number:$"
mess2	db 13,10,"Enter Password:$"

pass	db "word1234"

stdnum	db 8 dup (' ')
stdpas	db 8 dup (' ')

.code

start:

	call setscr			;set screen


	mov	Ax, @data
	mov	ds, Ax

	
	mov	dx, offset mess1	;print "Enter Student Number"
	call	prnt

	mov	ah, 0ah			;take input for student number
	mov	dx, offset stdnum
	int	21h


	mov	dx, offset mess2	;print "Enter Password"
	call	prnt 

	mov	ah, 0ah			;take input for student password
	mov	dx, offset stdpas
	int	21h	

	call	cmppass	




	mov AH, 4cH
	int 21H

; ------------------------ print functions ------------------------


prnt: 

	mov ah, 09h
	int 21h
	ret

prntst1:				;print 1st year courses

	mov dx, offset st1
	call prnt
	ret	

prntst2:				;print 2nd year courses

	mov dx, offset st2
	call prnt	
	ret

prntst3:				;print 3rd year courses

	mov dx, offset st3
	call prnt	
	ret

prntst4:				;print 4th year courses

	mov dx, offset st4
	call prnt	
	ret

prntst5:				;print 5th year courses

	mov dx, offset st5
	call prnt	
	ret

; ----------------------- compare functions -----------------------

cmppass:


	mov	ax, @data
	mov	bx, @data
	mov	al, [pass]
	mov	bl, [stdpas]
    mov dx, 0
	mov	cx, 8
	
C20:	
    
    cmp	al,bl
	jne	noteq
	
	inc	al
	inc	bl
	dec	cx
	cmp	cx, 0
	jne	c20
	
	

	call	prntst1

	
ret


noteq:

	call	prntst3
	ret


; --------------- set screen, set color and set cursor --------------

setscr:

	mov ax, 0600H
	mov cx, 0        
	mov dx, 184FH    
	mov bh, 7
	int 10H

        mov ah,06H      
        mov al,00H      
        mov bh,89H     	;green background and red forground
        mov cx,0    	
        mov dx,184FH    
        int 10H

        mov ah,2      	;set cursor
        mov dh,02H      ;row number
        mov dl,00H      ;column number
        mov bh,0        ;page number
        int 10H

	ret




end start

Recommended Answers

All 3 Replies

are you BZU ??

may we help each other :)

add me

<snip email>

What's the point of all those prntst# functions?...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.