I have just learned about the in and out instructions but I do not really understand it. If I simply follow the explanation on this site (http://z80-heaven.wikidot.com/direct-input-output#toc5) I would make this simple program, but it does not work. Is the documentation wrong or did I understand it wrongly?
This is the code:
ld hl,0400h ;210004 ;random value ld a,%11111110 ;3EFE ;group 0 out ($01),a ;D301 ;tell hardware to look for group zero keypress in a,($01) ;DB01 ;receive keypress bit 0,a ;CB47 ;test if down arrow was pressed jr nz,$-8 ;20F6 ;if it was not pressed then return to ld a, for another key press Bcall(_DispHL) ;EF0745 ;If it was pressed then display the value of hl. ret ;C9
EDIt: If I read the example on this site (http://wikiti.brandonw.net/?title=83Plus:Ports:01) it seems like no loops is needed but If I use this code it simply quits the program right after it started so I don't even had the time to press anything.
ld hl,0400h ;210s004 ld a,%11111110 ;3EFE out ($01),a ;D301 in a,($01) ;DB01 bit 0,a ;CB47 call z,disp ;CCA49D ret ;C9 disp: Bcall(_DispHL) ;EF0745 ret ;C9