Not sure if you can use asm as part of a function. I suggest to move the asm parts to a js file and create functions for the two parts. Then in unit1.pas call the function with Application.RunScript().
Attached the modified sample you have sent. Not sure if shows all the data, but it works to a certain extent.
Also be carefull with the word 'end' as a variable. Could be a reserved word.
I am not professional developer, so I may be wrong with my assumptions.
I was wrong. According to the TMS Web Core manual it is possible to use assembler code as part of a pascal function. I have no idea why it doesn't work in your case. The experts may have an answer.