;This Intel(r) Pentium(r) code is based on the AMD Am29F010B datasheet ;It writes the specified number of bytes (multiples of 4) to ;4 parallel Am29F010B 8-bit devices (32-bit wide flash bus) ;following parameters assumed to be passed ; EDX = Start Address of Flash image in RAM ; EBP = Start Address of Flash to be programmed ; EDI = Number of bytes to be programmed ;other registers used during algorithm: ; BX =max timeout reg ; ECX=transfer register ; EAX =read back status register ; ESI=1st command address ; ESP=2nd command address .386P CODE_SEG SEGMENT USE32 ASSUME CS:CODE_SEG,DS:CODE_SEG ;setup usercode breakpoint BreakPoint: JMP BreakPoint ;calculate end address ADD EDI, EBP ;calculate command addresses MOV ESI, EBP ADD ESI, 1554h ; Commmand address offset from datasheet 555h x 4h MOV ESP, EBP ADD ESP, 0AA8h ; Commmand address offset from datasheet 2AAh x 4h ;copy from source location and write to destination location Loops: MOV DWORD PTR [ESI], 0AAAAAAAAh ; Command Cycle 1 from datasheet MOV DWORD PTR [ESP], 55555555h ; Command Cycle 2 from datasheet MOV DWORD PTR [ESI], 0A0A0A0A0h ; Command Cycle 3 from datasheet MOV ECX, [EDX] MOV [EBP], ECX ; Command Cycle 4 from datasheet ;mask current byte being written to flash for dq31, dq23, dq15, dq7 AND ECX, 80808080h ;reset decrementing counter to max value MOV BX, 3FFFh DataPoll: ;store current state of dq7:0 and mask for dq31, dq23, dq15, dq7 MOV EAX, [EBP] AND EAX, 80808080h ;check if dq31, dq23, dq15, dq7 are the same as the values written ;if they are the same, this indicates that the embedded algorithm has completed ;if the embedded algorithm is still running the values will be the complement CMP ECX, EAX JE Verify ;check for timeout DEC BX CMP BX, 0 JG DataPoll MOV EDX, -1 ; TSL script checks for FFFFFFFF returned - timeout JMP BreakPoint Verify: ;check if data is same as written MOV ECX, [EBP] CMP ECX, [EDX] JE Next MOV EDX, -2 ; TSL script checks for FFFFFFFE returned - bad verify JMP BreakPoint Next: ADD EDX, 4 ADD EBP, 4 CMP EDI, EBP JG Loops Completed: ;set flag for successful completion MOV EDX, 0 ; TSL script checks for 0 returned - success JMP BreakPoint ;****************************************************** ;CODE ENDS HERE. ;****************************************************** CODE_SEG ENDS END BreakPoint