By Sen-cuo Ro

This booklet offers x86 meeting language programmers a view approximately easy methods to use the assets and lines supplied by means of the i386/i486 processor, the most recent and such a lot complex microprocessor from the Intel x86 relations. as the i386/i486 processor is fullyyt appropriate with its predecessor, the 8086/88 processor, this publication concentrates at the superior gains in comparison to its predecessor. We imagine the reader is already accustomed to the thoughts of 8086/88 meeting language programming. Our target is to teach you the programming tools that follow to robust positive aspects of the i386/i486. The i387 math coprocessor isn't mentioned during this booklet. an in depth clarification approximately tips to use each one i386/i486 guide isn't really lined during this booklet. even if, we record the whole i386/i486 guide set in Appendix B. association of the ebook This publication is split into sections to aid readers begin studying from the thoughts which are just like the 8086/8088 processor. Then, the dialogue shifts to the assets and surroundings of the i386/i486 processor. in the course of the e-book, real-life application examples are used to demonstrate intimately how one can use the improved good points or features of the processor. bankruptcy 1 introduces the i386/i486 structure and its superior beneficial properties. The dialogue contains the operation mode, common registers, phase registers, approach registers, and approach information buildings. bankruptcy 2 discusses the strategy that the i386/i486 processor makes use of to make itself absolutely appropriate with the 8086/88 processor and to outline the interrupt vector desk tackle, that is varied from the 8086/88 processor.

Show description

Read or Download i386/i486 Advanced Programming: Real Mode Protected Mode Virtual 8086 Mode PDF

Best compilers books

The Definitive Guide to SugarCRM: Better Business Applications (Books for Professionals by Professionals)

SugarCRM is certainly one of if no longer the top Open resource CRM resolution on the market at five. five million downloads and transforming into and with approximately 17,000 registered builders and many extra clients. it will be the reliable, definitive e-book written by way of SugarCRM and recommended by means of SugarCRM. additionally, this publication will be additionally the one SugarCRM developer publication on the way to tackle the platform similar beneficial properties considering SugarCRM five.

Methodologies and Software Engineering for Agent Systems: The Agent-Oriented Software Engineering Handbook

As info applied sciences turn into more and more dispensed and available to bigger variety of humans and as advertisement and executive corporations are challenged to scale their purposes and companies to bigger industry stocks, whereas lowering expenditures, there's call for for software program methodologies and appli- tions to supply the next gains: Richer software end-to-end performance; relief of human involvement within the layout and deployment of the software program; Flexibility of software program behaviour; and Reuse and composition of current software program functions and structures in novel or adaptive methods.

Numeric Computation and Statistical Data Analysis on the Java Platform

Numerical computation, wisdom discovery and statistical facts research built-in with strong 2nd and 3D photographs for visualisation are the foremost subject matters of this ebook. The Python code examples powered through the Java platform can simply be reworked to different programming languages, corresponding to Java, Groovy, Ruby and BeanShell.

Additional info for i386/i486 Advanced Programming: Real Mode Protected Mode Virtual 8086 Mode

Example text

IRestore old IOTR content. lidt fword ptr [old_IOT addr] ;Terminate the program 26 i386/i486 Advanced Programming mov ax,4cOOh int 21h start endp code ends ;Terminate this program ;by calling DOS function call. ;Local Interrupt service routine ;These routines will get the offset address of its message ;and display the message on the screen. INTCODE segment use16 assume cs:intcode,ds:data IntO: mov si,offset IntOM jmp dispmsg Intl: mov si,offset IntlM jmp dispmsg Int2: mov si,offset Int2M jmp dispmsg Int3: mov si,offset Int3M jmp dispmsg Int4: mov si,offset Int4M jmp dispmsg IntS: mov si,offset IntSM jmp dispmsg Int6: mov si,offset Int6M dispmsg jmp Int7: mov si,offset Int7M jmp dispmsg IntS: mov si,offset IntSM jmp dispmsg Int9: mov si,offset Int9M jmp dispmsg IntlO: mov si,offset IntlOM jmp dispmsg Intll : mov si,offset IntllM dispmsg jmp Int12: mov si,offset Int12M jmp dispmsg Int13: mov si,offset Int13M jmp dispmsg Int14: mov si,offset Int14M jmp dispmsg IntlS: mov si,offset IntlSM dispmsg: mov call iret di, SO dispit * 3S ;Message display routine iBecause DOS function call is not available at this time, ;we have to display it by ourself.

H' ,0 ;STEP 6: stack segment for privilege level 0,1,2 stkO segment db 100h stkO limit equ stkO- ends para public use16 'stkO' dup(O) stk1 para public use16 'stk1' dup(O) segment db 100h stk1 limit equ stk1- ends $ $ Enter and Leave Protected Mode 49 stk2 segment db 100h stk2 limit equ stk2- ends para public use16 'stk2' dup(O) $ ;STEP 7: Task state segment taskO TSS TSS stack segment para public use16 'taskO' stkO selec,stkO limit,stk1 selec, stk1-limit, stk2 selec,stk2 limit ;cr3 TSS cr3 TSS-regs O,O,O,O,O,O,O,O,O,stkO limit gdata selec,code selec~stkO selec, Tss=seg gdata-selec,gdata selec,gdata selec dd -0 -;LOT field dw ;task trap flag dw 68h ;l/O base taskO TSS limit equ $ taskO-TSS- ends ° - - ° ; STEP 8: Oununy segment dmy dmy segment para public use16 'dmy' 128 dup(O) db ends ;COOE segment code main segment para public use16 'code' assume cs:code,ds:gdata proc far mov ax,gdata ;get gdata segment address mov ds,ax ;put in os ;STEP 9: initialize lOT mov mov mov mov mov fillidt: mov add add loop iSTEP 10: mov mov xor aX,lOT eS,ax di,offset idt tab aX,offset int=entry cx, lNTNO es:[di],ax di,osCPSlZE aX,lNTSlZE fillidt ;get lOT segment address ;put in ES ;get lOT offset address ;get interrupt service ;routine address ;get interrupt number ;put entry address in lOT ;adjust address in lOT ;adjust interrupt service jroutine address, the size of each ;routine is defined in lNTSlZE ikeep filling get GOT/lOT limit and linear address aX,offset gdt limit PGOT_limit, axeax,eax ;get GOT segment limit iPut in pGOT limit ;clear eax - 50 i386/i486 Advanced Programming mov shl aX,GDT eax,4 mov pGDT_addr,eax mov mov xor mov shl ax,offset idt limit PlDT_limit,axeax,eax ax,idt eax,4 mov plDT_addr,eax ;get GDT segment address ;convert to 32 bit linear ; address ;put in pGDT_addr ;get lOT segment limit iPut in pGDT limit ;clear eax ;get lDT segment address iconvert to 32 bit ;linear address iPut in plDT_addr ;STEP 11: based on gdt phys tab to set linear base address for each corresponaing descriptor bdtl: mov mov mov ax, GOT es,ax si,offset gdt_phys_tab mov cx,gdt_tab_size lodsw mov bx,ax and bX,OfffSh lodsw push shl mov ax ax,4 es:[bx] [d_basel],ax pop shr mov ax ax,12 es:[bx][d_base2],al loop bdtl iget gdt segment address iPut in ES ;get address of igdt phys tab iget-gdt_phys_tab size iget descriptor number iPut in BX imask off Tl bit and RPL iget corresponding isegment address for ithe above descriptor isave it ;get lower 4 bytes offset isave it in descriptor ;basel position irestore segment address iget the highest byte ;save it in descriptor ;base2 position icontinue ; STEP 12 : switch to protected mode cli 19dt [pGDT] lidt [pIDT] mov or mov eax,crO al,prot enable crO,eax- jmp dword ptr cs:[enter_prot] ;far jump to iflush instruction queue enter prot: -dw offset now in prot code selec- dw ;clear interrupt ;load GDT address and ilimit into GDTR ;load lDT address and ilimit into lDTR ;get crO register jset protected mode enabl4 ;restore crO jElP icode segment selector iSTEP 13: execute in protected mode, set LDTR,SS,SP,OS,ES,FS,GS Enter and Leave Protected Mode 51 now in_prot: xor ax,ax lldt ax mov mov mov mov mov mov mov mov ;clear ax ;load NULL selector ito LOTR ax,stkO_selec ;get stack segment ; selector ss,ax ;put in 55 sp,offset stkO limit ;set stack pointer ax,gdata selec;get data segment selector ds,ax ;put in os es,ax ;put in ES fs,ax ;put in FS gs,ax iPut in GS ;STEP 14: display message in protected mode iclear the screen first mov ax,video_selec iget video segment selector es,ax mov iPut in ES cx,4000h ibuffer size to clear mov di,di iscreen starting address xor mov ah,attribute icharacter attribute mov al,space ispace rep stosw ifill it mov si,offset in_protected iget protected mode imessage address mov di,320 iget display address call disp_it icall display procedure iSTEP 15: load TSS to TR mov ax,taskO TSS selec ltr ax iget TSS selector for icurrent task iload into task register - ;STEP 16: switch back to real-address mode int 20 iinterrupt 20 iSTEP 17: Interrupt service Routine REPT call iret ENOM iSTEP 18: disp: pop mov mov sub shr INTNO disp ientry point for iinterrupt service routine icall the display message iprocedure get interrupt number and display it ax ;get return address from stack bx,gdata selec ireload data segment ds,bx ax, offset int_entry iget offset from the ;interrupt entry aX,TWO ;divide by 4 to get 52 i386/i486Advanced Programming mov mov call mov si,offset int num cx,TWO htoa si,offset int_msg mov call di,5*160 disp_it ;STEP 19: cli mov mov mov mov mov mov mov and mov db dw dw iSTEP 20: ;interrupt number ;get ascii code address ;convert to 2 ascii code ;call convert procedure ;get interrupt message ; address ;get display address ;call display procedure return to real-address mode ax,dmy_selec es,ax ds,ax fs,ax gs,ax ss,ax eax,crO eax,not prot_enable crO,eax ;disable interrupt ;dununy selector ;reset segment registers ;load the content of CRO ;disable protected mode ;restore the content of ;CRO Oeah ;far jump to flush ;instruction queue offset next instruction inew EIP code ;new CS execute in real-address mode, set DS,SS and SP next instruction: mov ax, Gdata ;get mov ds,ax ;put mov ax,stkO ;get mov ss,ax ;put mov sp,offset stkO limit data segment address in DS stack segment address in SS ;set stack pointer ;STEP 21: set IDTR to DOS interrupt table lidt [pold] sti ;load DOS interrupt vector ;table to IDTR register ;enable interrupt ;STEP 22: terminate this process main mov int endp ax,4cOOh 21h ;terminate process ;DOS function call ; Procedure: disp it ;Display string in protected mode ; Input: ds:si - string address, the end of the string must ;be 0 disp_it mov mov proc near ax,video_selec es,ax ;get video segment selector iPut in ES Enter and Leave Protected Mode mov disp_itl: lodsb stosw cmp jne ret disp_it ah,attribute ;display attribute al,O disp_itl ;get display character ;put it on screen ;end of display character ?

The offset of these routines is initialized at run time. Step 3: Variable • pGDT is a pointer to a six-byte data that has the linear base address and limit value for the GOT. These values are set at run time. • pIDT is a pointer to a six-byte data that has the linear base address and limit value for the lOT. These values are set at run time. • pold is a pointer to a six-byte data that has the linear base address and limit value for the interrupt vector table defmed in real-address mode with DOS environment.

Download PDF sample

Rated 4.78 of 5 – based on 39 votes