Assembly language help??
I am learning PASAM and have no previous experience with any machine languages.I have some experience with PBASIC and SPIN.
I have read both D'Silva's and Potatoheads - PASAM beginner literature and also most of the other available
material.
It would be very helpful if some one would explain in detail how the following code works - one step at a time
specially when the instruction is follwed by few conditions - that changes the original value.
Please explain this code as much detail as possible:
"Assembly language serial driver"
··················· ORG······················· 'no need to explain this
entry··········· mov··· t1,par
·················· add··· t1,#4· << 2
················· rdlong·· t2,t1
··················mov····· rxmask,#1
················· shl······· rxmask,t2················ ' I understand "masking"·I wan't to understand what is the logic
················ add······t1,#4
················ rdlong·· t2,t1
················ mov····· txmask,#1
·················shl······· txmask,t2
t1··········· res·· 1
t2··········· res··· 1
rxmask····· res··· 1
txmask····· res··· 1
Thank you.
Siri
I have read both D'Silva's and Potatoheads - PASAM beginner literature and also most of the other available
material.
It would be very helpful if some one would explain in detail how the following code works - one step at a time
specially when the instruction is follwed by few conditions - that changes the original value.
Please explain this code as much detail as possible:
"Assembly language serial driver"
··················· ORG······················· 'no need to explain this
entry··········· mov··· t1,par
·················· add··· t1,#4· << 2
················· rdlong·· t2,t1
··················mov····· rxmask,#1
················· shl······· rxmask,t2················ ' I understand "masking"·I wan't to understand what is the logic
················ add······t1,#4
················ rdlong·· t2,t1
················ mov····· txmask,#1
·················shl······· txmask,t2
t1··········· res·· 1
t2··········· res··· 1
rxmask····· res··· 1
txmask····· res··· 1
Thank you.
Siri
Comments
on initialising a cog the PARameter you send to it gets copied into PAR
entry mov t1,par ' this copies PAR ( the parameter you supplied to the cog ) to t1
add t1,#4<<2 ' this adds #4<<2 to t1 4<<2 = 16 as << = shift left so 4 shift left 2 times = 16
rdlong t2,t1 ' read long from HubRAM addressed at t1, ( PAR+16 remember [noparse]:)[/noparse] ) and puts the value located there into t2
mov rxmask,#1 ' stores 1 in rxmask (the # means the next value is an immediate number ie, it's not taken from a location at that address cogram )
shl rxmask,t2 ' shifts left rxmask by t2 ( contents of HubRAM location PAR+16 remember )
add t1,#4 ' adds 4 to t1 ( ie for this code example it points to the next long eg it's now PAR + 20 )
rdlong t2,t1 ' read long from HubRAM address at t1 ( PAR + 20 ) and stores it in t2
mov txmask,#1 ' stores 1 in txmask
shl txmask,t2 ' shifts left txmask by t2 ( contents of HubRAM location PAR+20 remember [noparse]:)[/noparse] )
( then will probably do something weird, as you've not stopped the cog or kept it in a loop, the program counter will continue onto t1, which is a variable, not a valid instruction )
basically this program will get a long at HubRAM PAR+16 and set bit 1 of rxmask, and shift it, in essence setting the bit of that corresponds to the value at that address. and same for txmask, but from PAR+20
Hope this helps you,
Baggers.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
Thank you very much for the quick reply.
I will digest evry bit of what you posted.
Siri
Can you explain to me why- this line of code was necessary
" add t1,#4<<2 ' this adds #4<<2 to t1 4<<2 = 16 as << = shift left so 4 shift left 2 times = 16"
Is it wright if I say what this did was to make t1= par+16 and - why was not done by just coding as: add t1,#16
Thanks
Siri
The addition of 4 longs is done because the first 4 longs in the Spin parameter array contain no parameters for the Assembly initalisation section. This first 4 longs are pointers which are initialized from Spin to read and write the input and output buffers and are used later in the Assembly code (assuming the code comes from FullDuplexSerial).
Andy
I am sure I will have more later.
Thanks again.
Siri