Query Regarding read() function in ExpL

57 views
Skip to first unread message

anish_b...@nitc.ac.in

unread,
Nov 25, 2020, 8:07:34 AM11/25/20
to XOS Users
Sir,
On stage 19, I am trying to implement a linked list in ExpL. While doing so, I noticed that if I use the read function provided by ExpL, I am unable to read the correct value into the dynamically allocated variable. But the same works if I do an exposcall() to the "Read" function.
I was able to deduce that read() works on static variables whereas not on dynamic variables. While exposcall() to "Read" works for both. Also, while calling read() as well as exposcall(), the INT 6 is getting called. So, the system call is made by both.
When I call read() for a dynamic variable an incorrect address is getting passed (I presume), which is in the code space of the program and a memory exception is raised. The exception showed an address 2302 in EMA (varies if a make changes to program but always in the same code page), which is in the code page of the program.
Can you help me understand this? Please let me know if I need to provide more context.

Thank you

ishan ghosh

unread,
Nov 25, 2020, 8:51:42 AM11/25/20
to XOS Users
Hi,

Can you try to run the code from https://silcnitc.github.io/testprograms/test8.html and replace
"read(x);  p=alloc();  p.data=x;" with "p=alloc(); read(p.data);"
Just making sure there's nothing wrong with your expl code.

anish_b...@nitc.ac.in

unread,
Nov 25, 2020, 9:48:56 AM11/25/20
to XOS Users
Thanks for the reply
No changing to read(p.data) doesn't work. It raises the same exception as I was experiencing before. I think the compiler doesn't translate read() same as the exposcall to "Read". The address passed to the kernel (where the input is to be stored) is the same in both cases. The problem occurs after the return from the kernel. The value stored in the variable is incorrect (0 always). The exception only occurs on the second read. I think the first read might have changed the address of the next element, or might have stored the value in a way which corrupted the node variable, thus changing the next element's address.
Also, the base program (without modifications) that you sent works as expected on my implementation.

ishan ghosh

unread,
Nov 25, 2020, 10:25:44 AM11/25/20
to XOS Users
I tried out the code on my machine. read(p.data) seems to work. Not sure what exactly the problem is. Can you maybe try debugging till the exact statement where the exception happens?
Post a screenshot of the debug screen with the instructions and also run the "reg" command in xsm-debug mode and show the registers too.
Reply all
Reply to author
Forward
0 new messages