dinhtandl 0 Newbie Poster

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 that address a IO Addrress or Memory Address in DOS?
And this 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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.