February 10th, 2012, 12:22 AM
Rotation/String Problem - NASM
I've run into a small problem with the loop that I have, the ror command does fine rotating the bits of:
Until it gets to the end of the byte and it just prints out 0's after.
Now I've narrowed my problem down to 2 things:
; loop start
mov cx, 16
xor ebx, ebx
xor eax, eax
mov al, [bitValues]
; Find the bit value of the inputted letters
mov bl, [inputString]
; 'and' the results...
and bl, al
;cmp al, 0
rcr eax, 1
cmp cx, 0
PutStr endOfLoop_reached ; end of looping over bits
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.
February 10th, 2012, 07:29 PM
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:
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.
; Step #1:
; Get String Input
; 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
mov dx, bx
and dx, ax
cmp dx, 0
; enter value into array
mov [esp], byte 1
; enter value into array
mov [esp], byte 0
ror bx, 1
; End of Step #2
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!
Originally Posted by D1sciple1337