Index: trunk/src/VBox/Devices/BiosCommonCode/commondefs.inc
===================================================================
--- trunk/src/VBox/Devices/BiosCommonCode/commondefs.inc	(revision 60440)
+++ trunk/src/VBox/Devices/BiosCommonCode/commondefs.inc	(revision 60441)
@@ -46,7 +46,55 @@
 
 
+;;
+; Pretends to do a call by pushing the return address and jumping
+; to the function.
+;
+; This is slightly problematic on 8086 since it doesn't support pushing
+; word immediates. OTOH, it support pushing memory, so we'll do that
+; instead when targeting 8086.
+;
+if 0 ;; this crap crashes wasm, makes it call exit(0), or similar weird stuff.
+     ;; switched to a simpler approach where I define the one return address variable myself.
+DO_JMP_CALL     macro calling, returning
+ if VBOX_BIOS_CPU gt 8086
+        push    returning
+        jmp     calling
+ else
+        push    word ptr cs:[%jmp_call_addr_&returning]
+        jmp     calling
+;public jmp_call_addr_&returning
+%jmp_call_addr_&returning: dw offset retaddr
+ endif
+endm
+
+DO_JMP_CALL_AGAIN macro calling, returning
+ if VBOX_BIOS_CPU gt 8086
+        push    returning
+        jmp     calling
+ else
+        push    word ptr cs:[%jmp_call_addr_&returning]
+        jmp     calling
+ endif
+endm
+
+else  ; Simplified.
+DO_JMP_CALL_EX  macro calling, returning, returning_ptr_var
+ if VBOX_BIOS_CPU gt 8086
+        push    returning
+        jmp     calling
+  else
+        push    word ptr cs:[returning_ptr_var]
+        jmp     calling
+  endif
+endm
+
+endif ; Simplified.
+
+
 ;; For handling the pusha instruction depending on target CPU.
-DO_PUSHA        macro
- if VBOX_BIOS_CPU eq 8086
+DO_pusha        macro
+ if VBOX_BIOS_CPU gt 8086
+        pusha
+ else
         push    ax
         push    cx
@@ -57,6 +105,4 @@
         push    si
         push    di
- else
-        pusha
  endif
 endm
@@ -64,6 +110,8 @@
 
 ;; For handling the popad/popa instruction depending on target CPU.
-DO_POPA         macro
- if VBOX_BIOS_CPU eq 8086
+DO_popa         macro
+ if VBOX_BIOS_CPU gt 8086
+        popa
+ else
         pop     di
         pop     si
@@ -74,6 +122,4 @@
         pop     cx
         pop     ax
- else
-        popa
  endif
 endm
@@ -82,5 +128,9 @@
 ;; For handling the pushad/pusha instruction depending on target CPU.
 DO_PUSHAD       macro
- if VBOX_BIOS_CPU eq 8086
+ if VBOX_BIOS_CPU ge 80386
+        pushad
+ elseif VBOX_BIOS_CPU gt 8086
+        pusha
+ else
         push    ax
         push    cx
@@ -91,8 +141,4 @@
         push    si
         push    di
- elseif VBOX_BIOS_CPU lt 80386
-        pusha
- else
-        pushad
  endif
 endm
@@ -101,5 +147,9 @@
 ;; For handling the popad/popa instruction depending on target CPU.
 DO_POPAD        macro
- if VBOX_BIOS_CPU eq 8086
+ if VBOX_BIOS_CPU ge 80386
+        popad
+ elseif VBOX_BIOS_CPU gt 8086
+        popa
+ else
         pop     di
         pop     si
@@ -110,10 +160,70 @@
         pop     cx
         pop     ax
- elseif VBOX_BIOS_CPU lt 80386
-        popa
- else
-        popad
- endif
-endm
+ endif
+endm
+
+
+;; ASSUMES working stack.
+DO_shr          macro reg, count
+ if VBOX_BIOS_CPU ge 80186
+        shr     reg, count
+ else
+  if count ge 6
+        push    cx
+        mov     cl, count
+        shr     reg, cl
+        pop     cx
+  else
+   if count ge 5
+        shr     reg, 1
+   endif
+   if count ge 4
+        shr     reg, 1
+   endif
+   if count ge 3
+        shr     reg, 1
+   endif
+   if count ge 2
+        shr     reg, 1
+   endif
+   if count ge 1
+        shr     reg, 1
+   endif
+  endif
+ endif
+endm
+
+
+;; ASSUMES working stack.
+DO_shl          macro reg, count
+ if VBOX_BIOS_CPU ge 80186
+        shl     reg, count
+ else
+  if count ge 6
+        push    cx
+        mov     cl, count
+        shl     reg, cl
+        pop     cx
+  else
+   if count ge 5
+        shl     reg, 1
+   endif
+   if count ge 4
+        shl     reg, 1
+   endif
+   if count ge 3
+        shl     reg, 1
+   endif
+   if count ge 2
+        shl     reg, 1
+   endif
+   if count ge 1
+        shl     reg, 1
+   endif
+  endif
+ endif
+endm
+
+
 
 
Index: trunk/src/VBox/Devices/Graphics/BIOS/vberom.asm
===================================================================
--- trunk/src/VBox/Devices/Graphics/BIOS/vberom.asm	(revision 60440)
+++ trunk/src/VBox/Devices/Graphics/BIOS/vberom.asm	(revision 60441)
@@ -801,5 +801,5 @@
 endif
 set_palette_data:
-  DO_PUSHAD
+  DO_pushad
   push  ds
   push  es
@@ -831,5 +831,5 @@
   loop  set_pal_loop
   pop   ds
-  DO_POPAD
+  DO_popad
 vbe_09_ok:
   mov  ax, 004Fh
@@ -837,5 +837,5 @@
 
 get_palette_data:
-  DO_PUSHAD
+  DO_pushad
   mov   al, dl
   mov   dx, VGAREG_DAC_READ_ADDRESS
@@ -864,5 +864,5 @@
 endif
   loop  get_pal_loop
-  DO_POPAD
+  DO_popad
   jmp   vbe_09_ok
 
Index: trunk/src/VBox/Devices/Graphics/BIOS/vgarom.asm
===================================================================
--- trunk/src/VBox/Devices/Graphics/BIOS/vgarom.asm	(revision 60440)
+++ trunk/src/VBox/Devices/Graphics/BIOS/vgarom.asm	(revision 60441)
@@ -87,9 +87,9 @@
   push es
   push ds
-  DO_PUSHA
+  DO_pusha
   mov   bx, 0C000h
   mov   ds, bx
   call _int10_debugmsg
-  DO_POPA
+  DO_popa
   pop ds
   pop es
@@ -200,5 +200,5 @@
   push es
   push ds
-  DO_PUSHA
+  DO_pusha
 
 ;; We have to set ds to access the right data segment
@@ -207,5 +207,5 @@
   call _int10_func
 
-  DO_POPA
+  DO_popa
   pop ds
   pop es
Index: trunk/src/VBox/Devices/PC/BIOS/Makefile.kmk
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/Makefile.kmk	(revision 60440)
+++ trunk/src/VBox/Devices/PC/BIOS/Makefile.kmk	(revision 60441)
@@ -90,5 +90,5 @@
  VBoxPcBios8086_EXTENDS = VBoxPcBios386
  VBoxPcBios8086_CFLAGS  = -0
- VBoxPcBios8086_DEFS    = $(filter-out VBOX_BIOS_CPU=80386,$(VBoxPcBios386_DEFS)) VBOX_BIOS_CPU=80186 ## @todo get it working as 8086!
+ VBoxPcBios8086_DEFS    = $(filter-out VBOX_BIOS_CPU=80386,$(VBoxPcBios386_DEFS)) VBOX_BIOS_CPU=8086
 
 
Index: trunk/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.asm
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.asm	(revision 60440)
+++ trunk/src/VBox/Devices/PC/BIOS/VBoxBiosAlternative386.asm	(revision 60441)
@@ -15399,7 +15399,7 @@
 
 section BIOSSEG progbits vstart=0xe000 align=1 ; size=0x2000 class=CODE group=AUTO
-    db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
-    db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
-    db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 058h, 04dh
+biosorg_check_before_or_at_0E02Eh:           ; 0xfe000 LB 0x30
+    times 0x2e db 0
+    db  'XM'
 eoi_both_pics:                               ; 0xfe030 LB 0x4
     mov AL, strict byte 020h                  ; b0 20
@@ -15415,5 +15415,5 @@
     loop 0e039h                               ; e2 f6
     retn                                      ; c3
-eoi_jmp_post:                                ; 0xfe044 LB 0x17
+eoi_jmp_post:                                ; 0xfe044 LB 0xb
     call 0e030h                               ; e8 e9 ff
     db  033h, 0c0h
@@ -15421,4 +15421,5 @@
     mov ds, ax                                ; 8e d8
     jmp far [00467h]                          ; ff 2e 67 04
+biosorg_check_before_or_at_0E059h:           ; 0xfe04f LB 0xc
     times 0xa db 0
     db  'XM'
@@ -15479,5 +15480,5 @@
     je short 0e047h                           ; 74 85
     jmp short 0e0c4h                          ; eb 00
-normal_post:                                 ; 0xfe0c4 LB 0x1ff
+normal_post:                                 ; 0xfe0c4 LB 0x1f6
     mov ax, 07800h                            ; b8 00 78
     db  08bh, 0e0h
@@ -15680,4 +15681,5 @@
     call 0edbfh                               ; e8 07 0b
     jmp short 0e31bh                          ; eb 61
+biosorg_check_before_or_at_0E2C1h:           ; 0xfe2ba LB 0x9
     add byte [bx+si], al                      ; 00 00
     add byte [bx+si], al                      ; 00 00
@@ -15695,5 +15697,5 @@
     int 002h                                  ; cd 02
     iret                                      ; cf
-hard_drive_post:                             ; 0xfe2d2 LB 0x12c
+hard_drive_post:                             ; 0xfe2d2 LB 0xbd
     db  033h, 0c0h
     ; xor ax, ax                                ; 33 c0
@@ -15775,4 +15777,5 @@
     sti                                       ; fb
     retf 00002h                               ; ca 02 00
+biosorg_check_before_or_at_0E3FCh:           ; 0xfe38f LB 0x6f
     times 0x6d db 0
     db  'XM'
@@ -15830,15 +15833,17 @@
 int19_handler:                               ; 0xfe6f2 LB 0x3
     jmp near 0f0ach                           ; e9 b7 09
-biosorg_check_0E6F5h:                        ; 0xfe6f5 LB 0x34
+biosorg_check_at_0E6F5h:                     ; 0xfe6f5 LB 0xa
     or word [bx+si], ax                       ; 09 00
     cld                                       ; fc
     add byte [bx+di], al                      ; 00 01
     je short 0e73ch                           ; 74 40
-    times 0x2b db 0
+    times 0x3 db 0
+biosorg_check_before_or_at_0E727h:           ; 0xfe6ff LB 0x2a
+    times 0x28 db 0
     db  'XM'
-biosorg_check_0E729h:                        ; 0xfe729 LB 0x10
+biosorg_check_at_0E729h:                     ; 0xfe729 LB 0x10
     times 0xe db 0
     db  'XM'
-biosorg_check_0E739h:                        ; 0xfe739 LB 0x1a
+biosorg_check_at_0E739h:                     ; 0xfe739 LB 0x1a
     push DS                                   ; 1e
     push ES                                   ; 06
@@ -15883,5 +15888,5 @@
     out strict byte 0a1h, AL                  ; e6 a1
     retn                                      ; c3
-ebda_post:                                   ; 0xfe778 LB 0xb6
+ebda_post:                                   ; 0xfe778 LB 0x45
     mov ax, 0e746h                            ; b8 46 e7
     mov word [00034h], ax                     ; a3 34 00
@@ -15908,7 +15913,8 @@
     mov word [0040eh], 09fc0h                 ; c7 06 0e 04 c0 9f
     retn                                      ; c3
+biosorg_check_before_or_at_0E82Ch:           ; 0xfe7bd LB 0x71
     times 0x6f db 0
     db  'XM'
-biosorg_check_0E82Eh:                        ; 0xfe82e LB 0x36
+biosorg_check_at_0E82Eh:                     ; 0xfe82e LB 0x36
     sti                                       ; fb
     push ES                                   ; 06
@@ -15971,5 +15977,5 @@
     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
     db  0ffh, 0ffh, 000h, 004h, 000h, 093h, 000h, 000h
-pmode_setup:                                 ; 0xfe8e0 LB 0xa7
+pmode_setup:                                 ; 0xfe8e0 LB 0x5c
     push eax                                  ; 66 50
     push esi                                  ; 66 56
@@ -15998,7 +16004,8 @@
     pop eax                                   ; 66 58
     retn                                      ; c3
+biosorg_check_before_or_at_0E985h:           ; 0xfe93c LB 0x4b
     times 0x49 db 0
     db  'XM'
-biosorg_check_0E987h:                        ; 0xfe987 LB 0x2d2
+biosorg_check_at_0E987h:                     ; 0xfe987 LB 0x5c
     cli                                       ; fa
     push ax                                   ; 50
@@ -16058,7 +16065,8 @@
     popaw                                     ; 61
     iret                                      ; cf
+biosorg_check_before_or_at_0EC57h:           ; 0xfe9e3 LB 0x276
     times 0x274 db 0
     db  'XM'
-biosorg_check_0EC59h:                        ; 0xfec59 LB 0x2
+biosorg_check_at_0EC59h:                     ; 0xfec59 LB 0x2
     jmp short 0ecb0h                          ; eb 55
 int13_relocated:                             ; 0xfec5b LB 0x55
@@ -16267,5 +16275,5 @@
     aad 00ah                                  ; d5 0a
     retn                                      ; c3
-rtc_post:                                    ; 0xfedbf LB 0x198
+rtc_post:                                    ; 0xfedbf LB 0x77
     db  066h, 033h, 0c0h
     ; xor eax, eax                              ; 66 33 c0
@@ -16315,7 +16323,8 @@
     mov byte [00470h], AL                     ; a2 70 04
     retn                                      ; c3
+biosorg_check_before_or_at_0EF55h:           ; 0xfee36 LB 0x121
     times 0x11f db 0
     db  'XM'
-int0e_handler:                               ; 0xfef57 LB 0x70
+int0e_handler:                               ; 0xfef57 LB 0x3b
     push ax                                   ; 50
     push dx                                   ; 52
@@ -16350,4 +16359,5 @@
     pop ax                                    ; 58
     iret                                      ; cf
+biosorg_check_before_or_at_0EFC5h:           ; 0xfef92 LB 0x35
     times 0x33 db 0
     db  'XM'
@@ -16361,5 +16371,5 @@
     db  0f6h
     invd                                      ; 0f 08
-biosorg_check_0EFD2h:                        ; 0xfefd2 LB 0x2
+biosorg_check_at_0EFD2h:                     ; 0xfefd2 LB 0x2
     jmp short 0efd4h                          ; eb 00
 int17_handler:                               ; 0xfefd4 LB 0xd
@@ -16379,17 +16389,20 @@
 _rmode_IDT:                                  ; 0xfefe7 LB 0x6
     db  0ffh, 003h, 000h, 000h, 000h, 000h
-int1c_handler:                               ; 0xfefed LB 0x58
+int1c_handler:                               ; 0xfefed LB 0x1
     iret                                      ; cf
+biosorg_check_before_or_at_0F043h:           ; 0xfefee LB 0x57
     times 0x55 db 0
     db  'XM'
-biosorg_check_0F045h:                        ; 0xff045 LB 0x20
+biosorg_check_at_0F045h:                     ; 0xff045 LB 0x1
     iret                                      ; cf
+biosorg_check_before_or_at_0F063h:           ; 0xff046 LB 0x1f
     times 0x1d db 0
     db  'XM'
-int10_handler:                               ; 0xff065 LB 0x3f
+int10_handler:                               ; 0xff065 LB 0x1
     iret                                      ; cf
+biosorg_check_before_or_at_0F0A2h:           ; 0xff066 LB 0x3e
     times 0x3c db 0
     db  'XM'
-biosorg_check_0F0A4h:                        ; 0xff0a4 LB 0x8
+biosorg_check_at_0F0A4h:                     ; 0xff0a4 LB 0x8
     push CS                                   ; 0e
     pop DS                                    ; 1f
@@ -16692,6 +16705,7 @@
     db  000h, 0e8h, 060h, 0f8h, 0deh, 061h, 0f8h, 0deh, 062h, 0f8h, 0deh, 063h, 0f8h, 0deh, 01ch, 000h
     db  000h, 0f0h, 061h, 0f8h, 0deh, 062h, 0f8h, 0deh, 063h, 0f8h, 0deh, 060h, 0f8h, 0deh, 01dh, 000h
-_pci_routing_table_size:                     ; 0xff4a0 LB 0x3a1
+_pci_routing_table_size:                     ; 0xff4a0 LB 0x2
     loopne 0f4a3h                             ; e0 01
+biosorg_check_before_or_at_0F83Fh:           ; 0xff4a2 LB 0x39f
     times 0x39d db 0
     db  'XM'
@@ -16788,5 +16802,5 @@
     popaw                                     ; 61
     iret                                      ; cf
-int76_handler:                               ; 0xff8d7 LB 0x197
+int76_handler:                               ; 0xff8d7 LB 0x12
     push ax                                   ; 50
     push DS                                   ; 1e
@@ -16798,4 +16812,5 @@
     pop ax                                    ; 58
     iret                                      ; cf
+biosorg_check_before_or_at_0FA6Ch:           ; 0xff8e9 LB 0x185
     times 0x183 db 0
     db  'XM'
@@ -16865,5 +16880,5 @@
     db  018h, 018h, 018h, 000h, 018h, 018h, 018h, 000h, 0e0h, 030h, 030h, 01ch, 030h, 030h, 0e0h, 000h
     db  076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h
-biosorg_check_0FE6Eh:                        ; 0xffe6e LB 0x21
+biosorg_check_at_0FE6Eh:                     ; 0xffe6e LB 0x21
     cmp ah, 0b1h                              ; 80 fc b1
     jne short 0fe82h                          ; 75 0f
@@ -16890,5 +16905,5 @@
     pop ES                                    ; 07
     iret                                      ; cf
-int70_handler:                               ; 0xffe8f LB 0x16
+int70_handler:                               ; 0xffe8f LB 0xd
     push ES                                   ; 06
     push DS                                   ; 1e
@@ -16902,9 +16917,10 @@
     pop ES                                    ; 07
     iret                                      ; cf
+biosorg_check_before_or_at_0FEA3h:           ; 0xffe9c LB 0x9
     add byte [bx+si], al                      ; 00 00
     add byte [bx+si], al                      ; 00 00
     add byte [bx+si], al                      ; 00 00
     add byte [bx+si+04dh], bl                 ; 00 58 4d
-int08_handler:                               ; 0xffea5 LB 0x4e
+int08_handler:                               ; 0xffea5 LB 0x43
     sti                                       ; fb
     push eax                                  ; 66 50
@@ -16940,10 +16956,11 @@
     pop eax                                   ; 66 58
     iret                                      ; cf
+biosorg_check_before_or_at_0FEF1h:           ; 0xffee8 LB 0xb
     times 0x9 db 0
     db  'XM'
-biosorg_check_0FEF3h:                        ; 0xffef3 LB 0xd
+biosorg_check_at_0FEF3h:                     ; 0xffef3 LB 0xd
     times 0xb db 0
     db  'XM'
-biosorg_check_0FF00h:                        ; 0xfff00 LB 0x53
+biosorg_check_at_0FF00h:                     ; 0xfff00 LB 0x19
     dec di                                    ; 4f
     jc short 0ff64h                           ; 72 61
@@ -16961,9 +16978,10 @@
     dec di                                    ; 4f
     push bx                                   ; 53
+biosorg_check_before_or_at_0FF51h:           ; 0xfff19 LB 0x3a
     times 0x38 db 0
     db  'XM'
 dummy_iret:                                  ; 0xfff53 LB 0x1
     iret                                      ; cf
-biosorg_check_0FF54h:                        ; 0xfff54 LB 0x9c
+biosorg_check_at_0FF54h:                     ; 0xfff54 LB 0x2c
     iret                                      ; cf
     mov ax, ax                                ; 89 c0
@@ -16993,5 +17011,7 @@
     add byte [bx+si], al                      ; 00 00
     add byte [di], ah                         ; 00 25
-    times 0x6f db 0
+    times 0x1 db 0
+biosorg_check_before_or_at_0FFEEh:           ; 0xfff80 LB 0x70
+    times 0x6e db 0
     db  'XM'
 cpu_reset:                                   ; 0xffff0 LB 0x10
Index: trunk/src/VBox/Devices/PC/BIOS/orgs.asm
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/orgs.asm	(revision 60440)
+++ trunk/src/VBox/Devices/PC/BIOS/orgs.asm	(revision 60441)
@@ -161,4 +161,7 @@
 public		int13_handler
 public		int13_relocated
+if VBOX_BIOS_CPU eq 8086
+public 	jmp_call_ret_int13_out
+endif
 public		int15_handler
 public		int17_handler
@@ -171,6 +174,8 @@
 public		normal_post
 public		eoi_jmp_post
+public		no_eoi_jmp_post
 public		eoi_master_pic
 public		ebda_post
+public		seg_40_value
 public		hard_drive_post
 public		int13_legacy
@@ -239,4 +244,6 @@
 		jmp	dword ptr ds:[0467h]
 
+seg_40_value:	dw 40h ;; Replaces a push 40; pop ds.
+
 ;; --------------------------------------------------------
 ;; POST entry point
@@ -254,4 +261,6 @@
 		jz	in_real_mode
 		SET_DEFAULT_CPU_286
+else
+		jmp	in_real_mode
 endif
 
@@ -288,6 +297,5 @@
 		;; faulting the CPU or similar. Check reboot flag.
 		;; NB: At this point, registers need not be preserved.
-		push	40h
-		pop	ds
+               mov     ds, cs:[seg_40_value]
 		cmp	word ptr ds:[72h], 1234h
 		jnz	reset_sys	; trigger system reset
@@ -500,5 +508,5 @@
 		mov	dx, 278h	; parallel port 2
 		call	detect_parport
-		shl	bx, 0Eh
+		DO_shl	bx, 0Eh
 		mov	ax, ds:[410h]	; equipment word
 		and	ax, 3FFFh
@@ -520,5 +528,5 @@
 		mov	dx, 2E8h	; fourth serial address
 		call	detect_serial
-		shl	bx, 9
+		DO_shl	bx, 9
 		mov	ax, ds:[410h]	; equipment word
 		and	ax, 0F1FFh	; bits 9-11 determine serial ports
@@ -760,8 +768,8 @@
 		push	ds
 		push	es
-		DO_PUSHA
+		DO_pusha
 		C_SETUP
 		call	_int14_function
-		DO_POPA
+		DO_popa
 		pop	es
 		pop	ds
@@ -776,8 +784,8 @@
 		push	ds
 		push	es
-		DO_PUSHA
+		DO_pusha
 		C_SETUP
 		call	_dummy_isr_function
-		DO_POPA
+		DO_popa
 		pop	es
 		pop	ds
@@ -837,5 +845,5 @@
 		push	es
 		push	ds
-		DO_PUSHA
+		DO_pusha
 
 		cmp	ah, 0
@@ -847,5 +855,5 @@
 		C_SETUP
 		call	_int16_function
-		DO_POPA
+		DO_popa
 		pop	ds
 		pop	es
@@ -874,5 +882,5 @@
 		C_SETUP
 		call	_int16_function
-		DO_POPA
+		DO_popa
 		pop	ds
 		pop	es
@@ -919,5 +927,5 @@
 		in	al, KBC_DATA
 		push	ds
-		DO_PUSHA
+		DO_pusha
 		cld			; Before INT 15h (and any C code)
 ifdef BX_CALL_INT15_4F
@@ -952,5 +960,5 @@
 
 int09_done:
-		DO_POPA
+		DO_popa
 		pop	ds
 		cli
@@ -969,5 +977,5 @@
 
 int06_handler:
-		DO_PUSHA
+		DO_pusha
 		push	es
 		push	ds
@@ -976,5 +984,5 @@
 		pop	ds
 		pop	es
-		DO_POPA
+		DO_popa
 		iret
 
@@ -999,10 +1007,12 @@
 		ja	int13_not_eltorito
 
-		DO_PUSHA
+		DO_pusha
 		push	es
 		push	ds
 		C_SETUP			; TODO: setup C envrionment only once?
-		push	int13_out	; simulate a call
-		jmp	_int13_eltorito	; ELDX not used
+		DO_JMP_CALL_EX _int13_eltorito, int13_out, jmp_call_ret_int13_out ; ELDX not used
+if VBOX_BIOS_CPU eq 8086
+jmp_call_ret_int13_out: dw offset int13_out
+endif
 
 int13_not_eltorito:
@@ -1031,11 +1041,10 @@
 		pop	es
 
-		DO_PUSHA
+		DO_pusha
 		push	es
 		push	ds
 		C_SETUP			; TODO: setup environment only once?
 
-		push	int13_out	; simulate a call
-		jmp	_int13_cdemu	; ELDX not used
+		DO_JMP_CALL_EX _int13_cdemu, int13_out, jmp_call_ret_int13_out ; ELDX not used
 
 int13_nocdemu:
@@ -1080,10 +1089,9 @@
 
 		;; now the registers can be restored with
-		;; pop ds; pop es; DO_POPA; iret
+		;; pop ds; pop es; DO_popa; iret
 		test	dl, 80h		; non-removable?
 		jnz	int13_notfloppy
 
-		push	int13_out	; simulate a near call
-		jmp	_int13_diskette_function
+		DO_JMP_CALL_EX _int13_diskette_function, int13_out, jmp_call_ret_int13_out
 
 int13_notfloppy:
@@ -1116,5 +1124,5 @@
 		pop	ds
 		pop	es
-		DO_POPA
+		DO_popa
 		iret
 
@@ -1214,5 +1222,5 @@
 look_drive0:
 		; TODO: pre-init bl to reduce jumps
-		shr	al, 4		; drive 0 in high nibble
+		DO_shr	al, 4		; drive 0 in high nibble
 		jz	f0_missing	; jump if no drive
 		mov	bl, 7		; drv0 determined, multi-rate, chgline
@@ -1255,6 +1263,14 @@
 		;; in : AL in packed BCD format
 		;; out: AL in binary, AH always 0
+if VBOX_BIOS_CPU ge 80186
 		shl	ax, 4
 		shr	al, 4
+else
+		push	cx
+               mov	cl, 4
+		shl	ax, cl
+		shr	al, cl
+               pop	cx
+endif
 		aad
 		ret
@@ -1437,8 +1453,8 @@
 		push	ds
 		push	es
-		DO_PUSHA
+		DO_pusha
 		C_SETUP
 		call	_int17_function
-		DO_POPA
+		DO_popa
 		pop	es
 		pop	ds
@@ -1564,5 +1580,5 @@
 		; 3rd boot device
 		mov	ax, 3
-		push	3
+		push	ax
 		call	_int19_function
 		inc	sp
@@ -1585,5 +1601,5 @@
 if VBOX_BIOS_CPU lt 80386
 		mov	[bp], ax
-               shl	ax, 4
+               DO_shl	ax, 4
 		mov	[bp+2], ax	; set ip
 		mov	ax, [bp]
@@ -1658,5 +1674,5 @@
 		cmp	ah, 0d0h
 		je	int15_handler32
-		DO_PUSHA
+		DO_pusha
 		cmp	ah, 53h		; APM function?
 		je	apm_call
@@ -1666,5 +1682,5 @@
 		call	_int15_function
 int15_handler_popa_ret:
-		DO_POPA
+		DO_popa
 int15_handler32_ret:
 		pop	es
@@ -1690,7 +1706,7 @@
 		.286
 else
-		DO_PUSHA
+		DO_pusha
 		call	_int15_function32
-		DO_POPA
+		DO_popa
 endif
 		jmp	int15_handler32_ret
@@ -1719,12 +1735,13 @@
 
 		sti
-		DO_PUSHA
+		DO_pusha
 		push	es
 		push	ds
-		push	0		; placeholder for status
-		push	0		; placeholder for X
-		push	0		; placeholder for Y
-		push	0		; placeholder for Z
-		push	0		; placeholder for make_far_call bool
+               xor	ax, ax
+		push	ax		; placeholder for status
+		push	ax		; placeholder for X
+		push	ax		; placeholder for Y
+		push	ax		; placeholder for Z
+		push	ax		; placeholder for make_far_call bool
 		C_SETUP
 		call	_int74_function
@@ -1733,5 +1750,10 @@
 
 		;; make far call to EBDA:0022
+if VBOX_BIOS_CPU ge 80186
 		push	0
+else
+               xor	ax, ax
+               push	ax
+endif
 		pop	ds
 		push	ds:[40Eh]
@@ -1744,5 +1766,5 @@
 		pop	ds
 		pop	es
-		DO_POPA
+		DO_popa
 		iret
 
@@ -1763,4 +1785,41 @@
 
 int76_handler	endp
+
+
+;;
+;; IRQ 8 handler (RTC)
+;;
+int70_handler:
+		push	es
+		push	ds
+		DO_pusha
+		C_SETUP
+		call	_int70_function
+		DO_popa
+		pop	ds
+		pop	es
+		iret
+
+
+
+if VBOX_BIOS_CPU lt 80386
+;
+; We're tight on space down below in the int08_handler, so put
+; the 16-bit rollover code here.
+;
+int08_maybe_rollover:
+               ja	int08_rollover
+		cmp	ax, 00B0h
+               jb	int08_rollover_store
+		;; there has been a midnight rollover
+int08_rollover:
+		xor	dx, dx
+		xor	ax, ax
+
+		inc	byte ptr ds:[70h]	; increment rollover flag
+int08_rollover_store:
+		jmp	int08_store_ticks
+endif
+
 
 ;; --------------------------------------------------------
@@ -1796,45 +1855,13 @@
 		push	es
 		push	ds
-		DO_PUSHA
+		DO_pusha
 		C_SETUP
 int1a_callfunction:
 		call	_int1a_function
-		DO_POPA
+		DO_popa
 		pop	ds
 		pop	es
 		iret
 
-
-;;
-;; IRQ 8 handler (RTC)
-;;
-int70_handler:
-		push	es
-		push	ds
-		DO_PUSHA
-		C_SETUP
-		call	_int70_function
-		DO_POPA
-		pop	ds
-		pop	es
-		iret
-
-if VBOX_BIOS_CPU lt 80386
-;
-; We're tight on space down below in the int08_handler, so put
-; the 16-bit rollover code here.
-;
-int08_maybe_rollover:
-               ja	int08_rollover
-		cmp	ax, 00B0h
-               jb	int08_store_ticks
-		;; there has been a midnight rollover
-int08_rollover:
-		xor	dx, dx
-		xor	ax, ax
-
-		inc	byte ptr ds:[70h]	; increment rollover flag
-		jmp	int08_store_ticks
-endif
 
 ;; --------------------------------------------------------
@@ -1874,5 +1901,6 @@
 else
 		cmp	dx, 18h
-               jae	int08_maybe_rollover
+               jb	int08_store_ticks
+               jmp	int08_maybe_rollover
 endif
 
