question in the pm tutorial
Posted: Thu Feb 19, 2004 8:04 pm
following is Pmode #1 written by Alexei A. Frounze.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PMode tutorials in C and Asm ;;
;; Copyright (C) 2000 Alexei A. Frounze ;;
;; The programs and sources come under the GPL ;;
;; (GNU General Public License), for more information ;;
;; read the file gnu-gpl.txt (originally named COPYING). ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GLOBAL _read_msw, _read_cr0, _write_cr0
SEGMENT _TEXT PUBLIC CLASS=CODE USE16
_read_msw:
smsw ax
retn
_read_cr0:
mov eax, cr0 ; read CR0 to eax
mov edx, eax
shr edx, 16 ; dx:ax = CR0 (return value)
retn
_write_cr0:
push bp
mov bp, sp
mov eax, [ss:bp+4] ; eax = 32-bit parameter
mov cr0, eax
pop bp
retn
SEGMENT _DATA PUBLIC CLASS=DATA
in the _write_cr0, to refer the first parameter, why is the offset = 4? not 8? and could I just mov eax, [bp+8]? I tihink no ss segment register needed, am I right?
when calling write_cr0, where is (E)IP register saved?is it saved in stack?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PMode tutorials in C and Asm ;;
;; Copyright (C) 2000 Alexei A. Frounze ;;
;; The programs and sources come under the GPL ;;
;; (GNU General Public License), for more information ;;
;; read the file gnu-gpl.txt (originally named COPYING). ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GLOBAL _read_msw, _read_cr0, _write_cr0
SEGMENT _TEXT PUBLIC CLASS=CODE USE16
_read_msw:
smsw ax
retn
_read_cr0:
mov eax, cr0 ; read CR0 to eax
mov edx, eax
shr edx, 16 ; dx:ax = CR0 (return value)
retn
_write_cr0:
push bp
mov bp, sp
mov eax, [ss:bp+4] ; eax = 32-bit parameter
mov cr0, eax
pop bp
retn
SEGMENT _DATA PUBLIC CLASS=DATA
in the _write_cr0, to refer the first parameter, why is the offset = 4? not 8? and could I just mov eax, [bp+8]? I tihink no ss segment register needed, am I right?
when calling write_cr0, where is (E)IP register saved?is it saved in stack?