hi I have been looking around for a good file io tutorial and I cant find any. It is simple enough to me the process, mov dx,043h mov al,54 out dx,al etc. but i have no idea which ports go to where or how to write to a hard disk or floppy drive etc. how do i find out which ports map to where?

Recommended Answers

All 6 Replies

You're using 80x86 assembly language, and I'm assuming you're using a PC as a target platform.

Under DOS the ports are accessible, under Win32, pretty much not, unless Win98 or earlier.

Web Search PC bios, DOS interrupts, etc.

I wouldn't just be throwing values and random ports. I know one very early computer (though I think it was an 8080) that used I/O ports to control the high voltage circuit on the built in monitor, and the wrong value would blow the circuitry! But I digress.

You have the basic idea of value to port.


forms:

; OUT #8, AL/AX,EAX,RAX
  out 045h,al

; OUT DX,AL/AX/EAX/RAX
  out dx,al

; String based
; these are only efficient for repeat counts of 64 or more.

;  OUTSX
  outsb           ; Output 8 bits    
  outsw           ; Output 16 bits   
  outsd           ; Output 32 bits   

  mov ecx,5
rep outsb


; these are similar to a LODS (String Load) instruction
  outs dx,byte ptr ds:[esi]
  outs dx,word ptr ds:[esi]
  outs dx,dword ptr ds:[esi]

alright but the problem is I am trying to make a new Operating system(as a learning experience) and I have began work on a filesystem and file structure which I have mapped out on paper. The problem is, I have no idea which i/o ports map to where or where I can find that out-i have looked anywhere. So I guess my question is, how can I figure out which i/o ports go to where?

You could install Windows and go through the device manager and view the Input Output port mappings. Device manufacturers know how they've mapped their ports and so do their drivers.

You can also get the IRQ's.

Or use old hardware, and review the original PC Bios as well as peripheral cards such as RS-232, video, etc.

what are IRQ's? and also I downloaded Ralf Wolf's interrupt list from 2000 im not sure how up to date it is but it is VERY complete and thorough, and includes memory-mapped i/o as well as actual port maps---However, this has led me to a fork in my OS creating career-should I use BIOS interrupts(which seem uniform from bios to bios) or i/o ports(which may or may not be, I'm not entirely sure at this point?). I/O ports have seemed to be faster on all the accounts I have seen, but much more complicated

IRQ Interrupt Request

IRQ 0...F are reserved on a PC Bios and typically shared by multiple devices.

thank you, you have been extremely helpful! Also, I was wondering, could you point to a good tutorial for writing hardware interrupt handlers in assembly?(preferably in fasm or nasm syntax) Thanks!

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.