Question regarding ASM Listing (Z8k)



Hi,

first I've to admit, that I'm not that familiar with ASM but I'm starting
to learn and implemented my first own hello world programs ;)

I've a Z8k system running UNIX. I've fixed a bug the C-Compiler on that
system had (source was available) regarding a libc system call, but I
didn't fully understand the ASM listings. Both, the listing from my
test-c-Program the compiler produced, and the asm implementation of the
libc function where not fully understandable to me. So I'm asking my
questions here hoping that one of you could explain the thing to me and
answer my questions.

Precondition - a function "_fopen" gets called and after the call
register r2 contains a filepointer (integer).

This filepointer shall be processed further by the function "_fcntl".


.seg
fp := r13
FP := rr12
sp := r15
SP := rr14
[...]
callr _open
inc sp,#%6
ld FP(#~L1+%5a),r2
xor r2,r2
push @SP,r2
xor r2,r2
push @SP,r2
push @SP,_stkseg+~L1+%5a(fp)
callr _fcntl
inc sp,#%6

_fcntl is defined as follows:

.seg

sp := r15
SP := rr14

.psec
.code
_fcntl::
{
ldm r0,|_stkseg+4|(sp),#4
xor r4,r4
sc #38 // switch
ld r2,r4
ret nc
jp cerror
}

The systemcall 38 calls the fcntl() Implementation in the UNIX kernel
which expects 3 arguments in r0,r1 and r2 and returns its status in r4.

Now my questions:

a) _open returns the filepointer in r2. What exactly means "FP(#~L1+%5a)"
where r2 gets loaded to?
b) A stack gets filled with push. In this case the stack is the register
rr14. What does the @ in front of SP mean?
c) What means "_stkseg+~L1+%5a(fp)"? For me it looks like the register
"@SP" gets filled with the values from the "stack segment(=_stkseg?)"
+ ~L1 + 90. Wy +~L1 and 90 is done at the end? What is ~L1? Why is
there a (fp) at the end?

Now the FILO-Stack contains 0,0,filepointer from r2.

d) what exaclty happens in the _fcntl's ldm call? I understand, that it
loads 4 words from "|_stkseg+4|(sp)" into r0. But what is the meaning
of the pipes "|" and why is there (sp) at the end?
e) The function in the kernel which gets called with the systemcall 38
expects 3 parameters as I noted previous in r0,r1 and r2. I understand,
that the ldm call reads 4 words into r0. But how are r1 and r2 are
filled up? does the ldm automatically fills the next register each
with a single word read? But why are there 4 words read then and not
only 3?

Greetings, Oliver




--
Oliver Lehmann
http://www.pofo.de/
http://wishlist.ans-netz.de/
.



Relevant Pages