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 February 9th, 2012, 11:22 PM
D1sciple1337 D1sciple1337 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 D1sciple1337 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 57 sec
Reputation Power: 0
Assembly - Rotation/String Problem - NASM

Hey,

I've run into a small problem with the loop that I have, the ror command does fine rotating the bits of:

1000 0000

Until it gets to the end of the byte and it just prints out 0's after.

Code:

PutStr prompt1_msg
		nwln
		GetStr inputString
		PutStr inputString_test
		nwln
		PutStr inputString
		nwln

; loop start

		mov cx, 16

		
		xor ebx, ebx
		xor eax, eax

		mov al, [bitValues]

		start_of_loop:

			PutLInt eax
			nwln

			; Find the bit value of the inputted letters
			mov bl, [inputString]
			PutStr andBitwise_op	
			nwln

			; 'and' the results...
			and bl, al
			;cmp al, 0
			jz jump_notOne 

			jump_one:
			PutStr bitValue_oneEntered
			jmp jump_Exit

			jump_notOne:		
			PutStr bitValue_zeroEntered

			jump_Exit:
			rcr eax, 1
			nwln
			
			dec cx
			cmp cx, 0
			jnz start_of_loop
			
		exit_loop:
		PutStr endOfLoop_reached ; end of looping over bits
		nwln


Now I've narrowed my problem down to 2 things:
1) The way I've stored my 2 input characters, as a character string isn't properly reading input
2) The ror isn't working the way it should

I am leaning more towards (1) but I am sort of stumped. The idea with this is I am checking each of the bits, via and, to put the bits into an array after. The problem only starts after the 8th bit.

Thanks

Reply With Quote
  #2  
Old February 10th, 2012, 06:29 PM
D1sciple1337 D1sciple1337 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 D1sciple1337 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 57 sec
Reputation Power: 0
Well, seeing as nobody checks this forum often, I will just post this up for some other person to stumble upon someday and hope it helps:

Code:
                ; ----------------
		; Step #1:
		; Get String Input
		; ----------------
		PutStr promptInput_msg
		nwln 
		GetStr inputString
		PutStr inputString_test
		nwln 
		PutStr inputString	
		nwln
		; ----------------
		; End of Step #1
		; ----------------

		; ----------------
		; Step #2:
	    ; Transmit bit by bit into an array of 2 bytes (16 bits) to contain both
		; inputted characters
		; ----------------

		; clear the registries before using
		xor ax, ax
		xor bx, bx
		xor cl, cl
		xor dx, dx
		xor esp, esp

		mov cl, 16
		mov ax, [inputString]
		mov bx, 1000000000000000B
		mov esp, unpackArray

		PutStr looping_start
		nwln

		start_of_loop:

		mov dx, bx
		
		and dx, ax
		cmp dx, 0
		jz jump_zero

		PutStr bitValue_oneEntered
		; enter value into array
		mov [esp], byte 1
		jmp jump_Exit

		jump_zero:
		PutStr bitValue_zeroEntered
		; enter value into array		
		mov [esp], byte 0	
		
		jump_Exit:
		nwln
		inc esp
		dec cl
		ror bx, 1
		jnz start_of_loop

		PutStr endOfLoop_reached

		; ----------------
		; End of Step #2
		; ----------------


This code is using a mask to check the value of the input string at each bit, and return either a 0/1 that is placed into a seperate array. The initial problem with the code was that I was using a 8bit model to compare against the 16 bits of the inputString.

I will explain now the problems I had run into and what I did to fix them. Basically the problem I had was not managing the registries properly and overwriting some of them with other values, or putting values into registries that didn't have the proper size.

I simple terms, just using registry A* for instance:
AL, AH (A-low, A-high) each only hold 1 byte (8 bits) so they are useful for only holding things with 8 bit positions or 1 character.
AX is basically AL and AH combined, so it allows, yup, 2 bytes (16 bits) to be used.
EAX is is extended A which holds even more and so forth...

For simplicity's sake, you are alotted registries A-D in each of these cases which the exception of some others that you can look up on the web.

So when coding in Assembly you have to mind your registry management, I'd strongly suggest mapping out on paper first!

Quote:
Originally Posted by D1sciple1337
Hey,

I've run into a small problem with the loop that I have, the ror command does fine rotating the bits of:

1000 0000

Until it gets to the end of the byte and it just prints out 0's after.

Code:

PutStr prompt1_msg
		nwln
		GetStr inputString
		PutStr inputString_test
		nwln
		PutStr inputString
		nwln

; loop start

		mov cx, 16

		
		xor ebx, ebx
		xor eax, eax

		mov al, [bitValues]

		start_of_loop:

			PutLInt eax
			nwln

			; Find the bit value of the inputted letters
			mov bl, [inputString]
			PutStr andBitwise_op	
			nwln

			; 'and' the results...
			and bl, al
			;cmp al, 0
			jz jump_notOne 

			jump_one:
			PutStr bitValue_oneEntered
			jmp jump_Exit

			jump_notOne:		
			PutStr bitValue_zeroEntered

			jump_Exit:
			rcr eax, 1
			nwln
			
			dec cx
			cmp cx, 0
			jnz start_of_loop
			
		exit_loop:
		PutStr endOfLoop_reached ; end of looping over bits
		nwln


Now I've narrowed my problem down to 2 things:
1) The way I've stored my 2 input characters, as a character string isn't properly reading input
2) The ror isn't working the way it should

I am leaning more towards (1) but I am sort of stumped. The idea with this is I am checking each of the bits, via and, to put the bits into an array after. The problem only starts after the 8th bit.

Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Assembly - Rotation/String Problem - NASM

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