Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 1st, 2011, 08:32 PM
Funzo Funzo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 3 Funzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 42 sec
Reputation Power: 0
Simple assembly code review help! seems like this problem should be simple

The code below is supposed to take a string of ascii 0s and 1s (representing bits) that follows this format: 1byte start of transmission (can be ignored), 4 byte ip address and up to 8 bytes of text, then an ending byte 03H, then there is an address saved in a WORD

I encounter these errors when trying to link it:
***3.o: In function `sipo':
***3.asm.text+0x73): undefined reference to `proc_PutStr'
***3.o: In function `aLoop':
***3.asm.text+0x8a): undefined reference to `proc_GetCh'
***3.o: In function `inner_loop':
***3.asm.text+0xcb): undefined reference to `proc_GetCh'
***3.o: In function `receiveCheckSum':
***3.asm.text+0x169): undefined reference to `proc_GetCh'

Code:
%include "io.mac"
.DATA
	char_prompt    db  "Please input a string of 0s and 1s that represents the XXY protocol ",0
	IP_prompt   db  "The IP address is: ",0
	message_prompt   db  "The message is: ",0
	char_prompt2   db  "Error in Transmission",0
	query_msg        db  "Do you want to quit (Y/N): ",0

.UDATA
	input		resb 1
	address		resb 4
	message		resb 8
	checksum	resw 1
	counter		resb 1
	savingCheckSum	resb 1
	locationInCheckSum	resb 1
	currentByte	resb 1
.CODE
     .STARTUP
	begin:
		push	input
		push	address
		push	checksum
		mov	[savingCheckSum], byte 0
		call	sipo
		PutStr	IP_prompt
			;output actual ip address TODO
		PutStr	message_prompt
		PutStr	message
		push	message
		push	address
		call	checker
		test	AX,[savingCheckSum]
		je	the_end
		PutStr	char_prompt2
	the_end:
	.EXIT

	sipo:		;paramters:
		PutStr	char_prompt             ; request a char. input
		                     					; 1) an array called "address" which contains the 4 bytes of the address .
		pop	ECX			;save call stack			; 2) An array called "message" which contains the bytes of the message.
 		pop	EAX			;save checksum location 		;3) a word variable called "checksum" which contains the checksum.	
		pop	EBX			;save ip address location
		pop	ESI			;save message address
		push	ECX			;put back the call address		
		mov	ECX, 8
	aLoop:
		GetCh	[input]			;get the first 8 characters and do nothing with them
		loop	aLoop
		mov	[counter], byte 7
		mov	AL, 0			;current byte
	outer_loop:
		mov	ECX, 8			;loop 8 times for 8 bits
		mov	AH, 80H			;mask byte
		inc	AL
		mov	[currentByte], AL	;save currentbyte so that at the end we know how many bytes were read excluding checksum
	inner_loop:
		inc	byte [counter]
		test	[savingCheckSum], byte 0
		je	receiveCheckSum
		GetCh	[input]
		cmp	[counter], byte 40
		jl	receiveIP
		jmp	receiveMessage
	receiveIP:
		test	[input], byte 0
		je	endof_innerLoop		;if it's 0, let's finish this loop!
		mov	EDX, EBX
		dec	EDX
		add	EDX, [currentByte]
		OR	[EDX], AH		;use the mask to set the bit to 1
		jmp	endof_innerLoop
	receiveMessage:
		mov	EDX,ESI
		add	ESI,[currentByte]
		sub	EDX,6
		cmp	[EDX],byte 03H		;check for termination char, put a NULL at the end of message if it is (done below in ready)
		je	ready
		test	[input], byte 0
		je	endof_innerLoop
		mov	EDX,[currentByte]
		add	EDX,ESI
		sub	EDX, 5
		OR	[EDX], AH		;use the mask to set the bit to 1
		jmp	endof_innerLoop
	ready:					;get ready to save the checksum
		mov	EDX,ESI
		add	ESI,[currentByte]
		sub	EDX,6
		mov	[EDX], byte ''	;put null character	
		mov 	[locationInCheckSum], byte 0
		mov	[savingCheckSum], byte 1
		jmp	endof_innerLoop
	receiveCheckSum:
		test	[locationInCheckSum],byte 16	; THIS IS THE ONLY PLACE TO EXIT THE LOOP, after we read 16 bits from the checksum, we exit the loop
		je	finish_loop
		GetCh	[input]	
		test	[input], byte 0
		inc	byte [locationInCheckSum]
		je	endof_innerLoop
		OR	[EAX], AH

	endof_innerLoop:
		shr	AH, 1
		cmp	ECX,1
		je	endOf_OuterLoop
		dec	ECX
		jmp	inner_loop
	endOf_OuterLoop:
		jmp	outer_loop

	finish_loop:
		dec	byte [currentByte]
		dec	byte [currentByte]
		ret
		
	checker:
		pop	ECX		;get everything into the registers and return the stack to the way it was before it was setup for this function
		pop	EDX		;address
		pop	ESI		;message
		mov	EBX, 0
		push	ECX
		mov	AX,  0
		mov	ECX, 2	;check 2 bytes for a WORD
	check_address_outer:
		push	ECX	
		mov	ECX, 8
		mov	AH, 80H			;mask byte
	check_address_inner:
		test	AH, [EDX+EDI]	;EDI is stack pointer -- CONFIRM THIS
		jz	endThisLoopAlready
		inc	AX
	endThisLoopAlready:
		shr	AH, 1
		loop	check_address_inner
		pop	ECX
		loop	check_address_outer
		mov	ECX, [currentByte]
		dec	ECX
		dec	ECX
		dec	ECX

	anotherOuterLoop:			;goes through the message
		push	ECX
		mov	AH, 80H			;mask byte
		mov	ECX, 8			;8 bits
	anotherInnerLoop:
		test	[ESI+EBX], AH
		jz	endInner
		inc	AX
	endInner:
		shr	AH, 1
		loop	anotherInnerLoop
	endOuter:
		pop	ECX
		inc	EBX
		loop	anotherOuterLoop
	outOfLoops:	
		ret


If you see any other problems please let me know!! this code has never been compiled/tested because I haven't gotten past this stage so I'm sure there are other flaws in it.


and PS: it's obvious because I didn't even bother to remove the references that this is an assignment and to be clear I'm not asking for answers I'd just like some help


Thanks in advance!!

Reply With Quote
  #2  
Old March 2nd, 2011, 07:46 PM
OmegaZero OmegaZero is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2007
Posts: 737 OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 56 m 3 sec
Reputation Power: 928
The PutStr and GetCh procedures that you're using are from some library which you need to tell the linker to include.

The documentation for that library should tell you what library you need to include and the documentation for your linker will tell you how to specify additional libraries on the command line. Or you can check your textbook / examples / talk to your instructor.
__________________
sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Simple assembly code review help! seems like this problem should be simple

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap