
;This is the only 8088 assembly code required by the
; emulator

; version to be assembled by TASM or MASM
; will set bp = cpmstack, ds = cpmseg, and try
; to access by BRKEM #baseint
; for this to work, #baseint must have been already installed
; to point to 8080 code
; the interrupt  pointer determines the cs of the 8080 code
; we calculate the ds  = cs, since there are no overides
; in emulation mode, and most 8080 code implicitly assumes
; cs = ds
; could redo bdos code to bankswitch the variables used,
; but why bother


; procedure gotocpm(cpmseg,cpmstack,baseint : word);
;begin
; contains a kludge to get variable interrupt call
; or BRKEM call
; have to rewrite byte after the opcode
; on machines with a cache, could be a problem

code segment word public
     assume cs:code
     public  gotocpm
gotocpm proc near
            push bp    ;
            mov  bp,sp ; standard set up code, no local variables
            mov  ax,[bp + 4] ; brkem int # patch
            mov  byte ptr cs:hack,al  ; modify code
            mov  ax,[bp + 8] ; using near call, so last param at bp + 2
            mov  dx,[bp +6]  ; cpmstack to dx
            push bp       ; used by V20 as stack pointer
            push ds       ; set equal to CP/M data=code
            mov  ds,ax    ; [cpm80] set data segment for cpm
            mov  bp, dx   ; cpmstack to set cp/m stack
            db   0fh,0ffh ;   BRKEM
hack:       db   000h;    ;   BRKEM  XX uses XX interrupt
                          ; overwritten in this version
            pop ds
            pop bp
            mov sp,bp  ; standard exit code
            pop bp
            ret 6   ; 3 two byte parameters pushed on stack
gotocpm     endp

code ends
end
