Jump to content

phantomas90

Active Members
  • Posts

    375
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by phantomas90

  1. Special Review - "The IDA Pro" book - 2nd Edition Postby SecurityXploded » Fri Jun 17, 2011 10:20 am Few days back we were approached by "No Starch Press" to write special review for their upcoming second edition of 'IDA Pro Book".Second edition of this awesome title is set to release on next week on June 24, 2011. We had written short review for the first edition of this book - the most splendid book every produced on world’s most popular disassembler. And it is highly recommended by Ilfak Guilfanov, the man behind the IDA Pro Disassembler. We have received the copy of 2nd edition from the publisher today and we will be soon publishing our review soon. You can expect the review to be out some time early next month. Sursa: Aici download: Aici
  2. ATB-Atlantis ma relaxeaza
  3. Acum e nevoie de ajutorul vostru.Aici veti gasi programul. Deschideti, alegeti tipul de harta si zoom-ul si dati "arata harta". Dupa ce apare harta va aparea si un msgbox in care vor fi afisate coordonatele:scrieti-le undeva. Dupa care intrati pe google maps/earth si va cautati locatia voastra exacta, apoi reveniti cu un post de genu: "Am rulat programul si mi-a aratat coordonatele: X,Y. Coordonatele mele reale sunt X1,Y1. Providerul meu de internet este: Orange-disconnecting people IP-ul meu este:aaa.bbb.ccc.ddd" Va rog sa fiti cat mai seriosi, fiecare informatie de aici va fi luata ca referinta cand se calculeaza abaterile cauzate de ip2location. Puteam sa includ ceva in sursa sa-mi dea direct datele pe un ftp, dar las la latitudinea voastra. Cum se va face asta:Iau cate un IP si coordonatele reale, rulez acest ip2location pentrul acel IP si pentru mine. apoi fac translatie cu v/2(v fiind vectorul de translatie) a punctului meu. apoi aplic chestia asta in functie de cate ip-uri de test am la dispozitie. Asfel la 100 de IP-uri+coordonate voi avea o eroare maxima de 5m. Programul de mai sus, in faza actuala nu permite decat localizarea ip-lui propriu. In faza finala va fi free dar fara sursa. Oricine vrea sa contribuie va primi sursa. Va multumesc!
  4. ____________________________________________________________________
  5. @hellscream uite si optimizarea: Ai doua puncte: A1 si B1 de coordonate cunoscute. Punctele A, B si C le "ceri" tu coordonatele. si rezulta un triunghi ABC. Trasezi 2 cercuri: Unul cu centrul in A1 si cu raza A1-A si celalalt centru in B1 si raza B1-B. Ele se intersecteaza in doua puncte.(eu nu le-am mai denumit dar poti sa le zici C1 si C2). Apoi compari rapoartele (A1-A)/(C1-C) cu (A1-A)/(C2-C) si alegi punctul pentru care raportul da cel mai mic rezultat. E o metoda asemenatoare cu metoda triangulatiei.
  6. @hellscream totul e legat de linia asta: hhttp://maps.google.com/maps/api/staticmap?center=" & $nr_lat & "," & $nr_long & "&zoom="& $zoom2 & "&size=" & $Size2 &"&maptype="& $MapType2 & "&markers=color:blue%|label:A%7C" & $nr_lat & "," & $nr_long & "&[COLOR="Red"]sensor=false[/COLOR]","staticmap.png" Citeste aici sa vezi care e treaba cu acel sensor: static maps api si vino cu o idee de optimizare. Ce am inteles eu de acolo e ca sensor=true se da doar atunci cand folosesti un device gen gps sau telefon cu gps. Acum treaba cu coordonatele e in functie de providerul de net. Am testat cu syntesis, din BV: eu am coordonate intregi, el are zecimale.
  7. @cco poate ai dreptate. Nu zic ca nu exista microcontrolere specializate pe asa ceva. Dar asta am facut pastrand doar principiul de polarizare al tranzistoarelor, restul fiind calculate si simulate pana a iesit. Cat despre compresia audio: da, am schema dar inca nu m-am apucat de ea, inca ma depaseste. In primul rand eu am postat pt incepatori, in al doilea rand daca folosesc scheme home made poate le voi repara mai usor cand crapa iar in al treilea rand microcontrolerele au la baza tot tranzistoare:D
  8. Nu cred ca va accepta Sulea aceasta metoda de rezolvare. E simplu sa modifici o adresa din functia de verificare a parolei si sa sara la "goodBoy". De exemplu ai: JB SHORT 004013B8 salt care face parte din verificare. daca modifici cu: JB SHORT 004013D3 orice cod vei introduce va fi dat ca fiind corect si iti va afisa mesajul dorit.
  9. ca ion a vazut extrateresti?-probabil asta e raspunsul asteptat. sau gresesc?
  10. Din titlu va dati seama la ce ajuta. Avantajul este ca poate tine aproximativ constanta tensiunea de iesire chiar daca are variatii mari la intrare. Schema circuitului este urmatoarea: Amplificarea se face in 2 etaje. Reglarea se face prin acel circuit. Tensiunea se "culege" din iesirea celui de-al doilea etaj. La o tensiune de intrare de 1miliVolt vom avea la iesire: Iar daca avem la intrare 0.001 miliVolti la iesire avem: Simularile sunt facute in OrCad. Intrebarea probabila:" La ce ajuta?" -Daca vreti sa va faceti microfoane directionale, protejaza impotriva zgomotelor puternice(care pot "arde" difuzorul); poate fi aplicata si la "iesirea" unui anumit canal audio: astfel se pot lega boxe mai mici la statii de putere mare. - La anumiti senzori(de ex celule fotoelectrice) - Cel mai frecvent utilizate este la radare. Trecand la partea tehnica: Circuitul este dimensionat pentru lucru in domeniul 0.001mV--> 30mV, cu iesire in domeniul 1,05V--> 1,5V dar nu conteaza asta, conteaza principiul. Cine doreste sa-l modifice pt uzul propriu PM si va trimit proiectul orcad de unde puteti redimensiona dupa nevoie. Ideea mea este sa-l modific si pt semnale Dirac(dreptunghiulare) cu iesire in 4,5V-->5V pentru a putea fi legat pe portul USB. Astfel, cu ajutorul unor "mesteri" in ASM se pot aduce informatii in PC de la orice senzor exterior(optici, de miscare, etc).
  11. torrentul tau nu mai merge. Am gasit modulul cu introducerea, si acum downloadez astea. Am pus imagine ca nu avem voie cu torrente.
  12. pyth0n3, cand zici "aceiasi sursa" te referi la acelasi IP? Pt ca doua PC-uri diferite cu acelasi provider de internet(gen clicknet), cu IP dinamic, pot avea la doua momente diferite de timp acelasi IP.[testat]
  13. Din punct de vedere teoretic este posibil ce ai zis tu. Explicatie: Avem un model de circuit integrat pe placa(precum in imagine): Datorita apropierii conductoarelor(acele linii aurii de pe placa) exista posibilitatea aparitiei unei reactante capacitive(ca si cum ar exista un condensator). Q:Ce inseamna asta? A:Inseamna ca se inchide un circuit. Q:Care circuit? A: Circuitul de sub butonul de deschidere a convorbirii.(adica intra in functiune microfonul+difuzorul). Q: De ce se intampla acest fenomen? A: Datorita distantei foarte mici dintre cele doua extremitati care in mod normal ar intra in contact doar prin apasarea butonului. Q: Dar prin condesator nu trece curentul.Deci...? A: Corect. Prin condensator nu trece curent continuu, acela care exista in bateria telefonului. Convorbirea telefonica este bazata pe modulatia in impulsuri a semnalului rezultat din microfon( exista o carte: "GSM pentru incepatori"). Curentul alternativ poate trece prin condensator=> se poate initia convorbirea fara acordul receptorului. Q: Care sunt conditiile fizice pentru realizarea fenomenului? A: O amplitudine mult mai mare a semnalului de apel.(se poate realiza din releul de telecomunicatii, sau prin telecomandarea releului-acea antena de pe deal fara de care nu avem semnal la telefon). Q: Da, dar daca aplitudinea e mult mai mare, inseamna ca deschide toate telefoanele din zona. A: Gresit. Fiecare convorbire are alocat un spectru de frecventa. Frecventa pe care vorbim noi la telefon are alocat un anumit spatiu( de ex intre 200 si 202 MHZ). Acest spatiu se aloca automat in functie de spectrul inchiriat de provider si de numarul de convorbiri existente in acel moment pe retea( d'aia nu putem suna de craciun sau de anul nou). Codarea semnalului se face tot in functie de frecventa disponibila si de NUMARUL DE TELEFON. In concluzie: daca cineva are acces la comenzile de initiare a apelului te poate asculta in voie. Poate ca unii le stiati, altii nu. Bosny shoot yourself!
  14. Donwload Screenshot: Ideea: Lena lectia 6 Programul dateaza din epoca de piatra. In arhiva veti gasi: -pcsurgeon2.exe -blind cracking -pcsurgeon_test2.exe - check serial return true Sunt doua variante crack-uite ale programului. O sa fac si tutorial daca intereseaza pe cineva.
  15. IceyJoke si Sulea daca amandoi ati fi atat de avansati in Reverse Engineering precum va credeti, pana acum ati fi modificat un client de poker, ati fi plini de bani, ati sta la umbra in Hawai cu cocktail-uri si un Alienware in fata. Eu zic sa terminati cu cearta, fiecare are dreptate in felul lui. Mai bine pt aceasta comunitate ati incerca sa faceti ceva gen Lena: tutoriale "noob fiendly" + paper-uri de pe care sa studiem si muritorii de rand.
  16. La messenger almost always on. In rest depinde de ce am de facut. Daca e vorba doar de filme 5 min si dupa stau in pat. Daca e vorba de ASM, vreo 5-6 ore, cu mici pauze. => Media 2-3 ore.
  17. Da, a fost frumoasa gluma...da iintoarceti-l la loc.
  18. edited. Am introdus codu asta langa al tau pentru localizare pe harta. $nr_lat=$lat $nr_long=$long $hDownload = InetGet("http://maps.google.com/maps/api/staticmap?center=" & $nr_lat & "," & $nr_long & "&zoom=12&size=400x400&sensor=false","staticmap.png", 1, 1) ;****************************************************************** ; Create a GUI for the original image $hGUI1 = GUICreate("Original", 400, 300, 0, 0) GUISetState() _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile ("staticmap.png") ; Draw original image $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND ($hGUI1) _GDIPlus_GraphicsDrawImage ($hGraphic1, $hImage, 0, 0) ; Release resources _GDIPlus_GraphicsDispose ($hGraphic1) _GDIPlus_ImageDispose ($hImage) _GDIPlus_Shutdown () FileDelete("staticmap.png") ------------------------------------------------------------------------ Mai lucrez la partea cu marker, sa pot sa-l pun pe harta si eventual cateva controale de zoom. Atentie: google static maps are limita 1000 de requesturi pe zi. Asta e codul facut de mine separat pt teste: #include <GUIConstantsEx.au3> #include <INet.au3> #include <String.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <ScreenCapture.au3> GUICreate("Image_location",300,300,50,50,-1) GUISetState(@SW_SHOW) $lat=GUICtrlCreateInput("",80,20,100,20,-1) $long=GUICtrlCreateInput("",80,50,100,20,-1) $zoom=GUICtrlCreateInput("",80,80,40,20,-1) $MapType=GUICtrlCreateCombo("roadmap",80,110,100,20,-1) GUICtrlSetData($MapType,"roadmap|satellite|terrain|hybrid","roadmap") $Size=GUICtrlCreateCombo("400x400",80,140,100,20,-1) GUICtrlSetData($Size,"400x400|640x640|500x500|","400x400") ;--------------------------------------------------------- GUICtrlCreateLabel("Latitudine:",5,22,50,20,-1) GUICtrlCreateLabel("Longitudine:",5,52,70,20,-1) GUICtrlCreateLabel("Zoom:",5,82,70,20,-1) GUICtrlCreateLabel("MapType:",5,112,70,20,-1) GUICtrlCreateLabel("Size:",5,142,70,20,-1) ;--------------------------------------------------------- $buton_harta=GUICtrlCreateButton("Arata harta",200,10,100,50,-1) $buton_exit=GUICtrlCreateButton("Exit",200,250,100,50,-1) While 1 $msg = GUIGetMsg() if $msg=$buton_harta Then $nr_lat=GUICtrlRead($lat) $nr_long=GUICtrlRead($long) $zoom2=GUICtrlRead($zoom) $MapType2=GUICtrlRead($MapType) $Size2=GUICtrlRead($Size) $hDownload = InetGet("hhttp://maps.google.com/maps/api/staticmap?center=" & $nr_lat & "," & $nr_long & "&zoom="& $zoom2 & "&size=" & $Size2 &"&maptype="& $MapType2 & "&markers=color:blue%|label:A%7C" & $nr_lat & "," & $nr_long & "&sensor=false","staticmap.png", 1, 1) ;****************************************************************** ; Create a GUI for the original image $x=StringTrimLeft ($Size,4) $xx=int($x) $hGUI1 = GUICreate("Coordonatele cerute",400,400,400,0,-1) GUISetState() _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile ("staticmap.png") ; Draw original image $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND ($hGUI1) _GDIPlus_GraphicsDrawImage ($hGraphic1, $hImage, 0, 0) ; Release resources _GDIPlus_GraphicsDispose ($hGraphic1) _GDIPlus_ImageDispose ($hImage) _GDIPlus_Shutdown () ;****************************************************************** EndIf if $msg=$gui_event_close then GUIDelete($hGUI1) FileDelete("staticmap.png") EndIf If $msg = $buton_exit Then FileDelete("staticmap.png") ExitLoop EndIf WEnd ------------------------------------------------- Am rezolvat, am modificat sursele postate mai sus. Acum merge. In programul facut de synthesis la apasarea "Locate" va arata harta. @pax: uite cat costa un ip2location pt un server: ------- Ce facem noi poate nu va ajunge la acest stadiu dar cred ca va fi folositor cuiva.
  19. Tare programelul. Doar l-am compilat si l-am executat odata: Se pare ca pt noi nu vede decat coordonatele tarii. Am incercat si pe un IP random si mi l-a gasit ca fiind din Republica Ceha dar avea si zecimale la coordonate.
  20. Mersi pt joc. L-am desfacut dar ma blochez la functia de desenare a flagului. Nu pot sa-mi dau seama care e. Am gasit Setimer si am blocat timpul la o secunda. GetPrivateProfileIntW are rost sa incep de aici? Am luat si hack-ul tau si am vazut ca modifici un process. Inca nu stapanesc asa bine API ca sa imi dau seama exact ce se intampla.
  21. Pune jocul intr-o arhiva ca eu nu-l am in windows. Mersi!
  22. Intai explica spune ce stii sa faci si pe ce ramura ai vrea sa aprofundezi. Dupa care vei primi si sfaturi/tutoriale.
  23. Helloo Usr6. Am urmarit si eu tutoriale de genu, cu folosirea IDA Pro. Treaba e ca nu inteleg cum face patch-ul pt programul crack-uit. Adica ai optiunea "Export to exe" dar iti zice ca programul nu suporta asa ceva. Intreb ca poate ai reusit sa faci ceva de aici.Mersi anticipat.
  24. Mda, cum am presupus. Nici o miscare, nici o munca depusa sau un tutorial. Aici aveti o lista completa a comenzilor ASM, cu explicatie la fiecare + intreruperile(cu tot cu explicatii). Deschideti arhiva, rulati executabilul. Daca da vre-o eroare incercati cu File-> Open si din acelasi folder selectati un fisier( de ex ASM) si o sa le incarce pe toate. Enjoy it! Revenind la crack: Nu are rost. Mereu se va gasi cineva sa spuna "cum trebuia sa faci". PM me cei care vreti mai multe materiale pt studiul ASM, reverse etc. ========================================================= The elements of the assembly language and the format of the executable programs Laboratory no. 4 The elements of the assembly language and the format of the executable programs INTRODUCTION The purpose of the paper is the presentation of the instruction format in assembly language, of the most important pseudo-instructions when working with segments and dates conservation and also the structure of the executable programs .COM and .EXE. The elements of the assembly language TASM The format of the instructions An instruction may be represented on a line of maximum 128 characters, the general form being: [<label>:] [<opcod>[<operatives>][;<comments>]] where: <label> is a name, maximum 31 characters (letters, numbers or special characters _,?,@,..), the first character being a letter or one of the special characters. Each label has a value attached and also a relative address in the segment where it belongs to. <opcod> the mnemonic of the instruction. <operatives> the operative (or operatives) associated with the instruction concordant to the syntax required for the instruction. It may be a constant, a symbol or expressions containing these. <comments> a certain text forego of the character “;” . The insertion of blank lines and of certain number of spaces is allowed. These facilities are used for assuring the legibility of the program. The specification of constants Numerical constants – are presented through a row of numbers, the first being between 0 and 9 (if for example the number is in hexadecimal and starts with a character, a 0 will be put in front of its). The basis of the number is specified through a letter at the end of the number (B for binary, Q for octal, D for decimal, H for hexadecimal; without an explicit specification, the number is considered decimal). Examples: 010010100B, 26157Q (octal), 7362D (or 7362), 0AB3H. Character constants or rows of characters are specified between quotation (“ “) or apostrophes (‘ ‘). Examples: “row of characters”, ‘row of characters’ Symbols The symbols represent memory positions. These can be: labels or variables. Any symbol has the next attributes: - the segment where it is defined - the offset (the relative address in the segment) - the type of the symbol (belongs to definition) Labels The labels may be defined only in the zone program and then can be operatives to CALL or JMP instructions. The attributes of labels are: - the segment (generally CS) is the address of the paragraph where begins the segment which contains the label. When a reference is made to the label, the value is found in CS (the effective value is known only during running) - the offset is the distance in octets of the label beside the beginning of the segment where it has been defined - the type determines the reference manner of the label; there are two types: NEAR and FAR. The NEAR type reference is a segment (only the offset) and the FAR type reference specifies also the segment (segment: offset). The labels are defined at the beginning of the source line. If after the label follows “:” character then there will be the NEAR type. Variables The definition of variables (date labels) may be made with space booking pseudo-instructions. The purpose of variables are: - segment and offset – similarly to labels with the distinction that there may be other ledger segments - the type – is a constant, which shows the length (in octets) of the booked zone: BYTE (1), WORD (2), DWORD (4), QWORD (8), TWORD (10), STRUC (defined by the user), RECORD (2). Examples: DAT DB 0FH, 07H ; occupies one octet each, totally 2 DATW LABEL WORD ; label for type conversion MOV AL,DAT ; AL<-0FH MOV AX,DATW ; AL<-0FH, AH<-07H MOV AX,DAT ; type error Expressions The expressions are defined through constants, symbols, pseudo-operatives and operatives (for variables are considered only the address and not the content, because when compiling, only the address is known). Operatives (in the order of priorities) 1. Brackets () [] . (dot) - structure_name.variable – serves for binding the name of a structure with its elements LENGTH – number of zone element SIZE – the zone length in octets WIDTH – a fields width from RECORD Example: if are declared EXP DW 100 DUP (1) Then: LENGTH EXP has the value 100 TYPE EXP has the value 2 SIZE EXP has the value 200 2. segment name: - redefinition of segment Example: MOV AX, ES:[BX] 3. PTR – redefinition of variable type Example: DAT DB 03 MOV AX, WORD PTR DAT OFFSET – furnishes the offset of a symbol SEG – furnishes the segment of a symbol TYPE – a zones type (length of elements) THIS – creation of an attributed operative (segment, offset, type) date Example: SIRO EQU THIS BYTE SIRC DW 100 DUP(?) SIRC is a defined of 100 length; the variable SIRO has the same segment and offset as SIRC but it is BYTE type. 4. HIGH – addresses the high part of a word LOW – addresses the low part of a word Example: DAT DW 2345H MOV AH, HIGH DAT ; AH<-23 5. * / MOD Example: MOV CX, (TYPE EXP)*(LENGTH EXP) 6. + - 7. EQ, NE, LE, LT, GE, GT 8. NOT –logic operative 9. AND 10. or, xor 11. SHORT – forces the short appeal Example: JMP label ; direct jump JMP SHORT label ; IP is relative Pseudo instructions Pseudo-instructions are commands (orders, instructions) for assembler, necessary for the proper translations of the program and for the facility of the computer programmer’s activity. Will be presented only the pseudo-instructions indispensable writing the first programs. Pseudo-instructions work with segments Any segment is identified with a name and class, both specified by the user. When defined, the segments receive a series of attributes, which specifies for the assembler and for the link-editor the relations between segments. The segments definition are made through: segment_name SEGMENT [align_type] [combine type] [‘class’] ... ... segment_name ENDS where: segment_name – is the segment’s name chosen by the user (the name is associated with a value, corresponding to the segment’s position in the memory). align_type – is the segment’s alignment type (in memory). The values, which it may take, are: PARA (paragraph alignment, 16 octets multiple) BYTE (octet alignment) WORD (word alignment) PAGE (page alignment – 256 octets multiple) combine_type – is actually the segment’s type and represents an information for the link-editor specifying the connection of segments with the same name. It may be: PUBLIC – specifies the concatenation COMMON – specifies the overlap AT expression – specifies the segment’s load having the address expression *16 STACK – shows that the current segment makes part of pile segment MEMORY – specifies the segment’s location as the last segment from the program ‘class’ – is the segment’s class; the link-editor continually arranges the segments having the same class in order of its appearance. It is recommended to use the ‘code’, ‘data’, ‘constant’, ‘memory’, ‘stack’ classes. The designation of the active segment In a program may be defined more segments (code and date). The assembler verifies whether the dates or the instructions addressed may be reached with the segment register having a certain content. For a realization in proper conditions, the assembler of the active segment must be communicated, meaning that the segment register must contain the address of the loaded segment. ASSUME <reg-seg>:<name-seg>, <reg-seg>:<name-seg> ... reg-seg – the register segment name-seg – the segment which will be active with the proper register segment Example: ASSUME CS:prg, DS:date1, ES:date2 Observations: - the pseudo-instruction does not prepare the register segment but communicates to the assembler where the symbols must be looked for - DS is recommended to be shown at the beginning of the assembler with a typical sequence: ASSUME DS:name_seg_date MOV AX, name_seg_date MOV DS, AX - CS must not be initialized but must be activated with ASSUME before the first label - instead of name-seg from ASSUME the NOTHING identifier may be used if we don’t want to associate a segment to the register. The preserving of a zone date Usually the dates are defined in a data segment. The pseudo-instruction definition has the type: <name> <type> [expression list] [<factor> DUP (<expression list>)] where: name – is the symbol’s name (of the date’s label) type - is the symbol’s type: DB – for octet reservation DW – for word reservation (2 octets) DD – for double word reservation (4 octets) DQ – for quadruple word reservation (8 octets) DT – for 10 octets reservation expressions list – an expression whose result is initialized with the reserved zone; the “?” character is written only if the zone won’t be initialized factor – a constant, which shows how many times the expression, is repeated after DUP: Examples: DAT db 45 dat1 db 45h, ‘a’, ‘A”, 85h dat2 db ‘abcdefghi’ ; the text is generated lg_dat2 db $-dat2 ; the length of the given row dat2 ($ is the local current counter) aa db 100 dup(56h) ; 100 octets having the value 56h bb db 20 dup (?) ; 20 not initialized octets ad dw dat1 ; contains the address (offset) of the given variable dat1 adr dd dat1 ; contains the address (offset + segment) of given variable dat1 Other possibilities for defining symbols - the definition of constants: <name> EQU <expression> The symbol “name” will be replaced with the value’s expression. - labels declaration: <name> LABEL <type> <name> label will have the value of the segment where it is defined, the offset equal to the offset of the first instruction for date reserving or other instructions which follow and the type defined by the <type> which may be: BYTE, WORD, DWORD, QWORD, TBYTE, the name of a structure, NEAR or FAR. If it’s put the “:” character after label this will be NEAR: Example: if we have the definitions ENTRY LABEL FAR ENTRY1: then: JMP ENTRY ; is FAR type jump JMP ENTRY1 ; is NEAR type jump Position counter modification ORG <expression> ; the position counter will be put to the value’s expression Example: ORG 100h ; counter at 100h ORG $+2 ; skip 2 octets ($ is the local current counter) The definition of the procedure A procedure may be defined as a sequence of instructions which ends with RET instructions and is appealed with CALL. The definition is made with the sequence: <procedure_name> PROC <[NEAR], FAR> ... the procedure’s instructions < procedure_name > ENDP Example: ; DBADD procedure, which at (DX:AX) adds (CX:BX) with the result in (DX:AX) DBADD PROC NEAR ADD AX,BX ; add word LOW ADC DX,CX ; add word HIGH with CARRY DBADD ENDP The appeal is made with CALL DBADD from the same segment. From other segments the procedure is invisible. Observations: - the declaration of the procedure does not make any command; the user must assure the returning with RET. - no appealing procedure may be defined both with FAR and NEAR. This function is established very carefully when projecting the programs (the solution for declaring FAR procedures apparently simple, is totally non-economic). - There is a possibility of defining sheltered procedures The program’s structure in assembly language 1. .COM programs • The program contains only one segment, so the code and date may have, on the whole, maximum 64Ko; because of this the references are relatively made at the address from the beginning of the segment. • The source program must begin with ORG 100H pseudo-instruction for reserving space for PSP. • The dates may be put anywhere in the program, but it is recommended to be put at the beginning (great careful must be paid for not operating by mistake the zone date, meaning not skipping the jump instruction over date zone, otherwise these will be interpreted as instructions, the result being other than the expected one). • It is not necessary the initialization of segment registers, them being loaded with the common value from CS. • The end of the program may be made with RET or with the appeal of function system INT 21H having the parameter in AH 4CH. Model for .COM programs COMMENT * the presentation of the program * CODE SEGMENET PARA PUBLIC ‘CODE’ ASSUME CS:CODE, DS:CODE, ES:CODE ORG 100H START: JMP ENTRY ************** define zone date ENTRY: ************** program’s instructions MOV AH,4CH INT 21H ; exit to operating system CODE ENDS END START 2. .EXE programs • The programs may as larger as the disposing memory. • For the correct execution, the user must explicitly initialize DS, ES and SS registers. • It is recommended that the .EXE programs be conceived as a FAR type procedure (to make able the reversing of the context, so as, at the ending of the program the recovery is made correct, if the program has been appealed from another program). Because of this, at the beginning of the program, through the sequence: push ds mov ax,0 push ax is saved a vector, which shows at PSP beginning and in these conditions the ending of an .EXE program may be made through RET in FAR context. Model for .EXE program COMMENT * identification information for the program, author, data, program’s function, utilization * ;----------------------------------------------------------------------------------------- ; EXTERN section ; the declaration of extern variables ;----------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------- ; PUBLIC section ; the list of GLOBALE’S variables defined in this file ---------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------- ; CONSTANTE’S section ; The definitions of constants, including INCLUDE instructions, which read ; constant definitions ;----------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------- ; MACRO section ; Macro definitions, structures, recordings and/or INCLUDE instructions which ; read such definitions ;----------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------- ; DATA section ; date definitions ;----------------------------------------------------------------------------------------- DATA SEGMENT PARA PUBLIC ‘DATA’ ... ... define date zone DATA ENDS ... ... other date segment ;----------------------------------------------------------------------------------------- ; STACK section ;----------------------------------------------------------------------------------------- STACK SEGMENT PARA STACK ‘STACK’ DW STACK_SIZE DUP (?) ; the pile will have 256 words STACK_START LABEL WORD ; the top of the pile STACK ENDS ;----------------------------------------------------------------------------------------- ; CODE section ;----------------------------------------------------------------------------------------- CODE SEGMENT PARA PUBLIC ‘CODE’ START PROC FAR ASSUME CS:CODE, DS:DATA PUSH DS XOR AX,AX PUSH AX ; the initialization for the returning MOV AX,DATA MOV DS, AX ; the initialization of DS date segment ;----------------------------------------------------------------------------------------- ... ... the main program’s instructions ;----------------------------------------------------------------------------------------- RET ; the ending of FAR type program START ENDP ;----------------------------------------------------------------------------------------- ; PROCEDURES ; other procedures from the main program ;----------------------------------------------------------------------------------------- CODE ENDS ... ... other code segment ;----------------------------------------------------------------------------------------- ; the memory’s segment section ;----------------------------------------------------------------------------------------- MEMORY SEGMENT PARA MEMORY ‘MEMORY’ ... ... programs at high addresses ... ... the definition of the memory’s margins of the program MEMORY ENDS END START Example of written program in assembly language The program calculates the sum of a row of numbers at SIR address and length specified in LGSIR variable; the result will be put in SUM location. The first source program will be in the .COM type CODE SEGMENT PARA PUBLIC ‘CODE’ ASSUME CS:CODE, DS:CODE ORG 100H START: JMP ENTRY SIR DB 1,2,3,4 LGSIR DB $-SIR SUM DB 0 ENTRY: MOV CH,0 MOV CL,LGSIR ; in CX is the length’s row MOV AL,0 ; the initialization of the register where the sum is ; calculated MOV SI,0 ; the index’s initialization NEXT: ADD AL,SIR[SI] ; the add of the current element INC SI ; passing at the next element in the row LOOP NEXT ; CX decrementation and jump to next ; element if CX differs from 0 MOV SUM,AL ; end of program MOV AH,4Ch INT 21H CODE ENDS END START Laboratory tasks • The presented example will be studied. • Will be written the program for calculating the sum of a row’s elements in .COM format, will be assembled, link-edited and fault traced with Turbo Debugger following the registers and memories content (SUM location). • Will be rewritten the .EXE format program and will be fault traced. • Will be modified the program in such a way to be able to add numbers written on word (2 octets, DW) and will be studied the case where the number’s sum does not enter on the same length with the numbers from the row. Mai am cateva laboratoare de genu. Mai vreti?
×
×
  • Create New...