線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1541
推到 Plurk!
推到 Facebook!

ASM Data Transport Commands實例說明

 
turboted
版主


發表:95
回覆:754
積分:452
註冊:2002-07-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-12-11 18:26:15 IP:61.30.xxx.xxx 未訂閱
XCHG - The exchange commands interchanges the contents of two registers, or between register and memory. Example: if AX = 1234H and DX = ABCDH, after XCHG AX,DX, the contents of AX would be ABCDH and the contents of DX will be 1234H. XLAT - The 'translate' command uses DS:BX as a base pointer, and AL as in index into a table of bytes. The contents of AL are replaced by the byte at DS:[BX AL]. Warning: This command does not seem to be correctly assembled by my copy of NASM. (I will fix this soon!) IN - The IN command is used to read data from an I/O port to the A register. Port numbers range from 0000H to FFFFH. For the case where a port address is in the range 00H to FFH, the IN command can call out the port by numerical value. Example: IN AL,1BH ;read byte from port 1BH. IN AX,2CH ;read word from port 2CH. The choice of byte or word transfer is made by the hardware designer. (AX indicates word transfer and AL indicates byte transfer.) When the port address is greater than 255, the port number must be placed in the DX register. Example: mov DX, 1234H ;port 1234H in AX, DX ;read the word mov DX, 0CABH ;port number in AL, DX ;read byte from port OUT - The OUT command is used to write data to an I/O port. The same usage of AX/AL and DX apply. Example: mov DX, 1234H out DX, AL ;write byte from AL to port 1234H INSB and INSW - When large amounts of data need to be transferred between ports and memory, the INSB, INSW, OUSTB and OUTSW commands are useful. These commands are only available on 286 and higher CPUs. The INSB and INSW commands use DX for the port number, and ES:DI as a pointer. The INSB is the command for byte transfers, while INSW is the command for word transfers. Commonly, these commands are used with the CX register as a count, and with the REP prefix to create a tight loop. Example: mov DX, 1234H ;port number mov AX, 0A000H ;Destination segment mov ES, AX ; xor DI, DI ;Destination offset mov CX, 32000 ;Loop counter rep insw ;Fill video buffer with words from port 1234H OUTSB and OUTSW - The OUTSB and OUTSW commands use DX for the port number, and DS:SI as a pointer. The OUTSB is the command for byte transfers, while OUTSW is the command for word transfers. Commonly, these commands are used with the CX register as a count, and with the REP prefix to create a tight loop. Example: mov DX, 1234H ;port number push DS ;save segment register mov AX, 0A000H ;source segment mov DS, AX ; xor SI, SI ;source offset mov CX, 32000 ;Loop counter rep outsw ;Write video buffer to port 1234H pop DS ;restore segment register 發表人 - turboted 於 2002/12/11 18:28:14
系統時間:2024-05-05 23:11:34
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!