Can somebody please tell me how to make a loop.
I am trying to convert a decimal number to binary.
I know to divide, and I am putting the remainder on the stack but I have to repeat this until quotient = 1 (quotient = eax)
start:
mov eax, 65
mov ecx, 2
div ecx
push edx
end start:
end start
I am trying to convert a decimal number to binary.
I know to divide, and I am putting the remainder on the stack but I have to repeat this until quotient = 1 (quotient = eax)
start:
mov eax, 65
mov ecx, 2
div ecx
push edx
end start:
end start
some_label:
...
cmp eax, 1 ; Compare eax to 1
jne some_label ; Jump if not equal to "some_label"
...
If you are dividing by 2, why don't you use shift right?
C:\Documents.asm(14) : error A2008: syntax error : loop
C:\Documents.asm(8) : error A2081: missing operand after unary operator
.386
.model flat, stdcall
option casemap:none
.data
.code
start:
loop:
mov eax, 65
mov ecx, 2
div ecx
push edx
cmp eax, 1
jne loop
end start
C:\Documents.asm(8) : error A2081: missing operand after unary operator
.386
.model flat, stdcall
option casemap:none
.data
.code
start:
loop:
mov eax, 65
mov ecx, 2
div ecx
push edx
cmp eax, 1
jne loop
end start
What does it do? AS I know Shift right moves the bits to the right and the left most bit goes to the carry flag and the rightmost flas is filled with a 0.
but aritmetically what does it do?
but aritmetically what does it do?
loop is an opcode, you can't use it for a label.
Shifting right will divide by two, just as removing the first digit from a decimal number will divide by 10 (no rounding).
If you are converting a number in eax to a binary string, you are probably better off using the shift & carry method.
Mirno
Shifting right will divide by two, just as removing the first digit from a decimal number will divide by 10 (no rounding).
If you are converting a number in eax to a binary string, you are probably better off using the shift & carry method.
Mirno
Can u please explain me a little more about the shift and carry method.
I must convert a float number to binary IEEE. suppose 3.21 x 10 E 2
I know to convert 3 to binary. and it fills me the stack with 0 and 1 but I dont know how to retireve those values to a register.
I must convert a float number to binary IEEE. suppose 3.21 x 10 E 2
I know to convert 3 to binary. and it fills me the stack with 0 and 1 but I dont know how to retireve those values to a register.
goto
http://www.ray.masmcode.com
he has a whole floating point library useing the FPU
http://www.ray.masmcode.com
he has a whole floating point library useing the FPU
I cant use FPU
Pushing a 32 bit value containing 0 or 1 onto the stack isn't a very clever way of doing something like this.
Create a buffer 33 bytes long (32 bytes for each of the 32 bits you'll put in there and 1 more for the terminator).
Using shift (left or right depending on the order you want them out), move one bit into the carry flag. If the carry flag is set, move a '1' into your buffer, else move a zero. Increment your pointer to your buffer. Repeat until you've gone through all bits.
If you've still not worked out how to convert an integer to a floating point value, maybe you should talk with your professor / teacher.
To be honest, it's not rocket surgery.
Also, don't keep re-registering (I'm guessing you're the same guy as from http://217.160.247.193/index.php?topic=20925.0), it clutters up the database.
Mirno
Create a buffer 33 bytes long (32 bytes for each of the 32 bits you'll put in there and 1 more for the terminator).
Using shift (left or right depending on the order you want them out), move one bit into the carry flag. If the carry flag is set, move a '1' into your buffer, else move a zero. Increment your pointer to your buffer. Repeat until you've gone through all bits.
If you've still not worked out how to convert an integer to a floating point value, maybe you should talk with your professor / teacher.
To be honest, it's not rocket surgery.
Also, don't keep re-registering (I'm guessing you're the same guy as from http://217.160.247.193/index.php?topic=20925.0), it clutters up the database.
Mirno
I am sorry for registering but I wanted to change my email to get notificacion and I didnt see the option. AS the other email I will not check it anymore