william stallings computer organization and architecture 6 th edition
DESCRIPTION
William Stallings Computer Organization and Architecture 6 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions. What is an instruction set?. The complete collection of instructions that are understood by a CPU Machine Code Binary Usually represented by assembly codes. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/1.jpg)
William Stallings Computer Organization and Architecture6th Edition
Chapter 10Instruction Sets:Characteristicsand Functions
![Page 2: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/2.jpg)
What is an instruction set?
• The complete collection of instructions that are understood by a CPU
• Machine Code• Binary• Usually represented by assembly codes
![Page 3: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/3.jpg)
Elements of an Instruction
• Operation code (Op code)—Specifies the operation to be performed.
• Source Operand reference—Input operands for the operation.
• Result Operand reference—Put the answer here
• Next Instruction Reference—Tell the CPU where to fetch the next
instruction after the execution of this instruction is complete.
![Page 4: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/4.jpg)
Elements of an Instruction (cont.)
• Source and Result operands can be in one of three areas:—Main memory (or virtual memory or cache)—CPU register—I/O device
![Page 5: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/5.jpg)
Instruction Cycle State Diagram
![Page 6: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/6.jpg)
Instruction Representation
• In machine code each instruction has a unique bit pattern
• For human consumption (well, programmers anyway) a symbolic representation is used—e.g. ADD, SUB, LOAD
• Operands can also be represented in this way—ADD A,B
![Page 7: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/7.jpg)
Simple Instruction Format
![Page 8: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/8.jpg)
Instruction Types
• Data processing—Arithmetic and logic instructions
• Data storage (main memory)—Memory instruction
• Data movement (I/O)—I/O instruction are need to transfer programs
and data into memory and the results of computations back out to the user.
• Program flow control —Test and branch instruction—Test instructions are used to test the value of a
data word or the status of a computation.—Branch instructions are used to branch a
different set of instructions depending on the decision made.
![Page 9: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/9.jpg)
Number of Addresses (a)
• 3 addresses—Operand 1, Operand 2, Result—a = b + c;—May be a forth - next instruction (usually
implicit)—Not common—Needs very long words to hold everything
![Page 10: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/10.jpg)
Number of Addresses (b)
• 2 addresses—One address doubles as operand and result—a = a + b—Reduces length of instruction—Requires some extra work
– Temporary storage to hold some results
![Page 11: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/11.jpg)
Number of Addresses (c)
• 1 address—Implicit second address—Usually a register (accumulator)—Common on early machines
![Page 12: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/12.jpg)
Number of Addresses (d)
• 0 (zero) addresses—All addresses implicit—Uses a stack—e.g. push a— push b— add— pop c
—c = a + b
![Page 13: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/13.jpg)
Utilization of instruction address
![Page 14: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/14.jpg)
Example: Y=(A-B)/(C+D*E)
• Three-address instruction—SUB Y, A, B (Y=A-B)
MPY T, D, E (T=D*E)ADD T, T, C (T=T+C)DIV Y, Y, T (Y=Y/T)
• Two-address instruction—MOVE Y, A (Y=A)
SUB Y, B (Y=Y-B)MOVET, D (T=D)MPY T, E (T=T*E)ADD T, C (T=T+C)DIV Y, T (Y=Y/T)
![Page 15: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/15.jpg)
Example: Y=(A-B)/(C+D*E)
• One-address instruction—LOADD (AC=D)
MPY E (AC=AC*E)ADD C (AC=AC+C)STOR Y (Y=AC)LOAD A (AC=A)SUB B (AC=AC-B)DIV Y (AC=AC/Y)STOR Y (Y=AC)
![Page 16: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/16.jpg)
精選範例
![Page 17: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/17.jpg)
精選範例 - 解答
![Page 18: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/18.jpg)
How Many Addresses
• More addresses—More complex instructions—More registers
– Inter-register operations are quicker
—Fewer instructions per program
• Fewer addresses—Less complex instructions—More instructions per program—Faster fetch/execution of instructions
![Page 19: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/19.jpg)
Design Decisions (1)
• Operation repertoire—How many ops?—What can they do?—How complex are they?
• Data types—The various types of data upon which
operations are performed.
• Instruction formats—Length of op code field—Number of addresses
![Page 20: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/20.jpg)
Design Decisions (2)
• Registers—Number of CPU registers available—Which operations can be performed on which
registers?
• Addressing modes (later…)—The mode or modes by which the address of
an operand is specified.
• RISC v CISC
![Page 21: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/21.jpg)
Types of Operand
• Machine instruction operate on data, the most important categories of data are—Addresses—Numbers
– Integer/floating point
—Characters– ASCII etc.
—Logical Data– Bits or flags
![Page 22: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/22.jpg)
Types of Operand (cont.)
• Address—Addresses are a form of data.—Addresses can be considered to be unsigned
integers
• Numbers—There is a limit to the magnitude of numbers
representable on a machine.—In the FP numbers, a limit to their precision.—Three types of numerical data are common in
computer– Integer or fixed point– Floating point– Decimal
+ Binary/decimal converter
![Page 23: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/23.jpg)
Types of Operand (cont.)
• Characters—A number of codes have been devised by
which characters are represented by a sequence of bits
—International Reference Alphabet (IRA)– American Standard Code for Information Interchange
(ASCII)+ 7 bit, 128 different characters, including some control
characters.
– IRA-encoded characters+ 8 bit+ The last bit is parity bit
– Extended Binary Coded Decimal Interchange Code (EBCDIC)
+ Used on IBM S/390 machines+ 8 bit
![Page 24: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/24.jpg)
Types of Operand (cont.)
• Logical Data—To consider an n-bit unit as consisting of n 1-
bit items of data—Each item having the value 0 or 1
• The same data are treated sometimes as logical and other times as numerical or text.—The “type” of a unit of data is determined by
the operation being performed on it—It is almost always the case with machine
language.
![Page 25: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/25.jpg)
Pentium Data Types
• 8 bit Byte• 16 bit word• 32 bit double word• 64 bit quad word• Addressing is by 8 bit unit• A 32 bit double word is read at addresses
divisible by 4• Little-endian style
—The least significant byte is stored in the lowest address.
![Page 26: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/26.jpg)
Specific Data Types
• General - arbitrary binary contents• Integer - signed binary value (2s
complement)• Ordinal - unsigned integer• Unpacked BCD - One digit per byte• Packed BCD - 2 BCD digits per byte• Near Pointer - 32 bit offset within segment• Bit field• Byte String• Floating Point – IEEE 754 standard
![Page 27: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/27.jpg)
Pentium Floating Point Data Types
![Page 28: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/28.jpg)
PowerPC Data Types
• The PowerPC can deal with data type of—8 (byte), 16 (halfword), 32 (word) and 64
(doubleword) length data types
• Some instructions need operand aligned on 32 bit boundary
• Can be big- or little-endian• Fixed point processor recognises:
—Unsigned byte, unsigned halfword, signed halfword, unsigned word, signed word, unsigned doubleword, byte string (<128 bytes)
• Floating point—IEEE 754—Single or double precision
![Page 29: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/29.jpg)
Types of Operation
• Data Transfer• Arithmetic• Logical• Conversion• I/O• System Control• Transfer of Control
![Page 30: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/30.jpg)
Common Instruction Set Operation
![Page 31: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/31.jpg)
Common Instruction Set Operation (cont.)
![Page 32: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/32.jpg)
Common Instruction Set Operation (cont.)
![Page 33: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/33.jpg)
Common Instruction Set Operation (cont.)
![Page 34: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/34.jpg)
CPU actions for various types of operations
![Page 35: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/35.jpg)
Data Transfer
• The data transfer instruction must specify the followings:—Source—Destination—Amount of data—The mode of addressing for each operand
• May be different instructions for different movements—e.g. IBM 370
• Or one instruction and different addresses—e.g. VAX
![Page 36: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/36.jpg)
Example of IBM S/390 Data Transfer Operations
![Page 37: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/37.jpg)
Data Transfer (cont.)
• CPU actions—If both source and destination are register, the
CPU transfer data from one register to another.—If one or both operands are in memory, the
CPU must perform some or all of the following actions
– Calculate the memory address– If the address refers to virtual memory, translate
from virtual to actual memory address.– Determine whether the addressed item is in cache– If not, issue a command to the memory module.
![Page 38: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/38.jpg)
Arithmetic
• Most machine provide the basic arithmetic—Add, Subtract, Multiply, Divide
• These are always provided for signed integer (fixed-point) numbers.
• They are often provide floating point and packed decimal numbers.
• Other possible operations include—Absolute—Negate—Increment—Decrement
![Page 39: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/39.jpg)
Logical• Bitwise operations• AND, OR, NOT
— The AND operation can be used as a mask that selects certain bits in a word and zeros out the remaining bits
• Logical shift— The bits of a word are shifted left or right— On one end, the bit shifted out is lost.— On the other end, a o is shifted in,
![Page 40: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/40.jpg)
Logical: Shift and Rotate Operations
![Page 41: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/41.jpg)
Logical (cont.)
• Arithmetic shift—The arithmetic shift operation treats the data
as a signed integer and does the sign bit.—A right arithmetic shift corresponds to a
division by 2—A left arithmetic shift corresponds to a
multiplication by 2
• Rotate—Preserve all of the bits being operated on.
![Page 42: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/42.jpg)
Logical (cont.)
• Conversion—That change the format or operate on the
format of data—E.g. Binary to Decimal
![Page 43: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/43.jpg)
Input/Output
• A variety of approaches—Isolated programmed I/O, memory-mapped
programmed I/O, DMA, and I/O processor
• May be specific instructions (Isolated)• May be done using data movement
instructions (memory mapped)• May be done by a separate controller
(DMA)
![Page 44: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/44.jpg)
Systems Control
• System control—Can be executed only while the CPU is in a
certain privileged state or is executing a program in a special privileged area of memory.
• CPU needs to be in specific state —Ring 0 on 80386+—Kernel mode
• For operating systems use
![Page 45: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/45.jpg)
Transfer of Control
• Branch—Jump instruction, has as one of its operands,
the address of the next instruction to be executed.
—Conditional branch– e.g. branch to x if result is zero
—User-visible register– Most machine provide a 1-bit or multiple-bit
condition code
• Skip—Includes an implied address, the address of
the next instruction plus one instruction-length—e.g. increment and skip if zero (ISZ)—ISZ Register1
![Page 46: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/46.jpg)
Transfer of Control (cont.)
• Procedure Call instruction—The reasons for the use of procedures are
economy and modularity.—A procedure allows the same piece of code to
be used many times.—The procedure mechanism involves two basic
instructions– Call instruction– Return instruction
—A procedure can be called from more than one location
—A procedure call can appear in a procedure (nesting of procedures to an arbitrary depth)
—Each procedure call is matched by a return in the called program
![Page 47: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/47.jpg)
Transfer of Control (cont.)
—There are three common places for storing the return address
– Register– Start of called procedure– Top of stack
—Reentrant procedure– A reentrant procedure is one in which it is possible to
have several calls open to it at the same time– Eg. Recursive procedure
![Page 48: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/48.jpg)
Branch Instruction
![Page 49: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/49.jpg)
Nested Procedure Calls
![Page 50: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/50.jpg)
Use of Stack
![Page 51: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/51.jpg)
Stack Frame Growth Using Sample Procedures P and Q
![Page 52: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/52.jpg)
Assembly Language
• A CPU can understand and execute machine instructions
• Such instructions are simply binary numbers stored in computer
• For more improvement—Make use of the symbolic name or mnemonic
of each instruction—Symbolic program—Pseudo instruction
• Programs written in assembly language are translated into machine language by assembler
![Page 53: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/53.jpg)
Stacks
• A stack is an ordered set of elements• Only one of which can be accessed at a time• The point of access is called the top of the stack• The number of element in the stack is called
length• Stack is a pushdown list or a last-in-first-out list
![Page 54: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/54.jpg)
Basic Stack Operation
![Page 55: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/55.jpg)
Stack Implementation
• Because all of these operations refer to the top of the stack, the address of the operand or operands is implicit and need not be included in the instruction.
• Zero-address instruction• Three address are needed for proper
operation—Stack pointer
– Contains the address of the top of the stack
—Stack base– Contains the address of the bottom location in the
reserved block
—Stack limit– Contains the address of the other end of the reserved
block
![Page 56: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/56.jpg)
Typical Stack Organizations
![Page 57: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/57.jpg)
Expression Evaluation
• Reverse Polish (postfix)• The postfix is easily evaluated using a
stack• Algorithm
—If the element is a variable or constant, push it onto the stack
—If the element is an operator, – pop the top two items of the stack, – perform the operation, – and push the result.
![Page 58: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/58.jpg)
Use of stack to compute f=(a-b)/(c+d*e)
![Page 59: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/59.jpg)
Byte Order(A portion of chips?)
• What order do we read numbers that occupy more than one byte
• e.g. (numbers in hex to make it easy to read)
• 12345678 can be stored in 4x8bit locations as follows
![Page 60: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/60.jpg)
Byte Order (example)
• Address Value (1) Value(2)• 184 12 78• 185 34 56• 186 56 34• 187 78 12
• i.e. read top down or bottom up?
Big endian最大有效位元由低位址往高位址方向存放
Little endian最小有效位元由低位址往高位址方向存放
![Page 61: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/61.jpg)
Byte Order Names
• The problem is called Endian• The system on the left has the most
significant byte in the lowest address—This is called big-endian
• The system on the right has the least significant byte in the lowest address—This is called little-endian
![Page 62: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/62.jpg)
Example of C Data Structure
![Page 63: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/63.jpg)
Alternative View of Memory Map
![Page 64: William Stallings Computer Organization and Architecture 6 th Edition](https://reader034.vdocuments.us/reader034/viewer/2022051623/56815922550346895dc64ad1/html5/thumbnails/64.jpg)
Standard…What Standard?
• Pentium (80x86), VAX are little-endian• IBM 370, Moterola 680x0 (Mac), and most
RISC are big-endian• Internet is big-endian
—Makes writing Internet programs on PC more awkward!
—WinSock provides htoi and itoh (Host to Internet & Internet to Host) functions to convert