Mike Chambers
Veteran Member
- Joined
- Sep 2, 2006
- Messages
- 2,621
Do you happen to have an updated version of your ROM I could play with?
Do you happen to have an updated version of your ROM I could play with?
EDIT: If you read the post I had here, ignore it! Sorry. I realized I was testing that in a version of the emulator from early 2011 that had known problems. It's not the case in the current, it just calls function 1h then 0h and sits there.
It calls func 0h immediately after 1h without a key even being pressed though!
I did a little "debugging" (okay, just dumping int 16h calls to stdout) of it in Fake86, and what happens when I press a key for the first time is it calls these int 16h functions in this order: 2h, 1Ch, Ah, 8h, 6h, 4h, 2h, 0h. Some of these aren't standard BIOS functions according to RBIL. 1Ch and 8h aren't in the list, 6h is for some TSR called AAKEYS, and 4h is for the Tandy 2000. Maybe this will help?
The second time I press a key at the prompt, it simply seems to keep calling int 16h function 2h repeatedly.
If it matters, I use this BIOS in the emu: http://www.phatcode.net/downloads.php?id=101
EDIT: If you read the post I had here, ignore it! Sorry. I realized I was testing that in a version of the emulator from early 2011 that had known problems. It's not the case in the current, it just calls function 1h then 0h and sits there.
It calls func 0h immediately after 1h without a key even being pressed though!
;Returns: AL- ASCII character, AH- BIOS Scancode
wait_for_key proc near
xor ax, ax
mov ah, 0x01
keep_waiting:
int 0x16 ;See if keystroke is available.
jz keep_waiting
xor ax, ax
;dec ah ;ah => 0x00, which is the next function we need.
int 0x16 ;Remove key from buffer.
ret
wait_for_key endp
Well then this just doesn't make a lot of sense to me, it looks like it's up to the BIOS code. What in the would could cause this?
I'll download Fake86, organize my code and create a git repository. I've been putting it off (the repo part) mainly because I have to learn how to do it all over again every. single. time...
It doesn't have a real debugging interface, I just kinda hacked in some code to dump the interrupt calls and recompiled.
Have a look at www.emu8086.com - this will let you single step and examine everything closely... and I hate git too.
EDIT: I ran it emu8086, and it works there. There's no real BIOS in emu8086 though, so any calls to one are high-level emulated. So it works in that, Bochs, but not in Fake86 or real machines... hmm. Interesting. What does your int 9h handler look like? I don't believe emu8086 even uses int 9h on keypresses. It seems to just directly put key input into the "BIOS" buffer. My guess at this point is that you may be doing something incorrectly in that handler.
How'd you add my monitor expansion ROM to Fake86, btw ? I don't see a command line option to do it...
loadrom (0xF6000UL, PATH_DATAFILES "rombasic.bin", 0);
loadrom (0xF4000UL, PATH_DATAFILES "monitor.bin", 0);
There isn't one. I really should add that. You'll have to recompile.
Find this line in main.c:
Code:loadrom (0xF6000UL, PATH_DATAFILES "rombasic.bin", 0);
...and put this line above it:
Code:loadrom (0xF4000UL, PATH_DATAFILES "monitor.bin", 0);
I could just give you my binary if you like. At least, if you're on Windows.
Here you go: http://rubbermallet.org/fake86-0.13.9.2-win32.zip
This should do it: fake86 -oprom F4000 monitor.bin
No prob! And yes, that's where it seems to hang up on. What is it that you're doing when you receive an int 9h?
int9_handler proc far
;We need to prepare for the possibility that we will return to
;the debugger!
pushf
push cs
add sp, -0x02 ;We can't use any other registers now!
;The original SP can be calculated later.
push bp
mov bp, sp
;mov ss:[0x02 + bp], offset cs:[main_loop]- Crashes spectacularly
mov ss:[0x02 + bp], offset main_loop
;Not sure which registers are used.
push ax
push cx
push dx
push bx
push si
push di
push ds
push es
int 0x12 ;Needs to be the modified ISR
inc ax
mov cl, 6 ;Multiply by 64 to get segment-equivalent (1024/16)
shl ax, cl
mov es, ax ;Data area is now prepared
pushf ;Simulate interrupt
call es:[old_int9_handler] ;Absolute indirect
;Has the debugger been defeated?
;If so, restore the interrupts.
;Is key combination valid?
;If so, are we in main_loop already?
;if not call main_loop. It is the ma
;otherwise restore program state, regardless of whether we are
;in debugger or not.
;push ax
;push si
;push ds
mov ax, cs
mov ds, ax
;Test message
mov si, offset key_message
call print_str
assume ds:DGROUP
xor ax, ax
mov ah, 0x02
int 0x16
cmp al, 0x0C ;CTRL+ALT+ESCAPE pressed?
;pop si
pop es
pop ds
pop di
pop si
pop bx
pop dx
pop cx
pop ax
mov sp, bp
pop bp
;The POPped registers did not affect the comparison
jnz exit_int
iret ;Otherwise, use IRET to jump into the main loop!
exit_int:
add sp, 0x06 ;Skip going into the main debug loop
iret
int9_handler endp
pushf ;Simulate interrupt
call es:[old_int9_handler] ;Absolute indirect[/CODE]
0071 9C pushf
0072 26 FF 1E 08 00 call dword ptr es:L$7
Okay, I see what you're saying. What I'm trying to do is perform a far call with an absolute address (0xEA), when the address is not known ahead of time. But yes, my assembler is also assembling that as 0xFF with a segment override 0x26 (ES), according to my listings.
Code:0071 9C pushf 0072 26 FF 1E 08 00 call dword ptr es:L$7