Question:
assembly language IA 32 help?
comosta
2008-10-04 08:27:31 UTC
GIVEN THE DATA BELOW, DESIGN AN IA-32 ASSEMBLY LANGUAGE
PROGRAM TO CONVERT EACH INTEGER IN X TO A 32-BYTE BINARY
STRING AND A 4-BYTE HEX STRING AND SAVE THEM IN IN Y AND Z
RESPECTIVELY.

.DATA

X SDWORD 500, -500, 1000, -1000
Y BYTE 4 DUP (32 DUP ('0'))
Z BYTE 4 DUP (4 DUP ('0'))
Three answers:
balk
2008-10-05 16:54:01 UTC
So, you're looking for an algorithm that converts a dword into an ASCII binary string?

Well, I won't do your homework for you, but I'll give you some help. There are different ways you can do this, but here's one method:



You can use the TEST or AND CPU instructions (TEST is more efficient) to see if a bit is set. Since you're converting dwords, your loop should run 32 times.



The algorithm with TEST works like this (I'll use the number 500 in this example.):



1) Use a register (e.g. EDX) to store a number with the value 80000000h. This number has bit 31 set, and the rest of the bits are zero.

2) Use a register as a pointer which points to the start of the Y array.

3) Use a register as a loop counter.

4) TEST EDX with 500.

5) If it's zero, then write the ASCII '0' to the Y array and then increment the array pointer.

6) If it's one, then do the same thing as step 5, but write the ASCII '1' character.

7) Shift EDX to the right once to test the next bit.

8) Decrement your loop counter and jump to step 4 until the loop is done.



Converting a dword to a hex string works by dividing a number (e.g. 500) by 16 in a loop. There is more code required with this algorithm due to the ASCII conversion.
Lie Ryan
2008-10-04 08:34:28 UTC
We won't do your homework for you, we'll help if you get stuck.



PS: I'm wondering though, how far the world advanced since my last sleep, since last time I checked, the computing world is still mostly a 32-bit world, some uses 64-bit, and several supercomputers uses 128-bit. But somehow, someone seems to have successfully created a 32-byte computers.
anonymous
2008-10-04 08:31:58 UTC
You forgot to ask a question.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...