Thanx to Von-Bonjour, im quite happily getting my own hardware expariments going.. (can hardly wait to get my etch-a-sketch going on stepper motors.. hehehe :P ) But I am still quite new to 32bit asm and have found 3 problems that im seaching to fix.. 1) I understand 16 bit no problem, but surprisingly im haveing a difficult time manipulating 32 bit registers/memory to 16 bit or 8 bit and back.. (moreso on the later) My first experiment/idea to learn from was to translate and display DWORDS in hex by converting them to a string and displaying in a message box. I normally wouldnt have much problem, but i've discovered there is no 32bit shift/rol. So i decided to code a Macro to do this for me, but then i ran into a problem realizing that I cant just build a 32 bit value like i would for a 16 bit (ie mov ah, high; mov al, low). Im sure this is really not a tough problem but its go me snagged at the moment. 2) I then thought it may be easier if i looked up an API reference, but I can seem to find anything.. (and im not even sure if my api/html references i found are complete enough) ~~ anyone have any ideas of where get a good list of api references?? So far im mainly writing out stuff from other people's code.. 3) Math... I can build my own math libraries (which would be slow going im sure) for 32bit asm, but i was wondering what other people do when it comes to math? And I admit, my 16 bit experiences didnt really include floating point math... Again if someone has a sugestion where to start looking i thank you in advanced... NaN
Posted on 2001-01-11 20:55:00 by NaN
You need to get the Pentium manuals (at the very least, a 386 manual). They're available at developer.intel.com and probably elsewhere, but I don't know how big they are. I'm sure there are 32-bit shifts. Code has been posted here that use them. You just need to use 32-bit registers and operands. Your assembler might need to be told you're using a processor that's better than a default 8086. (It has to be at least a 386.) The only 64-bit shifts I can think of, offhand, are SHLD and SHRD. They don't work in an obvious way, unless you've thought about optimizing multiprecision shifts. Another set of manuals you will probably want are MASM manuals. I have no idea where those might be found. For debugging, you can use the wsprintfA API. It's similar to the sprintf function in C, but it doesn't do floating point.
Posted on 2001-01-11 22:36:00 by tank
Three simple minded answers: 1) MASM does too have a 32 bit shift instruction. ROL ROL eax, 16 ; will swap low and high words in eax Here is the code I wrote for the MASM32 lib to translate to ascii hex strings: mov ecx, ADDR Buffer ; buffer must be min 10 bytes add ecx, 8 mov WORD PTR , 0048H ; "H", 0 (Hex identifier and trailing zero) dec ecx Convert: mov eax, dwValue ; origional value in dwValue is destroyed and eax, 0FH ; get digit .IF al < 10 add al, "0" ; convert digits 0-9 to ascii .ELSE add al, ("A"-10) ; convert digits A-F to ascii .ENDIF mov BYTE PTR , al dec ecx ror dwValue,4 ; shift in next hex digit cmp ecx, lpBuffer ; see if we have more to do jae Convert Just an idea how complicated such a simple thing can seem, as I am quite stingy with instructions, moving only the part of the data I need. Also some counter-intuative things, like the text pointer must move BACKWARDS since I'm converting the least significant hex quantity first. 2) The best API reference I have is MSDN on CD, which I got with VB and VC. If you have neither, it's online. Petzold's "Programming Windows" (Now on 98) is the sole BEST way to learn how to drive the windows API. However, it is written in C, so you need to learn enough C to "read C, see asm." I truly recomend learning how to "read C, see asm." 3) Math? Whats that? I actually encounter very very little math. That I usually encounter is integer math, and I hack out some appropiate code. I had to use the FP registers once, wasn't all that hard (took an afternoon of fumbling to write 3 lines of asm)
Posted on 2001-01-11 23:27:00 by Ernie
NaN, Bit shifts and rotations in 32 bit assembler are very simple and you can easily get 8, 16 and 32 bit positioning. All you need to do is visualise the 32 bit register as 32 bit locations and use either ROL or ROR to position the bits you want where you can get them. If you use EAX as the example register, you can access AL, AX or EAX in the normal manner, all you need to do is rotate the bit locations so that the correct bits are in the register you need. Regards, hutch@pbq.com.au
Posted on 2001-01-12 01:18:00 by hutch--
another opcode that is very often not used is 'movzx'. movzx function exactly like a mov instruction, but the source operand can be of a smaller value. movzx stands for; move with zeros extended so the higher bits are automactily set to a default of sero e.g: mov al,8 ;Or anything else, 8 is just for demostration movzx bx,al ;make bx = al movzx ecx,bx ;make edx = bx edx equals 8, same as the orignal value also: mov al,8 movzx ebx,al ;This will also work All 3 of the above are perfectly legal, and will work. There is also a signed intager version of movzx, and that is movsx; move with sign extended It works the same as movzx, except the sign (most signifcant) bit is copied into the new operand.
Posted on 2001-01-13 01:19:00 by manimal
Thanx for you help... I guess my reference is too outdated... it has 32 bit asm included by x86 generations, but i trusted it to be true when it stoped at the 16 bit rol... I will D/L a lates intel PDF and figure out what's missing... Manimal, thanx also for the advice... i think i would find that particularily useful.. NaN
Posted on 2001-01-13 16:00:00 by NaN