~ubuntu-branches/ubuntu/wily/slof/wily

« back to all changes in this revision

Viewing changes to slof/fs/fcode/little-big.fs

  • Committer: Package Import Robot
  • Author(s): Aurelien Jarno
  • Date: 2012-09-16 23:05:23 UTC
  • Revision ID: package-import@ubuntu.com-20120916230523-r2ynulqmp2tyu2e5
Tags: upstream-20120217+dfsg
ImportĀ upstreamĀ versionĀ 20120217+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\ *****************************************************************************
 
2
\ * Copyright (c) 2004, 2011 IBM Corporation
 
3
\ * All rights reserved.
 
4
\ * This program and the accompanying materials
 
5
\ * are made available under the terms of the BSD License
 
6
\ * which accompanies this distribution, and is available at
 
7
\ * http://www.opensource.org/licenses/bsd-license.php
 
8
\ *
 
9
\ * Contributors:
 
10
\ *     IBM Corporation - initial implementation
 
11
\ ****************************************************************************/
 
12
 
 
13
\ little- and big-endian FCODE IP access functions
 
14
 
 
15
 
 
16
?bigendian [IF]                       \ Big endian access functions first
 
17
 
 
18
 
 
19
: read-fcode-num16 ( -- n )
 
20
   0 fcode-num !
 
21
   ?arch64 IF
 
22
      read-byte fcode-num 6 + C!
 
23
      next-ip
 
24
      read-byte fcode-num 7 + C!
 
25
   ELSE
 
26
      read-byte fcode-num 2 + C!
 
27
      next-ip
 
28
      read-byte fcode-num 3 + C!
 
29
   THEN
 
30
   fcode-num @
 
31
;
 
32
 
 
33
: read-fcode-num32 ( -- n )
 
34
   0 fcode-num !
 
35
   ?arch64 IF
 
36
      read-byte fcode-num 4 + C!
 
37
      next-ip
 
38
      read-byte fcode-num 5 + C!
 
39
      next-ip
 
40
      read-byte fcode-num 6 + C!
 
41
      next-ip
 
42
      read-byte fcode-num 7 + C!
 
43
   ELSE
 
44
      read-byte fcode-num 0 + C!
 
45
      next-ip
 
46
      read-byte fcode-num 1 + C!
 
47
      next-ip
 
48
      read-byte fcode-num 2 + C!
 
49
      next-ip
 
50
      read-byte fcode-num 3 + C!
 
51
   THEN
 
52
   fcode-num @
 
53
;
 
54
 
 
55
 
 
56
[ELSE]                                \ Now the little endian access functions
 
57
 
 
58
 
 
59
: read-fcode-num16 ( -- n )
 
60
   0 fcode-num !
 
61
   ?arch64 IF
 
62
      read-byte fcode-num 7 + C!
 
63
      next-ip
 
64
      read-byte fcode-num 6 + C!
 
65
   ELSE
 
66
      read-byte fcode-num 1 + C!
 
67
      next-ip
 
68
      read-byte fcode-num 0 + C!
 
69
   THEN
 
70
   fcode-num @
 
71
;
 
72
 
 
73
: read-fcode-num32 ( adr -- n )
 
74
   0 fcode-num !
 
75
   ?arch64 IF
 
76
      read-byte fcode-num 7 + C!
 
77
      next-ip
 
78
      read-byte fcode-num 6 + C!
 
79
      next-ip
 
80
      read-byte fcode-num 5 + C!
 
81
      next-ip
 
82
      read-byte fcode-num 4 + C!
 
83
   ELSE
 
84
      read-byte fcode-num 3 + C!
 
85
      next-ip
 
86
      read-byte fcode-num 2 + C!
 
87
      next-ip
 
88
      read-byte fcode-num 1 + C!
 
89
      next-ip
 
90
      read-byte fcode-num 0 + C!
 
91
   THEN
 
92
   fcode-num @
 
93
;
 
94
 
 
95
 
 
96
[THEN]