In and out instructions

Source: Internet
Author: User

In and Outout 0fah,al (does it refer to a port that outputs a byte to 0FAH from AL?) ) out Dx,al  out 0fah,ax (AX is a word why can it also output to the 8-bit port referred to in 0FAH?). Out 03f8h,al (This command has an error why?)      This is because in the out instruction directly with the digital address, the port number can only be 0 to FFH, and the above instruction should be changed to MOV dx 03f8h; only in DX, which is the rule. Out Dx,al-----------------------------------------out 0fah,al (is it a port that outputs one byte to 0FAH from AL?). Yes---------------------------------------out 0fah,ax (AX is a word why can it also output to the 8-bit port referred to in 0FAH?). This instruction puts the data in Al at 0FAH and places the data in AH at 0FBH. These four instructions are mainly to illustrate the different uses of this out instruction, and to learn these instructions do not have to hard remember the various uses of each instruction, as long as the prescribed addressing method. In (input) inputs out output This set of instructions is limited to using accumulator ax or AL to transmit information. In input instruction long format:   in  al,port (bytes)        & nbsp                in  ax,port (word) Operation: (AL) <-(PORT) (bytes)                    (AX) <-(port+1,port) (word) Short format:   in   AL,DX (bytes)     &NB Sp              in AX,DX (word) Operation: al<-((DX)) (bytes)          &nbs P        ax<-((DX) +1,DX) (word). Out output Instruction long format:   out  port,al (bytes)                      &NB Sp          out  port,ax (word) Operation: (PORT) <-(AL) (bytes)                    (port+1,port) <-(AX) (word) Short format:   out  dx,al (bytes)          &N Bsp         out dx,ax (word) Operation: ((DX)) <-(AL) (bytes)                    (DX) +1, (DX)) <-ax   in the ibm-pc machine, the external device can have up to 65,536 I/O ports, the port (that is, the port address of the peripheral) is 0000~FFFFH. The first 256 ports (0~FFH Can be specified directly in the directive, this is the long format of the port, when the machine instruction is represented by two bytes, the second byte is the port number. So you can specify the port number directly in the specified format, but only the first 256 ports. When the port number >=256, you can only use the short format, at which point, You must first place the port number in the DX register (the port number can be from 0000 to 0FFFFH), and then use the in or out instruction to transmit the information.  in,out Port read-write instruction port is the host and peripheral data exchange. (Peripheral interface Circuitry has registers dedicated to data interaction.) To be different from the registers in the CPU, called ports). Port has data port, status port and control port 3 kinds. The PC assigns an address (called a port number) to each port, creating an I/O address space that is independent of the memory space. In 8086/8088, the range of port addresses is 0000 to FFFF. The external operation of the CPU is done through a dedicated port read-write instruction. Read port with in instruction, write port with out instruction. InchAcc,port; reading data from port ports to Acc;port can be either an immediate number or a DX. When ACC is AL, reads 1 bytes of data from port to al    ACC to ax, reads 2 bytes of data from port to Axout PORT,ACC; writes ACC data to port; Example: in al,21h ; represents reading a byte of data from a 21H port to Alin ax,21h; reads 1 bytes of data from port address 21H to AL, reads 1 bytes from the port address 22H to Ahmov dx,379h    in   AL,DX ; Read 1 bytes from port 379H to al     out 21h,al; writes the value of AL to 21H ports     out 21h,ax; writes the value of AX to a contiguous two bytes starting at the port address 21H. (Port[21h]=al,port[22h]=ah) MOV dx,378h    out Dx,ax; write AH and AL to Port 379H and 378H respectively

In and out directives

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.