Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

retrieveing web pages

7 views
Skip to first unread message

MonkeyBoy

unread,
May 12, 2012, 5:04:31 PM5/12/12
to
Is there any way of downloading a webpage into a buffer from
assembler.

Greg

Gerph

unread,
May 12, 2012, 7:22:38 PM5/12/12
to
On May 12, 10:04 pm, MonkeyBoy <monkeyboy196f...@googlemail.com>
wrote:
> Is there any way of downloading a webpage into a buffer from
> assembler.

a) Stop using assembler.

b) (when you've ignored the advice in a) ) Stop using assembler.

c) (when taking offense at the advice in b) ) Consult the year and
determine whether you really want to be writing assembler. If you
don't believe in calendars, consult your common sense and ask whether
manipulating webpages in assembler is really sensible.

d) (having considered the advice in c) to be beneath you) Consult the
guide for linking C code with other languages, as a transition to
stopping using assembler (http://usenet.gerph.org/CGuide/ and
http://groups.google.com/group/comp.sys.acorn.programmer/msg/e0845aa2a2ddc216)

e) (when d) is clearly not something you want to do) Place fingers in
ears because clearly my advice isn't going to help, whatever I might
say.

From BASIC, C, Assembler or many other languages, the simplest answer
is to use the URLFetcher interfaces. These are very simple SWI calls
and can be used from any language. But assembler is not the right
language to be using for such things. Of course, you could do it
yourself. Socket SWIs are documented in PRM 5a, and the principles of
BSD sockets can be found in many tutorials on the 'net. Communicating
with a HTTP server is not that hard - although the specifics if you
need special features are more tricky - and can be found in RFCs on
the topic. Search for HTTP (assuming that you're talking about HTTP -
if you want other protocols, you'll need to examine them, and of
course the URLFetchers are a far better proposition for doing so) for
more details on the communications protocol.

--
Gerph
... I look into your eyes and I am at the center of the sun;
And I cannot be hurt by anything this wicked world has done

Gazza

unread,
May 12, 2012, 7:25:46 PM5/12/12
to
On May 12, 10:04 pm, MonkeyBoy <monkeyboy196f...@googlemail.com>
wrote:
> Is there any way of downloading a webpage into a buffer from
> assembler.
>
> Greg

This isn't by me, nor is it in ASM (I hope SPROW doesn't mind me
posting this.)... But it may point you to the correct SWIs... From
there it should be just a matter of converting the calls to use ASM...

910REM
**********************************************************************
920REM
* *
930REM * SWI calls for RISC OS
hosts *
940REM
* *
950REM
**********************************************************************
960DEFFNgethost_swi(name$)
970LOCALhost%,flags%
980SYS"XResolver_GetHost",name$ TO,host%;flags%
990IF(flags% AND1)<>0 THEN=0
1000=host%
1010:
1020DEFFNcreat_swi(pf%,type%,prot%)
1030LOCALhandle%,flags%
1040SYS"XSocket_Creat",pf%,type%,prot% TOhandle%;flags%
1050IF(flags% AND1)<>0 THEN=-1
1060=handle%
1070:
1080DEFFNbind_swi(handle%,addr%,addrlen%)
1090LOCALflags%
1100SYS"XSocket_Bind",handle%,addr%,addrlen% TO;flags%
1110IF(flags% AND1)<>0 THEN=-1
1120=0
1130:
1140DEFFNlisten_swi(handle%,count%)
1150LOCALflags%
1160SYS"XSocket_Listen",handle%,count% TO;flags%
1170IF(flags% AND1)<>0 THEN=-1
1180=0
1190:
1200DEFFNaccept_swi(handle%,addr%,addrlenblk%)
1210LOCALconn%,flags%
1220SYS"XSocket_Accept",handle%,addr%,addrlenblk% TOconn%;flags%
1230IF(flags% AND1)<>0 THEN=-1
1240=conn%
1250:
1260DEFFNconnect_swi(handle%,addr%,addrlen%)
1270LOCALflags%
1280SYS"XSocket_Connect",handle%,addr%,addrlen% TO;flags%
1290IF(flags% AND1)<>0 THEN=-1
1300=0
1310:
1320DEFFNrecv_swi(handle%,data%,len%,opts%)
1330LOCALrecd%,flags%
1340SYS"XSocket_Recv",handle%,data%,len%,opts% TOrecd%;flags%
1350IF(flags% AND1)<>0 THEN=-1
1360=recd%
1370:
1380DEFFNsend_swi(handle%,data%,len%,opts%)
1390LOCALsent%,flags%
1400SYS"Socket_Send",handle%,data%,len%,opts% TOsent%;flags%
1410IF(flags% AND1)<>0 THEN=-1
1420=sent%
1430:
1440DEFPROCshutdown_swi(handle%,type%)
1450SYS"XSocket_Shutdown",handle%,type%
1460ENDPROC
1470:
1480DEFPROCclose_swi(handle%)
1490SYS"XSocket_Close",handle%
1500ENDPROC
1510:

This is part of SPROW's HTTPServer program in BASIC. I hope he doesn't
mind me hacking it to pieces and posting it like this. If needs be and
SPROW sees this and doesn't mind, then I have the whole listing, else
he may be able to help further. Like I said, I was looking around the
other day and just happened to be curious.

Jeremy Nicoll - news posts

unread,
May 14, 2012, 8:22:34 PM5/14/12
to
MonkeyBoy <monkeybo...@googlemail.com> wrote:

> Is there any way of downloading a webpage into a buffer from assembler.

Dunno. Why not use cURL or wget instead? Let the authors of those packages
solve all the tricky problems...

--
Jeremy C B Nicoll - my opinions are my own.

Email sent to my from-address will be deleted. Instead, please reply
to newsre...@wingsandbeaks.org.uk replacing "aaa" by "284".

Rick Murray

unread,
May 15, 2012, 9:21:12 AM5/15/12
to
As the administrator of ARMwiki ( http://www.heyrick.co.uk/armwiki/
), I have only one question:
WHY ARE YOU USING ASSEMBLER FOR THIS?

Given the latency of network connections, and the fact that a lot of
the networking code is written in C, I don't think you'll find any
notable speed boost by writing a fetcher in assembler. You will make
your life much easier using a higher level language.

Indeed, the only reason I can think for writing *that* in assembler
is that you want to write a module but you don't have the C
compiler...?


Best wishes,

Rick.
Message has been deleted
0 new messages