Link to home
Start Free TrialLog in
Avatar of yasmeens
yasmeens

asked on

Help with Assembly Language Program

I have an assignment for my Machine Language class, which I am having problems with.  The book that we are working from is Assembly language for intel-based computers.
I have actually never been able to get my programs to compile at all, and I have no clue what I am doing wrong.
Our assignment was to write a program that asks the user to enter an integer test score between 0 to 100.  The program should display the appropriate letter grade:
Score                          Letter Grade
90 to 100                      A
89 to 80                          B
79 to 70                          C
69 to 60                          D
59 to 0                            F
I wrote a program (code is attached in a snippet) but when I attempt to compile, I get the following errors:
Assembling: program4.asm
program4.asm(11) : error A2008: syntax error : kybdData
program4.asm(32) : error A2006: undefined symbol : kybdData
program4.asm(41) : error A2006: undefined symbol : kybdData
program4.asm(47) : error A2006: undefined symbol : kybdData
program4.asm(53) : error A2006: undefined symbol : kybdData
program4.asm(59) : error A2006: undefined symbol : kybdData
program4.asm(65) : error A2006: undefined symbol : kybdData
program4.asm(71) : error A2006: undefined symbol : ERRS
program4.asm(19) : error A2006: undefined symbol : DGROUP
program4.asm(29) : error A2006: undefined symbol : kybdData
program4.asm(77) : warning A4023: with /coff switch, leading underscore required
 for start address : main

I don't know if this is relevant, but I have been editing and saving my ASM files in VIsual C++ 2005 Edition, but for some reason I cannot register, so I created and edited this file in Notepad++.
Can someone please let me know where I am going wrong?  I get the concepts and when I do my homework, I understand, but somehow applying that knowledge to my code is not working for me with this class.  
TITLE InterpretScore        (program4.asm)

.MODEL small
.STACK 100h
.386

.data

message BYTE "Please enter the score and hit the enter key",0dh,0ah

kybdData KEYBOARD <>




.code
main PROC
LOCAL Count;;	
	mov	ax,@data				; initialize DS
	mov	ds,ax

	mov	ah,40h				; write to file/device
	mov	bx,1					; output handle
	mov	cx,SIZEOF message		; number of bytes
	mov	dx,OFFSET message		; addr of buffer
	int	21h
	
	mov ah, 0Ah					;
	mov dx, OFFSET kybdData		;
	int 21h						
	
	IF ( kybdData LT 0) OR (kybdData GT 100)
		ECHO Warning:Score cannot be less than 0 or more than 100.
		ECHO Please try again.
		ECHO *****************************************************
		
	ENDIF
	

	
	IF ( kybdData LE 100) OR (kybdData GE 90)
		ECHO You have an A.
		ECHO *****************************************************
		Count = 1
	ENDIF
	
	IF 	( kybdData LE 89) OR (kybdData GE 80)
		ECHO You have an B.
		ECHO *****************************************************
		Count = Count + 1
	ENDIF
	
	IF ( kybdData LE 79) OR (kybdData GE 70)
		ECHO You have an C.
		ECHO *****************************************************
		Count = Count + 2
	ENDIF
	
	IF ( kybdData LE 69) OR (kybdData GE 60)
		ECHO You have an D.
		ECHO *****************************************************
		Count = Count + 3
	ENDIF
	
	IF ( kybdData LE 59) 
		ECHO You have an F.
		ECHO *****************************************************
		Count = Count + 4
	ENDIF
	
	IF ERRS LE 5;;
	EXITM;;
	ENDIF
	
	.EXIT
main ENDP
END main

Open in new window

Avatar of yasmeens
yasmeens

ASKER

I saw one error and corrected in.  Updated code is attached.

Errors are below:
Assembling: program4.asm
program4.asm(11) : error A2008: syntax error : kybdData
program4.asm(32) : error A2006: undefined symbol : kybdData
program4.asm(41) : error A2006: undefined symbol : kybdData
program4.asm(47) : error A2006: undefined symbol : kybdData
program4.asm(53) : error A2006: undefined symbol : kybdData
program4.asm(59) : error A2006: undefined symbol : kybdData
program4.asm(65) : error A2006: undefined symbol : kybdData
program4.asm(71) : error A2094: operand must be relocatable
program4.asm(19) : error A2006: undefined symbol : DGROUP
program4.asm(29) : error A2006: undefined symbol : kybdData
program4.asm(77) : warning A4023: with /coff switch, leading underscore required
 for start address : main
TITLE InterpretScore        (program4.asm)

.MODEL small
.STACK 100h
.386

.data

message BYTE "Please enter the score and hit the enter key",0dh,0ah

kybdData KEYBOARD <>




.code
main PROC
LOCAL Count;;	
	mov	ax,@data				; initialize DS
	mov	ds,ax

	mov	ah,40h				; write to file/device
	mov	bx,1					; output handle
	mov	cx,SIZEOF message		; number of bytes
	mov	dx,OFFSET message		; addr of buffer
	int	21h
	
	mov ah, 0Ah					;
	mov dx, OFFSET kybdData		;
	int 21h						
	
	IF ( kybdData LT 0) OR (kybdData GT 100)
		ECHO Warning:Score cannot be less than 0 or more than 100.
		ECHO Please try again.
		ECHO *****************************************************
		
	ENDIF
	

	
	IF ( kybdData LE 100) OR (kybdData GE 90)
		ECHO You have an A.
		ECHO *****************************************************
		Count = 1
	ENDIF
	
	IF 	( kybdData LE 89) OR (kybdData GE 80)
		ECHO You have an B.
		ECHO *****************************************************
		Count = Count + 1
	ENDIF
	
	IF ( kybdData LE 79) OR (kybdData GE 70)
		ECHO You have an C.
		ECHO *****************************************************
		Count = Count + 2
	ENDIF
	
	IF ( kybdData LE 69) OR (kybdData GE 60)
		ECHO You have an D.
		ECHO *****************************************************
		Count = Count + 3
	ENDIF
	
	IF ( kybdData LE 59) 
		ECHO You have an F.
		ECHO *****************************************************
		Count = Count + 4
	ENDIF
	
	IF Count LE 5;;
	EXITM;;
	ENDIF
	
	.EXIT
main ENDP
END main

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial