×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Read IO or Memory in DOS

Read IO or Memory in DOS

Read IO or Memory in DOS

(OP)
Dear all,

I use MASM611 to compile code assemply.
Please hepl me to implement functions to read IO or Memory.
I have a Base Address (example: 0xE1004000), i want to read IO or Memory at this address. And is this address a IO Addrress or Memory Address in DOS?
And Following code is code to read IO at the address is lower 0xFFFF:

; _ioread
;
; This procedure reads data from the io port specified. Data can
; be a byte, word or long word as specified by the size parameter.
;
; C Prototype
;
; Note: The maximum address is 0xFFFF
; short ioread(unsigned long addr, unsigned long * data, short size);
;
; addr - io address to write to
; data - location where data will be stored.
; size - size of data to read in bytes. {1, 2, 4}
;
_ioread PROC FAR
push bp
mov bp,sp

push ebx ; save registers
push edx
push di
push es

; get io address and check to make sure it's in range
mov edx,[bp+6] ; address
cmp edx,0000FFFFH
jg ioread_err_range

xor eax,eax ; prepare to recieve data
mov bx,[bp+0EH] ; size

cmp bx,4 ; write long word
jne ioread_check_word
in eax,dx
jmp ioread_err_ok

ioread_check_word: ; write word
cmp bx,2
jne ioread_check_byte
in ax,dx
jmp ioread_err_ok

ioread_check_byte: ; write byte
cmp bx,1
jne ioread_err_range
in al,dx
jmp ioread_err_ok

ioread_err_ok: ; successful procedure
mov edx,[bp+0AH] ; data
mov di,dx
shr edx,16
mov es,dx
mov es:[di],eax ; store result
xor ax,ax
jmp ioread_omega

ioread_err_range: ; range error in procedure
mov ax,0FFFFH

ioread_omega:

pop es ; restore registers
pop di
pop edx
pop ebx

mov sp,bp
pop bp
ret
_ioread ENDP

I want to edit this code to read with 32 bit address.
Please help me

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close