Some assembly help
Dutch
Posts: 8
Cant get my head around this at the moment, so if someone can help. I need to expand a WORD to a LONG. So for example bit 0 of the WORD becomes bit 0 of the LONG and bit 1 of the LONG can be left as zero. Then bit 1 of the WORD becomes bit 2 of the LONG and bit 3 of the LONG can be left as zero, for all 16 bits of the WORD. So finally bit 15 of the WORD becomes bit 30 of the LONG and bit 31 can be left as zero. I am thinking maybe using RCL instructions, but I cannot get my head around assembly. This needs to be converted in the shortest possible time. If anyone can help it would be appreciated.
Comments
Anyway, here's what you shoud do:
The word goes into the (input) the long comes out in the (output).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
rdword xword, addr
mov count, #16
:expand_loop shl xlong , #1
shl xword, #1 wc
rcl xlong, #1
djnz count, #:expand_loop
Will this work ???????? Looks as though you have same number of instructions, will try your way, many thanks.
Just note that your word must occupy the upper half of xword for this to work.
If you don't care about the odd bits then this should work as well:
Post Edited (kuroneko) : 3/20/2009 1:03:34 AM GMT