HP3000-L Archives

December 1997, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Klein <[log in to unmask]>
Reply To:
Mark Klein <[log in to unmask]>
Date:
Mon, 8 Dec 1997 13:47:24 PST
Content-Type:
text/plain
Parts/Attachments:
text/plain (65 lines)
>strcpy (textline, "some message");
>
>FWRITE ( nHandle, textline, (short) -80, 0 ); /* file is an 80-bytes FA file
>*/
>

CSEQ sez:

CSEQ [nm]: fwrite

Procedure FWRITE (
   filenum      :        int16   ;        {R26}
   target       : anyvar record  ;        {(skip R25)
                                           R23, R24}
                                          {Address type = LongAddr}
   tcount       :        int16   ;        {SP-$0032}
   control      :        UInt16  )        {SP-$0036}
      { CCE: ok                                                  }
      { CCG: EOF                                                 }
      { CCL: error                                               }
   {tcount is > 0 for 16-bit words, < 0 for bytes                      }
   {If MR is not on, trying to write a record larger                   }
   {than the record size is illegal.                                   }
      uncheckable_anyvar

CSEQ [nm]:

Notice that the target (anyvar record) is labeled "Address type =
LongAddr". Last week I posted a caution about long pointers to the list
along with the "longpointer.h" file.

The gcc way to implement this is:

/tmp(135): cat fwrite.c
#include "longpointer.h"

main()
  {
  char *buf = "this is a test!";
  char  buf1[80];
  int   ccode;

  extern int    CCODE();
  extern int    errno;

  extern void   FWRITE(
                        short           filenum,
                        LONGPOINTER     target,
                        short           tcount,
                        unsigned short  control);

  LONGPOINTER lp_buf = longaddr(buf);
  FWRITE(1,lp_buf,-strlen(buf),0);
  ccode = CCODE();
  sprintf(buf1, "ccode from FWRITE call: %d\n",ccode);
  FWRITE(1,longaddr(buf1),-strlen(buf1),0);
  if (errno != 0)
    printf(buf1, "errno: %d\n", errno);
  };
/tmp(136):

Note that I was too lazy to call FOPEN for this test and simply
specified to write to file designator 1 which is $stdlist. Since you've
got FOPEN working, I didn't think it needed here.

ATOM RSS1 RSS2