Ideal
P386
Include "../macro.inc"
Include "../mem386.inc"
Segment mysegment para use32 'code'
  Assume cs:mysegment,ds:mysegment
  Org 0H
  TSS		TSS32	<>
  _GDT_		dd	?,?
  _IDT_		dd	?,?
  _TR_		dd	?

  Org 080H
	dd	12345678h

  Org 100H

Proc	DoTest	near
	mov	eax,esp
	mov	ebp,esp

	db	67h		; change address size prefix
	db	66h		; change operand size prefix
;	db	6Ah,90h		; push immediate 8 bit
;	db	68h,90h,90h	; push immediate 16 bit
	call	DT0

	db	8 dup (90h)	; nop's
DT0:
	db	4 dup (90h)	; nop's
	sub	eax,esp
	mov	esp,ebp
EndP

Proc	SaveState	near
	push	ebx
	mov	ebx,[esp+8]
	mov	[ebx+TSS.saveEAX],eax
	mov	[ebx+TSS.saveECX],ecx
	mov	[ebx+TSS.saveEDX],edx
	pop	eax
	mov	[ebx+TSS.saveEBX],eax
	mov	[ebx+TSS.saveESP],esp
	mov	[ebx+TSS.saveEBP],ebp
	mov	[ebx+TSS.saveESI],esi
	mov	[ebx+TSS.saveEDI],edi
	mov	ax,es
	movzx	eax,ax
	mov	[dword ebx+TSS.saveES],eax
	mov	ax,cs
	movzx	eax,ax
	mov	[dword ebx+TSS.saveCS],eax
	mov	ax,ss
	movzx	eax,ax
	mov	[dword ebx+TSS.saveSS],eax
	mov	ax,ds
	movzx	eax,ax
	mov	[dword ebx+TSS.saveDS],eax
	mov	ax,fs
	movzx	eax,ax
	mov	[dword ebx+TSS.saveFS],eax
	mov	ax,gs
	movzx	eax,ax
	mov	[dword ebx+TSS.saveGS],eax

	lea	eax,[ebx+100H]
	mov	[dword ebx+TSS.saveEIP],eax

	pushfd
	pop	[dword ebx+TSS.saveEFlags]

;	str	[word ptr _TR_]
;	sidt	[pword ptr ebx+_GDT_]
;	sgdt	[pword ptr ebx+_IDT_]
;	sldt	[TSS.saveLDT]

	mov	eax,10101010H

	retn

;    Sel_Lien_Arriere dw ?,0	;(???)
;    ESP_CPL0	dd	?	; non mis à jour
;    SS_CPL0	dw	?,0	;
;    ESP_CPL1	dd	?	;
;    SS_CPL1	dw	?,0	;
;    ESP_CPL2	dd	?	;
;    SS_CPL2	dw	?,0	;
;		dd	0	;(réservé)
;    saveEIP	dd	?
;    saveEFlags	dd	?
;
;    TrapBit	dw	0	; non mis à jour
;    BaseCarteES	dw	?	; non mis à jour

if1
 AAA	db 10240 dup (?)
 public AAA
endif

EndP

EndS
End

IF 0
  Test results:
- when in 16-bit *operand* mode, push's decrement stack by 2.
- when in 16-bit *operand* mode, immediate pushes are 16-bit.
ENDIF
