?login_element?

Subversion Repositories NedoOS

Rev

Rev 653 | Blame | Compare with Previous | Last modification | View Log | Download

;ЇюЁьрЄ ьхЄъш:
;(2) рфЁхё ёыхфє■∙хщ ьхЄъш шыш _LBLBUFEOF (0xffff)
;[(1) фышэр шьхэш ьхЄъш (Єюы№ъю т lbltype.c)]
;(n) шь  ьхЄъш (ASCIIZ)
;(1) Єшя ьхЄъш
;(1) ыюъры№эюёЄ№ ьхЄъш (isloc), юс√ўэю 0
;(2) рфЁхё ьхЄъш Єшяр (т lbltype.c шэфхъё ьхЄъш Єшяр т ьрёёштх _lbls)
;(2) ЁрчьхЁ шэЇюЁьрЎшюээюую яюы  яхЁхьхээющ шыш Єшяр (1,2,4 шыш ьэюую фы  ёЄЁєъЄєЁ, 0 фы  ЇєэъЎшщ)

;_lblhash = 0x00;
;REPEAT {
;  _lblshift[_lblhash] = _LBLBUFEOF;
;  INC _lblhash;
;}UNTIL (_lblhash == 0x00);
;_lblbuffreeidx = 0;
initlblbuf
        EXPORT initlblbuf
        xor a
        LD HL,_lblshift
        LD DE,_LBLBUFEOF
initlblbuf.A.
        LD [HL],E
        INC HL
        LD [HL],D
        INC HL
        INC a
        JP NZ,initlblbuf.A.
        LD HL,_lbls
        LD [_lblbuffreeidx],HL
        RET

;тхЁэєЄ№ Єшя ьхЄъш _name ш _typeaddr
;t = _T_UNKNOWN;
;_lblhash = (BYTE)hash((PBYTE)_name);
;plbl_idx = _lblshift[_lblhash];
;WHILE (plbl_idx != _LBLBUFEOF) { //яюър Ўхяюўър ьхЄюъ эх чръюэўшырё№
;  plbl = &_lbls[plbl_idx];
;  plbl_idx = *(PUINT)(plbl);
;  plbl = &plbl[+sizeof(UINT)+1]; //skip string size
;  IF (strcp((PCHAR)_name, (PCHAR)plbl)) { //ьхЄър эрщфхэр
;    _typeaddr = (UINT)(plbl - _lbls); //фы  чряюьшэрэш  Єшяр т сєфє∙хщ яхЁхьхээющ //т C шэфхъё√, т рёьх єърчрЄхыш (ыхчєЄ т UINT)
;    plbl = &plbl[_lenname+1];
;    t = *(TYPE*)(plbl);
;    plbl = &plbl[+sizeof(TYPE)]; //INC plbl;
;    _isloc = (BOOL)*(PBYTE)(plbl);
;    INC plbl;
;    IF ((t&_T_TYPE)==(TYPE)0x00) _typeaddr = *(PUINT)(plbl); //тёяюьшэрхь рфЁхё Єшяр, хёыш ¤Єю яхЁхьхээр , р эх юс· тыхэшх Єшяр
;    plbl = &plbl[+sizeof(UINT)];
;    _varsz = *(PUINT)(plbl);
;    break;
;  };
;};
;RETURN t;
lbltype
        EXPORT lbltype
        LD de,[_name]
        xor a
        ld h,a
        ld l,a
lbltype.hash0.
        xor l
        add hl,hl
        add a,l ;TODO h
        ld l,a
        ld a,[de]
        inc de
        or a
        jp nz,lbltype.hash0.
        ld h,a;0
        add hl,hl
        LD de,_lblshift
        ADD HL,DE
        ld [_lblhashaddr],hl ;for addlbl
        LD e,[HL]
        INC HL
        LD d,[HL] ;de=first label (from hash)
lbltype.A.
        ld a,d
        and e
        inc a ;label==_LBLBUFEOF?
        jr z,lbltype.B. ;not found
        ex de,hl
        LD e,[HL]
        INC HL
        LD d,[HL] ;de=next label
        inc hl
        LD [lbltype.newtypeaddr],hl ;фы  чряюьшэрэш  Єшяр т сєфє∙хщ яхЁхьхээющ
        LD bc,[_name] ;de
lbltype.strcp0.
        ld a,[bc] ;s2 (name)
        cp [hl] ;s1 (label name)
        jr nz,lbltype.A.
        inc hl
        inc bc
        or a
        jp nz,lbltype.strcp0.
        LD a,[HL]
        ld c,a ;t
        inc hl ;+sizeof(TYPE)
        AND _T_TYPE
        LD A,[HL]
        LD [_isloc],A
        INC HL
        LD e,[HL]
        INC HL
        LD d,[HL] ;рфЁхё Єшяр
        inc hl
        jr Z,lbltype.E. ;шёяюы№чєхь рфЁхё Єшяр
lbltype.newtypeaddr=$+1
        ld de,0 ;хёыш ¤Єю юс· тыхэшх Єшяр, Єю шёяюы№чєхь рфЁхё ёрьющ ьхЄъш
lbltype.E.
        LD [_typeaddr],de
        LD e,[HL]
        INC HL
        LD d,[HL]
        LD [_varsz],de
        ld a,c ;RETURN t
        ret
lbltype.B.
        LD A,_T_UNKNOWN
         ;ld hl,_lbls+2
         ;LD [_typeaddr],hl ;фы  чряюьшэрэш  Єшяр т сєфє∙хщ яхЁхьхээющ
        RET

;_lblhash = (BYTE)hash((PBYTE)_name);
;plbl_idx = _lblshift[_lblhash];
;WHILE (plbl_idx != _LBLBUFEOF) { //яюър Ўхяюўър ьхЄюъ эх чръюэўшырё№
;  plbl = &_lbls[plbl_idx];
;  plbl_idx = *(PUINT)(plbl);
;  plbl = &plbl[+sizeof(UINT)+1]; //skip string size
;  IF (strcp((PCHAR)_name, (PCHAR)plbl)) { //ьхЄър эрщфхэр
;    POKE *(PCHAR)(plbl) = '\0';
;    break;
;  };
;};
dellbl
        EXPORT dellbl
        LD de,[_name]
        xor a
        ld h,a
        ld l,a
dellbl.hash0.
        xor l
        add hl,hl
        add a,h;l
        ld l,a
        ld a,[de]
        inc de
        or a
        jp nz,dellbl.hash0.
        ld h,a;0
        add hl,hl
        LD de,_lblshift
        ADD HL,DE
        LD e,[HL]
        INC HL
        LD d,[HL]
dellbl.A.
        ld a,d
        and e
        inc a ;de==_LBLBUFEOF?
        ret z
        ex de,hl
        LD e,[HL]
        INC HL
        LD d,[HL]
        inc hl
        LD [dellbl.plbl],HL
        LD bc,[_name]
dellbl.strcp0.
        ld a,[bc] ;s2
        cp [hl] ;s1
        jr nz,dellbl.A.
        inc hl
        inc bc
        or a
        jp nz,dellbl.strcp0.
dellbl.plbl=$+1
        LD [0],a
        RET

;тч Є№ эрчтрэшх Єшяр ёЄЁєъЄєЁ√ т s (ёЁрчє яюёых lbltype)
;RETURN strcopy((PCHAR)&_lbls[_typeaddr], (UINT)*(PBYTE)&_lbls[_typeaddr-1], s); //from, n, to //т C шэфхъё√, т рёьх єърчрЄхыш (ыхчєЄ т UINT)
gettypename
        EXPORT gettypename
        EXPORT gettypename.A.
        LD hl,[_typeaddr]
gettypename.A.=$+1
        ld de,0 ;to
        xor a
        ld b,a
        ld c,a
gettypename0
        cp [hl]
        ldi
        jp nz,gettypename0 ;bc=-len
        ld h,a
        ld l,a ;0
        scf
        sbc hl,bc ;0-(-len)-1 = len-1 ;len without terminator
        RET

;EXPORT PROC addlbl(TYPE t, BOOL isloc, UINT varsz) //(_name)
;oldt = lbltype(); //(_name) //єёЄрэртыштрхЄ _isloc (хёыш эрщфхэр) ш _typeaddr (рфЁхё, хёыш эрщфхэр)
;IF ((oldt == _T_UNKNOWN)||isloc) { //хёыш эх с√ыю ьхЄъш шыш ыюъры№эр  яютхЁї уыюсры№эющ шыш фЁєующ ыюъры№эющ (ярЁрьхЄЁр)
;  //ьхЄъш эхЄ: яш°хь т эрўрыю Ўхяюўъш рфЁхё ъюэЎр ёЄЁрэшЎ√ ш ёючфр╕ь ьхЄъє Єрь ёю ёё√ыъющ эр ёЄрЁюх эрўрыю Ўхяюўъш
;  freeidx = _lblbuffreeidx; //[0] //эрўрыю ётюсюфэюую ьхёЄр
;  IF (freeidx < _LBLBUFMAXSHIFT) { //хёЄ№ ьхёЄю яюф ьхЄъє
;    plbl = &_lbls[freeidx]; //єърчрЄхы№ эр эрўрыю ёючфртрхьющ ьхЄъш
;    //яш°хь ьхЄъє
;    POKE *(PUINT)(plbl) = _lblshift[_lblhash]; //ёЄрЁ√щ єърчрЄхы№ эр эрўрыю Ўхяюўъш
;    plbl = &plbl[+sizeof(UINT)];
;    POKE *(PBYTE)(plbl) = (BYTE)_lenname;
;    INC plbl;
;    strcopy(_name, _lenname, (PCHAR)plbl);
;    plbl = &plbl[_lenname+1];
;    POKE *(TYPE*)(plbl) = t;
;    plbl = &plbl[+sizeof(TYPE)]; //INC plbl;
;    POKE *(PBYTE)(plbl) = (BYTE)isloc;
;    INC plbl;
;    POKE *(PUINT)(plbl) = _typeaddr; //ёё√ыър эр эрчтрэшх Єшяр (фы  ёЄЁєъЄєЁ√)
;    plbl = &plbl[+sizeof(UINT)];
;    _varszaddr = (UINT)(plbl - _lbls); //ўЄюс√ яюЄюь ьюцэю с√ыю ьхэ Є№
;    POKE *(PUINT)(plbl) = varsz;
;    _lblbuffreeidx = (UINT)(plbl - _lbls) + +sizeof(UINT); //єърчрЄхы№ ъюэхЎ ёючфртрхьющ ьхЄъш
;    _lblshift[_lblhash] = freeidx; //эют√щ єърчрЄхы№ эр эрўрыю Ўхяюўъш
;  }ELSE {errstr("nomem"); enderr();
;  };
;}ELSE IF (oldt != t) {
;  errstr("addvar type doesn't match previous declaration:"); errstr(_name); enderr();
;};
addlbl
        EXPORT addlbl
        EXPORT addlbl.A.
        EXPORT addlbl.B.
        EXPORT addlbl.C.
        CALL lbltype
        LD [addlbl.oldt],A
addlbl.B.=$+1
        ld b,0
        inc b
        jr z,addlbl.islocon
        SUB _T_UNKNOWN
        JP nz,addlbl.D.
addlbl.islocon
        LD HL,[_lblbuffreeidx] ;addr of free space for a label
        LD DE,_lbls+_LBLBUFMAXSHIFT
        LD A,L
        SUB E
        LD A,H
        SBC A,D
        JP NC,addlbl.F.
        ex de,hl ;de=addr of space for a label
_lblhashaddr=$+1
        LD hl,0
        ld a,[hl]
        ld [hl],e ;correct addr in hash table LSB
        ld [de],a ;copy next label addr from hash table LSB
        inc hl
        ld a,[hl]
        ld [hl],d ;correct addr in hash table HSB
        inc de
        ld [de],a ;copy next label addr from hash table HSB
        inc de
        LD bc,[_lenname]
        LD HL,[_name]
        inc bc ;copy with terminator
        ldir
        ex de,hl
addlbl.A.=$+1
        LD [HL],0 ;t
        inc hl
        LD A,[addlbl.B.] ;isloc
        LD [HL],A
        INC HL
        LD DE,[_typeaddr]
        LD [HL],E
        INC HL
        LD [HL],D
        INC HL
        LD [_varszaddr],HL
addlbl.C.=$+1
        LD DE,0 ;varsz
        LD [HL],E
        INC HL
        LD [HL],D
        INC HL
        LD [_lblbuffreeidx],hl
        ret
addlbl.F.
        LD HL,addlbl.H.
        LD [errstr.A.],HL
        CALL errstr
        jp enderr
addlbl.D.
        LD A,[addlbl.A.] ;t
addlbl.oldt=$+1
        SUB 0
        ret z
        LD HL,addlbl.K.
        LD [errstr.A.],HL
        CALL errstr
        LD HL,[_name]
        LD [errstr.A.],HL
        CALL errstr
        jp enderr
addlbl.H.
        db "nomem",0
addlbl.K.
        db "addvar type doesn't match previous declaration:",0

;POKE *(PUINT)(&_lbls[addr]) = shift;
setvarsz
        EXPORT setvarsz
        EXPORT setvarsz.A.
        EXPORT setvarsz.B.
setvarsz.B.=$+1
        LD hl,0 ;shift
setvarsz.A.=$+1
        LD [0],hl ;addr
        RET