Assembly Source series of Gameport

Source: Internet
Author: User
Tags port number

This is the past DOS era of the compilation of source code, although it has passed, but for the study of the compilation is still helpful, assembly language is only a programmer a basic language, most people can grasp, not necessarily to in-depth study ...

;
; GAMEPORT.ASM
;
; Author: Paul Cullum
; released to the public domain
;
    .MODEL TINY
    .DATA
    yes   DB   13,10,"Game port is installed.",13,10,"$"
    no   DB   13,10,"Game port is not installed.",13,10,"$"
    .CODE
    ORG 100h
start: mov   al, 1      ;value to write to port
    mov   dx, 201h    ;port number
    out   dx, al     ;write to port
    mov   cx, 0F00h    ;# of loops
port_loop:
    in   al, dx     ;read from port
    and   al, 0Fh     ;if jstick present, then AL should be
    cmp   al, 0Fh     ; 0Fh after ANDing with 0Fh.
    je   jstick_exists
    loop  port_loop
    mov   dx, OFFSET no  ;gameport not installed
    jmp   SHORT done
jstick_exists:         
    mov   dx, OFFSET yes ;gameport installed
done:  mov   ah, 9h
    int   21h
    mov   ax, 4c00h
    int   21h
END   start

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.