was haltet ihr von dem code einer 16bit EMB/XMS/EMS Verwaltung



  • EMB/XMS/EMS Verwaltung

    int xms;
    int *offbuffer[17];
    char *XMSControl;
    typedef int WORD;
    typedef char BYTE;
    typedef char *SEG;
    typedef char *OFS;
    
    typedef struct tagEMBinfos
     {
      BYTE lockcount;       /* n what ever */
      WORD bufferlen;       /* n the length of the buffer mybe used for exact use of the buffer thing*/
      BYTE ERROR;           /* 0 does it worked or is there an error 0 it error */
      BYTE HandleInvalid;   /* 0 the buffer may not exists */
      BYTE FuncNotValid;    /* 0 if the function is not implemented */
      BYTE VDISK;           /* 0 if not, 1 if yes */
      BYTE HandleLocked;    /* 0 if not, 1 if yes */
      BYTE NoMemory;        /* 0 if memor is availaible, 1 if not */
      BYTE NoHandles;       /* 0 if not else 1 */
      WORD *Handle;         /* if used */
      WORD cflag;
      } EMBinfos;
     EMBinfos embinfoblk, *embinfo=&embinfoblk;
    
      /**********************************************************************
       *    INIT XMS FUNCTION
       *    EMB  whatever
       *
       *
       ***********************************************************************/
    int emberror(int error){
    embinfo->FuncNotValid=0;
    embinfo->HandleInvalid=0;
    embinfo->VDISK=0;
    embinfo->NoMemory=0;
    embinfo->NoHandles=0;
    embinfo->HandleLocked=0;
    switch(error){
    case 0x0080: embinfo->FuncNotValid=1;
    case 0x00A2: embinfo->HandleInvalid=1;
    case 0x0081: embinfo->VDISK=1;
    case 0x00A0: embinfo->NoMemory=1;
    case 0x00A1: embinfo->NoHandles=1;
    case 0x00AB: embinfo->HandleLocked=1;
      }
    return 1;
    }
    
    int initXMS(void){
    asm{
    mov ax,4300h
    int 2fh
    }
    if(_AL==0x80){
    xms=1;
    asm{
    mov ah,43h
    mov al,10h
    int 2fh
    mov word ptr [XMSControl],bx
    mov word ptr [XMSControl+2],es
    }
    return 1;
    }else {
    emberror(_BL);
    return 0;
    }
    }
    
    int *allocEMB(int size){
    if (xms==1){
    asm{
    mov dx,size
    mov ah,09h
    call [XMSControl]
    }
    if (_AX==0){
    emberror(_BL);
    return 0;
    }else{
    embinfo->Handle=(int *)_DX;
    return (int *)_DX;
    }
    
    }
    return (int *) 0x000;
    }
    
    int lockEMB(int *handle){
    // Nicht implementiert steht in irgendeiner RFC
    return 1;
    }
    
    int queryEMB(void){
    if (xms==1) {
    asm {
    mov ah,08h
    call [XMSControl]
    }
    return _DX;
    }
    return 0;
    }
    
    int freeEMB(int *segment){
    if (xms==1) {
    asm {
    mov ah,0ah
    mov dx,word ptr [segment]
    call [XMSControl]
    }
    if (_AX==0x0000){
    emberror(_BL);
    return 1;
    }else {
    return _AX;
    }
    }
    return 0;
    }
    
    int getEMBinfo(int *handle){
    embinfoblk.ERROR =0x0080;
    embinfo->bufferlen=0;
    embinfo->HandleInvalid=0;   /* 0 the buffer may not exists */
    embinfo->FuncNotValid=0;    /* 0 if the function is not implemented */
    embinfo->VDISK=0;
    asm {
       mov ah,0eh
       mov dx,word ptr [handle]
       call [XMSControl]
        }
      if (_AX==0x0001) {
       embinfo->ERROR =_AX;
       embinfo->bufferlen =_DX;
       embinfo->lockcount =_BH;
      return 1;
      }else {
       embinfo->ERROR = 0;
       if (_BL==0x0080){embinfo->FuncNotValid=1;}
       if (_BL==0x00A2){embinfo->HandleInvalid=1;}
       if (_BL==0x0081){embinfo->VDISK=1;}
      return 0;
      }
    }
    

    na was meint ihr!

    lg buntehaare


  • Mod

    buntehaare schrieb:

    na was meint ihr!

    Erste Gedanken:
    -Unformatiert 👎
    -Kein Syntax-Highlighting 👎
    -Wieso sollte ich das lesen?
    -Was will der Fragesteller überhaupt?
    -https://sites.google.com/site/csourcecodes/home/codesnippets (edit: Ach, die Seite ist von dir. Das erklärt einiges über das Design der Seite.)



  • buntehaare schrieb:

    na was meint ihr!

    Spitze! Besser hätt ichs auch nicht machen können ...



  • Belli schrieb:

    buntehaare schrieb:

    na was meint ihr!

    Spitze! Besser hätt ichs auch nicht machen können ...

    danke Belli, ich finde der Code erklärt sich von selbst wenn man sich etwas auskennt mit Assembler und ems/xms/emb (RFC's) ., ich programmiere gerne auf low level 16 bit. weil was kommt vor windows 16 bit, wie bios oder hats schon 32 bit ich war zu lang weg um das zu wissen.

    SeppJ
    -https://sites.google.com/site/csourcecodes/home/codesnippets (edit: Ach, die Seite ist von dir. Das erklärt einiges über das Design der Seite.)

    zuviel chaos ? 😉

    typedef struct tagEMBinfos
    {
    BYTE lockcount; /* n what ever /
    WORD bufferlen; /
    n the length of the buffer mybe used for exact use of the buffer thing*/
    BYTE ERROR; /* 0 does it worked or is there an error 0 is an error /
    BYTE HandleInvalid; /
    0 the buffer may not exists /
    BYTE FuncNotValid; /
    0 if the function is not implemented /
    BYTE VDISK; /
    0 if not, 1 if yes /
    BYTE HandleLocked; /
    0 if not, 1 if yes /
    BYTE NoMemory; /
    0 if memory is availaible, 1 if not /
    BYTE NoHandles; /
    0 if not else 1 */
    WORD *Handle; /* if used */
    WORD cflag;
    } EMBinfos;
    EMBinfos embinfoblk, *embinfo=&embinfoblk;

    Man kann den Code natürlich erweitern und für seine zwecke anpassen.

    Ich wollte einfach nur die meinung von euch wissen, danke dafür, auch kritik ist ok 😉
    also ich finde der code ist leicht lesbar ... ?! und er Funktioniert 100%. Es gibt noch einige XMS/EMB funktionen die hier nicht implementiert sind...

    danke tschau
    buntehaare, aja und gutes neues nachträglich , soll es besser werden als das alte...


Anmelden zum Antworten