WEB开发网
开发学院软件开发汇编语言 汇编源码系列之getseg_c 阅读

汇编源码系列之getseg_c

 2008-04-29 09:33:31 来源:WEB开发网   
核心提示:这个都是过去DOS时代的汇编源码,虽然已经过去了,汇编源码系列之getseg_c,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......

; Name     getseg -- Get current Segment Values
;
;
; Synopsis   getseg(pcs, pds, pes, pss, psi, pdi, psp, pflag);
;
;        unsigned *cs Pointer to where code segment address goes
;        unsigned *ds Pointer to data segment
;        unsigned *es Pointer to extra segment
;        unsigned *ss Pointer to stack segment
;        unsigned *si Pointer to si register
;        unsigned *di Pointer to di register
;        unsigned *sp Pointer to sp register
;        unsigned *flag Returns flag
;
;
; Returns    cs       value of Code segment
;        ds       value of Data segment
;        es       value of Extra segment
;        ss       value of Stack segment
;        si       value of SI register ****NOT RELIABLE****
;        di       value of DI register
;        sp       value of Stack Pointer
;        flag      value of Flags register
;
;
;
pgroup group  prog
prog  segment byte public 'PROG' ; Combine with C 'PROG' program segment
    assume  cs:pgroup
    public  getseg
getseg proc   near
    push   bp         ; Save the frame pointer
    mov   bp,sp
    mov   si,[bp + 04]    ; Get the values for the registers
    mov   ax,[si]
    mov   si,[bp + 06]
    mov   bx, [si]
    mov   si,[bp + 08]
    mov   cx, [si]
    mov   si,[bp + 10]
    mov   dx,[si]
;==============================================================================
    mov ax, cs         ;Get value of code segment
    mov bx, ds         ;data segment
    mov cx, es         ;extra segment
    mov dx, ss         ;stack segment
;==============================================================================
uret:  mov   bp,sp       ; Now recover the values of the
    mov   si,[bp + 04]    ; parameters
    mov   [si],ax
    mov   si, [bp + 06]
    mov   [si], bx
    mov   si, [bp + 08]
    mov   [si], cx
    mov   si, [bp + 10]
    mov   [si], dx
    mov   si, [bp + 12]
    mov   [si], si
    mov   si, [bp + 14]
    mov   [si], di
    mov   si, [bp + 16]
    mov   [si], sp
    mov   al, 00       ;zero out al
    lahf            ;load flag into ah
    mov   si, [bp + 18]
    mov   [si], ax
    mov   ax,0        ; No error
quit:  pop   bp         ; Get the original frame pointer.
    ret
getseg endp
prog  ends
    end


Tags:汇编 源码 系列

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接