text
stringlengths
1
1.05M
; A301677: Partial sums of A301676. ; 1,5,13,26,44,66,93,124,159,200,244,292,347,404,465,534,604,678,761,844,931,1028,1124,1224,1335,1444,1557,1682,1804,1930,2069,2204,2343,2496,2644,2796,2963,3124,3289,3470,3644,3822,4017,4204,4395,4604,4804,5008,5231,5444,5661,5898,6124,6354,6605,6844,7087 mov $1,$0 mov $4,$0 lpb $0,1 div $1,3 add $2,1 add $2,$1 sub $0,$2 mul $0,$2 trn $0,1 mod $1,1 add $1,$0 mod $0,1 lpe add $1,1 mov $3,$4 mul $3,2 add $1,$3 mov $5,$4 mul $5,$4 mov $3,$5 mul $3,2 add $1,$3
SECTION rodata_driver PUBLIC __pc88_lores_pixel_map __pc88_lores_pixel_map: defb $01,$02,$04,$08,$10,$20,$40,$80
;/*! ; @file ; ; @ingroup fapi ; ; @brief DosClose DOS wrapper ; ; (c) osFree Project 2018, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ; ;0 NO_ERROR ;2 ERROR_FILE_NOT_FOUND ;5 ERROR_ACCESS_DENIED ;6 ERROR_INVALID_HANDLE ; ;--------D-213E------------------------------- ;INT 21 - DOS 2+ - "CLOSE" - CLOSE FILE ; AH = 3Eh ; BX = file handle ;Return: CF clear if successful ; AX destroyed ; CF set on error ; AX = error code (06h) (see #01680 at AH=59h/BX=0000h) ;Notes: if the file was written to, any pending disk writes are performed, the ; time and date stamps are set to the current time, and the directory ; entry is updated ; recent versions of DOS preserve AH because some versions of Multiplan ; had a bug which depended on AH being preserved ;SeeAlso: AH=10h,AH=3Ch,AH=3Dh,INT 2F/AX=1106h,INT 2F/AX=1227h ; ; ;*/ .8086 ; Helpers INCLUDE helpers.inc INCLUDE dos.inc _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 @PROLOG DOSCLOSE FILEHANDLE DW ? @START DOSCLOSE CLOSE_HANDLE [BP].ARGS.FILEHANDLE JC EXIT XOR AX, AX EXIT: @EPILOG DOSCLOSE _TEXT ENDS END
db 0 ; species ID placeholder db 90, 85, 75, 115, 115, 100 ; hp atk def spd sat sdf db ELECTRIC, ELECTRIC ; type db 3 ; catch rate db 216 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_UNKNOWN ; gender ratio db 100 ; unknown 1 db 80 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/raikou/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_SLOW ; growth rate dn EGG_NONE, EGG_NONE ; egg groups ; tm/hm learnset tmhm HEADBUTT, CURSE, ROAR, TOXIC, ZAP_CANNON, ROCK_SMASH, PSYCH_UP, DARK_PULSE, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, RAIN_DANCE, NUZZLE, POISON_FANG, IRON_HEAD, THUNDER, RETURN, DIG, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SANDSTORM, SWIFT, PURSUIT, REST, CUT, STRENGTH, FLASH, THUNDERBOLT ; end
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: File FILE: fileMain.asm AUTHOR: Dennis Chow, December 12, 1989 METHODS: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- dc 12/12/89 Initial revision. DESCRIPTION: Externally callable routines for this module. No routines outside this file should be called from outside this module. $Id: fileMain.asm,v 1.1 97/04/04 16:56:13 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileRecvStart %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Receive a file CALLED BY: TermFileRecvStart PASS: ds - dgroup RETURN: carry set if error DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: Clear out values in text object REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 12/12/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileRecvStart proc far ; ; We need to initialize fileHandle to be BOGUS_VAL because ; FileRecvEnd checks for this value when determining whether ; to close an open file or not. This becomes a problem when ; the receiver has an error while opening a file and a dialog ; box is popped-up and awaits for a user response. While ; waiting, the sender will timeout and given the option to ; abort. If the sender aborts before the receiver can resolve ; its open file error, then FileRecvEnd will be executed with ; an uninitialized fileHandle, thus causing a fatal error in ; FileClose. ; 6/2/95 - ptrinh ; mov ds:[fileHandle], BOGUS_VAL cmp ds:[recvProtocol], NONE je 5$ mov si, offset RecvFileSelector ;use xmodem file selector jmp short 10$ 5$: mov si, offset TextRecvFileSelector ;pass where to get path from 10$: mov dx, ds:[transferUIHandle] ; CallMod SetFilePath ;if error setting path jnc 12$ ;for the file jmp error ;then exit 12$: ; cmp ds:[recvProtocol], NONE je 15$ mov si, offset RecvTextEdit jmp short 20$ 15$: mov si, offset TextRecvTextEdit 20$: mov dx, ds:[transferUIHandle] ; see if it exists CallMod GetFileName ;ds:dx->filename LONG jc error ; exit if error push bx ; save filename block handle CallMod CheckFileStatus pop bx ; retrieve filename block handle jnc 42$ call MemFree ; free filename block jmp error 42$: push bx ; save filename block handle GetResourceHandleNS RecvFileDisp, bx mov si, offset RecvFileDisp cmp es:[recvProtocol], XMODEM ;set the recv display je 50$ ; with the name of file GetResourceHandleNS AsciiRecvDisp, bx mov si, offset AsciiRecvDisp 50$: call SetFileName pop bx ; retrieve filename block handle call MemFree ; free filename block segmov ds, es, ax ;restore dgroup mov ax, FILE_BUF_SIZE ;get block of memory for packet mov cx, ALLOC_DYNAMIC call MemAlloc jnc 60$ jmp memErr 60$: mov ds:[packetHandle], bx ;save handle to segment clr ds:[packetHead] ;point to beginning of packet mov cx, FILE_OVERWRITE ;we're going to overwrite any cmp ds:[recvProtocol], XMODEM ;existing files je 62$ mov si, offset TextRecvTextEdit ;get file handle jmp short 65$ 62$: mov si, offset RecvTextEdit 65$: mov dx, ds:[transferUIHandle] CallMod GetFileHandle ;open file to download to jnc 68$ ; ; Delete packet from packetHandle ; clr bx xchg bx, ds:[packetHandle] call MemFree ; bx destroyed stc ; indicator file open err jmp exit 68$: mov ds:[fileHandle], bx mov ds:[termStatus], FILE_RECV mov ds:[softFlowCtrl], FALSE ; in case text capture if not _TELNET cmp ds:[recvProtocol], NONE ; don't disable software je 69$ ; flow control for call InitSerialForFileTrans ; text capture jnc 69$ jmp error endif ; !_TELNET 69$: ;moved here from TermFileRecvStart - brianc 2/15/94 NCCT < call SetFileRecvInput > CallMod DisableFileTransfer ;disable file transfer triggers if not _TELNET CallMod DisableScripts CallMod DisableProtocol CallMod DisableModemCmd endif ; !_TELNET mov ax, MSG_GEN_GUP_INTERACTION_COMMAND mov cx, IC_DISMISS cmp ds:[recvProtocol], NONE je 70$ mov si, offset RecvXmodemBox jmp short 75$ 70$: mov si, offset RecvAsciiBox 75$: CallTransferUI cmp ds:[recvProtocol], XMODEM je 80$ call DoAsciiRecv jmp short exit 80$: GetResourceHandleNS RecvStatusSummons, bx mov si, offset RecvStatusSummons ;enable recv status box mov ax, MSG_GEN_INTERACTION_INITIATE mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage ; call FileTransInit ;init file transfer variables if not _TELNET NRSP < call GetRecvProto > endif mov ds:[sendACK], FALSE ;don't send ACKs during timeouts mov ds:[maxTimeouts], MAX_INIT_TIMEOUTS mov ds:[tranState], TM_GET_HOST ;wait for host cmp ds:[useChecksum], TRUE jne sendCRC mov di, TEN_SECOND ;set 10 second timer for 128 call FileStartTimer ; byte packet mov cl, CHAR_NAK jmp short writeChar sendCRC: mov di, THREE_SECOND call FileStartTimer ;set shorter timer for CRC mov cl, CHAR_CRC writeChar: call FileWriteChar ;tell host we're here clc jmp short exit memErr: mov bp, ERR_NO_MEM_FTRANS ;display error message displayErr:: CallMod DisplayErrorMessage ; and set error: segmov ds, es, ax ;restore dgroup stc ; error flag exit: ret FileRecvStart endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileStopTimer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: stop a timer CALLED BY: FileDoReceive PASS: ds - dgroup RETURN: --- DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 12/12/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileStopTimer proc far mov bx, ds:[timerHandle] cmp bx, BOGUS_VAL ;is timer on je exit ;nope, exit clr ax ; 0 => continual call TimerStop ; and flag timer off mov ds:[timerHandle], BOGUS_VAL ;else turn off timer exit: ret FileStopTimer endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileRecvData %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handle a timeout or a buffer of characters sent during a file receive. CALLED BY: SerialInThread, Timer event PASS: cx - number of chars in buffer dx - TIMER_EVENT (if called by timer) ds - dgroup ds:si - buffer to read chars from RETURN: cx - number of unprocessed chars left in auxBuf (THIS WILL ALWAYS BE 0, AS FILE XFER IS SYNCHRONOUS) DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: I don't restart the timer when I get a timeout, I figure I don't use up that much time processing the timeout and want to keep the code simple. When I get timeout reset transfer state to (wait for start of packet) send NAK increment timeout count REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 12/12/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileRecvData proc far cmp dx, TIMER_EVENT ;if this a timeout jne charIn ; call HandleRecvTimeout ;process it jmp exit ; charIn: cmp ds:[tranState], TM_IN_PACKET jne notInPack jmp inPacket notInPack: cmp ds:[tranState], TM_GOT_CAN_1 je checkCan cmp ds:[tranState], TM_GET_EOT ;waiting for EOT jne notEOT mov al, {byte} ds:[si] ; cmp al, CHAR_EOT ;if didn't resend EOT jne falseEOT ;then it was bogus jmp fileEnd checkCan: mov al, {byte} ds:[si] ; cmp al, CHAR_CAN ;if didn't send two CANCELs jne falseEOT ;then ignore it jmp fileCancel falseEOT: ; mov ds:[tranState], TM_GET_SOH ;bogus EOT, continue with trans jmp short checkStart notEOT: cmp ds:[tranState], TM_GET_HOST ;are we trying to contact host je checkStart cmp ds:[tranState], TM_GET_PAK_NUM ; je packetNumber cmp ds:[tranState], TM_GET_PAK_CMPL ; je packetCmpl cmp ds:[tranState], TM_GET_CHECK_1 ;if got checksum je cmpCheck1 ; check its value cmp ds:[tranState], TM_GET_CHECK_2 ;if got checksum je cmpCheck2 ; check its value cmp ds:[tranState], TM_GET_SOH ;are we waiting for start of je checkStart ; packet jmp exit checkStart: mov al, {byte} ds:[si] cmp al, CHAR_SOH ;start of 128 char packet je gotStart cmp al, CHAR_STX ;start of 1K packet je gotStart ; cmp al, CHAR_EOT ;is this end of transmission? LONG je checkEOT ;then ACK the EOT cmp al, CHAR_CAN je gotCan inc si ;advance buffer ptr loop checkStart jmp exit ;SOH not found, exit gotStart: ;remote is alive dec cx ;decrement character count inc si ;update ptr past SOH cmp al, CHAR_SOH je pack128 cmp ds:[packetSize], PACKET_1K je stopTimer mov ds:[packetSize], PACKET_1K ;changing packet size jmp short stopTimer pack128: cmp ds:[packetSize], PACKET_128 ;ignore if same packet size je stopTimer mov ds:[packetSize], PACKET_128 stopTimer: call FileStopTimer ;got host mov ds:[timerInterval], TEN_SECOND ;within packet set a ten mov ds:[tranState], TM_GET_PAK_NUM ; second timer mov bx, ds:[packetSize] ;expecting a packet full mov ds:[expChars], bx ; of characters jcxz restartTimer ;start up timer packetNumber: call FileCheckPacketNum jcxz restartTimer ;if buffer empty exit jc checkStart packetCmpl: call FileCheckPackCompl jcxz restartTimer jc checkStart inPacket: call FileProcessPacket jmp short exit cmpCheck1: call FileCheck1 jmp short exit cmpCheck2: call FileCheck2 jmp short exit restartTimer: call FileRestartTimer jmp short exit gotCan: dec cx inc si ;update ptr past CAN jcxz 10$ cmp {byte} ds:[si], CHAR_CAN je fileCancel ;falseCan: mov ds:[tranState], TM_GET_SOH inc si dec cx jcxz exit jmp checkStart 10$: mov ds:[tranState],TM_GOT_CAN_1 jmp short exit checkEOT: mov cl, CHAR_NAK ;nak the first EOT call FileWriteChar ; and wait for another mov ds:[tranState], TM_GET_EOT ; EOT jmp short exit fileCancel: mov cl, CHAR_ACK ;else ACK the EOT and call FileWriteChar ; be done with transfer call FileStopTimer ;stop timer before putting ; up blocking dialog mov bp, ERR_REMOTE_CAN call DisplayErrorMessage call FileRecvEnd jmp short exit fileEnd: mov cl, CHAR_ACK ;else ACK the EOT and call FileWriteChar ; be done with transfer call FileRecvEnd ; exit: ; don't wait for timeout to send NAK -- brianc 2/23/94 call FileSendNakNow clr cx ;return "number of unprocessed chars ;in [auxBuf] = 0". ret FileRecvData endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileRecvAbort %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Tell remote to abort file send CALLED BY: PASS: ds = dgroup RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: File transfer can only be aborted at the beginning of a file transfer. I'm in the middle of trying to fix it so this isn't true!! -mkh 3/30/94 REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 12/13/89 Initial version hirayama 3/30/94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileRecvAbort proc far ornf ds:[currentFileFlags], mask FF_RECV_ABORT_TRIGGER_CLICKED NRSP < cmp ds:[recvProtocol], XMODEM > NRSP < je doX > call EndAsciiRecv jmp short exit doX: cmp ds:[termStatus], FILE_RECV ;if started file je stopRecv ;then need to stop it mov cx, LEN_CAN ;else cancel the transfer push ds segmov ds, cs ; ds:si = cancel string mov si, offset abortStr call FileWriteBuf pop ds stopRecv: ; ; If BEGAN_RECIEVING_PACKETS flag is *not* set (i.e. we haven't ; received any Xmodem packets yet), just end the session like ; before. Otherwise, allow the session to continue, and things ; will be cleaned up when we're about to send an Ack packet. -mkh ; test ds:[currentFileFlags], mask FF_BEGAN_RECEIVING_PACKETS jnz exit mov cx, LEN_CAN ;else cancel the transfer push ds segmov ds, cs ; ds:si = cancel string mov si, offset abortStr call FileWriteBuf pop ds call FileRecvEnd exit: ret FileRecvAbort endp ;cancel string abortStr db LEN_CAN dup (CHAR_CAN) COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileSendStart %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send a file CALLED BY: TermXModemSend PASS: ds, es - dgroup RETURN: --- DESTROYED: PSEUDO CODE/STRATEGY: If can't find file to send display error message Else read file into buffer wait for NAK KNOWN BUGS/SIDE EFFECTS/IDEAS: Some of send variables could be combined with recv variables to save bytes. REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 12/27/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileSendStart proc far cmp ds:[sendProtocol], NONE je 15$ mov si, offset SendFileSelector ;pass object offset jmp short 20$ 15$: mov si, offset TextSendFileSelector ; 20$: mov dx, ds:[transferUIHandle] CallMod GetFileSelection ; return bp = GenFileSelectorEntryFlags jc exit ;exit if filename dorked call SendFile ; pass bp = GenFileSelectorEntryFlags exit: ret FileSendStart endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileSendAbort %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Quit trying to send the file CALLED BY: PASS: RETURN: DESTROYED: PSEUDO CODE/STRATEGY: check if doing ascii or xmodem file send if ascii just stop sending packets if xmodem If file transfer hasn't begun then send Abortstring Else send EOF sequence KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 12/13/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileSendAbort proc far cmp ds:[fileSendAbortCalled], TRUE je exit mov ds:[fileSendAbortCalled], TRUE NRSP < cmp ds:[sendProtocol], XMODEM > NRSP < je stopX > cmp ds:[fileDone], TRUE ;is file send done ? je exit ; mov ds:[fileDone], TRUE ;well now it is call EndAsciiSend jmp short exit stopX: mov ds:[fileDone], TRUE ;*** always send CANs if 0 tst ds:[numPacketSent] jz 10$ call SendEndOfFile ;tell remote we're done mov ds:[tranState], TM_ACK_EOT ;wait for ACK jmp short exit 10$: endif mov cx, LEN_CAN push ds segmov ds, cs ; ds:si = cancel string mov si, offset abortStr call FileWriteBuf ;if error sending cancel string pop ds jc 30$ ; bail cmp ds:[termStatus], FILE_SEND ;if start button has been jne exit ; pressed then stop 30$: call FileSendEnd ; the send exit: ret FileSendAbort endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileSendData %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Handle data from remote when sending a file CALLED BY: PASS: cx - number of chars in buffer dx - TIMER_EVENT (if called by timer) ds - dgroup ds:si - buffer to read chars from RETURN: cx - number of unprocessed chars left in auxBuf (THIS WILL ALWAYS BE 0, AS FILE XFER IS SYNCHRONOUS) DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 12/27/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileSendData proc far cmp ds:[fileTransferCancelled], TRUE ; abort? jne continue ; nope, continue call FileSendAbort ; yes, abort jmp exit continue: cmp dx, TIMER_EVENT ;if timeout when waiting for jne charIn ; remote then abort call HandleSendTimeout ;if can't resend packet then jc EOT_ACKed ; abort jmp exit charIn: cmp ds:[tranState], TM_GOT_CAN_1 je checkCAN cmp ds:[tranState], TM_GET_REMOTE je checkRemote cmp ds:[tranState], TM_GET_ACK je checkACK cmp ds:[tranState], TM_ACK_EOT je checkACK_EOT jmp short exit checkACK_EOT: cmp {byte} ds:[si], CHAR_ACK je EOT_ACKed inc si loop checkACK_EOT call SendEndOfFile jnc exit ;if no error exit EOT_ACKed: ;EOT acked mov ds:[tranState], TM_FILE_DONE ;we are out of here call FileSendEnd jmp short exit checkACK: cmp {byte}ds:[si], CHAR_ACK ;remote ACKing packet ? je ackPacket cmp {byte}ds:[si], CHAR_CAN ;remote canceling send? je gotCancel cmp {byte}ds:[si], CHAR_NAK je nakPacket inc si loop checkACK jmp nakPacket ;figure anything, but ;ACK, CAN, or NAK ;should nak the packet ackPacket: call IncSendPacket jmp short exit gotCancel: ;check if remote mov ds:[tranState], TM_GOT_CAN_1 ;wants to cancel send dec cx ; dec char count inc si ; adv buf ptr jcxz exit ; if buf empty exit checkCAN: cmp {byte}ds:[si], CHAR_CAN ; if don't get je cancelSend ; consecutive CANs mov ds:[tranState], TM_GET_ACK ; consider it a NAK nakPacket: call IncSendErrors jc cancelSend ;if error resending jmp short exit ; packet cancel send cancelSend: call FileSendEnd jmp short exit checkRemote: ;also allow CHAR_CAN? - brianc 9/21/90 cmp {byte}ds:[si], CHAR_NAK ;use checksum je gotNAK cmp {byte}ds:[si], CHAR_CRC je gotCRC inc si ; else ignore loop checkRemote jcxz exit gotCRC: mov ds:[useChecksum], FALSE ;use CRC gotNAK: ; and send da packet call FileStopTimer call ReadInPacket call SendPacket ; exit: cmp ds:[fileTransferCancelled], TRUE ; cancelled? jne noCancel call FileSendAbort ; if so, abort ; (OK to abort twice) noCancel: clr cx ;return "number of unprocessed chars ;in [auxBuf] = 0". ret FileSendData endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileSendSelect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: User double clicked on an entry in send File selector CALLED BY: PASS: cx - number of chars in buffer RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 12/27/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileSendSelect proc far mov si, offset SendFileSelector ;pass object offset mov dx, ds:[transferUIHandle] ;exit if a file not CallMod GetFileSelection ; selected jc exit ; exit: ret FileSendSelect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SendFile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: send the file CALLED BY: FileSendStart, TermFileSendSelect PASS: ds - dgroup ds:dx - name of file to send bp - GenFileSelectorEntryFlags GFSEF_LONGNAME RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 05/01/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SendFile proc far push bp ; save GFSEF_* flags push dx ;save ptr to filename mov ds:[fileSendHandle], BOGUS_VAL cmp ds:[sendProtocol], NONE je 5$ mov si, offset SendFileSelector ;pass object offset jmp short 10$ 5$: mov si, offset TextSendFileSelector ;pass object offset 10$: mov dx, ds:[transferUIHandle] CallMod SetFilePath ;continue if no error jnc 12$ ; setting path add sp, 4 ; clean up stack jmp exit 12$: mov ax, MSG_GEN_GUP_INTERACTION_COMMAND ;bring down the file mov cx, IC_DISMISS cmp ds:[sendProtocol], NONE je 15$ mov si, offset MenuInterface:SendXmodemBox ; selector box jmp short 20$ 15$: mov si, offset MenuInterface:SendAsciiBox 20$: GetResourceHandleNS MenuInterface, bx mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage pop dx ;restore ptr to filname GetResourceHandleNS SendFileDisp, bx mov si, offset SendFileDisp call SetFileName ;set name of send file pop bp ; retrieve GFSEF_* flags call FileOpenForSend LONG jc noFile mov ds:[fileTransferCancelled], FALSE mov ds:[fileSendAbortCalled], FALSE mov ds:[softFlowCtrl], FALSE ; in case text send if not _TELNET cmp ds:[sendProtocol], NONE ; don't disable software je 30$ ; flow control for call InitSerialForFileTrans ; text send jnc 30$ jmp exit endif ; !_TELNET 30$: CallMod DisableFileTransfer if not _TELNET CallMod DisableScripts CallMod DisableProtocol CallMod DisableModemCmd endif ; !_TELNET NRSP < cmp ds:[sendProtocol], XMODEM ; triggers> NRSP < je doXModem > call DoAsciiSend jmp short exit doXModem: CallMod SetFileSendInput ;redirect input to ; send module GetResourceHandleNS SendStatusSummons, bx mov si, offset SendStatusSummons ;enable send status box mov ax, MSG_GEN_INTERACTION_INITIATE mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage call FileTransInit ;init file trans var if not _TELNET call GetSendPacketSize endif mov ds:[tranState], TM_GET_REMOTE ;waiting for remote mov ds:[maxTimeouts], MAX_INIT_TIMEOUTS mov ds:[fileDone], FALSE ;reset last packet flag clr ax mov ds:[packetHead], ax ;ptr to start of file mov ds:[numEOTsent], al mov di, ONE_MINUTE/2 call FileStartTimer clc ;flag okay jmp short exit noFile: ;;error reported in FileOpenForSend - brianc 9/19/90 ;; mov bp, ERR_FILE_NOT_FOUND ;display error message ;; CallMod DisplayErrorMessage exit: ret SendFile endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileSendAsciiPacket %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send the next ascii packet CALLED BY: TermSendAsciiPacket PASS: ds - dgroup RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 05/01/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileSendAsciiPacket proc far tst ds:[fileDone] ;if file done forget this jz send cmp ds:[inMiddleOfPacket], TRUE jne exit send: call SendAsciiPacket exit: ret FileSendAsciiPacket endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AsciiRecvData %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: receive a bunch of chars during an ascii transfer CALLED BY: SerialInThread, Timer event PASS: cx - number of chars in buffer ds - dgroup (non _CAPTURE_CLEAN_TEXT) es - dgroup (_CAPTURE_CLEAN_TEXT) ds:si - buffer to read chars from (auxBuf in udata) (characters are in BBS code page) RETURN: cx - # of unprocessed chars DESTROYED: ax, bx, dx, bp, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: should I just write the characters that come out to disk or should I display them on the screen too?. For now I'll display them and write them out. REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 05/14/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AsciiRecvData proc far call WriteAsciiPacket ;(pass in BBS code page) ; ; After the operation, we don't always want to call ; FoamWarnSpaceAfterOperation because it will put dialog if disk ; space goes below Warning Level. Since we allow capture until ; Critical level, this dialog can be very very annoying. ; NRSP < jc exit > RSP < jnc writePacketOK > RSP < ; > RSP < ; Since we can't write packet to disk, that may imply a problem with> RSP < ; disk space. Put up a warning note if necessary and stop catpure> RSP < ; > RSP < mov ax, MSG_FILE_RECV_STOP_CHECK_DISKSPACE > RSP < jmp stopCapture > RSP < writePacketOK: > if not _CAPTURE_CLEAN_TEXT mov bp, si ;pass buffer in dx:bp mov dx, ds ; ; ; it is okay to send this method, passing a fptr as this is run ; under the serial thread (called from SerialReadData) so this ; will be a direct call ; mov ax, MSG_READ_BUFFER ;(pass in BBS code page) CallSerialThread endif ; !_CAPTURE_CLEAN_TEXT exit: ret AsciiRecvData endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileReset %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Reset file transfer UI objects to starting state CALLED BY: RestoreState PASS: RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dennis 08/09/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileReset proc far call FileSendReset call FileRecvReset ret FileReset endp if _CAPTURE_CLEAN_TEXT COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileCaptureText %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Capture text to a file "Text capture" has been started CALLED BY: (EXTERNAL) ScreenData PASS: es:bp = fptr to buffer of characters dx = number of characters to capture ds:si = Screen Class object instance data RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- simon 9/28/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileCaptureText proc far class ScreenClass uses ds, es, si, cx .enter ; ; Skip if we are not capturing text ; mov cx, es ; cx <- sptr of buf GetResourceSegmentNS dgroup, es cmp es:[fileHandle], BOGUS_VAL je done EC < tstdw es:[fileXferTextObj] > EC < ERROR_Z TERM_INVALID_FILE_CAPTURE_STATUS > ; ; Also make sure if we are displaying international char. If so, ; don't write it to file. ; BitTest ds:[si][SI_intFlags], SIF_FILE_CAPTURE jz done ; ; Make a copy of characters to the file ; push ax, bx, dx, bp, di movdw dssi, cxbp mov cx, dx ; ; FSMParseString has converted characters to code page. This will ; screw up CodePage -> Geos used by FoamDocConvertFromDosAppend since ; this foam lib routine will do CodePage -> Geos again. Therefore, we ; convert the characters from Geos -> CodePage here before passing to ; FoamDocConvertFromDosAppend. A better solution will be to not do ; code page conversion for data coming from remote, but this will ; complicate the existing code structure. ; ; Since this routine returns to update screen, the characters after ; logging to file have to be converted back to Geos charset. ; mov ax, MAPPING_DEFAULT_CHAR mov bx, es:[bbsCP] call LocalGeosToCodePage ; carry if def char used EC < Assert_buffer dssi, cx > push cx call AsciiRecvData ; cx <- #unprocessed data pop cx ; but we don't care mov ax, MAPPING_DEFAULT_CHAR EC < Assert_dgroup es > mov bx, es:[bbsCP] EC < Assert_buffer dssi, cx > call LocalCodePageToGeos ; carry if def char used pop ax, bx, dx, bp, di done: .leave ret FileCaptureText endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileCaptureTextChar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Capture character to file CALLED BY: (EXTERNAL) ScreenCR PASS: al = character to write to file (SBCS) ax = character to write to file (DBCS) RETURN: nothing DESTROYED: ax, bx, cx, dx, si, di, ds, es SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- simon 9/28/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileCaptureTextChar proc far charToWrite local TCHAR uses ax, bx, cx, dx, si, di .enter SBCS < mov ss:[charToWrite], al > DBCS < mov ss:[charToWrite], ax > segmov ds, ss, ax lea si, ss:[charToWrite] ; dssi <- char GetResourceSegmentNS dgroup, es mov cx, 1 ; just 1 char push bp call AsciiRecvData pop bp .leave ret FileCaptureTextChar endp endif ; _CAPTURE_CLEAN_TEXT
; /***************************************************************************** ; * ugBASIC - an isomorphic BASIC language compiler for retrocomputers * ; ***************************************************************************** ; * Copyright 2021-2022 Marco Spedaletti (asimov@mclink.it) ; * ; * Licensed under the Apache License, Version 2.0 (the "License"); ; * you may not use this file except in compliance with the License. ; * You may obtain a copy of the License at ; * ; * http://www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * distributed under the License is distributed on an "AS IS" BASIS, ; * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; * See the License for the specific language governing permissions and ; * limitations under the License. ; *---------------------------------------------------------------------------- ; * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0 ; * (la "Licenza"); è proibito usare questo file se non in conformità alla ; * Licenza. Una copia della Licenza è disponibile all'indirizzo: ; * ; * http://www.apache.org/licenses/LICENSE-2.0 ; * ; * Se non richiesto dalla legislazione vigente o concordato per iscritto, ; * il software distribuito nei termini della Licenza è distribuito ; * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o ; * implicite. Consultare la Licenza per il testo specifico che regola le ; * autorizzazioni e le limitazioni previste dalla medesima. ; ****************************************************************************/ ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;* * ;* TEXT AT GIVEN POSITION ON VIC-II * ;* * ;* by Marco Spedaletti * ;* * ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * TEXTPTR = $20 TEXTSIZE = $24 TABSTODRAW = $36 SCREENCODE = $2E TEXTATDECODE: CMP #32 BCS TEXTATXSP128 JMP TEXTATSP128 TEXTATXSP128: CMP #64 BCS TEXTATXSP0 JMP TEXTATDECODE0 TEXTATXSP0: CMP #96 BCS TEXTATXSM64 JMP TEXTATSM64 TEXTATXSM64: CMP #160 BCS TEXTATXSP64 JMP TEXTATSP64 TEXTATXSP64: CMP #192 BCS TEXTATX2SM64 JMP TEXTATSM64 TEXTATX2SM64: CMP #224 BCS TEXTATX2SM128 JMP TEXTATSM128 TEXTATX2SM128: JMP TEXTATDECODE0 TEXTATSP64: CLC ADC #64 JMP TEXTATDECODE0 TEXTATSP128: ADC #128 JMP TEXTATDECODE0 TEXTATSM64: SBC #63 JMP TEXTATDECODE0 TEXTATSM128: SBC #127 JMP TEXTATDECODE0 TEXTATDECODE0: STA SCREENCODE RTS
; A010876: a(n) = n mod 7. ; 0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3 mod $0,7 mov $1,$0
// // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // #define BOOST_LOCALE_SOURCE #include <locale> #include <stdexcept> #include <boost/locale/generator.hpp> #include <boost/locale/conversion.hpp> #include <boost/locale/encoding.hpp> #include <vector> #include <string.h> #include "api.hpp" #include "all_generator.hpp" namespace boost { namespace locale { namespace impl_win { class utf16_converter : public converter<wchar_t> { public: utf16_converter(winlocale const &lc,size_t refs = 0) : converter<wchar_t>(refs), lc_(lc) { } virtual std::wstring convert(converter_base::conversion_type how,wchar_t const *begin,wchar_t const *end,int flags = 0) const { switch(how) { case converter_base::upper_case: return towupper_l(begin,end,lc_); case converter_base::lower_case: return towlower_l(begin,end,lc_); case converter_base::case_folding: return wcsfold(begin,end); case converter_base::normalization: return wcsnormalize(static_cast<norm_type>(flags),begin,end); default: return std::wstring(begin,end-begin); } } private: winlocale lc_; }; class utf8_converter : public converter<char> { public: utf8_converter(winlocale const &lc,size_t refs = 0) : converter<char>(refs), lc_(lc) { } virtual std::string convert(converter_base::conversion_type how,char const *begin,char const *end,int flags = 0) const { std::wstring tmp = conv::to_utf<wchar_t>(begin,end,"UTF-8"); wchar_t const *wb=tmp.c_str(); wchar_t const *we=wb+tmp.size(); std::wstring res; switch(how) { case upper_case: res = towupper_l(wb,we,lc_); break; case lower_case: res = towlower_l(wb,we,lc_); break; case case_folding: res = wcsfold(wb,we); break; case normalization: res = wcsnormalize(static_cast<norm_type>(flags),wb,we); break; default: res = tmp; // make gcc happy } return conv::from_utf(res,"UTF-8"); } private: winlocale lc_; }; std::locale create_convert( std::locale const &in, winlocale const &lc, character_facet_type type) { switch(type) { case char_facet: return std::locale(in,new utf8_converter(lc)); case wchar_t_facet: return std::locale(in,new utf16_converter(lc)); default: return in; } } } // namespace impl_win32 } // locale } // boost // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0xfe57, %rdi sub $22711, %r12 mov $0x6162636465666768, %rbx movq %rbx, (%rdi) nop nop add $35870, %rbp lea addresses_normal_ht+0x1e0f7, %rsi lea addresses_normal_ht+0xefbf, %rdi nop add %rbp, %rbp mov $56, %rcx rep movsl nop nop nop sub $11290, %rsi lea addresses_D_ht+0x11417, %rsi lea addresses_D_ht+0x1a17, %rdi nop nop nop nop nop xor %r13, %r13 mov $23, %rcx rep movsw sub %rcx, %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r8 push %rax push %rdi push %rdx push %rsi // Store lea addresses_D+0x7757, %rsi nop and %rax, %rax mov $0x5152535455565758, %r8 movq %r8, (%rsi) nop nop nop nop nop inc %rsi // Store lea addresses_A+0x9217, %r13 nop nop nop nop add %rdi, %rdi movb $0x51, (%r13) xor $51839, %r8 // Load lea addresses_UC+0x12c1a, %rsi nop nop cmp $43188, %r8 movups (%rsi), %xmm4 vpextrq $1, %xmm4, %r13 nop nop nop nop xor $44200, %rdx // Load lea addresses_D+0x1844f, %rdi nop nop nop nop nop xor $52376, %rdx and $0xffffffffffffffc0, %rdi vmovntdqa (%rdi), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %rsi nop nop nop sub %rdx, %rdx // Store lea addresses_RW+0x14e17, %rsi dec %rdx mov $0x5152535455565758, %r13 movq %r13, %xmm4 vmovups %ymm4, (%rsi) nop nop nop sub $14836, %rax // Load lea addresses_A+0x11db7, %rsi nop nop and $33964, %r8 mov (%rsi), %eax inc %r13 // Faulty Load lea addresses_PSE+0xf217, %rax nop nop nop nop and %rdx, %rdx vmovups (%rax), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r8 lea oracles, %r11 and $0xff, %r8 shlq $12, %r8 mov (%r11,%r8,1), %r8 pop %rsi pop %rdx pop %rdi pop %rax pop %r8 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 10}} {'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 32, 'NT': True, 'same': False, 'congruent': 3}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 10}} {'src': {'type': 'addresses_A', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 5}} {'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; A004609: Expansion of sqrt(6) in base 2. ; Submitted by Jamie Morken(s4) ; 1,0,0,1,1,1,0,0,1,1,0,0,0,1,0,0,0,1,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1,0,1,0,0,0,0,1,1,0,0,1,0,0,0,0 mov $1,1 mov $2,1 mov $3,$0 add $3,2 mov $4,$0 add $4,2 mov $7,10 pow $7,$4 lpb $3 mov $4,$2 pow $4,2 mul $4,6 mov $5,$1 pow $5,2 add $4,$5 mov $6,$1 mov $1,$4 mul $6,$2 mul $6,2 mov $2,$6 mov $8,$4 div $8,$7 max $8,1 div $1,$8 div $2,$8 sub $3,1 mov $9,2 lpe div $1,2 mov $3,$9 pow $3,$0 div $2,$3 div $1,$2 mod $1,$9 mov $0,$1
SECTION code_crt0_sccz80 PUBLIC l_case ; Entry: hl = value to switch on ; (sp) = switch table (i.e. the return address) .l_case ld d,h ;After de = switch value ld e,l pop hl ;hl = switch table .swloop ld c,(hl) inc hl ld b,(hl) ;bc -> case addr, else 0 inc hl ld a,b or c jr z,swend ;default or continuation code ld a,(hl+) cp e ld a,(hl+) jr nz,swloop cp d jr nz,swloop ld h,b ;cases matched ld l,c .swend jp (hl)
#include <cstdlib> #include <boost/hana/assert.hpp> #include <gem/gem.hpp> using namespace gem; using namespace boost::hana; auto main(void) -> int { // { // Dimension d1 {2}; // auto d2 = 3u; // BOOST_HANA_RUNTIME_CHECK(less(d1, d2)); // BOOST_HANA_RUNTIME_CHECK(d2 > d1); // BOOST_HANA_RUNTIME_CHECK(d1 <= d1); // BOOST_HANA_RUNTIME_CHECK(d2 <= d2); // } // { // auto d1 = 2u; // Dimension d2 {3}; // BOOST_HANA_RUNTIME_CHECK(less(d1, d2)); // BOOST_HANA_RUNTIME_CHECK(d2 > d1); // BOOST_HANA_RUNTIME_CHECK(d1 <= d1); // BOOST_HANA_RUNTIME_CHECK(d2 >= d2); // } // { // Dimension d1 {2_u}; // auto d2 = 3u; // BOOST_HANA_RUNTIME_CHECK (less(d1, d2)); // BOOST_HANA_RUNTIME_CHECK (d2 > d1); // BOOST_HANA_CONSTANT_CHECK(d1 <= d1); // BOOST_HANA_RUNTIME_CHECK (d2 >= d2); // } // { // auto d1 = 2u; // Dimension d2 {3_u}; // BOOST_HANA_RUNTIME_CHECK (less(d1, d2)); // BOOST_HANA_RUNTIME_CHECK (d2 > d1); // BOOST_HANA_RUNTIME_CHECK (d1 <= d1); // BOOST_HANA_CONSTANT_CHECK(d2 >= d2); // } // { // auto d1 = 2_u; // Dimension d2 {3_u}; // BOOST_HANA_CONSTANT_CHECK(less(d1, d2)); // BOOST_HANA_CONSTANT_CHECK(d2 > d1); // BOOST_HANA_CONSTANT_CHECK(d1 <= d1); // BOOST_HANA_CONSTANT_CHECK(d2 >= d2); // } // { // Dimension d1 {2}; // Dimension d2 {3}; // BOOST_HANA_RUNTIME_CHECK(less(d1, d2)); // BOOST_HANA_RUNTIME_CHECK(d2 > d1); // BOOST_HANA_RUNTIME_CHECK(d1 <= d1); // BOOST_HANA_RUNTIME_CHECK(d2 >= d2); // } // { // Dimension d1 {2}; // Dimension d2 {3_u}; // BOOST_HANA_RUNTIME_CHECK (less(d1, d2)); // BOOST_HANA_RUNTIME_CHECK (d2 > d1); // BOOST_HANA_RUNTIME_CHECK (d1 <= d1); // BOOST_HANA_CONSTANT_CHECK(d2 >= d2); // } // { // Dimension d1 {2_c}; // Dimension d2 {3}; // BOOST_HANA_RUNTIME_CHECK (less(d1, d2)); // BOOST_HANA_RUNTIME_CHECK (d2 > d1); // BOOST_HANA_CONSTANT_CHECK(d1 <= d1); // BOOST_HANA_RUNTIME_CHECK (d2 >= d2); // } // { // Dimension d1 {2_c}; // Dimension d2 {3_u}; // // BOOST_HANA_CONSTANT_CHECK(less(d1, d2)); // BOOST_HANA_CONSTANT_CHECK(d2 > d1); // BOOST_HANA_CONSTANT_CHECK(d1 <= d1); // BOOST_HANA_CONSTANT_CHECK(d2 >= d2); // } return EXIT_SUCCESS; }
; ; File: x86/pumpcore/head.asm ; ; The kernel entry point for x86 processors. ; 32 bit. ; ; The kernel image was loaded in the physical address 0x00100000, ; with the entry point in 0x00101000. ; The linear address is 0xC0000000. ; The boot loader made some initial memory configuration. Only ; enough to jump to the entry point in 0xC0001000. ; ; Heap and Stack: ; KERNEL_HEAP_START, KERNEL_HEAP_END ; KERNEL_STACK_START, KERNEL_STACK_END ; See: include/globals/gva.h ; ; In the end of the document you are gonna find ; the GDT and the IDT tables. ; ; History: ; 2005 - Create by Fred Nora. ; 2006 ~ 2020 Some new routines. ; HEAD_CURRENT_ARCH_X86 EQU 1000 ;; ;; Imported. ;; ; See: gdef.h extern _blSavedLastValidAddress; extern _blSavedMetafileAddress; extern _blSavedDiskNumber; extern _blSavedHeads; extern _blSavedSPT; extern _blSavedCylinders; ;; ... ; Buffers ; See: gdef.h extern _g_frontbuffer_pa ; ... ; Stacks. ; ps: It needs to be the same in the tss. ; See: include/mm/x86mm.h extern _kernel_stack_start extern _kernel_stack_start_pa ;; Used in the TSS. ; ... ;; ;; == Context ============================================= ;; extern _contextSS ; User Mode. extern _contextESP ; User Mode. extern _contextEFLAGS ; User Mode. extern _contextCS ; User Mode. extern _contextEIP ; User Mode. extern _contextDS extern _contextES extern _contextFS extern _contextGS extern _contextEAX extern _contextEBX extern _contextECX extern _contextEDX extern _contextESI extern _contextEDI extern _contextEBP ; ... ; GUI flag. extern _g_useGUI ; ... ;; ;; == Imported functions ======================================= ;; ;; Entry point for the architecture independent routine. extern _kernel_main ;; Entry point for the x86 initialization. extern _x86main ;; ================================================== ;; head_init: ;; ;; IN: ;; al = 'G' (Graphic Mode). ;; al = 'T' (Text Mode). ;; ebx = LFB. ;; ecx = BootBlock pointer. ;; edx = BootBlock pointer. ;; ebp = BootBlock pointer. ;; Called by _kernel_begin in head_32.asm head_init: ; Saving mov dword [_kArg1], eax mov dword [_kArg2], ebx mov dword [_kArg3], ecx mov dword [_kArg4], edx ; #debug ; The vga memory was mapped in 0x800000 by the boot loader. ;mov byte [0x800000], byte "K" ;mov byte [0x800001], byte 9 ;mov byte [0xb8000], byte "k" ;mov byte [0xb8000], byte 9 ;; #debug ;; Testing GUI routines. ;mov eax, 0xc0c0c0 ;mov ebx, 500 ;mov ecx, 500 ;call _gui_buffer_putpixel ;call _asm_refresh_screen ;jmp $ ;; ;; Magic byte for gui mode. ;; ; This flag tell us that we are in graphics mode. cmp al, byte 'G' je .LuseGUI ; Fail. No GUI. .Lfail_nogui: mov byte [0xb8000], byte "T" mov byte [0xb8001], byte 9 mov byte [0xb8002], byte "M" mov byte [0xb8003], byte 9 .Lnogui_hang: cli hlt jmp .Lnogui_hang ; ; == Use GUI ======================================= ; .LuseGUI: ; Check again. cmp al, byte 'G' jne .Lfail_nogui ; #important ; Saving flags. ; 1=gui mov dword [_g_useGUI], dword 1 mov dword [_SavedBootMode], dword 1 ; ; == Boot block ======================================== ; ; Now we're gonna grap all the offsets in the block. ;; #todo: ;; We need to put all these information in the same document ;; and use the same prefix. ;; These variables was defined here in this document. ;; See: include/globals/gdef.h for the globals. ; BootBlock pointer. ; With this pointer we can create a boot block structure. ; ecx = BootBlock pointer. ; edx = LoaderBlock pointer. mov dword [_SavedBootBlock], edx ;;mov dword [_SavedBootBlock], ebp ; 0 - LFB. ; FrontBuffer Address, (LFB) ; Physical address. xor eax, eax mov eax, dword [edx +0] mov dword [_SavedLFB], eax mov dword [_g_frontbuffer_pa], eax ; 4 - X. xor eax, eax mov ax, word [edx +4] mov dword [_SavedX], eax ; 8 - Y. xor eax, eax mov ax, word [edx +8] mov dword [_SavedY], eax ; 12 - BPP. xor eax, eax mov al, byte [edx +12] mov dword [_SavedBPP], eax ;; 16 - Last valid ram address. ;; Used to know the size of the RAM. xor eax, eax mov eax, dword [edx +16] mov dword [_blSavedLastValidAddress], eax ;; 20 - Metafile address. xor eax, eax mov eax, dword [edx +20] mov dword [_blSavedMetafileAddress], eax ;; 24 - disk number xor eax, eax mov eax, dword [edx +24] mov dword [_blSavedDiskNumber], eax ;; 28 - heads xor eax, eax mov eax, dword [edx +28] mov dword [_blSavedHeads], eax ;; 32 - spt xor eax, eax mov eax, dword [edx +32] mov dword [_blSavedSPT], eax ;; 36 - cylinders xor eax, eax mov eax, dword [edx +36] mov dword [_blSavedCylinders], eax ;; #todo ;; We can create a robust bootblock. ;; ... ; ; == Interrupts support ============================== ; ;; This is the order here: ;; gdt, idt, ldt, tss+tr. ; No interrupts for now. ; It was already done is head_32.asm cli ;; Memory management registes: ;; GDTR, IDTR, LDTR and TR. ; ; == GDT ================================================ ; ; We have another configuration in another place. lgdt [_GDT_register] ;; #todo ;; Vamos tentar colocar aqui a configuração dos registradores ;; de segmento. Essa configuração no momento está logo abaixo. ;; Pelo menos os segmentos de dados. ; #todo ; Temos que configurar os registradores novamente, ; logo após configurarmos a GDT. ; #todo ; Devemos fazer o mesmo se o código em C carregar uma ; nova GDT, e ele faz. ;xor eax, eax ;mov ax, word 0x10 mov ax, word __BOOT_DS mov ds, ax mov es, ax mov fs, ax mov gs, ax ; ; == IDT ================================================ ; ; We have another configuration in another place. call setup_idt ; Create a common handler, 'unhandled_int'. call setup_faults ; Setup vectors for faults and exceptions. call setup_vectors ; Some new vectors. lidt [_IDT_register] ; ; == LDT ================================================ ; ; Clear LDT xor eax, eax lldt ax ; ; == TR (tss) ====================================== ; ;; The tr configuration is little bit confused here. ;; There is another configuration in another place. ;; We're gonna work on this in the future. ; Flush TSS: ; Load the index of our TSS structure. ; The index is 0x28, as it is the 5th selector and ; each is 8 bytes long, but we set the bottom two bits (making 0x2B) ; so that it has an RPL of 3, not zero. ; Load 0x2B into the task state register. ; #important: ; We need to put the TSS address into the GDT. ;; ?? ;; We already did this. (103) ;; mov word [gdt6], tss0_end - tss0 - 1 ; This is the address os our tss ? mov eax, dword tss0 ; This is the place for the tss0 into the gdt. mov [gdt6 + 2], ax shr eax, 16 mov [gdt6 + 4], al mov [gdt6 + 7], ah ; Load TR. ; 0x2B = (0x28+3). mov ax, word 0x2B ltr ax ; ; ======================================================== ; ; Jump to flush it. ;; jmp 8:_trJumpToFlush jmp __BOOT_CS:_trJumpToFlush nop _trJumpToFlush: nop ; Order: ; PIC and PIT early initialization ; ; == PIC ======================================== ; ; Early PIC initialization. picEarlyInitialization: ;; ?? ;; PIC MODE ;; Selecting the 'Processor Interrup Mode'. ;; All the APIC components are ignored here, and ;; the system will operate in the single-thread mode ;; using LINT0. cli ;xor eax, eax mov al, 00010001b ; begin PIC1 initialization. out 0x20, al IODELAY mov al, 00010001b ; begin PIC2 initialization. out 0xA0, al IODELAY mov al, 0x20 ; IRQ 0-7: interrupts 20h-27h. out 0x21, al IODELAY mov al, 0x28 ; IRQ 8-15: interrupts 28h-2Fh. out 0xA1, al IODELAY mov al, 4 out 0x21, al IODELAY mov al, 2 out 0xA1, al IODELAY ;mov al, 00010001b ; 11 sfnm 80x86 support. mov al, 00000001b ; 01 80x86 support. out 0x21, al IODELAY out 0xA1, al IODELAY ; Mask all interrupts. cli mov al, 255 out 0xA1, al IODELAY out 0x21, al IODELAY ; ; == PIT ======================================== ; ; Early PIT initialization. pitEarlyInitialization: ;; Setup system timers. ;; ?? ;; Some frequencies to remember. ;; PIT 8253 e 8254 = (1234DD) 1193181.6666 / 100 = 11930. ; 1.19MHz. ;; APIC timer = 3,579,545 / 100 = 35796 3.5 MHz. ;; 11931 ; (1193181.6666 / 100 = 11930) timer frequency 100 HZ. ;xor eax, eax mov al, byte 0x36 mov dx, word 0x43 out dx, al IODELAY mov eax, dword 11931 mov dx, word 0x40 out dx, al IODELAY mov al, ah out dx, al IODELAY ; ; == RTC ======================================== ; ; Early RTC initialization. ;rtcEarlyInitialization: ;#todo ; Nothing for now ;; #todo: ;; memory caching control. ; Unmask all interrupts. mov al, 0 out 0xA1, al IODELAY out 0x21, al IODELAY ; No interrupts. cli ; ; == Set up registers ================================== ; ; Debug registers: ; DR0 ~ DR7 ; Debug registers. ; Disable break points. xor eax, eax ;mov dr2, eax mov dr7, eax ;; ... ; ; Data segments for ring 0. ; ;; #todo ;; Devemos antecipar essa configuração o máximo possível, ;; colocarmos perto do carregamento do gdtr. ;xor eax, eax ;mov ax, word 0x10 mov ax, word __BOOT_DS mov ds, ax mov es, ax mov fs, ax mov gs, ax ; ; Stack ; ; Initialize and save. ; Is it the same in the tss ? mov eax, 0x003FFFF0 mov esp, eax mov dword [_kernel_stack_start], eax mov dword [_kernel_stack_start_pa], eax ; ; == Kernel Status =================================== ; ;; #bugbug ;; It does not make sanse. ;; Why changing to '1' if _kernel_main changes to '0'? ;; we need to think about this flag. mov dword [_KernelStatus], dword 1 ;; mov dword [_KernelStatus], dword 0 ; # test: ; Clean flags. ; # perigo ; Como ficam as interrupções? ;; push dword 0 ;; popfd ; ; == Calling the C part =============================== ; ;; .Lcall_c_code: ; We only have one argument. The arch type. ; See: kernel/0mem/main.c mov eax, dword HEAD_CURRENT_ARCH_X86 push eax xor eax, eax xor ebx, ebx xor ecx, ecx xor edx, edx ; #bugbug ; We need to check what kind of jum we can use in this case. ; For AMD and for Intel. ; 32 ? 64 ? ; call ? ret ? ; There are limitations. call _kernel_main ; We really don't wanna reach this point. ; We are in graphics mode and we can't print an error message. ; We will not return to boot.asm. jmp _EarlyRing0IdleThread ; #todo ; Maybe we can export this ; as a main loop for all processes. ; For now we have a idle thread. global _EarlyRing0IdleThread _EarlyRing0IdleThread: cli hlt jmp _EarlyRing0IdleThread ; ; == Data area ================================== ; ;; ==================================================== ;; _SavedBootBlock: ;; To save the arguments that came from Boot Manager. ;; It's about video ... ;; global _SavedBootBlock _SavedBootBlock: dd 0 global _SavedLFB _SavedLFB: dd 0 global _SavedX _SavedX: dd 0 global _SavedY _SavedY: dd 0 global _SavedBPP _SavedBPP: dd 0 global _SavedLastValidAddress _SavedLastValidAddress: dd 0 ;; 1 = GUI ; 0 = Text Mode global _SavedBootMode _SavedBootMode: dd 0 ;; ;;================================================= ;; Kernel arguments. ;; global _kArg1 _kArg1: dd 0 global _kArg2 _kArg2: dd 0 global _kArg3 _kArg3: dd 0 global _kArg4 _kArg4: dd 0 ;; ;; == Segment ========================================== ;; segment .text ;; #ps ;; The gdt and the idt are in the code segment. ;; protection ? ;; ;; == GDT ==================================================== ;; ;; ;; TYPES: ;; The TYPE values for these are ;; ;; >> 0101 for a task gate, 5 ;; >> D110 for a interrupt gate, E ;; >> D111 for a trap gate, F ;; ;; where D is 1 for 32 bit gate and 0 for a 16 bit gate. ;; global _gdt _gdt: ;Selector 0 - Null. NULL_SEL equ $-_gdt dd 0 dd 0 ;Selector 8 - Code, kernel mode. __BOOT_CS equ $-_gdt CODE_SEL equ $-_gdt dw 0xFFFF dw 0 db 0 db 0x9A ; present, ring0, code, non-confirming, readble. db 0xCF db 0 ;Selector 0x10 - Data, kernel mode. __BOOT_DS equ $-_gdt DATA_SEL equ $-_gdt dw 0xFFFF dw 0 db 0 db 0x92 ; present, ring0, data, expanded up, writeble. (BITS) db 0xCF db 0 ;Selector 18h - Code, user mode. USER_CODE_SEL equ $-_gdt dw 0xFFFF dw 0 db 0 db 0xF8 ;;0xFE ;;5,E,F ;;A ; 1111b ,ah [ ( present|ring3|1 ) A = CODE ] db 0xCF db 0 ;dw 0xffff ;dw 0x0000 ;db 0x00 ;dw 11011111b *256 +11111010b ;db 0x00 ;Selector 20h - Data, user mode. USER_DATA_SEL equ $-_gdt dw 0xFFFF dw 0 db 0 db 0xF2 ; 1111b ,2h [ ( present|ring3|1 ) , 2 = DATA ] db 0xCF db 0 ;dw 0xffff ;dw 0x0000 ;db 0x00 ;dw 11011111b *256 +11110010b ;db 0x00 ;Tem que ter pelo menos uma tss para mudar para user mode, ;sen�o da falta. ;Selector 28h - Tss. TSS_DATA_SEL equ $-_gdt gdt6: dw 104 ;;103 dw 0 db 0 db 0x89 ;;0x89 ;; presente, ring0(onde esta a tss??), s=0(segmento do sistema) / ;;89h ((Present|Executable|Accessed)) 1001 bit3=32bitcode db 0x10 db 0 ;Selector 30h - Ldt. LDT_TEST_SEL equ $-_gdt db 0xff db 0x0 db 0x0 db 0xd1 db 0x0 db 0x82 db 0x0 db 0x0 global _end_gdt _end_gdt: dd 0 ; _GDT_register global _GDT_register _GDT_register: dw (_end_gdt-_gdt)-1 dd _gdt ;; ;; == IDT ==================================================== ;; ; ; Usadas nas entradas da idt. ; sys_interrupt equ 0x8E sys_code equ 8 ;Code selector. ;==================================================; ; Idt. ; ; Interrupt vectors for intel x86 ; ;==================================================; global _idt _idt: ;0 interrupt 0h, div error. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;1 interrupt 1h, debug exception. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;2 interrupt 2h, non maskable interrupt. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;3 interrupt 3h, int3 trap. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;4 interrupt 4h, into trap. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;5 interrupt 5h, bound trap. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;6 interrupt 6h, invalid instruction. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;7 interrupt 7h, no coprocessor. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;8 interrupt 8h, double fault. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;9 interrupt 9h, coprocessor segment overrun 1. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;10 interrupt Ah, invalid tss. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;11 interrupt Bh, segment not present. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;12 interrupt Ch, stack fault. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;13 interrupt Dh, general protection fault. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;14 interrupt Eh, page fault. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;15 interrupt Fh, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;16 interrupt 10h, coprocessor error. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;17 interrupt 11h, alignment check. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;18 interrupt 12h, machine check. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;; ;; ## Intel reserveds ## ;; ;19 interrupt 13h, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;20 interrupt 14h, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;21 interrupt 15h, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;22 interrupt 16h, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;23 interrupt 17h, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;24 interrupt 18h, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;25 interrupt 19h, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;26 interrupt 1Ah, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;27 interrupt 1Bh, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;28 interrupt 1Ch, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;29 interrupt 1Dh, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;30 interrupt 1Eh, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;31 interrupt 1Fh, reserved. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;; ;; ## IRQs ## ;; ;32 interrupt 20h, IRQ0, TIMER. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;33 interrupt 21h, IRQ1, TECLADO. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;34 interrupt 22h, IRQ2. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;35 interrupt 23h, IRQ3. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;36 interrupt 24h, IRQ4. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;37 interrupt 25h, IRQ5. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;38 interrupt 26h, IRQ6. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;39 interrupt 27h, IRQ7. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;40 interrupt 28h, IRQ8. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;41 interrupt 29h, IRQ9. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;42 interrupt 2Ah, IRQ10. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;43 interrupt 2Bh, IRQ11. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;44 interrupt 2Ch, IRQ12. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;45 interrupt 2Dh, IRQ13. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;46 interrupt 2Eh, IRQ 14. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;47 interrupt 2Fh, IRQ15. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;48 interrupt 30h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;49 interrupt 31h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;50 interrupt 32h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;51 interrupt 33h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;52 interrupt 34h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;53 interrupt 35h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;54 interrupt 36h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;55 interrupt 37h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;56 interrupt 38h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;57 interrupt 39h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;58 interrupt 3Ah. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;59 interrupt 3Bh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;60 interrupt 3Ch. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;61 interrupt 3Dh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;62 interrupt 3Eh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;63 interrupt 3Fh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;64 interrupt 40h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;65 interrupt 41h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;66 interrupt 42h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;67 interrupt 43h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;68 interrupt 44h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;69 interrupt 45h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;70 interrupt 46h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;71 interrupt 47h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;72 interrupt 48h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;73 interrupt 49h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;74 interrupt 4Ah. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;75 interrupt 4Bh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;76 interrupt 4Ch. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;77 interrupt 4Dh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;78 interrupt 4Eh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;79 interrupt 4Fh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;80 interrupt 50h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;81 interrupt 51h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;82 interrupt 52h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;83 interrupt 53h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;84 interrupt 54h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;85 interrupt 55h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;86 interrupt 56h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;87 interrupt 57h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;88 interrupt 58h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;89 interrupt 59h dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;90 interrupt 5Ah. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;91 interrupt 5Bh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;92 interrupt 5Ch. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;93 interrupt 5Dh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;94 interrupt 5Eh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;95 interrupt 5Fh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;96 interrupt 60h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;97 interrupt 61h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;98 interrupt 62h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;99 interrupt 63h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;100 interrupt 64h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;101 interrupt 65h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;102 interrupt 66h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;103 interrupt 67h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;104 interrupt 68h dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;105 interrupt 69h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;106 interrupt 6Ah. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;107 interrupt 6Bh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;108 interrupt 6Ch. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;109 interrupt 6Dh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;110 interrupt 6Eh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;111 interrupt 6Fh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;112 interrupt 70h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;113 interrupt 71h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;114 interrupt 72h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;115 interrupt 73h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;116 interrupt 74h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;117 interrupt 75h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;118 interrupt 76h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;119 interrupt 77h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;120 interrupt 78h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;121 interrupt 79h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;122 interrupt 7Ah. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;123 interrupt 7Bh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;124 interrupt 7Ch. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;125 interrupt 7Dh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;126 interrupt 7Eh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;127 interrupt 7Fh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;; ;; ## system call ## ;; ;;#importante ;;Essa agora vai ser a system call. ;;Ela � UNIX-like e usada em muitos sistemas. ;128 interrupt 80h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;129 interrupt 81h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;130 interrupt 82h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;131 interrupt 83h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;132 interrupt 84h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;133 interrupt 85h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;134 interrupt 86h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;135 interrupt 87h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;136 interrupt 88h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;137 interrupt 89h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;138 interrupt 8Ah. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;139 interrupt 8Bh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;140 interrupt 8Ch. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;141 interrupt 8Dh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;142 interrupt 8Eh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;143 interrupt 8Fh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;144 interrupt 90h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;145 interrupt 91h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;146 interrupt 92h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;147 interrupt 93h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;148 interrupt 94h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;149 interrupt 95h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;150 interrupt 96h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;151 interrupt 97h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;152 interrupt 98h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;153 interrupt 99h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;154 interrupt 9Ah. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;155 interrupt 9Bh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;156 interrupt 9Ch. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;157 interrupt 9Dh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;158 interrupt 9Eh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;159 interrupt 9Fh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;160 interrupt A0h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;161 interrupt A1h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;162 interrupt A2h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;163 interrupt A3h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;164 interrupt A4h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;165 interrupt A5h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;166 interrupt A6h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;167 interrupt A7h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;168 interrupt A8h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;169 interrupt A9h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;170 interrupt AAh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;171 interrupt ABh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;172 interrupt ACh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;173 interrupt ADh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;174 interrupt AEh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;175 interrupt AFh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;176 interrupt B0h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;177 interrupt B1h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;178 interrupt B2h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;179 interrupt B3h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;180 interrupt B4h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;181 interrupt B5h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;182 interrupt B6h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;183 interrupt B7h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;184 interrupt B8h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;185 interrupt B9h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;186 interrupt BAh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;187 interrupt BBh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;188 interrupt BCh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;189 interrupt BDh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;190 interrupt BEh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;191 interrupt BFh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;192 interrupt C0h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;193 interrupt C1h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;194 interrupt C2h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;195 interrupt C3h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;196 interrupt C4h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;197 interrupt C5h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;198 interrupt C6h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;199 interrupt C7h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;;#obs ;;Essa n�o � mais a interrup��o do sistema. ;;Agora � a tradicional 128 (0x80) ;200 interrupt C8h, dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;201 interrupt C9h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;202 interrupt CAh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;203 interrupt CBh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;204 interrupt CCh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;205 interrupt CDh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;206 interrupt CEh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;207 interrupt CFh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;208 interrupt D0h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;209 interrupt D1h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;210 interrupt D2h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;211 interrupt D3h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;212 interrupt D4h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;213 interrupt D5h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;214 interrupt D6H. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;215 interrupt D7h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;216 interrupt D8h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;217 interrupt D9h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;218 interrupt DAh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;219 interrupt DBh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;220 interrupt DCh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;221 interrupt DDh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;222 interrupt DEh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;223 interrupt DFh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;224 interrupt E0h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;225 interrupt E1h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;226 interrupt E2h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;227 interrupt E3h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;228 interrupt E4h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;229 interrupt E5h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;230 interrupt E6h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;231 interrupt E7h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;232 interrupt E8h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;233 interrupt E9h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;234 interrupt EAh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;235 interrupt EBh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;236 interrupt ECh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;237 interrupt EDh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;238 interrupt EEh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;239 interrupt EFh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;240 interrupt F0h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;241 interrupt F1h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;242 interrupt F2h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;243 interrupt F3h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;244 interrupt F4h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;245 interrupt F5h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;246 interrupt F6h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;247 interrupt F7h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;248 interrupt F8h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;249 interrupt F9h. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;250 interrupt FAh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;251 interrupt FBh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;252 interrupt FCh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;253 interrupt FDh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;254 interrupt FEh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 ;255 interrupt FFh. dw 0 dw sys_code db 0 db sys_interrupt dw 0 idt_end: dd 0 ; ; IDT_register ; global _IDT_register _IDT_register: dw (256*8) - (1) dd _idt ; ; End ;
; A209084: a(n) = 2*a(n-1) + 4*a(n-2) with n>1, a(0)=0, a(1)=4. ; 0,4,8,32,96,320,1024,3328,10752,34816,112640,364544,1179648,3817472,12353536,39976960,129368064,418643968,1354760192,4384096256,14187233280,45910851584,148570636288,480784678912,1555851902976,5034842521600,16293092655104,52725555396608,170623481413632,552149184413696,1786792294481920,5782181326618624 lpb $0,1 sub $0,1 add $1,1 add $3,2 add $3,$2 add $3,1 mov $4,$1 mov $1,1 add $1,$3 add $2,$4 mul $2,2 mov $3,$2 lpe add $0,6 add $1,$0 add $5,6 sub $1,$5
db 'jmpx4',0 Label0: jmp Label0 Label1: jmp Label0 Label2: jmp Label0 Label3: jmp Label0 db 'jo',0 jo Label0 db 'jno',0 jno Label0 db 'jb',0 jb Label0 db 'jnb',0 jnb Label0 db 'jz',0 jz Label0 db 'jnz',0 jnz Label0 db 'jbe',0 jbe Label0 db 'jnbe',0 jnbe Label0
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld a, 00 ldff(ff), a ld a, 30 ldff(00), a ld a, 01 ldff(4d), a stop, 00 ld a, ff ldff(45), a ld b, 42 call lwaitly_b ld a, 40 ldff(41), a ld a, 02 ldff(ff), a xor a, a ldff(0f), a ei ld a, b inc a inc a ldff(45), a ld c, 0f .text@1000 lstatint: ld a, 48 ldff(41), a ldff(45), a xor a, a .text@10d1 ldff(c), a ld a, 44 ldff(45), a nop nop ldff a, (c) jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a ld bc, 7a00 ld hl, 8000 ld d, 00 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles pop af ld b, a srl a srl a srl a srl a ld(9800), a ld a, b and a, 0f ld(9801), a ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f 00 00 08 08 22 22 41 41 7f 7f 41 41 41 41 41 41 00 00 7e 7e 41 41 41 41 7e 7e 41 41 41 41 7e 7e 00 00 3e 3e 41 41 40 40 40 40 40 40 41 41 3e 3e 00 00 7e 7e 41 41 41 41 41 41 41 41 41 41 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 40 40 40 40 7f 7f 40 40 40 40 40 40
; float log1p(float x) __z88dk_fastcall SECTION code_clib SECTION code_fp_math48 PUBLIC cm48_sdccix_log1p_fastcall EXTERN cm48_sdccixp_dx2m48, am48_log1p, cm48_sdccixp_m482d cm48_sdccix_log1p_fastcall: call cm48_sdccixp_dx2m48 call am48_log1p jp cm48_sdccixp_m482d
; A020761: Decimal expansion of 1/2. ; 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 pow $1,$0 mul $1,5
; A102083: a(n) = 8*n^2 + 4*n + 1. ; 1,13,41,85,145,221,313,421,545,685,841,1013,1201,1405,1625,1861,2113,2381,2665,2965,3281,3613,3961,4325,4705,5101,5513,5941,6385,6845,7321,7813,8321,8845,9385,9941,10513,11101,11705,12325,12961,13613,14281,14965,15665,16381,17113,17861,18625,19405,20201,21013,21841,22685,23545,24421,25313,26221,27145,28085,29041,30013,31001,32005,33025,34061,35113,36181,37265,38365,39481,40613,41761,42925,44105,45301,46513,47741,48985,50245,51521,52813,54121,55445,56785,58141,59513,60901,62305,63725,65161,66613 mov $1,8 mul $1,$0 add $1,4 mul $1,$0 add $1,1 mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x3af3, %rsi lea addresses_D_ht+0x5210, %rdi nop nop nop nop xor %rdx, %rdx mov $52, %rcx rep movsw nop nop nop nop nop dec %r11 lea addresses_UC_ht+0xd010, %r12 nop nop nop nop nop sub %rdx, %rdx movups (%r12), %xmm7 vpextrq $0, %xmm7, %rsi sub $45644, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %r9 push %rax push %rbx push %rcx push %rsi // Store lea addresses_PSE+0x43f7, %r15 nop nop nop nop nop and $39434, %rax movb $0x51, (%r15) nop inc %r9 // Store lea addresses_WT+0x11653, %rsi nop nop nop nop dec %rcx movw $0x5152, (%rsi) nop add $51053, %rbx // Faulty Load lea addresses_A+0xd2f3, %rax nop nop nop and $28187, %r9 mov (%rax), %rcx lea oracles, %rsi and $0xff, %rcx shlq $12, %rcx mov (%rsi,%rcx,1), %rcx pop %rsi pop %rcx pop %rbx pop %rax pop %r9 pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': True, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'35': 21829} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
; FV-1 Testing ; ; Program: Cancellation ; ; Run a sin LFO and test exp/log cancellation: ; ; x = 2**log(x) ; ; POT0: Offset ; POT1: Level ; ; Prepare LFOs skp RUN,main wlds SIN0,100,32767 main: rdax POT0,-1.0 ; load POT0 inverted sof -2.0,-1.0 ; flip and invert wrax REG0,0.0 ; save DC offset and clear acc cho rdal,SIN0 ; read from sin LFO mulx POT1 ; scale test signal level rdax REG0,1.0 ; add the offset amount wrax REG0,1.0 ; save value for sign test wrax DACL,1.0 ; output x to left channel log 1.0,0.0 ; take log(x) exp 1.0,0.0 ; compute 2**(log(x)) wrax REG1,0.0 ; save result ldax REG0 ; load the original value skp NEG,negate ldax REG1 ; fetch positive result skp 0,output negate: ldax REG1 ; fetch positive result sof -1.0,0.0 ; invert output: wrax DACR,0.0 ; output to right channel
/* Copyright (c) 2016 nemesis project/mrn@sdf.org. All rights reserved. http://mrn.sixbit.org/ Governed by the BSD 2 Clause license, the full text of which is contained in the file License.txt included in nemesis binary and source code distribution packages. Based on TrueCrypt 7.1a, which was governed by the TrueCrypt license, which is also made available with nemesis. */ #include "System.h" #include "Platform/SystemInfo.h" #ifdef TC_UNIX #include <unistd.h> #include "Platform/Unix/Process.h" #endif #include "Core/RandomNumberGenerator.h" #include "Core/VolumeCreator.h" #include "Main/Application.h" #include "Main/GraphicUserInterface.h" #include "Main/Resources.h" #include "VolumeCreationWizard.h" #include "EncryptionOptionsWizardPage.h" #include "InfoWizardPage.h" #include "ProgressWizardPage.h" #include "SingleChoiceWizardPage.h" #include "VolumeCreationProgressWizardPage.h" #include "VolumeFormatOptionsWizardPage.h" #include "VolumeLocationWizardPage.h" #include "VolumePasswordWizardPage.h" #include "VolumeSizeWizardPage.h" namespace nemesis { VolumeCreationWizard::VolumeCreationWizard (wxWindow* parent) : WizardFrame (parent), CrossPlatformSupport (true), DisplayKeyInfo (true), LargeFilesSupport (false), QuickFormatEnabled (false), SelectedFilesystemClusterSize (0), SelectedFilesystemType (VolumeCreationOptions::FilesystemType::FAT), SelectedVolumeHostType (VolumeHostType::File), SelectedVolumeType (VolumeType::Normal), SectorSize (0), VolumeSize (0) { RandomNumberGenerator::Start(); SetTitle (LangString["INTRO_TITLE"]); SetImage (Resources::GetVolumeCreationWizardBitmap (Gui->GetCharHeight (this) * 21)); SetMaxStaticTextWidth (55); SetStep (Step::VolumeHostType); class Timer : public wxTimer { public: Timer (VolumeCreationWizard *wizard) : Wizard (wizard) { } void Notify() { Wizard->OnRandomPoolUpdateTimer(); } VolumeCreationWizard *Wizard; }; RandomPoolUpdateTimer.reset (dynamic_cast <wxTimer *> (new Timer (this))); RandomPoolUpdateTimer->Start (200); } VolumeCreationWizard::~VolumeCreationWizard () { } WizardPage *VolumeCreationWizard::GetPage (WizardStep step) { switch (step) { case Step::VolumeHostType: { ClearHistory(); OuterVolume = false; LargeFilesSupport = false; QuickFormatEnabled = false; SingleChoiceWizardPage <VolumeHostType::Enum> *page = new SingleChoiceWizardPage <VolumeHostType::Enum> (GetPageParent(), wxEmptyString, true); page->SetMinSize (wxSize (Gui->GetCharWidth (this) * 58, Gui->GetCharHeight (this) * 18 + 5)); page->SetPageTitle (LangString["INTRO_TITLE"]); page->AddChoice (VolumeHostType::File, LangString["IDC_FILE_CONTAINER"], LangString["IDT_FILE_CONTAINER"], L"introcontainer", LangString["IDC_MORE_INFO_ON_CONTAINERS"]); page->AddChoice (VolumeHostType::Device, _("Create a volume within a partition/&drive"), _("Formats and encrypts a non-system partition, entire external or secondary drive, entire USB stick, etc.")); page->SetSelection (SelectedVolumeHostType); return page; } case Step::VolumeType: { SingleChoiceWizardPage <VolumeType::Enum> *page = new SingleChoiceWizardPage <VolumeType::Enum> (GetPageParent(), wxEmptyString, true); page->SetPageTitle (LangString["VOLUME_TYPE_TITLE"]); page->AddChoice (VolumeType::Normal, LangString["IDC_STD_VOL"], LangString["NORMAL_VOLUME_TYPE_HELP"]); page->AddChoice (VolumeType::Hidden, LangString["IDC_HIDDEN_VOL"], LangString["HIDDEN_VOLUME_TYPE_HELP"], L"hiddenvolume", LangString["IDC_HIDDEN_VOL_HELP"]); page->SetSelection (SelectedVolumeType); return page; } case Step::VolumeLocation: { VolumeLocationWizardPage *page = new VolumeLocationWizardPage (GetPageParent(), SelectedVolumeHostType); page->SetPageTitle (LangString["VOLUME_LOCATION"]); if (SelectedVolumeType == VolumeType::Hidden) page->SetPageText (LangString[SelectedVolumeHostType == VolumeHostType::File ? "FILE_HELP_HIDDEN_HOST_VOL" : "DEVICE_HELP_HIDDEN_HOST_VOL"]); else page->SetPageText (LangString[SelectedVolumeHostType == VolumeHostType::File ? "FILE_HELP" : "DEVICE_HELP_NO_INPLACE"]); page->SetVolumePath (SelectedVolumePath); return page; } case Step::EncryptionOptions: { EncryptionOptionsWizardPage *page = new EncryptionOptionsWizardPage (GetPageParent()); if (OuterVolume) page->SetPageTitle (LangString["CIPHER_HIDVOL_HOST_TITLE"]); else if (SelectedVolumeType == VolumeType::Hidden) page->SetPageTitle (LangString["CIPHER_HIDVOL_TITLE"]); else page->SetPageTitle (LangString["CIPHER_TITLE"]); page->SetEncryptionAlgorithm (SelectedEncryptionAlgorithm); page->SetHash (SelectedHash); return page; } case Step::VolumeSize: { wxString freeSpaceText; wxString pageTitle; wxString pageText; if (OuterVolume) { pageTitle = LangString["SIZE_HIDVOL_HOST_TITLE"]; pageText = LangString["SIZE_HELP_HIDDEN_HOST_VOL"]; } else if (SelectedVolumeType == VolumeType::Hidden) { pageTitle = LangString["SIZE_HIDVOL_TITLE"]; pageText = LangString["SIZE_HELP_HIDDEN_VOL"] + L"\n\n" + _("Please note that if your operating system does not allocate files from the beginning of the free space, the maximum possible hidden volume size may be much smaller than the size of the free space on the outer volume. This not a bug in nemesis but a limitation of the operating system."); freeSpaceText = StringFormatter (_("Maximum possible hidden volume size for this volume is {0}."), Gui->SizeToString (MaxHiddenVolumeSize)); } else { pageTitle = LangString["SIZE_TITLE"]; pageText = LangString["VOLUME_SIZE_HELP"]; } VolumeSizeWizardPage *page = new VolumeSizeWizardPage (GetPageParent(), SelectedVolumePath, SectorSize, freeSpaceText); page->SetPageTitle (pageTitle); page->SetPageText (pageText); if (!OuterVolume && SelectedVolumeType == VolumeType::Hidden) page->SetMaxVolumeSize (MaxHiddenVolumeSize); else page->SetVolumeSize (VolumeSize); if (OuterVolume) page->SetMinVolumeSize (TC_MIN_HIDDEN_VOLUME_HOST_SIZE); else if (SelectedVolumeType == VolumeType::Hidden) page->SetMinVolumeSize (TC_MIN_HIDDEN_VOLUME_SIZE); else page->SetMinVolumeSize (TC_MIN_VOLUME_SIZE); return page; } case Step::VolumePassword: { VolumePasswordWizardPage *page = new VolumePasswordWizardPage (GetPageParent(), Password, Keyfiles); if (OuterVolume) page->SetPageTitle (LangString["PASSWORD_HIDVOL_HOST_TITLE"]); else if (SelectedVolumeType == VolumeType::Hidden) page->SetPageTitle (LangString["PASSWORD_HIDVOL_TITLE"]); else page->SetPageTitle (LangString["PASSWORD_TITLE"]); page->SetPageText (LangString[OuterVolume ? "PASSWORD_HIDDENVOL_HOST_HELP" : "PASSWORD_HELP"]); return page; } case Step::LargeFilesSupport: { SingleChoiceWizardPage <bool> *page = new SingleChoiceWizardPage <bool> (GetPageParent(), wxEmptyString, true); page->SetPageTitle (LangString["FILESYS_PAGE_TITLE"]); page->AddChoice (false, _("I will not store files larger than 4 GB on the volume"), _("Choose this option if you do not need to store files larger than 4 GB (4,294,967,296 bytes) on the volume.")); page->AddChoice (true, _("I will store files larger than 4 GB on the volume"), _("Choose this option if you need to store files larger than 4 GB (4,294,967,296 bytes) on the volume.")); page->SetSelection (LargeFilesSupport); return page; } case Step::FormatOptions: { VolumeFormatOptionsWizardPage *page = new VolumeFormatOptionsWizardPage (GetPageParent(), VolumeSize, SectorSize, SelectedVolumePath.IsDevice() && (OuterVolume || SelectedVolumeType != VolumeType::Hidden), OuterVolume, LargeFilesSupport); page->SetPageTitle (_("Format Options")); page->SetFilesystemType (SelectedFilesystemType); if (!OuterVolume && SelectedVolumeType == VolumeType::Hidden) QuickFormatEnabled = true; page->SetQuickFormat (QuickFormatEnabled); return page; } case Step::CrossPlatformSupport: { SingleChoiceWizardPage <bool> *page = new SingleChoiceWizardPage <bool> (GetPageParent(), wxEmptyString, true); page->SetPageTitle (_("Cross-Platform Support")); page->AddChoice (true, _("I will mount the volume on other platforms"), _("Choose this option if you need to use the volume on other platforms.")); page->AddChoice (false, StringFormatter (_("I will mount the volume only on {0}"), SystemInfo::GetPlatformName()), _("Choose this option if you do not need to use the volume on other platforms.")); page->SetSelection (CrossPlatformSupport); return page; } case Step::CreationProgress: { VolumeCreationProgressWizardPage *page = new VolumeCreationProgressWizardPage (GetPageParent(), DisplayKeyInfo); if (OuterVolume) page->SetPageTitle (LangString["FORMAT_HIDVOL_HOST_TITLE"]); else if (SelectedVolumeType == VolumeType::Hidden) page->SetPageTitle (LangString["FORMAT_HIDVOL_TITLE"]); else page->SetPageTitle (LangString["FORMAT_TITLE"]); page->SetPageText (LangString["FORMAT_HELP"]); page->AbortEvent.Connect (EventConnector <VolumeCreationWizard> (this, &VolumeCreationWizard::OnAbortButtonClick)); page->SetNextButtonText (LangString["FORMAT"]); return page; } case Step::VolumeCreatedInfo: { InfoWizardPage *page = new InfoWizardPage (GetPageParent()); page->SetPageTitle (LangString["FORMAT_FINISHED_TITLE"]); page->SetPageText (LangString["FORMAT_FINISHED_HELP"]); SetCancelButtonText (_("Exit")); return page; } case Step::OuterVolumeContents: { ClearHistory(); MountOptions mountOptions; mountOptions.Keyfiles = Keyfiles; mountOptions.Password = Password; mountOptions.Path = make_shared <VolumePath> (SelectedVolumePath); try { wxBusyCursor busy; Gui->SetActiveFrame (this); MountedOuterVolume = Core->MountVolume (mountOptions); } catch (exception &e) { Gui->SetActiveFrame (this); Gui->ShowError (e); Close(); return new InfoWizardPage (GetPageParent()); } struct OpenOuterVolumeFunctor : public Functor { OpenOuterVolumeFunctor (const DirectoryPath &outerVolumeMountPoint) : OuterVolumeMountPoint (outerVolumeMountPoint) { } virtual void operator() () { Gui->OpenExplorerWindow (OuterVolumeMountPoint); } DirectoryPath OuterVolumeMountPoint; }; InfoWizardPage *page = new InfoWizardPage (GetPageParent(), _("Open Outer Volume"), shared_ptr <Functor> (new OpenOuterVolumeFunctor (MountedOuterVolume->MountPoint))); page->SetPageTitle (LangString["HIDVOL_HOST_FILLING_TITLE"]); page->SetPageText (StringFormatter ( _("Outer volume has been successfully created and mounted as '{0}'. To this volume you should now copy some sensitive-looking files that you actually do NOT want to hide. The files will be there for anyone forcing you to disclose your password. You will reveal only the password for this outer volume, not for the hidden one. The files that you really care about will be stored in the hidden volume, which will be created later on. When you finish copying, click Next. Do not dismount the volume.\n\nNote: After you click Next, the outer volume will be analyzed to determine the size of uninterrupted area of free space whose end is aligned with the end of the volume. This area will accommodate the hidden volume, so it will limit its maximum possible size. The procedure ensures no data on the outer volume are overwritten by the hidden volume."), wstring (MountedOuterVolume->MountPoint))); return page; } case Step::HiddenVolume: { ClearHistory(); OuterVolume = false; LargeFilesSupport = false; InfoWizardPage *page = new InfoWizardPage (GetPageParent()); page->SetPageTitle (LangString["HIDVOL_PRE_CIPHER_TITLE"]); page->SetPageText (LangString["HIDVOL_PRE_CIPHER_HELP"]); return page; } default: throw ParameterIncorrect (SRC_POS); } } void VolumeCreationWizard::OnAbortButtonClick (EventArgs &args) { AbortRequested = true; } void VolumeCreationWizard::OnMouseMotion (wxMouseEvent& event) { event.Skip(); if (!IsWorkInProgress() && RandomNumberGenerator::IsRunning()) { RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event))); long coord = event.GetX(); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); coord = event.GetY(); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); } } void VolumeCreationWizard::OnProgressTimer () { if (!IsWorkInProgress()) return; if (AbortRequested && !AbortConfirmationPending) { AbortConfirmationPending = true; if (Gui->AskYesNo (LangString ["FORMAT_ABORT"], true)) { if (IsWorkInProgress() && Creator.get() != nullptr) { CreationAborted = true; Creator->Abort(); } } AbortRequested = false; AbortConfirmationPending = false; } VolumeCreator::ProgressInfo progress = Creator->GetProgressInfo(); VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); page->SetProgressValue (progress.SizeDone); if (!progress.CreationInProgress && !AbortConfirmationPending) { SetWorkInProgress (false); OnVolumeCreatorFinished (); } } void VolumeCreationWizard::OnRandomPoolUpdateTimer () { if (!IsWorkInProgress()) { wxLongLong time = wxGetLocalTimeMillis(); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&time), sizeof (time))); } } void VolumeCreationWizard::OnVolumeCreatorFinished () { VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); ProgressTimer.reset(); page->SetProgressState (false); Gui->EndInteractiveBusyState (this); SetWorkInProgress (false); UpdateControls(); try { if (!CreationAborted) { Creator->CheckResult(); #ifdef TC_UNIX // Format non-FAT filesystem const char *fsFormatter = nullptr; switch (SelectedFilesystemType) { case VolumeCreationOptions::FilesystemType::Ext2: fsFormatter = "mkfs.ext2"; break; case VolumeCreationOptions::FilesystemType::Ext3: fsFormatter = "mkfs.ext3"; break; #ifdef TC_MACOSX case VolumeCreationOptions::FilesystemType::exFAT: fsFormatter = "newfs_exfat"; break; #endif case VolumeCreationOptions::FilesystemType::Ext4: fsFormatter = "mkfs.ext4"; break; case VolumeCreationOptions::FilesystemType::MacOsExt: fsFormatter = "newfs_hfs"; break; case VolumeCreationOptions::FilesystemType::UFS: fsFormatter = "newfs" ; break; default: break; } if (fsFormatter) { wxBusyCursor busy; MountOptions mountOptions (Gui->GetPreferences().DefaultMountOptions); mountOptions.Path = make_shared <VolumePath> (SelectedVolumePath); mountOptions.NoFilesystem = true; mountOptions.Protection = VolumeProtection::None; mountOptions.Password = Password; mountOptions.Keyfiles = Keyfiles; shared_ptr <VolumeInfo> volume = Core->MountVolume (mountOptions); finally_do_arg (shared_ptr <VolumeInfo>, volume, { Core->DismountVolume (finally_arg, true); }); Thread::Sleep (2000); // Try to prevent race conditions caused by OS // Temporarily take ownership of the device if the user is not an administrator UserId origDeviceOwner ((uid_t) -1); DevicePath virtualDevice = volume->VirtualDevice; #ifdef TC_MACOSX string virtualDeviceStr = virtualDevice; if (virtualDeviceStr.find ("/dev/rdisk") != 0) virtualDevice = "/dev/r" + virtualDeviceStr.substr (5); #endif try { File file; file.Open (virtualDevice, File::OpenReadWrite); } catch (...) { if (!Core->HasAdminPrivileges()) { origDeviceOwner = virtualDevice.GetOwner(); Core->SetFileOwner (virtualDevice, UserId (getuid())); } } finally_do_arg2 (FilesystemPath, virtualDevice, UserId, origDeviceOwner, { if (finally_arg2.SystemId != (uid_t) -1) Core->SetFileOwner (finally_arg, finally_arg2); }); // Create filesystem list <string> args; if (SelectedFilesystemType == VolumeCreationOptions::FilesystemType::MacOsExt && VolumeSize >= 10 * BYTES_PER_MB) args.push_back ("-J"); args.push_back (string (virtualDevice)); Process::Execute (fsFormatter, args); } #endif // TC_UNIX if (OuterVolume) { SetStep (Step::OuterVolumeContents); } else { Gui->ShowInfo (SelectedVolumeType == VolumeType::Hidden ? "HIDVOL_FORMAT_FINISHED_HELP" : "FORMAT_FINISHED_INFO"); SetStep (Step::VolumeCreatedInfo); } return; } } catch (exception &e) { Gui->ShowError (e); } page->SetProgressValue (0); if (SelectedVolumeType == VolumeType::Normal && !SelectedVolumePath.IsDevice()) { try { FilePath (wstring (SelectedVolumePath)).Delete(); } catch (...) { } } } WizardFrame::WizardStep VolumeCreationWizard::ProcessPageChangeRequest (bool forward) { switch (GetCurrentStep()) { case Step::VolumeHostType: { SingleChoiceWizardPage <VolumeHostType::Enum> *page = dynamic_cast <SingleChoiceWizardPage <VolumeHostType::Enum> *> (GetCurrentPage()); try { SelectedVolumeHostType = page->GetSelection(); } catch (NoItemSelected &) { return GetCurrentStep(); } return Step::VolumeType; } case Step::VolumeType: { SingleChoiceWizardPage <VolumeType::Enum> *page = dynamic_cast <SingleChoiceWizardPage <VolumeType::Enum> *> (GetCurrentPage()); try { SelectedVolumeType = page->GetSelection(); } catch (NoItemSelected &) { return GetCurrentStep(); } if (SelectedVolumeType == VolumeType::Hidden) OuterVolume = true; return Step::VolumeLocation; } case Step::VolumeLocation: { VolumeLocationWizardPage *page = dynamic_cast <VolumeLocationWizardPage *> (GetCurrentPage()); SelectedVolumePath = page->GetVolumePath(); VolumeSize = 0; if (forward) { if (Core->IsVolumeMounted (SelectedVolumePath)) { Gui->ShowInfo ("DISMOUNT_FIRST"); return GetCurrentStep(); } if (SelectedVolumePath.IsDevice()) { if (!DeviceWarningConfirmed && !Gui->AskYesNo (LangString["FORMAT_DEVICE_FOR_ADVANCED_ONLY"])) return GetCurrentStep(); DeviceWarningConfirmed = true; foreach_ref (const HostDevice &drive, Core->GetHostDevices()) { if (drive.Path == SelectedVolumePath && !drive.Partitions.empty()) { foreach_ref (const HostDevice &partition, drive.Partitions) { if (partition.MountPoint == "/") { Gui->ShowError (_("Error: You are trying to encrypt a system drive.\n\nnemesis can encrypt a system drive only under Windows.")); return GetCurrentStep(); } } Gui->ShowError ("DEVICE_PARTITIONS_ERR"); return GetCurrentStep(); } } try { SectorSize = Core->GetDeviceSectorSize (SelectedVolumePath); VolumeSize = Core->GetDeviceSize (SelectedVolumePath); } catch (UserAbort&) { return Step::VolumeLocation; } catch (exception &e) { Gui->ShowError (e); Gui->ShowError ("CANNOT_CALC_SPACE"); return GetCurrentStep(); } DirectoryPath mountPoint; try { mountPoint = Core->GetDeviceMountPoint (SelectedVolumePath); if (!mountPoint.IsEmpty()) { if (mountPoint == "/") { Gui->ShowError (_("Error: You are trying to encrypt a system partition.\n\nnemesis can encrypt system partitions only under Windows.")); return GetCurrentStep(); } if (!Gui->AskYesNo (StringFormatter (_("WARNING: Formatting of the device will destroy all data on filesystem '{0}'.\n\nDo you want to continue?"), wstring (mountPoint)), false, true)) return GetCurrentStep(); try { Core->DismountFilesystem (mountPoint, true); } catch (exception &e) { Gui->ShowError (e); Gui->ShowError (StringFormatter (_("The filesystem of the selected device is currently mounted. Please dismount '{0}' before proceeding."), wstring (mountPoint))); return GetCurrentStep(); } } } catch (...) { } } else SectorSize = TC_SECTOR_SIZE_FILE_HOSTED_VOLUME; } return Step::EncryptionOptions; } case Step::EncryptionOptions: { EncryptionOptionsWizardPage *page = dynamic_cast <EncryptionOptionsWizardPage *> (GetCurrentPage()); SelectedEncryptionAlgorithm = page->GetEncryptionAlgorithm (); SelectedHash = page->GetHash (); if (forward) RandomNumberGenerator::SetHash (SelectedHash); if (SelectedVolumePath.IsDevice() && (OuterVolume || SelectedVolumeType != VolumeType::Hidden)) return Step::VolumePassword; else return Step::VolumeSize; } case Step::VolumeSize: { VolumeSizeWizardPage *page = dynamic_cast <VolumeSizeWizardPage *> (GetCurrentPage()); try { VolumeSize = page->GetVolumeSize(); } catch (Exception &e) { if (forward) { Gui->ShowError (e); return GetCurrentStep(); } } if (forward && !OuterVolume && SelectedVolumeType == VolumeType::Hidden && (double) VolumeSize / MaxHiddenVolumeSize > 0.85) { if (!Gui->AskYesNo (LangString["FREE_SPACE_FOR_WRITING_TO_OUTER_VOLUME"])) return GetCurrentStep(); } if (forward && SelectedVolumeHostType == VolumeHostType::File && VolumeSize > 4 * BYTES_PER_GB && (OuterVolume || SelectedVolumeType != VolumeType::Hidden) && !Core->FilesystemSupportsLargeFiles (SelectedVolumePath)) { Gui->ShowWarning (LangString["VOLUME_TOO_LARGE_FOR_FAT32"]); } return Step::VolumePassword; } case Step::VolumePassword: { VolumePasswordWizardPage *page = dynamic_cast <VolumePasswordWizardPage *> (GetCurrentPage()); Password = page->GetPassword(); Keyfiles = page->GetKeyfiles(); if (forward && Password && !Password->IsEmpty()) { try { Password->CheckPortability(); } catch (UnportablePassword &e) { Gui->ShowError (e); return GetCurrentStep(); } if (Password->Size() < VolumePassword::WarningSizeThreshold && !Gui->AskYesNo (LangString["PASSWORD_LENGTH_WARNING"], false, true)) { return GetCurrentStep(); } } if (forward && OuterVolume) { // Use FAT to prevent problems with free space QuickFormatEnabled = false; SelectedFilesystemType = VolumeCreationOptions::FilesystemType::FAT; return Step::CreationProgress; } if (VolumeSize > 4 * BYTES_PER_GB) { if (VolumeSize <= TC_MAX_FAT_SECTOR_COUNT * SectorSize) return Step::LargeFilesSupport; else SelectedFilesystemType = VolumeCreationOptions::FilesystemType::GetPlatformNative(); } return Step::FormatOptions; } case Step::LargeFilesSupport: { SingleChoiceWizardPage <bool> *page = dynamic_cast <SingleChoiceWizardPage <bool> *> (GetCurrentPage()); try { LargeFilesSupport = page->GetSelection(); } catch (NoItemSelected &) { return GetCurrentStep(); } if (LargeFilesSupport) SelectedFilesystemType = VolumeCreationOptions::FilesystemType::GetPlatformNative(); else SelectedFilesystemType = VolumeCreationOptions::FilesystemType::FAT; return Step::FormatOptions; } case Step::FormatOptions: { VolumeFormatOptionsWizardPage *page = dynamic_cast <VolumeFormatOptionsWizardPage *> (GetCurrentPage()); SelectedFilesystemType = page->GetFilesystemType(); QuickFormatEnabled = page->IsQuickFormatEnabled(); if (SelectedFilesystemType != VolumeCreationOptions::FilesystemType::None && SelectedFilesystemType != VolumeCreationOptions::FilesystemType::FAT) return Step::CrossPlatformSupport; return Step::CreationProgress; } case Step::CrossPlatformSupport: { SingleChoiceWizardPage <bool> *page = dynamic_cast <SingleChoiceWizardPage <bool> *> (GetCurrentPage()); try { CrossPlatformSupport = page->GetSelection(); } catch (NoItemSelected &) { return GetCurrentStep(); } if (forward && CrossPlatformSupport) Gui->ShowWarning (StringFormatter (_("Please note that the volume will not be formatted with a FAT filesystem and, therefore, you may be required to install additional filesystem drivers on platforms other than {0}, which will enable you to mount the volume."), SystemInfo::GetPlatformName())); return Step::CreationProgress; } case Step::CreationProgress: { VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); DisplayKeyInfo = page->IsKeyInfoDisplayed(); if (forward) { if (SelectedVolumeType != VolumeType::Hidden || OuterVolume) { if (OuterVolume && VolumeSize > TC_MAX_FAT_SECTOR_COUNT * SectorSize) { uint64 limit = TC_MAX_FAT_SECTOR_COUNT * SectorSize / BYTES_PER_TB; wstring err = StringFormatter (_("Error: The hidden volume to be created is larger than {0} TB ({1} GB).\n\nPossible solutions:\n- Create a container/partition smaller than {0} TB.\n"), limit, limit * 1024); if (SectorSize < 4096) { err += _("- Use a drive with 4096-byte sectors to be able to create partition/device-hosted hidden volumes up to 16 TB in size"); #if defined (TC_LINUX) err += _(".\n"); #else err += _(" (not supported by components available on this platform).\n"); #endif } Gui->ShowError (err); return GetCurrentStep(); } if (SelectedVolumePath.IsDevice()) { wxString confirmMsg = LangString["OVERWRITEPROMPT_DEVICE"]; confirmMsg.Replace (L"%hs", L"%s"); if (!Gui->AskYesNo (wxString::Format (confirmMsg, wxString (_("DEVICE")).c_str(), wstring (SelectedVolumePath).c_str(), L""), false, true)) return GetCurrentStep(); } else if (FilesystemPath (wstring (SelectedVolumePath)).IsFile()) { wxString confirmMsg = LangString["OVERWRITEPROMPT"]; confirmMsg.Replace (L"%hs", L"%s"); if (!Gui->AskYesNo (wxString::Format (confirmMsg, wstring (SelectedVolumePath).c_str(), false, true))) return GetCurrentStep(); } } AbortRequested = false; AbortConfirmationPending = false; CreationAborted = false; SetWorkInProgress (true); UpdateControls(); Gui->BeginInteractiveBusyState (this); try { make_shared_auto (VolumeCreationOptions, options); options->Filesystem = SelectedFilesystemType; options->FilesystemClusterSize = SelectedFilesystemClusterSize; options->SectorSize = SectorSize; options->EA = SelectedEncryptionAlgorithm; options->Password = Password; options->Keyfiles = Keyfiles; options->Path = SelectedVolumePath; options->Quick = QuickFormatEnabled; options->Size = VolumeSize; options->Type = OuterVolume ? VolumeType::Normal : SelectedVolumeType; options->VolumeHeaderKdf = Pkcs5Kdf::GetAlgorithm (*SelectedHash); Creator.reset (new VolumeCreator); Creator->CreateVolume (options); page->SetKeyInfo (Creator->GetKeyInfo()); class Timer : public wxTimer { public: Timer (VolumeCreationWizard *wizard) : Wizard (wizard) { } void Notify() { Wizard->OnProgressTimer(); } VolumeCreationWizard *Wizard; }; page->SetProgressRange (options->Size); page->SetProgressState (true); ProgressTimer.reset (dynamic_cast <wxTimer *> (new Timer (this))); ProgressTimer->Start (50); } catch (Exception &e) { CreationAborted = true; OnVolumeCreatorFinished(); Gui->ShowError (e); } } return GetCurrentStep(); } case Step::VolumeCreatedInfo: Creator.reset(); SetCancelButtonText (L""); return Step::VolumeHostType; case Step::OuterVolumeContents: try { // Determine maximum size of the hidden volume. Scan cluster table offline as a live filesystem test would // require using FUSE and loop device which cannot be used for devices with sectors larger than 512. wxBusyCursor busy; MaxHiddenVolumeSize = 0; Gui->SetActiveFrame (this); if (MountedOuterVolume) { Core->DismountVolume (MountedOuterVolume); MountedOuterVolume.reset(); } #ifdef TC_UNIX // Temporarily take ownership of a device if the user is not an administrator UserId origDeviceOwner ((uid_t) -1); if (!Core->HasAdminPrivileges() && SelectedVolumePath.IsDevice()) { origDeviceOwner = FilesystemPath (wstring (SelectedVolumePath)).GetOwner(); Core->SetFileOwner (SelectedVolumePath, UserId (getuid())); } finally_do_arg2 (FilesystemPath, SelectedVolumePath, UserId, origDeviceOwner, { if (finally_arg2.SystemId != (uid_t) -1) Core->SetFileOwner (finally_arg, finally_arg2); }); #endif shared_ptr <Volume> outerVolume = Core->OpenVolume (make_shared <VolumePath> (SelectedVolumePath), true, Password, Keyfiles, VolumeProtection::ReadOnly); MaxHiddenVolumeSize = Core->GetMaxHiddenVolumeSize (outerVolume); // Add a reserve (in case the user mounts the outer volume and creates new files // on it by accident or OS writes some new data behind his or her back, such as // System Restore etc.) uint64 reservedSize = outerVolume->GetSize() / 200; if (reservedSize > 10 * BYTES_PER_MB) reservedSize = 10 * BYTES_PER_MB; if (MaxHiddenVolumeSize < reservedSize) MaxHiddenVolumeSize = 0; else MaxHiddenVolumeSize -= reservedSize; MaxHiddenVolumeSize -= MaxHiddenVolumeSize % outerVolume->GetSectorSize(); // Must be a multiple of the sector size } catch (exception &e) { Gui->SetActiveFrame (this); Gui->ShowError (e); return GetCurrentStep(); } return Step::HiddenVolume; case Step::HiddenVolume: return Step::EncryptionOptions; default: throw ParameterIncorrect (SRC_POS); } } void VolumeCreationWizard::UpdateControls () { VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); if (page) { page->EnableAbort (IsWorkInProgress()); } } bool VolumeCreationWizard::DeviceWarningConfirmed; }
/* * Copyright (c) 2019, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <cudf/utilities/traits.hpp> #include <tests/utilities/type_lists.hpp> #include <tests/utilities/base_fixture.hpp> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <algorithm> #include <tuple> template <typename Tuple, typename F, std::size_t... Indices> void tuple_for_each_impl(Tuple&& tuple, F&& f, std::index_sequence<Indices...>) { (void)std::initializer_list<int>{ ((void)(f(std::get<Indices>(std::forward<Tuple>(tuple)))), int{})...}; } template <typename F, typename... Args> void tuple_for_each(const std::tuple<Args...>& tuple, F&& f) { tuple_for_each_impl(tuple, std::forward<F>(f), std::index_sequence_for<Args...>{}); } class TraitsTest : public ::testing::Test {}; template <typename T> class TypedTraitsTest : public TraitsTest {}; TYPED_TEST_CASE(TypedTraitsTest, cudf::test::AllTypes); TEST_F(TraitsTest, NumericDataTypesAreNumeric) { using namespace cudf::test; EXPECT_TRUE(std::all_of(numeric_type_ids.begin(), numeric_type_ids.end(), [](cudf::type_id type) { return cudf::is_numeric(cudf::data_type{type}); })); } TEST_F(TraitsTest, TimestampDataTypesAreNotNumeric) { using namespace cudf::test; EXPECT_TRUE(std::none_of( timestamp_type_ids.begin(), timestamp_type_ids.end(), [](cudf::type_id type) { return cudf::is_numeric(cudf::data_type{type}); })); } /* These types are not yet supported by the type dispatcher TEST_F(TraitsTest, NonNumericDataTypesAreNotNumeric) { using namespace cudf::test; EXPECT_TRUE(std::none_of( non_numeric_type_ids.begin(), non_numeric_type_ids.end(), [](cudf::type_id type) { return cudf::is_numeric(cudf::data_type{type}); })); } */ TEST_F(TraitsTest, NumericDataTypesAreNotTimestamps) { using namespace cudf::test; EXPECT_TRUE(std::none_of(numeric_type_ids.begin(), numeric_type_ids.end(), [](cudf::type_id type) { return cudf::is_timestamp(cudf::data_type{type}); })); } TEST_F(TraitsTest, TimestampDataTypesAreTimestamps) { using namespace cudf::test; EXPECT_TRUE(std::all_of( timestamp_type_ids.begin(), timestamp_type_ids.end(), [](cudf::type_id type) { return cudf::is_timestamp(cudf::data_type{type}); })); } TYPED_TEST(TypedTraitsTest, RelationallyComparable) { // All the test types should be comparable with themselves bool comparable = cudf::is_relationally_comparable<TypeParam, TypeParam>(); EXPECT_TRUE(comparable); } TYPED_TEST(TypedTraitsTest, NotRelationallyComparable) { // No type should be comparable with an empty dummy type struct foo {}; bool comparable = cudf::is_relationally_comparable<foo, TypeParam>(); EXPECT_FALSE(comparable); comparable = cudf::is_relationally_comparable<TypeParam, foo>(); EXPECT_FALSE(comparable); } // TODO: Tests for is_compound/is_simple, is_fixed_width CUDF_TEST_PROGRAM_MAIN()
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 4, 0x90 .globl _n8_cpAddMulDgt_BNU _n8_cpAddMulDgt_BNU: push %rbx push %r12 mov %edx, %edx movq (%rsi), %rax cmp $(1), %rdx jnz .Lgeneral_casegas_1 mul %rcx addq %rax, (%rdi) adc $(0), %rdx mov %rdx, %rax pop %r12 pop %rbx ret .Lgeneral_casegas_1: lea (-40)(%rsi,%rdx,8), %rsi lea (-40)(%rdi,%rdx,8), %rdi mov $(5), %rbx sub %rdx, %rbx mul %rcx mov %rax, %r8 movq (8)(%rsi,%rbx,8), %rax mov %rdx, %r9 cmp $(0), %rbx jge .Lskip_muladd_loop4gas_1 .p2align 4, 0x90 .Lmuladd_loop4gas_1: mul %rcx xor %r10, %r10 addq %r8, (%rdi,%rbx,8) adc %rax, %r9 movq (16)(%rsi,%rbx,8), %rax adc %rdx, %r10 mul %rcx xor %r11, %r11 addq %r9, (8)(%rdi,%rbx,8) adc %rax, %r10 movq (24)(%rsi,%rbx,8), %rax adc %rdx, %r11 mul %rcx xor %r8, %r8 addq %r10, (16)(%rdi,%rbx,8) adc %rax, %r11 movq (32)(%rsi,%rbx,8), %rax adc %rdx, %r8 mul %rcx xor %r9, %r9 addq %r11, (24)(%rdi,%rbx,8) adc %rax, %r8 movq (40)(%rsi,%rbx,8), %rax adc %rdx, %r9 add $(4), %rbx jnc .Lmuladd_loop4gas_1 .Lskip_muladd_loop4gas_1: mul %rcx xor %r10, %r10 addq %r8, (%rdi,%rbx,8) adc %rax, %r9 adc %rdx, %r10 cmp $(2), %rbx ja .Lfin_mul1x4n_2gas_1 jz .Lfin_mul1x4n_3gas_1 jp .Lfin_mul1x4n_4gas_1 .Lfin_mul1x4n_1gas_1: movq (16)(%rsi,%rbx,8), %rax mul %rcx xor %r11, %r11 addq %r9, (8)(%rdi,%rbx,8) adc %rax, %r10 movq (24)(%rsi,%rbx,8), %rax adc %rdx, %r11 mul %rcx xor %r8, %r8 addq %r10, (16)(%rdi,%rbx,8) adc %rax, %r11 movq (32)(%rsi,%rbx,8), %rax adc %rdx, %r8 mul %rcx xor %r9, %r9 addq %r11, (24)(%rdi,%rbx,8) adc %rax, %r8 adc $(0), %rdx addq %r8, (32)(%rdi,%rbx,8) adc $(0), %rdx mov %rdx, %rax jmp .Lexitgas_1 .Lfin_mul1x4n_4gas_1: movq (16)(%rsi,%rbx,8), %rax mul %rcx xor %r11, %r11 addq %r9, (8)(%rdi,%rbx,8) adc %rax, %r10 movq (24)(%rsi,%rbx,8), %rax adc %rdx, %r11 mul %rcx xor %r8, %r8 addq %r10, (16)(%rdi,%rbx,8) adc %rax, %r11 adc $(0), %rdx addq %r11, (24)(%rdi,%rbx,8) adc $(0), %rdx mov %rdx, %rax jmp .Lexitgas_1 .Lfin_mul1x4n_3gas_1: movq (16)(%rsi,%rbx,8), %rax mul %rcx xor %r11, %r11 addq %r9, (8)(%rdi,%rbx,8) adc %rax, %r10 adc $(0), %rdx addq %r10, (16)(%rdi,%rbx,8) adc $(0), %rdx mov %rdx, %rax jmp .Lexitgas_1 .Lfin_mul1x4n_2gas_1: addq %r9, (8)(%rdi,%rbx,8) adc $(0), %r10 mov %r10, %rax .Lexitgas_1: pop %r12 pop %rbx ret
SCLK .set 3 MOSI .set 2 MISO .set 5 ; TODO: v2-branch has improved but untested code (hw-loops, simultanious mosi / clk setting) ; TODO: code of DAC is 1:1 replacement, ADC is more difficult .macro NOP ; TODO: this assembler understands a simple NOP, without macro MOV r23, r23 .endm .global adc_readwrite adc_readwrite: MOV r24, r14 ; Save input arg (CS pin) LDI r20, 16 ; Load Counter for outloop LDI r21, 18; Load Counter for inloop LDI r14, 0 ; Clear return reg SET r30, r30, SCLK ; Set SCLK high CLR r30, r30, r24 ; Set CS low adc_outloop_head: SUB r20, r20, 1 ; decrement shiftloop counter QBBC adc_mosi_clear, r15, r20 adc_mosi_set: SET r30, r30, SCLK ; Set SCLK high SET r30, r30, MOSI ; Set MOSI high JMP adc_outloop_tail adc_mosi_clear: SET r30, r30, SCLK ; Set SCLK high CLR r30, r30, MOSI ; Set MOSI low NOP adc_outloop_tail: NOP NOP NOP CLR r30, r30, SCLK ; Set SCLK low NOP NOP QBLT adc_outloop_head, r20, 0 NOP CLR r30, r30, MOSI ; clear MOSI adc_inloop_head: SET r30, r30, SCLK ; Set SCLK high SUB r21, r21, 1 ; decrement shiftloop counter NOP NOP NOP NOP CLR r30, r30, SCLK ; Set SCLK low QBBC adc_miso_clear, r31, MISO adc_miso_set: SET r14, r14, r21 JMP adc_inloop_tail adc_miso_clear: NOP NOP adc_inloop_tail: NOP QBLT adc_inloop_head, r21, 0 adc_end: SET r30, r30, r24 ; set CS high JMP r3.w2 ; DAC8562 ; -> MSB begins with falling CS ; -> begin with high CLK ; -> Reads on falling CLK-Edge ; -> transfer frame must contain 24 capture edges for writing .global dac_write ; code performs with 25 MHz, ~ 980 ns CS low dac_write: LDI r20, 24 ; Load Counter for outloop SET r30, r30, SCLK ; Set SCLK high CLR r30, r30, r14 ; Set CS low dac_loop_head: SUB r20, r20, 1 ; Decrement counter QBBS dac_mosi_set, r15, r20 ; If bit number [r20] is set in value [r15] dac_mosi_clear: SET r30, r30, SCLK ; Set SCLK high CLR r30, r30, MOSI ; Set MOSI low JMP dac_loop_tail dac_mosi_set: SET r30, r30, SCLK ; Set SCLK high SET r30, r30, MOSI ; Set MOSI high NOP dac_loop_tail: NOP CLR r30, r30, SCLK ; Set SCLK low QBLT dac_loop_head, r20, 0 dac_end: NOP CLR r30, r30, MOSI ; clear MOSI SET r30, r30, r14 ; set CS high JMP r3.w2
nop nop nop main: addi $sp, $sp, 128 addi $a0, $0, 8 # n = 8 addi $s3, $0, 1 addi $s4, $0, 2 jal fib add $s0, $v0, $0 j done fib: addi $sp, $sp, -20 sw $ra, 20($sp) beq $a0, $s3, n0 beq $a0, $s4, n1 sw $a0, 0($sp) lw $t0, 0($sp) addi $t1, $t0, -1 addi $t2, $t0, -2 sw $t1, 4($sp) sw $t2, 8($sp) lw $a0, 4($sp) jal fib sw $v0, 12($sp) lw $a0, 8($sp) jal fib sw $v0, 16($sp) lw $t3, 12($sp) lw $t4, 16($sp) add $v0, $t3, $t4 j end n0: # Fibonacci base case n = 1 addi $v0, $0, 0 j end n1: # Fibonacci base case n = 2 addi $v0, $0, 1 j end end: # End of fibonacci function lw $ra, 20($sp) addi $sp, $sp, 20 jr $ra done: # Result from fib function -> $s0 = 13 ori $t6, $0, 1 addi $s1, $s0, 1 j while while: # Do while loop with exit condition $s1 = 0 addi $s1, $s1, -1 add $s5, $s5, $s4 # $s5 = $s5 + 2 bne $s1, $0, while
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "primitives/block.h" #include "hash.h" #include "tinyformat.h" #include "utilstrencodings.h" #include "crypto/common.h" #include "arith_uint256.h" #include "patternsearch.h" uint256 CBlockHeader::GetHash() const { uint256 midHash = GetMidHash(); uint256 cacheBlockHash=Hash(BEGIN(nVersion), END(nFinalCalculation)); if(!patternsearch::pattern_verify( midHash, nStartLocation, nFinalCalculation)){ return uint256S("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); }else{ return cacheBlockHash; } } uint256 CBlockHeader::GetMidHash() const { return Hash(BEGIN(nVersion), END(nNonce)); //return SerializeHash(*this); } uint256 CBlockHeader::FindBestPatternHash(int& collisions,char *scratchpad,int nThreads,int* minerStopFlag) { uint256 smallestHashSoFar = uint256S("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); uint32_t smallestHashLocation=0; uint32_t smallestHashFinalCalculation=0; if(nThreads==0){ return smallestHashSoFar; } uint256 midHash = GetMidHash(); //Threads can only be a power of 2 /*int newThreadNumber = 1; while(newThreadNumber < nThreads){ newThreadNumber*=2; } nThreads=newThreadNumber;*/ std::vector< std::pair<uint32_t,uint32_t> > results =patternsearch::pattern_search( midHash,scratchpad,nThreads,minerStopFlag); //uint32_t candidateStartLocation=0; //uint32_t candidateFinalCalculation=0; collisions=results.size(); uint256 fullHash = smallestHashSoFar; for (unsigned i=0; i < results.size(); i++) { nStartLocation = results[i].first; nFinalCalculation = results[i].second; fullHash = Hash(BEGIN(nVersion), END(nFinalCalculation)); //LogPrintf("Consider Candidate:%s\n",fullHash.ToString()); //LogPrintf("against:%s\n",smallestHashSoFar.ToString()); if(UintToArith256(fullHash)<UintToArith256(smallestHashSoFar)){ //LogPrintf("New Best Candidate:%s\n",fullHash.ToString()); //if better, update location //printf("best hash so far for the nonce\n"); smallestHashSoFar=fullHash; smallestHashLocation=results[i].first; smallestHashFinalCalculation=results[i].second; } } nStartLocation = smallestHashLocation; nFinalCalculation = smallestHashFinalCalculation; return smallestHashSoFar; } uint256 CBlock::BuildMerkleTree(bool* fMutated) const { /* WARNING! If you're reading this because you're learning about crypto and/or designing a new system that will use merkle trees, keep in mind that the following merkle tree algorithm has a serious flaw related to duplicate txids, resulting in a vulnerability (CVE-2012-2459). The reason is that if the number of hashes in the list at a given time is odd, the last one is duplicated before computing the next level (which is unusual in Merkle trees). This results in certain sequences of transactions leading to the same merkle root. For example, these two trees: A A / \ / \ B C B C / \ | / \ / \ D E F D E F F / \ / \ / \ / \ / \ / \ / \ 1 2 3 4 5 6 1 2 3 4 5 6 5 6 for transaction lists [1,2,3,4,5,6] and [1,2,3,4,5,6,5,6] (where 5 and 6 are repeated) result in the same root hash A (because the hash of both of (F) and (F,F) is C). The vulnerability results from being able to send a block with such a transaction list, with the same merkle root, and the same block hash as the original without duplication, resulting in failed validation. If the receiving node proceeds to mark that block as permanently invalid however, it will fail to accept further unmodified (and thus potentially valid) versions of the same block. We defend against this by detecting the case where we would hash two identical hashes at the end of the list together, and treating that identically to the block having an invalid merkle root. Assuming no double-SHA256 collisions, this will detect all known ways of changing the transactions without affecting the merkle root. */ vMerkleTree.clear(); vMerkleTree.reserve(vtx.size() * 2 + 16); // Safe upper bound for the number of total nodes. for (std::vector<CTransaction>::const_iterator it(vtx.begin()); it != vtx.end(); ++it) vMerkleTree.push_back(it->GetHash()); int j = 0; bool mutated = false; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { for (int i = 0; i < nSize; i += 2) { int i2 = std::min(i+1, nSize-1); if (i2 == i + 1 && i2 + 1 == nSize && vMerkleTree[j+i] == vMerkleTree[j+i2]) { // Two identical hashes at the end of the list at a particular level. mutated = true; } vMerkleTree.push_back(Hash(BEGIN(vMerkleTree[j+i]), END(vMerkleTree[j+i]), BEGIN(vMerkleTree[j+i2]), END(vMerkleTree[j+i2]))); } j += nSize; } if (fMutated) { *fMutated = mutated; } return (vMerkleTree.empty() ? uint256() : vMerkleTree.back()); } std::vector<uint256> CBlock::GetMerkleBranch(int nIndex) const { if (vMerkleTree.empty()) BuildMerkleTree(); std::vector<uint256> vMerkleBranch; int j = 0; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { int i = std::min(nIndex^1, nSize-1); vMerkleBranch.push_back(vMerkleTree[j+i]); nIndex >>= 1; j += nSize; } return vMerkleBranch; } uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMerkleBranch, int nIndex) { if (nIndex == -1) return uint256(); for (std::vector<uint256>::const_iterator it(vMerkleBranch.begin()); it != vMerkleBranch.end(); ++it) { if (nIndex & 1) hash = Hash(BEGIN(*it), END(*it), BEGIN(hash), END(hash)); else hash = Hash(BEGIN(hash), END(hash), BEGIN(*it), END(*it)); nIndex >>= 1; } return hash; } std::string CBlock::ToString() const { std::stringstream s; s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n", GetHash().ToString(), nVersion, hashPrevBlock.ToString(), hashMerkleRoot.ToString(), nTime, nBits, nNonce, vtx.size()); for (unsigned int i = 0; i < vtx.size(); i++) { s << " " << vtx[i].ToString() << "\n"; } s << " vMerkleTree: "; for (unsigned int i = 0; i < vMerkleTree.size(); i++) s << " " << vMerkleTree[i].ToString(); s << "\n"; return s.str(); }
#include <v8.h> #include <node.h> #include <libtorrent/storage.hpp> #include "storage.hpp" using namespace v8; using namespace node; namespace nodelt { void bind_storage(Handle<Object> target) { // set libtorrent::storage_mode_t Local<Object> storage_mode_t = Object::New(); storage_mode_t->Set(String::NewSymbol("storage_mode_allocate"), Integer::New(libtorrent::storage_mode_allocate)); storage_mode_t->Set(String::NewSymbol("storage_mode_sparse"), Integer::New(libtorrent::storage_mode_sparse)); target->Set(String::NewSymbol("storage_mode_t"), storage_mode_t); }; }; // namespace nodelt
; A169515: Number of reduced words of length n in Coxeter group on 22 generators S_i with relations (S_i)^2 = (S_i S_j)^34 = I. ; 1,22,462,9702,203742,4278582,89850222,1886854662,39623947902,832102905942,17474161024782,366957381520422,7706105011928862,161828205250506102,3398392310260628142,71366238515473190982 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,21 lpe mov $0,$2 div $0,21
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x1124c, %rsi lea addresses_D_ht+0x5dda, %rdi add $50017, %rbx mov $17, %rcx rep movsw nop nop nop cmp %r13, %r13 lea addresses_A_ht+0xc4a, %rsi lea addresses_D_ht+0xa4da, %rdi nop nop nop nop nop and $45773, %r14 mov $111, %rcx rep movsb nop nop nop lfence lea addresses_UC_ht+0x9afa, %rsi lea addresses_WT_ht+0x66bc, %rdi and %rdx, %rdx mov $107, %rcx rep movsq nop cmp %r13, %r13 lea addresses_WT_ht+0x112da, %rsi lea addresses_normal_ht+0x20da, %rdi nop nop nop nop inc %r8 mov $39, %rcx rep movsq nop nop cmp %rcx, %rcx lea addresses_WC_ht+0x17eda, %rbx nop nop nop nop cmp %r8, %r8 mov (%rbx), %r14d nop nop nop nop nop add $30173, %rbx lea addresses_A_ht+0xa3f2, %r13 nop nop nop dec %rsi movb $0x61, (%r13) sub $20747, %rsi lea addresses_normal_ht+0x1e1f0, %rbx nop nop and %rdx, %rdx mov (%rbx), %cx sub %rsi, %rsi lea addresses_normal_ht+0x155da, %r8 nop nop nop xor %rbx, %rbx mov $0x6162636465666768, %rcx movq %rcx, %xmm3 and $0xffffffffffffffc0, %r8 vmovaps %ymm3, (%r8) nop nop nop nop cmp $42822, %rdi lea addresses_UC_ht+0xe138, %r8 nop nop nop nop nop add %r13, %r13 movups (%r8), %xmm1 vpextrq $1, %xmm1, %r14 nop nop inc %r14 lea addresses_UC_ht+0x19cda, %rsi nop nop nop mfence mov $0x6162636465666768, %r14 movq %r14, %xmm6 and $0xffffffffffffffc0, %rsi movaps %xmm6, (%rsi) nop nop nop nop nop mfence lea addresses_normal_ht+0x8e33, %rsi lea addresses_UC_ht+0x1581a, %rdi nop nop nop cmp %rdx, %rdx mov $39, %rcx rep movsb nop nop nop nop nop add $44007, %rcx lea addresses_WC_ht+0x95af, %rsi lea addresses_A_ht+0x246, %rdi nop nop nop dec %r14 mov $37, %rcx rep movsb nop nop xor %rdi, %rdi lea addresses_WT_ht+0x719a, %rsi nop nop nop xor $8078, %r8 movb (%rsi), %r13b nop nop add $12987, %rdx lea addresses_WC_ht+0xf9da, %rsi lea addresses_WT_ht+0x45da, %rdi nop nop nop nop dec %r13 mov $75, %rcx rep movsq nop nop add $37022, %rbx lea addresses_WC_ht+0xe052, %rsi lea addresses_WC_ht+0x34da, %rdi nop nop nop nop xor %r8, %r8 mov $11, %rcx rep movsq nop nop nop cmp $21987, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r14 push %r8 push %rax push %rbx push %rcx push %rdx push %rsi // Store lea addresses_US+0x58da, %r14 nop nop nop cmp %rbx, %rbx mov $0x5152535455565758, %rdx movq %rdx, %xmm5 movups %xmm5, (%r14) cmp %rsi, %rsi // Store lea addresses_PSE+0x42a, %rbx and $59636, %rax movb $0x51, (%rbx) nop nop nop nop nop xor %rbx, %rbx // Faulty Load lea addresses_RW+0xe0da, %rbx nop nop nop nop nop add $65346, %r8 mov (%rbx), %si lea oracles, %rax and $0xff, %rsi shlq $12, %rsi mov (%rax,%rsi,1), %rsi pop %rsi pop %rdx pop %rcx pop %rbx pop %rax pop %r8 pop %r14 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': True, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 4}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_RW', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 6}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_A_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 10}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': True, 'congruent': 7}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': True, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': True, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 10}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
; A026602: n-th number k such that s(k) = 2, where s = A026600. ; 2,4,9,10,15,17,21,23,25,28,33,35,39,41,43,47,49,54,57,59,61,65,67,72,73,78,80,82,87,89,93,95,97,101,103,108,111,113,115,119,121,126,127,132,134,137,139,144,145,150,152,156,158,160 mov $2,$0 lpb $0 add $1,$0 add $1,$0 div $0,3 lpe add $0,$1 add $0,1 lpb $0 mod $0,3 lpe mov $1,$0 add $1,1 mov $3,$2 mul $3,3 add $1,$3
BITS 32 global _MeasurementChain_Start global _MeasurementChain_Checkpoint global _MeasurementChain_End global _FunctionTracePack_Start global _FunctionTracePack_End section .text _MeasurementChain_Start: push eax push edx mov eax, 0xFFFFFFF0 ; callcount inc dword [eax] rdtsc mov dword [0xFFFFFFF8],eax ; checkpoint mov dword [0xFFFFFFFC],edx pop edx pop eax jmp $ + 0x12345678 _MeasurementChain_Checkpoint: push eax push ecx push edx push esi mov esi,dword [7E0h] ; total mov ecx,dword [7E4h] sub esi,dword [0FFFFFFF8h] ; checkpoint sbb ecx,dword [0FFFFFFFCh] rdtsc add esi,eax mov dword [7E0h],esi ; total adc ecx,edx mov dword [7E4h],ecx mov dword [0xFFFFFFF8],eax ; checkpoint mov dword [0xFFFFFFFC],edx mov eax, 0xFFFFFFF0 ; callcount inc dword [eax] pop esi pop edx pop ecx pop eax jmp $ + 0x12345678 _MeasurementChain_End: _FunctionTracePack_Start: pushad mov eax, esp push eax mov ecx,11223344h ; this mov eax,55667788h ; func call eax popad jmp $ + 0x12345678 _FunctionTracePack_End:
FuchsiaPokecenter_Script: call Serial_TryEstablishingExternallyClockedConnection jp EnableAutoTextBoxDrawing FuchsiaPokecenter_TextPointers: dw FuchsiaHealNurseText dw FuchsiaPokecenterText2 dw FuchsiaPokecenterText3 dw FuchsiaTradeNurseText FuchsiaHealNurseText: TX_POKECENTER_NURSE FuchsiaPokecenterText2: TX_FAR _FuchsiaPokecenterText1 db "@" FuchsiaPokecenterText3: TX_FAR _FuchsiaPokecenterText3 db "@" FuchsiaTradeNurseText: TX_CABLE_CLUB_RECEPTIONIST
; A123168: Continued fraction for c = sqrt(2)*(exp(sqrt(2))-1)/(exp(sqrt(2))+1). ; 0,1,6,5,14,9,22,13,30,17,38,21,46,25,54,29,62,33,70,37,78,41,86,45,94,49,102,53,110,57,118,61,126,65,134,69,142,73,150,77,158,81,166,85,174,89,182,93,190,97,198,101,206,105,214,109,222,113,230,117,238,121,246,125,254,129,262,133,270,137,278,141,286,145,294,149,302,153,310,157,318,161,326,165,334,169,342,173,350,177,358,181,366,185,374,189,382,193,390,197,398,201,406,205,414,209,422,213,430,217,438,221,446,225,454,229,462,233,470,237,478,241,486,245,494,249,502,253,510,257,518,261,526,265,534,269,542,273,550,277,558,281,566,285,574,289,582,293,590,297,598,301,606,305,614,309,622,313,630,317,638,321,646,325,654,329,662,333,670,337,678,341,686,345,694,349,702,353,710,357,718,361,726,365,734,369,742,373,750,377,758,381,766,385,774,389,782,393,790,397,798,401,806,405,814,409,822,413,830,417,838,421,846,425,854,429,862,433,870,437,878,441,886,445,894,449,902,453,910,457,918,461,926,465,934,469,942,473,950,477,958,481,966,485,974,489,982,493,990,497 mov $1,$0 mov $2,$0 gcd $2,2 mul $1,$2 mul $1,2 trn $1,$2
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/login/ui/arrow_button_view.h" #include <utility> #include "ash/resources/vector_icons/vector_icons.h" #include "ash/style/ash_color_provider.h" #include "base/time/time.h" #include "cc/paint/paint_flags.h" #include "ui/accessibility/ax_node_data.h" #include "ui/gfx/animation/multi_animation.h" #include "ui/gfx/animation/tween.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/skia_util.h" #include "ui/views/controls/highlight_path_generator.h" #include "ui/views/metadata/metadata_impl_macros.h" namespace ash { namespace { // Arrow icon size. constexpr int kArrowIconSizeDp = 20; constexpr int kArrowIconBackroundRadius = 25; constexpr const int kBorderForFocusRingDp = 3; // How long does a single step of the loading animation take - i.e., the time it // takes for the arc to grow from a point to a full circle. constexpr base::TimeDelta kLoadingAnimationStepDuration = base::TimeDelta::FromSeconds(2); void PaintLoadingArc(gfx::Canvas* canvas, const gfx::Rect& bounds, double loading_fraction) { gfx::Rect oval = bounds; // Inset to make sure the whole arc is inside the visible rect. oval.Inset(/*horizontal=*/1, /*vertical=*/1); SkPath path; path.arcTo(RectToSkRect(oval), /*startAngle=*/-90, /*sweepAngle=*/360 * loading_fraction, /*forceMoveTo=*/true); cc::PaintFlags flags; // Use the same color as the arrow icon. flags.setColor(AshColorProvider::Get()->GetContentLayerColor( AshColorProvider::ContentLayerType::kButtonIconColor)); flags.setStyle(cc::PaintFlags::kStroke_Style); flags.setAntiAlias(true); canvas->DrawPath(path, flags); } } // namespace ArrowButtonView::ArrowButtonView(PressedCallback callback, int size) : LoginButton(std::move(callback)) { SetBorder(views::CreateEmptyBorder(gfx::Insets(kBorderForFocusRingDp))); SetPreferredSize(gfx::Size(size + 2 * kBorderForFocusRingDp, size + 2 * kBorderForFocusRingDp)); SetFocusBehavior(FocusBehavior::ALWAYS); // Layer rendering is needed for animation. SetPaintToLayer(); layer()->SetFillsBoundsOpaquely(false); focus_ring()->SetPathGenerator( std::make_unique<views::FixedSizeCircleHighlightPathGenerator>( kArrowIconBackroundRadius)); } ArrowButtonView::~ArrowButtonView() = default; void ArrowButtonView::PaintButtonContents(gfx::Canvas* canvas) { const gfx::Rect rect(GetContentsBounds()); // Draw background. cc::PaintFlags flags; flags.setAntiAlias(true); flags.setColor(AshColorProvider::Get()->GetControlsLayerColor( AshColorProvider::ControlsLayerType::kControlBackgroundColorInactive)); flags.setStyle(cc::PaintFlags::kFill_Style); canvas->DrawCircle(gfx::PointF(rect.CenterPoint()), rect.width() / 2, flags); // Draw arrow icon. views::ImageButton::PaintButtonContents(canvas); // Draw the arc of the loading animation. if (loading_animation_) PaintLoadingArc(canvas, rect, loading_animation_->GetCurrentValue()); } void ArrowButtonView::GetAccessibleNodeData(ui::AXNodeData* node_data) { LoginButton::GetAccessibleNodeData(node_data); // TODO(tbarzic): Fix this - https://crbug.com/961930. if (GetAccessibleName().empty()) node_data->SetNameExplicitlyEmpty(); } void ArrowButtonView::EnableLoadingAnimation(bool enabled) { if (!enabled) { if (!loading_animation_) return; loading_animation_.reset(); SchedulePaint(); return; } if (loading_animation_) return; // Use MultiAnimation in order to have a continuously running analog of // LinearAnimation. loading_animation_ = std::make_unique<gfx::MultiAnimation>(gfx::MultiAnimation::Parts{ gfx::MultiAnimation::Part(kLoadingAnimationStepDuration, gfx::Tween::LINEAR), }); loading_animation_->set_delegate(&loading_animation_delegate_); loading_animation_->Start(); } void ArrowButtonView::OnThemeChanged() { views::View::OnThemeChanged(); AshColorProvider::Get()->DecorateIconButton( this, kLockScreenArrowIcon, /*toggled_=*/false, kArrowIconSizeDp); } ArrowButtonView::LoadingAnimationDelegate::LoadingAnimationDelegate( ArrowButtonView* owner) : owner_(owner) {} ArrowButtonView::LoadingAnimationDelegate::~LoadingAnimationDelegate() = default; void ArrowButtonView::LoadingAnimationDelegate::AnimationProgressed( const gfx::Animation* /*animation*/) { owner_->SchedulePaint(); } BEGIN_METADATA(ArrowButtonView, LoginButton) END_METADATA } // namespace ash
; A101604: a(n) = 2*a(n-1) + 5*a(n-2) + 2*a(n-3). ; 1,2,9,30,109,386,1377,4902,17461,62186,221481,788814,2809405,10005842,35636337,126920694,452034757,1609945658,5733906489,20421610782,72732645325,259041157538,922588763265,3285848604870,11702723341141 mov $3,2 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 add $0,$3 cal $0,52986 ; Expansion of ( 1-2*x ) / ( (x-1)*(2*x^2+3*x-1) ). div $0,2 mov $2,$3 mov $4,$0 lpb $2 mov $1,$4 sub $2,1 lpe lpe lpb $5 sub $1,$4 mov $5,0 lpe
; void *z80_otdr(void *src, uint16_t port) SECTION code_z80 PUBLIC z80_otdr_callee EXTERN asm_z80_otdr z80_otdr_callee: pop hl pop bc ex (sp),hl jp asm_z80_otdr
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 80 .text@150 lbegin: ld a, ff ldff(45), a ld b, 03 call lwaitly_b ld a, 40 ldff(41), a ld a, 02 ldff(ff), a ei ld a, b inc a inc a ldff(45), a ld c, 0f .text@1000 lstatint: nop nop nop nop ldff(45), a ldff a, (c) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/pybind/imperative.h" #include <Python.h> #include <pybind11/chrono.h> #include <pybind11/complex.h> #include <pybind11/functional.h> #include <pybind11/stl.h> #include <algorithm> #include <memory> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #include "paddle/fluid/framework/scope_guard.h" #include "paddle/fluid/imperative/all_reduce.h" #include "paddle/fluid/imperative/amp_auto_cast.h" #include "paddle/fluid/imperative/basic_engine.h" #include "paddle/fluid/imperative/bkcl_context.h" #include "paddle/fluid/imperative/data_loader.h" #include "paddle/fluid/imperative/gloo_context.h" #include "paddle/fluid/imperative/hccl_context.h" #include "paddle/fluid/imperative/heter_ccl_context.h" #include "paddle/fluid/imperative/hooks.h" #include "paddle/fluid/imperative/layer.h" #include "paddle/fluid/imperative/nccl_context.h" #include "paddle/fluid/imperative/partial_grad_engine.h" #include "paddle/fluid/imperative/profiler.h" #include "paddle/fluid/imperative/py_layer_fwd.h" #include "paddle/fluid/imperative/reducer.h" #include "paddle/fluid/imperative/tracer.h" #include "paddle/fluid/imperative/type_defs.h" #include "paddle/fluid/memory/allocation/mmap_allocator.h" #include "paddle/fluid/operators/utils.h" #include "paddle/fluid/pybind/op_function.h" #include "paddle/fluid/pybind/pybind_boost_headers.h" #include "paddle/fluid/pybind/tensor_py.h" namespace paddle { namespace pybind { PyTypeObject *g_varbase_pytype = nullptr; namespace py = ::pybind11; template <typename T> static T PyObjectCast(PyObject *obj) { try { return py::cast<T>(py::handle(obj)); } catch (py::cast_error &) { PADDLE_THROW(platform::errors::InvalidArgument( "Python object is not type of %s", typeid(T).name())); } } class PyVariableWrapperHook : public imperative::VariableWrapperHook { public: explicit PyVariableWrapperHook(PyObject *func) : py_func_(func) { Py_INCREF(py_func_); } ~PyVariableWrapperHook() { py::gil_scoped_acquire gil; Py_DECREF(py_func_); } std::shared_ptr<imperative::VariableWrapper> operator()( const std::shared_ptr<imperative::VariableWrapper> &var) override { py::gil_scoped_acquire gil; VLOG(3) << "Call PyVariableWrapperHook for var " << var->Name(); // 1. unpack temp VarBase from VariableWrapper std::shared_ptr<imperative::VarBase> tmp_varbase = std::make_shared<imperative::VarBase>(var); // 2. call hook and return PyObject *res = nullptr; try { res = PyObject_CallFunctionObjArgs(py_func_, py::cast(tmp_varbase).ptr(), nullptr); } catch (platform::EnforceNotMet &e) { throw std::move(e); } catch (std::exception &e) { PADDLE_THROW(platform::errors::Unavailable( "Hook function of Tensor raises an exception: %s.", e.what())); } catch (...) { PADDLE_THROW(platform::errors::Fatal( "Hook function of Tensor raises an unknown exception.")); } PADDLE_ENFORCE_NOT_NULL(res, platform::errors::Unavailable( "Hook function of Tensor return a nullptr.")); if (res == Py_None) { return var; } return PyObjectCast<std::shared_ptr<imperative::VarBase>>(res)->SharedVar(); } private: PyObject *py_func_; }; static const platform::Place PyObjectToPlace(const py::object &place_obj) { if (py::isinstance<platform::CPUPlace>(place_obj)) { return place_obj.cast<platform::CPUPlace>(); } else if (py::isinstance<platform::CUDAPlace>(place_obj)) { return place_obj.cast<platform::CUDAPlace>(); } else if (py::isinstance<platform::XPUPlace>(place_obj)) { return place_obj.cast<platform::XPUPlace>(); } else if (py::isinstance<platform::CUDAPinnedPlace>(place_obj)) { return place_obj.cast<platform::CUDAPinnedPlace>(); } else if (py::isinstance<platform::NPUPlace>(place_obj)) { return place_obj.cast<platform::NPUPlace>(); } else if (py::isinstance<platform::Place>(place_obj)) { return place_obj.cast<platform::Place>(); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Place should be one of " "Place/CPUPlace/XPUPlace/CUDAPlace/CUDAPinnedPlace/NPUPlace")); } } // only initialize varbase, but not its tensor. static void InitVarBaseOnly(imperative::VarBase *self, const std::string &name, bool persistable = false, int stop_gradient = -1) { auto name_ = name == "" ? imperative::GetCurrentTracer()->GenerateUniqueName( "generated_tensor") : name; VLOG(5) << "Init Tensor as: / name: " << name_ << " / persistable: " << persistable << " / stop_gradient: " << stop_gradient; new (self) imperative::VarBase(name_); if (stop_gradient != -1) { self->SetOverridedStopGradient(stop_gradient); } self->SetPersistable(persistable); self->SetType(framework::proto::VarType::LOD_TENSOR); } // initialize varbase and its tensor. static void InitVarBaseAndTensor( imperative::VarBase *self, const py::array &array, const platform::Place &place, const std::string &name, bool persistable = false, bool zero_copy = false, int stop_gradient = -1) { InitVarBaseOnly(self, name, persistable, stop_gradient); auto *tensor = self->MutableVar()->GetMutable<framework::LoDTensor>(); VLOG(4) << "zero_copy: " << zero_copy; if (platform::is_cpu_place(place)) { SetTensorFromPyArray<platform::CPUPlace>( tensor, array, BOOST_GET_CONST(platform::CPUPlace, place), zero_copy); } else if (platform::is_xpu_place(place)) { SetTensorFromPyArray<platform::XPUPlace>( tensor, array, BOOST_GET_CONST(platform::XPUPlace, place), zero_copy); } else if (platform::is_gpu_place(place)) { SetTensorFromPyArray<platform::CUDAPlace>( tensor, array, BOOST_GET_CONST(platform::CUDAPlace, place), zero_copy); } else if (platform::is_cuda_pinned_place(place)) { SetTensorFromPyArray<platform::CUDAPinnedPlace>( tensor, array, BOOST_GET_CONST(platform::CUDAPinnedPlace, place), zero_copy); } else if (platform::is_npu_place(place)) { SetTensorFromPyArray<platform::NPUPlace>( tensor, array, BOOST_GET_CONST(platform::NPUPlace, place), zero_copy); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Place should be one of " "CPUPlace/XPUPlace/CUDAPlace/CUDAPinnedPlace/NPUPlace")); } self->SetDataType(tensor->type()); } static void InitVarBaseFromNumpyWithKwargs(imperative::VarBase *self, const py::kwargs &kwargs) { VLOG(4) << "Init VarBase from kwargs: "; auto persistable = kwargs.contains("persistable") ? kwargs["persistable"].cast<bool>() : false; auto zero_copy = kwargs.contains("zero_copy") ? kwargs["zero_copy"].cast<bool>() : false; auto name = kwargs.contains("name") ? kwargs["name"].cast<std::string>() : ""; auto stop_gradient = kwargs.contains("stop_gradient") ? kwargs["stop_gradient"].cast<int>() : -1; auto default_place = imperative::GetCurrentTracer()->ExpectedPlace(); if (kwargs.contains("value")) { auto array = kwargs["value"].cast<py::array>(); // place is only used when array is given, otherwise, it is meaningless and // ignored auto place = kwargs.contains("place") ? PyObjectToPlace(kwargs["place"]) : default_place; InitVarBaseAndTensor(self, array, place, name, persistable, zero_copy, stop_gradient); } else { InitVarBaseOnly(self, name, persistable, stop_gradient); } } template <typename P> static void InitVarBaseFromNumpyWithArg(imperative::VarBase *self, const py::array &array, const P &place, bool persistable = false, bool zero_copy = false, std::string name = "", int stop_gradient = -1) { VLOG(4) << "Init VarBase from Arg: "; // 0: self, 1: value, 2: place, 3: persistable, 4: zero_copy, 5: name , 6: // stop_gradient if (name == "") { name = imperative::GetCurrentTracer()->GenerateUniqueName("generated_tensor"); } VLOG(5) << "Init Tensor as: / name: " << name << " / persistable: " << persistable << " / zero_copy: " << zero_copy << " / stop_gradient: " << stop_gradient << " / at " << place; new (self) imperative::VarBase(name); self->SetPersistable(persistable); auto *tensor = self->MutableVar()->GetMutable<framework::LoDTensor>(); if (stop_gradient != -1) { self->SetOverridedStopGradient(stop_gradient); } SetTensorFromPyArray<P>(tensor, array, place, zero_copy); self->SetType(framework::proto::VarType::LOD_TENSOR); self->SetDataType(tensor->type()); } static void InitVarBaseFromNumpyWithArgDefault(imperative::VarBase *self, const py::array &array) { auto place = imperative::GetCurrentTracer()->ExpectedPlace(); VLOG(4) << "Init VarBase from numpy at " << place; InitVarBaseAndTensor(self, array, place, ""); } static void InitVarBaseFromTensorWithArgDefault(imperative::VarBase *self, const framework::Tensor &tensor, const std::string &name) { VLOG(4) << "Init VarBase"; auto place = imperative::GetCurrentTracer()->ExpectedPlace(); auto name_ = name == "" ? imperative::GetCurrentTracer()->GenerateUniqueName( "generated_tensor") : name; new (self) imperative::VarBase(name_); self->SetPersistable(false); self->SetType(framework::proto::VarType::LOD_TENSOR); self->SetDataType(tensor.type()); auto *new_tensor = self->MutableVar()->GetMutable<framework::LoDTensor>(); // Same place,share data directly if (place == tensor.place()) { new_tensor->ShareDataWith(tensor); VLOG(4) << "Same place, do ShareDataWith"; } else { framework::TensorCopy(tensor, place, new_tensor); VLOG(4) << "Different place, do TensorCopy"; } } template <typename P> static void InitVarBaseFromTensorWithArg(imperative::VarBase *self, const framework::Tensor &tensor, const P &place, const std::string &name) { VLOG(4) << "Init VarBase"; auto name_ = name == "" ? imperative::GetCurrentTracer()->GenerateUniqueName( "generated_tensor") : name; new (self) imperative::VarBase(name_); self->SetPersistable(false); self->SetType(framework::proto::VarType::LOD_TENSOR); self->SetDataType(tensor.type()); auto *new_tensor = self->MutableVar()->GetMutable<framework::LoDTensor>(); // Same place,share data directly if (platform::is_same_place(place, tensor.place())) { new_tensor->ShareDataWith(tensor); VLOG(4) << "Same place, do ShareDataWith"; } else { framework::TensorCopy(tensor, place, new_tensor); VLOG(4) << "Different place, do TensorCopy"; } } static std::string GetTypeName(const imperative::VarBase &var) { if (var.Type() == framework::proto::VarType::RAW) { return "RAW"; } else if (!var.Var().IsInitialized()) { return "nullptr"; } else { return framework::ToTypeName(var.Var().Type()); } } using PyNameVarBaseMap = std::unordered_map<std::string, py::handle>; // NOTE(zjl): py::handle is a very light wrapper of PyObject *. // Unlike py::object, py::handle does not change reference count of PyObject *. static std::vector<std::shared_ptr<imperative::VarBase>> GetVarBaseListFromPyHandle(const py::handle &handle) { PyObject *py_obj = handle.ptr(); // get underlying PyObject // Python None is not nullptr in C++! if (!py_obj || py_obj == Py_None) { return {}; } std::vector<std::shared_ptr<imperative::VarBase>> result; if (PyList_Check(py_obj)) { // List of VarBase size_t len = PyList_GET_SIZE(py_obj); result.reserve(len); for (size_t i = 0; i < len; ++i) { PyObject *py_ivar = PyList_GET_ITEM(py_obj, i); PADDLE_ENFORCE_NOT_NULL( py_ivar, platform::errors::InvalidArgument("Python Object is NULL")); result.emplace_back( PyObjectCast<std::shared_ptr<imperative::VarBase>>(py_ivar)); } } else if (PyTuple_Check(py_obj)) { // Tuple of VarBase size_t len = PyTuple_GET_SIZE(py_obj); result.reserve(len); for (size_t i = 0; i < len; ++i) { PyObject *py_ivar = PyTuple_GET_ITEM(py_obj, i); PADDLE_ENFORCE_NOT_NULL( py_ivar, platform::errors::InvalidArgument("Python Object is NULL")); result.emplace_back( PyObjectCast<std::shared_ptr<imperative::VarBase>>(py_ivar)); } } else { // VarBase result.emplace_back( PyObjectCast<std::shared_ptr<imperative::VarBase>>(py_obj)); } return result; } static bool IsNumpyType(PyObject *obj) { // It is not a good way to judge the type of obj by its type'name. Maybe using // `PyArray_IsScalar` will be better. However, this interface cannot be used // by including pybind11, and it needs to compile with numpy. auto type_name = std::string(Py_TYPE(obj)->tp_name); return type_name == "numpy.int64" || type_name == "numpy.longlong" || type_name == "numpy.int32" || type_name == "numpy.int16"; } static bool PyCheckTensor(PyObject *obj) { return py::isinstance<imperative::VarBase>(obj); } // cast numpy type form S to T, this may allocate new memory template <class T, class S> static py::array_t<T> CastNumpyType(py::array_t<S> array) { if (std::is_same<T, S>::value) { return array; } auto dim = array.ndim(); std::vector<py::ssize_t> result_shape(dim); for (auto i = 0; i < dim; i++) { result_shape[i] = array.shape(i); } py::array_t<T> result(result_shape); return py::vectorize([](S s) { return static_cast<T>(s); })(array); } template <class T> static py::array_t<T> CastNumpyArray(const py::object &array) { if (py::isinstance<py::array_t<float>>(array)) { return CastNumpyType<T>(array.cast<py::array_t<float>>()); } else if (py::isinstance<py::array_t<double>>(array)) { return CastNumpyType<T>(array.cast<py::array_t<double>>()); } else if (py::isinstance<py::array_t<int32_t>>(array)) { return CastNumpyType<T>(array.cast<py::array_t<int32_t>>()); } else if (py::isinstance<py::array_t<int64_t>>(array)) { return CastNumpyType<T>(array.cast<py::array_t<int64_t>>()); } else if (py::isinstance<py::array_t<bool>>(array)) { return CastNumpyType<T>(array.cast<py::array_t<bool>>()); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Value type error. The assign numpy value allows integer, float, " "double and bool, " "but received %s.", Py_TYPE(array.ptr())->tp_name)); } // can't reach here return py::array_t<T>(); } static imperative::NameVarBaseMap ConvertToNameVarBaseMap( const PyNameVarBaseMap &map) { imperative::NameVarBaseMap result; for (auto &pair : map) { auto var_vec = GetVarBaseListFromPyHandle(pair.second); if (!var_vec.empty()) { result.emplace(pair.first, std::move(var_vec)); } } PADDLE_ENFORCE_EQ( PyErr_Occurred(), nullptr, platform::errors::InvalidArgument(py::str(py::handle(PyErr_Occurred())))); return result; } static bool PyCheckInteger(PyObject *obj) { #if PY_VERSION_HEX < 0x03000000 return (PyLong_Check(obj) || PyInt_Check(obj)) && !PyBool_Check(obj); #else return PyLong_Check(obj) && !PyBool_Check(obj); #endif } static Py_ssize_t GetSliceIndexFromTensor( const std::shared_ptr<imperative::VarBase> &tensor_index) { const auto &tensor = tensor_index->Var().Get<framework::LoDTensor>(); if (tensor.numel() == 1) { if (tensor.type() == framework::proto::VarType::INT32) { return static_cast<Py_ssize_t>(operators::GetValue<int32_t>(&tensor)); } else if (tensor.type() == framework::proto::VarType::INT64) { return static_cast<Py_ssize_t>(operators::GetValue<int64_t>(&tensor)); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Currently, the type of tensor in slice indices only allows " "int32 and int64, please check the type of index tensor.")); } } else { PADDLE_THROW(platform::errors::InvalidArgument( "Currently, tensor in slice indices only allows 1 element, " "but received %d.", tensor.numel())); } } // NOTE(zhiqiu): Revised version of PySlice_GetIndices. From: // https://github.com/python/cpython/blob/8d21aa21f2cbc6d50aab3f420bb23be1d081dac4/Objects/sliceobject.c#L103 // Original PySlice_GetIndices return wrong result when // slice_item contains long int, such as arr[:180L]. // NOT sure why this happens !!! // Besides, PySlice_GetIndices cannot raise error when float in slice item. // So, I make a revised version of PySlice_GetIndices, named to // _PySlice_GetIndices. Try to use _PySlice_Unpack which is more robust than // PySlice_GetIndices in the future. static int _PySlice_GetIndices(PySliceObject *r, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) { /* XXX support long ints */ if (r->step == Py_None) { *step = 1; } else { if (PyCheckInteger(r->step) || IsNumpyType(r->step)) { *step = PyLong_AsLong(r->step); } else if (PyCheckTensor(r->step)) { *step = GetSliceIndexFromTensor( py::cast<std::shared_ptr<imperative::VarBase>>(r->step)); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Currently, slice indices only allows None, integers, " "tensor(int) and numpy(int) in slice item, but received %s.", std::string(Py_TYPE(r->step)->tp_name))); } } if (r->start == Py_None) { *start = *step < 0 ? length - 1 : 0; } else { if (PyCheckInteger(r->start) || IsNumpyType(r->start)) { *start = PyLong_AsLong(r->start); } else if (PyCheckTensor(r->start)) { *start = GetSliceIndexFromTensor( py::cast<std::shared_ptr<imperative::VarBase>>(r->start)); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Currently, slice indices only allows None, integers, " "tensor(int) and numpy(int) in slice item, but received %s.", std::string(Py_TYPE(r->start)->tp_name))); } if (*start < 0) *start += length; *start = std::max(*start, static_cast<Py_ssize_t>(0)); } if (r->stop == Py_None) { *stop = *step < 0 ? -1 : length; } else { if (PyCheckInteger(r->stop) || IsNumpyType(r->stop)) { *stop = PyLong_AsLong(r->stop); } else if (PyCheckTensor(r->stop)) { *stop = GetSliceIndexFromTensor( py::cast<std::shared_ptr<imperative::VarBase>>(r->stop)); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Currently, slice indices only allows None, integers, " "tensor(int) and numpy(int) in slice item, but received %s.", std::string(Py_TYPE(r->stop)->tp_name))); } if (0 < *step && *stop < 0) *stop += length; *stop = std::min(*stop, length); } if (*stop > length) return -1; if (*start >= length) return -1; if (*step == 0) return -1; return 0; } static void ParseIndexingSlice( framework::LoDTensor *tensor, PyObject *_index, std::vector<int> *slice_axes, std::vector<int> *slice_starts, std::vector<int> *slice_ends, std::vector<int> *slice_strides, std::vector<int> *decrease_axis, std::vector<int> *none_axes, std::vector<int> *infer_flags, std::vector<int> *list_select_idxs, bool *list_select_flag) { // We allow indexing by Integers, Slices, Ellipsis, None, tuples of those // types, and list of Bool and Integers. // wrap to tuple // NOTE(zhiqiu): PyTuple_Pack increases refcount. PyObject *index = !PyTuple_Check(_index) ? PyTuple_Pack(1, _index) : _index; DEFINE_PADDLE_SCOPE_GUARD([index, _index]() { if (!PyTuple_Check(_index)) { Py_DECREF(index); VLOG(4) << "Call Py_DECREF"; } }); PADDLE_ENFORCE_EQ( tensor->IsInitialized(), true, platform::errors::InvalidArgument("tensor has not been initialized")); const auto &shape = tensor->dims(); const int rank = shape.size(); const int size = PyTuple_GET_SIZE(index); // specified_dims is the number of dimensions which indexed by Interger, // Slices. int specified_dims = 0; int ell_count = 0; for (int dim = 0; dim < size; ++dim) { PyObject *slice_item = PyTuple_GetItem(index, dim); if (PyCheckInteger(slice_item) || PySlice_Check(slice_item)) { specified_dims++; } else if (slice_item == Py_Ellipsis) { ell_count++; } } PADDLE_ENFORCE_LE(ell_count, 1, platform::errors::InvalidArgument( "An index can only have a single ellipsis ('...')")); int none_count = 0; for (int i = 0, dim = 0; i < size; ++i) { PyObject *slice_item = PyTuple_GetItem(index, i); infer_flags->push_back(1); int dim_len = shape[dim]; if (PyCheckInteger(slice_item) || IsNumpyType(slice_item)) { // integer, PyLong_AsLong supports both int and long int start = static_cast<int>(PyLong_AsLong(slice_item)); auto s_t = start; start = start < 0 ? start + dim_len : start; if (start >= dim_len || start < 0) { std::string str_error_message = "The starting index " + std::to_string(s_t) + " of slice is out of bounds in tensor " + std::to_string(dim) + "-th axis, it shound be in the range of [" + std::to_string(-dim_len) + ", " + std::to_string(dim_len) + ")"; // py::index_error is corresponding to IndexError in Python // Used to indicate out of bounds access in __getitem__, __setitem__ throw py::index_error(str_error_message); } slice_axes->push_back(dim); slice_starts->push_back(start); slice_ends->push_back(start + 1); slice_strides->push_back(1); decrease_axis->push_back(dim); dim++; } else if (PySlice_Check(slice_item)) { // slice item Py_ssize_t start, end, step; PySliceObject *p = reinterpret_cast<PySliceObject *>(slice_item); _PySlice_GetIndices(p, dim_len, &start, &end, &step); // :: or : or 0:dim_len:1 if (start == 0 && end == dim_len && step == 1) { dim++; continue; } slice_axes->push_back(dim); slice_starts->push_back(start); slice_ends->push_back(end); slice_strides->push_back(step); dim++; } else if (slice_item == Py_Ellipsis) { dim += rank - specified_dims; } else if (slice_item == Py_None) { none_axes->push_back(dim + none_count); none_count++; } else if (PyList_Check(slice_item)) { *list_select_flag = true; PADDLE_ENFORCE_EQ( size, 1, platform::errors::InvalidArgument( "When index contains a list, its length is excepted to 1, " "but received %d", size)); bool all_bool = true; int list_size = PyList_GET_SIZE(slice_item); for (int j = 0; j < list_size; ++j) { PyObject *list_item = PyList_GetItem(slice_item, j); if (PyCheckInteger(list_item)) { all_bool = false; } else if (!PyBool_Check(list_item)) { PADDLE_THROW(platform::errors::InvalidArgument( "Only support int or bool in index list.")); } } if (all_bool) { PADDLE_ENFORCE_EQ( list_size, shape[0], platform::errors::InvalidArgument( "The dimension of bool index doesn't match indexed array along " "dimension 0, the target dimension is %d, but received %d.", shape[0], list_size)); for (int j = 0; j < list_size; ++j) { PyObject *list_item = PyList_GetItem(slice_item, j); if (list_item == Py_True) { list_select_idxs->push_back(j); } } } else { for (int j = 0; j < list_size; ++j) { PyObject *list_item = PyList_GetItem(slice_item, j); if (PyCheckInteger(list_item)) { list_select_idxs->push_back( static_cast<int>(PyLong_AsLong(list_item))); } else if (list_item == Py_True) { list_select_idxs->push_back(1); } else { list_select_idxs->push_back(0); } } } } else { PADDLE_THROW(platform::errors::InvalidArgument( "Currently, Tensor.__indices__() only allows indexing " "by Integers, Slices, Ellipsis, None, tuples of these types " "and list of Bool and Integers, but received " "%s in %dth slice item", std::string(Py_TYPE(slice_item)->tp_name), i + 1)); } } // valid_index is the number of dimensions exclude None index const int valid_indexs = size - none_axes->size() - ell_count; PADDLE_ENFORCE_EQ(valid_indexs <= rank, true, platform::errors::InvalidArgument( "Too many indices (%d) for tensor of dimension %d.", valid_indexs, rank)); } template <typename P> static void VarBaseCopy(std::shared_ptr<imperative::VarBase> &src, // NOLINT imperative::VarBase &dst, // NOLINT const P &dst_device, const bool blocking) { if (dst.SharedVar()->IsEmpty()) { VLOG(3) << "deep copy Variable from " << src->Name() << " to " << dst.Name(); dst.SetPersistable(src->Persistable()); dst.SetDataType(src->DataType()); dst.SetType(src->Type()); dst.SetOverridedStopGradient(src->OverridedStopGradient()); if (!src->SharedVar()->IsEmpty()) { if (src->Var().IsType<framework::LoDTensor>()) { auto &src_tensor = src->Var().Get<framework::LoDTensor>(); auto *dst_tensor = dst.MutableVar()->GetMutable<framework::LoDTensor>(); dst_tensor->set_lod(src_tensor.lod()); framework::TensorCopy(src_tensor, dst_device, dst_tensor); if (blocking) { platform::DeviceContextPool::Instance().Get(dst_device)->Wait(); auto src_device = src_tensor.place(); if (!(src_device == dst_device)) { platform::DeviceContextPool::Instance().Get(src_device)->Wait(); } } } else if (src->Var().IsType<framework::SelectedRows>()) { auto &src_selected_rows = src->Var().Get<framework::SelectedRows>(); auto *dst_selected_rows = dst.MutableVar()->GetMutable<framework::SelectedRows>(); dst_selected_rows->set_height(src_selected_rows.height()); dst_selected_rows->set_rows(src_selected_rows.rows()); framework::TensorCopy(src_selected_rows.value(), dst_device, dst_selected_rows->mutable_value()); if (blocking) { platform::DeviceContextPool::Instance().Get(dst_device)->Wait(); auto src_device = src_selected_rows.value().place(); if (!(src_device == dst_device)) { platform::DeviceContextPool::Instance().Get(src_device)->Wait(); } } } if (!blocking) { IncreaseVarbaseReferenceCountUntilCopyComplete(src, dst_device); } } else { PADDLE_THROW(platform::errors::InvalidArgument( "The source Tensor(%s) can not copy when it is empty.", src->Name())); } } else { PADDLE_THROW(platform::errors::InvalidArgument( "The destion Tensor(%s) can not copy when it is not empty.", dst.Name())); } } // Bind Methods void BindImperative(py::module *m_ptr) { auto &m = *m_ptr; BindOpFunctions(&m); #ifndef _WIN32 // Dygraph DataLoader signal handler m.def("_set_process_pids", [](int64_t key, py::object &obj) { PADDLE_ENFORCE_EQ( py::isinstance<py::tuple>(obj) || py::isinstance<py::list>(obj), true, platform::errors::InvalidArgument( "The subprocess ids set in DataLoader is illegal." "Expected data type is tuple or list, but received %s", obj.get_type())); py::list pids = py::cast<py::list>(obj); std::set<pid_t> pids_set = {}; for (size_t i = 0; i < pids.size(); i++) { pids_set.insert(pids[i].cast<pid_t>()); } imperative::SetLoadProcessPIDs(key, pids_set); }); m.def("_erase_process_pids", [](int64_t key) { imperative::EraseLoadProcessPIDs(key); }); m.def("_set_process_signal_handler", []() { imperative::SetLoadProcessSignalHandler(); }); m.def("_throw_error_if_process_failed", []() { imperative::ThrowErrorIfLoadProcessFailed(); }); // Dygraph DataLoader reader process & thread related functions m.def( "_convert_to_tensor_list", [](py::object &obj) -> py::list { // 0. input data check PADDLE_ENFORCE( py::isinstance<py::tuple>(obj) || py::isinstance<py::list>(obj), platform::errors::InvalidArgument( "The batch data read into DataLoader is illegal." "Expected data type is tuple or list, but received %s", obj.get_type())); py::list batch = py::cast<py::list>(obj); py::list tensors; for (size_t i = 0; i < batch.size(); ++i) { // 1. cast to python array auto array = batch[i].cast<py::array>(); PADDLE_ENFORCE_NE( string::Sprintf("%s", array.dtype()).compare("object"), 0, platform::errors::InvalidArgument( "Faild to convert input data to a regular ndarray.\n * " "Usually this means the input data contains nested " "lists with different lengths.\n * Check the reader " "function passed to 'set_(sample/sample_list/batch)" "_generator' to locate the data causes this issue.")); // 2. construcct LoDTensor framework::LoDTensor t; SetTensorFromPyArray<platform::CPUPlace>(&t, array, platform::CPUPlace(), true); // 3. allocate shared memory void *data_ptr = t.data<void>(); size_t data_size = t.numel() * framework::SizeOfType(t.type()); auto shared_writer_holder = memory::allocation::AllocateMemoryMapWriterAllocation(data_size); // 4. maintain mmap fd set & backup ipc_name const std::string &ipc_name = shared_writer_holder->ipc_name(); memory::allocation::MemoryMapFdSet::Instance().Insert(ipc_name); // 5. copy data & reset holder memory::Copy(platform::CPUPlace(), shared_writer_holder->ptr(), platform::CPUPlace(), data_ptr, data_size); t.ResetHolder(shared_writer_holder); // 6. append to result list tensors.append(t); } return tensors; }, py::return_value_policy::take_ownership); m.def("_array_to_share_memory_tensor", [](py::object &obj) { // 1. cast to python array auto array = obj.cast<py::array>(); PADDLE_ENFORCE_NE( string::Sprintf("%s", array.dtype()).compare("object"), 0, platform::errors::InvalidArgument( "Faild to convert input data to a regular ndarray.\n * " "Usually this means the input data contains nested " "lists with different lengths.\n * Check the reader " "function passed to 'set_(sample/sample_list/batch)" "_generator' to locate the data causes this issue.")); // 2. construcct LoDTensor framework::LoDTensor t; SetTensorFromPyArray<platform::CPUPlace>(&t, array, platform::CPUPlace(), true); // 3. allocate shared memory void *data_ptr = t.data<void>(); size_t data_size = t.numel() * framework::SizeOfType(t.type()); auto shared_writer_holder = memory::allocation::AllocateMemoryMapWriterAllocation(data_size); // 4. maintain mmap fd set & backup ipc_name const std::string &ipc_name = shared_writer_holder->ipc_name(); memory::allocation::MemoryMapFdSet::Instance().Insert(ipc_name); // 5. copy data & reset holder memory::Copy(platform::CPUPlace(), shared_writer_holder->ptr(), platform::CPUPlace(), data_ptr, data_size); t.ResetHolder(shared_writer_holder); return t; }, py::return_value_policy::take_ownership); m.def("_remove_tensor_list_mmap_fds", [](py::list &tensor_list) { for (size_t i = 0; i < tensor_list.size(); ++i) { auto t = tensor_list[i].cast<framework::LoDTensor>(); auto *mmap_writer_allocation = dynamic_cast<memory::allocation::MemoryMapWriterAllocation *>( t.Holder().get()); PADDLE_ENFORCE_NOT_NULL( mmap_writer_allocation, platform::errors::NotFound("The shared memory of LoDTensor in " "DataLoader's child process has been " "released.")); memory::allocation::MemoryMapFdSet::Instance().Remove( mmap_writer_allocation->ipc_name()); } }); m.def("_cleanup_mmap_fds", []() { memory::allocation::MemoryMapFdSet::Instance().Clear(); }); #endif m.def("start_imperative_gperf_profiler", []() { imperative::StartProfile(); }); m.def("stop_imperative_gperf_profiler", []() { imperative::StopProfile(); }); m.def("_is_dygraph_debug_enabled", []() { return imperative::IsDebugEnabled(); }); m.def("_dygraph_debug_level", []() { return imperative::GetDebugLevel(); }); m.def("_switch_tracer", [](const std::shared_ptr<imperative::Tracer> &tracer) { imperative::SetCurrentTracer(tracer); }); py::class_<imperative::VarBase, std::shared_ptr<imperative::VarBase>> varbase( m, "VarBase", R"DOC()DOC"); g_varbase_pytype = (PyTypeObject *)varbase.ptr(); // NOLINT varbase.def_static("_alive_vars", &imperative::VarBase::AliveVarNames) .def("__init__", [](imperative::VarBase &self) { std::string name = imperative::GetCurrentTracer()->GenerateUniqueName( "generated_tensor"); new (&self) imperative::VarBase(name); }) .def("__init__", [](imperative::VarBase &self, framework::proto::VarType::Type dtype, const std::vector<int> &dims, const py::handle &name, framework::proto::VarType::Type type, bool persistable) { VLOG(4) << "Init VarBase"; std::string act_name = ""; if (!name.ptr() || name.ptr() == Py_None) { act_name = imperative::GetCurrentTracer()->GenerateUniqueName( "generated_tensor"); } else { act_name = name.cast<std::string>(); } new (&self) imperative::VarBase(act_name); self.SetPersistable(persistable); self.SetType(type); self.SetDataType(dtype); if (type == framework::proto::VarType::LOD_TENSOR) { auto *tensor = self.MutableVar()->GetMutable<framework::LoDTensor>(); tensor->Resize(framework::make_ddim(dims)); } }) .def("__init__", &InitVarBaseFromNumpyWithArg<platform::CPUPlace>, py::arg("value"), py::arg("place"), py::arg("persistable") = false, py::arg("zero_copy") = false, py::arg("name") = "", py::arg("stop_gradient") = -1) .def("__init__", &InitVarBaseFromNumpyWithArg<platform::XPUPlace>, py::arg("value"), py::arg("place"), py::arg("persistable") = false, py::arg("zero_copy") = false, py::arg("name") = "", py::arg("stop_gradient") = -1) .def("__init__", &InitVarBaseFromNumpyWithArg<platform::CUDAPlace>, py::arg("value"), py::arg("place"), py::arg("persistable") = false, py::arg("zero_copy") = false, py::arg("name") = "", py::arg("stop_gradient") = -1) .def("__init__", &InitVarBaseFromNumpyWithArg<platform::CUDAPinnedPlace>, py::arg("value"), py::arg("place"), py::arg("persistable") = false, py::arg("zero_copy") = false, py::arg("name") = "", py::arg("stop_gradient") = -1) .def("__init__", &InitVarBaseFromNumpyWithArg<platform::NPUPlace>, py::arg("value"), py::arg("place"), py::arg("persistable") = false, py::arg("zero_copy") = false, py::arg("name") = "", py::arg("stop_gradient") = -1) .def("__init__", &InitVarBaseFromNumpyWithArgDefault, py::arg("value")) .def("__init__", &InitVarBaseFromTensorWithArgDefault, py::arg("tensor"), py::arg("name") = "") .def("__init__", &InitVarBaseFromTensorWithArg<platform::CPUPlace>, py::arg("tensor"), py::arg("place"), py::arg("name") = "") .def("__init__", &InitVarBaseFromTensorWithArg<platform::XPUPlace>, py::arg("tensor"), py::arg("place"), py::arg("name") = "") .def("__init__", &InitVarBaseFromTensorWithArg<platform::CUDAPlace>, py::arg("tensor"), py::arg("place"), py::arg("name") = "") .def("__init__", &InitVarBaseFromTensorWithArg<platform::CUDAPinnedPlace>, py::arg("tensor"), py::arg("place"), py::arg("name") = "") .def("__init__", &InitVarBaseFromTensorWithArg<platform::NPUPlace>, py::arg("tensor"), py::arg("place"), py::arg("name") = "") .def("__init__", &InitVarBaseFromNumpyWithKwargs) .def( "__setitem_varbase__", [](std::shared_ptr<imperative::VarBase> &self, py::handle _index, py::object &value_obj) { VLOG(4) << "Call __setitem_varbase__"; auto self_tensor = self->MutableVar()->GetMutable<framework::LoDTensor>(); // NOTE(zhiqiu): PyTuple_Pack increases refcount while PyTuple_New // https://github.com/python/cpython/blob/24b63c695ae0a95b06379eaadace66735abac1e2/Objects/tupleobject.c#L251 PyObject *index_ptr = !PyTuple_Check(_index.ptr()) ? PyTuple_Pack(1, _index.ptr()) : _index.ptr(); DEFINE_PADDLE_SCOPE_GUARD([index_ptr, &_index]() { if (!PyTuple_Check(_index.ptr())) { Py_DECREF(index_ptr); VLOG(4) << "Call Py_DECREF"; } }); auto is_tensor = [](py::handle var) { if (!var.ptr() || var.ptr() == Py_None) { return false; } try { py::cast<std::shared_ptr<imperative::VarBase>>(var); return true; } catch (py::cast_error &) { return false; } }; // 1. Check argumnets bool parse_index = true; // Check whether _index can be parsed. const int size = PyTuple_GET_SIZE(index_ptr); for (int dim = 0; dim < size; ++dim) { PyObject *slice_item = PyTuple_GetItem(index_ptr, dim); if (!(PyCheckInteger(slice_item) || PySlice_Check(slice_item) || slice_item == Py_Ellipsis || slice_item == Py_None)) { parse_index = false; break; } } // 2. Call op set_value to speed up if the condition is met, // otherwise call TensorToPyArray. // TODO(liym27): Try not to call TensorToPyArray because it always // copys data to cpu place, which reduces performance. if (parse_index) { std::vector<int> axes, starts, ends, steps, decrease_axes, none_axes, infer_flags, list_select_idxs; // if index is a list, list_select_flag will be true bool list_select_flag = false; ParseIndexingSlice(self_tensor, index_ptr, &axes, &starts, &ends, &steps, &decrease_axes, &none_axes, &infer_flags, &list_select_idxs, &list_select_flag); framework::AttributeMap attrs = {{"axes", axes}, {"starts", starts}, {"ends", ends}, {"steps", steps}, {"decrease_axes", decrease_axes}, {"none_axes", none_axes}}; imperative::NameVarBaseMap ins = {{"Input", {self}}}; imperative::NameVarBaseMap outs = {{"Out", {self}}}; const auto &tracer = imperative::GetCurrentTracer(); if (tracer->HasGrad()) { PADDLE_ENFORCE_EQ( self->IsLeaf() && !self->OverridedStopGradient(), false, platform::errors::InvalidArgument( "Leaf Tensor (%s) that doesn't stop gradient can't use " "inplace strategy.", self->Name())); } if (PyCheckTensor(value_obj.ptr())) { auto value_tensor = value_obj.cast<std::shared_ptr<imperative::VarBase>>(); ins.insert({"ValueTensor", {value_tensor}}); // pass the stop_gradient from value to tensor if (!value_tensor->OverridedStopGradient() && self->OverridedStopGradient()) { self->SetOverridedStopGradient(false); } } else if (py::isinstance<py::array>(value_obj)) { auto value_tensor = std::shared_ptr<imperative::VarBase>( new imperative::VarBase(false, tracer->GenerateUniqueName())); py::object value = value_obj; if (self->DataType() == framework::proto::VarType::FP32) { if (!py::isinstance<py::array_t<float>>(value_obj)) { value = CastNumpyArray<float>(value_obj); } } else if (self->DataType() == framework::proto::VarType::FP64) { if (!py::isinstance<py::array_t<double>>(value_obj)) { value = CastNumpyArray<double>(value_obj); } } else if (self->DataType() == framework::proto::VarType::INT32) { if (!py::isinstance<py::array_t<int32_t>>(value_obj)) { value = CastNumpyArray<int32_t>(value_obj); } } else if (self->DataType() == framework::proto::VarType::INT64) { if (!py::isinstance<py::array_t<int64_t>>(value_obj)) { value = CastNumpyArray<int64_t>(value_obj); } } else if (self->DataType() == framework::proto::VarType::BOOL) { if (!py::isinstance<py::array_t<bool>>(value_obj)) { value = CastNumpyArray<bool>(value_obj); } } else { PADDLE_THROW(platform::errors::InvalidArgument( "When assign a numpy.np value to a paddle.Tensor, " "the data type of the paddle.Tensor must be bool, " "float32, int32 or int64, " "please check the type of tensor.")); } SetTensorFromPyArray(value_tensor->MutableVar() ->GetMutable<framework::LoDTensor>(), value, self->Place(), false); ins.insert({"ValueTensor", {value_tensor}}); } else { // convert the value to self data type if (py::isinstance<py::float_>(value_obj) || py::isinstance<py::int_>(value_obj) || py::isinstance<py::bool_>(value_obj)) { if (self->DataType() == framework::proto::VarType::FP32) { attrs["fp32_values"] = std::vector<float>{value_obj.cast<float>()}; } else if (self->DataType() == framework::proto::VarType::FP64) { attrs["fp64_values"] = std::vector<double>{value_obj.cast<double>()}; } else if (self->DataType() == framework::proto::VarType::INT32) { attrs["int32_values"] = std::vector<int32_t>{value_obj.cast<int32_t>()}; } else if (self->DataType() == framework::proto::VarType::INT64) { attrs["int64_values"] = std::vector<int64_t>{value_obj.cast<int64_t>()}; } else if (self->DataType() == framework::proto::VarType::BOOL) { attrs["bool_values"] = std::vector<int>{value_obj.cast<bool>()}; } else { PADDLE_THROW(platform::errors::InvalidArgument( "When assign a value to a paddle.Tensor, " "the data type of the paddle.Tensor must be bool, " "float32, int32 or int64, " "please check the type of tensor.")); } attrs["shape"] = std::vector<int64_t>{1}; } else { PADDLE_THROW(platform::errors::InvalidArgument( "Value type error. The assign value allows " "numpy.ndarray, integer, float or bool, " "but received %s.", Py_TYPE(value_obj.ptr()))); } } { // Release gil and do tracing py::gil_scoped_release release; tracer->TraceOp("set_value", ins, outs, std::move(attrs), {{"Input", "Out"}}); } } else { auto self_numpy = TensorToPyArray(*self_tensor); VLOG(4) << "parse_index is false"; if (is_tensor(_index)) { VLOG(4) << "index is tensor"; auto index_var = py::cast<std::shared_ptr<imperative::VarBase>>(_index); auto index_tensor = index_var->MutableVar()->GetMutable<framework::LoDTensor>(); auto index_numpy = TensorToPyArray(*index_tensor); self_numpy[index_numpy] = value_obj; } else { VLOG(4) << "index is not tensor"; self_numpy[_index] = value_obj; } SetTensorFromPyArray(self_tensor, self_numpy, self_tensor->place(), false); } // NOTE(liym27): // Increase the version of VarBase self because __setitem__ is an // inplace operator for the VarBase self. self->BumpInplaceVersion(); }) .def("_getitem_index_not_tensor", [](std::shared_ptr<imperative::VarBase> &self, py::handle _index) { VLOG(4) << "Call _getitem_index_not_tensor"; std::vector<int> slice_axes, slice_starts, slice_ends, slice_strides, decrease_axis, none_axes, infer_flags, list_select_idxs; // if index is a list, list_select_flag will be true bool list_select_flag = false; auto tensor = self->MutableVar()->GetMutable<framework::LoDTensor>(); ParseIndexingSlice(tensor, _index.ptr(), &slice_axes, &slice_starts, &slice_ends, &slice_strides, &decrease_axis, &none_axes, &infer_flags, &list_select_idxs, &list_select_flag); // release gil and do tracing py::gil_scoped_release release; const auto &tracer = imperative::GetCurrentTracer(); auto out = slice_axes.empty() && !list_select_flag ? self : std::shared_ptr<imperative::VarBase>( new imperative::VarBase( tracer->GenerateUniqueName())); if (!slice_axes.empty()) { imperative::NameVarBaseMap ins = {{"Input", {self}}}; framework::AttributeMap attrs = { {"axes", slice_axes}, {"starts", slice_starts}, {"ends", slice_ends}, {"infer_flags", infer_flags}, {"decrease_axis", decrease_axis}}; imperative::NameVarBaseMap outs = {{"Out", {out}}}; std::string op_type = "slice"; for (auto stride : slice_strides) { if (stride != 1) { op_type = "strided_slice"; attrs.insert({"strides", slice_strides}); attrs.erase("decrease_axis"); break; } } tracer->TraceOp(op_type, ins, outs, std::move(attrs)); } if (!none_axes.empty()) { // Deal with cases when all axes are decreased. // After slice, the shape of out is [1], which should have been // [], but Paddle doesn't support scalar. // In order to ensure the correctness of the final shape of out, // one dimension of out needs to be decreased. // For example: // # x.shape: (2,3,4) // out = x[0, 1, 1, None] # out.shape : (1) if (static_cast<int>(decrease_axis.size()) == tensor->dims().size()) { none_axes.pop_back(); } if (!none_axes.empty()) { // Deal with cases that decrease_axes is not empty // For example: // # x.shape: (2,3,4) // out = x[0, 0:2, None] # out.shape : (2, 1, 4) for (auto &axis : none_axes) { int len = 0; for (int da : decrease_axis) { if (da < axis) { len++; } } axis -= len; } imperative::NameVarBaseMap ins = {{"X", {out}}}; framework::AttributeMap attrs = {{"axes", none_axes}}; auto new_out = std::shared_ptr<imperative::VarBase>( new imperative::VarBase(tracer->GenerateUniqueName())); auto out_xshape = std::shared_ptr<imperative::VarBase>( new imperative::VarBase(tracer->GenerateUniqueName())); imperative::NameVarBaseMap outs = {{"Out", {new_out}}, {"XShape", {out_xshape}}}; tracer->TraceOp("unsqueeze2", ins, outs, std::move(attrs)); return new_out; } } // the index is a list if (list_select_flag) { auto select_index = std::shared_ptr<imperative::VarBase>( new imperative::VarBase(tracer->GenerateUniqueName())); auto *idx_tensor = select_index->MutableVar() ->GetMutable<framework::LoDTensor>(); auto *dev_ctx = platform::DeviceContextPool::Instance().Get( tracer->ExpectedPlace()); TensorFromVector(list_select_idxs, *dev_ctx, idx_tensor); imperative::NameVarBaseMap ins = {{"X", {self}}, {"Index", {select_index}}}; imperative::NameVarBaseMap outs = {{"Out", {out}}}; tracer->TraceOp("index_select", ins, outs, {{"dim", 0}}); } return out; }) .def( "_getitem_from_offset", [](std::shared_ptr<imperative::VarBase> &self, const py::args &args) { const auto &tensor = self->Var().Get<framework::LoDTensor>(); PADDLE_ENFORCE_EQ( tensor.IsInitialized(), true, platform::errors::InvalidArgument( "Tensor of %s is Empty, please check if it has no data.", self->Name())); const auto &tensor_dims = tensor.dims(); std::vector<size_t> dims(tensor_dims.size()); std::vector<size_t> strides(tensor_dims.size()); size_t numel = 1; for (int i = tensor_dims.size() - 1; i >= 0; --i) { strides[i] = numel; dims[i] = static_cast<size_t>(tensor_dims[i]); numel *= dims[i]; } size_t offset = 0; if (args.empty()) { PADDLE_ENFORCE_EQ( numel, 1, platform::errors::InvalidArgument( "only one element tensors can be converted to Python " "scalars when no input coordinates")); } else if (args.size() == 1) { offset = args[0].cast<size_t>(); PADDLE_ENFORCE_LT( offset, numel, platform::errors::InvalidArgument( "index %d is out of bounds for size %d", offset, numel)); } else { PADDLE_ENFORCE_EQ(args.size(), dims.size(), platform::errors::InvalidArgument( "incorrect number of indices for Tensor")); for (size_t i = 0; i < args.size(); ++i) { size_t index = args[i].cast<size_t>(); PADDLE_ENFORCE_LT( index, dims[i], platform::errors::InvalidArgument( "index %d is out fo bounds for axis %d with size %d", index, i, dims[i])); offset += index * strides[i]; } } #define TENSOR_TO_PY_SCALAR(T, proto_type) \ if (tensor.type() == proto_type) { \ std::string py_dtype_str = details::TensorDTypeToPyDTypeStr(proto_type); \ T b = TensorGetElement<T>(tensor, offset); \ return py::array(py::dtype(py_dtype_str.c_str()), {}, {}, \ static_cast<void *>(&b)); \ } _ForEachDataType_(TENSOR_TO_PY_SCALAR); #undef TENSOR_TO_PY_SCALAR PADDLE_THROW(platform::errors::Unimplemented( "Unsupported tensor data type: %s", framework::DataTypeToString(tensor.type()))); }, py::return_value_policy::copy) .def("_inplace_version", [](imperative::VarBase &self) -> uint32_t { const auto &var = self.MutableVar(); PADDLE_ENFORCE_EQ( var->IsInitialized(), true, platform::errors::InvalidArgument( "Tensor of %s is Empty, please check if it has no data.", self.Name())); return var->CurrentInplaceVersion(); }) .def("_bump_inplace_version", [](std::shared_ptr<imperative::VarBase> &self) { // NOTE(liym27): _bump_inplace_version is only used for inplace // operation self->BumpInplaceVersion(); }, R"DOC( **Notes**: **This API is ONLY available in Dygraph mode.** **This is a very low level API. Users should not use it directly. ** Bump the version whenever the Tensor is modified through an inplace operation. )DOC") .def("numpy", [](imperative::VarBase &self) -> py::array { const auto &tensor = self.MutableVar()->Get<framework::LoDTensor>(); PADDLE_ENFORCE_EQ( tensor.IsInitialized(), true, platform::errors::InvalidArgument( "Tensor of %s is Empty, please check if it has no data.", self.Name())); return TensorToPyArray(tensor, true); }, R"DOC( Returns a numpy array shows the value of current Tensor. Returns: ndarray: The numpy value of current Tensor. Returns type: ndarray: dtype is same as current Tensor Examples: .. code-block:: python import paddle import numpy as np data = np.random.uniform(-1, 1, [30, 10, 32]).astype('float32') linear = paddle.nn.Linear(32, 64) data = paddle.to_tensor(data) x = linear(data) print(x.numpy()) )DOC") .def("detach", [](const imperative::VarBase &self) -> std::shared_ptr<imperative::VarBase> { PADDLE_ENFORCE_EQ( self.Var().IsInitialized(), true, platform::errors::InvalidArgument( "Tensor %s has not been initialized!", self.Name())); PADDLE_ENFORCE_EQ( self.Var().IsType<framework::LoDTensor>() || self.Var().IsType<framework::SelectedRows>(), true, platform::errors::InvalidArgument( "Type of Tensor[%s] must be LoDTensor or SelectedRows!", self.Name())); auto detach_var = std::make_shared<imperative::VarBase>( true, "detach_" + self.Name()); detach_var->SetPersistable(self.Persistable()); detach_var->SetType(self.Type()); detach_var->SetDataType(self.DataType()); if (self.Var().IsType<framework::LoDTensor>()) { const auto &origin_tensor = self.Var().Get<framework::LoDTensor>(); PADDLE_ENFORCE_EQ( origin_tensor.IsInitialized(), true, platform::errors::InvalidArgument( "Tensor %s has not been initialized!", self.Name())); auto *detach_tensor = detach_var->MutableVar()->GetMutable<framework::LoDTensor>(); detach_tensor->ShareDataWith(origin_tensor); // NOTE(liym27): Call ShareInplaceVersionCounterWith to share the // same TensorInplaceVersion, which is used to check whether // inplace // operations are correct. detach_tensor->ShareInplaceVersionCounterWith(origin_tensor); } else { const auto &origin_selected_rows = self.Var().Get<framework::SelectedRows>(); PADDLE_ENFORCE_EQ( origin_selected_rows.value().IsInitialized(), true, platform::errors::InvalidArgument( "Tensor %s has not been initialized!", self.Name())); auto *detach_selected_rows = detach_var->MutableVar() ->GetMutable<framework::SelectedRows>(); detach_selected_rows->set_height(origin_selected_rows.height()); detach_selected_rows->set_rows(origin_selected_rows.rows()); detach_selected_rows->mutable_value()->ShareDataWith( origin_selected_rows.value()); detach_selected_rows->mutable_value() ->ShareInplaceVersionCounterWith( origin_selected_rows.value()); } VLOG(3) << "The detached Tensor(" << detach_var->Name() << ") share data with " << self.Name(); return detach_var; }, py::return_value_policy::take_ownership, R"DOC( Returns a new Tensor, detached from the current graph. It will share data with origin Tensor and always doesn't have a Tensor copy. In addition, the detached Tensor doesn't provide gradient propagation. Returns: The detached Tensor. Examples: .. code-block:: python import paddle x = paddle.to_tensor(1.0, stop_gradient=False) detach_x = x.detach() detach_x[:] = 10.0 print(x) # Tensor(shape=[1], dtype=float32, place=CPUPlace, stop_gradient=False, # [10.]) y = x**2 y.backward() print(x.grad) # [20.0] print(detach_x.grad) # None, 'stop_gradient=True' by default detach_x.stop_gradient = False # Set stop_gradient to be False, supported auto-grad z = detach_x**3 z.backward() print(x.grad) # [20.0], detach_x is detached from x's graph, not affect each other print(detach_x.grad) # [300.0], detach_x has its own graph # Due to sharing of data with origin Tensor, There are some unsafe operations: y = 2 * x detach_x[:] = 5.0 y.backward() # It will raise Error: # one of the variables needed for gradient computation has been modified by an inplace operation. )DOC") .def("clear_gradient", &imperative::VarBase::ClearGradient, py::arg("set_to_zero") = true, R"DOC( Only for Tensor that has gradient, normally we use this for Parameters since other temporary Tensor doesen't has gradient. The Gradient of current Tensor will be set to ``0`` . Returns: None Examples: .. code-block:: python import paddle input = paddle.uniform([10, 2]) linear = paddle.nn.Linear(2, 3) out = linear(input) out.backward() print("Before clear_gradient, linear.weight.grad: {}".format(linear.weight.grad)) linear.weight.clear_gradient() print("After clear_gradient, linear.weight.grad: {}".format(linear.weight.grad)) )DOC") .def("_gradient_set_empty", &imperative::VarBase::_GradientSetEmpty, py::arg("set_is_empty") = true) .def("_is_gradient_set_empty", &imperative::VarBase::_IsGradientSetEmpty) .def("clone", [](std::shared_ptr<imperative::VarBase> &self) { const auto &tensor = self->Var().Get<framework::LoDTensor>(); PADDLE_ENFORCE_EQ( tensor.IsInitialized(), true, platform::errors::InvalidArgument( "%s has not been initialized", self->Name())); auto tracer = imperative::GetCurrentTracer(); auto new_var = std::make_shared<imperative::VarBase>( true, tracer->GenerateUniqueName(self->Name() + "_clone")); framework::AttributeMap attrs; imperative::NameVarBaseMap ins = {{"X", {self}}}; imperative::NameVarBaseMap outs = {{"Out", {new_var}}}; tracer->TraceOp("assign", ins, outs, attrs); return new_var; }, py::return_value_policy::copy, R"DOC( Returns a new Tensor, which is clone of origin Tensor, and it remains in the current graph. It will always have a Tensor copy. Tn addition, the cloned Tensor provides gradient propagation. Returns: The cloned Tensor. Examples: .. code-block:: python import paddle x = paddle.to_tensor(1.0, stop_gradient=False) clone_x = x.clone() y = clone_x**2 y.backward() print(clone_x.stop_gradient) # False print(clone_x.grad) # [2.0], support gradient propagation print(x.stop_gradient) # False print(x.grad) # [2.0], clone_x support gradient propagation for x x = paddle.to_tensor(1.0) clone_x = x.clone() clone_x.stop_gradient = False z = clone_x**3 z.backward() print(clone_x.stop_gradient) # False print(clone_x.grad) # [3.0], support gradient propagation print(x.stop_gradient) # True print(x.grad) # None )DOC") .def("_grad_name", &imperative::VarBase::GradVarName) .def("_grad_value", [](imperative::VarBase &self) { return self.MutableGradVar()->Get<framework::LoDTensor>(); }, py::return_value_policy::reference) .def("_set_grad_type", [](imperative::VarBase &self, framework::proto::VarType::Type type) { self.MutableGradVarBase()->SetType(type); }) .def("_reset_grad_inplace_version", [](imperative::VarBase &self, bool set_to_zero) { /* *** This interfaceis a complete hack *** reset_grad_inplace_version removes all inplace related records to Grad VarBase/VariableWrapper, the essential purpose of which is to let you use inplace operations as if using its non-inplaced version, which of course will cause unexpected consequences if not used with care. Make sure you fully understand what you're doing before make use of this interface, and prepare for the worst. */ py::gil_scoped_release release; if (self.HasGradVar()) { auto grad_var = self.GradVarBase(); auto var_wrapper = grad_var->SharedVar(); if (var_wrapper) { var_wrapper->ResetInplaceVersion(set_to_zero); } } }) .def("_grad_ivar", [](const imperative::VarBase &self) { auto &grad_var = self.GradVarBase(); if (grad_var && grad_var->Var().IsInitialized()) { auto *tensor = grad_var->MutableVar()->IsType<framework::LoDTensor>() ? grad_var->MutableVar() ->GetMutable<framework::LoDTensor>() : grad_var->MutableVar() ->GetMutable<framework::SelectedRows>() ->mutable_value(); if (tensor->IsInitialized()) { return grad_var; } } return std::shared_ptr<imperative::VarBase>(nullptr); }, py::return_value_policy::copy) .def("_set_grad_ivar", [](imperative::VarBase &self, imperative::VarBase &grad) { self.SetGradVarBase(grad); }) .def("_is_sparse", [](imperative::VarBase &self) { return self.Var().IsType<framework::SelectedRows>(); }) .def("_allreduce", [](imperative::VarBase &self, const imperative::ParallelStrategy &strategy) { if (strategy.nranks_ > 1) { #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) #if NCCL_VERSION_CODE >= 2212 imperative::AllReduce(self.Var(), self.MutableVar(), strategy); #else if (!self.Var().IsType<framework::SelectedRows>()) { imperative::AllReduce(self.Var(), self.MutableVar(), strategy); } else { PADDLE_THROW(platform::errors::Unimplemented( "Imperative SelectedRows allreduce is not supported when " "paddle is compiled with NCCL verison lower than v2.2.12. " "You can set is_sparse=False for the Layer containing " "this argument, such as Embedding(is_sparse=False).")); } #endif // NCCL_VERSION_CODE #else PADDLE_THROW(platform::errors::Unimplemented( "Imperative allreduce is not supported when paddle is " "not compiled with NCCL.")); #endif // PADDLE_WITH_NCCL or PADDLE_WITH_RCCL } }, py::call_guard<py::gil_scoped_release>()) .def("_register_grad_hook", [](imperative::VarBase &self, const py::handle &hook) { PADDLE_ENFORCE_EQ( !self.OverridedStopGradient() && self.HasGradVar(), true, platform::errors::InvalidArgument( "Cannot register gradient hook on a Tensor that stop " "gradient or without gradient.")); return self.GradVarBase()->AddVariableWrapperHook( std::make_shared<PyVariableWrapperHook>(hook.ptr())); }) .def("_remove_grad_hook", [](imperative::VarBase &self, int64_t hook_id) { PADDLE_ENFORCE_EQ( !self.OverridedStopGradient() && self.HasGradVar(), true, platform::errors::InvalidArgument( "Cannot remove gradient hook on a Tensor that stop " "gradient or without gradient.")); return self.GradVarBase()->RemoveVariableWrapperHook(hook_id); }) .def("_register_void_function_post_hook", [](imperative::VarBase &self, const py::handle &hook) { PADDLE_ENFORCE_EQ( !self.OverridedStopGradient() && self.HasGradVar(), true, platform::errors::InvalidArgument( "Cannot register void function post hook on a Tensor that " "stop " "gradient or without gradient.")); auto py_func = PyObjectCast<std::function<void()>>(hook.ptr()); auto grad_node = self.MutableGradVarBase()->GradNode(); for (auto &cur_op : *grad_node) { cur_op.AddVoidFunctionPostHook( std::make_shared<std::function<void()>>(py_func)); } }) .def("_register_backward_hook", [](imperative::VarBase &self, const py::handle &hook) { PADDLE_ENFORCE_EQ( self.IsLeaf(), true, platform::errors::InvalidArgument( "Only can register backward hook for leaf Tensor.")); PADDLE_ENFORCE_EQ( !self.OverridedStopGradient() && self.HasGradVar(), true, platform::errors::InvalidArgument( "Cannot register backward hook on a Tensor that stop " "gradient or without gradient.")); auto py_func = PyObjectCast<std::function<void()>>(hook.ptr()); self.GradVarBase()->AddVoidHook( std::make_shared<std::function<void()>>(py_func)); }, R"DOC( Registers a backward hook for current Tensor. This hook will be called every time the gradient of current Tensor has been fully calculated. There are two differences with `_register_grad_hook`: 1. This backward hook will be executed after the gradient accumulation completed across batchs, but the hook registered by `_register_grad_hook` will be executed the gradient accumulation completed in current batch. 2. This backward hook function should have the following signature: hook() -> None It requires no input and no return value. Args: hook(function): A backward hook to be registered for Tensor.gradient Returns: None )DOC") .def("cpu", [](const std::shared_ptr<imperative::VarBase> &self) { if (platform::is_cpu_place(self->Place())) { return self; } else { auto new_var = self->NewVarBase(platform::CPUPlace(), true); new_var->SetOverridedStopGradient(self->OverridedStopGradient()); return new_var; } }, R"DOC( Returns a copy of this Tensor in CPU memory. If this Tensor is already in CPU memory, then no copy is performed and the original Tensor is returned. Examples: .. code-block:: python import paddle x = paddle.to_tensor(1.0, place=paddle.CUDAPlace(0)) print(x.place) # CUDAPlace(0) y = x.cpu() print(y.place) # CPUPlace )DOC") .def("pin_memory", [](const std::shared_ptr<imperative::VarBase> &self) { #if !defined(PADDLE_WITH_CUDA) && !defined(PADDLE_WITH_HIP) PADDLE_THROW(platform::errors::PermissionDenied( "Cannot copy this Tensor to pinned memory in CPU version " "Paddle, " "Please recompile or reinstall Paddle with CUDA support.")); #endif if (platform::is_cuda_pinned_place(self->Place())) { return self; } else { auto new_var = self->NewVarBase(platform::CUDAPinnedPlace(), true); new_var->SetOverridedStopGradient(self->OverridedStopGradient()); return new_var; } }, R"DOC( Returns a copy of this Tensor in pin memory. If this Tensor is already in pin memory, then no copy is performed and the original Tensor is returned. Examples: .. code-block:: python import paddle x = paddle.to_tensor(1.0, place=paddle.CUDAPlace(0)) print(x.place) # CUDAPlace(0) y = x.pin_memory() print(y.place) # CUDAPinnedPlace )DOC") .def("cuda", [](const std::shared_ptr<imperative::VarBase> &self, py::handle &handle, bool blocking) { #if !defined(PADDLE_WITH_CUDA) && !defined(PADDLE_WITH_HIP) PADDLE_THROW(platform::errors::PermissionDenied( "Cannot copy this Tensor to GPU in CPU version Paddle, " "Please recompile or reinstall Paddle with CUDA support.")); #else int device_count = platform::GetGPUDeviceCount(); int device_id = 0; if (handle == py::none()) { if (platform::is_gpu_place(self->Place())) { return self; } } else { PyObject *py_obj = handle.ptr(); PADDLE_ENFORCE_EQ( PyCheckInteger(py_obj), true, platform::errors::InvalidArgument( " 'device_id' must be a positive integer")); device_id = py::cast<int>(handle); } PADDLE_ENFORCE_GE( device_id, 0, platform::errors::InvalidArgument( "Can not copy Tensor to Invalid CUDAPlace(%d), device id " "must inside [0, %d)", device_id, device_count)); PADDLE_ENFORCE_LT( device_id, device_count, platform::errors::InvalidArgument( "Can not copy Tensor to Invalid CUDAPlace(%d), device id " "must inside [0, %d)", device_id, device_count)); platform::CUDAPlace place = platform::CUDAPlace(device_id); if (platform::is_same_place(self->Place(), place)) { return self; } else { auto new_var = self->NewVarBase(place, blocking); new_var->SetOverridedStopGradient(self->OverridedStopGradient()); return new_var; } #endif }, py::arg("device_id") = py::none(), py::arg("blocking") = true, R"DOC( Returns a copy of this Tensor in GPU memory. If this Tensor is already in GPU memory and device_id is default, then no copy is performed and the original Tensor is returned. Args: device_id(int, optional): The destination GPU device id. Default: None, means current device. blocking(bool, optional): If False and the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect. Default: False. Examples: .. code-block:: python # required: gpu import paddle x = paddle.to_tensor(1.0, place=paddle.CPUPlace()) print(x.place) # CPUPlace y = x.cuda() print(y.place) # CUDAPlace(0) y = x.cuda(None) print(y.place) # CUDAPlace(0) y = x.cuda(1) print(y.place) # CUDAPlace(1) )DOC") .def("_share_memory", [](const std::shared_ptr<imperative::VarBase> &self) { #ifndef _WIN32 PADDLE_ENFORCE_EQ( platform::is_cpu_place(self->Place()), true, platform::errors::InvalidArgument( "Sharing memory only support CPU Tensor currently")); // 1. get LoDTensor auto *t = self->MutableVar()->GetMutable<framework::LoDTensor>(); // 2. allocate shared memory void *data_ptr = t->data<void>(); size_t data_size = t->numel() * framework::SizeOfType(t->type()); auto shared_writer_holder = memory::allocation::AllocateMemoryMapWriterAllocation( data_size); // 3. maintain mmap fd set & backup ipc_name const std::string &ipc_name = shared_writer_holder->ipc_name(); memory::allocation::MemoryMapFdSet::Instance().Insert(ipc_name); // 4. copy data & reset holder memory::Copy(platform::CPUPlace(), shared_writer_holder->ptr(), platform::CPUPlace(), data_ptr, data_size); t->ResetHolder(shared_writer_holder); return *t; #else PADDLE_THROW(platform::errors::PermissionDenied( "Sharing memory in Windows OS is not supported currently")); #endif }, py::return_value_policy::reference) .def("copy_", &imperative::VarBase::CopyFrom) .def("_copy_to", [](const std::shared_ptr<imperative::VarBase> &self, const platform::CPUPlace &place, bool blocking) { auto new_var = self->NewVarBase(place, blocking); // Note(zhiqiu): Since NewVarBase may use GpuCopyAsync to // copy data from the tensor of self to the tensor of new varbase, // we need to ensure that the varbase self is not destructed until // the GpuCopyAsync is completed. Otherwise, the memory may be // freed // when varbase self is destructed. // To do that, we increase the reference count of self by 1 and // add a cuda event to wait the GpuCopyAsync's completion. if (!blocking) { IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); } return new_var; }, py::return_value_policy::copy) .def("_copy_to", [](const std::shared_ptr<imperative::VarBase> &self, const platform::CUDAPinnedPlace &place, bool blocking) { auto new_var = self->NewVarBase(place, blocking); if (!blocking) { IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); } return new_var; }, py::return_value_policy::copy) .def("_copy_to", [](const std::shared_ptr<imperative::VarBase> &self, const platform::XPUPlace &place, bool blocking) { auto new_var = self->NewVarBase(place, blocking); if (!blocking) { IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); } return new_var; }, py::return_value_policy::copy) .def("_copy_to", [](const std::shared_ptr<imperative::VarBase> &self, const platform::CUDAPlace &place, bool blocking) { auto new_var = self->NewVarBase(place, blocking); if (!blocking) { IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); } return new_var; }, py::return_value_policy::copy) .def("_copy_to", [](const std::shared_ptr<imperative::VarBase> &self, const platform::NPUPlace &place, bool blocking) { auto new_var = self->NewVarBase(place, blocking); if (!blocking) { IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); } return new_var; }, py::return_value_policy::copy) .def("_copy_to", [](const std::shared_ptr<imperative::VarBase> &self, const platform::Place &place, bool blocking) { auto new_var = self->NewVarBase(place, blocking); if (!blocking) { IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); } return new_var; }, py::return_value_policy::copy) .def("value", [](imperative::VarBase &self) { return self.MutableVar(); }, py::return_value_policy::reference) .def("_clear", [](const std::shared_ptr<imperative::VarBase> &self) { auto *t = self->MutableVar()->GetMutable<framework::LoDTensor>(); PADDLE_ENFORCE_EQ( t->IsInitialized(), true, platform::errors::InvalidArgument( "Tensor %s has not been initialized!", self->Name())); t->clear(); }) .def("_offset", [](const std::shared_ptr<imperative::VarBase> &self) { auto *t = self->MutableVar()->GetMutable<framework::LoDTensor>(); PADDLE_ENFORCE_EQ( t->IsInitialized(), true, platform::errors::InvalidArgument( "Tensor %s has not been initialized!", self->Name())); return t->offset(); }) .def("_share_buffer_to", [](const std::shared_ptr<imperative::VarBase> &self, std::shared_ptr<imperative::VarBase> &dst) { auto *src = self->MutableVar()->GetMutable<framework::LoDTensor>(); auto *dst_ = dst->MutableVar()->GetMutable<framework::LoDTensor>(); PADDLE_ENFORCE_EQ( src->IsInitialized(), true, platform::errors::InvalidArgument( "Tensor %s has not been initialized!", self->Name())); dst_->ShareBufferWith(*src); }) .def("_is_shared_buffer_with", [](const std::shared_ptr<imperative::VarBase> &self, std::shared_ptr<imperative::VarBase> &dst) { auto *src = self->MutableVar()->GetMutable<framework::LoDTensor>(); auto *dst_ = dst->MutableVar()->GetMutable<framework::LoDTensor>(); if (!src->IsInitialized() || !dst_->IsInitialized()) { return false; } return dst_->IsSharedBufferWith(*src); }) .def("_slice", [](const std::shared_ptr<imperative::VarBase> &self, int64_t begin_idx, int64_t end_idx) { auto *t = self->MutableVar()->GetMutable<framework::LoDTensor>(); PADDLE_ENFORCE_EQ( t->IsInitialized(), true, platform::errors::InvalidArgument( "Tensor %s has not been initialized!", self->Name())); return t->Slice(begin_idx, end_idx); }) .def("_copy_gradient_from", [](std::shared_ptr<imperative::VarBase> &self, const imperative::VarBase &src) { self->_CopyGradientFrom(src); }) .def("_numel", [](std::shared_ptr<imperative::VarBase> &self) { auto *t = self->MutableVar()->GetMutable<framework::LoDTensor>(); return t->numel(); }) .def_property("name", &imperative::VarBase::Name, &imperative::VarBase::SetName) .def_property("stop_gradient", &imperative::VarBase::OverridedStopGradient, &imperative::VarBase::SetOverridedStopGradient) .def_property("persistable", &imperative::VarBase::Persistable, &imperative::VarBase::SetPersistable) .def_property_readonly( "shape", [](imperative::VarBase &self) { if (self.Var().IsType<framework::LoDTensor>()) { return framework::vectorize<int>( self.Var().Get<framework::LoDTensor>().dims()); } else if (self.Var().IsType<framework::SelectedRows>()) { return framework::vectorize<int>( self.Var().Get<framework::SelectedRows>().value().dims()); } else if (self.Var().IsType<framework::Strings>()) { return std::vector<int>{static_cast<int>( self.Var().Get<framework::Strings>().size())}; } else if (self.Var().IsType<framework::Vocab>()) { return std::vector<int>{ static_cast<int>(self.Var().Get<framework::Vocab>().size())}; } else { VLOG(2) << "It is meaningless to get shape of " "variable type " << GetTypeName(self); return std::vector<int>(); } }) .def_property_readonly("is_leaf", &imperative::VarBase::IsLeaf, R"DOC( Whether a Tensor is leaf Tensor. For the Tensor whose stop_gradient is ``True`` , it will be leaf Tensor. For the Tensor whose stop_gradient is ``False`` , it will be leaf Tensor too if it is created by user. Returns: bool: Whether a Tensor is leaf Tensor. Examples: .. code-block:: python import paddle x = paddle.to_tensor(1.) print(x.is_leaf) # True x = paddle.to_tensor(1., stop_gradient=True) y = x + 1 print(x.is_leaf) # True print(y.is_leaf) # True x = paddle.to_tensor(1., stop_gradient=False) y = x + 1 print(x.is_leaf) # True print(y.is_leaf) # False )DOC") .def_property_readonly( "place", [](imperative::VarBase &self) { return self.Place(); }, py::return_value_policy::copy) .def_property_readonly("_place_str", [](imperative::VarBase &self) { std::stringstream ostr; ostr << self.Place(); return ostr.str(); }) .def_property_readonly("type", &imperative::VarBase::Type) .def_property_readonly("dtype", &imperative::VarBase::DataType); py::class_<imperative::jit::ProgramDescTracer>(m, "ProgramDescTracer", "") .def("create_program_desc", &imperative::jit::ProgramDescTracer::CreateProgramDesc) .def("reset", &imperative::jit::ProgramDescTracer::Reset); py::enum_<paddle::imperative::AmpLevel>(m, "AmpLevel", py::arithmetic()) .value("O0", paddle::imperative::AmpLevel::O0) .value("O1", paddle::imperative::AmpLevel::O1) .value("O2", paddle::imperative::AmpLevel::O2) .value("O3", paddle::imperative::AmpLevel::O3) .export_values(); py::class_<imperative::Tracer, std::shared_ptr<imperative::Tracer>>( m, "Tracer", R"DOC()DOC") .def("__init__", [](imperative::Tracer &self) { new (&self) imperative::Tracer(); }) .def_property("_enable_program_desc_tracing", &imperative::Tracer::IsProgramDescTracingEnabled, &imperative::Tracer::SetEnableProgramDescTracing) .def_property("_amp_level", &imperative::Tracer::GetAmpLevel, &imperative::Tracer::SetAmpLevel) .def_property("_has_grad", &imperative::Tracer::HasGrad, &imperative::Tracer::SetHasGrad) .def_property( "_expected_place", [](const imperative::Tracer &self) -> py::object { return py::cast(self.ExpectedPlace()); }, [](imperative::Tracer &self, const py::object &obj) { if (py::isinstance<platform::CUDAPlace>(obj)) { auto p = obj.cast<platform::CUDAPlace *>(); self.SetExpectedPlace(*p); VLOG(4) << "Tracer(" << &self << ")" << " set expected place " << *p; } else if (py::isinstance<platform::XPUPlace>(obj)) { auto p = obj.cast<platform::XPUPlace *>(); self.SetExpectedPlace(*p); VLOG(4) << "Tracer(" << &self << ")" << " set expected place " << *p; } else if (py::isinstance<platform::CPUPlace>(obj)) { auto p = obj.cast<platform::CPUPlace *>(); self.SetExpectedPlace(*p); VLOG(4) << "Tracer(" << &self << ")" << " set expected place " << *p; } else if (py::isinstance<platform::CUDAPinnedPlace>(obj)) { auto p = obj.cast<platform::CUDAPinnedPlace *>(); self.SetExpectedPlace(*p); VLOG(4) << "Tracer(" << &self << ")" << " set expected place " << *p; } else if (py::isinstance<platform::NPUPlace>(obj)) { auto p = obj.cast<platform::NPUPlace *>(); self.SetExpectedPlace(*p); VLOG(4) << "Tracer(" << &self << ")" << " set expected place " << *p; } else if (py::isinstance<platform::Place>(obj)) { auto p = obj.cast<platform::Place *>(); self.SetExpectedPlace(*p); VLOG(4) << "Tracer(" << &self << ")" << " set expected place " << *p; } else { PADDLE_THROW(platform::errors::InvalidArgument( "Incompatible Place Type: supports XPUPlace, CUDAPlace, " "CPUPlace, NPUPlace" "and CUDAPinnedPlace, " "but got Unknown Type!")); } }) .def("_get_program_desc_tracer", &imperative::Tracer::GetProgramDescTracer, py::return_value_policy::reference) .def("_generate_unique_name", &imperative::Tracer::GenerateUniqueName, py::arg("key") = "dygraph_tmp") .def("_set_amp_op_list", [](imperative::Tracer &self, std::unordered_set<std::string> &allow_ops, std::unordered_set<std::string> &block_ops) { // NOTE(zhiqiu): The automatic conversion in pybind11 between // c++ // STL and python set/list/dict involve a copy operation that // prevents pass-by-reference semantics, so it is ok to swap. // The reaseon why not directly pass // std::shared_ptr<std::unordered_set<std::string>> // is that pybind11 forbid shared_ptr<T> where T is not custom // type. imperative::AmpOperators::Instance().GetMutableAllowOps()->swap( allow_ops); imperative::AmpOperators::Instance().GetMutableBlockOps()->swap( block_ops); VLOG(5) << "AMP operators changed, " << imperative::AmpOperators::Instance(); }) .def("_get_amp_op_list", [](imperative::Tracer &self) { return std::make_tuple( *(imperative::AmpOperators::Instance().GetMutableAllowOps()), *(imperative::AmpOperators::Instance().GetMutableBlockOps())); }) .def("trace", [](imperative::Tracer &self, const std::string &type, const PyNameVarBaseMap &ins, const PyNameVarBaseMap &outs, framework::AttributeMap attrs, const platform::XPUPlace &place, bool trace_backward) { auto ins_map = ConvertToNameVarBaseMap(ins); auto outs_map = ConvertToNameVarBaseMap(outs); { py::gil_scoped_release release; self.TraceOp(type, std::move(ins_map), std::move(outs_map), std::move(attrs), place, trace_backward); } }) .def("trace", [](imperative::Tracer &self, const std::string &type, const PyNameVarBaseMap &ins, const PyNameVarBaseMap &outs, framework::AttributeMap attrs, const platform::CUDAPlace &place, bool trace_backward) { auto ins_map = ConvertToNameVarBaseMap(ins); auto outs_map = ConvertToNameVarBaseMap(outs); { py::gil_scoped_release release; self.TraceOp(type, std::move(ins_map), std::move(outs_map), std::move(attrs), place, trace_backward); } }) .def("trace", [](imperative::Tracer &self, const std::string &type, const PyNameVarBaseMap &ins, const PyNameVarBaseMap &outs, framework::AttributeMap attrs, const platform::NPUPlace &place, bool trace_backward) { auto ins_map = ConvertToNameVarBaseMap(ins); auto outs_map = ConvertToNameVarBaseMap(outs); { py::gil_scoped_release release; self.TraceOp(type, std::move(ins_map), std::move(outs_map), std::move(attrs), place, trace_backward); } }) .def("trace", [](imperative::Tracer &self, const std::string &type, const PyNameVarBaseMap &ins, const PyNameVarBaseMap &outs, framework::AttributeMap attrs, const platform::CPUPlace &place, bool trace_backward) { auto ins_map = ConvertToNameVarBaseMap(ins); auto outs_map = ConvertToNameVarBaseMap(outs); { py::gil_scoped_release release; self.TraceOp(type, std::move(ins_map), std::move(outs_map), std::move(attrs), place, trace_backward); } }); // define parallel context py::class_<imperative::ParallelStrategy> parallel_strategy( m, "ParallelStrategy", ""); parallel_strategy.def(py::init()) .def_property( "nranks", [](const imperative::ParallelStrategy &self) { return self.nranks_; }, [](imperative::ParallelStrategy &self, int nranks) { self.nranks_ = nranks; }) .def_property("local_rank", [](const imperative::ParallelStrategy &self) { return self.local_rank_; }, [](imperative::ParallelStrategy &self, int local_rank) { self.local_rank_ = local_rank; }) .def_property( "trainer_endpoints", [](const imperative::ParallelStrategy &self) { return self.trainer_endpoints_; }, [](imperative::ParallelStrategy &self, std::vector<std::string> eps) { self.trainer_endpoints_ = eps; }) .def_property("current_endpoint", [](const imperative::ParallelStrategy &self) { return self.current_endpoint_; }, [](imperative::ParallelStrategy &self, const std::string &ep) { self.current_endpoint_ = ep; }) .def_property( "nrings", [](const imperative::ParallelStrategy &self) { return self.nrings_; }, [](imperative::ParallelStrategy &self, int nrings) { self.nrings_ = nrings; }); m.def("varbase_copy", &VarBaseCopy<platform::Place>); m.def("varbase_copy", &VarBaseCopy<platform::CPUPlace>); m.def("varbase_copy", &VarBaseCopy<platform::CUDAPlace>); m.def("varbase_copy", &VarBaseCopy<platform::XPUPlace>); m.def("varbase_copy", &VarBaseCopy<platform::CUDAPinnedPlace>); m.def("varbase_copy", &VarBaseCopy<platform::NPUPlace>); m.def( "dygraph_partial_grad", [](const std::vector<std::shared_ptr<imperative::VarBase>> &input_targets, const std::vector<std::shared_ptr<imperative::VarBase>> &output_targets, const std::vector<std::shared_ptr<imperative::VarBase>> &output_grads, const std::vector<std::shared_ptr<imperative::VarBase>> &no_grad_vars, const platform::Place &place, bool create_graph, bool retain_graph, bool allow_unused, bool only_inputs) { imperative::PartialGradEngine engine( input_targets, output_targets, output_grads, no_grad_vars, place, create_graph, retain_graph, allow_unused, only_inputs); engine.Execute(); return engine.GetResult(); }, py::call_guard<py::gil_scoped_release>()); m.def( "dygraph_run_backward", [](const std::vector<std::shared_ptr<imperative::VarBase>> &tensors, const std::vector<std::shared_ptr<imperative::VarBase>> &grad_tensors, bool retain_graph, const imperative::Tracer &tracer) { auto *engine = tracer.GetEngine(); engine->Init(tensors, grad_tensors, retain_graph); VLOG(3) << "Start backward"; engine->Execute(); VLOG(3) << "Finish backward"; }, py::call_guard<py::gil_scoped_release>()); #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) || \ defined(PADDLE_WITH_XPU_BKCL) || defined(PADDLE_WITH_GLOO) py::class_<imperative::ParallelContext, std::shared_ptr<imperative::ParallelContext>>(m, "ParallelContext"); py::class_<imperative::Reducer, std::shared_ptr<imperative::Reducer>>( m, "Reducer", R"DOC()DOC") .def(py::init<const std::vector<std::shared_ptr<imperative::VarBase>> &, const std::vector<std::vector<size_t>> &, const std::vector<bool> &, std::shared_ptr<imperative::ParallelContext>, const std::vector<size_t> &, bool>()) .def("prepare_for_backward", &imperative::Reducer::PrepareForBackward, py::arg("vars"), py::call_guard<py::gil_scoped_release>()); m.def("assign_group_by_size", &imperative::AssignGroupBySize, py::arg("vars"), py::arg("is_sparse_gradient"), py::arg("group_size_limits") = std::vector<size_t>{25 * 1024 * 1024}, py::arg("tensor_indices") = std::vector<int64_t>{}, py::call_guard<py::gil_scoped_release>()); #endif #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) py::class_<imperative::NCCLParallelContext, imperative::ParallelContext, std::shared_ptr<imperative::NCCLParallelContext>>( m, "NCCLParallelContext") .def(py::init<const imperative::ParallelStrategy &, const platform::CUDAPlace &>()) .def("init", [](imperative::NCCLParallelContext &self) { self.Init(); }) .def("init_with_ring_id", &imperative::NCCLParallelContext::InitWithRingID, py::arg("ring_id")); #endif #if defined(PADDLE_WITH_XPU_BKCL) py::class_<imperative::BKCLParallelContext, imperative::ParallelContext, std::shared_ptr<imperative::BKCLParallelContext>>( m, "BKCLParallelContext") .def(py::init<const imperative::ParallelStrategy &, const platform::XPUPlace &>()) .def("init", [](imperative::BKCLParallelContext &self) { self.Init(); }) .def("init_with_ring_id", &imperative::BKCLParallelContext::InitWithRingID, py::arg("ring_id")); #endif #if defined(PADDLE_WITH_GLOO) // xiongkun py::class_<imperative::GLOOParallelContext, imperative::ParallelContext, std::shared_ptr<imperative::GLOOParallelContext>>( m, "GLOOParallelContext") .def(py::init<const imperative::ParallelStrategy &, const platform::CPUPlace &>()) .def("init", [](imperative::GLOOParallelContext &self) { self.Init(); }) .def("init_with_ring_id", &imperative::GLOOParallelContext::InitWithRingID, py::arg("ring_id")); #endif #if defined(PADDLE_WITH_ASCEND_CL) py::class_<imperative::HCCLParallelContext, imperative::ParallelContext, std::shared_ptr<imperative::HCCLParallelContext>>( m, "HCCLParallelContext") .def(py::init<const imperative::ParallelStrategy &, const platform::NPUPlace &>()) .def("init", [](imperative::HCCLParallelContext &self) { self.Init(); }) .def("init_with_ring_id", &imperative::HCCLParallelContext::InitWithRingID, py::arg("ring_id")); #endif #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) || \ defined(PADDLE_WITH_XPU_BKCL) || defined(PADDLE_WITH_ASCEND_CL) py::class_<imperative::HeterParallelContext, imperative::ParallelContext, std::shared_ptr<imperative::HeterParallelContext>>( m, "HeterParallelContext") .def(py::init<const imperative::ParallelStrategy &, const int &>()) .def("init", [](imperative::HeterParallelContext &self) { self.Init(); }); #endif m.def("pylayer_apply", [](const platform::CPUPlace &place, const py::object &cls, const py::args args, const py::kwargs kwargs) { return imperative::PyLayerApply(place, cls, args, kwargs); }); m.def("pylayer_apply", [](const platform::CUDAPlace &place, const py::object &cls, const py::args args, const py::kwargs kwargs) { return imperative::PyLayerApply(place, cls, args, kwargs); }); m.def("pylayer_apply", [](const platform::XPUPlace &place, const py::object &cls, const py::args args, const py::kwargs kwargs) { return imperative::PyLayerApply(place, cls, args, kwargs); }); m.def("pylayer_apply", [](const platform::CUDAPinnedPlace &place, const py::object &cls, const py::args args, const py::kwargs kwargs) { return imperative::PyLayerApply(place, cls, args, kwargs); }); m.def("pylayer_apply", [](const platform::NPUPlace &place, const py::object &cls, const py::args args, const py::kwargs kwargs) { return imperative::PyLayerApply(place, cls, args, kwargs); }); #if defined(PADDLE_WITH_CUDA) m.def( "async_write", [](const imperative::VarBase &src, imperative::VarBase &dst, const imperative::VarBase &offset, const imperative::VarBase &count) { PADDLE_ENFORCE_EQ( platform::is_gpu_place(src.Place()), true, platform::errors::InvalidArgument( "Required `src` device should be CUDAPlace, but received %d. ", src.Place())); PADDLE_ENFORCE_EQ( platform::is_cuda_pinned_place(dst.Place()), true, platform::errors::InvalidArgument( "Required `dst` device should be CUDAPinnedPlace, " "but received %d. ", dst.Place())); PADDLE_ENFORCE_EQ( platform::is_cpu_place(offset.Place()), true, platform::errors::InvalidArgument("Required `offset` device should " "be CPUPlace, but received %d. ", offset.Place())); PADDLE_ENFORCE_EQ( platform::is_cpu_place(count.Place()), true, platform::errors::InvalidArgument( "Required `count` device should be CPUPlace, but received %d. ", count.Place())); // TODO(daisiming): In future, add index as arguments following // async_read. auto &src_tensor = src.Var().Get<framework::LoDTensor>(); auto *dst_tensor = dst.MutableVar()->GetMutable<framework::LoDTensor>(); auto &offset_tensor = offset.Var().Get<framework::LoDTensor>(); auto &count_tensor = count.Var().Get<framework::LoDTensor>(); const auto &deviceId = paddle::platform::GetCurrentDeviceId(); PADDLE_ENFORCE_EQ(offset_tensor.dims().size(), 1, platform::errors::InvalidArgument( "`offset` tensor should be one-dimensional.")); PADDLE_ENFORCE_EQ(count_tensor.dims().size(), 1, platform::errors::InvalidArgument( "`count` tensor should be one-dimensional.")); PADDLE_ENFORCE_EQ(offset_tensor.numel(), count_tensor.numel(), platform::errors::InvalidArgument( "`offset` and `count` tensor size dismatch.")); PADDLE_ENFORCE_EQ( src_tensor.dims().size(), dst_tensor->dims().size(), platform::errors::InvalidArgument( "`src` and `dst` should have the same tensor shape, " "except for the first dimension.")); for (int i = 1; i < src_tensor.dims().size(); i++) { PADDLE_ENFORCE_EQ( src_tensor.dims()[i], dst_tensor->dims()[i], platform::errors::InvalidArgument( "`src` and `dst` should have the same tensor shape, " "except for the first dimension.")); } auto stream = paddle::platform::stream::get_current_stream(deviceId) ->raw_stream(); int64_t size = src_tensor.numel() / src_tensor.dims()[0]; auto *src_data = src_tensor.data<float>(); auto *dst_data = dst_tensor->mutable_data<float>(dst.Place()); const int64_t *offset_data = offset_tensor.data<int64_t>(); const int64_t *count_data = count_tensor.data<int64_t>(); int64_t src_offset = 0, dst_offset, c; for (int64_t i = 0; i < offset_tensor.numel(); i++) { dst_offset = offset_data[i], c = count_data[i]; PADDLE_ENFORCE_LE(src_offset + c, src_tensor.dims()[0], platform::errors::InvalidArgument( "Invalid offset or count index")); PADDLE_ENFORCE_LE(dst_offset + c, dst_tensor->dims()[0], platform::errors::InvalidArgument( "Invalid offset or count index")); cudaMemcpyAsync( dst_data + (dst_offset * size), src_data + (src_offset * size), c * size * sizeof(float), cudaMemcpyDeviceToHost, stream); src_offset += c; } }, R"DOC( This api provides a way to write pieces of source tensor to destination tensor inplacely and asynchronously. In which, we use `offset` and `count` to determine where to copy. `offset` means the begin points of the copy pieces of `src`, and `count` means the lengths of the copy pieces of `src`. To be noted, the copy process will run asynchronously from cuda to pin memory. We can simply remember this as "gpu async_write to pin_memory". Arguments: src (Tensor): The source tensor, and the data type should be `float32` currently. Besides, `src` should be placed on CUDAPlace. dst (Tensor): The destination tensor, and the data type should be `float32` currently. Besides, `dst` should be placed on CUDAPinnedPlace. The shape of `dst` should be the same with `src` except for the first dimension. offset (Tensor): The offset tensor, and the data type should be `int64` currently. Besides, `offset` should be placed on CPUPlace. The shape of `offset` should be one-dimensional. count (Tensor): The count tensor, and the data type should be `int64` currently. Besides, `count` should be placed on CPUPlace. The shape of `count` should be one-dimensinal. Examples: .. code-block:: python import numpy as np import paddle from paddle.fluid import core from paddle.device import cuda if core.is_compiled_with_cuda(): src = paddle.rand(shape=[100, 50, 50]) dst = paddle.emtpy(shape=[200, 50, 50]).pin_memory() offset = paddle.to_tensor( np.array([0, 60], dtype="int64"), place=paddle.CPUPlace()) count = paddle.to_tensor( np.array([40, 60], dtype="int64"), place=paddle.CPUPlace()) stream = cuda.Stream() with cuda.stream_guard(stream): core.async_write(src, dst, offset, count) offset_a = paddle.gather(dst, paddle.to_tensor(np.arange(0, 40))) offset_b = paddle.gather(dst, paddle.to_tensor(np.arange(60, 120))) offset_array = paddle.concat([offset_a, offset_b], axis=0) print(np.allclose(src.numpy(), offset_array.numpy())) # True )DOC"); m.def( "async_read", [](const imperative::VarBase &src, imperative::VarBase &dst, const imperative::VarBase &index, imperative::VarBase &buffer, const imperative::VarBase &offset, const imperative::VarBase &count) { PADDLE_ENFORCE_EQ(platform::is_cuda_pinned_place(src.Place()), true, platform::errors::InvalidArgument( "Required `src` device should be " "CUDAPinnedPlace, but received %d.", src.Place())); PADDLE_ENFORCE_EQ( platform::is_gpu_place(dst.Place()), true, platform::errors::InvalidArgument( "Required `dst` device should be CUDAPlace, but received %d.", dst.Place())); PADDLE_ENFORCE_EQ( platform::is_cpu_place(index.Place()), true, platform::errors::InvalidArgument( "Required `index` device should be CPUPlace, but received %d.", index.Place())); PADDLE_ENFORCE_EQ( platform::is_cuda_pinned_place(buffer.Place()), true, platform::errors::InvalidArgument( "Required `buffer` device should be CUDAPinnedPlace, " "but received %d.", buffer.Place())); PADDLE_ENFORCE_EQ( platform::is_cpu_place(offset.Place()), true, platform::errors::InvalidArgument( "Required `offset` device should be CPUPlace, but received %d.", offset.Place())); PADDLE_ENFORCE_EQ( platform::is_cpu_place(count.Place()), true, platform::errors::InvalidArgument( "Required `count` device should be CPUPlace, but received %d.", count.Place())); auto &src_tensor = src.Var().Get<framework::LoDTensor>(); auto *dst_tensor = dst.MutableVar()->GetMutable<framework::LoDTensor>(); auto &index_tensor = index.Var().Get<framework::LoDTensor>(); auto *buffer_tensor = buffer.MutableVar()->GetMutable<framework::LoDTensor>(); auto &offset_tensor = offset.Var().Get<framework::LoDTensor>(); auto &count_tensor = count.Var().Get<framework::LoDTensor>(); auto *dst_data = dst_tensor->mutable_data<float>(dst.Place()); const auto &deviceId = paddle::platform::GetCurrentDeviceId(); PADDLE_ENFORCE_EQ(src_tensor.dims().size(), dst_tensor->dims().size(), platform::errors::InvalidArgument( "`src` and `dst` should have same tensor shape, " "except for the first dimension.")); PADDLE_ENFORCE_EQ( src_tensor.dims().size(), buffer_tensor->dims().size(), platform::errors::InvalidArgument( "`src` and `buffer` should have same tensor shape, " "except for the first dimension.")); for (int i = 1; i < src_tensor.dims().size(); i++) { PADDLE_ENFORCE_EQ( src_tensor.dims()[i], dst_tensor->dims()[i], platform::errors::InvalidArgument( "`src` and `dst` should have the same tensor shape, " "except for the first dimension.")); PADDLE_ENFORCE_EQ( src_tensor.dims()[i], buffer_tensor->dims()[i], platform::errors::InvalidArgument( "`src` and `buffer` should have the same tensor shape, " "except for the first dimension.")); } PADDLE_ENFORCE_EQ(index_tensor.dims().size(), 1, platform::errors::InvalidArgument( "`index` tensor should be one-dimensional.")); auto stream = paddle::platform::stream::get_current_stream(deviceId) ->raw_stream(); int64_t numel = 0; // total copy length int64_t copy_flag = offset_tensor.dims()[0]; int64_t size = src_tensor.numel() / src_tensor.dims()[0]; if (copy_flag != 0) { PADDLE_ENFORCE_EQ(offset_tensor.dims().size(), 1, platform::errors::InvalidArgument( "`offset` tensor should be one-dimensional.")); PADDLE_ENFORCE_EQ(count_tensor.dims().size(), 1, platform::errors::InvalidArgument( "`count` tensor should be one-dimensional.")); PADDLE_ENFORCE_EQ(offset_tensor.numel(), count_tensor.numel(), platform::errors::InvalidArgument( "`offset` and `count` tensor size dismatch.")); auto *offset_data = offset_tensor.data<int64_t>(); auto *count_data = count_tensor.data<int64_t>(); for (int64_t i = 0; i < count_tensor.numel(); i++) { numel += count_data[i]; } PADDLE_ENFORCE_LE(numel + index_tensor.numel(), buffer_tensor->dims()[0], platform::errors::InvalidArgument( "Buffer tensor size is too small.")); PADDLE_ENFORCE_LE(numel + index_tensor.numel(), dst_tensor->dims()[0], platform::errors::InvalidArgument( "Target tensor size is too small.")); int64_t src_offset, dst_offset = 0, c; auto *src_data = src_tensor.data<float>(); for (int64_t i = 0; i < offset_tensor.numel(); i++) { src_offset = offset_data[i], c = count_data[i]; PADDLE_ENFORCE_LE(src_offset + c, src_tensor.dims()[0], platform::errors::InvalidArgument( "Invalid offset or count index.")); PADDLE_ENFORCE_LE(dst_offset + c, dst_tensor->dims()[0], platform::errors::InvalidArgument( "Invalid offset or count index.")); cudaMemcpyAsync( dst_data + (dst_offset * size), src_data + (src_offset * size), c * size * sizeof(float), cudaMemcpyHostToDevice, stream); dst_offset += c; } } else { PADDLE_ENFORCE_LE(index_tensor.numel(), buffer_tensor->dims()[0], platform::errors::InvalidArgument( "Buffer tensor size is too small.")); } // Select the index data to the buffer auto index_select = [](const framework::Tensor &src_tensor, const framework::Tensor &index_tensor, framework::Tensor *buffer_tensor) { auto *src_data = src_tensor.data<float>(); auto *index_data = index_tensor.data<int64_t>(); auto *buffer_data = buffer_tensor->mutable_data<float>(buffer_tensor->place()); const int &slice_size = src_tensor.numel() / src_tensor.dims()[0]; const int &copy_bytes = slice_size * sizeof(float); int64_t c = 0; for (int64_t i = 0; i < index_tensor.numel(); i++) { std::memcpy(buffer_data + c * slice_size, src_data + index_data[i] * slice_size, copy_bytes); c += 1; } }; index_select(src_tensor, index_tensor, buffer_tensor); // Copy the data to device memory cudaMemcpyAsync(dst_data + (numel * size), buffer_tensor->data<float>(), index_tensor.numel() * size * sizeof(float), cudaMemcpyHostToDevice, stream); }, R"DOC( This api provides a way to read from pieces of source tensor to destination tensor asynchronously. In which, we use `index`, `offset` and `count` to determine where to read. `index` means the index position of src tensor we want to read. `offset` and count means the begin points and length of pieces of src tensor we want to read. To be noted, the copy process will run asynchronously from pin memory to cuda place. We can simply remember this as "cuda async_read from pin_memory". Arguments: src (Tensor): The source tensor, and the data type should be `float32` currently. Besides, `src` should be placed on CUDAPinnedPlace. dst (Tensor): The destination tensor, and the data type should be `float32` currently. Besides, `dst` should be placed on CUDAPlace. The shape of `dst` should be the same with `src` except for the first dimension. index (Tensor): The index tensor, and the data type should be `int64` currently. Besides, `index` should be on CPUplace. The shape of `index` should be one-dimensional. buffer (Tensor): The buffer tensor, used to buffer index copy tensor temporarily. The data type should be `float32` currently, and should be placed on CUDAPinnedPlace. The shape of `buffer` should be the same with `src` except for the first dimension. offset (Tensor): The offset tensor, and the data type should be `int64` currently. Besides, `offset` should be placed on CPUPlace. The shape of `offset` should be one-dimensional. count (Tensor): The count tensor, and the data type should be `int64` currently. Besides, `count` should be placed on CPUPlace. The shape of `count` should be one-dimensinal. Examples: .. code-block:: python import numpy as np import paddle from paddle.fluid import core from paddle.device import cuda if core.is_compiled_with_cuda(): src = paddle.rand(shape=[100, 50, 50], dtype="float32").pin_memory() dst = paddle.empty(shape=[100, 50, 50], dtype="float32") offset = paddle.to_tensor( np.array([0, 60], dtype="int64"), place=paddle.CPUPlace()) count = paddle.to_tensor( np.array([40, 60], dtype="int64"), place=paddle.CPUPlace()) buffer = paddle.empty(shape=[50, 50, 50], dtype="float32").pin_memory() index = paddle.to_tensor( np.array([1, 3, 5, 7, 9], dtype="int64")).cpu() stream = cuda.Stream() with cuda.stream_guard(stream): core.async_read(src, dst, index, buffer, offset, count) )DOC"); #endif } } // namespace pybind } // namespace paddle
// // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2013-2015, 2021 // // Copyright: See COPYING file that comes with this distribution // #pragma once #include <utility> #include <memory> #include <atomic> #include <functional> namespace wflow{ template<typename H> struct callback_handler { typedef std::function<void()> double_call_fun_t; typedef std::function<void()> no_call_fun_t; typedef std::shared_ptr< std::atomic_flag > ready_ptr; callback_handler() = default; callback_handler(const callback_handler&) = default; callback_handler(callback_handler&&) = default; callback_handler& operator=(const callback_handler&) = default; callback_handler& operator=(callback_handler&&) = default; ~callback_handler() { if ( _ready!=nullptr && _ready.use_count()==1 && _no_call!=nullptr && !_ready->test_and_set() ) _no_call(); } callback_handler(H&& h, const ready_ptr& ready, const double_call_fun_t& dc, const no_call_fun_t& nc) : _handler( std::forward<H>(h) ) , _ready(ready) , _double_call(dc) , _no_call(nc) { } template <class... Args> auto operator()(Args&&... args) -> typename std::result_of< H(Args&&...) >::type { if ( !_ready->test_and_set() ) return _handler(std::forward<Args>(args)...); else if (_double_call!=nullptr) _double_call(); return typename std::result_of< H(Args&&...) >::type(); } private: H _handler; ready_ptr _ready; double_call_fun_t _double_call; no_call_fun_t _no_call; }; }
ld a,(Fuel) ld de,txt_fuel_level ld c, -100 call .Num1 ld c,-10 call .Num1 ld c,-1 .Num1: ld b,'0'-1 .Num2: inc b add a,c jr c,.Num2 sub c push bc push af ld a,c cp -1 call z,.InsertDot ld a,b ld (de),a inc de pop af pop bc ret .InsertDot: ld a,'.' ld (de),a inc de ret
; Test case: ld ix,val ld b,(ix+1) ld c,(ix+2) ld (val2),bc loop: jr loop val: db 0,0,0 val2: dw 0
; size_t b_vector_write_block_callee(void *src, size_t n, b_vector_t *v, size_t idx) SECTION code_adt_b_vector PUBLIC _b_vector_write_block_callee _b_vector_write_block_callee: pop af exx pop hl exx pop de pop hl pop bc push af INCLUDE "adt/b_vector/z80/asm_b_vector_write_block.asm"
frame 1, 10 frame 2, 40 frame 1, 06 endanim
; A052201: Equivalent of the Kurepa hypothesis for left factorial. ; Submitted by Jon Maiga ; 4,15,48,175,816,4851,34960,292743,2774040,29251651,339184776,4285584615,58571107168,860622082035,13525670637216,226358825764711,4018390654376520,75413358213752643,1491684815796629080 add $0,2 lpb $0 add $1,$0 add $1,1 mul $2,$0 add $2,$1 add $1,$0 sub $0,1 lpe mov $0,$2 div $0,2 sub $0,1
// Copyright (c) 2012-2016, The CryptoNote developers, The Bytecoin developers // // This file is part of Bitcoinphantom. // // Bitcoinphantom is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Bitcoinphantom is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with Bitcoinphantom. If not, see <http://www.gnu.org/licenses/>. #include "Ipv4Resolver.h" #include <cassert> #include <random> #include <stdexcept> #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include <ws2tcpip.h> #include <System/Dispatcher.h> #include <System/ErrorMessage.h> #include <System/InterruptedException.h> #include <System/Ipv4Address.h> namespace System { Ipv4Resolver::Ipv4Resolver() : dispatcher(nullptr) { } Ipv4Resolver::Ipv4Resolver(Dispatcher& dispatcher) : dispatcher(&dispatcher) { } Ipv4Resolver::Ipv4Resolver(Ipv4Resolver&& other) : dispatcher(other.dispatcher) { if (dispatcher != nullptr) { other.dispatcher = nullptr; } } Ipv4Resolver::~Ipv4Resolver() { } Ipv4Resolver& Ipv4Resolver::operator=(Ipv4Resolver&& other) { dispatcher = other.dispatcher; if (dispatcher != nullptr) { other.dispatcher = nullptr; } return *this; } Ipv4Address Ipv4Resolver::resolve(const std::string& host) { assert(dispatcher != nullptr); if (dispatcher->interrupted()) { throw InterruptedException(); } addrinfo hints = { 0, AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, NULL, NULL, NULL }; addrinfo* addressInfos; int result = getaddrinfo(host.c_str(), NULL, &hints, &addressInfos); if (result != 0) { throw std::runtime_error("Ipv4Resolver::resolve, getaddrinfo failed, " + errorMessage(result)); } size_t count = 0; for (addrinfo* addressInfo = addressInfos; addressInfo != nullptr; addressInfo = addressInfo->ai_next) { ++count; } std::mt19937 generator{ std::random_device()() }; size_t index = std::uniform_int_distribution<size_t>(0, count - 1)(generator); addrinfo* addressInfo = addressInfos; for (size_t i = 0; i < index; ++i) { addressInfo = addressInfo->ai_next; } Ipv4Address address(ntohl(reinterpret_cast<sockaddr_in*>(addressInfo->ai_addr)->sin_addr.S_un.S_addr)); freeaddrinfo(addressInfo); return address; } }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r13 push %r14 push %rcx push %rdi push %rsi lea addresses_WT_ht+0x11241, %r14 nop nop nop nop xor %r10, %r10 movl $0x61626364, (%r14) nop nop nop nop nop add $62200, %r11 lea addresses_UC_ht+0x714f, %rsi lea addresses_A_ht+0x1e41, %rdi clflush (%rdi) nop nop add $41654, %r13 mov $116, %rcx rep movsl nop nop nop nop nop and $26969, %rdi lea addresses_WC_ht+0x12d81, %r10 nop nop nop add %rcx, %rcx movw $0x6162, (%r10) nop and $15367, %r14 lea addresses_D_ht+0x1518d, %r10 nop nop nop nop nop cmp %r11, %r11 mov $0x6162636465666768, %rdi movq %rdi, (%r10) nop nop nop nop nop cmp %rsi, %rsi lea addresses_A_ht+0x14dc1, %rsi nop nop nop inc %rdi mov $0x6162636465666768, %rcx movq %rcx, (%rsi) nop nop add %r14, %r14 lea addresses_WT_ht+0x4f, %rsi nop nop nop and $5720, %rcx vmovups (%rsi), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $1, %xmm2, %r10 nop nop nop nop nop and %r13, %r13 lea addresses_A_ht+0x105b1, %rcx nop nop nop and %rsi, %rsi and $0xffffffffffffffc0, %rcx movaps (%rcx), %xmm5 vpextrq $0, %xmm5, %r14 nop nop sub %r14, %r14 lea addresses_D_ht+0x1b41, %rsi lea addresses_D_ht+0x6901, %rdi nop nop nop add $18017, %r12 mov $2, %rcx rep movsb cmp $23968, %r10 lea addresses_WT_ht+0x18811, %rsi lea addresses_WC_ht+0x3699, %rdi nop nop nop nop cmp %r12, %r12 mov $71, %rcx rep movsb and $1807, %rdi lea addresses_D_ht+0x5d81, %rsi lea addresses_WT_ht+0x1c241, %rdi clflush (%rsi) sub %r12, %r12 mov $124, %rcx rep movsq nop nop nop add %r10, %r10 lea addresses_A_ht+0x17e41, %rsi lea addresses_normal_ht+0xae41, %rdi nop nop nop cmp %r11, %r11 mov $72, %rcx rep movsq nop xor $6360, %r11 pop %rsi pop %rdi pop %rcx pop %r14 pop %r13 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r8 push %r9 push %rbp push %rbx push %rdi // Store mov $0x4c180000000008a5, %r12 nop nop nop nop xor $22568, %rbx mov $0x5152535455565758, %r8 movq %r8, %xmm2 vmovups %ymm2, (%r12) nop nop add $40632, %r8 // Store lea addresses_UC+0x19141, %r14 nop add %r9, %r9 mov $0x5152535455565758, %r12 movq %r12, (%r14) nop nop nop nop nop sub $52742, %r9 // Store lea addresses_WT+0x1e241, %r8 nop nop nop nop cmp $14477, %r12 movl $0x51525354, (%r8) nop nop nop nop nop xor %r12, %r12 // Load lea addresses_A+0x3351, %rbx clflush (%rbx) nop nop nop xor %rbp, %rbp mov (%rbx), %r9 nop nop nop nop add %rbp, %rbp // Faulty Load lea addresses_WT+0x18641, %r8 nop sub $33820, %r14 mov (%r8), %edi lea oracles, %r14 and $0xff, %rdi shlq $12, %rdi mov (%r14,%rdi,1), %rdi pop %rdi pop %rbx pop %rbp pop %r9 pop %r8 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WT', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_NC', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT', 'same': False, 'size': 4, 'congruent': 9, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_WT', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A_ht', 'same': True, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 3, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': True}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'39': 23} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
//================================================================================================= /*! // \file src/mathtest/dmatsmatadd/MDbDCa.cpp // \brief Source file for the MDbDCa dense matrix/sparse matrix addition math test // // Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/CompressedMatrix.h> #include <blaze/math/DiagonalMatrix.h> #include <blaze/math/DynamicMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/dmatsmatadd/OperationTest.h> #include <blazetest/system/MathTest.h> //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'MDbDCa'..." << std::endl; using blazetest::mathtest::TypeA; using blazetest::mathtest::TypeB; try { // Matrix type definitions typedef blaze::DynamicMatrix<TypeB> MDb; typedef blaze::DiagonalMatrix< blaze::CompressedMatrix<TypeA> > DCa; // Creator type definitions typedef blazetest::Creator<MDb> CMDb; typedef blazetest::Creator<DCa> CDCa; // Running tests with small matrices for( size_t i=0UL; i<=6UL; ++i ) { for( size_t j=0UL; j<=i; ++j ) { RUN_DMATSMATADD_OPERATION_TEST( CMDb( i, i ), CDCa( i, j ) ); } } // Running tests with large matrices RUN_DMATSMATADD_OPERATION_TEST( CMDb( 67UL, 67UL ), CDCa( 67UL, 7UL ) ); RUN_DMATSMATADD_OPERATION_TEST( CMDb( 128UL, 128UL ), CDCa( 128UL, 16UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense matrix/sparse matrix addition:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
// -*- mode: c++; indent-tabs-mode: nil; -*- // // Copyright (c) 2009-2013 Illumina, Inc. // // This software is provided under the terms and conditions of the // Illumina Open Source Software License 1. // // You should have received a copy of the Illumina Open Source // Software License 1 along with this program. If not, see // <https://github.com/sequencing/licenses/> // /// \file /// \author Morten Kallberg /// #include "blt_util/ranksum.hh" #include <cmath> #include <algorithm> #include <iostream> #include <vector> #include <iostream> #include <map> using namespace std; double get_z_score(int n1, int n2, double w1) { double mean = n1*(n1+n2+1)/2.0; double var = sqrt(n1*n2*(n1+n2+1)/12.0); if (static_cast<int>(var)==0) { return 0.0; } double z = (w1-mean)/var; return z; } // return the U statistic double ranksum::get_u_stat() { // cout << "doing U stat" << endl; vector<int> myvector = this->getSpace(); int current_rank = 1; R1 = 0.0; R2 = 0.0; N1 = 0; N2 = 0; //loop over all observations for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it) { int key = *it; // get the observation counts for reference and alt int obs1= this->get_obs_count(true,key); int obs2= this->get_obs_count(false,key); int obs = obs1 + obs2; double rank_weight = (2*current_rank + obs -1)/2.0; R1 += rank_weight*obs1; R2 += rank_weight*obs2; N1 += obs1; N2 += obs2; current_rank += obs; // cout << key << "\t{"<< obs1 << ", " << obs2 << "}" << " sum: " << obs ; // cout << " weight " << rank_weight << " U1: " << U1 << " U2: " << U2 << endl; // cout << "updated rank " << current_rank << endl; } //return the z-score for the smaller of U1 and U2 assuming a gaussian approx. double z; if (R1>R2) { z = get_z_score(N2,N1,R2); } else { z = get_z_score(N1,N2,R1); } return z; } void ranksum::add_observation(bool is_ref, int obs) { space[obs] =1; if (is_ref) { l1[obs]++; // cout << "ref case" << endl; } else { l2[obs]++; // cout << "alt case" << endl; // cout << "ref_base: " << ref_base << " alt_base: " << base << endl; } } // output specification ostream& operator<< (ostream& out, map<int, int>& l) { out << "Elements in l: " << endl; for (map<int, int>::iterator it = l.begin(); it != l.end(); ++it) out << "\t" <<(*it).first << " => " << (*it).second << endl; return out; } ostream& operator<< (ostream& out, ranksum& r) { double z = r.get_u_stat(); out << endl << "My reference base: " << r.get_refbase() << endl; out << "elements in space: " << endl; out << "["; vector<int> myvector = r.getSpace(); for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it) std::cout << ' ' << *it; out << "]" << endl; out << r.l1; out << r.l2; out << "N1: " << r.N1 << "\tR1: " << r.R1 << endl; out << "N2: " << r.N2 << "\tR2: " << r.R2 << endl; out << "Z-score: " << z << endl; return out; }
; void zx_visit_wc_pix(struct r_Rect8 *r, void *function) SECTION code_clib SECTION code_arch PUBLIC _zx_visit_wc_pix_callee EXTERN asm_zx_visit_wc_pix _zx_visit_wc_pix_callee: pop hl pop bc ex (sp),hl l0_zx_visit_wc_pix_callee: ex de,hl push bc ex (sp),ix call asm_zx_visit_wc_pix pop ix ret
IDD_DLGVERSION equ 1700 IDC_EDTVERFILE equ 2903 IDC_EDTVERPROD equ 2904 IDC_CBOVEROS equ 2905 IDC_CBOVERTYPE equ 2906 IDC_CBOVERLANG equ 2907 IDC_CBOVERCHAR equ 2908 IDC_LSTVER equ 2909 IDC_EDTVER equ 2910 IDC_EDTVERTPE equ 2911 IDC_BTNVERADD equ 2912 .const szVerOS dd 00000004h db 'WINDOWS32',0 dd 00000000h db 'UNKNOWN',0 dd 00010000h db 'DOS',0 dd 00020000h db 'OS216',0 dd 00030000h db 'OS232',0 dd 00040000h db 'NT',0 dd 00000000h db 'BASE',0 dd 00000001h db 'WINDOWS16',0 dd 00000002h db 'PM16',0 dd 00000003h db 'PM32',0 dd 00010001h db 'DOS_WINDOWS16',0 dd 00010004h db 'DOS_WINDOWS32',0 dd 00020002h db 'OS216_PM16',0 dd 00030003h db 'OS232_PM32',0 dd 00040004h db 'NT_WINDOWS32',0 dd 0,0 szVerFT dd 00000000h db 'UNKNOWN',0 dd 00000001h db 'APP',0 dd 00000002h db 'DLL',0 dd 00000003h db 'DRV',0 dd 00000004h db 'FONT',0 dd 00000005h db 'VXD',0 dd 00000007h db 'STATIC_LIB',0 dd 0,0 szVerLNG dd 0409h db 'U.S. English',0 dd 0401h db 'Arabic',0 dd 0402h db 'Bulgarian',0 dd 0403h db 'Catalan',0 dd 0404h db 'Traditional Chinese',0 dd 0405h db 'Czech',0 dd 0406h db 'Danish',0 dd 0407h db 'German',0 dd 0408h db 'Greek',0 dd 040Ah db 'Castilian Spanish',0 dd 040Bh db 'Finnish',0 dd 040Ch db 'French',0 dd 040Dh db 'Hebrew',0 dd 040Eh db 'Hungarian',0 dd 040Fh db 'Icelandic',0 dd 0410h db 'Italian',0 dd 0411h db 'Japanese',0 dd 0412h db 'Korean',0 dd 0413h db 'Dutch',0 dd 0414h db 'Norwegian - Bokml',0 dd 0415h db 'Polish',0 dd 0416h db 'Brazilian Portuguese',0 dd 0417h db 'Rhaeto-Romanic',0 dd 0417h db 'Rhaeto-Romanic',0 dd 0418h db 'Romanian',0 dd 0419h db 'Russian',0 dd 041Ah db 'Croato-Serbian (Latin)',0 dd 041Bh db 'Slovak',0 dd 041Ch db 'Albanian',0 dd 041Dh db 'Swedish',0 dd 041Eh db 'Thai',0 dd 041Fh db 'Turkish',0 dd 0420h db 'Urdu',0 dd 0421h db 'Bahasa',0 dd 0804h db 'Simplified Chinese',0 dd 0807h db 'Swiss German',0 dd 0809h db 'U.K. English',0 dd 080Ah db 'Mexican Spanish',0 dd 080Ch db 'Belgian French',0 dd 0810h db 'Swiss Italian',0 dd 0813h db 'Belgian Dutch',0 dd 0814h db 'Norwegian - Nynorsk',0 dd 0816h db 'Portuguese',0 dd 081Ah db 'Serbo-Croatian (Cyrillic)',0 dd 0C0Ch db 'Canadian French',0 dd 100Ch db 'Swiss French',0 dd 0,0 szVerCHS dd 1200 db 'Unicode',0 dd 0 db '7-bit ASCII',0 dd 932 db 'Japan (Shift - JIS X-0208)',0 dd 949 db 'Korea (Shift - KSC 5601)',0 dd 950 db 'Taiwan (GB5)',0 dd 1250 db 'Latin-2 (Eastern European)',0 dd 1251 db 'Cyrillic',0 dd 1252 db 'Multilingual',0 dd 1253 db 'Greek',0 dd 1254 db 'Turkish',0 dd 1255 db 'Hebrew',0 dd 1256 db 'Arabic',0 dd 0,0 szVerTpe db 'CompanyName',0 db 'FileVersion',0 db 'FileDescription',0 db 'InternalName',0 db 'LegalCopyright',0 db 'LegalTrademarks',0 db 'OriginalFilename',0 db 'ProductName',0 db 'ProductVersion',0 db 0 szStringFileInfo db 'StringFileInfo',0 szVarFileInfo db 'VarFileInfo',0 szTranslation db 'Translation',0 .data szVersionName db 'IDR_VERSION',0 defver VERSIONMEM <,1,1,0,0,0,1,0,0,0,4,0,409h,4B0h> VERSIONITEM <"FileVersion","1.0.0.0"> VERSIONITEM <"ProductVersion","1.0.0.0"> VERSIONITEM 30 dup(<>) .data? szVersionTxt db 32*256 dup(?) lpOldEditProc dd ? hVerDlg dd ? .code IncrementVersion proc lpProMem:DWORD printdec hDialog, "Testval" mov eax,hDialog .if eax && eax==hVerDlg invoke CloseDialog .endif invoke GetTypeMem,lpProMem,TPE_VERSION .if eax mov edx,[eax].PROJECT.hmem inc [edx].VERSIONMEM.fv3 inc [edx].VERSIONMEM.pv3 mov [eax].PROJECT.changed,TRUE .endif ret IncrementVersion endp ExportVersionNames proc uses esi edi,hMem:DWORD invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,1024*16 mov edi,eax invoke GlobalLock,edi push edi mov esi,hMem ;#define .if [esi].VERSIONMEM.szname && [esi].VERSIONMEM.value invoke ExportName,addr [esi].VERSIONMEM.szname,[esi].VERSIONMEM.value,edi lea edi,[edi+eax] .endif pop eax ret ExportVersionNames endp ExportVersion proc uses esi edi,hMem:DWORD invoke xGlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,1024*16 mov edi,eax invoke GlobalLock,edi push edi mov esi,hMem ;Name or ID .if [esi].VERSIONMEM.szname invoke strcpy,edi,addr [esi].VERSIONMEM.szname .else invoke ResEdBinToDec,[esi].VERSIONMEM.value,edi .endif invoke strlen,edi add edi,eax mov al,' ' stosb invoke SaveStr,edi,addr szVERSIONINFO add edi,eax mov al,0Dh stosb mov al,0Ah stosb ;File version invoke SaveStr,edi,addr szFILEVERSION add edi,eax mov al,' ' stosb push esi lea esi,[esi].VERSIONMEM.fv call SaveVer pop esi ;Product version invoke SaveStr,edi,addr szPRODUCTVERSION add edi,eax mov al,' ' stosb push esi lea esi,[esi].VERSIONMEM.pv call SaveVer pop esi ;File OS invoke SaveStr,edi,addr szFILEOS add edi,eax mov al,' ' stosb mov eax,[esi].VERSIONMEM.os call SaveHex ;File type invoke SaveStr,edi,addr szFILETYPE add edi,eax mov al,' ' stosb mov eax,[esi].VERSIONMEM.ft call SaveHex invoke SaveStr,edi,addr szBEGIN add edi,eax mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb invoke SaveStr,edi,addr szBLOCK add edi,eax mov al,' ' stosb mov al,22h stosb invoke SaveStr,edi,addr szStringFileInfo add edi,eax mov al,22h stosb mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb invoke SaveStr,edi,addr szBEGIN add edi,eax mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb stosb stosb invoke SaveStr,edi,addr szBLOCK add edi,eax mov al,' ' stosb mov al,22h stosb mov eax,[esi].VERSIONMEM.lng invoke hexEax invoke strcpy,edi,offset strHex+4 add edi,4 mov eax,[esi].VERSIONMEM.chs invoke hexEax invoke strcpy,edi,offset strHex+4 add edi,4 mov al,22h stosb mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb stosb stosb invoke SaveStr,edi,addr szBEGIN add edi,eax mov al,0Dh stosb mov al,0Ah stosb push esi lea esi,[esi+sizeof VERSIONMEM] .while TRUE .break .if ![esi].VERSIONITEM.szname .if [esi].VERSIONITEM.szvalue mov al,' ' stosb stosb stosb stosb stosb stosb invoke SaveStr,edi,addr szVALUE add edi,eax mov al,' ' stosb mov al,22h stosb invoke SaveStr,edi,addr [esi].VERSIONITEM.szname add edi,eax mov al,22h stosb mov al,',' stosb mov al,' ' stosb mov al,22h stosb invoke SaveStr,edi,addr [esi].VERSIONITEM.szvalue add edi,eax mov al,'\' stosb mov al,'0' stosb mov al,22h stosb mov al,0Dh stosb mov al,0Ah stosb .endif lea esi,[esi+sizeof VERSIONITEM] .endw pop esi mov al,' ' stosb stosb stosb stosb invoke SaveStr,edi,addr szEND add edi,eax mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb invoke SaveStr,edi,addr szEND add edi,eax mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb invoke SaveStr,edi,addr szBLOCK add edi,eax mov al,' ' stosb mov al,22h stosb invoke SaveStr,edi,addr szVarFileInfo add edi,eax mov al,22h stosb mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb invoke SaveStr,edi,addr szBEGIN add edi,eax mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb stosb stosb invoke SaveStr,edi,addr szVALUE add edi,eax mov al,' ' stosb mov al,22h stosb invoke SaveStr,edi,addr szTranslation add edi,eax mov al,22h stosb mov al,',' stosb mov al,' ' stosb mov al,'0' stosb mov al,'x' stosb mov eax,[esi].VERSIONMEM.lng invoke hexEax invoke strcpy,edi,offset strHex+4 add edi,4 mov al,',' stosb mov al,' ' stosb mov al,'0' stosb mov al,'x' stosb mov eax,[esi].VERSIONMEM.chs invoke hexEax invoke strcpy,edi,offset strHex+4 add edi,4 mov al,0Dh stosb mov al,0Ah stosb mov al,' ' stosb stosb invoke SaveStr,edi,addr szEND add edi,eax mov al,0Dh stosb mov al,0Ah stosb invoke SaveStr,edi,addr szEND add edi,eax mov al,0Dh stosb mov al,0Ah stosb mov al,0Dh stosb mov al,0Ah stosb mov al,0 stosb pop eax ret SaveVer: mov eax,[esi] call SaveVerItem mov eax,[esi+4] call SaveVerItem mov eax,[esi+8] call SaveVerItem mov eax,[esi+12] call SaveVerItem dec edi mov al,0Dh stosb mov al,0Ah stosb retn SaveVerItem: invoke ResEdBinToDec,eax,edi invoke strlen,edi lea edi,[edi+eax] mov al,',' stosb retn SaveHex: mov word ptr [edi],'x0' add edi,2 invoke hexEax invoke strcpy,edi,offset strHex add edi,8 mov al,0Dh stosb mov al,0Ah stosb retn ExportVersion endp SaveVersionEdit proc uses ebx esi edi,hWin:HWND LOCAL nInx:DWORD LOCAL buffer[512]:BYTE invoke GetWindowLong,hWin,GWL_USERDATA .if !eax invoke SendMessage,hRes,PRO_ADDITEM,TPE_VERSION,FALSE push eax invoke RtlMoveMemory,[eax].PROJECT.hmem,offset defver,sizeof VERSIONMEM+sizeof VERSIONITEM*32 pop eax .endif mov ebx,eax push ebx mov esi,[ebx].PROJECT.hmem invoke GetProjectItemName,ebx,addr buffer invoke SetProjectItemName,ebx,addr buffer invoke GetDlgItemText,hWin,IDC_EDTVERFILE,addr buffer,16 push esi lea esi,[esi].VERSIONMEM.fv call GetVerNum pop esi invoke GetDlgItemText,hWin,IDC_EDTVERPROD,addr buffer,16 push esi lea esi,[esi].VERSIONMEM.pv call GetVerNum pop esi invoke SendDlgItemMessage,hWin,IDC_CBOVEROS,CB_GETCURSEL,0,0 invoke SendDlgItemMessage,hWin,IDC_CBOVEROS,CB_GETITEMDATA,eax,0 mov [esi].VERSIONMEM.os,eax invoke SendDlgItemMessage,hWin,IDC_CBOVERTYPE,CB_GETCURSEL,0,0 invoke SendDlgItemMessage,hWin,IDC_CBOVERTYPE,CB_GETITEMDATA,eax,0 mov [esi].VERSIONMEM.ft,eax invoke SendDlgItemMessage,hWin,IDC_CBOVERLANG,CB_GETCURSEL,0,0 invoke SendDlgItemMessage,hWin,IDC_CBOVERLANG,CB_GETITEMDATA,eax,0 mov [esi].VERSIONMEM.lng,eax invoke SendDlgItemMessage,hWin,IDC_CBOVERCHAR,CB_GETCURSEL,0,0 invoke SendDlgItemMessage,hWin,IDC_CBOVERCHAR,CB_GETITEMDATA,eax,0 mov [esi].VERSIONMEM.chs,eax lea esi,[esi+sizeof VERSIONMEM] mov nInx,0 .while TRUE mov [esi].VERSIONITEM.szname,0 mov [esi].VERSIONITEM.szvalue,0 invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETTEXT,nInx,addr [esi].VERSIONITEM.szname .break .if eax==LB_ERR invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETITEMDATA,nInx,0 invoke strcpy,addr [esi].VERSIONITEM.szvalue,eax lea esi,[esi+sizeof VERSIONITEM] inc nInx .endw pop eax ret GetVerNum: lea edi,buffer call GetVerNumItem mov [esi],eax call GetVerNumItem mov [esi+4],eax call GetVerNumItem mov [esi+8],eax call GetVerNumItem mov [esi+12],eax retn GetVerNumItem: invoke ResEdDecToBin,edi .while byte ptr [edi]!='.' && byte ptr [edi] inc edi .endw .if byte ptr [edi]=='.' inc edi .endif retn SaveVersionEdit endp VersionSetCbo proc uses esi,hWin:HWND,nID:DWORD,lpKey:DWORD,nVal:DWORD LOCAL nInx:DWORD mov esi,lpKey .while byte ptr [esi+4] push [esi] add esi,4 invoke SendDlgItemMessage,hWin,nID,CB_ADDSTRING,0,esi pop edx invoke SendDlgItemMessage,hWin,nID,CB_SETITEMDATA,eax,edx invoke strlen,esi lea esi,[esi+eax+1] .endw mov nInx,0 .while TRUE invoke SendDlgItemMessage,hWin,nID,CB_GETITEMDATA,nInx,0 .break .if eax==CB_ERR .if eax==nVal invoke SendDlgItemMessage,hWin,nID,CB_SETCURSEL,nInx,0 .break .endif inc nInx .endw ret VersionSetCbo endp EditProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM .if uMsg==WM_CHAR .if wParam==VK_RETURN invoke GetParent,hWin invoke PostMessage,eax,WM_COMMAND,IDC_BTNVERADD,hWin xor eax,eax ret .endif .endif invoke CallWindowProc,lpOldEditProc,hWin,uMsg,wParam,lParam ret EditProc endp VersionEditProc proc uses esi edi,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL nInx:DWORD LOCAL buffer[512]:BYTE LOCAL rect:RECT LOCAL fChanged:DWORD mov eax,uMsg .if eax==WM_INITDIALOG mov eax,hWin mov hVerDlg,eax mov fChanged,FALSE mov esi,lParam invoke SetWindowLong,hWin,GWL_USERDATA,esi .if esi mov esi,[esi].PROJECT.hmem .else invoke GetFreeProjectitemID,TPE_VERSION mov esi,offset defver mov [esi].VERSIONMEM.value,eax invoke strcpy,addr [esi].VERSIONMEM.szname,addr szVersionName invoke GetUnikeName,addr [esi].VERSIONMEM.szname mov fChanged,TRUE .endif invoke RtlZeroMemory,offset szVersionTxt,sizeof szVersionTxt mov lpResType,offset szVERSIONINFO lea eax,[esi].VERSIONMEM.szname mov lpResName,eax lea eax,[esi].VERSIONMEM.value mov lpResID,eax invoke SendDlgItemMessage,hWin,IDC_EDTVERFILE,EM_LIMITTEXT,16,0 push esi lea esi,[esi].VERSIONMEM.fv call ConvVer pop esi invoke SetDlgItemText,hWin,IDC_EDTVERFILE,addr buffer invoke SendDlgItemMessage,hWin,IDC_EDTVERPROD,EM_LIMITTEXT,16,0 push esi lea esi,[esi].VERSIONMEM.pv call ConvVer pop esi invoke SetDlgItemText,hWin,IDC_EDTVERPROD,addr buffer invoke VersionSetCbo,hWin,IDC_CBOVEROS,offset szVerOS,[esi].VERSIONMEM.os invoke VersionSetCbo,hWin,IDC_CBOVERTYPE,offset szVerFT,[esi].VERSIONMEM.ft invoke VersionSetCbo,hWin,IDC_CBOVERLANG,addr szVerLNG,[esi].VERSIONMEM.lng invoke VersionSetCbo,hWin,IDC_CBOVERCHAR,addr szVerCHS,[esi].VERSIONMEM.chs lea esi,[esi+sizeof VERSIONMEM] mov edi,offset szVerTpe .while byte ptr [edi] call AddTpe invoke strlen,edi lea edi,[edi+eax+1] .endw mov edi,offset szVersionTxt .while [esi].VERSIONITEM.szname invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_ADDSTRING,0,addr [esi].VERSIONITEM.szname invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_SETITEMDATA,eax,edi invoke strcpy,edi,addr [esi].VERSIONITEM.szvalue add edi,256 lea esi,[esi+sizeof VERSIONITEM] .endw invoke SendDlgItemMessage,hWin,IDC_EDTVER,EM_LIMITTEXT,255,0 invoke SendDlgItemMessage,hWin,IDC_EDTVERTPE,EM_LIMITTEXT,63,0 invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_SETCURSEL,0,0 invoke SendMessage,hWin,WM_COMMAND,(LBN_SELCHANGE shl 16) or IDC_LSTVER,0 invoke GetDlgItem,hWin,IDC_EDTVERTPE mov edx,eax invoke SetWindowLong,edx,GWL_WNDPROC,addr EditProc mov lpOldEditProc,eax invoke GetWindowLong,hWin,GWL_USERDATA .if !eax invoke SaveVersionEdit,hWin invoke SetWindowLong,hWin,GWL_USERDATA,eax .endif invoke PropertyList,-2 mov fNoScroll,TRUE invoke ShowScrollBar,hDEd,SB_BOTH,FALSE invoke SendMessage,hWin,WM_SIZE,0,0 mov eax,fChanged mov fDialogChanged,eax .elseif eax==WM_COMMAND mov eax,wParam mov edx,eax shr edx,16 and eax,0FFFFh .if edx==BN_CLICKED .if eax==IDOK invoke SaveVersionEdit,hWin .if fDialogChanged invoke SendMessage,hRes,PRO_SETMODIFY,TRUE,0 mov fDialogChanged,FALSE .endif .elseif eax==IDCANCEL invoke SendMessage,hWin,WM_CLOSE,NULL,NULL invoke PropertyList,0 .elseif eax==IDC_BTNVERADD invoke SendDlgItemMessage,hWin,IDC_EDTVERTPE,WM_GETTEXT,sizeof buffer,addr buffer .if eax lea edi,buffer invoke GetWindowLong,hWin,GWL_USERDATA .if eax mov esi,[eax].PROJECT.hmem .else mov esi,offset defver .endif lea esi,[esi+sizeof VERSIONMEM] call AddTpe invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_RESETCONTENT,0,0 mov edi,offset szVersionTxt mov nInx,-1 .while [esi].VERSIONITEM.szname invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_ADDSTRING,0,addr [esi].VERSIONITEM.szname invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_SETITEMDATA,eax,edi invoke strcpy,edi,addr [esi].VERSIONITEM.szvalue inc nInx add edi,256 lea esi,[esi+sizeof VERSIONITEM] .endw mov buffer,0 invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_SETCURSEL,nInx,0 invoke SendDlgItemMessage,hWin,IDC_EDTVERTPE,WM_SETTEXT,0,addr buffer invoke SendMessage,hWin,WM_COMMAND,(LBN_SELCHANGE shl 16) or IDC_LSTVER,0 invoke GetDlgItem,hWin,IDC_BTNVERADD invoke EnableWindow,eax,FALSE .endif .endif .elseif edx==EN_CHANGE .if eax==IDC_EDTVER invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETCURSEL,0,0 invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETITEMDATA,eax,0 invoke SendDlgItemMessage,hWin,IDC_EDTVER,WM_GETTEXT,256,eax .elseif eax==IDC_EDTVERTPE invoke GetDlgItem,hWin,IDC_BTNVERADD push eax invoke SendDlgItemMessage,hWin,IDC_EDTVERTPE,WM_GETTEXTLENGTH,0,0 pop edx invoke EnableWindow,edx,eax .endif mov fDialogChanged,TRUE invoke NotifyParent .elseif edx==LBN_SELCHANGE .if eax==IDC_LSTVER invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETCURSEL,0,0 .if eax!=LB_ERR invoke SendDlgItemMessage,hWin,IDC_LSTVER,LB_GETITEMDATA,eax,0 invoke SendDlgItemMessage,hWin,IDC_EDTVER,WM_SETTEXT,0,eax .endif .endif mov fDialogChanged,TRUE invoke NotifyParent .endif .elseif eax==WM_CLOSE mov fNoScroll,FALSE invoke ShowScrollBar,hDEd,SB_BOTH,TRUE invoke DestroyWindow,hWin mov hVerDlg,0 .elseif eax==WM_SIZE invoke SendMessage,hDEd,WM_VSCROLL,SB_THUMBTRACK,0 invoke SendMessage,hDEd,WM_HSCROLL,SB_THUMBTRACK,0 invoke GetClientRect,hDEd,addr rect mov rect.left,3 mov rect.top,3 sub rect.right,6 sub rect.bottom,6 invoke MoveWindow,hWin,rect.left,rect.top,rect.right,rect.bottom,TRUE .else mov eax,FALSE ret .endif mov eax,TRUE ret ConvVer: lea edi,buffer invoke ResEdBinToDec,[esi],edi invoke strlen,edi lea edi,[edi+eax] mov al,'.' stosb invoke ResEdBinToDec,[esi+4],edi invoke strlen,edi lea edi,[edi+eax] mov al,'.' stosb invoke ResEdBinToDec,[esi+8],edi invoke strlen,edi lea edi,[edi+eax] mov al,'.' stosb invoke ResEdBinToDec,[esi+12],edi retn AddTpe: push esi .while [esi].VERSIONITEM.szname invoke strcmpi,addr [esi].VERSIONITEM.szname,edi .break .if !eax lea esi,[esi+sizeof VERSIONITEM] .endw invoke strcpy,addr [esi].VERSIONITEM.szname,edi pop esi retn VersionEditProc endp
// This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name: projects/06/pong/Pong.asm // The Pong game program was originally written in the high-level Jack language. // The Jack code was then translated by the Jack compiler into VM code. // The VM code was then translated by the VM translator into the Hack // assembly code shown here. @256 D=A @SP M=D @133 0;JMP @R15 M=D @SP AM=M-1 D=M A=A-1 D=M-D M=0 @END_EQ D;JNE @SP A=M-1 M=-1 (END_EQ) @R15 A=M 0;JMP @R15 M=D @SP AM=M-1 D=M A=A-1 D=M-D M=0 @END_GT D;JLE @SP A=M-1 M=-1 (END_GT) @R15 A=M 0;JMP @R15 M=D @SP AM=M-1 D=M A=A-1 D=M-D M=0 @END_LT D;JGE @SP A=M-1 M=-1 (END_LT) @R15 A=M 0;JMP @5 D=A @LCL A=M-D D=M @R13 M=D @SP AM=M-1 D=M @ARG A=M M=D D=A @SP M=D+1 @LCL D=M @R14 AM=D-1 D=M @THAT M=D @R14 AM=M-1 D=M @THIS M=D @R14 AM=M-1 D=M @ARG M=D @R14 AM=M-1 D=M @LCL M=D @R13 A=M 0;JMP @SP A=M M=D @LCL D=M @SP AM=M+1 M=D @ARG D=M @SP AM=M+1 M=D @THIS D=M @SP AM=M+1 M=D @THAT D=M @SP AM=M+1 M=D @4 D=A @R13 D=D+M @SP D=M-D @ARG M=D @SP MD=M+1 @LCL M=D @R14 A=M 0;JMP @0 D=A @R13 M=D @sys.init D=A @R14 M=D @RET_ADDRESS_CALL0 D=A @95 0;JMP (RET_ADDRESS_CALL0) (ball.new) @15 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.alloc D=A @R14 M=D @RET_ADDRESS_CALL1 D=A @95 0;JMP (RET_ADDRESS_CALL1) @SP AM=M-1 D=M @THIS M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @10 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @THIS D=M @11 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ARG D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @12 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ARG D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @THIS D=M @13 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @SP M=M+1 A=M-1 M=0 @THIS D=M @14 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.show D=A @R14 M=D @RET_ADDRESS_CALL2 D=A @95 0;JMP (RET_ADDRESS_CALL2) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (ball.dispose) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.dealloc D=A @R14 M=D @RET_ADDRESS_CALL3 D=A @95 0;JMP (RET_ADDRESS_CALL3) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (ball.show) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @1 D=A @R13 M=D @screen.setcolor D=A @R14 M=D @RET_ADDRESS_CALL4 D=A @95 0;JMP (RET_ADDRESS_CALL4) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.draw D=A @R14 M=D @RET_ADDRESS_CALL5 D=A @95 0;JMP (RET_ADDRESS_CALL5) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (ball.hide) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @SP M=M+1 A=M-1 M=0 @1 D=A @R13 M=D @screen.setcolor D=A @R14 M=D @RET_ADDRESS_CALL6 D=A @95 0;JMP (RET_ADDRESS_CALL6) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.draw D=A @R14 M=D @RET_ADDRESS_CALL7 D=A @95 0;JMP (RET_ADDRESS_CALL7) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (ball.draw) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @5 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @5 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @4 D=A @R13 M=D @screen.drawrectangle D=A @R14 M=D @RET_ADDRESS_CALL8 D=A @95 0;JMP (RET_ADDRESS_CALL8) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (ball.getleft) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (ball.getright) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @5 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @54 0;JMP (ball.setdestination) @3 D=A (LOOP_ball.setdestination) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_ball.setdestination D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @math.abs D=A @R14 M=D @RET_ADDRESS_CALL9 D=A @95 0;JMP (RET_ADDRESS_CALL9) @SP AM=M-1 D=M @LCL A=M M=D @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @math.abs D=A @R14 M=D @RET_ADDRESS_CALL10 D=A @95 0;JMP (RET_ADDRESS_CALL10) @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT0 D=A @38 0;JMP (RET_ADDRESS_LT0) @THIS D=M @7 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @THIS D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ball.setdestination$if_true0 D;JNE @ball.setdestination$if_false0 0;JMP (ball.setdestination$if_true0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT1 D=A @38 0;JMP (RET_ADDRESS_LT1) @THIS D=M @8 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT2 D=A @38 0;JMP (RET_ADDRESS_LT2) @THIS D=M @9 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ball.setdestination$if_end0 0;JMP (ball.setdestination$if_false0) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT3 D=A @38 0;JMP (RET_ADDRESS_LT3) @THIS D=M @8 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT4 D=A @38 0;JMP (RET_ADDRESS_LT4) @THIS D=M @9 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D (ball.setdestination$if_end0) @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL11 D=A @95 0;JMP (RET_ADDRESS_CALL11) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL12 D=A @95 0;JMP (RET_ADDRESS_CALL12) @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL13 D=A @95 0;JMP (RET_ADDRESS_CALL13) @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (ball.move) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.hide D=A @R14 M=D @RET_ADDRESS_CALL14 D=A @95 0;JMP (RET_ADDRESS_CALL14) @SP AM=M-1 D=M @R5 M=D @THIS D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT5 D=A @38 0;JMP (RET_ADDRESS_LT5) @SP AM=M-1 D=M @ball.move$if_true0 D;JNE @ball.move$if_false0 0;JMP (ball.move$if_true0) @THIS D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 M=D @ball.move$if_end0 0;JMP (ball.move$if_false0) @THIS D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 M=D @THIS D=M @9 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ball.move$if_true1 D;JNE @ball.move$if_false1 0;JMP (ball.move$if_true1) @THIS D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ball.move$if_true2 D;JNE @ball.move$if_false2 0;JMP (ball.move$if_true2) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M M=D @ball.move$if_end2 0;JMP (ball.move$if_false2) @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M+1 M=D (ball.move$if_end2) @ball.move$if_end1 0;JMP (ball.move$if_false1) @THIS D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ball.move$if_true3 D;JNE @ball.move$if_false3 0;JMP (ball.move$if_true3) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M M=D @ball.move$if_end3 0;JMP (ball.move$if_false3) @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M+1 M=D (ball.move$if_end3) (ball.move$if_end1) (ball.move$if_end0) @THIS D=M @8 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ball.move$if_true4 D;JNE @ball.move$if_false4 0;JMP (ball.move$if_true4) @THIS D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ball.move$if_true5 D;JNE @ball.move$if_false5 0;JMP (ball.move$if_true5) @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M+1 M=D @ball.move$if_end5 0;JMP (ball.move$if_false5) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M M=D (ball.move$if_end5) @ball.move$if_end4 0;JMP (ball.move$if_false4) @THIS D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ball.move$if_true6 D;JNE @ball.move$if_false6 0;JMP (ball.move$if_true6) @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M+1 M=D @ball.move$if_end6 0;JMP (ball.move$if_false6) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M M=D (ball.move$if_end6) (ball.move$if_end4) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @10 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT0 D=A @22 0;JMP (RET_ADDRESS_GT0) @SP A=M-1 M=!M @SP AM=M-1 D=M @ball.move$if_true7 D;JNE @ball.move$if_false7 0;JMP (ball.move$if_true7) @SP M=M+1 A=M-1 M=1 @THIS D=M @14 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @THIS D=M @10 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M M=D (ball.move$if_false7) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @11 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT6 D=A @38 0;JMP (RET_ADDRESS_LT6) @SP A=M-1 M=!M @SP AM=M-1 D=M @ball.move$if_true8 D;JNE @ball.move$if_false8 0;JMP (ball.move$if_true8) @2 D=A @SP AM=M+1 A=A-1 M=D @THIS D=M @14 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @THIS D=M @11 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M M=D (ball.move$if_false8) @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @12 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT1 D=A @22 0;JMP (RET_ADDRESS_GT1) @SP A=M-1 M=!M @SP AM=M-1 D=M @ball.move$if_true9 D;JNE @ball.move$if_false9 0;JMP (ball.move$if_true9) @3 D=A @SP AM=M+1 A=A-1 M=D @THIS D=M @14 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @THIS D=M @12 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 M=D (ball.move$if_false9) @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @13 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT7 D=A @38 0;JMP (RET_ADDRESS_LT7) @SP A=M-1 M=!M @SP AM=M-1 D=M @ball.move$if_true10 D;JNE @ball.move$if_false10 0;JMP (ball.move$if_true10) @4 D=A @SP AM=M+1 A=A-1 M=D @THIS D=M @14 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @THIS D=M @13 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 M=D (ball.move$if_false10) @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.show D=A @R14 M=D @RET_ADDRESS_CALL15 D=A @95 0;JMP (RET_ADDRESS_CALL15) @SP AM=M-1 D=M @R5 M=D @THIS D=M @14 A=D+A D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (ball.bounce) @5 D=A (LOOP_ball.bounce) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_ball.bounce D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @10 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL16 D=A @95 0;JMP (RET_ADDRESS_CALL16) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @10 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL17 D=A @95 0;JMP (RET_ADDRESS_CALL17) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ0 D=A @6 0;JMP (RET_ADDRESS_EQ0) @SP AM=M-1 D=M @ball.bounce$if_true0 D;JNE @ball.bounce$if_false0 0;JMP (ball.bounce$if_true0) @10 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @ball.bounce$if_end0 0;JMP (ball.bounce$if_false0) @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT8 D=A @38 0;JMP (RET_ADDRESS_LT8) @SP A=M-1 M=!M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @RET_ADDRESS_EQ1 D=A @6 0;JMP (RET_ADDRESS_EQ1) @SP AM=M-1 D=M A=A-1 M=D&M @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT9 D=A @38 0;JMP (RET_ADDRESS_LT9) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP A=M-1 D=!M M=D+1 @RET_ADDRESS_EQ2 D=A @6 0;JMP (RET_ADDRESS_EQ2) @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M @ball.bounce$if_true1 D;JNE @ball.bounce$if_false1 0;JMP (ball.bounce$if_true1) @20 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @ball.bounce$if_end1 0;JMP (ball.bounce$if_false1) @5 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D (ball.bounce$if_end1) (ball.bounce$if_end0) @THIS D=M @14 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @RET_ADDRESS_EQ3 D=A @6 0;JMP (RET_ADDRESS_EQ3) @SP AM=M-1 D=M @ball.bounce$if_true2 D;JNE @ball.bounce$if_false2 0;JMP (ball.bounce$if_true2) @506 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @50 D=A @SP AM=M+1 A=A-1 M=D @SP A=M-1 D=!M M=D+1 @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL18 D=A @95 0;JMP (RET_ADDRESS_CALL18) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL19 D=A @95 0;JMP (RET_ADDRESS_CALL19) @SP AM=M-1 D=M @LCL A=M+1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL20 D=A @95 0;JMP (RET_ADDRESS_CALL20) @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 M=D @ball.bounce$if_end2 0;JMP (ball.bounce$if_false2) @THIS D=M @14 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ4 D=A @6 0;JMP (RET_ADDRESS_EQ4) @SP AM=M-1 D=M @ball.bounce$if_true3 D;JNE @ball.bounce$if_false3 0;JMP (ball.bounce$if_true3) @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @LCL A=M M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @50 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL21 D=A @95 0;JMP (RET_ADDRESS_CALL21) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL22 D=A @95 0;JMP (RET_ADDRESS_CALL22) @SP AM=M-1 D=M @LCL A=M+1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL23 D=A @95 0;JMP (RET_ADDRESS_CALL23) @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 M=D @ball.bounce$if_end3 0;JMP (ball.bounce$if_false3) @THIS D=M @14 A=D+A D=M @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ5 D=A @6 0;JMP (RET_ADDRESS_EQ5) @SP AM=M-1 D=M @ball.bounce$if_true4 D;JNE @ball.bounce$if_false4 0;JMP (ball.bounce$if_true4) @250 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @25 D=A @SP AM=M+1 A=A-1 M=D @SP A=M-1 D=!M M=D+1 @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL24 D=A @95 0;JMP (RET_ADDRESS_CALL24) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL25 D=A @95 0;JMP (RET_ADDRESS_CALL25) @SP AM=M-1 D=M @LCL A=M M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL26 D=A @95 0;JMP (RET_ADDRESS_CALL26) @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @ball.bounce$if_end4 0;JMP (ball.bounce$if_false4) @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @25 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL27 D=A @95 0;JMP (RET_ADDRESS_CALL27) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL28 D=A @95 0;JMP (RET_ADDRESS_CALL28) @SP AM=M-1 D=M @LCL A=M M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL29 D=A @95 0;JMP (RET_ADDRESS_CALL29) @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D (ball.bounce$if_end4) (ball.bounce$if_end3) (ball.bounce$if_end2) @THIS D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @3 D=A @R13 M=D @ball.setdestination D=A @R14 M=D @RET_ADDRESS_CALL30 D=A @95 0;JMP (RET_ADDRESS_CALL30) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (bat.new) @5 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.alloc D=A @R14 M=D @RET_ADDRESS_CALL31 D=A @95 0;JMP (RET_ADDRESS_CALL31) @SP AM=M-1 D=M @THIS M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.show D=A @R14 M=D @RET_ADDRESS_CALL32 D=A @95 0;JMP (RET_ADDRESS_CALL32) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (bat.dispose) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.dealloc D=A @R14 M=D @RET_ADDRESS_CALL33 D=A @95 0;JMP (RET_ADDRESS_CALL33) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (bat.show) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @1 D=A @R13 M=D @screen.setcolor D=A @R14 M=D @RET_ADDRESS_CALL34 D=A @95 0;JMP (RET_ADDRESS_CALL34) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.draw D=A @R14 M=D @RET_ADDRESS_CALL35 D=A @95 0;JMP (RET_ADDRESS_CALL35) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (bat.hide) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @SP M=M+1 A=M-1 M=0 @1 D=A @R13 M=D @screen.setcolor D=A @R14 M=D @RET_ADDRESS_CALL36 D=A @95 0;JMP (RET_ADDRESS_CALL36) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.draw D=A @R14 M=D @RET_ADDRESS_CALL37 D=A @95 0;JMP (RET_ADDRESS_CALL37) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (bat.draw) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @4 D=A @R13 M=D @screen.drawrectangle D=A @R14 M=D @RET_ADDRESS_CALL38 D=A @95 0;JMP (RET_ADDRESS_CALL38) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (bat.setdirection) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (bat.getleft) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (bat.getright) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @54 0;JMP (bat.setwidth) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.hide D=A @R14 M=D @RET_ADDRESS_CALL39 D=A @95 0;JMP (RET_ADDRESS_CALL39) @SP AM=M-1 D=M @R5 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.show D=A @R14 M=D @RET_ADDRESS_CALL40 D=A @95 0;JMP (RET_ADDRESS_CALL40) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (bat.move) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @RET_ADDRESS_EQ6 D=A @6 0;JMP (RET_ADDRESS_EQ6) @SP AM=M-1 D=M @bat.move$if_true0 D;JNE @bat.move$if_false0 0;JMP (bat.move$if_true0) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT10 D=A @38 0;JMP (RET_ADDRESS_LT10) @SP AM=M-1 D=M @bat.move$if_true1 D;JNE @bat.move$if_false1 0;JMP (bat.move$if_true1) @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @THIS A=M M=D (bat.move$if_false1) @SP M=M+1 A=M-1 M=0 @1 D=A @R13 M=D @screen.setcolor D=A @R14 M=D @RET_ADDRESS_CALL41 D=A @95 0;JMP (RET_ADDRESS_CALL41) @SP AM=M-1 D=M @R5 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @4 D=A @R13 M=D @screen.drawrectangle D=A @R14 M=D @RET_ADDRESS_CALL42 D=A @95 0;JMP (RET_ADDRESS_CALL42) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @1 D=A @R13 M=D @screen.setcolor D=A @R14 M=D @RET_ADDRESS_CALL43 D=A @95 0;JMP (RET_ADDRESS_CALL43) @SP AM=M-1 D=M @R5 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @4 D=A @R13 M=D @screen.drawrectangle D=A @R14 M=D @RET_ADDRESS_CALL44 D=A @95 0;JMP (RET_ADDRESS_CALL44) @SP AM=M-1 D=M @R5 M=D @bat.move$if_end0 0;JMP (bat.move$if_false0) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @511 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT2 D=A @22 0;JMP (RET_ADDRESS_GT2) @SP AM=M-1 D=M @bat.move$if_true2 D;JNE @bat.move$if_false2 0;JMP (bat.move$if_true2) @511 D=A @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M M=D (bat.move$if_false2) @SP M=M+1 A=M-1 M=0 @1 D=A @R13 M=D @screen.setcolor D=A @R14 M=D @RET_ADDRESS_CALL45 D=A @95 0;JMP (RET_ADDRESS_CALL45) @SP AM=M-1 D=M @R5 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @4 D=A @R13 M=D @screen.drawrectangle D=A @R14 M=D @RET_ADDRESS_CALL46 D=A @95 0;JMP (RET_ADDRESS_CALL46) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @1 D=A @R13 M=D @screen.setcolor D=A @R14 M=D @RET_ADDRESS_CALL47 D=A @95 0;JMP (RET_ADDRESS_CALL47) @SP AM=M-1 D=M @R5 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @3 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @4 D=A @R13 M=D @screen.drawrectangle D=A @R14 M=D @RET_ADDRESS_CALL48 D=A @95 0;JMP (RET_ADDRESS_CALL48) @SP AM=M-1 D=M @R5 M=D (bat.move$if_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (main.main) @SP AM=M+1 A=A-1 M=0 @0 D=A @R13 M=D @ponggame.newinstance D=A @R14 M=D @RET_ADDRESS_CALL49 D=A @95 0;JMP (RET_ADDRESS_CALL49) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @ponggame.getinstance D=A @R14 M=D @RET_ADDRESS_CALL50 D=A @95 0;JMP (RET_ADDRESS_CALL50) @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ponggame.run D=A @R14 M=D @RET_ADDRESS_CALL51 D=A @95 0;JMP (RET_ADDRESS_CALL51) @SP AM=M-1 D=M @R5 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ponggame.dispose D=A @R14 M=D @RET_ADDRESS_CALL52 D=A @95 0;JMP (RET_ADDRESS_CALL52) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (ponggame.new) @7 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.alloc D=A @R14 M=D @RET_ADDRESS_CALL53 D=A @95 0;JMP (RET_ADDRESS_CALL53) @SP AM=M-1 D=M @THIS M=D @0 D=A @R13 M=D @screen.clearscreen D=A @R14 M=D @RET_ADDRESS_CALL54 D=A @95 0;JMP (RET_ADDRESS_CALL54) @SP AM=M-1 D=M @R5 M=D @50 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @230 D=A @SP AM=M+1 A=A-1 M=D @229 D=A @SP AM=M+1 A=A-1 M=D @THIS D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @7 D=A @SP AM=M+1 A=A-1 M=D @4 D=A @R13 M=D @bat.new D=A @R14 M=D @RET_ADDRESS_CALL55 D=A @95 0;JMP (RET_ADDRESS_CALL55) @SP AM=M-1 D=M @THIS A=M M=D @253 D=A @SP AM=M+1 A=A-1 M=D @222 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @511 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @229 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @R13 M=D @ball.new D=A @R14 M=D @RET_ADDRESS_CALL56 D=A @95 0;JMP (RET_ADDRESS_CALL56) @SP AM=M-1 D=M @THIS A=M+1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @400 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @3 D=A @R13 M=D @ball.setdestination D=A @R14 M=D @RET_ADDRESS_CALL57 D=A @95 0;JMP (RET_ADDRESS_CALL57) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @238 D=A @SP AM=M+1 A=A-1 M=D @511 D=A @SP AM=M+1 A=A-1 M=D @240 D=A @SP AM=M+1 A=A-1 M=D @4 D=A @R13 M=D @screen.drawrectangle D=A @R14 M=D @RET_ADDRESS_CALL58 D=A @95 0;JMP (RET_ADDRESS_CALL58) @SP AM=M-1 D=M @R5 M=D @22 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @2 D=A @R13 M=D @output.movecursor D=A @R14 M=D @RET_ADDRESS_CALL59 D=A @95 0;JMP (RET_ADDRESS_CALL59) @SP AM=M-1 D=M @R5 M=D @8 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.new D=A @R14 M=D @RET_ADDRESS_CALL60 D=A @95 0;JMP (RET_ADDRESS_CALL60) @83 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL61 D=A @95 0;JMP (RET_ADDRESS_CALL61) @99 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL62 D=A @95 0;JMP (RET_ADDRESS_CALL62) @111 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL63 D=A @95 0;JMP (RET_ADDRESS_CALL63) @114 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL64 D=A @95 0;JMP (RET_ADDRESS_CALL64) @101 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL65 D=A @95 0;JMP (RET_ADDRESS_CALL65) @58 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL66 D=A @95 0;JMP (RET_ADDRESS_CALL66) @32 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL67 D=A @95 0;JMP (RET_ADDRESS_CALL67) @48 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL68 D=A @95 0;JMP (RET_ADDRESS_CALL68) @1 D=A @R13 M=D @output.printstring D=A @R14 M=D @RET_ADDRESS_CALL69 D=A @95 0;JMP (RET_ADDRESS_CALL69) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (ponggame.dispose) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.dispose D=A @R14 M=D @RET_ADDRESS_CALL70 D=A @95 0;JMP (RET_ADDRESS_CALL70) @SP AM=M-1 D=M @R5 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.dispose D=A @R14 M=D @RET_ADDRESS_CALL71 D=A @95 0;JMP (RET_ADDRESS_CALL71) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.dealloc D=A @R14 M=D @RET_ADDRESS_CALL72 D=A @95 0;JMP (RET_ADDRESS_CALL72) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (ponggame.newinstance) @0 D=A @R13 M=D @ponggame.new D=A @R14 M=D @RET_ADDRESS_CALL73 D=A @95 0;JMP (RET_ADDRESS_CALL73) @SP AM=M-1 D=M @ponggame.0 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (ponggame.getinstance) @ponggame.0 D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (ponggame.run) @SP AM=M+1 A=A-1 M=0 @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D (ponggame.run$while_exp0) @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP A=M-1 M=!M @SP AM=M-1 D=M @ponggame.run$while_end0 D;JNE (ponggame.run$while_exp1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ7 D=A @6 0;JMP (RET_ADDRESS_EQ7) @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M A=A-1 M=D&M @SP A=M-1 M=!M @SP AM=M-1 D=M @ponggame.run$while_end1 D;JNE @0 D=A @R13 M=D @keyboard.keypressed D=A @R14 M=D @RET_ADDRESS_CALL74 D=A @95 0;JMP (RET_ADDRESS_CALL74) @SP AM=M-1 D=M @LCL A=M M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.move D=A @R14 M=D @RET_ADDRESS_CALL75 D=A @95 0;JMP (RET_ADDRESS_CALL75) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ponggame.moveball D=A @R14 M=D @RET_ADDRESS_CALL76 D=A @95 0;JMP (RET_ADDRESS_CALL76) @SP AM=M-1 D=M @R5 M=D @ponggame.run$while_exp1 0;JMP (ponggame.run$while_end1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @130 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ8 D=A @6 0;JMP (RET_ADDRESS_EQ8) @SP AM=M-1 D=M @ponggame.run$if_true0 D;JNE @ponggame.run$if_false0 0;JMP (ponggame.run$if_true0) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @2 D=A @R13 M=D @bat.setdirection D=A @R14 M=D @RET_ADDRESS_CALL77 D=A @95 0;JMP (RET_ADDRESS_CALL77) @SP AM=M-1 D=M @R5 M=D @ponggame.run$if_end0 0;JMP (ponggame.run$if_false0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @132 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ9 D=A @6 0;JMP (RET_ADDRESS_EQ9) @SP AM=M-1 D=M @ponggame.run$if_true1 D;JNE @ponggame.run$if_false1 0;JMP (ponggame.run$if_true1) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @bat.setdirection D=A @R14 M=D @RET_ADDRESS_CALL78 D=A @95 0;JMP (RET_ADDRESS_CALL78) @SP AM=M-1 D=M @R5 M=D @ponggame.run$if_end1 0;JMP (ponggame.run$if_false1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @140 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ10 D=A @6 0;JMP (RET_ADDRESS_EQ10) @SP AM=M-1 D=M @ponggame.run$if_true2 D;JNE @ponggame.run$if_false2 0;JMP (ponggame.run$if_true2) @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 M=D (ponggame.run$if_false2) (ponggame.run$if_end1) (ponggame.run$if_end0) (ponggame.run$while_exp2) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ11 D=A @6 0;JMP (RET_ADDRESS_EQ11) @SP A=M-1 M=!M @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M A=A-1 M=D&M @SP A=M-1 M=!M @SP AM=M-1 D=M @ponggame.run$while_end2 D;JNE @0 D=A @R13 M=D @keyboard.keypressed D=A @R14 M=D @RET_ADDRESS_CALL79 D=A @95 0;JMP (RET_ADDRESS_CALL79) @SP AM=M-1 D=M @LCL A=M M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.move D=A @R14 M=D @RET_ADDRESS_CALL80 D=A @95 0;JMP (RET_ADDRESS_CALL80) @SP AM=M-1 D=M @R5 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ponggame.moveball D=A @R14 M=D @RET_ADDRESS_CALL81 D=A @95 0;JMP (RET_ADDRESS_CALL81) @SP AM=M-1 D=M @R5 M=D @ponggame.run$while_exp2 0;JMP (ponggame.run$while_end2) @ponggame.run$while_exp0 0;JMP (ponggame.run$while_end0) @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ponggame.run$if_true3 D;JNE @ponggame.run$if_false3 0;JMP (ponggame.run$if_true3) @10 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @output.movecursor D=A @R14 M=D @RET_ADDRESS_CALL82 D=A @95 0;JMP (RET_ADDRESS_CALL82) @SP AM=M-1 D=M @R5 M=D @9 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.new D=A @R14 M=D @RET_ADDRESS_CALL83 D=A @95 0;JMP (RET_ADDRESS_CALL83) @71 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL84 D=A @95 0;JMP (RET_ADDRESS_CALL84) @97 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL85 D=A @95 0;JMP (RET_ADDRESS_CALL85) @109 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL86 D=A @95 0;JMP (RET_ADDRESS_CALL86) @101 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL87 D=A @95 0;JMP (RET_ADDRESS_CALL87) @32 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL88 D=A @95 0;JMP (RET_ADDRESS_CALL88) @79 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL89 D=A @95 0;JMP (RET_ADDRESS_CALL89) @118 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL90 D=A @95 0;JMP (RET_ADDRESS_CALL90) @101 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL91 D=A @95 0;JMP (RET_ADDRESS_CALL91) @114 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL92 D=A @95 0;JMP (RET_ADDRESS_CALL92) @1 D=A @R13 M=D @output.printstring D=A @R14 M=D @RET_ADDRESS_CALL93 D=A @95 0;JMP (RET_ADDRESS_CALL93) @SP AM=M-1 D=M @R5 M=D (ponggame.run$if_false3) @SP M=M+1 A=M-1 M=0 @54 0;JMP (ponggame.moveball) @5 D=A (LOOP_ponggame.moveball) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_ponggame.moveball D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.move D=A @R14 M=D @RET_ADDRESS_CALL94 D=A @95 0;JMP (RET_ADDRESS_CALL94) @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT3 D=A @22 0;JMP (RET_ADDRESS_GT3) @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ12 D=A @6 0;JMP (RET_ADDRESS_EQ12) @SP A=M-1 M=!M @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M @ponggame.moveball$if_true0 D;JNE @ponggame.moveball$if_false0 0;JMP (ponggame.moveball$if_true0) @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @LCL A=M M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.getleft D=A @R14 M=D @RET_ADDRESS_CALL95 D=A @95 0;JMP (RET_ADDRESS_CALL95) @SP AM=M-1 D=M @LCL A=M+1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @bat.getright D=A @R14 M=D @RET_ADDRESS_CALL96 D=A @95 0;JMP (RET_ADDRESS_CALL96) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.getleft D=A @R14 M=D @RET_ADDRESS_CALL97 D=A @95 0;JMP (RET_ADDRESS_CALL97) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @ball.getright D=A @R14 M=D @RET_ADDRESS_CALL98 D=A @95 0;JMP (RET_ADDRESS_CALL98) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ13 D=A @6 0;JMP (RET_ADDRESS_EQ13) @SP AM=M-1 D=M @ponggame.moveball$if_true1 D;JNE @ponggame.moveball$if_false1 0;JMP (ponggame.moveball$if_true1) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT4 D=A @22 0;JMP (RET_ADDRESS_GT4) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT11 D=A @38 0;JMP (RET_ADDRESS_LT11) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 M=D @THIS D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M @ponggame.moveball$if_true2 D;JNE @ponggame.moveball$if_false2 0;JMP (ponggame.moveball$if_true2) @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @10 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @RET_ADDRESS_LT12 D=A @38 0;JMP (RET_ADDRESS_LT12) @SP AM=M-1 D=M @ponggame.moveball$if_true3 D;JNE @ponggame.moveball$if_false3 0;JMP (ponggame.moveball$if_true3) @SP M=M+1 A=M-1 M=1 @SP A=M-1 D=!M M=D+1 @SP AM=M-1 D=M @LCL A=M M=D @ponggame.moveball$if_end3 0;JMP (ponggame.moveball$if_false3) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @10 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @RET_ADDRESS_GT5 D=A @22 0;JMP (RET_ADDRESS_GT5) @SP AM=M-1 D=M @ponggame.moveball$if_true4 D;JNE @ponggame.moveball$if_false4 0;JMP (ponggame.moveball$if_true4) @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M @LCL A=M M=D (ponggame.moveball$if_false4) (ponggame.moveball$if_end3) @THIS D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @THIS D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @bat.setwidth D=A @R14 M=D @RET_ADDRESS_CALL99 D=A @95 0;JMP (RET_ADDRESS_CALL99) @SP AM=M-1 D=M @R5 M=D @THIS D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M+1 A=A+1 A=A+1 A=A+1 M=D @22 D=A @SP AM=M+1 A=A-1 M=D @7 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @output.movecursor D=A @R14 M=D @RET_ADDRESS_CALL100 D=A @95 0;JMP (RET_ADDRESS_CALL100) @SP AM=M-1 D=M @R5 M=D @THIS D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.printint D=A @R14 M=D @RET_ADDRESS_CALL101 D=A @95 0;JMP (RET_ADDRESS_CALL101) @SP AM=M-1 D=M @R5 M=D (ponggame.moveball$if_false2) (ponggame.moveball$if_false1) @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @ball.bounce D=A @R14 M=D @RET_ADDRESS_CALL102 D=A @95 0;JMP (RET_ADDRESS_CALL102) @SP AM=M-1 D=M @R5 M=D (ponggame.moveball$if_false0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (array.new) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT6 D=A @22 0;JMP (RET_ADDRESS_GT6) @SP A=M-1 M=!M @SP AM=M-1 D=M @array.new$if_true0 D;JNE @array.new$if_false0 0;JMP (array.new$if_true0) @2 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL103 D=A @95 0;JMP (RET_ADDRESS_CALL103) @SP AM=M-1 D=M @R5 M=D (array.new$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.alloc D=A @R14 M=D @RET_ADDRESS_CALL104 D=A @95 0;JMP (RET_ADDRESS_CALL104) @54 0;JMP (array.dispose) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.dealloc D=A @R14 M=D @RET_ADDRESS_CALL105 D=A @95 0;JMP (RET_ADDRESS_CALL105) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (keyboard.init) @SP M=M+1 A=M-1 M=0 @54 0;JMP (keyboard.keypressed) @24576 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.peek D=A @R14 M=D @RET_ADDRESS_CALL106 D=A @95 0;JMP (RET_ADDRESS_CALL106) @54 0;JMP (keyboard.readchar) @SP A=M M=0 AD=A+1 M=0 @SP M=D+1 @SP M=M+1 A=M-1 M=0 @1 D=A @R13 M=D @output.printchar D=A @R14 M=D @RET_ADDRESS_CALL107 D=A @95 0;JMP (RET_ADDRESS_CALL107) @SP AM=M-1 D=M @R5 M=D (keyboard.readchar$while_exp0) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ14 D=A @6 0;JMP (RET_ADDRESS_EQ14) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT7 D=A @22 0;JMP (RET_ADDRESS_GT7) @SP AM=M-1 D=M A=A-1 M=D|M @SP A=M-1 M=!M @SP AM=M-1 D=M @keyboard.readchar$while_end0 D;JNE @0 D=A @R13 M=D @keyboard.keypressed D=A @R14 M=D @RET_ADDRESS_CALL108 D=A @95 0;JMP (RET_ADDRESS_CALL108) @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT8 D=A @22 0;JMP (RET_ADDRESS_GT8) @SP AM=M-1 D=M @keyboard.readchar$if_true0 D;JNE @keyboard.readchar$if_false0 0;JMP (keyboard.readchar$if_true0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D (keyboard.readchar$if_false0) @keyboard.readchar$while_exp0 0;JMP (keyboard.readchar$while_end0) @0 D=A @R13 M=D @string.backspace D=A @R14 M=D @RET_ADDRESS_CALL109 D=A @95 0;JMP (RET_ADDRESS_CALL109) @1 D=A @R13 M=D @output.printchar D=A @R14 M=D @RET_ADDRESS_CALL110 D=A @95 0;JMP (RET_ADDRESS_CALL110) @SP AM=M-1 D=M @R5 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.printchar D=A @R14 M=D @RET_ADDRESS_CALL111 D=A @95 0;JMP (RET_ADDRESS_CALL111) @SP AM=M-1 D=M @R5 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (keyboard.readline) @5 D=A (LOOP_keyboard.readline) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_keyboard.readline D;JGT @80 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.new D=A @R14 M=D @RET_ADDRESS_CALL112 D=A @95 0;JMP (RET_ADDRESS_CALL112) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.printstring D=A @R14 M=D @RET_ADDRESS_CALL113 D=A @95 0;JMP (RET_ADDRESS_CALL113) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @string.newline D=A @R14 M=D @RET_ADDRESS_CALL114 D=A @95 0;JMP (RET_ADDRESS_CALL114) @SP AM=M-1 D=M @LCL A=M+1 M=D @0 D=A @R13 M=D @string.backspace D=A @R14 M=D @RET_ADDRESS_CALL115 D=A @95 0;JMP (RET_ADDRESS_CALL115) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D (keyboard.readline$while_exp0) @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP A=M-1 M=!M @SP AM=M-1 D=M @keyboard.readline$while_end0 D;JNE @0 D=A @R13 M=D @keyboard.readchar D=A @R14 M=D @RET_ADDRESS_CALL116 D=A @95 0;JMP (RET_ADDRESS_CALL116) @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ15 D=A @6 0;JMP (RET_ADDRESS_EQ15) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M @keyboard.readline$if_true0 D;JNE @keyboard.readline$if_false0 0;JMP (keyboard.readline$if_true0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ16 D=A @6 0;JMP (RET_ADDRESS_EQ16) @SP AM=M-1 D=M @keyboard.readline$if_true1 D;JNE @keyboard.readline$if_false1 0;JMP (keyboard.readline$if_true1) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.eraselastchar D=A @R14 M=D @RET_ADDRESS_CALL117 D=A @95 0;JMP (RET_ADDRESS_CALL117) @SP AM=M-1 D=M @R5 M=D @keyboard.readline$if_end1 0;JMP (keyboard.readline$if_false1) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL118 D=A @95 0;JMP (RET_ADDRESS_CALL118) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D (keyboard.readline$if_end1) (keyboard.readline$if_false0) @keyboard.readline$while_exp0 0;JMP (keyboard.readline$while_end0) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (keyboard.readint) @SP A=M M=0 AD=A+1 M=0 @SP M=D+1 @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @keyboard.readline D=A @R14 M=D @RET_ADDRESS_CALL119 D=A @95 0;JMP (RET_ADDRESS_CALL119) @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.intvalue D=A @R14 M=D @RET_ADDRESS_CALL120 D=A @95 0;JMP (RET_ADDRESS_CALL120) @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.dispose D=A @R14 M=D @RET_ADDRESS_CALL121 D=A @95 0;JMP (RET_ADDRESS_CALL121) @SP AM=M-1 D=M @R5 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (math.init) @SP AM=M+1 A=A-1 M=0 @16 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL122 D=A @95 0;JMP (RET_ADDRESS_CALL122) @SP AM=M-1 D=M @math.1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL123 D=A @95 0;JMP (RET_ADDRESS_CALL123) @SP AM=M-1 D=M @math.0 M=D @SP M=M+1 A=M-1 M=0 @math.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D (math.init$while_exp0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT13 D=A @38 0;JMP (RET_ADDRESS_LT13) @SP A=M-1 M=!M @SP AM=M-1 D=M @math.init$while_end0 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @math.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @math.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @math.init$while_exp0 0;JMP (math.init$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (math.abs) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT14 D=A @38 0;JMP (RET_ADDRESS_LT14) @SP AM=M-1 D=M @math.abs$if_true0 D;JNE @math.abs$if_false0 0;JMP (math.abs$if_true0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 D=!M M=D+1 @SP AM=M-1 D=M @ARG A=M M=D (math.abs$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (math.multiply) @5 D=A (LOOP_math.multiply) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_math.multiply D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT15 D=A @38 0;JMP (RET_ADDRESS_LT15) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT9 D=A @22 0;JMP (RET_ADDRESS_GT9) @SP AM=M-1 D=M A=A-1 M=D&M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT10 D=A @22 0;JMP (RET_ADDRESS_GT10) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT16 D=A @38 0;JMP (RET_ADDRESS_LT16) @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @math.abs D=A @R14 M=D @RET_ADDRESS_CALL124 D=A @95 0;JMP (RET_ADDRESS_CALL124) @SP AM=M-1 D=M @ARG A=M M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @math.abs D=A @R14 M=D @RET_ADDRESS_CALL125 D=A @95 0;JMP (RET_ADDRESS_CALL125) @SP AM=M-1 D=M @ARG A=M+1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT17 D=A @38 0;JMP (RET_ADDRESS_LT17) @SP AM=M-1 D=M @math.multiply$if_true0 D;JNE @math.multiply$if_false0 0;JMP (math.multiply$if_true0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M+1 M=D (math.multiply$if_false0) (math.multiply$while_exp0) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT18 D=A @38 0;JMP (RET_ADDRESS_LT18) @SP A=M-1 M=!M @SP AM=M-1 D=M @math.multiply$while_end0 D;JNE @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @math.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D&M @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT11 D=A @22 0;JMP (RET_ADDRESS_GT11) @SP AM=M-1 D=M @math.multiply$if_true1 D;JNE @math.multiply$if_false1 0;JMP (math.multiply$if_true1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @math.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D (math.multiply$if_false1) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @ARG A=M M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @math.multiply$while_exp0 0;JMP (math.multiply$while_end0) @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @math.multiply$if_true2 D;JNE @math.multiply$if_false2 0;JMP (math.multiply$if_true2) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 D=!M M=D+1 @SP AM=M-1 D=M @LCL A=M M=D (math.multiply$if_false2) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (math.divide) @4 D=A (LOOP_math.divide) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_math.divide D;JGT @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ17 D=A @6 0;JMP (RET_ADDRESS_EQ17) @SP AM=M-1 D=M @math.divide$if_true0 D;JNE @math.divide$if_false0 0;JMP (math.divide$if_true0) @3 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL126 D=A @95 0;JMP (RET_ADDRESS_CALL126) @SP AM=M-1 D=M @R5 M=D (math.divide$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT19 D=A @38 0;JMP (RET_ADDRESS_LT19) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT12 D=A @22 0;JMP (RET_ADDRESS_GT12) @SP AM=M-1 D=M A=A-1 M=D&M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT13 D=A @22 0;JMP (RET_ADDRESS_GT13) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT20 D=A @38 0;JMP (RET_ADDRESS_LT20) @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @math.abs D=A @R14 M=D @RET_ADDRESS_CALL127 D=A @95 0;JMP (RET_ADDRESS_CALL127) @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @math.abs D=A @R14 M=D @RET_ADDRESS_CALL128 D=A @95 0;JMP (RET_ADDRESS_CALL128) @SP AM=M-1 D=M @ARG A=M M=D (math.divide$while_exp0) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP A=M-1 M=!M @SP AM=M-1 D=M @math.divide$while_end0 D;JNE @32767 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT21 D=A @38 0;JMP (RET_ADDRESS_LT21) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M @math.divide$if_true1 D;JNE @math.divide$if_false1 0;JMP (math.divide$if_true1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT14 D=A @22 0;JMP (RET_ADDRESS_GT14) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M @math.divide$if_true2 D;JNE @math.divide$if_false2 0;JMP (math.divide$if_true2) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D (math.divide$if_false2) (math.divide$if_false1) @math.divide$while_exp0 0;JMP (math.divide$while_end0) (math.divide$while_exp1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP A=M-1 D=!M M=D+1 @RET_ADDRESS_GT15 D=A @22 0;JMP (RET_ADDRESS_GT15) @SP A=M-1 M=!M @SP AM=M-1 D=M @math.divide$while_end1 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT16 D=A @22 0;JMP (RET_ADDRESS_GT16) @SP A=M-1 M=!M @SP AM=M-1 D=M @math.divide$if_true3 D;JNE @math.divide$if_false3 0;JMP (math.divide$if_true3) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @ARG A=M M=D (math.divide$if_false3) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M M=D @math.divide$while_exp1 0;JMP (math.divide$while_end1) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @math.divide$if_true4 D;JNE @math.divide$if_false4 0;JMP (math.divide$if_true4) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 D=!M M=D+1 @SP AM=M-1 D=M @LCL A=M+1 M=D (math.divide$if_false4) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (math.sqrt) @4 D=A (LOOP_math.sqrt) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_math.sqrt D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT22 D=A @38 0;JMP (RET_ADDRESS_LT22) @SP AM=M-1 D=M @math.sqrt$if_true0 D;JNE @math.sqrt$if_false0 0;JMP (math.sqrt$if_true0) @4 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL129 D=A @95 0;JMP (RET_ADDRESS_CALL129) @SP AM=M-1 D=M @R5 M=D (math.sqrt$if_false0) @7 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D (math.sqrt$while_exp0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP A=M-1 D=!M M=D+1 @RET_ADDRESS_GT17 D=A @22 0;JMP (RET_ADDRESS_GT17) @SP A=M-1 M=!M @SP AM=M-1 D=M @math.sqrt$while_end0 D;JNE @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @math.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL130 D=A @95 0;JMP (RET_ADDRESS_CALL130) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT18 D=A @22 0;JMP (RET_ADDRESS_GT18) @SP A=M-1 M=!M @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT23 D=A @38 0;JMP (RET_ADDRESS_LT23) @SP A=M-1 M=!M @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M @math.sqrt$if_true1 D;JNE @math.sqrt$if_false1 0;JMP (math.sqrt$if_true1) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D (math.sqrt$if_false1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M M=D @math.sqrt$while_exp0 0;JMP (math.sqrt$while_end0) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (math.max) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT19 D=A @22 0;JMP (RET_ADDRESS_GT19) @SP AM=M-1 D=M @math.max$if_true0 D;JNE @math.max$if_false0 0;JMP (math.max$if_true0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M+1 M=D (math.max$if_false0) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (math.min) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT24 D=A @38 0;JMP (RET_ADDRESS_LT24) @SP AM=M-1 D=M @math.min$if_true0 D;JNE @math.min$if_false0 0;JMP (math.min$if_true0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M+1 M=D (math.min$if_false0) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (memory.init) @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @memory.0 M=D @2048 D=A @SP AM=M+1 A=A-1 M=D @memory.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @14334 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @2049 D=A @SP AM=M+1 A=A-1 M=D @memory.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @2050 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (memory.peek) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @memory.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (memory.poke) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @memory.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (memory.alloc) @SP AM=M+1 A=A-1 M=0 @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @RET_ADDRESS_LT25 D=A @38 0;JMP (RET_ADDRESS_LT25) @SP AM=M-1 D=M @memory.alloc$if_true0 D;JNE @memory.alloc$if_false0 0;JMP (memory.alloc$if_true0) @5 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL131 D=A @95 0;JMP (RET_ADDRESS_CALL131) @SP AM=M-1 D=M @R5 M=D (memory.alloc$if_false0) @2048 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D (memory.alloc$while_exp0) @SP M=M+1 A=M-1 M=0 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT26 D=A @38 0;JMP (RET_ADDRESS_LT26) @SP A=M-1 M=!M @SP AM=M-1 D=M @memory.alloc$while_end0 D;JNE @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D @memory.alloc$while_exp0 0;JMP (memory.alloc$while_end0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @16379 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT20 D=A @22 0;JMP (RET_ADDRESS_GT20) @SP AM=M-1 D=M @memory.alloc$if_true1 D;JNE @memory.alloc$if_false1 0;JMP (memory.alloc$if_true1) @6 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL132 D=A @95 0;JMP (RET_ADDRESS_CALL132) @SP AM=M-1 D=M @R5 M=D (memory.alloc$if_false1) @SP M=M+1 A=M-1 M=0 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @RET_ADDRESS_GT21 D=A @22 0;JMP (RET_ADDRESS_GT21) @SP AM=M-1 D=M @memory.alloc$if_true2 D;JNE @memory.alloc$if_false2 0;JMP (memory.alloc$if_true2) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=0 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @RET_ADDRESS_EQ18 D=A @6 0;JMP (RET_ADDRESS_EQ18) @SP AM=M-1 D=M @memory.alloc$if_true3 D;JNE @memory.alloc$if_false3 0;JMP (memory.alloc$if_true3) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @4 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @memory.alloc$if_end3 0;JMP (memory.alloc$if_false3) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D (memory.alloc$if_end3) @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D (memory.alloc$if_false2) @SP M=M+1 A=M-1 M=0 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @54 0;JMP (memory.dealloc) @SP A=M M=0 AD=A+1 M=0 @SP M=D+1 @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M M=D @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D @SP M=M+1 A=M-1 M=0 @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ19 D=A @6 0;JMP (RET_ADDRESS_EQ19) @SP AM=M-1 D=M @memory.dealloc$if_true0 D;JNE @memory.dealloc$if_false0 0;JMP (memory.dealloc$if_true0) @SP M=M+1 A=M-1 M=0 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @memory.dealloc$if_end0 0;JMP (memory.dealloc$if_false0) @SP M=M+1 A=M-1 M=0 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP M=M+1 A=M-1 M=0 @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=1 @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @RET_ADDRESS_EQ20 D=A @6 0;JMP (RET_ADDRESS_EQ20) @SP AM=M-1 D=M @memory.dealloc$if_true1 D;JNE @memory.dealloc$if_false1 0;JMP (memory.dealloc$if_true1) @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @memory.dealloc$if_end1 0;JMP (memory.dealloc$if_false1) @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=1 @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D (memory.dealloc$if_end1) (memory.dealloc$if_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.init) @16384 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @output.4 M=D @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP AM=M-1 D=M @output.2 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @output.1 M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @output.0 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.new D=A @R14 M=D @RET_ADDRESS_CALL133 D=A @95 0;JMP (RET_ADDRESS_CALL133) @SP AM=M-1 D=M @output.3 M=D @0 D=A @R13 M=D @output.initmap D=A @R14 M=D @RET_ADDRESS_CALL134 D=A @95 0;JMP (RET_ADDRESS_CALL134) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @output.createshiftedmap D=A @R14 M=D @RET_ADDRESS_CALL135 D=A @95 0;JMP (RET_ADDRESS_CALL135) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.initmap) @127 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL136 D=A @95 0;JMP (RET_ADDRESS_CALL136) @SP AM=M-1 D=M @output.5 M=D @SP M=M+1 A=M-1 M=0 @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL137 D=A @95 0;JMP (RET_ADDRESS_CALL137) @SP AM=M-1 D=M @R5 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL138 D=A @95 0;JMP (RET_ADDRESS_CALL138) @SP AM=M-1 D=M @R5 M=D @33 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL139 D=A @95 0;JMP (RET_ADDRESS_CALL139) @SP AM=M-1 D=M @R5 M=D @34 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @20 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL140 D=A @95 0;JMP (RET_ADDRESS_CALL140) @SP AM=M-1 D=M @R5 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @18 D=A @SP AM=M+1 A=A-1 M=D @18 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @18 D=A @SP AM=M+1 A=A-1 M=D @18 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @18 D=A @SP AM=M+1 A=A-1 M=D @18 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL141 D=A @95 0;JMP (RET_ADDRESS_CALL141) @SP AM=M-1 D=M @R5 M=D @36 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL142 D=A @95 0;JMP (RET_ADDRESS_CALL142) @SP AM=M-1 D=M @R5 M=D @37 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @35 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @49 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL143 D=A @95 0;JMP (RET_ADDRESS_CALL143) @SP AM=M-1 D=M @R5 M=D @38 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL144 D=A @95 0;JMP (RET_ADDRESS_CALL144) @SP AM=M-1 D=M @R5 M=D @39 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL145 D=A @95 0;JMP (RET_ADDRESS_CALL145) @SP AM=M-1 D=M @R5 M=D @40 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL146 D=A @95 0;JMP (RET_ADDRESS_CALL146) @SP AM=M-1 D=M @R5 M=D @41 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL147 D=A @95 0;JMP (RET_ADDRESS_CALL147) @SP AM=M-1 D=M @R5 M=D @42 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL148 D=A @95 0;JMP (RET_ADDRESS_CALL148) @SP AM=M-1 D=M @R5 M=D @43 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL149 D=A @95 0;JMP (RET_ADDRESS_CALL149) @SP AM=M-1 D=M @R5 M=D @44 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL150 D=A @95 0;JMP (RET_ADDRESS_CALL150) @SP AM=M-1 D=M @R5 M=D @45 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL151 D=A @95 0;JMP (RET_ADDRESS_CALL151) @SP AM=M-1 D=M @R5 M=D @46 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL152 D=A @95 0;JMP (RET_ADDRESS_CALL152) @SP AM=M-1 D=M @R5 M=D @47 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @32 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL153 D=A @95 0;JMP (RET_ADDRESS_CALL153) @SP AM=M-1 D=M @R5 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL154 D=A @95 0;JMP (RET_ADDRESS_CALL154) @SP AM=M-1 D=M @R5 M=D @49 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @14 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL155 D=A @95 0;JMP (RET_ADDRESS_CALL155) @SP AM=M-1 D=M @R5 M=D @50 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL156 D=A @95 0;JMP (RET_ADDRESS_CALL156) @SP AM=M-1 D=M @R5 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL157 D=A @95 0;JMP (RET_ADDRESS_CALL157) @SP AM=M-1 D=M @R5 M=D @52 D=A @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @26 D=A @SP AM=M+1 A=A-1 M=D @25 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @60 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL158 D=A @95 0;JMP (RET_ADDRESS_CALL158) @SP AM=M-1 D=M @R5 M=D @53 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL159 D=A @95 0;JMP (RET_ADDRESS_CALL159) @SP AM=M-1 D=M @R5 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL160 D=A @95 0;JMP (RET_ADDRESS_CALL160) @SP AM=M-1 D=M @R5 M=D @55 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @49 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL161 D=A @95 0;JMP (RET_ADDRESS_CALL161) @SP AM=M-1 D=M @R5 M=D @56 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL162 D=A @95 0;JMP (RET_ADDRESS_CALL162) @SP AM=M-1 D=M @R5 M=D @57 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @62 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @14 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL163 D=A @95 0;JMP (RET_ADDRESS_CALL163) @SP AM=M-1 D=M @R5 M=D @58 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL164 D=A @95 0;JMP (RET_ADDRESS_CALL164) @SP AM=M-1 D=M @R5 M=D @59 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL165 D=A @95 0;JMP (RET_ADDRESS_CALL165) @SP AM=M-1 D=M @R5 M=D @60 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL166 D=A @95 0;JMP (RET_ADDRESS_CALL166) @SP AM=M-1 D=M @R5 M=D @61 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL167 D=A @95 0;JMP (RET_ADDRESS_CALL167) @SP AM=M-1 D=M @R5 M=D @62 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @3 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL168 D=A @95 0;JMP (RET_ADDRESS_CALL168) @SP AM=M-1 D=M @R5 M=D @64 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @59 D=A @SP AM=M+1 A=A-1 M=D @59 D=A @SP AM=M+1 A=A-1 M=D @59 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL169 D=A @95 0;JMP (RET_ADDRESS_CALL169) @SP AM=M-1 D=M @R5 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL170 D=A @95 0;JMP (RET_ADDRESS_CALL170) @SP AM=M-1 D=M @R5 M=D @65 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL171 D=A @95 0;JMP (RET_ADDRESS_CALL171) @SP AM=M-1 D=M @R5 M=D @66 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL172 D=A @95 0;JMP (RET_ADDRESS_CALL172) @SP AM=M-1 D=M @R5 M=D @67 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL173 D=A @95 0;JMP (RET_ADDRESS_CALL173) @SP AM=M-1 D=M @R5 M=D @68 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL174 D=A @95 0;JMP (RET_ADDRESS_CALL174) @SP AM=M-1 D=M @R5 M=D @69 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @11 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @11 D=A @SP AM=M+1 A=A-1 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL175 D=A @95 0;JMP (RET_ADDRESS_CALL175) @SP AM=M-1 D=M @R5 M=D @70 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @11 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @11 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL176 D=A @95 0;JMP (RET_ADDRESS_CALL176) @SP AM=M-1 D=M @R5 M=D @71 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @59 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @44 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL177 D=A @95 0;JMP (RET_ADDRESS_CALL177) @SP AM=M-1 D=M @R5 M=D @72 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL178 D=A @95 0;JMP (RET_ADDRESS_CALL178) @SP AM=M-1 D=M @R5 M=D @73 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL179 D=A @95 0;JMP (RET_ADDRESS_CALL179) @SP AM=M-1 D=M @R5 M=D @74 D=A @SP AM=M+1 A=A-1 M=D @60 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @14 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL180 D=A @95 0;JMP (RET_ADDRESS_CALL180) @SP AM=M-1 D=M @R5 M=D @75 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL181 D=A @95 0;JMP (RET_ADDRESS_CALL181) @SP AM=M-1 D=M @R5 M=D @76 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL182 D=A @95 0;JMP (RET_ADDRESS_CALL182) @SP AM=M-1 D=M @R5 M=D @77 D=A @SP AM=M+1 A=A-1 M=D @33 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL183 D=A @95 0;JMP (RET_ADDRESS_CALL183) @SP AM=M-1 D=M @R5 M=D @78 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @55 D=A @SP AM=M+1 A=A-1 M=D @55 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @59 D=A @SP AM=M+1 A=A-1 M=D @59 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL184 D=A @95 0;JMP (RET_ADDRESS_CALL184) @SP AM=M-1 D=M @R5 M=D @79 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL185 D=A @95 0;JMP (RET_ADDRESS_CALL185) @SP AM=M-1 D=M @R5 M=D @80 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL186 D=A @95 0;JMP (RET_ADDRESS_CALL186) @SP AM=M-1 D=M @R5 M=D @81 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @59 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL187 D=A @95 0;JMP (RET_ADDRESS_CALL187) @SP AM=M-1 D=M @R5 M=D @82 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL188 D=A @95 0;JMP (RET_ADDRESS_CALL188) @SP AM=M-1 D=M @R5 M=D @83 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL189 D=A @95 0;JMP (RET_ADDRESS_CALL189) @SP AM=M-1 D=M @R5 M=D @84 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @45 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL190 D=A @95 0;JMP (RET_ADDRESS_CALL190) @SP AM=M-1 D=M @R5 M=D @85 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL191 D=A @95 0;JMP (RET_ADDRESS_CALL191) @SP AM=M-1 D=M @R5 M=D @86 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL192 D=A @95 0;JMP (RET_ADDRESS_CALL192) @SP AM=M-1 D=M @R5 M=D @87 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @18 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL193 D=A @95 0;JMP (RET_ADDRESS_CALL193) @SP AM=M-1 D=M @R5 M=D @88 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL194 D=A @95 0;JMP (RET_ADDRESS_CALL194) @SP AM=M-1 D=M @R5 M=D @89 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL195 D=A @95 0;JMP (RET_ADDRESS_CALL195) @SP AM=M-1 D=M @R5 M=D @90 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @49 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @35 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL196 D=A @95 0;JMP (RET_ADDRESS_CALL196) @SP AM=M-1 D=M @R5 M=D @91 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL197 D=A @95 0;JMP (RET_ADDRESS_CALL197) @SP AM=M-1 D=M @R5 M=D @92 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=1 @3 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL198 D=A @95 0;JMP (RET_ADDRESS_CALL198) @SP AM=M-1 D=M @R5 M=D @93 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL199 D=A @95 0;JMP (RET_ADDRESS_CALL199) @SP AM=M-1 D=M @R5 M=D @94 D=A @SP AM=M+1 A=A-1 M=D @8 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL200 D=A @95 0;JMP (RET_ADDRESS_CALL200) @SP AM=M-1 D=M @R5 M=D @95 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL201 D=A @95 0;JMP (RET_ADDRESS_CALL201) @SP AM=M-1 D=M @R5 M=D @96 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL202 D=A @95 0;JMP (RET_ADDRESS_CALL202) @SP AM=M-1 D=M @R5 M=D @97 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @14 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL203 D=A @95 0;JMP (RET_ADDRESS_CALL203) @SP AM=M-1 D=M @R5 M=D @98 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL204 D=A @95 0;JMP (RET_ADDRESS_CALL204) @SP AM=M-1 D=M @R5 M=D @99 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL205 D=A @95 0;JMP (RET_ADDRESS_CALL205) @SP AM=M-1 D=M @R5 M=D @100 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @60 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL206 D=A @95 0;JMP (RET_ADDRESS_CALL206) @SP AM=M-1 D=M @R5 M=D @101 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL207 D=A @95 0;JMP (RET_ADDRESS_CALL207) @SP AM=M-1 D=M @R5 M=D @102 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @38 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL208 D=A @95 0;JMP (RET_ADDRESS_CALL208) @SP AM=M-1 D=M @R5 M=D @103 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @62 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL209 D=A @95 0;JMP (RET_ADDRESS_CALL209) @SP AM=M-1 D=M @R5 M=D @104 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @55 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL210 D=A @95 0;JMP (RET_ADDRESS_CALL210) @SP AM=M-1 D=M @R5 M=D @105 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @14 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL211 D=A @95 0;JMP (RET_ADDRESS_CALL211) @SP AM=M-1 D=M @R5 M=D @106 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @56 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL212 D=A @95 0;JMP (RET_ADDRESS_CALL212) @SP AM=M-1 D=M @R5 M=D @107 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL213 D=A @95 0;JMP (RET_ADDRESS_CALL213) @SP AM=M-1 D=M @R5 M=D @108 D=A @SP AM=M+1 A=A-1 M=D @14 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL214 D=A @95 0;JMP (RET_ADDRESS_CALL214) @SP AM=M-1 D=M @R5 M=D @109 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @29 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @43 D=A @SP AM=M+1 A=A-1 M=D @43 D=A @SP AM=M+1 A=A-1 M=D @43 D=A @SP AM=M+1 A=A-1 M=D @43 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL215 D=A @95 0;JMP (RET_ADDRESS_CALL215) @SP AM=M-1 D=M @R5 M=D @110 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @29 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL216 D=A @95 0;JMP (RET_ADDRESS_CALL216) @SP AM=M-1 D=M @R5 M=D @111 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL217 D=A @95 0;JMP (RET_ADDRESS_CALL217) @SP AM=M-1 D=M @R5 M=D @112 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @31 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL218 D=A @95 0;JMP (RET_ADDRESS_CALL218) @SP AM=M-1 D=M @R5 M=D @113 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @62 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL219 D=A @95 0;JMP (RET_ADDRESS_CALL219) @SP AM=M-1 D=M @R5 M=D @114 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @29 D=A @SP AM=M+1 A=A-1 M=D @55 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @3 D=A @SP AM=M+1 A=A-1 M=D @7 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL220 D=A @95 0;JMP (RET_ADDRESS_CALL220) @SP AM=M-1 D=M @R5 M=D @115 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL221 D=A @95 0;JMP (RET_ADDRESS_CALL221) @SP AM=M-1 D=M @R5 M=D @116 D=A @SP AM=M+1 A=A-1 M=D @4 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @28 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL222 D=A @95 0;JMP (RET_ADDRESS_CALL222) @SP AM=M-1 D=M @R5 M=D @117 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @27 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @54 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL223 D=A @95 0;JMP (RET_ADDRESS_CALL223) @SP AM=M-1 D=M @R5 M=D @118 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL224 D=A @95 0;JMP (RET_ADDRESS_CALL224) @SP AM=M-1 D=M @R5 M=D @119 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @18 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL225 D=A @95 0;JMP (RET_ADDRESS_CALL225) @SP AM=M-1 D=M @R5 M=D @120 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @51 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @30 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL226 D=A @95 0;JMP (RET_ADDRESS_CALL226) @SP AM=M-1 D=M @R5 M=D @121 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @62 D=A @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @24 D=A @SP AM=M+1 A=A-1 M=D @15 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL227 D=A @95 0;JMP (RET_ADDRESS_CALL227) @SP AM=M-1 D=M @R5 M=D @122 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @63 D=A @SP AM=M+1 A=A-1 M=D @27 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @6 D=A @SP AM=M+1 A=A-1 M=D @51 D=A @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL228 D=A @95 0;JMP (RET_ADDRESS_CALL228) @SP AM=M-1 D=M @R5 M=D @123 D=A @SP AM=M+1 A=A-1 M=D @56 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @7 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @56 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL229 D=A @95 0;JMP (RET_ADDRESS_CALL229) @SP AM=M-1 D=M @R5 M=D @124 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL230 D=A @95 0;JMP (RET_ADDRESS_CALL230) @SP AM=M-1 D=M @R5 M=D @125 D=A @SP AM=M+1 A=A-1 M=D @7 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @56 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @12 D=A @SP AM=M+1 A=A-1 M=D @7 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL231 D=A @95 0;JMP (RET_ADDRESS_CALL231) @SP AM=M-1 D=M @R5 M=D @126 D=A @SP AM=M+1 A=A-1 M=D @38 D=A @SP AM=M+1 A=A-1 M=D @45 D=A @SP AM=M+1 A=A-1 M=D @25 D=A @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @SP M=M+1 A=M-1 M=0 @12 D=A @R13 M=D @output.create D=A @R14 M=D @RET_ADDRESS_CALL232 D=A @95 0;JMP (RET_ADDRESS_CALL232) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.create) @SP AM=M+1 A=A-1 M=0 @11 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL233 D=A @95 0;JMP (RET_ADDRESS_CALL233) @SP AM=M-1 D=M @LCL A=M M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @output.5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=0 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=1 @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @3 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @4 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @5 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @6 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @7 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @8 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @8 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @9 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @9 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @10 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @10 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG D=M @11 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.createshiftedmap) @4 D=A (LOOP_output.createshiftedmap) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_output.createshiftedmap D;JGT @127 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL234 D=A @95 0;JMP (RET_ADDRESS_CALL234) @SP AM=M-1 D=M @output.6 M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D (output.createshiftedmap$while_exp0) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @127 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT27 D=A @38 0;JMP (RET_ADDRESS_LT27) @SP A=M-1 M=!M @SP AM=M-1 D=M @output.createshiftedmap$while_end0 D;JNE @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @output.5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D @11 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL235 D=A @95 0;JMP (RET_ADDRESS_CALL235) @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @output.6 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D (output.createshiftedmap$while_exp1) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @11 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT28 D=A @38 0;JMP (RET_ADDRESS_LT28) @SP A=M-1 M=!M @SP AM=M-1 D=M @output.createshiftedmap$while_end1 D;JNE @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @256 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL236 D=A @95 0;JMP (RET_ADDRESS_CALL236) @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @output.createshiftedmap$while_exp1 0;JMP (output.createshiftedmap$while_end1) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ21 D=A @6 0;JMP (RET_ADDRESS_EQ21) @SP AM=M-1 D=M @output.createshiftedmap$if_true0 D;JNE @output.createshiftedmap$if_false0 0;JMP (output.createshiftedmap$if_true0) @32 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @output.createshiftedmap$if_end0 0;JMP (output.createshiftedmap$if_false0) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D (output.createshiftedmap$if_end0) @output.createshiftedmap$while_exp0 0;JMP (output.createshiftedmap$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.getmap) @SP AM=M+1 A=A-1 M=0 @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT29 D=A @38 0;JMP (RET_ADDRESS_LT29) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @126 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT22 D=A @22 0;JMP (RET_ADDRESS_GT22) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @output.getmap$if_true0 D;JNE @output.getmap$if_false0 0;JMP (output.getmap$if_true0) @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @ARG A=M M=D (output.getmap$if_false0) @output.2 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @output.getmap$if_true1 D;JNE @output.getmap$if_false1 0;JMP (output.getmap$if_true1) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @output.5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D @output.getmap$if_end1 0;JMP (output.getmap$if_false1) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @output.6 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D (output.getmap$if_end1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (output.drawchar) @4 D=A (LOOP_output.drawchar) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_output.drawchar D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.getmap D=A @R14 M=D @RET_ADDRESS_CALL237 D=A @95 0;JMP (RET_ADDRESS_CALL237) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @output.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D (output.drawchar$while_exp0) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @11 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT30 D=A @38 0;JMP (RET_ADDRESS_LT30) @SP A=M-1 M=!M @SP AM=M-1 D=M @output.drawchar$while_end0 D;JNE @output.2 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @output.drawchar$if_true0 D;JNE @output.drawchar$if_false0 0;JMP (output.drawchar$if_true0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @output.4 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @256 D=A @SP AM=M+1 A=A-1 M=D @SP A=M-1 D=!M M=D+1 @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @output.drawchar$if_end0 0;JMP (output.drawchar$if_false0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @output.4 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @255 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D (output.drawchar$if_end0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @output.4 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 M=D @output.drawchar$while_exp0 0;JMP (output.drawchar$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.movecursor) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT31 D=A @38 0;JMP (RET_ADDRESS_LT31) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @22 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT23 D=A @22 0;JMP (RET_ADDRESS_GT23) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT32 D=A @38 0;JMP (RET_ADDRESS_LT32) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @63 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT24 D=A @22 0;JMP (RET_ADDRESS_GT24) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @output.movecursor$if_true0 D;JNE @output.movecursor$if_false0 0;JMP (output.movecursor$if_true0) @20 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL238 D=A @95 0;JMP (RET_ADDRESS_CALL238) @SP AM=M-1 D=M @R5 M=D (output.movecursor$if_false0) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL239 D=A @95 0;JMP (RET_ADDRESS_CALL239) @SP AM=M-1 D=M @output.0 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @352 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL240 D=A @95 0;JMP (RET_ADDRESS_CALL240) @SP AM=M-1 D=M A=A-1 M=D+M @output.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @output.1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @output.0 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL241 D=A @95 0;JMP (RET_ADDRESS_CALL241) @RET_ADDRESS_EQ22 D=A @6 0;JMP (RET_ADDRESS_EQ22) @SP AM=M-1 D=M @output.2 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.drawchar D=A @R14 M=D @RET_ADDRESS_CALL242 D=A @95 0;JMP (RET_ADDRESS_CALL242) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.printchar) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @0 D=A @R13 M=D @string.newline D=A @R14 M=D @RET_ADDRESS_CALL243 D=A @95 0;JMP (RET_ADDRESS_CALL243) @RET_ADDRESS_EQ23 D=A @6 0;JMP (RET_ADDRESS_EQ23) @SP AM=M-1 D=M @output.printchar$if_true0 D;JNE @output.printchar$if_false0 0;JMP (output.printchar$if_true0) @0 D=A @R13 M=D @output.println D=A @R14 M=D @RET_ADDRESS_CALL244 D=A @95 0;JMP (RET_ADDRESS_CALL244) @SP AM=M-1 D=M @R5 M=D @output.printchar$if_end0 0;JMP (output.printchar$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @0 D=A @R13 M=D @string.backspace D=A @R14 M=D @RET_ADDRESS_CALL245 D=A @95 0;JMP (RET_ADDRESS_CALL245) @RET_ADDRESS_EQ24 D=A @6 0;JMP (RET_ADDRESS_EQ24) @SP AM=M-1 D=M @output.printchar$if_true1 D;JNE @output.printchar$if_false1 0;JMP (output.printchar$if_true1) @0 D=A @R13 M=D @output.backspace D=A @R14 M=D @RET_ADDRESS_CALL246 D=A @95 0;JMP (RET_ADDRESS_CALL246) @SP AM=M-1 D=M @R5 M=D @output.printchar$if_end1 0;JMP (output.printchar$if_false1) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.drawchar D=A @R14 M=D @RET_ADDRESS_CALL247 D=A @95 0;JMP (RET_ADDRESS_CALL247) @SP AM=M-1 D=M @R5 M=D @output.2 D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M @output.printchar$if_true2 D;JNE @output.printchar$if_false2 0;JMP (output.printchar$if_true2) @output.0 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @output.0 M=D @output.1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @output.1 M=D (output.printchar$if_false2) @output.0 D=M @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ25 D=A @6 0;JMP (RET_ADDRESS_EQ25) @SP AM=M-1 D=M @output.printchar$if_true3 D;JNE @output.printchar$if_false3 0;JMP (output.printchar$if_true3) @0 D=A @R13 M=D @output.println D=A @R14 M=D @RET_ADDRESS_CALL248 D=A @95 0;JMP (RET_ADDRESS_CALL248) @SP AM=M-1 D=M @R5 M=D @output.printchar$if_end3 0;JMP (output.printchar$if_false3) @output.2 D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M @output.2 M=D (output.printchar$if_end3) (output.printchar$if_end1) (output.printchar$if_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.printstring) @SP A=M M=0 AD=A+1 M=0 @SP M=D+1 @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.length D=A @R14 M=D @RET_ADDRESS_CALL249 D=A @95 0;JMP (RET_ADDRESS_CALL249) @SP AM=M-1 D=M @LCL A=M+1 M=D (output.printstring$while_exp0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT33 D=A @38 0;JMP (RET_ADDRESS_LT33) @SP A=M-1 M=!M @SP AM=M-1 D=M @output.printstring$while_end0 D;JNE @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.charat D=A @R14 M=D @RET_ADDRESS_CALL250 D=A @95 0;JMP (RET_ADDRESS_CALL250) @1 D=A @R13 M=D @output.printchar D=A @R14 M=D @RET_ADDRESS_CALL251 D=A @95 0;JMP (RET_ADDRESS_CALL251) @SP AM=M-1 D=M @R5 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @output.printstring$while_exp0 0;JMP (output.printstring$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.printint) @output.3 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.setint D=A @R14 M=D @RET_ADDRESS_CALL252 D=A @95 0;JMP (RET_ADDRESS_CALL252) @SP AM=M-1 D=M @R5 M=D @output.3 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.printstring D=A @R14 M=D @RET_ADDRESS_CALL253 D=A @95 0;JMP (RET_ADDRESS_CALL253) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.println) @output.1 D=M @SP AM=M+1 A=A-1 M=D @352 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @output.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @output.1 M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @output.0 M=D @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP AM=M-1 D=M @output.2 M=D @output.1 D=M @SP AM=M+1 A=A-1 M=D @8128 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ26 D=A @6 0;JMP (RET_ADDRESS_EQ26) @SP AM=M-1 D=M @output.println$if_true0 D;JNE @output.println$if_false0 0;JMP (output.println$if_true0) @32 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @output.1 M=D (output.println$if_false0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (output.backspace) @output.2 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @output.backspace$if_true0 D;JNE @output.backspace$if_false0 0;JMP (output.backspace$if_true0) @output.0 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT25 D=A @22 0;JMP (RET_ADDRESS_GT25) @SP AM=M-1 D=M @output.backspace$if_true1 D;JNE @output.backspace$if_false1 0;JMP (output.backspace$if_true1) @output.0 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @output.0 M=D @output.1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @output.1 M=D @output.backspace$if_end1 0;JMP (output.backspace$if_false1) @31 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @output.0 M=D @output.1 D=M @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ27 D=A @6 0;JMP (RET_ADDRESS_EQ27) @SP AM=M-1 D=M @output.backspace$if_true2 D;JNE @output.backspace$if_false2 0;JMP (output.backspace$if_true2) @8128 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @output.1 M=D (output.backspace$if_false2) @output.1 D=M @SP AM=M+1 A=A-1 M=D @321 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @output.1 M=D (output.backspace$if_end1) @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @output.2 M=D @output.backspace$if_end0 0;JMP (output.backspace$if_false0) @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP AM=M-1 D=M @output.2 M=D (output.backspace$if_end0) @32 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.drawchar D=A @R14 M=D @RET_ADDRESS_CALL254 D=A @95 0;JMP (RET_ADDRESS_CALL254) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.init) @SP AM=M+1 A=A-1 M=0 @16384 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @screen.1 M=D @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP AM=M-1 D=M @screen.2 M=D @17 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL255 D=A @95 0;JMP (RET_ADDRESS_CALL255) @SP AM=M-1 D=M @screen.0 M=D @SP M=M+1 A=M-1 M=0 @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D (screen.init$while_exp0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT34 D=A @38 0;JMP (RET_ADDRESS_LT34) @SP A=M-1 M=!M @SP AM=M-1 D=M @screen.init$while_end0 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @screen.init$while_exp0 0;JMP (screen.init$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.clearscreen) @SP AM=M+1 A=A-1 M=0 (screen.clearscreen$while_exp0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @8192 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT35 D=A @38 0;JMP (RET_ADDRESS_LT35) @SP A=M-1 M=!M @SP AM=M-1 D=M @screen.clearscreen$while_end0 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @screen.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @screen.clearscreen$while_exp0 0;JMP (screen.clearscreen$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.updatelocation) @screen.2 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @screen.updatelocation$if_true0 D;JNE @screen.updatelocation$if_false0 0;JMP (screen.updatelocation$if_true0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @screen.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @screen.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @screen.updatelocation$if_end0 0;JMP (screen.updatelocation$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @screen.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @screen.1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D (screen.updatelocation$if_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.setcolor) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @screen.2 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.drawpixel) @3 D=A (LOOP_screen.drawpixel) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_screen.drawpixel D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT36 D=A @38 0;JMP (RET_ADDRESS_LT36) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @511 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT26 D=A @22 0;JMP (RET_ADDRESS_GT26) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT37 D=A @38 0;JMP (RET_ADDRESS_LT37) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @255 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT27 D=A @22 0;JMP (RET_ADDRESS_GT27) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @screen.drawpixel$if_true0 D;JNE @screen.drawpixel$if_false0 0;JMP (screen.drawpixel$if_true0) @7 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL256 D=A @95 0;JMP (RET_ADDRESS_CALL256) @SP AM=M-1 D=M @R5 M=D (screen.drawpixel$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL257 D=A @95 0;JMP (RET_ADDRESS_CALL257) @SP AM=M-1 D=M @LCL A=M M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL258 D=A @95 0;JMP (RET_ADDRESS_CALL258) @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL259 D=A @95 0;JMP (RET_ADDRESS_CALL259) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL260 D=A @95 0;JMP (RET_ADDRESS_CALL260) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.drawconditional) @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @screen.drawconditional$if_true0 D;JNE @screen.drawconditional$if_false0 0;JMP (screen.drawconditional$if_true0) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @screen.drawpixel D=A @R14 M=D @RET_ADDRESS_CALL261 D=A @95 0;JMP (RET_ADDRESS_CALL261) @SP AM=M-1 D=M @R5 M=D @screen.drawconditional$if_end0 0;JMP (screen.drawconditional$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @screen.drawpixel D=A @R14 M=D @RET_ADDRESS_CALL262 D=A @95 0;JMP (RET_ADDRESS_CALL262) @SP AM=M-1 D=M @R5 M=D (screen.drawconditional$if_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.drawline) @11 D=A (LOOP_screen.drawline) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_screen.drawline D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT38 D=A @38 0;JMP (RET_ADDRESS_LT38) @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @511 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT28 D=A @22 0;JMP (RET_ADDRESS_GT28) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT39 D=A @38 0;JMP (RET_ADDRESS_LT39) @SP AM=M-1 D=M A=A-1 M=D|M @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @255 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT29 D=A @22 0;JMP (RET_ADDRESS_GT29) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @screen.drawline$if_true0 D;JNE @screen.drawline$if_false0 0;JMP (screen.drawline$if_true0) @8 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL263 D=A @95 0;JMP (RET_ADDRESS_CALL263) @SP AM=M-1 D=M @R5 M=D (screen.drawline$if_false0) @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @1 D=A @R13 M=D @math.abs D=A @R14 M=D @RET_ADDRESS_CALL264 D=A @95 0;JMP (RET_ADDRESS_CALL264) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @1 D=A @R13 M=D @math.abs D=A @R14 M=D @RET_ADDRESS_CALL265 D=A @95 0;JMP (RET_ADDRESS_CALL265) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT40 D=A @38 0;JMP (RET_ADDRESS_LT40) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT41 D=A @38 0;JMP (RET_ADDRESS_LT41) @SP AM=M-1 D=M A=A-1 M=D&M @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 M=!M @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT42 D=A @38 0;JMP (RET_ADDRESS_LT42) @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @screen.drawline$if_true1 D;JNE @screen.drawline$if_false1 0;JMP (screen.drawline$if_true1) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M+1 A=A+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M+1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M+1 A=A+1 A=A+1 M=D (screen.drawline$if_false1) @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @screen.drawline$if_true2 D;JNE @screen.drawline$if_false2 0;JMP (screen.drawline$if_true2) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @8 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT30 D=A @22 0;JMP (RET_ADDRESS_GT30) @LCL D=M @7 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @screen.drawline$if_end2 0;JMP (screen.drawline$if_false2) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @8 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT31 D=A @22 0;JMP (RET_ADDRESS_GT31) @LCL D=M @7 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D (screen.drawline$if_end2) @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL266 D=A @95 0;JMP (RET_ADDRESS_CALL266) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL267 D=A @95 0;JMP (RET_ADDRESS_CALL267) @LCL D=M @9 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL268 D=A @95 0;JMP (RET_ADDRESS_CALL268) @LCL D=M @10 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @3 D=A @R13 M=D @screen.drawconditional D=A @R14 M=D @RET_ADDRESS_CALL269 D=A @95 0;JMP (RET_ADDRESS_CALL269) @SP AM=M-1 D=M @R5 M=D (screen.drawline$while_exp0) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @8 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT43 D=A @38 0;JMP (RET_ADDRESS_LT43) @SP A=M-1 M=!M @SP AM=M-1 D=M @screen.drawline$while_end0 D;JNE @LCL D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT44 D=A @38 0;JMP (RET_ADDRESS_LT44) @SP AM=M-1 D=M @screen.drawline$if_true3 D;JNE @screen.drawline$if_false3 0;JMP (screen.drawline$if_true3) @LCL D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @9 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @screen.drawline$if_end3 0;JMP (screen.drawline$if_false3) @LCL D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @10 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @LCL D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @screen.drawline$if_true4 D;JNE @screen.drawline$if_false4 0;JMP (screen.drawline$if_true4) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M M=D @screen.drawline$if_end4 0;JMP (screen.drawline$if_false4) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D (screen.drawline$if_end4) (screen.drawline$if_end3) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @3 D=A @R13 M=D @screen.drawconditional D=A @R14 M=D @RET_ADDRESS_CALL270 D=A @95 0;JMP (RET_ADDRESS_CALL270) @SP AM=M-1 D=M @R5 M=D @screen.drawline$while_exp0 0;JMP (screen.drawline$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.drawrectangle) @9 D=A (LOOP_screen.drawrectangle) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_screen.drawrectangle D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT32 D=A @22 0;JMP (RET_ADDRESS_GT32) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT33 D=A @22 0;JMP (RET_ADDRESS_GT33) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT45 D=A @38 0;JMP (RET_ADDRESS_LT45) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @511 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT34 D=A @22 0;JMP (RET_ADDRESS_GT34) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT46 D=A @38 0;JMP (RET_ADDRESS_LT46) @SP AM=M-1 D=M A=A-1 M=D|M @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @255 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT35 D=A @22 0;JMP (RET_ADDRESS_GT35) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @screen.drawrectangle$if_true0 D;JNE @screen.drawrectangle$if_false0 0;JMP (screen.drawrectangle$if_true0) @9 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL271 D=A @95 0;JMP (RET_ADDRESS_CALL271) @SP AM=M-1 D=M @R5 M=D (screen.drawrectangle$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL272 D=A @95 0;JMP (RET_ADDRESS_CALL272) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL273 D=A @95 0;JMP (RET_ADDRESS_CALL273) @SP AM=M-1 D=M A=A-1 M=M-D @LCL D=M @7 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL274 D=A @95 0;JMP (RET_ADDRESS_CALL274) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL275 D=A @95 0;JMP (RET_ADDRESS_CALL275) @SP AM=M-1 D=M A=A-1 M=M-D @LCL D=M @8 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @LCL D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP A=M-1 M=!M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @LCL D=M @8 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL276 D=A @95 0;JMP (RET_ADDRESS_CALL276) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D (screen.drawrectangle$while_exp0) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT36 D=A @22 0;JMP (RET_ADDRESS_GT36) @SP A=M-1 M=!M @SP A=M-1 M=!M @SP AM=M-1 D=M @screen.drawrectangle$while_end0 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ28 D=A @6 0;JMP (RET_ADDRESS_EQ28) @SP AM=M-1 D=M @screen.drawrectangle$if_true1 D;JNE @screen.drawrectangle$if_false1 0;JMP (screen.drawrectangle$if_true1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D&M @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL277 D=A @95 0;JMP (RET_ADDRESS_CALL277) @SP AM=M-1 D=M @R5 M=D @screen.drawrectangle$if_end1 0;JMP (screen.drawrectangle$if_false1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL278 D=A @95 0;JMP (RET_ADDRESS_CALL278) @SP AM=M-1 D=M @R5 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D (screen.drawrectangle$while_exp1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT47 D=A @38 0;JMP (RET_ADDRESS_LT47) @SP A=M-1 M=!M @SP AM=M-1 D=M @screen.drawrectangle$while_end1 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP A=M-1 D=!M M=D+1 @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL279 D=A @95 0;JMP (RET_ADDRESS_CALL279) @SP AM=M-1 D=M @R5 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @screen.drawrectangle$while_exp1 0;JMP (screen.drawrectangle$while_end1) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL280 D=A @95 0;JMP (RET_ADDRESS_CALL280) @SP AM=M-1 D=M @R5 M=D (screen.drawrectangle$if_end1) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @ARG A=M+1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M M=D @screen.drawrectangle$while_exp0 0;JMP (screen.drawrectangle$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.drawhorizontal) @11 D=A (LOOP_screen.drawhorizontal) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_screen.drawhorizontal D;JGT @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.min D=A @R14 M=D @RET_ADDRESS_CALL281 D=A @95 0;JMP (RET_ADDRESS_CALL281) @LCL D=M @7 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.max D=A @R14 M=D @RET_ADDRESS_CALL282 D=A @95 0;JMP (RET_ADDRESS_CALL282) @LCL D=M @8 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP A=M-1 D=!M M=D+1 @RET_ADDRESS_GT37 D=A @22 0;JMP (RET_ADDRESS_GT37) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @256 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT48 D=A @38 0;JMP (RET_ADDRESS_LT48) @SP AM=M-1 D=M A=A-1 M=D&M @LCL D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @512 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT49 D=A @38 0;JMP (RET_ADDRESS_LT49) @SP AM=M-1 D=M A=A-1 M=D&M @LCL D=M @8 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP A=M-1 D=!M M=D+1 @RET_ADDRESS_GT38 D=A @22 0;JMP (RET_ADDRESS_GT38) @SP AM=M-1 D=M A=A-1 M=D&M @SP AM=M-1 D=M @screen.drawhorizontal$if_true0 D;JNE @screen.drawhorizontal$if_false0 0;JMP (screen.drawhorizontal$if_true0) @LCL D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @2 D=A @R13 M=D @math.max D=A @R14 M=D @RET_ADDRESS_CALL283 D=A @95 0;JMP (RET_ADDRESS_CALL283) @LCL D=M @7 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @LCL D=M @8 A=D+A D=M @SP AM=M+1 A=A-1 M=D @511 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.min D=A @R14 M=D @RET_ADDRESS_CALL284 D=A @95 0;JMP (RET_ADDRESS_CALL284) @LCL D=M @8 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @LCL D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL285 D=A @95 0;JMP (RET_ADDRESS_CALL285) @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL D=M @7 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL286 D=A @95 0;JMP (RET_ADDRESS_CALL286) @SP AM=M-1 D=M A=A-1 M=M-D @LCL D=M @9 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @LCL D=M @8 A=D+A D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL287 D=A @95 0;JMP (RET_ADDRESS_CALL287) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @LCL D=M @8 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @16 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL288 D=A @95 0;JMP (RET_ADDRESS_CALL288) @SP AM=M-1 D=M A=A-1 M=M-D @LCL D=M @10 D=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @LCL D=M @9 A=D+A D=M @SP AM=M+1 A=A-1 M=D @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP A=M-1 M=!M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @LCL D=M @10 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @screen.0 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @32 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL289 D=A @95 0;JMP (RET_ADDRESS_CALL289) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 A=A+1 A=A+1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @LCL D=M @6 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ29 D=A @6 0;JMP (RET_ADDRESS_EQ29) @SP AM=M-1 D=M @screen.drawhorizontal$if_true1 D;JNE @screen.drawhorizontal$if_false1 0;JMP (screen.drawhorizontal$if_true1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D&M @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL290 D=A @95 0;JMP (RET_ADDRESS_CALL290) @SP AM=M-1 D=M @R5 M=D @screen.drawhorizontal$if_end1 0;JMP (screen.drawhorizontal$if_false1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @5 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL291 D=A @95 0;JMP (RET_ADDRESS_CALL291) @SP AM=M-1 D=M @R5 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D (screen.drawhorizontal$while_exp0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT50 D=A @38 0;JMP (RET_ADDRESS_LT50) @SP A=M-1 M=!M @SP AM=M-1 D=M @screen.drawhorizontal$while_end0 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP A=M-1 D=!M M=D+1 @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL292 D=A @95 0;JMP (RET_ADDRESS_CALL292) @SP AM=M-1 D=M @R5 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @screen.drawhorizontal$while_exp0 0;JMP (screen.drawhorizontal$while_end0) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @screen.updatelocation D=A @R14 M=D @RET_ADDRESS_CALL293 D=A @95 0;JMP (RET_ADDRESS_CALL293) @SP AM=M-1 D=M @R5 M=D (screen.drawhorizontal$if_end1) (screen.drawhorizontal$if_false0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.drawsymetric) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @3 D=A @R13 M=D @screen.drawhorizontal D=A @R14 M=D @RET_ADDRESS_CALL294 D=A @95 0;JMP (RET_ADDRESS_CALL294) @SP AM=M-1 D=M @R5 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @3 D=A @R13 M=D @screen.drawhorizontal D=A @R14 M=D @RET_ADDRESS_CALL295 D=A @95 0;JMP (RET_ADDRESS_CALL295) @SP AM=M-1 D=M @R5 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @3 D=A @R13 M=D @screen.drawhorizontal D=A @R14 M=D @RET_ADDRESS_CALL296 D=A @95 0;JMP (RET_ADDRESS_CALL296) @SP AM=M-1 D=M @R5 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @3 D=A @R13 M=D @screen.drawhorizontal D=A @R14 M=D @RET_ADDRESS_CALL297 D=A @95 0;JMP (RET_ADDRESS_CALL297) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (screen.drawcircle) @3 D=A (LOOP_screen.drawcircle) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_screen.drawcircle D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT51 D=A @38 0;JMP (RET_ADDRESS_LT51) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @511 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT39 D=A @22 0;JMP (RET_ADDRESS_GT39) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT52 D=A @38 0;JMP (RET_ADDRESS_LT52) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @255 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT40 D=A @22 0;JMP (RET_ADDRESS_GT40) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @screen.drawcircle$if_true0 D;JNE @screen.drawcircle$if_false0 0;JMP (screen.drawcircle$if_true0) @12 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL298 D=A @95 0;JMP (RET_ADDRESS_CALL298) @SP AM=M-1 D=M @R5 M=D (screen.drawcircle$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT53 D=A @38 0;JMP (RET_ADDRESS_LT53) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @511 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT41 D=A @22 0;JMP (RET_ADDRESS_GT41) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT54 D=A @38 0;JMP (RET_ADDRESS_LT54) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @255 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT42 D=A @22 0;JMP (RET_ADDRESS_GT42) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @screen.drawcircle$if_true1 D;JNE @screen.drawcircle$if_false1 0;JMP (screen.drawcircle$if_true1) @13 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL299 D=A @95 0;JMP (RET_ADDRESS_CALL299) @SP AM=M-1 D=M @R5 M=D (screen.drawcircle$if_false1) @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D @SP M=M+1 A=M-1 M=1 @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @4 D=A @R13 M=D @screen.drawsymetric D=A @R14 M=D @RET_ADDRESS_CALL300 D=A @95 0;JMP (RET_ADDRESS_CALL300) @SP AM=M-1 D=M @R5 M=D (screen.drawcircle$while_exp0) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT43 D=A @22 0;JMP (RET_ADDRESS_GT43) @SP A=M-1 M=!M @SP AM=M-1 D=M @screen.drawcircle$while_end0 D;JNE @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT55 D=A @38 0;JMP (RET_ADDRESS_LT55) @SP AM=M-1 D=M @screen.drawcircle$if_true2 D;JNE @screen.drawcircle$if_false2 0;JMP (screen.drawcircle$if_true2) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL301 D=A @95 0;JMP (RET_ADDRESS_CALL301) @SP AM=M-1 D=M A=A-1 M=D+M @3 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @screen.drawcircle$if_end2 0;JMP (screen.drawcircle$if_false2) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @2 D=A @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL302 D=A @95 0;JMP (RET_ADDRESS_CALL302) @SP AM=M-1 D=M A=A-1 M=D+M @5 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 M=D (screen.drawcircle$if_end2) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @4 D=A @R13 M=D @screen.drawsymetric D=A @R14 M=D @RET_ADDRESS_CALL303 D=A @95 0;JMP (RET_ADDRESS_CALL303) @SP AM=M-1 D=M @R5 M=D @screen.drawcircle$while_exp0 0;JMP (screen.drawcircle$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (string.new) @3 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.alloc D=A @R14 M=D @RET_ADDRESS_CALL304 D=A @95 0;JMP (RET_ADDRESS_CALL304) @SP AM=M-1 D=M @THIS M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT56 D=A @38 0;JMP (RET_ADDRESS_LT56) @SP AM=M-1 D=M @string.new$if_true0 D;JNE @string.new$if_false0 0;JMP (string.new$if_true0) @14 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL305 D=A @95 0;JMP (RET_ADDRESS_CALL305) @SP AM=M-1 D=M @R5 M=D (string.new$if_false0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT44 D=A @22 0;JMP (RET_ADDRESS_GT44) @SP AM=M-1 D=M @string.new$if_true1 D;JNE @string.new$if_false1 0;JMP (string.new$if_true1) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL306 D=A @95 0;JMP (RET_ADDRESS_CALL306) @SP AM=M-1 D=M @THIS A=M+1 M=D (string.new$if_false1) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS A=M M=D @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (string.dispose) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT45 D=A @22 0;JMP (RET_ADDRESS_GT45) @SP AM=M-1 D=M @string.dispose$if_true0 D;JNE @string.dispose$if_false0 0;JMP (string.dispose$if_true0) @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.dispose D=A @R14 M=D @RET_ADDRESS_CALL307 D=A @95 0;JMP (RET_ADDRESS_CALL307) @SP AM=M-1 D=M @R5 M=D (string.dispose$if_false0) @THIS D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @memory.dealloc D=A @R14 M=D @RET_ADDRESS_CALL308 D=A @95 0;JMP (RET_ADDRESS_CALL308) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (string.length) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (string.charat) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT57 D=A @38 0;JMP (RET_ADDRESS_LT57) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT46 D=A @22 0;JMP (RET_ADDRESS_GT46) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ30 D=A @6 0;JMP (RET_ADDRESS_EQ30) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @string.charat$if_true0 D;JNE @string.charat$if_false0 0;JMP (string.charat$if_true0) @15 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL309 D=A @95 0;JMP (RET_ADDRESS_CALL309) @SP AM=M-1 D=M @R5 M=D (string.charat$if_false0) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (string.setcharat) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT58 D=A @38 0;JMP (RET_ADDRESS_LT58) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT47 D=A @22 0;JMP (RET_ADDRESS_GT47) @SP AM=M-1 D=M A=A-1 M=D|M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ31 D=A @6 0;JMP (RET_ADDRESS_EQ31) @SP AM=M-1 D=M A=A-1 M=D|M @SP AM=M-1 D=M @string.setcharat$if_true0 D;JNE @string.setcharat$if_false0 0;JMP (string.setcharat$if_true0) @16 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL310 D=A @95 0;JMP (RET_ADDRESS_CALL310) @SP AM=M-1 D=M @R5 M=D (string.setcharat$if_false0) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (string.appendchar) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ32 D=A @6 0;JMP (RET_ADDRESS_EQ32) @SP AM=M-1 D=M @string.appendchar$if_true0 D;JNE @string.appendchar$if_false0 0;JMP (string.appendchar$if_true0) @17 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL311 D=A @95 0;JMP (RET_ADDRESS_CALL311) @SP AM=M-1 D=M @R5 M=D (string.appendchar$if_false0) @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @THIS D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (string.eraselastchar) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ33 D=A @6 0;JMP (RET_ADDRESS_EQ33) @SP AM=M-1 D=M @string.eraselastchar$if_true0 D;JNE @string.eraselastchar$if_false0 0;JMP (string.eraselastchar$if_true0) @18 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL312 D=A @95 0;JMP (RET_ADDRESS_CALL312) @SP AM=M-1 D=M @R5 M=D (string.eraselastchar$if_false0) @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (string.intvalue) @5 D=A (LOOP_string.intvalue) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_string.intvalue D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ34 D=A @6 0;JMP (RET_ADDRESS_EQ34) @SP AM=M-1 D=M @string.intvalue$if_true0 D;JNE @string.intvalue$if_false0 0;JMP (string.intvalue$if_true0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (string.intvalue$if_false0) @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @SP M=M+1 A=M-1 M=0 @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @45 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_EQ35 D=A @6 0;JMP (RET_ADDRESS_EQ35) @SP AM=M-1 D=M @string.intvalue$if_true1 D;JNE @string.intvalue$if_false1 0;JMP (string.intvalue$if_true1) @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 A=A+1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M @LCL A=M M=D (string.intvalue$if_false1) (string.intvalue$while_exp0) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT59 D=A @38 0;JMP (RET_ADDRESS_LT59) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D&M @SP A=M-1 M=!M @SP AM=M-1 D=M @string.intvalue$while_end0 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @48 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT60 D=A @38 0;JMP (RET_ADDRESS_LT60) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @9 D=A @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_GT48 D=A @22 0;JMP (RET_ADDRESS_GT48) @SP AM=M-1 D=M A=A-1 M=D|M @SP A=M-1 M=!M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @string.intvalue$if_true2 D;JNE @string.intvalue$if_false2 0;JMP (string.intvalue$if_true2) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @10 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL313 D=A @95 0;JMP (RET_ADDRESS_CALL313) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D (string.intvalue$if_false2) @string.intvalue$while_exp0 0;JMP (string.intvalue$while_end0) @LCL D=M @4 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @string.intvalue$if_true3 D;JNE @string.intvalue$if_false3 0;JMP (string.intvalue$if_true3) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 D=!M M=D+1 @SP AM=M-1 D=M @LCL A=M+1 M=D (string.intvalue$if_false3) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @54 0;JMP (string.setint) @4 D=A (LOOP_string.setint) D=D-1 @SP AM=M+1 A=A-1 M=0 @LOOP_string.setint D;JGT @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THIS M=D @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ36 D=A @6 0;JMP (RET_ADDRESS_EQ36) @SP AM=M-1 D=M @string.setint$if_true0 D;JNE @string.setint$if_false0 0;JMP (string.setint$if_true0) @19 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL314 D=A @95 0;JMP (RET_ADDRESS_CALL314) @SP AM=M-1 D=M @R5 M=D (string.setint$if_false0) @6 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.new D=A @R14 M=D @RET_ADDRESS_CALL315 D=A @95 0;JMP (RET_ADDRESS_CALL315) @SP AM=M-1 D=M @LCL A=M+1 A=A+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT61 D=A @38 0;JMP (RET_ADDRESS_LT61) @SP AM=M-1 D=M @string.setint$if_true1 D;JNE @string.setint$if_false1 0;JMP (string.setint$if_true1) @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP AM=M-1 D=M @LCL A=M+1 A=A+1 A=A+1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP A=M-1 D=!M M=D+1 @SP AM=M-1 D=M @ARG A=M+1 M=D (string.setint$if_false1) @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M+1 M=D (string.setint$while_exp0) @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT49 D=A @22 0;JMP (RET_ADDRESS_GT49) @SP A=M-1 M=!M @SP AM=M-1 D=M @string.setint$while_end0 D;JNE @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @10 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.divide D=A @R14 M=D @RET_ADDRESS_CALL316 D=A @95 0;JMP (RET_ADDRESS_CALL316) @SP AM=M-1 D=M @LCL A=M+1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @48 D=A @SP AM=M+1 A=A-1 M=D @ARG A=M+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @10 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @math.multiply D=A @R14 M=D @RET_ADDRESS_CALL317 D=A @95 0;JMP (RET_ADDRESS_CALL317) @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D @LCL A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @ARG A=M+1 M=D @string.setint$while_exp0 0;JMP (string.setint$while_end0) @LCL D=M @3 A=D+A D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @string.setint$if_true2 D;JNE @string.setint$if_false2 0;JMP (string.setint$if_true2) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @45 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @LCL A=M M=D (string.setint$if_false2) @THIS A=M D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT62 D=A @38 0;JMP (RET_ADDRESS_LT62) @SP AM=M-1 D=M @string.setint$if_true3 D;JNE @string.setint$if_false3 0;JMP (string.setint$if_true3) @19 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL318 D=A @95 0;JMP (RET_ADDRESS_CALL318) @SP AM=M-1 D=M @R5 M=D (string.setint$if_false3) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_EQ37 D=A @6 0;JMP (RET_ADDRESS_EQ37) @SP AM=M-1 D=M @string.setint$if_true4 D;JNE @string.setint$if_false4 0;JMP (string.setint$if_true4) @SP M=M+1 A=M-1 M=0 @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @48 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @string.setint$if_end4 0;JMP (string.setint$if_false4) @SP M=M+1 A=M-1 M=0 @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D (string.setint$while_exp1) @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @RET_ADDRESS_LT63 D=A @38 0;JMP (RET_ADDRESS_LT63) @SP A=M-1 M=!M @SP AM=M-1 D=M @string.setint$while_end1 D;JNE @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M A=A-1 M=M-D @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THAT M=D @THAT A=M D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @R5 M=D @SP AM=M-1 D=M @THAT M=D @R5 D=M @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @THAT A=M M=D @THIS A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=D+M @SP AM=M-1 D=M @THIS A=M+1 A=A+1 M=D @string.setint$while_exp1 0;JMP (string.setint$while_end1) (string.setint$if_end4) @LCL A=M+1 A=A+1 D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @array.dispose D=A @R14 M=D @RET_ADDRESS_CALL319 D=A @95 0;JMP (RET_ADDRESS_CALL319) @SP AM=M-1 D=M @R5 M=D @SP M=M+1 A=M-1 M=0 @54 0;JMP (string.newline) @128 D=A @SP AM=M+1 A=A-1 M=D @54 0;JMP (string.backspace) @129 D=A @SP AM=M+1 A=A-1 M=D @54 0;JMP (string.doublequote) @34 D=A @SP AM=M+1 A=A-1 M=D @54 0;JMP (sys.init) @0 D=A @R13 M=D @memory.init D=A @R14 M=D @RET_ADDRESS_CALL320 D=A @95 0;JMP (RET_ADDRESS_CALL320) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @math.init D=A @R14 M=D @RET_ADDRESS_CALL321 D=A @95 0;JMP (RET_ADDRESS_CALL321) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @screen.init D=A @R14 M=D @RET_ADDRESS_CALL322 D=A @95 0;JMP (RET_ADDRESS_CALL322) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @output.init D=A @R14 M=D @RET_ADDRESS_CALL323 D=A @95 0;JMP (RET_ADDRESS_CALL323) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @keyboard.init D=A @R14 M=D @RET_ADDRESS_CALL324 D=A @95 0;JMP (RET_ADDRESS_CALL324) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @main.main D=A @R14 M=D @RET_ADDRESS_CALL325 D=A @95 0;JMP (RET_ADDRESS_CALL325) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @sys.halt D=A @R14 M=D @RET_ADDRESS_CALL326 D=A @95 0;JMP (RET_ADDRESS_CALL326) @SP AM=M-1 D=M @R5 M=D (sys.halt) (sys.halt$while_exp0) @SP M=M+1 A=M-1 M=0 @SP A=M-1 M=!M @SP A=M-1 M=!M @SP AM=M-1 D=M @sys.halt$while_end0 D;JNE @sys.halt$while_exp0 0;JMP (sys.halt$while_end0) (sys.wait) @SP AM=M+1 A=A-1 M=0 @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_LT64 D=A @38 0;JMP (RET_ADDRESS_LT64) @SP AM=M-1 D=M @sys.wait$if_true0 D;JNE @sys.wait$if_false0 0;JMP (sys.wait$if_true0) @SP M=M+1 A=M-1 M=1 @1 D=A @R13 M=D @sys.error D=A @R14 M=D @RET_ADDRESS_CALL327 D=A @95 0;JMP (RET_ADDRESS_CALL327) @SP AM=M-1 D=M @R5 M=D (sys.wait$if_false0) (sys.wait$while_exp0) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT50 D=A @22 0;JMP (RET_ADDRESS_GT50) @SP A=M-1 M=!M @SP AM=M-1 D=M @sys.wait$while_end0 D;JNE @50 D=A @SP AM=M+1 A=A-1 M=D @SP AM=M-1 D=M @LCL A=M M=D (sys.wait$while_exp1) @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=0 @RET_ADDRESS_GT51 D=A @22 0;JMP (RET_ADDRESS_GT51) @SP A=M-1 M=!M @SP AM=M-1 D=M @sys.wait$while_end1 D;JNE @LCL A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @LCL A=M M=D @sys.wait$while_exp1 0;JMP (sys.wait$while_end1) @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @SP M=M+1 A=M-1 M=1 @SP AM=M-1 D=M A=A-1 M=M-D @SP AM=M-1 D=M @ARG A=M M=D @sys.wait$while_exp0 0;JMP (sys.wait$while_end0) @SP M=M+1 A=M-1 M=0 @54 0;JMP (sys.error) @3 D=A @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @string.new D=A @R14 M=D @RET_ADDRESS_CALL328 D=A @95 0;JMP (RET_ADDRESS_CALL328) @69 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL329 D=A @95 0;JMP (RET_ADDRESS_CALL329) @82 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL330 D=A @95 0;JMP (RET_ADDRESS_CALL330) @82 D=A @SP AM=M+1 A=A-1 M=D @2 D=A @R13 M=D @string.appendchar D=A @R14 M=D @RET_ADDRESS_CALL331 D=A @95 0;JMP (RET_ADDRESS_CALL331) @1 D=A @R13 M=D @output.printstring D=A @R14 M=D @RET_ADDRESS_CALL332 D=A @95 0;JMP (RET_ADDRESS_CALL332) @SP AM=M-1 D=M @R5 M=D @ARG A=M D=M @SP AM=M+1 A=A-1 M=D @1 D=A @R13 M=D @output.printint D=A @R14 M=D @RET_ADDRESS_CALL333 D=A @95 0;JMP (RET_ADDRESS_CALL333) @SP AM=M-1 D=M @R5 M=D @0 D=A @R13 M=D @sys.halt D=A @R14 M=D @RET_ADDRESS_CALL334 D=A @95 0;JMP (RET_ADDRESS_CALL334) @SP AM=M-1 D=M @R5 M=D
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r9 push %rcx push %rdx push %rsi lea addresses_normal_ht+0x1c65c, %r13 nop nop nop nop cmp %r10, %r10 movw $0x6162, (%r13) nop nop nop nop dec %rdx lea addresses_WC_ht+0x1097a, %rsi nop nop nop sub $39708, %rdx mov (%rsi), %rcx nop nop nop nop nop sub $54138, %r9 pop %rsi pop %rdx pop %rcx pop %r9 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r14 push %r8 push %r9 push %rax push %rbp // Load lea addresses_A+0x15cfa, %r8 nop add %r12, %r12 mov (%r8), %r13 nop nop nop cmp $1952, %r8 // Load lea addresses_US+0x1ddda, %rax nop nop nop xor $25085, %r14 vmovups (%rax), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $1, %xmm3, %r12 inc %rbp // Store lea addresses_PSE+0x1b0fa, %r9 nop nop nop nop nop dec %rax movw $0x5152, (%r9) nop cmp $13145, %r9 // Faulty Load lea addresses_A+0x4fa, %rax nop nop and %r13, %r13 mov (%rax), %rbp lea oracles, %r12 and $0xff, %rbp shlq $12, %rbp mov (%r12,%rbp,1), %rbp pop %rbp pop %rax pop %r9 pop %r8 pop %r14 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'00': 199, '35': 8, '48': 6, '10': 5} 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 48 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 00 00 00 35 00 35 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 10 00 00 35 00 */
; Object Mappings Subtype Frame Arttile dbglistobj Obj_Ring, Map_Ring, 0, 0, make_art_tile($6BC,1,1) dbglistobj Obj_Monitor, Map_Monitor, 6, 0, make_art_tile($4C4,0,0) dbglistobj Obj_PathSwap, Map_PathSwap, 9, 1, make_art_tile($6BC,1,0) dbglistobj Obj_PathSwap, Map_PathSwap, $D, 5, make_art_tile($6BC,1,0) dbglistobj Obj_Spring, Map_Spring, $81, 0, make_art_tile($4A4,0,0) dbglistobj Obj_Spring, Map_Spring, $90, 3, make_art_tile($4B4,0,0) dbglistobj Obj_Spring, Map_Spring, $A0, 6, make_art_tile($4A4,0,0) dbglistobj Obj_Spikes, Map_Spikes, 0, 0, make_art_tile($49C,0,0) dbglistobj Obj_Spikebonker, Map_Spikebonker, $20, 0, make_art_tile($500,0,0) dbglistobj Obj_Chainspike, Map_Chainspike, 0, 0, make_art_tile($542,0,0) dbglistobj Obj_TiltingBridge, Map_TiltingBridge, 0, 0, make_art_tile($34D,1,0) dbglistobj Obj_DEZHangCarrier, Map_DEZHangCarrier, 8, 0, make_art_tile($35D,1,0) dbglistobj Obj_Door, Map_HCZCNZDEZDoor, 2, 2, make_art_tile($36B,1,0) dbglistobj Obj_DEZTorpedoLauncher, Map_TorpedoLauncher, $10, 0, make_art_tile($373,0,0) dbglistobj Obj_DEZFloatingPlatform, Map_DEZFloatingPlatform, 2, 0, make_art_tile($33A,1,0) dbglistobj Obj_DEZFloatingPlatform, Map_DEZFloatingPlatform, 5, 0, make_art_tile($33A,1,0) dbglistobj Obj_DEZStaircase, Map_TiltingBridge, 0, 0, make_art_tile($480,1,0) dbglistobj Obj_DEZStaircase, Map_TiltingBridge, 4, 0, make_art_tile($480,1,0) dbglistobj Obj_DEZLightning, Map_DEZLightning, $B4, 4, make_art_tile($379,0,0) dbglistobj Obj_DEZConveyorPad, Map_DEZConveyorPad, 0, 0, make_art_tile($408,1,0) dbglistobj Obj_DEZConveyorPad, Map_DEZConveyorPad, $28, 4, make_art_tile($408,1,0) dbglistobj Obj_DEZEnergyBridge, Map_DEZEnergyBridge, 0, 0, make_art_tile($3FF,1,0) dbglistobj Obj_StillSprite, Map_StillSprites, $30, $30, make_art_tile($3FF,1,0) dbglistobj Obj_StillSprite, Map_StillSprites, $31, $31, make_art_tile($3FF,1,0) dbglistobj Obj_DEZRetractingSpring, Map_DEZRetractingSpring, 0, 0, make_art_tile($332,1,0) dbglistobj Obj_StillSprite, Map_StillSprites, $32, $32, make_art_tile($385,1,0) dbglistobj Obj_DEZTunnelLauncher, Map_DEZTunnelLauncher, 0, 2, make_art_tile($385,0,0) dbglistobj Obj_DEZGravitySwitch, Map_DEZGravitySwitch, 0, 0, make_art_tile($490,1,0)
// (C) Copyright Daniel James 2005. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include "./config.hpp" #ifdef TEST_EXTENSIONS # ifdef TEST_STD_INCLUDES # include <functional> # else # include <boost/functional/hash/map.hpp> # endif #endif #define BOOST_AUTO_TEST_MAIN #include <boost/test/auto_unit_test.hpp> #include <map> #ifdef TEST_EXTENSIONS using std::map; #define CONTAINER_TYPE map #include "./hash_map_test.hpp" using std::multimap; #define CONTAINER_TYPE multimap #include "./hash_map_test.hpp" #endif // TEST_EXTENSTIONS
#pragma once #include <protobuf/RadioRx.pb.h> #include <protobuf/RadioTx.pb.h> #include <protobuf/Robot.pb.h> #include <RobotIntent.hpp> #include <motion/MotionSetpoint.hpp> #include <set> #include "RobotStatus.hpp" #include "protobuf/grSim_Commands.pb.h" #include "protobuf/messages_robocup_ssl_robot_status.pb.h" #include "rc-fshare/rtp.hpp" /** * There are several different structs used throughout our code used to * represent the data sent to/from our robot. * * For Rx (robot to soccer), this includes: * - RTP. This is the packed format we use to send to and from real robots * - grSim. This is a protobuf-based format used to communicate with grSim * - RobotStatus. This is the in-memory representation used in Context. * - Packet::RadioRx. This is the representation used in the log frame. * * For Tx (soccer to robot), the structs are similar with one exception: * instead of a single equivalent to RobotStatus, in-memory representations of * Tx data is split across RobotIntent and MotionSetpoint. */ namespace ConvertRx { void rtp_to_status(const rtp::RobotStatusMessage& rtp, RobotStatus* status); void grsim_to_status(const Robot_Status& grsim, RobotStatus* status); void status_to_proto(const RobotStatus& status, Packet::RadioRx* proto); } // namespace ConvertRx namespace ConvertTx { void to_rtp(const RobotIntent& intent, const MotionSetpoint& setpoint, int shell, rtp::RobotTxMessage* rtp); void to_proto(const RobotIntent& intent, const MotionSetpoint& setpoint, int shell, Packet::Robot* proto); void to_grsim(const RobotIntent& intent, const MotionSetpoint& setpoint, int shell, grSim_Robot_Command* grsim); } // namespace ConvertTx void fill_header(rtp::Header* header);
; A287922: a(n) = prime(1)^2 + prime(n)^2. ; 8,13,29,53,125,173,293,365,533,845,965,1373,1685,1853,2213,2813,3485,3725,4493,5045,5333,6245,6893,7925,9413,10205,10613,11453,11885,12773,16133,17165,18773,19325,22205,22805,24653,26573,27893,29933,32045,32765,36485 cal $0,138690 ; Numbers of the form 56+p^2 (where p is a prime). sub $0,45 mov $1,$0 mov $2,1 cal $2,235399 ; Numbers which are the digital sum of the cube of some prime. sub $1,$2 add $1,2
PUBLIC pixeladdress EXTERN base_graphics ; ; $Id: pixladdr.asm,v 1.5 2015/01/19 01:32:52 pauloscustodio Exp $ ; ; ****************************************************************** ; ; Get absolute pixel address in map of virtual (x,y) coordinate. ; ; Design & programming by Gunther Strube, Copyright (C) InterLogic 1995 ; ; ****************************************************************** ; ; VZ200/300 version By Stefano Bodrato ; ; The VZ screen size is 128x64 ; We draw blue dots over green display (UGH!) ; ; .pixeladdress push hl ld a,h push af rra rra and @00111111 ld b,l ld hl,(base_graphics) ; pointer to base of graphics area ld l,a ld de,32 .adder add hl,de djnz adder ld d,h ld e,l pop af pop hl rla and @00000110 ; a = x mod 8 xor @00000111 ; a = 7 - a ret
#pragma once #ifdef DECLARE_EVENT #error "DECLARE_EVENT is already defined! Undefine it before including macros.hpp!" #endif // Declares a event with the given type, and name. // Creates the field and the add/remove methods #define DECLARE_EVENT(type, name) \ DECLARE_INSTANCE_FIELD(type, name); \ DECLARE_METHOD(void, add_##name, type action); \ DECLARE_METHOD(void, remove_##name, type action); #ifdef REGISTER_EVENT #error "REGISTER_EVENT is already defined! Undefine it before including macros.hpp!" #endif // Registers the event with the given type, and name. // Registers the field and the add/remove methods #define REGISTER_EVENT(name) \ REGISTER_FIELD(name); \ REGISTER_METHOD(add_##name); \ REGISTER_METHOD(remove_##name); #ifdef DEFINE_EVENT #error "DEFINE_EVENT is already defined! Undefine it before including macros.hpp!" #endif // Defines the event in the given namespace with the given type, and name. // Defines the add/remove methods #define DEFINE_EVENT(namespace, type, name) \ void namespace::add_##name(type action) { \ if(name){ \ name = (type)System::Delegate::Combine(name, action); \ }else{ \ name = action;\ } \ } \ void namespace::remove_##name(type action) { \ if(name) \ name = (type)System::Delegate::Remove(name, action); \ }
// Original test: ./lena/hw4/problem6/jalr_1.asm // Author: lena // Test source code follows //test that jalr returns to proper instruction with offset jal 4 halt nop addi r1, r7, 2 jalr r1, -2
; first setup of a window include win1_mac_oli include win1_keys_wman include win1_keys_wwork section utility xdef xwm_fset ;+++ ; first setup of a window ; ; Entry Exit ; d1.l size (or 0, or -1) ; a2 wman vector ; a3 primary block ; a6 global status area ;--- xwm_fset subr a3/d1-d3 move.l d1,d2 ; size move.l (a3)+,d1 ; layout memory size move.l (a3)+,a1 adda.l a6,a1 ; status area add.l (a3),a3 ; window defintion xjsr ut_setup_l subend end
; ; KISS TNC for the TNC-2 and clones ; ; k3mc 30 Sep 86 - original version ; ; 1 Mar 87. Fixed all known bugs. Re-arrange code to allow ROMing (this ; means that data areas need to be initialized from the code). Figure out the ; Stack Pointer given the amount of available RAM. Include the codes 05 00 ; and 05 01 to mean full duplex off and full duplex on, respectively. ; Clear out all available RAM. Do a “dance” with LEDs when initially booted: ; Flash the LED(s) for about 5 seconds such that CON only flashes if you have ; 8k RAM, STA only flashes if 16k RAM, and STA and CON flash if 32k RAM. ; ; 29 Mar 87. Add code to discard BREAK chars, and chars with framing errors. ; Fix bug in ib_rca which did not discard null received frames. ; ; 11 Dec 89. Incorporate code from Jan Schiefer, DL5UE, [44.130.48.9] ; Degerlocherstrasse 5, 7000 Stuttgart 70, Federal republic of Germany ; to fix the problem with Full-Duplex operation. New version number, v.4 ; ; 19 Jan 91. Shin-ichi Kanno , JN1JDZ , [133.168.32.129] ; Fix the DCD detection problem. Add the auto-enable operation. ; Add the code of output following data routine. New version number, v.5 ; ; 27 Jun 91. Add the TXdelay control . Fix buffer allocation problem . ; Add the code of Software DCD Detection routine. New version number, v.7 ; ; 25 Dec 2015 - Slightly re-formatted the text; place on github ; ; FALSE equ 0 TRUE equ NOT FALSE ALONE equ TRUE ;uncomment this line to get stand-alone code. ;TASCO equ TRUE ;uncomment this line to get for TASCO’s TNC’s ;(TNC-20,TNC-20H and TNC-22) ROM code. SIO_AUTO equ TRUE ;uncomment this line to set SIO PORT B for ;auto-enable mode. HARDWARE equ TRUE ;uncomment this line to add the set hardware ;sub command. ; .z80 ; aseg ; org 100h ;silly stuff for CP/M… ifdef ALONE .phase 0000h Free_RAM equ 8000h else ifdef TASCO .phase 7000h Free_RAM equ 0d000h else .phase 7800h Free_RAM equ 9000h endif endif SIO equ 0dch ;actually, only A5 is used for SIO -cs A_dat equ SIO+0 ;Modem port A_ctl equ SIO+1 ;Modem port B_dat equ SIO+2 ;user serial port B_ctl equ SIO+3 ;user serial port DCD equ 8 ;Bit in RR0, used in Ch A CTS equ 32 ;Bit in RR0, used in Ch A TBE equ 4 ;TX Buffer Empty bit RTS equ 2 ;Request To Send (PTT bit in WR5 of Chan A) Framing_Error equ 40h ;Bit in RR1 for async framing error Break_Abort equ 80h ;Bit in RR0 for async Break detection ifdef SIO_AUTO Auto_Enable equ 0e1h else Auto_Enable equ 0c1h endif FEND equ 300o ;300 octal FESC equ 333o ;333 octal TFEND equ 334o ;334 octal TFESC equ 335o ;335 octal ALEDon equ 69h ;bits for WR5 to turn on STA LED ALEDoff equ 0e9h ;bits for WR5 to turn off STA LED ALED equ 80h ;The DTR Bit in Ch A WR5, we will soon remove ;previous 2 definitions & use the memory loc. ;A_WR5 to hold Ch A WR5’s value, because we ;need to be aware when we are transmitting! BLEDon equ 6ah ;bits for WR5 to turn on CON LED BLEDoff equ 0eah ;bits for WR5 to turn off CON LED BLED equ 80h start: jp code_start ;go around this data area version: db 'v.7 27 Jun 91’ ;13 bytes (exactly!) here for version string I_Vector: dw ib_tbe ;ch B transmitter buffer empty interrupt/user dw ib_ext ;ch B ext/status change/user dw ib_rca ;ch B received char available/user dw ib_special ;ch B special receive condition/user dw ia_tbe ;ch A transmitter buffer empty interrupt/modem dw ia_ext ;ch A ext/status change/modem dw ia_rca ;ch A received char available/modem dw ia_special ;ch A special receive condition/modem code_start: di ;No interrupts for the moment… ;Init SIO. This is required even if we wanna flash LEDs… in a,(A_ctl) ;assure we are talking to ch 0 ld c,A_ctl ld b,a_size ld hl,a_init otir ;init sync (modem) port ;Init Async port, also to allow flashing LEDs in a,(B_ctl) ;assure we are talking to ch 0 ld c,B_ctl ld b,b_size ld hl,b_init otir ;init async port & interrupt vector ; ; Figure out where top of stack is, set stack pointer. ; 32K RAM system. ld sp,0 ;[JDZ] ;Clear out RAM. ld bc,0ffffh-Free_RAM-1 ;[JDZ] get Byte Count into BC ld hl,Free_RAM ;[JDZ] ld (hl),0 ;[JDZ] ld de,Free_RAM+1 ;[JDZ] get “source” address = Free_RAM ldir ;Zero memory. ;This sequence loads up our data area in RAM: ld hl,data_init ld de,TXdelay ld bc,data_size ldir ; init free buffer list. ld hl,Bottom ;[JDZ] beginning of buffer space ;[JDZ] now it’s also top of free list ld b,-1+(-100-Bottom)/128 ;[JDZ] get buffers - 1 ibloop: push hl ld de,128 add hl,de ;HL has “next” pointer ex de,hl ;DE has “next” pointer pop hl ;HL now has pointer to current buffer ld (hl),e ;low byte of “next” pointer first inc hl ld (hl),d ;now hi byte inc hl xor a ld (hl),a ;zero out count field inc hl ld (hl),a ;zero out # of bytes read field ex de,hl ;HL is now pointer to next buffer djnz ibloop ;and init all the available buffers xor a ld (hl),a ;Last “next” address is 0 inc hl ld (hl),a ;ditto inc hl ld (hl),a ;zero out count field inc hl ld (hl),a ;zero out # of bytes read field ;init regs for ib_ext interrupt exx ld bc,0 ;set prev state of SYNC pin,for 1200hz ld de,0 ;count of # of interrupts init exx ;[JDZ] Now have the CON and STA LEDs do a “dance”. ld b,6 ;Do it 6 times (arbitrary as hell, but should ;be an even number so that the LEDs are off at ;the end of this mess…) ld hl,0 ;use HL as downcounter dance0: call CON_Flip call STA_Flip dance1: dec hl ld a,h or l jr nz,dance1 djnz dance0 ;do this 6 times (3 “cycles”) ;Previous stuff showed that the download or boot worked properly… ;We re-initialize the SIO ports so that we flush garbage chars that may have ;come in while we were diddling the LEDs. This is necessary because unless we ;do this, then the A channel (modem) get RX overrun (esp if TNC was listening ;to noise) and RX overrun is VERY BAD - so bad, in fact, that I turn on both ;CON and STA and halt, because this situation should NEVER happen in normal ;use. I flush the B (tty) channel in case anything was sent to it in mid- ;stream. ;Re-Init SIO. in a,(A_ctl) ;assure we are talking to ch 0 ld c,A_ctl ld b,a_size ld hl,a_init otir ;init sync (modem) port ;Re-Init Async port. in a,(B_ctl) ;assure we are talking to ch 0 ld c,B_ctl ld b,b_size ld hl,b_init otir ;init async port & interrupt vector ; Prepare to load hi bits of interrupt vector ld a,I_Vector/256 ld i,a ;set interrupt page for mode 2 ints im 2 ei ;let ‘em rip! ;—————————————————————————– ; This is the background program. ; Note that since everything else is interrupt driven, and saves registers, ; this part of the code can use registers & expect values to stay. Commutator_loop: call TX_data call Host_TX_data jp Commutator_loop ;Now see if we need to start an output to RS-232 (host) port Host_TX_data: ld a,(out_started) or a ;also clears carry (see below) ret nz ;if output started, nothing to do in a,(B_ctl) ;look at RR0 and TBE ;isolate the TBE bit ret z ; else we should check to see if we need to start an output di call CON_off ; ld hl,(out_head_cbuf) ;grab current top of circ buf ptr ld de,(out_tail_cbuf) ;and where the next free buf ptr is ei ;interrupt protect the pickup of the ;two pointers 3 Feb 87 or a sbc hl,de ret z ;if the same, nothing to do ;else we need to start an output di ;interrupt protect this section, ;although I’m not sure it needs it… ;3 Feb 87 ;note: it should already BE done! ld hl,(out_head_cbuf) ;get pointer to next cbuf to output ld e,(hl) inc hl ld d,(hl) ;DE has pointer to buffer chain ld (out_chain_head),de ;set in interrupt routine’s place ld a,TRUE ld (out_started),a ;yes, output started call CON_on ld a,FEND out (B_dat),a ;send FEND character (start txing) ei ret ;keep looking for new opportunity TX_data: ld a,(TX_State) or a jp z,txd0 cp 1 jp z,txd1 cp 2 jp z,txd2 cp 3 jp z,txd3 cp 4 ret z ;When tail timer times out, turn off the TX ld a,(TX_Timer) or a ret nz ld a,5 ;ready to write to WR5 of Ch A di ;must have atomic use of A_WR5 & SIO out (A_ctl),a ;Next char to A_ctl goes to WR5 ld a,(A_WR5) ;grab A_WR5 and NOT RTS ;turn off RTS bit there ld (A_WR5),a ;keep memory copy updated out (A_ctl),a ;and turn off TX now xor a ld (TX_State),a ei ret txd0: ld a,(TX_outstanding) ;if there are no outstanding TX… or a ;…frames, then we don’t have to… ret z ;…worry about Transmitter ; do persistence algorithm ld a,r ;grab the Z-80 refresh register add a,a ;double;now 0 <= A reg <= 254 ld b,a ;B holds our “random” number ld a,(Persistence) sub b ;A reg = Persistence - Random # jp c,No_PTT ;if (P-r) < 0 then no PTT now ; Note that P=255 means ALWAYS key up ; else we’ve noticed that we’ve got some frame(s) to send. ; try to keyup TX ld a,(Full_Duplex) or a jp nz,Key_Up ;if Full Duplex, then there is no ;need to worry about all this silly ;slot time and persistence stuff! ifdef HARDWARE ;check soft DCD. ld a,(Soft_DCD) ld l,a bit 1,l jp z,txd1a ld a,(RX_State) or a jp nz,No_PTT ;check if Carrier Detect is active txd1a: bit 0,l jp z,Key_Up endif ld a,(A_RR0) ;A_RR0 is set in interrupt routine and DCD jp nz,No_PTT ;[JDZ] If carrier active, wait it out ;OK, so we’ve won with the random number generator. Keyup TX and start the ;TXdelay timer Key_Up: ld a,(TXdelay) ld (TX_Timer),a ;Get timer value into timer slot ld a,5 di ;we need quite time here. out (A_ctl),a ;Ready to write into WR5 of Ch A ld a,(A_WR5) or RTS ;Turn on the PTT bit… ld (A_WR5),a ;…in the memory copy of WR5 out (A_ctl),a ; Keyup transmitter ld a,2 ld (TX_State),a ei ret ;That’s all we do for now, we await ;TXdelay event No_PTT: ;since we lost on Random #, wait SlotTime before trying again ld a,(SlotTime) ld (TX_Timer),a ;Set up the timer value of this event ld a,1 ld (TX_State),a ret txd1: ld a,(TX_Timer) or a ret nz xor a ld (TX_State),a ret txd2: ld a,(TX_Timer) or a ret nz ld a,3 ld (TX_State),a ret txd3: ifdef HARDWARE ; CTS flow ld a,(CTS_Control) or a jp z,txd3a ld a,(A_RR0) and CTS ret z txd3a: endif di ld a,4 ld (TX_State),a call TXnext_CBuf ;gets HL to point to buffer chain, and ;sets TX_Chain_Head for the interrupt ;routine ld a,80h out (A_ctl),a ; reset TX CRC call getchar ; getchar needs int. protection out (A_dat),a ; Ship this char to TX modem ld a,TRUE ld (TX_Started),a ; and, yes Virgina, we’ve started TX ld a,0c0h out (A_ctl),a ; reset TX underrun/EOM latch ei ret ; include IA.MAC ;Modem interrupt catchers ;————————————————————————— ia_tbe: push af push hl ld a,(TX_Started) or a jp z,ia_t2 ; previous frame finished ld hl,(TX_Chain_Head) call getchar ld (TX_Chain_Head),hl ; must keep this pointer updated jp z,ia_t1 ; no more to send out (A_dat),a ; else ship this char out ia_t9: pop hl pop af ei reti ; just return from these interrupts ia_t1: ; halt ;if it gets here, halt xor a ld (TX_Started),a ; TX is NOT started ld hl,TX_Outstanding ; make is so that one fewer frames ; NOT “(TX_Outstanding)” (!) 29 Sep dec (hl) ; are outstanding ld a,28h out (A_ctl),a ; reset TX interrupt pending jp ia_t9 ;previous frame is done, SIO now sending a flag. More? ia_t2: ld a,(TX_Outstanding) or a jp nz,ia_t21 ;if more to send, go there ; else we’re done here, clean up. ld a,28h out (A_ctl),a ; Reset TX interrupt pending ;start Tail timer event ld a,(TailTime) ld (TX_Timer),a ; wait for CRC to clear TX ld a,5 ld (TX_State),a jp ia_t9 ia_t21: ;start up next frame call TXnext_CBuf ; get the next buffer chain pointer ; setup HL and TX_Chain_Head ld a,80h out (A_ctl),a ; reset TX CRC generator call getchar out (A_dat),a ;get 1st char of next frame ld a,TRUE ld (TX_Started),a ; TX started again ld a,0c0h out (A_ctl),a ; reset TX underrun/EOM latch jp ia_t9 ;————————————————————————— ; Got a character from the SIO RX interrupt, deal with it ; Extensive mods 3 Feb 87 to be in line with what I now know about SIO… ia_rca: push af push hl ld a,(RX_flushing) or a jp z,ia_rc1 in a,(A_dat) jp ia_rc9 ia_rc1: ld a,(RX_Allocated_Buffer) or a jp nz,ia_rc7 ; Go there if we are in “receiving” state ;else we are not yet receiving, so allocate buffer & make us “receiving” call allocate_buffer ; get a new buffer jp z,ia_rc5 ; NO ROOM, flush this frame ; if got a buffer, insert this character. ; after doing initial buffer setup. ia_rc6: ld (RX_head),hl ; save chain head address (1st buffer) ld (RX_buf),hl ; tuck away addr of our current buffer ld a,TRUE ld (RX_Allocated_Buffer),a ; and mark that ; we are receiving ld a,0 ; Channel 0 call putchar ; SLIP’ frame “type” field here (Always 0) ia_rc7: in a,(A_dat) ; grab the pending character ld hl,(RX_buf) ; load up address of our current RX buffer call putchar ; and stuff in this particular buffer jp c,ia_rc2 ; If NO ROOM, flush this frame. ld (RX_buf),hl ; HL might have changed in putchar() ia_rc9: pop hl pop af ei reti ; nothing else to do here ; if no room, flush this frame (sigh) ia_rc2: xor a ld (RX_Allocated_Buffer),a ld hl,(RX_head) call free_chain ia_rc5: ld a,TRUE ld (RX_flushing),a ; we are in the midst of ; flushing this frame call STA_on ;ddd Note that we are in flushing ;state jp ia_rc9 ;————————————————————————— ; From out point of view, this interrupt is only interesting because it ; tells us if we’re at end of frame. ia_special: push af push hl ; regs we’ll need ld a,1 out (A_ctl),a ; ready to read RR1 in a,(A_ctl) ; OK, grab RR1 ; First check if RX overrun. This is VERY BAD, so what can we do? ; Well, we merely treat it as a bad CRC, that is, just flushing the ; frame. I don’t like dropping chars (and it shouldn;t happen very often) ; but at high speeds, it may occur with 2.5 MHz z80s. bit 5,a ; RX overrun? jp nz,ia_sp8 ; If a problem, treat as bad CRC ; That is, flush this frame…. ;ia_sp0: bit 7,a ; check state of End of Frame bit jp z,ia_sp8 ; Else something weird happened - probably ; RX overrun. In any case, flush this frame. ; error reset & then exit ; that is, treat like it was a CRC error ; If End of Frame, check CRC bit for valid. ia_sp1: bit 6,a ; Check CRC error bit jp nz,ia_sp8 ; If CRC error bit is on, then was CRC error ; First ensure that we indeed have a buffer allocated… ld a,(RX_Allocated_Buffer) or a jp z,ia_sp9 ; if no buffer allocated, ignore this. ; Else this was a good frame, and we should ship it out to host ; Leave the first CRC character at end of buffer chain in the buffer, as ; getchar() will flush it. ld hl,(RX_head) call out_queue_insert ; Shove this buffer string onto ; output queue xor a ld (RX_Allocated_Buffer),a ; We don’t have a buffer ; allocated for the next ; frame… jp ia_sp9 ; get here if there was a bad CRC ia_sp8: ld a,(RX_Allocated_Buffer) ; If we don’t have any ; buffers allocated, then or a ;8 Feb - SET CONDITION CODES !!!!!! jp z,ia_sp9 ; we MUST NOT “release” them !!! 10 Sep 86 ; if they are not allocated !!! xor a ld (RX_Allocated_Buffer),a ; not receiving if we have bad CRC ld hl,(RX_head) call free_chain ; free up all buffer(s) ia_sp9: ld a,30h ; error reset out (A_ctl),a in a,(A_dat) ; Avoid spurious RCA interrupt ld a,03h ; [JS] select WR3 out (A_ctl),a ; [JS] ld a,0D9h ; [JS] enter hunt mode out (A_ctl),a ; [JS] xor a ld (RX_State),a ; [JS] store sync/hunt state ld (RX_flushing),a ifdef HARDWARE ; Software DCD filetr ld a,(Full_Duplex) or a jp nz,ia_spsd ld a,(TX_State) cp 2 jp nc,ia_spsd ld a,(Soft_DCD) bit 1,a jp z,ia_spsd ld a,1 ld (TX_State),a ld a,(SlotTime) ld (TX_Timer),a ia_spsd: endif pop hl pop af ei reti ;————————————————————————— ; for ext/status interrupts on Modem, get DCD state into memory, and ; deallocate any spurious buffers (buffer stuff done 30 Sep 86). ia_ext: push af ld a,10h ; reset ext/status interrupts out (A_ctl),a in a,(A_ctl) ; grab RR0 ld (A_RR0),a bit 4,a ; [JS] check sync/hunt bit jp nz,ia_ex1 ; [JS] no need to worry, if not zero ld a,(RX_State) ; [JS] it is 0! Did it change? or a ; [JS] jp nz,ia_ex9 ; [JS] no, this is a DCD,CTS or EOM-interrupt ld a,TRUE ; [JS] indeed, it changed! ld (RX_State),a ; [JS] next time, we’ll know ld a,(RX_Allocated_Buffer) ; if we are not in the ; receiving state… or a ; then there are no allocated buffers and… jp z,ia_ex9 ; we MUST NOT “release” them !!! 10 Sep 86 ; if no buffers allocated !!! xor a ld (RX_Allocated_Buffer),a ; not receiving push hl ld hl,(RX_head) call free_chain ; free up all buffer(s) pop hl jp ia_ex9 ia_ex1: xor a ; [JS] Prepare for next frame start ld (RX_State),a ; [JS] ld (RX_flushing),a ia_ex9: pop af ei reti ; include IB.MAC ;TTY interrupt catchers ;————————————————————————— ; we get here whenever -cts, -dcd or -sync inputs change, as well as break ; detection. Since -dcd ; is always tied to +5 volts, we need only worry about -cts and -sync. ; -cts is wired to pin 20, DTR, of the RS232 connector, and is supposed to ; be used for host to TNC handshaking; we ignore this transition (We assume ; that the host is always ready). We also ignore break detection. We are ; only interested in -sync transitions, so we can keep time. ; NOTE! This is the ONLY routine that is allowed to use the other reg set!! ; deal with break detection… sync_hunt equ 10h ib_ext: ex af,af’ exx ; we want the other registers ld a,10h out (B_ctl),a ; reset ext/status interrupts in a,(B_ctl) ; grab RR0 ld d,a ; Hold it for a moment… and sync_hunt ; isolate this bit jp z,ib_s0 ;else sync/hunt is a 1 ld a,c or a jp z,ib_s1 ; go here if state of sync/hunt changed ; Here if sync/hunt bit did NOT change - maybe something else did…. ib_s9: ld a,d ; retreive RRO from above and Break_Abort ; Check if we are doing a break/abort thing jp z,ib_NBA ; There if No break/abort ; Else Break/Abort bit on, note state change… ld a,TRUE ld (in_break),a ; save in mem (probably can use E reg…) in a,(B_dat) ; clear out any null character from buffer jp ib_BOK ; Break OK for now… ib_NBA: ;if no break/abort, check if we are in break/abort state. ld a,(in_break) or a jp z,ib_BOK ; Nothing going on, Break OK ; Else we were in break mode, and this is the tail end of a break. xor a ld (in_break),a in a,(B_dat) ; discard the single extraneous null ib_BOK: ib_s99: ex af,af’ exx ei reti ; else something else & we don’t care ib_s0: ; sync/hunt is a 0 ld a,c or a jp nz,ib_s1a ; go here if sync/hunt changed jp ib_s9 ; else not interested, forget it ;get here if state of sync/hunt changed ib_s1: ld c,1 jp ib_s1b ib_s1a: ; first fix up C for next tick ld c,0 ib_s1b: ; Here when we’ve seen a real “clock tick” & dealt with C reg inc b ld a,b cp 12 jp nz,ib_s99 ; we act on every 12th clock tick… ld b,0 ; so reload divisor. This give us an ; effective interrupt rate of 100 Hz ; Decrement all the timers ld a,(TX_Timer) ; Get value, and … or a jp z,ib_s1c dec a ; … decrement it as required. ld (TX_Timer),a ib_s1c: jp ib_s99 ;————————————————————————— ib_special: push af ib_sp9: ; Normal exit ld a,30h ; error reset out (B_ctl),a pop af ei reti ;————————————————————————— ; The TX has become empty, shove a new character out ib_tbe: push af ; new char will return in A push hl ld a,(Out_esc_mode) or a jp z,ib_t1 ; not escaped, so go here ; else we are escaped, so send escaped char ld a,(Out_char) ; char which follows escape or a jp z,ib_t2 ; special case if at end of frame, clean up out (B_dat),a xor a ld (Out_esc_mode),a ; get out of escaped mode jp ib_t9 ; all for now… ib_t1: ld hl,(out_chain_head) ; we are currently on this buffer, call getchar ; as getchar() needs to know ld (out_chain_head),hl ; maybe HL changed,so save it in case jp z,ib_tdone ; if no more chars, deal with this cp FESC jp z,ib_t1a ; deal with FESC char in data stream cp FEND jp z,ib_t1b ; deal with FEND char in data stream ; else this char is nothing special, so shove it out out (B_dat),a ; shove it out jp ib_t9 ; if this is not last char, all for now ; else this is last char, send FEND ib_tdone: ld a,FEND out (B_dat),a ld a,TRUE ld (Out_esc_mode),a ; set special escaped mode by… xor a ld (Out_char),a ;… making escaped char a 0 jp ib_t9 ; all till TX Buffer goes empty again. ; here if are completely done sending frame ib_t2: push de ; need this for a moment ld hl,(out_head_cbuf) inc hl inc hl ld de,out_bottom or a push hl sbc hl,de pop hl ; this may be the one we want pop de jp nz,ib_t2a ; yes it is! ld hl,Out_Top ; else, make a circular buffer ib_t2a: ld (out_head_cbuf),hl ; we will work on this one next xor a ld (out_started),a ; not doing outputs anymore ld (Out_esc_mode),a ; !! NOT IN ESCAPED MODE ANYMORE !! ld a,28h ; NEEDED for ASYNC out (B_ctl),a ; reset TX interrupt pending ib_t9: pop hl pop af ei reti ; now get our butts out of here… ; here is FESC in data stream ib_t1a: out (B_dat),a ; Ship FESC character to port ld a,TFESC ; ready what will be next char ib_t1z: ld (Out_char),a ; set char for next time ld a,TRUE ld (Out_esc_mode),a ; we are in escaped mode jp ib_t9 ; all for now ; here is FEND in data stream ib_t1b: ld a,FESC out (B_dat),a ld a,TFEND jp ib_t1z ; rest is same as FESC case ;————————————————————————— ; Got a char from the TTY port, deal with it. ib_rca: push af in a,(B_ctl) ; Read RR0; force reg pointer to be 0 ld a,1 out (B_ctl),a ; ready to read RR1 in a,(B_ctl) ; Grab RR1 and Framing_Error ; Isolate the FE bit jp z,ib_Rtop ; No Framing Error, so process this char ; Else we have a Framing Error - Ignore this char & flush this frame… call STA_off ; Off with the LED! in a,(B_dat) ; Flush erroneous character xor a ld (In_state),a ; Force receiver to look for FEND ld a,(In_Allocated_Buffer) or a jp z,ib_rc9 ; If no buffer is allocated, done; Exit. ; Else we were receiving a data SLIP frame, so flush it. push hl ld hl,(In_head) call free_chain ; Dump these buffers back to free list pop hl jp ib_rc9 ; And get out of here! ib_rTop: ld a,(In_state) ; get our state machine value or a jp z,ib_r0 ; in state 0, waiting for FEND cp 1 jp z,ib_r1 ; in state 1, saw FEND cp 2 jp z,ib_r2 ; in state 2, data to follow cp 3 jp z,ib_r3 ; saw FESC, expecting TFESC or TFEND cp 10 jp z,ib_r10 ; Expecting TXdelay cp 20 jp z,ib_r20 ; Expecting P value cp 30 jp z,ib_r30 ; Expecting SlotTime value cp 40 jp z,ib_r40 ; Expecting TailTime value cp 50 jp z,ib_r50 ; Expecting Full/Half duplex value ifdef HARDWARE cp 60 jp z,ib_r60 ;[JDZ] Expecting Set Hardware value ifndef TASCO cp 61 jp z,ib_r61 ;[JDZ] Expecting Set Hardware value endif endif ;else we don’t know what happened, ignore it. ib_rcjunk: in a,(B_dat) ib_rcFEND: xor a ib_rcSTATE: ld (In_State),a ;go into In_State 0, FEND hunt ib_rc9: pop af ; throw it away, we don’t need junk ei reti ; Here if we are hunting for FEND character ib_r0: call STA_off in a,(B_dat) cp FEND jp nz,ib_rc9 ; if we didn’t see an FEND, keep looking ; else is an FEND, change state ld a,1 jp ib_rcSTATE ; Get here if we’ve seen FEND character; look for command byte ib_r1: call STA_off in a,(B_dat) cp FEND jp z,ib_rc9 ; Just another FEND, keep looking for cmd call STA_on ;getting valid SLIP; show in STA LED ; Here if we DO NOT have an FEND (expecting command byte) ifndef ALONE cp 0ffh jp z,kiss_exit endif and 0fh jp z,ib_r1a ; 0 command means data will follow cp 1 jp z,ib_r1b ; 1 command means TXdelay will follow cp 2 jp z,ib_r1c ; 2 command means P(Persistence) will follow cp 3 jp z,ib_r1d ; 3 command means Slot Time will follow cp 4 jp z,ib_r1e ; 4 command means TailTime to follow cp 5 jp z,ib_r1f ; 5 command means Full/Half duplex to come ifdef HARDWARE cp 6 jp z,ib_r1g ; 6 command means Set Hardware to come endif ; Here if we receive bogus command byte, flush rest of frame call STA_off ;bogosity, so turn off STA LED jp ib_rcFEND ; exit kiss mode. ifndef ALONE kiss_exit: ld hl,(000eh) res 4,(hl) ld hl,0000h push hl ld hl,(0019h) jp (hl) endif ; Data are expected, change state ib_r1a: ld a,2 jp ib_rcSTATE ; TXdelay to follow, change state ib_r1b: ld a,10 jp ib_rcSTATE ; P to follow, change state ib_r1c: ld a,20 jp ib_rcSTATE ; SlotTime to follow, change state ib_r1d: ld a,30 jp ib_rcSTATE ; TailTime to follow, change state ib_r1e: ld a,40 jp ib_rcSTATE ; Full/Half Duplex to follow, change state ib_r1f: ld a,50 jp ib_rcSTATE ifdef HARDWARE ; Set Hardware to follow, change state ib_r1g: ld a,60 jp ib_rcSTATE endif ; These bytes are data ib_r2: in a,(B_dat) cp FEND jp z,ib_r2b ; FEND means to queue this buffer push af ; Save the char we read on stack for a bit.. ld a,(In_Allocated_Buffer) or a jp nz,ib_r2c ; if we already allocated buffer push hl call allocate_buffer ; get our initial buffer to mess with jp nz,ib_r22 ; else no room, flush this frame pop af pop hl ; keep stack tidy jp ib_rcFEND ib_r22: ld a,TRUE ld (In_Allocated_Buffer),a ; make ourselves active ld (In_buffer),hl ld (In_head),hl ; save current & head of chain pointers pop hl ib_r2c: pop af ; Retreive the data char we just got… cp FESC jp z,ib_r2a ; If FESC in data stream, switch state push hl ld hl,(In_buffer) call putchar ; shove this character into our buffer jp nc,ib_r2ca xor a ld (In_Allocated_buffer),a ld hl,(In_head) call free_buffer pop hl jp ib_rcFEND ib_r2ca: ld (In_buffer),hl ; save in case HL changed pop hl jp ib_rc9 ; done so far ; FESC character seen while grabbing data ib_r2a: ld a,3 jp ib_rcSTATE ; FEND character seen while grabbing data ib_r2b: ld a,(In_Allocated_Buffer) or a jp z,ib_r2z ; No bytes accumulated, so is null frame ; else we must ship this frame to TX push hl ; This bug found 29 Sep (must save HL !!!) ld hl,(In_Buffer) call putchar ; put a garbage character at the end of ; last buffer because getchar() will strip ; it. Hack needed because of RX use of ; putchar/getchar. ld hl,(In_head) jp nc,ib_r2za call free_chain jp ib_r2zb ib_r2za: call TX_queue_insert ib_r2zb: pop hl xor a ld (In_Allocated_Buffer),a ; input no longer active ib_r2z: ; entry point for null frame call STA_off ;done getting this frame, turn STA LED off ld a,1 ; Keep as was, FENDs only at end in v.32 jp ib_rcSTATE ; here if we’ve seen FESC in data stream ib_r3: in a,(B_dat) cp TFESC jp z,ib_r3a cp TFEND jp z,ib_r3b ; Else we don’t know what the hell it is, so ignore & keep collecting bytes ld a,2 jp ib_rcSTATE ; here if we’ve seen TFESC after an FESC in data stream; write an FESC ib_r3a: ld a,FESC ib_r3z: push hl ld hl,(In_buffer) call putchar jp nc,ib_r3za xor a ld (In_Allocated_buffer),a ld hl,(In_head) call free_buffer pop hl jp ib_rcFEND ib_r3za: ld (In_buffer),hl pop hl ld a,2 jp ib_rcSTATE ; Here if we’ve seen TFEND after FESC in data stream; write FEND ib_r3b: ld a,FEND jp ib_r3z ; rest is same as for TFESC case ; This character is interpreted as TXdelay ib_r10: in a,(B_dat) ld (TXdelay),a jp ib_rcFEND ; This charcter is P, Persistence value ib_r20: in a,(B_dat) ld (Persistence),a jp ib_rcFEND ; This character is SlotTime value ib_r30: in a,(B_dat) ld (SlotTime),a jp ib_rcFEND ; This character is TailTime value ib_r40: in a,(B_dat) ld (TailTime),a jp ib_rcFEND ; This character is Full/Half Duplex value ; 0 means Half Duplex, non-zero means Full Duplex ib_r50: in a,(B_dat) ld (Full_Duplex),a jp ib_rcFEND ifdef HARDWARE ; This character is Set Hardware value ; data means Output Address. ib_r60: in a,(B_dat) cp 0feh ; CTS flow off jp nc,ib_r60cts cp 0fch ; Reserved jp nc,ib_rcFEND cp 0f8h ; DCD jp nc,ib_r60DCD ifndef TASCO cp 020h jp nc,ib_rcFEND add a,0a0h ; A5=1 OUT_DATA address, Ch A ld (Out_Address),a ld a,61 jp ib_rcSTATE else jp ib_rcFEND endif ; CTS flow ib_r60cts: sub 0feh ld (CTS_Control),a jp ib_rcFEND ; Software DCD ib_r60dcd sub 0f8h ld (Soft_DCD),a jp ib_rcFEND ifndef TASCO ; data means Output Data. ib_r61: push bc ld a,(Out_Address) ld c,a in a,(B_dat) out ©,a pop bc jp ib_rcFEND endif endif ; include BUFFERS.MAC ;all buffer-related stuff in here ;plus all (eventually) variables ; ; The buffer list is kept from “bottom” to the end of RAM. The format of the ; buffers is: ;+——+——–+——-+—————————————————+ ;| next | Nbytes | Nread | data | ;+——+——–+——-+—————————————————+ ; ; 2 bytes 1 byte 1 byte 124 bytes (Total 128 bytes) ; next Pointer to next buffer on this buffer chain (or 0 if no more) ; Nbytes Number of bytes in this buffer that are valid ; Nread Number of bytes read from this buffer (used by getchar) ; data 124 bytes of data (not all is necessarily valid, see Nbytes field) ; ; The buffer pool is all here, and as processes need buffer space, it is all ; allocated out of this pool. See allocate_buffer and free_buffer code. ;————————————————————————— ; return in HL a pointer to a free buffer. If there are not more buffers, ; return with Z flag set. ; destroys no registers except return value HL. ; IS CALLED FROM AN INTERRUPT ROUTINE, so this operation is atomic. allocate_buffer: push bc push af ld hl,(free) ;get pointer to head of free list ld a,h or l jp nz,OK_allocate_buffer ; assure we’re not off the end ;get here if no more buffers. Return Z set - do not disturb A. pop af ld b,a ; tuck A away for a moment… xor a ; turn on Z bit ld a,b ; retreive original A pop bc ret OK_allocate_buffer: xor a ld c,(hl) ;grab lo byte of next free buffer ld (hl),a ; clear it out inc hl ld b,(hl) ; “ld bc,(hl)” now hi byte ld (hl),a ; clear it out, too ld (free),bc ; update with new free list pointer dec hl ; Now HL is at head of new buffer pop af ld b,a ; tuck A away for a moment… ld a,1 or a ; Turn Z bit off (i.e., all OK) ld a,b ; retreive original A pop bc ret ;————————————————————————— ; free_buffer gets passed a pointer (in HL) to a buffer to be freed. The ; buffer is placed on the head of the free list. The nbytes & nread fields ; are made 0 before placing on free list. ; THIS ROUTINE IS CALLED AT INTERRUPT LEVEL, so results are atomic. ; no registers are disturbed at all. The FREE pointer is updated, however. ; 159 T states [ 63.6 usec @ 2.5 MHz ] free_buffer: push af push bc ;we’ll use these push hl ;this will be new head of free list ld bc,(free) ;get old free head ld (hl),c ;put on free chain, first low byte… inc hl ld (hl),b ; …now hi byte xor a inc hl ld (hl),a ; zero out nbytes field inc hl ld (hl),a ; and the nread field of new head of free pop hl ;get new head of free list back ld (free),hl ;and save it in memory where it belongs pop bc pop af ret ; ————————————————————————– ; putchar - HL contains pointer to buffer, A contains the character to put ; into the buffer. Upon return, char is put into this buffer if ther is ; room, else another buffer is allocated and HL is updated to point to this ; new buffer. The new buffer is chained onto the old buffer in this case. ; The calling routine is responsible for maintaing both the head of a ; particular buffer chain (if it needs it), and the current buffer being ; manipulated. THIS ROUTINE IS CALLED AT INTERRUPT LEVEL, so is atomic. No ; registers disturbed, except that HL may have a new value. ; 211 T states [ 84.4 usec @ 2.5 MHz ] no new buffer required ; 338 T states [ 135.2 usec @ 2.5 MHz ] New buffer needed ; [JDZ] If carry flag is on, then memory is not enough to putchar. putchar: push bc push ix push af push hl ;do it this way for a reason… pop ix ;get buffer pointer into IX ld a,(ix+2) ;grab nbytes field cp 124 ;max of 124 chars in a buffer jp nz,putc1 call putc_need_new_buffer ; if it takes this call, it returns with a new buffer, with HL pointing to ; it (as well as IX), and with A reg set to 0. ; else just plunk into buffer jp nc,putc1 pop af scf jp putc2 putc1: inc (ix+2) ;one more char will go into this buffer ld c,a ;get previous nbytes xor a ld b,a ; bc <- nbytes, filled out to 16 bits add ix,bc ; update ix to point to where char goes pop af ; retreive the char we want to save ld (ix+4),a ; save it in this buffer or a ; reset Cy flag. putc2: pop ix pop bc ret ;done for the moment ; 127 T states [ 50.8 usec @ 2.5 MHz ] (really part of prev routine) putc_need_new_buffer: ;prev buffer filled, get a new one push de ; working registers push hl ; save current buffer pointer call allocate_buffer ; grab a new buffer, addr is in HL jp nz,putcnb1 pop hl scf jp putcnb2 putcnb1: ex de,hl ; “ld de,hl” - get new addr into DE for now pop hl ld (hl),e ; link new buffer onto chain, lo byte first inc hl ld (hl),d ; now hi byte, chaining done ex de,hl ; update HL for orig. calling routine’s use push hl pop ix ; upper routine needs ix pointing to new buf xor a ; and A is nbytes in calling routine, make.. ; zero for a new buffer putcnb2: pop de ; done with this working register ret ; all done here, let calling routine finish ; ————————————————————————– ; getchar - grab a character from the buffer pointed at by HL, return in A. ; if the “nread” field of this buf = “nbytes” then this buffer is exhausted, ; so follow the chain on to the next buffer & release old buffer. If the ; next chain is 0, or if the nbytes field is >= nread field, then there are ; no more bytes. In this case, return with Z bit set; normally return with ; Z bit reset (That is, non-zero) indicating a valid char is in A. Note ; that if we need to follow the chain to a new buffer, HL will be updated, ; too, so that the calling routine needs to deal with this. ; no registers changed except AF and possibly HL. ; CALLED AT INTERRUPT LEVEL, so operation is atomic. ; 212 T states [ 84.8 usec @ 2.5 MHz ] No new buffer needed ; 493 T states [ 197.2 usec @ 2.5 MHz ] if following chain getchar: push ix ; save because is working reg push bc ; working regs here push hl pop ix ; ix points to this buffer ld a,(ix+3) ; grab Nread cp (ix+2) ; compare with Nbytes call z,getc_new_buf ; if they are same, this buffer is spent inc (ix+3) ; we are reading one more char, update Nread inc a cp (ix+2) jp nz,getc_pluck_character ; if not looking at last character ; else, is the “next” pointer 0? push hl ld b,a ; !!!!! SAVE A REG !!!!!!! 4 Jan 87 ld a,(hl) inc hl or (hl) ld a,b ; !!!! Restore A Reg (Gasp!) pop hl jp nz,getc_pluck_character ; else next is 0 and we are on last char - flush it & quit call free_buffer pop bc pop ix ret ; note that Z bit is set (from above) ; else we can just pluck a character out of this buffer getc_pluck_character: dec a ; fix A from above mucking around… ld c,a ; get old Nread into BC ld b,0 ; ditto add ix,bc ; fix buffer pointer ld a,1 or a ; make Z bit reset ld a,(ix+4) ; get the desired byte pop bc pop ix ret ; all for this simple case ; old buffer is spent, get new one (if any) getc_new_buf: push de ; need this reg here ld e,(hl) ; get lo byte of Next pointer inc hl ld d,(hl) ; hi byte of Next pointer (now all in DE) dec hl ; HL now back to point at spent buffer call free_buffer ; give the buffer back ex de,hl ; “ld hl,de” - follow chain push hl pop ix ; init new IX (same as HL in this routine) xor a ; A holds Nread (needed above) pop de ; release DE from use by this excursion ret ; ————————————————————————– ; free_chain - MUST be called from interrupt routine to guarantee ; atomicity. Takes buffer chain pointed at by HL and returns them to free ; buffer list ; 303 T states + (n_on_chain-1)*238 T states ; [ 121.2 usec + (n_on_chain-1)*95.2 usec ] free_chain: push af push de push hl ; we will muck with these fc_0: ld e,(hl) ; get lo part of next buffer pointer inc hl ld d,(hl) ; now hi part of next buffer pointer dec hl call free_buffer ; release this buffer ld a,d or e jp z,fc_9 ; if “next” address is 0, we are at end ; else we’ve got more on this chain - deal with them. ex de,hl ; “ld hl,de” - HL points to “next” jp fc_0 fc_9: pop hl pop de pop af ret ; ————————————————————————– ; out_queue_insert - Places the just-received buffer on the output queue. ; The address of the RX buffer just received is in HL. ; The output queue is a circular buffer. The output routine keeps sending ; out buffers until its out_head_cbuf pointer equals its out_tail_cbuf ; pointer. The output routine never mucks with the out_tail_cbuf pointer; ; similarly, this routine never changes the out_head_cbuf pointer. So it ; is possible to ; insert new entries into the output circular buffer queue without ; disturbing the entry which is being sent to the output port. out_queue_insert: push af push de push hl ; use these ex de,hl ; “ld de,hl” - move buffer to link addr ld hl,(out_tail_cbuf) ; Grab next free location ld (hl),e ; set lo addr 1st inc hl ld (hl),d ; now hi addr inc hl ; Now HL points to next free entry in… ld de,out_bottom ; …circ buf, unless we’re at end or a ; clear carry push hl ; (may be be needed address) sbc hl,de pop hl ; get back what we think is good jp nz,oqi_0 ld hl,Out_Top ; get here if we’re at end of circ buffer. oqi_0: ld (out_tail_cbuf),hl pop hl pop de pop af ; keep clean ret ;————————————————————————— ; TX_Queue_Insert - similar to Out_queue_insert, but with different queue. ; Also, increments the byte TX_Outstanding (which counts the number of ; frames ready to be dumped to the modem port). This routine, like ; out_queue_insert, does not need to worry about queue wrap-around because ; there are more entries in each of these queues than there are buffers ; available. Yes, I know this is a hack, and wastes some RAM space, but it ; means I don’t have to check for overflows here. ; The queue is circular, and sometimes I call it a “CBuf” - Circular Buffer TX_Queue_Insert: push af push de push hl ex de,hl ; “ld de,hl” - save chain head in DE ld hl,(TX_Tail_CBuf) ; Next free location in TX CBuf ld (hl),e inc hl ld (hl),d ; put this chain into TX Queue inc hl ; HL is next availble TX Queue … ld de,TX_Bottom ; … unless we are at bottom of … or a ; … the TX Queue push hl sbc hl,de pop hl jp nz,TQI_0 ; go there if not at buffer bottom ld hl,TX_Top ; else reload with top of queue val TQI_0: ld (TX_Tail_CBuf),hl ; save next free queue slot ld hl,TX_Outstanding inc (hl) ; +1 more frame outstanding now pop hl pop de pop af ret ;—————————————————————————– ; Setup HL & TX_Chain_Head for transmission of next chain. TXnext_CBuf: push af push de ld hl,(TX_Head_CBuf) ld e,(hl) inc hl ld d,(hl) ; DE -> next chain to transmit inc hl ; HL MIGHT be next CBuf entry pointer push de ld de,TX_Bottom or a ;clear carry push hl ;save what might be correct value sbc hl,de pop hl pop de jp nz,TXn_1 ;go there if not at end of circ. buf ld hl,TX_Top ;else we wrap aroune TXn_1: ld (TX_Head_CBuf),hl ;save next circ buf pointer in mem ex de,hl ;return ptr to next chain to TX in HL ld (TX_Chain_Head),hl ;TX RCA routine needs this pop de pop af ret ;—————————————————————————– STA_on: ;Turn the STA LED on. ASSUMES that interrupts are disabled! push af ld a,5 out (A_ctl),a ; ready to write WR5 ld a,(A_WR5) ; get memory copy and NOT ALED ; set DTR bit to 0 so LED goes on out (A_ctl),a ; Actually turn on STA LED now… ld (A_WR5),a ; update memory copy pop af ret ;—————————————————————————– STA_off: ;Turn the STA LED off. ASSUMES that interrupts are disabled! push af ld a,5 out (A_ctl),a ; ready to write WR5 ld a,(A_WR5) ; get memory copy or ALED ; set DTR bit to 1 so LED goes off out (A_ctl),a ; Actually turn off STA LED now… ld (A_WR5),a ; update memory copy pop af ret ;These routines MUST be called with interrupts disabled! ;—————————————————————————– STA_flip: push af in a,(A_ctl) ;assure we are talking to ch 0 ld a,5 out (A_ctl),a ; ready to write WR5 ld a,(A_WR5) ; get memory copy xor ALED ; [JDZ] out (A_ctl),a ; Actually turn off STA LED now… ld (A_WR5),a ; update memory copy pop af ret ;—————————————————————————– CON_on: push af ld a,5 out (B_ctl),a ld a,BLEDon ld (B_WR5),a ; save in mem for flip routine out (B_ctl),a pop af ret ;—————————————————————————– CON_off: push af ld a,5 out (B_ctl),a ld a,BLEDoff ld (B_WR5),a ; save in mem for flip routine out (B_ctl),a pop af ret ;—————————————————————————– CON_flip: push af in a,(B_ctl) ;assure we are talking to ch 0 ld a,5 out (B_ctl),a ; ready to write WR5 ld a,(B_WR5) ; get memory copy xor BLED ; [JDZ] out (B_ctl),a ; Actually turn off CON LED now… ld (B_WR5),a ; update memory copy pop af ret ; SIO Initialize data. a_init: db 18h,4,20h,1,1bh,7,7eh,5,ALEDoff,3,0c9h ;For Modem a_size equ $-a_init b_init: ;[JDZ] For TTY db 18h,4,44h,2,I_Vector mod 256,3,Auto_Enable,5,BLEDoff,1,1fh b_size equ $-b_init ;This is the data area which gets blasted into RAM upon startup: [JDZ] data_init: TXdelay equ Free_RAM - data_init + $ db 33 ; TX delay default is 330 ms Persistence equ Free_RAM - data_init + $ db 63 ; default value for Persistence SlotTime equ Free_RAM - data_init + $ db 5 ; and Slot Time defaults to 50 ms TailTime equ Free_RAM - data_init + $ db 3 ; (should be 11 for 300 baud) ; Tail Timer default Full_Duplex equ Free_RAM - data_init + $ db 0 ;not Full Duplex to start CTS_Control equ Free_RAM - data_init + $ db 0 ;not CTS Control to start Soft_DCD equ Free_RAM - data_init + $ db 1 ;not Soft DCD to start RX_State equ Free_RAM - data_init + $ db 0 ;Means we are in Recieving State RX_Allocated_Buffer equ Free_RAM - data_init + $ db 0 ;set non-zero if we’re in RX state RX_buf equ Free_RAM - data_init + $ dw 0 ;address of current Receive buffer RX_head equ Free_RAM - data_init + $ dw 0 ;address of 1st RX buffer RX_Flushing equ Free_RAM - data_init + $ db 0 ;is non-0 if we ran out of buffer ;space and are currently flushing this ;frame being received. Used by ;ia_rca and reset by ia_ext. TX_State equ Free_RAM - data_init + $ db 0 ;TX state. ;0 : we’re not in TX state ;1 : we’re in slot time state ;2 : we’re in TX delay state ;3 : we’re in waiting CTS is turn on ;4 : we’re in Transmit data state ;5 : we’re in Tail time state TX_Started equ Free_RAM - data_init + $ db 0 ;non-zero if we’ve begun TXing chars TX_Outstanding equ Free_RAM - data_init + $ db 0 ;Number of TX CBufs queued up for TX TX_Head_CBuf equ Free_RAM - data_init + $ dw TX_Top ;Current active CBuf entry (if active) TX_Tail_CBuf equ Free_RAM - data_init + $ dw TX_Top ;next free CBuf entry TX_Chain_Head equ Free_RAM - data_init + $ dw 0 ;holds address of the current buffer ;chain head that we are transmitting TX_Timer equ Free_RAM - data_init + $ db 0 A_RR0 equ Free_RAM - data_init + $ db CTS A_WR5 equ Free_RAM - data_init + $ db ALEDoff ;state of STA LED & RTS (PTT) line, ;mainly… (For Ch A only [modem] ) B_WR5 equ Free_RAM - data_init + $ db BLEDoff ;these next two are used by the IB_TBE interrupt routine. Out_esc_mode equ Free_RAM - data_init + $ db 0 ; not in escaped mode Out_char equ Free_RAM - data_init + $ ds 1 ; next char to send if escaped mode in_break equ Free_RAM - data_init + $ db 0 ; non-zero if we are in a break detect ; sequence on the async port In_Buffer equ Free_RAM - data_init + $ dw 0 ;addr of current Input buffer In_Head equ Free_RAM - data_init + $ dw 0 ;addr of 1st Input Buffer In_Allocated_Buffer equ Free_RAM - data_init + $ db 0 ;is not 0 if we’ve already alloc’d buf In_State equ Free_RAM - data_init + $ db 1 ;convert back to 1 in v.32 code ;input state machine state ;4 Mar 8: Make it 0 (from 1) becuz ;noise on line is first triggering the ;code to assume that a frame is coming ;from the host….. Comment below was ;appropriate before ;assume that we’ve seen an FEND from ;(non-existent) “previous” frame. This ;means that when we are receiving data ;from user, there need be ONLY the ;FEND char at the end of a frame, and ;not at the beginning (although if a ;FEND is at the beginning, it is ;ignored.) Out_Started equ Free_RAM - data_init + $ db 0 ;Output not started yet (Logical var) Out_Head_CBuf equ Free_RAM - data_init + $ dw Out_Top ;address of buffer to be output rs232 Out_Tail_CBuf equ Free_RAM - data_init + $ dw Out_Top ;pointer to next free output buffer Out_Chain_Head equ Free_RAM - data_init + $ dw 0 ;addr of buffer we are now outputting free equ Free_RAM - data_init + $ dw Bottom ;address of 1st buffer on free list data_size equ $-data_init Out_Address equ free+2 ;address of output following data ;ds 1 buffer_area equ Out_Address+1 TX_Top equ buffer_area ;“top” of output circular buffer ; 255 out buffer chains pending, max TX_Bottom equ TX_Top+2*255 ;“bottom” of output circular buffer Out_Top equ TX_Bottom+2 Out_Bottom equ Out_Top+2*255 Bottom equ Out_Bottom+2 ;end of all code & predefined data ;*************************************************************************** ; out = to TTY port; in = from TTY port ; TX = to modem; RX = from modem ; ; ; means that that code executes without interrupts enabled (except ; for the initialization code) end start
global _foo:function _foo:
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Copyright (c) 2011-2012 Litecoin Developers // Copyright (c) 2013 livecoin Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <boost/foreach.hpp> #include <boost/tuple/tuple.hpp> using namespace std; using namespace boost; #include "script.h" #include "keystore.h" #include "bignum.h" #include "key.h" #include "main.h" #include "sync.h" #include "util.h" bool CheckSig(vector<unsigned char> vchSig, vector<unsigned char> vchPubKey, CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType); typedef vector<unsigned char> valtype; static const valtype vchFalse(0); static const valtype vchZero(0); static const valtype vchTrue(1, 1); static const CBigNum bnZero(0); static const CBigNum bnOne(1); static const CBigNum bnFalse(0); static const CBigNum bnTrue(1); static const size_t nMaxNumSize = 4; CBigNum CastToBigNum(const valtype& vch) { if (vch.size() > nMaxNumSize) throw runtime_error("CastToBigNum() : overflow"); // Get rid of extra leading zeros return CBigNum(CBigNum(vch).getvch()); } bool CastToBool(const valtype& vch) { for (unsigned int i = 0; i < vch.size(); i++) { if (vch[i] != 0) { // Can be negative zero if (i == vch.size()-1 && vch[i] == 0x80) return false; return true; } } return false; } void MakeSameSize(valtype& vch1, valtype& vch2) { // Lengthen the shorter one if (vch1.size() < vch2.size()) vch1.resize(vch2.size(), 0); if (vch2.size() < vch1.size()) vch2.resize(vch1.size(), 0); } // // Script is a stack machine (like Forth) that evaluates a predicate // returning a bool indicating valid or not. There are no loops. // #define stacktop(i) (stack.at(stack.size()+(i))) #define altstacktop(i) (altstack.at(altstack.size()+(i))) static inline void popstack(vector<valtype>& stack) { if (stack.empty()) throw runtime_error("popstack() : stack empty"); stack.pop_back(); } const char* GetTxnOutputType(txnouttype t) { switch (t) { case TX_NONSTANDARD: return "nonstandard"; case TX_PUBKEY: return "pubkey"; case TX_PUBKEYHASH: return "pubkeyhash"; case TX_SCRIPTHASH: return "scripthash"; case TX_MULTISIG: return "multisig"; } return NULL; } const char* GetOpName(opcodetype opcode) { switch (opcode) { // push value case OP_0 : return "0"; case OP_PUSHDATA1 : return "OP_PUSHDATA1"; case OP_PUSHDATA2 : return "OP_PUSHDATA2"; case OP_PUSHDATA4 : return "OP_PUSHDATA4"; case OP_1NEGATE : return "-1"; case OP_RESERVED : return "OP_RESERVED"; case OP_1 : return "1"; case OP_2 : return "2"; case OP_3 : return "3"; case OP_4 : return "4"; case OP_5 : return "5"; case OP_6 : return "6"; case OP_7 : return "7"; case OP_8 : return "8"; case OP_9 : return "9"; case OP_10 : return "10"; case OP_11 : return "11"; case OP_12 : return "12"; case OP_13 : return "13"; case OP_14 : return "14"; case OP_15 : return "15"; case OP_16 : return "16"; // control case OP_NOP : return "OP_NOP"; case OP_VER : return "OP_VER"; case OP_IF : return "OP_IF"; case OP_NOTIF : return "OP_NOTIF"; case OP_VERIF : return "OP_VERIF"; case OP_VERNOTIF : return "OP_VERNOTIF"; case OP_ELSE : return "OP_ELSE"; case OP_ENDIF : return "OP_ENDIF"; case OP_VERIFY : return "OP_VERIFY"; case OP_RETURN : return "OP_RETURN"; // stack ops case OP_TOALTSTACK : return "OP_TOALTSTACK"; case OP_FROMALTSTACK : return "OP_FROMALTSTACK"; case OP_2DROP : return "OP_2DROP"; case OP_2DUP : return "OP_2DUP"; case OP_3DUP : return "OP_3DUP"; case OP_2OVER : return "OP_2OVER"; case OP_2ROT : return "OP_2ROT"; case OP_2SWAP : return "OP_2SWAP"; case OP_IFDUP : return "OP_IFDUP"; case OP_DEPTH : return "OP_DEPTH"; case OP_DROP : return "OP_DROP"; case OP_DUP : return "OP_DUP"; case OP_NIP : return "OP_NIP"; case OP_OVER : return "OP_OVER"; case OP_PICK : return "OP_PICK"; case OP_ROLL : return "OP_ROLL"; case OP_ROT : return "OP_ROT"; case OP_SWAP : return "OP_SWAP"; case OP_TUCK : return "OP_TUCK"; // splice ops case OP_CAT : return "OP_CAT"; case OP_SUBSTR : return "OP_SUBSTR"; case OP_LEFT : return "OP_LEFT"; case OP_RIGHT : return "OP_RIGHT"; case OP_SIZE : return "OP_SIZE"; // bit logic case OP_INVERT : return "OP_INVERT"; case OP_AND : return "OP_AND"; case OP_OR : return "OP_OR"; case OP_XOR : return "OP_XOR"; case OP_EQUAL : return "OP_EQUAL"; case OP_EQUALVERIFY : return "OP_EQUALVERIFY"; case OP_RESERVED1 : return "OP_RESERVED1"; case OP_RESERVED2 : return "OP_RESERVED2"; // numeric case OP_1ADD : return "OP_1ADD"; case OP_1SUB : return "OP_1SUB"; case OP_2MUL : return "OP_2MUL"; case OP_2DIV : return "OP_2DIV"; case OP_NEGATE : return "OP_NEGATE"; case OP_ABS : return "OP_ABS"; case OP_NOT : return "OP_NOT"; case OP_0NOTEQUAL : return "OP_0NOTEQUAL"; case OP_ADD : return "OP_ADD"; case OP_SUB : return "OP_SUB"; case OP_MUL : return "OP_MUL"; case OP_DIV : return "OP_DIV"; case OP_MOD : return "OP_MOD"; case OP_LSHIFT : return "OP_LSHIFT"; case OP_RSHIFT : return "OP_RSHIFT"; case OP_BOOLAND : return "OP_BOOLAND"; case OP_BOOLOR : return "OP_BOOLOR"; case OP_NUMEQUAL : return "OP_NUMEQUAL"; case OP_NUMEQUALVERIFY : return "OP_NUMEQUALVERIFY"; case OP_NUMNOTEQUAL : return "OP_NUMNOTEQUAL"; case OP_LESSTHAN : return "OP_LESSTHAN"; case OP_GREATERTHAN : return "OP_GREATERTHAN"; case OP_LESSTHANOREQUAL : return "OP_LESSTHANOREQUAL"; case OP_GREATERTHANOREQUAL : return "OP_GREATERTHANOREQUAL"; case OP_MIN : return "OP_MIN"; case OP_MAX : return "OP_MAX"; case OP_WITHIN : return "OP_WITHIN"; // crypto case OP_RIPEMD160 : return "OP_RIPEMD160"; case OP_SHA1 : return "OP_SHA1"; case OP_SHA256 : return "OP_SHA256"; case OP_HASH160 : return "OP_HASH160"; case OP_HASH256 : return "OP_HASH256"; case OP_CODESEPARATOR : return "OP_CODESEPARATOR"; case OP_CHECKSIG : return "OP_CHECKSIG"; case OP_CHECKSIGVERIFY : return "OP_CHECKSIGVERIFY"; case OP_CHECKMULTISIG : return "OP_CHECKMULTISIG"; case OP_CHECKMULTISIGVERIFY : return "OP_CHECKMULTISIGVERIFY"; // expanson case OP_NOP1 : return "OP_NOP1"; case OP_NOP2 : return "OP_NOP2"; case OP_NOP3 : return "OP_NOP3"; case OP_NOP4 : return "OP_NOP4"; case OP_NOP5 : return "OP_NOP5"; case OP_NOP6 : return "OP_NOP6"; case OP_NOP7 : return "OP_NOP7"; case OP_NOP8 : return "OP_NOP8"; case OP_NOP9 : return "OP_NOP9"; case OP_NOP10 : return "OP_NOP10"; // template matching params case OP_PUBKEYHASH : return "OP_PUBKEYHASH"; case OP_PUBKEY : return "OP_PUBKEY"; case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE"; default: return "OP_UNKNOWN"; } } bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType) { CAutoBN_CTX pctx; CScript::const_iterator pc = script.begin(); CScript::const_iterator pend = script.end(); CScript::const_iterator pbegincodehash = script.begin(); opcodetype opcode; valtype vchPushValue; vector<bool> vfExec; vector<valtype> altstack; if (script.size() > 10000) return false; int nOpCount = 0; try { while (pc < pend) { bool fExec = !count(vfExec.begin(), vfExec.end(), false); // // Read instruction // if (!script.GetOp(pc, opcode, vchPushValue)) return false; if (vchPushValue.size() > 520) return false; if (opcode > OP_16 && ++nOpCount > 201) return false; if (opcode == OP_CAT || opcode == OP_SUBSTR || opcode == OP_LEFT || opcode == OP_RIGHT || opcode == OP_INVERT || opcode == OP_AND || opcode == OP_OR || opcode == OP_XOR || opcode == OP_2MUL || opcode == OP_2DIV || opcode == OP_MUL || opcode == OP_DIV || opcode == OP_MOD || opcode == OP_LSHIFT || opcode == OP_RSHIFT) return false; if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) stack.push_back(vchPushValue); else if (fExec || (OP_IF <= opcode && opcode <= OP_ENDIF)) switch (opcode) { // // Push value // case OP_1NEGATE: case OP_1: case OP_2: case OP_3: case OP_4: case OP_5: case OP_6: case OP_7: case OP_8: case OP_9: case OP_10: case OP_11: case OP_12: case OP_13: case OP_14: case OP_15: case OP_16: { // ( -- value) CBigNum bn((int)opcode - (int)(OP_1 - 1)); stack.push_back(bn.getvch()); } break; // // Control // case OP_NOP: case OP_NOP1: case OP_NOP2: case OP_NOP3: case OP_NOP4: case OP_NOP5: case OP_NOP6: case OP_NOP7: case OP_NOP8: case OP_NOP9: case OP_NOP10: break; case OP_IF: case OP_NOTIF: { // <expression> if [statements] [else [statements]] endif bool fValue = false; if (fExec) { if (stack.size() < 1) return false; valtype& vch = stacktop(-1); fValue = CastToBool(vch); if (opcode == OP_NOTIF) fValue = !fValue; popstack(stack); } vfExec.push_back(fValue); } break; case OP_ELSE: { if (vfExec.empty()) return false; vfExec.back() = !vfExec.back(); } break; case OP_ENDIF: { if (vfExec.empty()) return false; vfExec.pop_back(); } break; case OP_VERIFY: { // (true -- ) or // (false -- false) and return if (stack.size() < 1) return false; bool fValue = CastToBool(stacktop(-1)); if (fValue) popstack(stack); else return false; } break; case OP_RETURN: { return false; } break; // // Stack ops // case OP_TOALTSTACK: { if (stack.size() < 1) return false; altstack.push_back(stacktop(-1)); popstack(stack); } break; case OP_FROMALTSTACK: { if (altstack.size() < 1) return false; stack.push_back(altstacktop(-1)); popstack(altstack); } break; case OP_2DROP: { // (x1 x2 -- ) if (stack.size() < 2) return false; popstack(stack); popstack(stack); } break; case OP_2DUP: { // (x1 x2 -- x1 x2 x1 x2) if (stack.size() < 2) return false; valtype vch1 = stacktop(-2); valtype vch2 = stacktop(-1); stack.push_back(vch1); stack.push_back(vch2); } break; case OP_3DUP: { // (x1 x2 x3 -- x1 x2 x3 x1 x2 x3) if (stack.size() < 3) return false; valtype vch1 = stacktop(-3); valtype vch2 = stacktop(-2); valtype vch3 = stacktop(-1); stack.push_back(vch1); stack.push_back(vch2); stack.push_back(vch3); } break; case OP_2OVER: { // (x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2) if (stack.size() < 4) return false; valtype vch1 = stacktop(-4); valtype vch2 = stacktop(-3); stack.push_back(vch1); stack.push_back(vch2); } break; case OP_2ROT: { // (x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2) if (stack.size() < 6) return false; valtype vch1 = stacktop(-6); valtype vch2 = stacktop(-5); stack.erase(stack.end()-6, stack.end()-4); stack.push_back(vch1); stack.push_back(vch2); } break; case OP_2SWAP: { // (x1 x2 x3 x4 -- x3 x4 x1 x2) if (stack.size() < 4) return false; swap(stacktop(-4), stacktop(-2)); swap(stacktop(-3), stacktop(-1)); } break; case OP_IFDUP: { // (x - 0 | x x) if (stack.size() < 1) return false; valtype vch = stacktop(-1); if (CastToBool(vch)) stack.push_back(vch); } break; case OP_DEPTH: { // -- stacksize CBigNum bn(stack.size()); stack.push_back(bn.getvch()); } break; case OP_DROP: { // (x -- ) if (stack.size() < 1) return false; popstack(stack); } break; case OP_DUP: { // (x -- x x) if (stack.size() < 1) return false; valtype vch = stacktop(-1); stack.push_back(vch); } break; case OP_NIP: { // (x1 x2 -- x2) if (stack.size() < 2) return false; stack.erase(stack.end() - 2); } break; case OP_OVER: { // (x1 x2 -- x1 x2 x1) if (stack.size() < 2) return false; valtype vch = stacktop(-2); stack.push_back(vch); } break; case OP_PICK: case OP_ROLL: { // (xn ... x2 x1 x0 n - xn ... x2 x1 x0 xn) // (xn ... x2 x1 x0 n - ... x2 x1 x0 xn) if (stack.size() < 2) return false; int n = CastToBigNum(stacktop(-1)).getint(); popstack(stack); if (n < 0 || n >= (int)stack.size()) return false; valtype vch = stacktop(-n-1); if (opcode == OP_ROLL) stack.erase(stack.end()-n-1); stack.push_back(vch); } break; case OP_ROT: { // (x1 x2 x3 -- x2 x3 x1) // x2 x1 x3 after first swap // x2 x3 x1 after second swap if (stack.size() < 3) return false; swap(stacktop(-3), stacktop(-2)); swap(stacktop(-2), stacktop(-1)); } break; case OP_SWAP: { // (x1 x2 -- x2 x1) if (stack.size() < 2) return false; swap(stacktop(-2), stacktop(-1)); } break; case OP_TUCK: { // (x1 x2 -- x2 x1 x2) if (stack.size() < 2) return false; valtype vch = stacktop(-1); stack.insert(stack.end()-2, vch); } break; // // Splice ops // case OP_CAT: { // (x1 x2 -- out) if (stack.size() < 2) return false; valtype& vch1 = stacktop(-2); valtype& vch2 = stacktop(-1); vch1.insert(vch1.end(), vch2.begin(), vch2.end()); popstack(stack); if (stacktop(-1).size() > 520) return false; } break; case OP_SUBSTR: { // (in begin size -- out) if (stack.size() < 3) return false; valtype& vch = stacktop(-3); int nBegin = CastToBigNum(stacktop(-2)).getint(); int nEnd = nBegin + CastToBigNum(stacktop(-1)).getint(); if (nBegin < 0 || nEnd < nBegin) return false; if (nBegin > (int)vch.size()) nBegin = vch.size(); if (nEnd > (int)vch.size()) nEnd = vch.size(); vch.erase(vch.begin() + nEnd, vch.end()); vch.erase(vch.begin(), vch.begin() + nBegin); popstack(stack); popstack(stack); } break; case OP_LEFT: case OP_RIGHT: { // (in size -- out) if (stack.size() < 2) return false; valtype& vch = stacktop(-2); int nSize = CastToBigNum(stacktop(-1)).getint(); if (nSize < 0) return false; if (nSize > (int)vch.size()) nSize = vch.size(); if (opcode == OP_LEFT) vch.erase(vch.begin() + nSize, vch.end()); else vch.erase(vch.begin(), vch.end() - nSize); popstack(stack); } break; case OP_SIZE: { // (in -- in size) if (stack.size() < 1) return false; CBigNum bn(stacktop(-1).size()); stack.push_back(bn.getvch()); } break; // // Bitwise logic // case OP_INVERT: { // (in - out) if (stack.size() < 1) return false; valtype& vch = stacktop(-1); for (unsigned int i = 0; i < vch.size(); i++) vch[i] = ~vch[i]; } break; case OP_AND: case OP_OR: case OP_XOR: { // (x1 x2 - out) if (stack.size() < 2) return false; valtype& vch1 = stacktop(-2); valtype& vch2 = stacktop(-1); MakeSameSize(vch1, vch2); if (opcode == OP_AND) { for (unsigned int i = 0; i < vch1.size(); i++) vch1[i] &= vch2[i]; } else if (opcode == OP_OR) { for (unsigned int i = 0; i < vch1.size(); i++) vch1[i] |= vch2[i]; } else if (opcode == OP_XOR) { for (unsigned int i = 0; i < vch1.size(); i++) vch1[i] ^= vch2[i]; } popstack(stack); } break; case OP_EQUAL: case OP_EQUALVERIFY: //case OP_NOTEQUAL: // use OP_NUMNOTEQUAL { // (x1 x2 - bool) if (stack.size() < 2) return false; valtype& vch1 = stacktop(-2); valtype& vch2 = stacktop(-1); bool fEqual = (vch1 == vch2); // OP_NOTEQUAL is disabled because it would be too easy to say // something like n != 1 and have some wiseguy pass in 1 with extra // zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001) //if (opcode == OP_NOTEQUAL) // fEqual = !fEqual; popstack(stack); popstack(stack); stack.push_back(fEqual ? vchTrue : vchFalse); if (opcode == OP_EQUALVERIFY) { if (fEqual) popstack(stack); else return false; } } break; // // Numeric // case OP_1ADD: case OP_1SUB: case OP_2MUL: case OP_2DIV: case OP_NEGATE: case OP_ABS: case OP_NOT: case OP_0NOTEQUAL: { // (in -- out) if (stack.size() < 1) return false; CBigNum bn = CastToBigNum(stacktop(-1)); switch (opcode) { case OP_1ADD: bn += bnOne; break; case OP_1SUB: bn -= bnOne; break; case OP_2MUL: bn <<= 1; break; case OP_2DIV: bn >>= 1; break; case OP_NEGATE: bn = -bn; break; case OP_ABS: if (bn < bnZero) bn = -bn; break; case OP_NOT: bn = (bn == bnZero); break; case OP_0NOTEQUAL: bn = (bn != bnZero); break; default: assert(!"invalid opcode"); break; } popstack(stack); stack.push_back(bn.getvch()); } break; case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: case OP_MOD: case OP_LSHIFT: case OP_RSHIFT: case OP_BOOLAND: case OP_BOOLOR: case OP_NUMEQUAL: case OP_NUMEQUALVERIFY: case OP_NUMNOTEQUAL: case OP_LESSTHAN: case OP_GREATERTHAN: case OP_LESSTHANOREQUAL: case OP_GREATERTHANOREQUAL: case OP_MIN: case OP_MAX: { // (x1 x2 -- out) if (stack.size() < 2) return false; CBigNum bn1 = CastToBigNum(stacktop(-2)); CBigNum bn2 = CastToBigNum(stacktop(-1)); CBigNum bn; switch (opcode) { case OP_ADD: bn = bn1 + bn2; break; case OP_SUB: bn = bn1 - bn2; break; case OP_MUL: if (!BN_mul(&bn, &bn1, &bn2, pctx)) return false; break; case OP_DIV: if (!BN_div(&bn, NULL, &bn1, &bn2, pctx)) return false; break; case OP_MOD: if (!BN_mod(&bn, &bn1, &bn2, pctx)) return false; break; case OP_LSHIFT: if (bn2 < bnZero || bn2 > CBigNum(2048)) return false; bn = bn1 << bn2.getulong(); break; case OP_RSHIFT: if (bn2 < bnZero || bn2 > CBigNum(2048)) return false; bn = bn1 >> bn2.getulong(); break; case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break; case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break; case OP_NUMEQUAL: bn = (bn1 == bn2); break; case OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break; case OP_NUMNOTEQUAL: bn = (bn1 != bn2); break; case OP_LESSTHAN: bn = (bn1 < bn2); break; case OP_GREATERTHAN: bn = (bn1 > bn2); break; case OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break; case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break; case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break; case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break; default: assert(!"invalid opcode"); break; } popstack(stack); popstack(stack); stack.push_back(bn.getvch()); if (opcode == OP_NUMEQUALVERIFY) { if (CastToBool(stacktop(-1))) popstack(stack); else return false; } } break; case OP_WITHIN: { // (x min max -- out) if (stack.size() < 3) return false; CBigNum bn1 = CastToBigNum(stacktop(-3)); CBigNum bn2 = CastToBigNum(stacktop(-2)); CBigNum bn3 = CastToBigNum(stacktop(-1)); bool fValue = (bn2 <= bn1 && bn1 < bn3); popstack(stack); popstack(stack); popstack(stack); stack.push_back(fValue ? vchTrue : vchFalse); } break; // // Crypto // case OP_RIPEMD160: case OP_SHA1: case OP_SHA256: case OP_HASH160: case OP_HASH256: { // (in -- hash) if (stack.size() < 1) return false; valtype& vch = stacktop(-1); valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32); if (opcode == OP_RIPEMD160) RIPEMD160(&vch[0], vch.size(), &vchHash[0]); else if (opcode == OP_SHA1) SHA1(&vch[0], vch.size(), &vchHash[0]); else if (opcode == OP_SHA256) SHA256(&vch[0], vch.size(), &vchHash[0]); else if (opcode == OP_HASH160) { uint160 hash160 = Hash160(vch); memcpy(&vchHash[0], &hash160, sizeof(hash160)); } else if (opcode == OP_HASH256) { uint256 hash = Hash(vch.begin(), vch.end()); memcpy(&vchHash[0], &hash, sizeof(hash)); } popstack(stack); stack.push_back(vchHash); } break; case OP_CODESEPARATOR: { // Hash starts after the code separator pbegincodehash = pc; } break; case OP_CHECKSIG: case OP_CHECKSIGVERIFY: { // (sig pubkey -- bool) if (stack.size() < 2) return false; valtype& vchSig = stacktop(-2); valtype& vchPubKey = stacktop(-1); ////// debug print //PrintHex(vchSig.begin(), vchSig.end(), "sig: %s\n"); //PrintHex(vchPubKey.begin(), vchPubKey.end(), "pubkey: %s\n"); // Subset of script starting at the most recent codeseparator CScript scriptCode(pbegincodehash, pend); // Drop the signature, since there's no way for a signature to sign itself scriptCode.FindAndDelete(CScript(vchSig)); bool fSuccess = CheckSig(vchSig, vchPubKey, scriptCode, txTo, nIn, nHashType); popstack(stack); popstack(stack); stack.push_back(fSuccess ? vchTrue : vchFalse); if (opcode == OP_CHECKSIGVERIFY) { if (fSuccess) popstack(stack); else return false; } } break; case OP_CHECKMULTISIG: case OP_CHECKMULTISIGVERIFY: { // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool) int i = 1; if ((int)stack.size() < i) return false; int nKeysCount = CastToBigNum(stacktop(-i)).getint(); if (nKeysCount < 0 || nKeysCount > 20) return false; nOpCount += nKeysCount; if (nOpCount > 201) return false; int ikey = ++i; i += nKeysCount; if ((int)stack.size() < i) return false; int nSigsCount = CastToBigNum(stacktop(-i)).getint(); if (nSigsCount < 0 || nSigsCount > nKeysCount) return false; int isig = ++i; i += nSigsCount; if ((int)stack.size() < i) return false; // Subset of script starting at the most recent codeseparator CScript scriptCode(pbegincodehash, pend); // Drop the signatures, since there's no way for a signature to sign itself for (int k = 0; k < nSigsCount; k++) { valtype& vchSig = stacktop(-isig-k); scriptCode.FindAndDelete(CScript(vchSig)); } bool fSuccess = true; while (fSuccess && nSigsCount > 0) { valtype& vchSig = stacktop(-isig); valtype& vchPubKey = stacktop(-ikey); // Check signature if (CheckSig(vchSig, vchPubKey, scriptCode, txTo, nIn, nHashType)) { isig++; nSigsCount--; } ikey++; nKeysCount--; // If there are more signatures left than keys left, // then too many signatures have failed if (nSigsCount > nKeysCount) fSuccess = false; } while (i-- > 0) popstack(stack); stack.push_back(fSuccess ? vchTrue : vchFalse); if (opcode == OP_CHECKMULTISIGVERIFY) { if (fSuccess) popstack(stack); else return false; } } break; default: return false; } // Size limits if (stack.size() + altstack.size() > 1000) return false; } } catch (...) { return false; } if (!vfExec.empty()) return false; return true; } uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType) { if (nIn >= txTo.vin.size()) { printf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn); return 1; } CTransaction txTmp(txTo); // In case concatenating two scripts ends up with two codeseparators, // or an extra one at the end, this prevents all those possible incompatibilities. scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR)); // Blank out other inputs' signatures for (unsigned int i = 0; i < txTmp.vin.size(); i++) txTmp.vin[i].scriptSig = CScript(); txTmp.vin[nIn].scriptSig = scriptCode; // Blank out some of the outputs if ((nHashType & 0x1f) == SIGHASH_NONE) { // Wildcard payee txTmp.vout.clear(); // Let the others update at will for (unsigned int i = 0; i < txTmp.vin.size(); i++) if (i != nIn) txTmp.vin[i].nSequence = 0; } else if ((nHashType & 0x1f) == SIGHASH_SINGLE) { // Only lockin the txout payee at same index as txin unsigned int nOut = nIn; if (nOut >= txTmp.vout.size()) { printf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut); return 1; } txTmp.vout.resize(nOut+1); for (unsigned int i = 0; i < nOut; i++) txTmp.vout[i].SetNull(); // Let the others update at will for (unsigned int i = 0; i < txTmp.vin.size(); i++) if (i != nIn) txTmp.vin[i].nSequence = 0; } // Blank out other inputs completely, not recommended for open transactions if (nHashType & SIGHASH_ANYONECANPAY) { txTmp.vin[0] = txTmp.vin[nIn]; txTmp.vin.resize(1); } // Serialize and hash CDataStream ss(SER_GETHASH, 0); ss.reserve(10000); ss << txTmp << nHashType; return Hash(ss.begin(), ss.end()); } // Valid signature cache, to avoid doing expensive ECDSA signature checking // twice for every transaction (once when accepted into memory pool, and // again when accepted into the block chain) class CSignatureCache { private: // sigdata_type is (signature hash, signature, public key): typedef boost::tuple<uint256, std::vector<unsigned char>, std::vector<unsigned char> > sigdata_type; std::set< sigdata_type> setValid; CCriticalSection cs_sigcache; public: bool Get(uint256 hash, const std::vector<unsigned char>& vchSig, const std::vector<unsigned char>& pubKey) { LOCK(cs_sigcache); sigdata_type k(hash, vchSig, pubKey); std::set<sigdata_type>::iterator mi = setValid.find(k); if (mi != setValid.end()) return true; return false; } void Set(uint256 hash, const std::vector<unsigned char>& vchSig, const std::vector<unsigned char>& pubKey) { // DoS prevention: limit cache size to less than 10MB // (~200 bytes per cache entry times 50,000 entries) // Since there are a maximum of 20,000 signature operations per block // 50,000 is a reasonable default. int64 nMaxCacheSize = GetArg("-maxsigcachesize", 50000); if (nMaxCacheSize <= 0) return; LOCK(cs_sigcache); while (static_cast<int64>(setValid.size()) > nMaxCacheSize) { // Evict a random entry. Random because that helps // foil would-be DoS attackers who might try to pre-generate // and re-use a set of valid signatures just-slightly-greater // than our cache size. uint256 randomHash = GetRandHash(); std::vector<unsigned char> unused; std::set<sigdata_type>::iterator it = setValid.lower_bound(sigdata_type(randomHash, unused, unused)); if (it == setValid.end()) it = setValid.begin(); setValid.erase(*it); } sigdata_type k(hash, vchSig, pubKey); setValid.insert(k); } }; bool CheckSig(vector<unsigned char> vchSig, vector<unsigned char> vchPubKey, CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType) { static CSignatureCache signatureCache; // Hash type is one byte tacked on to the end of the signature if (vchSig.empty()) return false; if (nHashType == 0) nHashType = vchSig.back(); else if (nHashType != vchSig.back()) return false; vchSig.pop_back(); uint256 sighash = SignatureHash(scriptCode, txTo, nIn, nHashType); if (signatureCache.Get(sighash, vchSig, vchPubKey)) return true; CKey key; if (!key.SetPubKey(vchPubKey)) return false; if (!key.Verify(sighash, vchSig)) return false; signatureCache.Set(sighash, vchSig, vchPubKey); return true; } // // Return public keys or hashes from scriptPubKey, for 'standard' transaction types. // bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsigned char> >& vSolutionsRet) { // Templates static map<txnouttype, CScript> mTemplates; if (mTemplates.empty()) { // Standard tx, sender provides pubkey, receiver adds signature mTemplates.insert(make_pair(TX_PUBKEY, CScript() << OP_PUBKEY << OP_CHECKSIG)); // Bitcoin address tx, sender provides hash of pubkey, receiver provides signature and pubkey mTemplates.insert(make_pair(TX_PUBKEYHASH, CScript() << OP_DUP << OP_HASH160 << OP_PUBKEYHASH << OP_EQUALVERIFY << OP_CHECKSIG)); // Sender provides N pubkeys, receivers provides M signatures mTemplates.insert(make_pair(TX_MULTISIG, CScript() << OP_SMALLINTEGER << OP_PUBKEYS << OP_SMALLINTEGER << OP_CHECKMULTISIG)); } // Shortcut for pay-to-script-hash, which are more constrained than the other types: // it is always OP_HASH160 20 [20 byte hash] OP_EQUAL if (scriptPubKey.IsPayToScriptHash()) { typeRet = TX_SCRIPTHASH; vector<unsigned char> hashBytes(scriptPubKey.begin()+2, scriptPubKey.begin()+22); vSolutionsRet.push_back(hashBytes); return true; } // Scan templates const CScript& script1 = scriptPubKey; BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates) { const CScript& script2 = tplate.second; vSolutionsRet.clear(); opcodetype opcode1, opcode2; vector<unsigned char> vch1, vch2; // Compare CScript::const_iterator pc1 = script1.begin(); CScript::const_iterator pc2 = script2.begin(); loop { if (pc1 == script1.end() && pc2 == script2.end()) { // Found a match typeRet = tplate.first; if (typeRet == TX_MULTISIG) { // Additional checks for TX_MULTISIG: unsigned char m = vSolutionsRet.front()[0]; unsigned char n = vSolutionsRet.back()[0]; if (m < 1 || n < 1 || m > n || vSolutionsRet.size()-2 != n) return false; } return true; } if (!script1.GetOp(pc1, opcode1, vch1)) break; if (!script2.GetOp(pc2, opcode2, vch2)) break; // Template matching opcodes: if (opcode2 == OP_PUBKEYS) { while (vch1.size() >= 33 && vch1.size() <= 120) { vSolutionsRet.push_back(vch1); if (!script1.GetOp(pc1, opcode1, vch1)) break; } if (!script2.GetOp(pc2, opcode2, vch2)) break; // Normal situation is to fall through // to other if/else statments } if (opcode2 == OP_PUBKEY) { if (vch1.size() < 33 || vch1.size() > 120) break; vSolutionsRet.push_back(vch1); } else if (opcode2 == OP_PUBKEYHASH) { if (vch1.size() != sizeof(uint160)) break; vSolutionsRet.push_back(vch1); } else if (opcode2 == OP_SMALLINTEGER) { // Single-byte small integer pushed onto vSolutions if (opcode1 == OP_0 || (opcode1 >= OP_1 && opcode1 <= OP_16)) { char n = (char)CScript::DecodeOP_N(opcode1); vSolutionsRet.push_back(valtype(1, n)); } else break; } else if (opcode1 != opcode2 || vch1 != vch2) { // Others must match exactly break; } } } vSolutionsRet.clear(); typeRet = TX_NONSTANDARD; return false; } bool Sign1(const CKeyID& address, const CKeyStore& keystore, uint256 hash, int nHashType, CScript& scriptSigRet) { CKey key; if (!keystore.GetKey(address, key)) return false; vector<unsigned char> vchSig; if (!key.Sign(hash, vchSig)) return false; vchSig.push_back((unsigned char)nHashType); scriptSigRet << vchSig; return true; } bool SignN(const vector<valtype>& multisigdata, const CKeyStore& keystore, uint256 hash, int nHashType, CScript& scriptSigRet) { int nSigned = 0; int nRequired = multisigdata.front()[0]; for (unsigned int i = 1; i < multisigdata.size()-1 && nSigned < nRequired; i++) { const valtype& pubkey = multisigdata[i]; CKeyID keyID = CPubKey(pubkey).GetID(); if (Sign1(keyID, keystore, hash, nHashType, scriptSigRet)) ++nSigned; } return nSigned==nRequired; } // // Sign scriptPubKey with private keys stored in keystore, given transaction hash and hash type. // Signatures are returned in scriptSigRet (or returns false if scriptPubKey can't be signed), // unless whichTypeRet is TX_SCRIPTHASH, in which case scriptSigRet is the redemption script. // Returns false if scriptPubKey could not be completely satisified. // bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash, int nHashType, CScript& scriptSigRet, txnouttype& whichTypeRet) { scriptSigRet.clear(); vector<valtype> vSolutions; if (!Solver(scriptPubKey, whichTypeRet, vSolutions)) return false; CKeyID keyID; switch (whichTypeRet) { case TX_NONSTANDARD: return false; case TX_PUBKEY: keyID = CPubKey(vSolutions[0]).GetID(); return Sign1(keyID, keystore, hash, nHashType, scriptSigRet); case TX_PUBKEYHASH: keyID = CKeyID(uint160(vSolutions[0])); if (!Sign1(keyID, keystore, hash, nHashType, scriptSigRet)) return false; else { CPubKey vch; keystore.GetPubKey(keyID, vch); scriptSigRet << vch; } return true; case TX_SCRIPTHASH: return keystore.GetCScript(uint160(vSolutions[0]), scriptSigRet); case TX_MULTISIG: scriptSigRet << OP_0; // workaround CHECKMULTISIG bug return (SignN(vSolutions, keystore, hash, nHashType, scriptSigRet)); } return false; } int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions) { switch (t) { case TX_NONSTANDARD: return -1; case TX_PUBKEY: return 1; case TX_PUBKEYHASH: return 2; case TX_MULTISIG: if (vSolutions.size() < 1 || vSolutions[0].size() < 1) return -1; return vSolutions[0][0] + 1; case TX_SCRIPTHASH: return 1; // doesn't include args needed by the script } return -1; } bool IsStandard(const CScript& scriptPubKey) { vector<valtype> vSolutions; txnouttype whichType; if (!Solver(scriptPubKey, whichType, vSolutions)) return false; if (whichType == TX_MULTISIG) { unsigned char m = vSolutions.front()[0]; unsigned char n = vSolutions.back()[0]; // Support up to x-of-3 multisig txns as standard if (n < 1 || n > 3) return false; if (m < 1 || m > n) return false; } return whichType != TX_NONSTANDARD; } unsigned int HaveKeys(const vector<valtype>& pubkeys, const CKeyStore& keystore) { unsigned int nResult = 0; BOOST_FOREACH(const valtype& pubkey, pubkeys) { CKeyID keyID = CPubKey(pubkey).GetID(); if (keystore.HaveKey(keyID)) ++nResult; } return nResult; } class CKeyStoreIsMineVisitor : public boost::static_visitor<bool> { private: const CKeyStore *keystore; public: CKeyStoreIsMineVisitor(const CKeyStore *keystoreIn) : keystore(keystoreIn) { } bool operator()(const CNoDestination &dest) const { return false; } bool operator()(const CKeyID &keyID) const { return keystore->HaveKey(keyID); } bool operator()(const CScriptID &scriptID) const { return keystore->HaveCScript(scriptID); } }; bool IsMine(const CKeyStore &keystore, const CTxDestination &dest) { return boost::apply_visitor(CKeyStoreIsMineVisitor(&keystore), dest); } bool IsMine(const CKeyStore &keystore, const CScript& scriptPubKey) { vector<valtype> vSolutions; txnouttype whichType; if (!Solver(scriptPubKey, whichType, vSolutions)) return false; CKeyID keyID; switch (whichType) { case TX_NONSTANDARD: return false; case TX_PUBKEY: keyID = CPubKey(vSolutions[0]).GetID(); return keystore.HaveKey(keyID); case TX_PUBKEYHASH: keyID = CKeyID(uint160(vSolutions[0])); return keystore.HaveKey(keyID); case TX_SCRIPTHASH: { CScript subscript; if (!keystore.GetCScript(CScriptID(uint160(vSolutions[0])), subscript)) return false; return IsMine(keystore, subscript); } case TX_MULTISIG: { // Only consider transactions "mine" if we own ALL the // keys involved. multi-signature transactions that are // partially owned (somebody else has a key that can spend // them) enable spend-out-from-under-you attacks, especially // in shared-wallet situations. vector<valtype> keys(vSolutions.begin()+1, vSolutions.begin()+vSolutions.size()-1); return HaveKeys(keys, keystore) == keys.size(); } } return false; } bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) { vector<valtype> vSolutions; txnouttype whichType; if (!Solver(scriptPubKey, whichType, vSolutions)) return false; if (whichType == TX_PUBKEY) { addressRet = CPubKey(vSolutions[0]).GetID(); return true; } else if (whichType == TX_PUBKEYHASH) { addressRet = CKeyID(uint160(vSolutions[0])); return true; } else if (whichType == TX_SCRIPTHASH) { addressRet = CScriptID(uint160(vSolutions[0])); return true; } // Multisig txns have more than one address... return false; } bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vector<CTxDestination>& addressRet, int& nRequiredRet) { addressRet.clear(); typeRet = TX_NONSTANDARD; vector<valtype> vSolutions; if (!Solver(scriptPubKey, typeRet, vSolutions)) return false; if (typeRet == TX_MULTISIG) { nRequiredRet = vSolutions.front()[0]; for (unsigned int i = 1; i < vSolutions.size()-1; i++) { CTxDestination address = CPubKey(vSolutions[i]).GetID(); addressRet.push_back(address); } } else { nRequiredRet = 1; CTxDestination address; if (!ExtractDestination(scriptPubKey, address)) return false; addressRet.push_back(address); } return true; } bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, bool fValidatePayToScriptHash, int nHashType) { vector<vector<unsigned char> > stack, stackCopy; if (!EvalScript(stack, scriptSig, txTo, nIn, nHashType)) return false; if (fValidatePayToScriptHash) stackCopy = stack; if (!EvalScript(stack, scriptPubKey, txTo, nIn, nHashType)) return false; if (stack.empty()) return false; if (CastToBool(stack.back()) == false) return false; // Additional validation for spend-to-script-hash transactions: if (fValidatePayToScriptHash && scriptPubKey.IsPayToScriptHash()) { if (!scriptSig.IsPushOnly()) // scriptSig must be literals-only return false; // or validation fails const valtype& pubKeySerialized = stackCopy.back(); CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end()); popstack(stackCopy); if (!EvalScript(stackCopy, pubKey2, txTo, nIn, nHashType)) return false; if (stackCopy.empty()) return false; return CastToBool(stackCopy.back()); } return true; } bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CTransaction& txTo, unsigned int nIn, int nHashType) { assert(nIn < txTo.vin.size()); CTxIn& txin = txTo.vin[nIn]; // Leave out the signature from the hash, since a signature can't sign itself. // The checksig op will also drop the signatures from its hash. uint256 hash = SignatureHash(fromPubKey, txTo, nIn, nHashType); txnouttype whichType; if (!Solver(keystore, fromPubKey, hash, nHashType, txin.scriptSig, whichType)) return false; if (whichType == TX_SCRIPTHASH) { // Solver returns the subscript that need to be evaluated; // the final scriptSig is the signatures from that // and then the serialized subscript: CScript subscript = txin.scriptSig; // Recompute txn hash using subscript in place of scriptPubKey: uint256 hash2 = SignatureHash(subscript, txTo, nIn, nHashType); txnouttype subType; bool fSolved = Solver(keystore, subscript, hash2, nHashType, txin.scriptSig, subType) && subType != TX_SCRIPTHASH; // Append serialized subscript whether or not it is completely signed: txin.scriptSig << static_cast<valtype>(subscript); if (!fSolved) return false; } // Test solution return VerifyScript(txin.scriptSig, fromPubKey, txTo, nIn, true, 0); } bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType) { assert(nIn < txTo.vin.size()); CTxIn& txin = txTo.vin[nIn]; assert(txin.prevout.n < txFrom.vout.size()); const CTxOut& txout = txFrom.vout[txin.prevout.n]; return SignSignature(keystore, txout.scriptPubKey, txTo, nIn, nHashType); } bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, bool fValidatePayToScriptHash, int nHashType) { assert(nIn < txTo.vin.size()); const CTxIn& txin = txTo.vin[nIn]; if (txin.prevout.n >= txFrom.vout.size()) return false; const CTxOut& txout = txFrom.vout[txin.prevout.n]; if (txin.prevout.hash != txFrom.GetHash()) return false; return VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, fValidatePayToScriptHash, nHashType); } static CScript PushAll(const vector<valtype>& values) { CScript result; BOOST_FOREACH(const valtype& v, values) result << v; return result; } static CScript CombineMultisig(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, const vector<valtype>& vSolutions, vector<valtype>& sigs1, vector<valtype>& sigs2) { // Combine all the signatures we've got: set<valtype> allsigs; BOOST_FOREACH(const valtype& v, sigs1) { if (!v.empty()) allsigs.insert(v); } BOOST_FOREACH(const valtype& v, sigs2) { if (!v.empty()) allsigs.insert(v); } // Build a map of pubkey -> signature by matching sigs to pubkeys: assert(vSolutions.size() > 1); unsigned int nSigsRequired = vSolutions.front()[0]; unsigned int nPubKeys = vSolutions.size()-2; map<valtype, valtype> sigs; BOOST_FOREACH(const valtype& sig, allsigs) { for (unsigned int i = 0; i < nPubKeys; i++) { const valtype& pubkey = vSolutions[i+1]; if (sigs.count(pubkey)) continue; // Already got a sig for this pubkey if (CheckSig(sig, pubkey, scriptPubKey, txTo, nIn, 0)) { sigs[pubkey] = sig; break; } } } // Now build a merged CScript: unsigned int nSigsHave = 0; CScript result; result << OP_0; // pop-one-too-many workaround for (unsigned int i = 0; i < nPubKeys && nSigsHave < nSigsRequired; i++) { if (sigs.count(vSolutions[i+1])) { result << sigs[vSolutions[i+1]]; ++nSigsHave; } } // Fill any missing with OP_0: for (unsigned int i = nSigsHave; i < nSigsRequired; i++) result << OP_0; return result; } static CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, const txnouttype txType, const vector<valtype>& vSolutions, vector<valtype>& sigs1, vector<valtype>& sigs2) { switch (txType) { case TX_NONSTANDARD: // Don't know anything about this, assume bigger one is correct: if (sigs1.size() >= sigs2.size()) return PushAll(sigs1); return PushAll(sigs2); case TX_PUBKEY: case TX_PUBKEYHASH: // Signatures are bigger than placeholders or empty scripts: if (sigs1.empty() || sigs1[0].empty()) return PushAll(sigs2); return PushAll(sigs1); case TX_SCRIPTHASH: if (sigs1.empty() || sigs1.back().empty()) return PushAll(sigs2); else if (sigs2.empty() || sigs2.back().empty()) return PushAll(sigs1); else { // Recurse to combine: valtype spk = sigs1.back(); CScript pubKey2(spk.begin(), spk.end()); txnouttype txType2; vector<vector<unsigned char> > vSolutions2; Solver(pubKey2, txType2, vSolutions2); sigs1.pop_back(); sigs2.pop_back(); CScript result = CombineSignatures(pubKey2, txTo, nIn, txType2, vSolutions2, sigs1, sigs2); result << spk; return result; } case TX_MULTISIG: return CombineMultisig(scriptPubKey, txTo, nIn, vSolutions, sigs1, sigs2); } return CScript(); } CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, const CScript& scriptSig1, const CScript& scriptSig2) { txnouttype txType; vector<vector<unsigned char> > vSolutions; Solver(scriptPubKey, txType, vSolutions); vector<valtype> stack1; EvalScript(stack1, scriptSig1, CTransaction(), 0, 0); vector<valtype> stack2; EvalScript(stack2, scriptSig2, CTransaction(), 0, 0); return CombineSignatures(scriptPubKey, txTo, nIn, txType, vSolutions, stack1, stack2); } unsigned int CScript::GetSigOpCount(bool fAccurate) const { unsigned int n = 0; const_iterator pc = begin(); opcodetype lastOpcode = OP_INVALIDOPCODE; while (pc < end()) { opcodetype opcode; if (!GetOp(pc, opcode)) break; if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY) n++; else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY) { if (fAccurate && lastOpcode >= OP_1 && lastOpcode <= OP_16) n += DecodeOP_N(lastOpcode); else n += 20; } lastOpcode = opcode; } return n; } unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const { if (!IsPayToScriptHash()) return GetSigOpCount(true); // This is a pay-to-script-hash scriptPubKey; // get the last item that the scriptSig // pushes onto the stack: const_iterator pc = scriptSig.begin(); vector<unsigned char> data; while (pc < scriptSig.end()) { opcodetype opcode; if (!scriptSig.GetOp(pc, opcode, data)) return 0; if (opcode > OP_16) return 0; } /// ... and return it's opcount: CScript subscript(data.begin(), data.end()); return subscript.GetSigOpCount(true); } bool CScript::IsPayToScriptHash() const { // Extra-fast test for pay-to-script-hash CScripts: return (this->size() == 23 && this->at(0) == OP_HASH160 && this->at(1) == 0x14 && this->at(22) == OP_EQUAL); } class CScriptVisitor : public boost::static_visitor<bool> { private: CScript *script; public: CScriptVisitor(CScript *scriptin) { script = scriptin; } bool operator()(const CNoDestination &dest) const { script->clear(); return false; } bool operator()(const CKeyID &keyID) const { script->clear(); *script << OP_DUP << OP_HASH160 << keyID << OP_EQUALVERIFY << OP_CHECKSIG; return true; } bool operator()(const CScriptID &scriptID) const { script->clear(); *script << OP_HASH160 << scriptID << OP_EQUAL; return true; } }; void CScript::SetDestination(const CTxDestination& dest) { boost::apply_visitor(CScriptVisitor(this), dest); } void CScript::SetMultisig(int nRequired, const std::vector<CKey>& keys) { this->clear(); *this << EncodeOP_N(nRequired); BOOST_FOREACH(const CKey& key, keys) *this << key.GetPubKey(); *this << EncodeOP_N(keys.size()) << OP_CHECKMULTISIG; }
Trade_PrintPlayerMonInfoText: hlcoord 5, 0 ld de, Trade_MonInfoText call PlaceString ld a, [wTradedPlayerMonSpecies] ld [wd11e], a predef IndexToPokedex hlcoord 9, 0 ld de, wd11e lb bc, LEADING_ZEROES | 1, 3 call PrintNumber hlcoord 5, 2 ld de, wcf4b call PlaceString hlcoord 8, 4 ld de, wTradedPlayerMonOT call PlaceString hlcoord 8, 6 ld de, wTradedPlayerMonOTID lb bc, LEADING_ZEROES | 2, 5 jp PrintNumber Trade_PrintEnemyMonInfoText: hlcoord 5, 10 ld de, Trade_MonInfoText call PlaceString ld a, [wTradedEnemyMonSpecies] ld [wd11e], a predef IndexToPokedex hlcoord 9, 10 ld de, wd11e lb bc, LEADING_ZEROES | 1, 3 call PrintNumber hlcoord 5, 12 ld de, wcd6d call PlaceString hlcoord 8, 14 ld de, wTradedEnemyMonOT call PlaceString hlcoord 8, 16 ld de, wTradedEnemyMonOTID lb bc, LEADING_ZEROES | 2, 5 jp PrintNumber Trade_MonInfoText: db "──№<DOT>" next "" next "OT/" next "<ID>№<DOT>@"
; A056791: Weight of binary expansion of n + length of binary expansion of n. ; 1,2,3,4,4,5,5,6,5,6,6,7,6,7,7,8,6,7,7,8,7,8,8,9,7,8,8,9,8,9,9,10,7,8,8,9,8,9,9,10,8,9,9,10,9,10,10,11,8,9,9,10,9,10,10,11,9,10,10,11,10,11,11,12,8,9,9,10,9,10,10,11,9,10,10,11,10,11,11,12,9,10,10,11,10,11,11 mov $2,$0 lpb $0 add $0,1 div $2,2 sub $0,$2 lpe add $0,1
kernel: file format elf32-i386 Disassembly of section .text: 80100000 <multiboot_header>: 80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh 80100006: 00 00 add %al,(%eax) 80100008: fe 4f 52 decb 0x52(%edi) 8010000b: e4 0f in $0xf,%al 8010000c <entry>: # Entering xv6 on boot processor, with paging off. .globl entry entry: # Turn on page size extension for 4Mbyte pages movl %cr4, %eax 8010000c: 0f 20 e0 mov %cr4,%eax orl $(CR4_PSE), %eax 8010000f: 83 c8 10 or $0x10,%eax movl %eax, %cr4 80100012: 0f 22 e0 mov %eax,%cr4 # Set page directory movl $(V2P_WO(entrypgdir)), %eax 80100015: b8 00 a0 10 00 mov $0x10a000,%eax movl %eax, %cr3 8010001a: 0f 22 d8 mov %eax,%cr3 # Turn on paging. movl %cr0, %eax 8010001d: 0f 20 c0 mov %cr0,%eax orl $(CR0_PG|CR0_WP), %eax 80100020: 0d 00 00 01 80 or $0x80010000,%eax movl %eax, %cr0 80100025: 0f 22 c0 mov %eax,%cr0 # Set up the stack pointer. movl $(stack + KSTACKSIZE), %esp 80100028: bc 50 c6 10 80 mov $0x8010c650,%esp # Jump to main(), and switch to executing at # high addresses. The indirect call is needed because # the assembler produces a PC-relative instruction # for a direct jump. mov $main, %eax 8010002d: b8 d0 37 10 80 mov $0x801037d0,%eax jmp *%eax 80100032: ff e0 jmp *%eax 80100034 <binit>: struct buf head; } bcache; void binit(void) { 80100034: 55 push %ebp 80100035: 89 e5 mov %esp,%ebp 80100037: 83 ec 28 sub $0x28,%esp struct buf *b; initlock(&bcache.lock, "bcache"); 8010003a: c7 44 24 04 60 88 10 movl $0x80108860,0x4(%esp) 80100041: 80 80100042: c7 04 24 60 c6 10 80 movl $0x8010c660,(%esp) 80100049: e8 50 51 00 00 call 8010519e <initlock> //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; 8010004e: c7 05 70 05 11 80 64 movl $0x80110564,0x80110570 80100055: 05 11 80 bcache.head.next = &bcache.head; 80100058: c7 05 74 05 11 80 64 movl $0x80110564,0x80110574 8010005f: 05 11 80 for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100062: c7 45 f4 94 c6 10 80 movl $0x8010c694,-0xc(%ebp) 80100069: eb 3a jmp 801000a5 <binit+0x71> b->next = bcache.head.next; 8010006b: 8b 15 74 05 11 80 mov 0x80110574,%edx 80100071: 8b 45 f4 mov -0xc(%ebp),%eax 80100074: 89 50 10 mov %edx,0x10(%eax) b->prev = &bcache.head; 80100077: 8b 45 f4 mov -0xc(%ebp),%eax 8010007a: c7 40 0c 64 05 11 80 movl $0x80110564,0xc(%eax) b->dev = -1; 80100081: 8b 45 f4 mov -0xc(%ebp),%eax 80100084: c7 40 04 ff ff ff ff movl $0xffffffff,0x4(%eax) bcache.head.next->prev = b; 8010008b: a1 74 05 11 80 mov 0x80110574,%eax 80100090: 8b 55 f4 mov -0xc(%ebp),%edx 80100093: 89 50 0c mov %edx,0xc(%eax) bcache.head.next = b; 80100096: 8b 45 f4 mov -0xc(%ebp),%eax 80100099: a3 74 05 11 80 mov %eax,0x80110574 //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 8010009e: 81 45 f4 18 02 00 00 addl $0x218,-0xc(%ebp) 801000a5: 81 7d f4 64 05 11 80 cmpl $0x80110564,-0xc(%ebp) 801000ac: 72 bd jb 8010006b <binit+0x37> b->prev = &bcache.head; b->dev = -1; bcache.head.next->prev = b; bcache.head.next = b; } } 801000ae: c9 leave 801000af: c3 ret 801000b0 <bget>: // Look through buffer cache for block on device dev. // If not found, allocate a buffer. // In either case, return B_BUSY buffer. static struct buf* bget(uint dev, uint blockno) { 801000b0: 55 push %ebp 801000b1: 89 e5 mov %esp,%ebp 801000b3: 83 ec 28 sub $0x28,%esp struct buf *b; acquire(&bcache.lock); 801000b6: c7 04 24 60 c6 10 80 movl $0x8010c660,(%esp) 801000bd: e8 fd 50 00 00 call 801051bf <acquire> loop: // Is the block already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ 801000c2: a1 74 05 11 80 mov 0x80110574,%eax 801000c7: 89 45 f4 mov %eax,-0xc(%ebp) 801000ca: eb 63 jmp 8010012f <bget+0x7f> if(b->dev == dev && b->blockno == blockno){ 801000cc: 8b 45 f4 mov -0xc(%ebp),%eax 801000cf: 8b 40 04 mov 0x4(%eax),%eax 801000d2: 3b 45 08 cmp 0x8(%ebp),%eax 801000d5: 75 4f jne 80100126 <bget+0x76> 801000d7: 8b 45 f4 mov -0xc(%ebp),%eax 801000da: 8b 40 08 mov 0x8(%eax),%eax 801000dd: 3b 45 0c cmp 0xc(%ebp),%eax 801000e0: 75 44 jne 80100126 <bget+0x76> if(!(b->flags & B_BUSY)){ 801000e2: 8b 45 f4 mov -0xc(%ebp),%eax 801000e5: 8b 00 mov (%eax),%eax 801000e7: 83 e0 01 and $0x1,%eax 801000ea: 85 c0 test %eax,%eax 801000ec: 75 23 jne 80100111 <bget+0x61> b->flags |= B_BUSY; 801000ee: 8b 45 f4 mov -0xc(%ebp),%eax 801000f1: 8b 00 mov (%eax),%eax 801000f3: 83 c8 01 or $0x1,%eax 801000f6: 89 c2 mov %eax,%edx 801000f8: 8b 45 f4 mov -0xc(%ebp),%eax 801000fb: 89 10 mov %edx,(%eax) release(&bcache.lock); 801000fd: c7 04 24 60 c6 10 80 movl $0x8010c660,(%esp) 80100104: e8 18 51 00 00 call 80105221 <release> return b; 80100109: 8b 45 f4 mov -0xc(%ebp),%eax 8010010c: e9 93 00 00 00 jmp 801001a4 <bget+0xf4> } sleep(b, &bcache.lock); 80100111: c7 44 24 04 60 c6 10 movl $0x8010c660,0x4(%esp) 80100118: 80 80100119: 8b 45 f4 mov -0xc(%ebp),%eax 8010011c: 89 04 24 mov %eax,(%esp) 8010011f: e8 cd 4a 00 00 call 80104bf1 <sleep> goto loop; 80100124: eb 9c jmp 801000c2 <bget+0x12> acquire(&bcache.lock); loop: // Is the block already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ 80100126: 8b 45 f4 mov -0xc(%ebp),%eax 80100129: 8b 40 10 mov 0x10(%eax),%eax 8010012c: 89 45 f4 mov %eax,-0xc(%ebp) 8010012f: 81 7d f4 64 05 11 80 cmpl $0x80110564,-0xc(%ebp) 80100136: 75 94 jne 801000cc <bget+0x1c> } // Not cached; recycle some non-busy and clean buffer. // "clean" because B_DIRTY and !B_BUSY means log.c // hasn't yet committed the changes to the buffer. for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ 80100138: a1 70 05 11 80 mov 0x80110570,%eax 8010013d: 89 45 f4 mov %eax,-0xc(%ebp) 80100140: eb 4d jmp 8010018f <bget+0xdf> if((b->flags & B_BUSY) == 0 && (b->flags & B_DIRTY) == 0){ 80100142: 8b 45 f4 mov -0xc(%ebp),%eax 80100145: 8b 00 mov (%eax),%eax 80100147: 83 e0 01 and $0x1,%eax 8010014a: 85 c0 test %eax,%eax 8010014c: 75 38 jne 80100186 <bget+0xd6> 8010014e: 8b 45 f4 mov -0xc(%ebp),%eax 80100151: 8b 00 mov (%eax),%eax 80100153: 83 e0 04 and $0x4,%eax 80100156: 85 c0 test %eax,%eax 80100158: 75 2c jne 80100186 <bget+0xd6> b->dev = dev; 8010015a: 8b 45 f4 mov -0xc(%ebp),%eax 8010015d: 8b 55 08 mov 0x8(%ebp),%edx 80100160: 89 50 04 mov %edx,0x4(%eax) b->blockno = blockno; 80100163: 8b 45 f4 mov -0xc(%ebp),%eax 80100166: 8b 55 0c mov 0xc(%ebp),%edx 80100169: 89 50 08 mov %edx,0x8(%eax) b->flags = B_BUSY; 8010016c: 8b 45 f4 mov -0xc(%ebp),%eax 8010016f: c7 00 01 00 00 00 movl $0x1,(%eax) release(&bcache.lock); 80100175: c7 04 24 60 c6 10 80 movl $0x8010c660,(%esp) 8010017c: e8 a0 50 00 00 call 80105221 <release> return b; 80100181: 8b 45 f4 mov -0xc(%ebp),%eax 80100184: eb 1e jmp 801001a4 <bget+0xf4> } // Not cached; recycle some non-busy and clean buffer. // "clean" because B_DIRTY and !B_BUSY means log.c // hasn't yet committed the changes to the buffer. for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ 80100186: 8b 45 f4 mov -0xc(%ebp),%eax 80100189: 8b 40 0c mov 0xc(%eax),%eax 8010018c: 89 45 f4 mov %eax,-0xc(%ebp) 8010018f: 81 7d f4 64 05 11 80 cmpl $0x80110564,-0xc(%ebp) 80100196: 75 aa jne 80100142 <bget+0x92> b->flags = B_BUSY; release(&bcache.lock); return b; } } panic("bget: no buffers"); 80100198: c7 04 24 67 88 10 80 movl $0x80108867,(%esp) 8010019f: e8 96 03 00 00 call 8010053a <panic> } 801001a4: c9 leave 801001a5: c3 ret 801001a6 <bread>: // Return a B_BUSY buf with the contents of the indicated block. struct buf* bread(uint dev, uint blockno) { 801001a6: 55 push %ebp 801001a7: 89 e5 mov %esp,%ebp 801001a9: 83 ec 28 sub $0x28,%esp struct buf *b; b = bget(dev, blockno); 801001ac: 8b 45 0c mov 0xc(%ebp),%eax 801001af: 89 44 24 04 mov %eax,0x4(%esp) 801001b3: 8b 45 08 mov 0x8(%ebp),%eax 801001b6: 89 04 24 mov %eax,(%esp) 801001b9: e8 f2 fe ff ff call 801000b0 <bget> 801001be: 89 45 f4 mov %eax,-0xc(%ebp) if(!(b->flags & B_VALID)) { 801001c1: 8b 45 f4 mov -0xc(%ebp),%eax 801001c4: 8b 00 mov (%eax),%eax 801001c6: 83 e0 02 and $0x2,%eax 801001c9: 85 c0 test %eax,%eax 801001cb: 75 0b jne 801001d8 <bread+0x32> iderw(b); 801001cd: 8b 45 f4 mov -0xc(%ebp),%eax 801001d0: 89 04 24 mov %eax,(%esp) 801001d3: e8 86 26 00 00 call 8010285e <iderw> } return b; 801001d8: 8b 45 f4 mov -0xc(%ebp),%eax } 801001db: c9 leave 801001dc: c3 ret 801001dd <bwrite>: // Write b's contents to disk. Must be B_BUSY. void bwrite(struct buf *b) { 801001dd: 55 push %ebp 801001de: 89 e5 mov %esp,%ebp 801001e0: 83 ec 18 sub $0x18,%esp if((b->flags & B_BUSY) == 0) 801001e3: 8b 45 08 mov 0x8(%ebp),%eax 801001e6: 8b 00 mov (%eax),%eax 801001e8: 83 e0 01 and $0x1,%eax 801001eb: 85 c0 test %eax,%eax 801001ed: 75 0c jne 801001fb <bwrite+0x1e> panic("bwrite"); 801001ef: c7 04 24 78 88 10 80 movl $0x80108878,(%esp) 801001f6: e8 3f 03 00 00 call 8010053a <panic> b->flags |= B_DIRTY; 801001fb: 8b 45 08 mov 0x8(%ebp),%eax 801001fe: 8b 00 mov (%eax),%eax 80100200: 83 c8 04 or $0x4,%eax 80100203: 89 c2 mov %eax,%edx 80100205: 8b 45 08 mov 0x8(%ebp),%eax 80100208: 89 10 mov %edx,(%eax) iderw(b); 8010020a: 8b 45 08 mov 0x8(%ebp),%eax 8010020d: 89 04 24 mov %eax,(%esp) 80100210: e8 49 26 00 00 call 8010285e <iderw> } 80100215: c9 leave 80100216: c3 ret 80100217 <brelse>: // Release a B_BUSY buffer. // Move to the head of the MRU list. void brelse(struct buf *b) { 80100217: 55 push %ebp 80100218: 89 e5 mov %esp,%ebp 8010021a: 83 ec 18 sub $0x18,%esp if((b->flags & B_BUSY) == 0) 8010021d: 8b 45 08 mov 0x8(%ebp),%eax 80100220: 8b 00 mov (%eax),%eax 80100222: 83 e0 01 and $0x1,%eax 80100225: 85 c0 test %eax,%eax 80100227: 75 0c jne 80100235 <brelse+0x1e> panic("brelse"); 80100229: c7 04 24 7f 88 10 80 movl $0x8010887f,(%esp) 80100230: e8 05 03 00 00 call 8010053a <panic> acquire(&bcache.lock); 80100235: c7 04 24 60 c6 10 80 movl $0x8010c660,(%esp) 8010023c: e8 7e 4f 00 00 call 801051bf <acquire> b->next->prev = b->prev; 80100241: 8b 45 08 mov 0x8(%ebp),%eax 80100244: 8b 40 10 mov 0x10(%eax),%eax 80100247: 8b 55 08 mov 0x8(%ebp),%edx 8010024a: 8b 52 0c mov 0xc(%edx),%edx 8010024d: 89 50 0c mov %edx,0xc(%eax) b->prev->next = b->next; 80100250: 8b 45 08 mov 0x8(%ebp),%eax 80100253: 8b 40 0c mov 0xc(%eax),%eax 80100256: 8b 55 08 mov 0x8(%ebp),%edx 80100259: 8b 52 10 mov 0x10(%edx),%edx 8010025c: 89 50 10 mov %edx,0x10(%eax) b->next = bcache.head.next; 8010025f: 8b 15 74 05 11 80 mov 0x80110574,%edx 80100265: 8b 45 08 mov 0x8(%ebp),%eax 80100268: 89 50 10 mov %edx,0x10(%eax) b->prev = &bcache.head; 8010026b: 8b 45 08 mov 0x8(%ebp),%eax 8010026e: c7 40 0c 64 05 11 80 movl $0x80110564,0xc(%eax) bcache.head.next->prev = b; 80100275: a1 74 05 11 80 mov 0x80110574,%eax 8010027a: 8b 55 08 mov 0x8(%ebp),%edx 8010027d: 89 50 0c mov %edx,0xc(%eax) bcache.head.next = b; 80100280: 8b 45 08 mov 0x8(%ebp),%eax 80100283: a3 74 05 11 80 mov %eax,0x80110574 b->flags &= ~B_BUSY; 80100288: 8b 45 08 mov 0x8(%ebp),%eax 8010028b: 8b 00 mov (%eax),%eax 8010028d: 83 e0 fe and $0xfffffffe,%eax 80100290: 89 c2 mov %eax,%edx 80100292: 8b 45 08 mov 0x8(%ebp),%eax 80100295: 89 10 mov %edx,(%eax) wakeup(b); 80100297: 8b 45 08 mov 0x8(%ebp),%eax 8010029a: 89 04 24 mov %eax,(%esp) 8010029d: e8 28 4a 00 00 call 80104cca <wakeup> release(&bcache.lock); 801002a2: c7 04 24 60 c6 10 80 movl $0x8010c660,(%esp) 801002a9: e8 73 4f 00 00 call 80105221 <release> } 801002ae: c9 leave 801002af: c3 ret 801002b0 <inb>: // Routines to let C code use special x86 instructions. static inline uchar inb(ushort port) { 801002b0: 55 push %ebp 801002b1: 89 e5 mov %esp,%ebp 801002b3: 83 ec 14 sub $0x14,%esp 801002b6: 8b 45 08 mov 0x8(%ebp),%eax 801002b9: 66 89 45 ec mov %ax,-0x14(%ebp) uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801002bd: 0f b7 45 ec movzwl -0x14(%ebp),%eax 801002c1: 89 c2 mov %eax,%edx 801002c3: ec in (%dx),%al 801002c4: 88 45 ff mov %al,-0x1(%ebp) return data; 801002c7: 0f b6 45 ff movzbl -0x1(%ebp),%eax } 801002cb: c9 leave 801002cc: c3 ret 801002cd <outb>: "memory", "cc"); } static inline void outb(ushort port, uchar data) { 801002cd: 55 push %ebp 801002ce: 89 e5 mov %esp,%ebp 801002d0: 83 ec 08 sub $0x8,%esp 801002d3: 8b 55 08 mov 0x8(%ebp),%edx 801002d6: 8b 45 0c mov 0xc(%ebp),%eax 801002d9: 66 89 55 fc mov %dx,-0x4(%ebp) 801002dd: 88 45 f8 mov %al,-0x8(%ebp) asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801002e0: 0f b6 45 f8 movzbl -0x8(%ebp),%eax 801002e4: 0f b7 55 fc movzwl -0x4(%ebp),%edx 801002e8: ee out %al,(%dx) } 801002e9: c9 leave 801002ea: c3 ret 801002eb <cli>: asm volatile("movw %0, %%gs" : : "r" (v)); } static inline void cli(void) { 801002eb: 55 push %ebp 801002ec: 89 e5 mov %esp,%ebp asm volatile("cli"); 801002ee: fa cli } 801002ef: 5d pop %ebp 801002f0: c3 ret 801002f1 <printint>: int locking; } cons; static void printint(int xx, int base, int sign) { 801002f1: 55 push %ebp 801002f2: 89 e5 mov %esp,%ebp 801002f4: 56 push %esi 801002f5: 53 push %ebx 801002f6: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789abcdef"; char buf[16]; int i; uint x; if(sign && (sign = xx < 0)) 801002f9: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 801002fd: 74 1c je 8010031b <printint+0x2a> 801002ff: 8b 45 08 mov 0x8(%ebp),%eax 80100302: c1 e8 1f shr $0x1f,%eax 80100305: 0f b6 c0 movzbl %al,%eax 80100308: 89 45 10 mov %eax,0x10(%ebp) 8010030b: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 8010030f: 74 0a je 8010031b <printint+0x2a> x = -xx; 80100311: 8b 45 08 mov 0x8(%ebp),%eax 80100314: f7 d8 neg %eax 80100316: 89 45 f0 mov %eax,-0x10(%ebp) 80100319: eb 06 jmp 80100321 <printint+0x30> else x = xx; 8010031b: 8b 45 08 mov 0x8(%ebp),%eax 8010031e: 89 45 f0 mov %eax,-0x10(%ebp) i = 0; 80100321: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 80100328: 8b 4d f4 mov -0xc(%ebp),%ecx 8010032b: 8d 41 01 lea 0x1(%ecx),%eax 8010032e: 89 45 f4 mov %eax,-0xc(%ebp) 80100331: 8b 5d 0c mov 0xc(%ebp),%ebx 80100334: 8b 45 f0 mov -0x10(%ebp),%eax 80100337: ba 00 00 00 00 mov $0x0,%edx 8010033c: f7 f3 div %ebx 8010033e: 89 d0 mov %edx,%eax 80100340: 0f b6 80 04 90 10 80 movzbl -0x7fef6ffc(%eax),%eax 80100347: 88 44 0d e0 mov %al,-0x20(%ebp,%ecx,1) }while((x /= base) != 0); 8010034b: 8b 75 0c mov 0xc(%ebp),%esi 8010034e: 8b 45 f0 mov -0x10(%ebp),%eax 80100351: ba 00 00 00 00 mov $0x0,%edx 80100356: f7 f6 div %esi 80100358: 89 45 f0 mov %eax,-0x10(%ebp) 8010035b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8010035f: 75 c7 jne 80100328 <printint+0x37> if(sign) 80100361: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 80100365: 74 10 je 80100377 <printint+0x86> buf[i++] = '-'; 80100367: 8b 45 f4 mov -0xc(%ebp),%eax 8010036a: 8d 50 01 lea 0x1(%eax),%edx 8010036d: 89 55 f4 mov %edx,-0xc(%ebp) 80100370: c6 44 05 e0 2d movb $0x2d,-0x20(%ebp,%eax,1) while(--i >= 0) 80100375: eb 18 jmp 8010038f <printint+0x9e> 80100377: eb 16 jmp 8010038f <printint+0x9e> consputc(buf[i]); 80100379: 8d 55 e0 lea -0x20(%ebp),%edx 8010037c: 8b 45 f4 mov -0xc(%ebp),%eax 8010037f: 01 d0 add %edx,%eax 80100381: 0f b6 00 movzbl (%eax),%eax 80100384: 0f be c0 movsbl %al,%eax 80100387: 89 04 24 mov %eax,(%esp) 8010038a: e8 dc 03 00 00 call 8010076b <consputc> }while((x /= base) != 0); if(sign) buf[i++] = '-'; while(--i >= 0) 8010038f: 83 6d f4 01 subl $0x1,-0xc(%ebp) 80100393: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80100397: 79 e0 jns 80100379 <printint+0x88> consputc(buf[i]); } 80100399: 83 c4 30 add $0x30,%esp 8010039c: 5b pop %ebx 8010039d: 5e pop %esi 8010039e: 5d pop %ebp 8010039f: c3 ret 801003a0 <cprintf>: //PAGEBREAK: 50 // Print to the console. only understands %d, %x, %p, %s. void cprintf(char *fmt, ...) { 801003a0: 55 push %ebp 801003a1: 89 e5 mov %esp,%ebp 801003a3: 83 ec 38 sub $0x38,%esp int i, c, locking; uint *argp; char *s; locking = cons.locking; 801003a6: a1 f4 b5 10 80 mov 0x8010b5f4,%eax 801003ab: 89 45 e8 mov %eax,-0x18(%ebp) if(locking) 801003ae: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 801003b2: 74 0c je 801003c0 <cprintf+0x20> acquire(&cons.lock); 801003b4: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 801003bb: e8 ff 4d 00 00 call 801051bf <acquire> if (fmt == 0) 801003c0: 8b 45 08 mov 0x8(%ebp),%eax 801003c3: 85 c0 test %eax,%eax 801003c5: 75 0c jne 801003d3 <cprintf+0x33> panic("null fmt"); 801003c7: c7 04 24 86 88 10 80 movl $0x80108886,(%esp) 801003ce: e8 67 01 00 00 call 8010053a <panic> argp = (uint*)(void*)(&fmt + 1); 801003d3: 8d 45 0c lea 0xc(%ebp),%eax 801003d6: 89 45 f0 mov %eax,-0x10(%ebp) for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801003d9: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 801003e0: e9 21 01 00 00 jmp 80100506 <cprintf+0x166> if(c != '%'){ 801003e5: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 801003e9: 74 10 je 801003fb <cprintf+0x5b> consputc(c); 801003eb: 8b 45 e4 mov -0x1c(%ebp),%eax 801003ee: 89 04 24 mov %eax,(%esp) 801003f1: e8 75 03 00 00 call 8010076b <consputc> continue; 801003f6: e9 07 01 00 00 jmp 80100502 <cprintf+0x162> } c = fmt[++i] & 0xff; 801003fb: 8b 55 08 mov 0x8(%ebp),%edx 801003fe: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80100402: 8b 45 f4 mov -0xc(%ebp),%eax 80100405: 01 d0 add %edx,%eax 80100407: 0f b6 00 movzbl (%eax),%eax 8010040a: 0f be c0 movsbl %al,%eax 8010040d: 25 ff 00 00 00 and $0xff,%eax 80100412: 89 45 e4 mov %eax,-0x1c(%ebp) if(c == 0) 80100415: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 80100419: 75 05 jne 80100420 <cprintf+0x80> break; 8010041b: e9 06 01 00 00 jmp 80100526 <cprintf+0x186> switch(c){ 80100420: 8b 45 e4 mov -0x1c(%ebp),%eax 80100423: 83 f8 70 cmp $0x70,%eax 80100426: 74 4f je 80100477 <cprintf+0xd7> 80100428: 83 f8 70 cmp $0x70,%eax 8010042b: 7f 13 jg 80100440 <cprintf+0xa0> 8010042d: 83 f8 25 cmp $0x25,%eax 80100430: 0f 84 a6 00 00 00 je 801004dc <cprintf+0x13c> 80100436: 83 f8 64 cmp $0x64,%eax 80100439: 74 14 je 8010044f <cprintf+0xaf> 8010043b: e9 aa 00 00 00 jmp 801004ea <cprintf+0x14a> 80100440: 83 f8 73 cmp $0x73,%eax 80100443: 74 57 je 8010049c <cprintf+0xfc> 80100445: 83 f8 78 cmp $0x78,%eax 80100448: 74 2d je 80100477 <cprintf+0xd7> 8010044a: e9 9b 00 00 00 jmp 801004ea <cprintf+0x14a> case 'd': printint(*argp++, 10, 1); 8010044f: 8b 45 f0 mov -0x10(%ebp),%eax 80100452: 8d 50 04 lea 0x4(%eax),%edx 80100455: 89 55 f0 mov %edx,-0x10(%ebp) 80100458: 8b 00 mov (%eax),%eax 8010045a: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 80100461: 00 80100462: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) 80100469: 00 8010046a: 89 04 24 mov %eax,(%esp) 8010046d: e8 7f fe ff ff call 801002f1 <printint> break; 80100472: e9 8b 00 00 00 jmp 80100502 <cprintf+0x162> case 'x': case 'p': printint(*argp++, 16, 0); 80100477: 8b 45 f0 mov -0x10(%ebp),%eax 8010047a: 8d 50 04 lea 0x4(%eax),%edx 8010047d: 89 55 f0 mov %edx,-0x10(%ebp) 80100480: 8b 00 mov (%eax),%eax 80100482: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80100489: 00 8010048a: c7 44 24 04 10 00 00 movl $0x10,0x4(%esp) 80100491: 00 80100492: 89 04 24 mov %eax,(%esp) 80100495: e8 57 fe ff ff call 801002f1 <printint> break; 8010049a: eb 66 jmp 80100502 <cprintf+0x162> case 's': if((s = (char*)*argp++) == 0) 8010049c: 8b 45 f0 mov -0x10(%ebp),%eax 8010049f: 8d 50 04 lea 0x4(%eax),%edx 801004a2: 89 55 f0 mov %edx,-0x10(%ebp) 801004a5: 8b 00 mov (%eax),%eax 801004a7: 89 45 ec mov %eax,-0x14(%ebp) 801004aa: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 801004ae: 75 09 jne 801004b9 <cprintf+0x119> s = "(null)"; 801004b0: c7 45 ec 8f 88 10 80 movl $0x8010888f,-0x14(%ebp) for(; *s; s++) 801004b7: eb 17 jmp 801004d0 <cprintf+0x130> 801004b9: eb 15 jmp 801004d0 <cprintf+0x130> consputc(*s); 801004bb: 8b 45 ec mov -0x14(%ebp),%eax 801004be: 0f b6 00 movzbl (%eax),%eax 801004c1: 0f be c0 movsbl %al,%eax 801004c4: 89 04 24 mov %eax,(%esp) 801004c7: e8 9f 02 00 00 call 8010076b <consputc> printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) s = "(null)"; for(; *s; s++) 801004cc: 83 45 ec 01 addl $0x1,-0x14(%ebp) 801004d0: 8b 45 ec mov -0x14(%ebp),%eax 801004d3: 0f b6 00 movzbl (%eax),%eax 801004d6: 84 c0 test %al,%al 801004d8: 75 e1 jne 801004bb <cprintf+0x11b> consputc(*s); break; 801004da: eb 26 jmp 80100502 <cprintf+0x162> case '%': consputc('%'); 801004dc: c7 04 24 25 00 00 00 movl $0x25,(%esp) 801004e3: e8 83 02 00 00 call 8010076b <consputc> break; 801004e8: eb 18 jmp 80100502 <cprintf+0x162> default: // Print unknown % sequence to draw attention. consputc('%'); 801004ea: c7 04 24 25 00 00 00 movl $0x25,(%esp) 801004f1: e8 75 02 00 00 call 8010076b <consputc> consputc(c); 801004f6: 8b 45 e4 mov -0x1c(%ebp),%eax 801004f9: 89 04 24 mov %eax,(%esp) 801004fc: e8 6a 02 00 00 call 8010076b <consputc> break; 80100501: 90 nop if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 80100502: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80100506: 8b 55 08 mov 0x8(%ebp),%edx 80100509: 8b 45 f4 mov -0xc(%ebp),%eax 8010050c: 01 d0 add %edx,%eax 8010050e: 0f b6 00 movzbl (%eax),%eax 80100511: 0f be c0 movsbl %al,%eax 80100514: 25 ff 00 00 00 and $0xff,%eax 80100519: 89 45 e4 mov %eax,-0x1c(%ebp) 8010051c: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 80100520: 0f 85 bf fe ff ff jne 801003e5 <cprintf+0x45> consputc(c); break; } } if(locking) 80100526: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 8010052a: 74 0c je 80100538 <cprintf+0x198> release(&cons.lock); 8010052c: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100533: e8 e9 4c 00 00 call 80105221 <release> } 80100538: c9 leave 80100539: c3 ret 8010053a <panic>: void panic(char *s) { 8010053a: 55 push %ebp 8010053b: 89 e5 mov %esp,%ebp 8010053d: 83 ec 48 sub $0x48,%esp int i; uint pcs[10]; cli(); 80100540: e8 a6 fd ff ff call 801002eb <cli> cons.locking = 0; 80100545: c7 05 f4 b5 10 80 00 movl $0x0,0x8010b5f4 8010054c: 00 00 00 cprintf("cpu%d: panic: ", cpu->id); 8010054f: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80100555: 0f b6 00 movzbl (%eax),%eax 80100558: 0f b6 c0 movzbl %al,%eax 8010055b: 89 44 24 04 mov %eax,0x4(%esp) 8010055f: c7 04 24 96 88 10 80 movl $0x80108896,(%esp) 80100566: e8 35 fe ff ff call 801003a0 <cprintf> cprintf(s); 8010056b: 8b 45 08 mov 0x8(%ebp),%eax 8010056e: 89 04 24 mov %eax,(%esp) 80100571: e8 2a fe ff ff call 801003a0 <cprintf> cprintf("\n"); 80100576: c7 04 24 a5 88 10 80 movl $0x801088a5,(%esp) 8010057d: e8 1e fe ff ff call 801003a0 <cprintf> getcallerpcs(&s, pcs); 80100582: 8d 45 cc lea -0x34(%ebp),%eax 80100585: 89 44 24 04 mov %eax,0x4(%esp) 80100589: 8d 45 08 lea 0x8(%ebp),%eax 8010058c: 89 04 24 mov %eax,(%esp) 8010058f: e8 dc 4c 00 00 call 80105270 <getcallerpcs> for(i=0; i<10; i++) 80100594: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 8010059b: eb 1b jmp 801005b8 <panic+0x7e> cprintf(" %p", pcs[i]); 8010059d: 8b 45 f4 mov -0xc(%ebp),%eax 801005a0: 8b 44 85 cc mov -0x34(%ebp,%eax,4),%eax 801005a4: 89 44 24 04 mov %eax,0x4(%esp) 801005a8: c7 04 24 a7 88 10 80 movl $0x801088a7,(%esp) 801005af: e8 ec fd ff ff call 801003a0 <cprintf> cons.locking = 0; cprintf("cpu%d: panic: ", cpu->id); cprintf(s); cprintf("\n"); getcallerpcs(&s, pcs); for(i=0; i<10; i++) 801005b4: 83 45 f4 01 addl $0x1,-0xc(%ebp) 801005b8: 83 7d f4 09 cmpl $0x9,-0xc(%ebp) 801005bc: 7e df jle 8010059d <panic+0x63> cprintf(" %p", pcs[i]); panicked = 1; // freeze other CPU 801005be: c7 05 a0 b5 10 80 01 movl $0x1,0x8010b5a0 801005c5: 00 00 00 for(;;) ; 801005c8: eb fe jmp 801005c8 <panic+0x8e> 801005ca <cgaputc>: #define CRTPORT 0x3d4 static ushort *crt = (ushort*)P2V(0xb8000); // CGA memory static void cgaputc(int c) { 801005ca: 55 push %ebp 801005cb: 89 e5 mov %esp,%ebp 801005cd: 83 ec 28 sub $0x28,%esp int pos; // Cursor position: col + 80*row. outb(CRTPORT, 14); 801005d0: c7 44 24 04 0e 00 00 movl $0xe,0x4(%esp) 801005d7: 00 801005d8: c7 04 24 d4 03 00 00 movl $0x3d4,(%esp) 801005df: e8 e9 fc ff ff call 801002cd <outb> pos = inb(CRTPORT+1) << 8; 801005e4: c7 04 24 d5 03 00 00 movl $0x3d5,(%esp) 801005eb: e8 c0 fc ff ff call 801002b0 <inb> 801005f0: 0f b6 c0 movzbl %al,%eax 801005f3: c1 e0 08 shl $0x8,%eax 801005f6: 89 45 f4 mov %eax,-0xc(%ebp) outb(CRTPORT, 15); 801005f9: c7 44 24 04 0f 00 00 movl $0xf,0x4(%esp) 80100600: 00 80100601: c7 04 24 d4 03 00 00 movl $0x3d4,(%esp) 80100608: e8 c0 fc ff ff call 801002cd <outb> pos |= inb(CRTPORT+1); 8010060d: c7 04 24 d5 03 00 00 movl $0x3d5,(%esp) 80100614: e8 97 fc ff ff call 801002b0 <inb> 80100619: 0f b6 c0 movzbl %al,%eax 8010061c: 09 45 f4 or %eax,-0xc(%ebp) if(c == '\n') 8010061f: 83 7d 08 0a cmpl $0xa,0x8(%ebp) 80100623: 75 30 jne 80100655 <cgaputc+0x8b> pos += 80 - pos%80; 80100625: 8b 4d f4 mov -0xc(%ebp),%ecx 80100628: ba 67 66 66 66 mov $0x66666667,%edx 8010062d: 89 c8 mov %ecx,%eax 8010062f: f7 ea imul %edx 80100631: c1 fa 05 sar $0x5,%edx 80100634: 89 c8 mov %ecx,%eax 80100636: c1 f8 1f sar $0x1f,%eax 80100639: 29 c2 sub %eax,%edx 8010063b: 89 d0 mov %edx,%eax 8010063d: c1 e0 02 shl $0x2,%eax 80100640: 01 d0 add %edx,%eax 80100642: c1 e0 04 shl $0x4,%eax 80100645: 29 c1 sub %eax,%ecx 80100647: 89 ca mov %ecx,%edx 80100649: b8 50 00 00 00 mov $0x50,%eax 8010064e: 29 d0 sub %edx,%eax 80100650: 01 45 f4 add %eax,-0xc(%ebp) 80100653: eb 35 jmp 8010068a <cgaputc+0xc0> else if(c == BACKSPACE){ 80100655: 81 7d 08 00 01 00 00 cmpl $0x100,0x8(%ebp) 8010065c: 75 0c jne 8010066a <cgaputc+0xa0> if(pos > 0) --pos; 8010065e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80100662: 7e 26 jle 8010068a <cgaputc+0xc0> 80100664: 83 6d f4 01 subl $0x1,-0xc(%ebp) 80100668: eb 20 jmp 8010068a <cgaputc+0xc0> } else crt[pos++] = (c&0xff) | 0x0700; // black on white 8010066a: 8b 0d 00 90 10 80 mov 0x80109000,%ecx 80100670: 8b 45 f4 mov -0xc(%ebp),%eax 80100673: 8d 50 01 lea 0x1(%eax),%edx 80100676: 89 55 f4 mov %edx,-0xc(%ebp) 80100679: 01 c0 add %eax,%eax 8010067b: 8d 14 01 lea (%ecx,%eax,1),%edx 8010067e: 8b 45 08 mov 0x8(%ebp),%eax 80100681: 0f b6 c0 movzbl %al,%eax 80100684: 80 cc 07 or $0x7,%ah 80100687: 66 89 02 mov %ax,(%edx) if(pos < 0 || pos > 25*80) 8010068a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 8010068e: 78 09 js 80100699 <cgaputc+0xcf> 80100690: 81 7d f4 d0 07 00 00 cmpl $0x7d0,-0xc(%ebp) 80100697: 7e 0c jle 801006a5 <cgaputc+0xdb> panic("pos under/overflow"); 80100699: c7 04 24 ab 88 10 80 movl $0x801088ab,(%esp) 801006a0: e8 95 fe ff ff call 8010053a <panic> if((pos/80) >= 24){ // Scroll up. 801006a5: 81 7d f4 7f 07 00 00 cmpl $0x77f,-0xc(%ebp) 801006ac: 7e 53 jle 80100701 <cgaputc+0x137> memmove(crt, crt+80, sizeof(crt[0])*23*80); 801006ae: a1 00 90 10 80 mov 0x80109000,%eax 801006b3: 8d 90 a0 00 00 00 lea 0xa0(%eax),%edx 801006b9: a1 00 90 10 80 mov 0x80109000,%eax 801006be: c7 44 24 08 60 0e 00 movl $0xe60,0x8(%esp) 801006c5: 00 801006c6: 89 54 24 04 mov %edx,0x4(%esp) 801006ca: 89 04 24 mov %eax,(%esp) 801006cd: e8 13 4e 00 00 call 801054e5 <memmove> pos -= 80; 801006d2: 83 6d f4 50 subl $0x50,-0xc(%ebp) memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 801006d6: b8 80 07 00 00 mov $0x780,%eax 801006db: 2b 45 f4 sub -0xc(%ebp),%eax 801006de: 8d 14 00 lea (%eax,%eax,1),%edx 801006e1: a1 00 90 10 80 mov 0x80109000,%eax 801006e6: 8b 4d f4 mov -0xc(%ebp),%ecx 801006e9: 01 c9 add %ecx,%ecx 801006eb: 01 c8 add %ecx,%eax 801006ed: 89 54 24 08 mov %edx,0x8(%esp) 801006f1: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801006f8: 00 801006f9: 89 04 24 mov %eax,(%esp) 801006fc: e8 15 4d 00 00 call 80105416 <memset> } outb(CRTPORT, 14); 80100701: c7 44 24 04 0e 00 00 movl $0xe,0x4(%esp) 80100708: 00 80100709: c7 04 24 d4 03 00 00 movl $0x3d4,(%esp) 80100710: e8 b8 fb ff ff call 801002cd <outb> outb(CRTPORT+1, pos>>8); 80100715: 8b 45 f4 mov -0xc(%ebp),%eax 80100718: c1 f8 08 sar $0x8,%eax 8010071b: 0f b6 c0 movzbl %al,%eax 8010071e: 89 44 24 04 mov %eax,0x4(%esp) 80100722: c7 04 24 d5 03 00 00 movl $0x3d5,(%esp) 80100729: e8 9f fb ff ff call 801002cd <outb> outb(CRTPORT, 15); 8010072e: c7 44 24 04 0f 00 00 movl $0xf,0x4(%esp) 80100735: 00 80100736: c7 04 24 d4 03 00 00 movl $0x3d4,(%esp) 8010073d: e8 8b fb ff ff call 801002cd <outb> outb(CRTPORT+1, pos); 80100742: 8b 45 f4 mov -0xc(%ebp),%eax 80100745: 0f b6 c0 movzbl %al,%eax 80100748: 89 44 24 04 mov %eax,0x4(%esp) 8010074c: c7 04 24 d5 03 00 00 movl $0x3d5,(%esp) 80100753: e8 75 fb ff ff call 801002cd <outb> crt[pos] = ' ' | 0x0700; 80100758: a1 00 90 10 80 mov 0x80109000,%eax 8010075d: 8b 55 f4 mov -0xc(%ebp),%edx 80100760: 01 d2 add %edx,%edx 80100762: 01 d0 add %edx,%eax 80100764: 66 c7 00 20 07 movw $0x720,(%eax) } 80100769: c9 leave 8010076a: c3 ret 8010076b <consputc>: void consputc(int c) { 8010076b: 55 push %ebp 8010076c: 89 e5 mov %esp,%ebp 8010076e: 83 ec 18 sub $0x18,%esp if(panicked){ 80100771: a1 a0 b5 10 80 mov 0x8010b5a0,%eax 80100776: 85 c0 test %eax,%eax 80100778: 74 07 je 80100781 <consputc+0x16> cli(); 8010077a: e8 6c fb ff ff call 801002eb <cli> for(;;) ; 8010077f: eb fe jmp 8010077f <consputc+0x14> } if(c == BACKSPACE){ 80100781: 81 7d 08 00 01 00 00 cmpl $0x100,0x8(%ebp) 80100788: 75 26 jne 801007b0 <consputc+0x45> uartputc('\b'); uartputc(' '); uartputc('\b'); 8010078a: c7 04 24 08 00 00 00 movl $0x8,(%esp) 80100791: e8 05 67 00 00 call 80106e9b <uartputc> 80100796: c7 04 24 20 00 00 00 movl $0x20,(%esp) 8010079d: e8 f9 66 00 00 call 80106e9b <uartputc> 801007a2: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801007a9: e8 ed 66 00 00 call 80106e9b <uartputc> 801007ae: eb 0b jmp 801007bb <consputc+0x50> } else uartputc(c); 801007b0: 8b 45 08 mov 0x8(%ebp),%eax 801007b3: 89 04 24 mov %eax,(%esp) 801007b6: e8 e0 66 00 00 call 80106e9b <uartputc> cgaputc(c); 801007bb: 8b 45 08 mov 0x8(%ebp),%eax 801007be: 89 04 24 mov %eax,(%esp) 801007c1: e8 04 fe ff ff call 801005ca <cgaputc> } 801007c6: c9 leave 801007c7: c3 ret 801007c8 <consoleintr>: #define C(x) ((x)-'@') // Control-x void consoleintr(int (*getc)(void)) { 801007c8: 55 push %ebp 801007c9: 89 e5 mov %esp,%ebp 801007cb: 83 ec 28 sub $0x28,%esp int c, doprocdump = 0; 801007ce: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) acquire(&cons.lock); 801007d5: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 801007dc: e8 de 49 00 00 call 801051bf <acquire> while((c = getc()) >= 0){ 801007e1: e9 39 01 00 00 jmp 8010091f <consoleintr+0x157> switch(c){ 801007e6: 8b 45 f0 mov -0x10(%ebp),%eax 801007e9: 83 f8 10 cmp $0x10,%eax 801007ec: 74 1e je 8010080c <consoleintr+0x44> 801007ee: 83 f8 10 cmp $0x10,%eax 801007f1: 7f 0a jg 801007fd <consoleintr+0x35> 801007f3: 83 f8 08 cmp $0x8,%eax 801007f6: 74 66 je 8010085e <consoleintr+0x96> 801007f8: e9 93 00 00 00 jmp 80100890 <consoleintr+0xc8> 801007fd: 83 f8 15 cmp $0x15,%eax 80100800: 74 31 je 80100833 <consoleintr+0x6b> 80100802: 83 f8 7f cmp $0x7f,%eax 80100805: 74 57 je 8010085e <consoleintr+0x96> 80100807: e9 84 00 00 00 jmp 80100890 <consoleintr+0xc8> case C('P'): // Process listing. doprocdump = 1; // procdump() locks cons.lock indirectly; invoke later 8010080c: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) break; 80100813: e9 07 01 00 00 jmp 8010091f <consoleintr+0x157> case C('U'): // Kill line. while(input.e != input.w && input.buf[(input.e-1) % INPUT_BUF] != '\n'){ input.e--; 80100818: a1 08 08 11 80 mov 0x80110808,%eax 8010081d: 83 e8 01 sub $0x1,%eax 80100820: a3 08 08 11 80 mov %eax,0x80110808 consputc(BACKSPACE); 80100825: c7 04 24 00 01 00 00 movl $0x100,(%esp) 8010082c: e8 3a ff ff ff call 8010076b <consputc> 80100831: eb 01 jmp 80100834 <consoleintr+0x6c> switch(c){ case C('P'): // Process listing. doprocdump = 1; // procdump() locks cons.lock indirectly; invoke later break; case C('U'): // Kill line. while(input.e != input.w && 80100833: 90 nop 80100834: 8b 15 08 08 11 80 mov 0x80110808,%edx 8010083a: a1 04 08 11 80 mov 0x80110804,%eax 8010083f: 39 c2 cmp %eax,%edx 80100841: 74 16 je 80100859 <consoleintr+0x91> input.buf[(input.e-1) % INPUT_BUF] != '\n'){ 80100843: a1 08 08 11 80 mov 0x80110808,%eax 80100848: 83 e8 01 sub $0x1,%eax 8010084b: 83 e0 7f and $0x7f,%eax 8010084e: 0f b6 80 80 07 11 80 movzbl -0x7feef880(%eax),%eax switch(c){ case C('P'): // Process listing. doprocdump = 1; // procdump() locks cons.lock indirectly; invoke later break; case C('U'): // Kill line. while(input.e != input.w && 80100855: 3c 0a cmp $0xa,%al 80100857: 75 bf jne 80100818 <consoleintr+0x50> input.buf[(input.e-1) % INPUT_BUF] != '\n'){ input.e--; consputc(BACKSPACE); } break; 80100859: e9 c1 00 00 00 jmp 8010091f <consoleintr+0x157> case C('H'): case '\x7f': // Backspace if(input.e != input.w){ 8010085e: 8b 15 08 08 11 80 mov 0x80110808,%edx 80100864: a1 04 08 11 80 mov 0x80110804,%eax 80100869: 39 c2 cmp %eax,%edx 8010086b: 74 1e je 8010088b <consoleintr+0xc3> input.e--; 8010086d: a1 08 08 11 80 mov 0x80110808,%eax 80100872: 83 e8 01 sub $0x1,%eax 80100875: a3 08 08 11 80 mov %eax,0x80110808 consputc(BACKSPACE); 8010087a: c7 04 24 00 01 00 00 movl $0x100,(%esp) 80100881: e8 e5 fe ff ff call 8010076b <consputc> } break; 80100886: e9 94 00 00 00 jmp 8010091f <consoleintr+0x157> 8010088b: e9 8f 00 00 00 jmp 8010091f <consoleintr+0x157> default: if(c != 0 && input.e-input.r < INPUT_BUF){ 80100890: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80100894: 0f 84 84 00 00 00 je 8010091e <consoleintr+0x156> 8010089a: 8b 15 08 08 11 80 mov 0x80110808,%edx 801008a0: a1 00 08 11 80 mov 0x80110800,%eax 801008a5: 29 c2 sub %eax,%edx 801008a7: 89 d0 mov %edx,%eax 801008a9: 83 f8 7f cmp $0x7f,%eax 801008ac: 77 70 ja 8010091e <consoleintr+0x156> c = (c == '\r') ? '\n' : c; 801008ae: 83 7d f0 0d cmpl $0xd,-0x10(%ebp) 801008b2: 74 05 je 801008b9 <consoleintr+0xf1> 801008b4: 8b 45 f0 mov -0x10(%ebp),%eax 801008b7: eb 05 jmp 801008be <consoleintr+0xf6> 801008b9: b8 0a 00 00 00 mov $0xa,%eax 801008be: 89 45 f0 mov %eax,-0x10(%ebp) input.buf[input.e++ % INPUT_BUF] = c; 801008c1: a1 08 08 11 80 mov 0x80110808,%eax 801008c6: 8d 50 01 lea 0x1(%eax),%edx 801008c9: 89 15 08 08 11 80 mov %edx,0x80110808 801008cf: 83 e0 7f and $0x7f,%eax 801008d2: 89 c2 mov %eax,%edx 801008d4: 8b 45 f0 mov -0x10(%ebp),%eax 801008d7: 88 82 80 07 11 80 mov %al,-0x7feef880(%edx) consputc(c); 801008dd: 8b 45 f0 mov -0x10(%ebp),%eax 801008e0: 89 04 24 mov %eax,(%esp) 801008e3: e8 83 fe ff ff call 8010076b <consputc> if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ 801008e8: 83 7d f0 0a cmpl $0xa,-0x10(%ebp) 801008ec: 74 18 je 80100906 <consoleintr+0x13e> 801008ee: 83 7d f0 04 cmpl $0x4,-0x10(%ebp) 801008f2: 74 12 je 80100906 <consoleintr+0x13e> 801008f4: a1 08 08 11 80 mov 0x80110808,%eax 801008f9: 8b 15 00 08 11 80 mov 0x80110800,%edx 801008ff: 83 ea 80 sub $0xffffff80,%edx 80100902: 39 d0 cmp %edx,%eax 80100904: 75 18 jne 8010091e <consoleintr+0x156> input.w = input.e; 80100906: a1 08 08 11 80 mov 0x80110808,%eax 8010090b: a3 04 08 11 80 mov %eax,0x80110804 wakeup(&input.r); 80100910: c7 04 24 00 08 11 80 movl $0x80110800,(%esp) 80100917: e8 ae 43 00 00 call 80104cca <wakeup> } } break; 8010091c: eb 00 jmp 8010091e <consoleintr+0x156> 8010091e: 90 nop consoleintr(int (*getc)(void)) { int c, doprocdump = 0; acquire(&cons.lock); while((c = getc()) >= 0){ 8010091f: 8b 45 08 mov 0x8(%ebp),%eax 80100922: ff d0 call *%eax 80100924: 89 45 f0 mov %eax,-0x10(%ebp) 80100927: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8010092b: 0f 89 b5 fe ff ff jns 801007e6 <consoleintr+0x1e> } } break; } } release(&cons.lock); 80100931: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100938: e8 e4 48 00 00 call 80105221 <release> if(doprocdump) { 8010093d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80100941: 74 05 je 80100948 <consoleintr+0x180> procdump(); // now call procdump() wo. cons.lock held 80100943: e8 6d 45 00 00 call 80104eb5 <procdump> } } 80100948: c9 leave 80100949: c3 ret 8010094a <consoleread>: int consoleread(struct inode *ip, char *dst, int n) { 8010094a: 55 push %ebp 8010094b: 89 e5 mov %esp,%ebp 8010094d: 83 ec 28 sub $0x28,%esp uint target; int c; iunlock(ip); 80100950: 8b 45 08 mov 0x8(%ebp),%eax 80100953: 89 04 24 mov %eax,(%esp) 80100956: e8 d1 10 00 00 call 80101a2c <iunlock> target = n; 8010095b: 8b 45 10 mov 0x10(%ebp),%eax 8010095e: 89 45 f4 mov %eax,-0xc(%ebp) acquire(&cons.lock); 80100961: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100968: e8 52 48 00 00 call 801051bf <acquire> while(n > 0){ 8010096d: e9 aa 00 00 00 jmp 80100a1c <consoleread+0xd2> while(input.r == input.w){ 80100972: eb 42 jmp 801009b6 <consoleread+0x6c> if(proc->killed){ 80100974: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010097a: 8b 40 24 mov 0x24(%eax),%eax 8010097d: 85 c0 test %eax,%eax 8010097f: 74 21 je 801009a2 <consoleread+0x58> release(&cons.lock); 80100981: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100988: e8 94 48 00 00 call 80105221 <release> ilock(ip); 8010098d: 8b 45 08 mov 0x8(%ebp),%eax 80100990: 89 04 24 mov %eax,(%esp) 80100993: e8 40 0f 00 00 call 801018d8 <ilock> return -1; 80100998: b8 ff ff ff ff mov $0xffffffff,%eax 8010099d: e9 a5 00 00 00 jmp 80100a47 <consoleread+0xfd> } sleep(&input.r, &cons.lock); 801009a2: c7 44 24 04 c0 b5 10 movl $0x8010b5c0,0x4(%esp) 801009a9: 80 801009aa: c7 04 24 00 08 11 80 movl $0x80110800,(%esp) 801009b1: e8 3b 42 00 00 call 80104bf1 <sleep> iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ 801009b6: 8b 15 00 08 11 80 mov 0x80110800,%edx 801009bc: a1 04 08 11 80 mov 0x80110804,%eax 801009c1: 39 c2 cmp %eax,%edx 801009c3: 74 af je 80100974 <consoleread+0x2a> ilock(ip); return -1; } sleep(&input.r, &cons.lock); } c = input.buf[input.r++ % INPUT_BUF]; 801009c5: a1 00 08 11 80 mov 0x80110800,%eax 801009ca: 8d 50 01 lea 0x1(%eax),%edx 801009cd: 89 15 00 08 11 80 mov %edx,0x80110800 801009d3: 83 e0 7f and $0x7f,%eax 801009d6: 0f b6 80 80 07 11 80 movzbl -0x7feef880(%eax),%eax 801009dd: 0f be c0 movsbl %al,%eax 801009e0: 89 45 f0 mov %eax,-0x10(%ebp) if(c == C('D')){ // EOF 801009e3: 83 7d f0 04 cmpl $0x4,-0x10(%ebp) 801009e7: 75 19 jne 80100a02 <consoleread+0xb8> if(n < target){ 801009e9: 8b 45 10 mov 0x10(%ebp),%eax 801009ec: 3b 45 f4 cmp -0xc(%ebp),%eax 801009ef: 73 0f jae 80100a00 <consoleread+0xb6> // Save ^D for next time, to make sure // caller gets a 0-byte result. input.r--; 801009f1: a1 00 08 11 80 mov 0x80110800,%eax 801009f6: 83 e8 01 sub $0x1,%eax 801009f9: a3 00 08 11 80 mov %eax,0x80110800 } break; 801009fe: eb 26 jmp 80100a26 <consoleread+0xdc> 80100a00: eb 24 jmp 80100a26 <consoleread+0xdc> } *dst++ = c; 80100a02: 8b 45 0c mov 0xc(%ebp),%eax 80100a05: 8d 50 01 lea 0x1(%eax),%edx 80100a08: 89 55 0c mov %edx,0xc(%ebp) 80100a0b: 8b 55 f0 mov -0x10(%ebp),%edx 80100a0e: 88 10 mov %dl,(%eax) --n; 80100a10: 83 6d 10 01 subl $0x1,0x10(%ebp) if(c == '\n') 80100a14: 83 7d f0 0a cmpl $0xa,-0x10(%ebp) 80100a18: 75 02 jne 80100a1c <consoleread+0xd2> break; 80100a1a: eb 0a jmp 80100a26 <consoleread+0xdc> int c; iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ 80100a1c: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 80100a20: 0f 8f 4c ff ff ff jg 80100972 <consoleread+0x28> *dst++ = c; --n; if(c == '\n') break; } release(&cons.lock); 80100a26: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100a2d: e8 ef 47 00 00 call 80105221 <release> ilock(ip); 80100a32: 8b 45 08 mov 0x8(%ebp),%eax 80100a35: 89 04 24 mov %eax,(%esp) 80100a38: e8 9b 0e 00 00 call 801018d8 <ilock> return target - n; 80100a3d: 8b 45 10 mov 0x10(%ebp),%eax 80100a40: 8b 55 f4 mov -0xc(%ebp),%edx 80100a43: 29 c2 sub %eax,%edx 80100a45: 89 d0 mov %edx,%eax } 80100a47: c9 leave 80100a48: c3 ret 80100a49 <consolewrite>: int consolewrite(struct inode *ip, char *buf, int n) { 80100a49: 55 push %ebp 80100a4a: 89 e5 mov %esp,%ebp 80100a4c: 83 ec 28 sub $0x28,%esp int i; iunlock(ip); 80100a4f: 8b 45 08 mov 0x8(%ebp),%eax 80100a52: 89 04 24 mov %eax,(%esp) 80100a55: e8 d2 0f 00 00 call 80101a2c <iunlock> acquire(&cons.lock); 80100a5a: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100a61: e8 59 47 00 00 call 801051bf <acquire> for(i = 0; i < n; i++) 80100a66: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80100a6d: eb 1d jmp 80100a8c <consolewrite+0x43> consputc(buf[i] & 0xff); 80100a6f: 8b 55 f4 mov -0xc(%ebp),%edx 80100a72: 8b 45 0c mov 0xc(%ebp),%eax 80100a75: 01 d0 add %edx,%eax 80100a77: 0f b6 00 movzbl (%eax),%eax 80100a7a: 0f be c0 movsbl %al,%eax 80100a7d: 0f b6 c0 movzbl %al,%eax 80100a80: 89 04 24 mov %eax,(%esp) 80100a83: e8 e3 fc ff ff call 8010076b <consputc> { int i; iunlock(ip); acquire(&cons.lock); for(i = 0; i < n; i++) 80100a88: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80100a8c: 8b 45 f4 mov -0xc(%ebp),%eax 80100a8f: 3b 45 10 cmp 0x10(%ebp),%eax 80100a92: 7c db jl 80100a6f <consolewrite+0x26> consputc(buf[i] & 0xff); release(&cons.lock); 80100a94: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100a9b: e8 81 47 00 00 call 80105221 <release> ilock(ip); 80100aa0: 8b 45 08 mov 0x8(%ebp),%eax 80100aa3: 89 04 24 mov %eax,(%esp) 80100aa6: e8 2d 0e 00 00 call 801018d8 <ilock> return n; 80100aab: 8b 45 10 mov 0x10(%ebp),%eax } 80100aae: c9 leave 80100aaf: c3 ret 80100ab0 <consoleinit>: void consoleinit(void) { 80100ab0: 55 push %ebp 80100ab1: 89 e5 mov %esp,%ebp 80100ab3: 83 ec 18 sub $0x18,%esp initlock(&cons.lock, "console"); 80100ab6: c7 44 24 04 be 88 10 movl $0x801088be,0x4(%esp) 80100abd: 80 80100abe: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100ac5: e8 d4 46 00 00 call 8010519e <initlock> devsw[CONSOLE].write = consolewrite; 80100aca: c7 05 cc 11 11 80 49 movl $0x80100a49,0x801111cc 80100ad1: 0a 10 80 devsw[CONSOLE].read = consoleread; 80100ad4: c7 05 c8 11 11 80 4a movl $0x8010094a,0x801111c8 80100adb: 09 10 80 cons.locking = 1; 80100ade: c7 05 f4 b5 10 80 01 movl $0x1,0x8010b5f4 80100ae5: 00 00 00 picenable(IRQ_KBD); 80100ae8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80100aef: e8 79 33 00 00 call 80103e6d <picenable> ioapicenable(IRQ_KBD, 0); 80100af4: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80100afb: 00 80100afc: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80100b03: e8 14 1f 00 00 call 80102a1c <ioapicenable> } 80100b08: c9 leave 80100b09: c3 ret 80100b0a: 66 90 xchg %ax,%ax 80100b0c <exec>: #include "x86.h" #include "elf.h" int exec(char *path, char **argv) { 80100b0c: 55 push %ebp 80100b0d: 89 e5 mov %esp,%ebp 80100b0f: 81 ec 38 01 00 00 sub $0x138,%esp struct elfhdr elf; struct inode *ip; struct proghdr ph; pde_t *pgdir, *oldpgdir; begin_op(); 80100b15: e8 ae 29 00 00 call 801034c8 <begin_op> if((ip = namei(path)) == 0){ 80100b1a: 8b 45 08 mov 0x8(%ebp),%eax 80100b1d: 89 04 24 mov %eax,(%esp) 80100b20: e8 64 19 00 00 call 80102489 <namei> 80100b25: 89 45 d8 mov %eax,-0x28(%ebp) 80100b28: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) 80100b2c: 75 0f jne 80100b3d <exec+0x31> end_op(); 80100b2e: e8 19 2a 00 00 call 8010354c <end_op> return -1; 80100b33: b8 ff ff ff ff mov $0xffffffff,%eax 80100b38: e9 e8 03 00 00 jmp 80100f25 <exec+0x419> } ilock(ip); 80100b3d: 8b 45 d8 mov -0x28(%ebp),%eax 80100b40: 89 04 24 mov %eax,(%esp) 80100b43: e8 90 0d 00 00 call 801018d8 <ilock> pgdir = 0; 80100b48: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) < sizeof(elf)) 80100b4f: c7 44 24 0c 34 00 00 movl $0x34,0xc(%esp) 80100b56: 00 80100b57: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80100b5e: 00 80100b5f: 8d 85 0c ff ff ff lea -0xf4(%ebp),%eax 80100b65: 89 44 24 04 mov %eax,0x4(%esp) 80100b69: 8b 45 d8 mov -0x28(%ebp),%eax 80100b6c: 89 04 24 mov %eax,(%esp) 80100b6f: e8 77 12 00 00 call 80101deb <readi> 80100b74: 83 f8 33 cmp $0x33,%eax 80100b77: 77 05 ja 80100b7e <exec+0x72> goto bad; 80100b79: e9 7b 03 00 00 jmp 80100ef9 <exec+0x3ed> if(elf.magic != ELF_MAGIC) 80100b7e: 8b 85 0c ff ff ff mov -0xf4(%ebp),%eax 80100b84: 3d 7f 45 4c 46 cmp $0x464c457f,%eax 80100b89: 74 05 je 80100b90 <exec+0x84> goto bad; 80100b8b: e9 69 03 00 00 jmp 80100ef9 <exec+0x3ed> if((pgdir = setupkvm()) == 0) 80100b90: e8 5c 74 00 00 call 80107ff1 <setupkvm> 80100b95: 89 45 d4 mov %eax,-0x2c(%ebp) 80100b98: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp) 80100b9c: 75 05 jne 80100ba3 <exec+0x97> goto bad; 80100b9e: e9 56 03 00 00 jmp 80100ef9 <exec+0x3ed> // Load program into memory. sz = 0; 80100ba3: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100baa: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) 80100bb1: 8b 85 28 ff ff ff mov -0xd8(%ebp),%eax 80100bb7: 89 45 e8 mov %eax,-0x18(%ebp) 80100bba: e9 cb 00 00 00 jmp 80100c8a <exec+0x17e> if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) 80100bbf: 8b 45 e8 mov -0x18(%ebp),%eax 80100bc2: c7 44 24 0c 20 00 00 movl $0x20,0xc(%esp) 80100bc9: 00 80100bca: 89 44 24 08 mov %eax,0x8(%esp) 80100bce: 8d 85 ec fe ff ff lea -0x114(%ebp),%eax 80100bd4: 89 44 24 04 mov %eax,0x4(%esp) 80100bd8: 8b 45 d8 mov -0x28(%ebp),%eax 80100bdb: 89 04 24 mov %eax,(%esp) 80100bde: e8 08 12 00 00 call 80101deb <readi> 80100be3: 83 f8 20 cmp $0x20,%eax 80100be6: 74 05 je 80100bed <exec+0xe1> goto bad; 80100be8: e9 0c 03 00 00 jmp 80100ef9 <exec+0x3ed> if(ph.type != ELF_PROG_LOAD) 80100bed: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax 80100bf3: 83 f8 01 cmp $0x1,%eax 80100bf6: 74 05 je 80100bfd <exec+0xf1> continue; 80100bf8: e9 80 00 00 00 jmp 80100c7d <exec+0x171> if(ph.memsz < ph.filesz) 80100bfd: 8b 95 00 ff ff ff mov -0x100(%ebp),%edx 80100c03: 8b 85 fc fe ff ff mov -0x104(%ebp),%eax 80100c09: 39 c2 cmp %eax,%edx 80100c0b: 73 05 jae 80100c12 <exec+0x106> goto bad; 80100c0d: e9 e7 02 00 00 jmp 80100ef9 <exec+0x3ed> if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) 80100c12: 8b 95 f4 fe ff ff mov -0x10c(%ebp),%edx 80100c18: 8b 85 00 ff ff ff mov -0x100(%ebp),%eax 80100c1e: 01 d0 add %edx,%eax 80100c20: 89 44 24 08 mov %eax,0x8(%esp) 80100c24: 8b 45 e0 mov -0x20(%ebp),%eax 80100c27: 89 44 24 04 mov %eax,0x4(%esp) 80100c2b: 8b 45 d4 mov -0x2c(%ebp),%eax 80100c2e: 89 04 24 mov %eax,(%esp) 80100c31: e8 89 77 00 00 call 801083bf <allocuvm> 80100c36: 89 45 e0 mov %eax,-0x20(%ebp) 80100c39: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 80100c3d: 75 05 jne 80100c44 <exec+0x138> goto bad; 80100c3f: e9 b5 02 00 00 jmp 80100ef9 <exec+0x3ed> if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) 80100c44: 8b 8d fc fe ff ff mov -0x104(%ebp),%ecx 80100c4a: 8b 95 f0 fe ff ff mov -0x110(%ebp),%edx 80100c50: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax 80100c56: 89 4c 24 10 mov %ecx,0x10(%esp) 80100c5a: 89 54 24 0c mov %edx,0xc(%esp) 80100c5e: 8b 55 d8 mov -0x28(%ebp),%edx 80100c61: 89 54 24 08 mov %edx,0x8(%esp) 80100c65: 89 44 24 04 mov %eax,0x4(%esp) 80100c69: 8b 45 d4 mov -0x2c(%ebp),%eax 80100c6c: 89 04 24 mov %eax,(%esp) 80100c6f: e8 60 76 00 00 call 801082d4 <loaduvm> 80100c74: 85 c0 test %eax,%eax 80100c76: 79 05 jns 80100c7d <exec+0x171> goto bad; 80100c78: e9 7c 02 00 00 jmp 80100ef9 <exec+0x3ed> if((pgdir = setupkvm()) == 0) goto bad; // Load program into memory. sz = 0; for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100c7d: 83 45 ec 01 addl $0x1,-0x14(%ebp) 80100c81: 8b 45 e8 mov -0x18(%ebp),%eax 80100c84: 83 c0 20 add $0x20,%eax 80100c87: 89 45 e8 mov %eax,-0x18(%ebp) 80100c8a: 0f b7 85 38 ff ff ff movzwl -0xc8(%ebp),%eax 80100c91: 0f b7 c0 movzwl %ax,%eax 80100c94: 3b 45 ec cmp -0x14(%ebp),%eax 80100c97: 0f 8f 22 ff ff ff jg 80100bbf <exec+0xb3> if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) goto bad; } iunlockput(ip); 80100c9d: 8b 45 d8 mov -0x28(%ebp),%eax 80100ca0: 89 04 24 mov %eax,(%esp) 80100ca3: e8 ba 0e 00 00 call 80101b62 <iunlockput> end_op(); 80100ca8: e8 9f 28 00 00 call 8010354c <end_op> ip = 0; 80100cad: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp) // Allocate two pages at the next page boundary. // Make the first inaccessible. Use the second as the user stack. sz = PGROUNDUP(sz); 80100cb4: 8b 45 e0 mov -0x20(%ebp),%eax 80100cb7: 05 ff 0f 00 00 add $0xfff,%eax 80100cbc: 25 00 f0 ff ff and $0xfffff000,%eax 80100cc1: 89 45 e0 mov %eax,-0x20(%ebp) if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) 80100cc4: 8b 45 e0 mov -0x20(%ebp),%eax 80100cc7: 05 00 20 00 00 add $0x2000,%eax 80100ccc: 89 44 24 08 mov %eax,0x8(%esp) 80100cd0: 8b 45 e0 mov -0x20(%ebp),%eax 80100cd3: 89 44 24 04 mov %eax,0x4(%esp) 80100cd7: 8b 45 d4 mov -0x2c(%ebp),%eax 80100cda: 89 04 24 mov %eax,(%esp) 80100cdd: e8 dd 76 00 00 call 801083bf <allocuvm> 80100ce2: 89 45 e0 mov %eax,-0x20(%ebp) 80100ce5: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 80100ce9: 75 05 jne 80100cf0 <exec+0x1e4> goto bad; 80100ceb: e9 09 02 00 00 jmp 80100ef9 <exec+0x3ed> clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); 80100cf0: 8b 45 e0 mov -0x20(%ebp),%eax 80100cf3: 2d 00 20 00 00 sub $0x2000,%eax 80100cf8: 89 44 24 04 mov %eax,0x4(%esp) 80100cfc: 8b 45 d4 mov -0x2c(%ebp),%eax 80100cff: 89 04 24 mov %eax,(%esp) 80100d02: e8 e8 78 00 00 call 801085ef <clearpteu> sp = sz; 80100d07: 8b 45 e0 mov -0x20(%ebp),%eax 80100d0a: 89 45 dc mov %eax,-0x24(%ebp) // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100d0d: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 80100d14: e9 9a 00 00 00 jmp 80100db3 <exec+0x2a7> if(argc >= MAXARG) 80100d19: 83 7d e4 1f cmpl $0x1f,-0x1c(%ebp) 80100d1d: 76 05 jbe 80100d24 <exec+0x218> goto bad; 80100d1f: e9 d5 01 00 00 jmp 80100ef9 <exec+0x3ed> sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100d24: 8b 45 e4 mov -0x1c(%ebp),%eax 80100d27: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80100d2e: 8b 45 0c mov 0xc(%ebp),%eax 80100d31: 01 d0 add %edx,%eax 80100d33: 8b 00 mov (%eax),%eax 80100d35: 89 04 24 mov %eax,(%esp) 80100d38: e8 43 49 00 00 call 80105680 <strlen> 80100d3d: 8b 55 dc mov -0x24(%ebp),%edx 80100d40: 29 c2 sub %eax,%edx 80100d42: 89 d0 mov %edx,%eax 80100d44: 83 e8 01 sub $0x1,%eax 80100d47: 83 e0 fc and $0xfffffffc,%eax 80100d4a: 89 45 dc mov %eax,-0x24(%ebp) if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100d4d: 8b 45 e4 mov -0x1c(%ebp),%eax 80100d50: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80100d57: 8b 45 0c mov 0xc(%ebp),%eax 80100d5a: 01 d0 add %edx,%eax 80100d5c: 8b 00 mov (%eax),%eax 80100d5e: 89 04 24 mov %eax,(%esp) 80100d61: e8 1a 49 00 00 call 80105680 <strlen> 80100d66: 83 c0 01 add $0x1,%eax 80100d69: 89 c2 mov %eax,%edx 80100d6b: 8b 45 e4 mov -0x1c(%ebp),%eax 80100d6e: 8d 0c 85 00 00 00 00 lea 0x0(,%eax,4),%ecx 80100d75: 8b 45 0c mov 0xc(%ebp),%eax 80100d78: 01 c8 add %ecx,%eax 80100d7a: 8b 00 mov (%eax),%eax 80100d7c: 89 54 24 0c mov %edx,0xc(%esp) 80100d80: 89 44 24 08 mov %eax,0x8(%esp) 80100d84: 8b 45 dc mov -0x24(%ebp),%eax 80100d87: 89 44 24 04 mov %eax,0x4(%esp) 80100d8b: 8b 45 d4 mov -0x2c(%ebp),%eax 80100d8e: 89 04 24 mov %eax,(%esp) 80100d91: e8 1e 7a 00 00 call 801087b4 <copyout> 80100d96: 85 c0 test %eax,%eax 80100d98: 79 05 jns 80100d9f <exec+0x293> goto bad; 80100d9a: e9 5a 01 00 00 jmp 80100ef9 <exec+0x3ed> ustack[3+argc] = sp; 80100d9f: 8b 45 e4 mov -0x1c(%ebp),%eax 80100da2: 8d 50 03 lea 0x3(%eax),%edx 80100da5: 8b 45 dc mov -0x24(%ebp),%eax 80100da8: 89 84 95 40 ff ff ff mov %eax,-0xc0(%ebp,%edx,4) goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100daf: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 80100db3: 8b 45 e4 mov -0x1c(%ebp),%eax 80100db6: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80100dbd: 8b 45 0c mov 0xc(%ebp),%eax 80100dc0: 01 d0 add %edx,%eax 80100dc2: 8b 00 mov (%eax),%eax 80100dc4: 85 c0 test %eax,%eax 80100dc6: 0f 85 4d ff ff ff jne 80100d19 <exec+0x20d> sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; } ustack[3+argc] = 0; 80100dcc: 8b 45 e4 mov -0x1c(%ebp),%eax 80100dcf: 83 c0 03 add $0x3,%eax 80100dd2: c7 84 85 40 ff ff ff movl $0x0,-0xc0(%ebp,%eax,4) 80100dd9: 00 00 00 00 ustack[0] = 0xffffffff; // fake return PC 80100ddd: c7 85 40 ff ff ff ff movl $0xffffffff,-0xc0(%ebp) 80100de4: ff ff ff ustack[1] = argc; 80100de7: 8b 45 e4 mov -0x1c(%ebp),%eax 80100dea: 89 85 44 ff ff ff mov %eax,-0xbc(%ebp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100df0: 8b 45 e4 mov -0x1c(%ebp),%eax 80100df3: 83 c0 01 add $0x1,%eax 80100df6: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80100dfd: 8b 45 dc mov -0x24(%ebp),%eax 80100e00: 29 d0 sub %edx,%eax 80100e02: 89 85 48 ff ff ff mov %eax,-0xb8(%ebp) sp -= (3+argc+1) * 4; 80100e08: 8b 45 e4 mov -0x1c(%ebp),%eax 80100e0b: 83 c0 04 add $0x4,%eax 80100e0e: c1 e0 02 shl $0x2,%eax 80100e11: 29 45 dc sub %eax,-0x24(%ebp) if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100e14: 8b 45 e4 mov -0x1c(%ebp),%eax 80100e17: 83 c0 04 add $0x4,%eax 80100e1a: c1 e0 02 shl $0x2,%eax 80100e1d: 89 44 24 0c mov %eax,0xc(%esp) 80100e21: 8d 85 40 ff ff ff lea -0xc0(%ebp),%eax 80100e27: 89 44 24 08 mov %eax,0x8(%esp) 80100e2b: 8b 45 dc mov -0x24(%ebp),%eax 80100e2e: 89 44 24 04 mov %eax,0x4(%esp) 80100e32: 8b 45 d4 mov -0x2c(%ebp),%eax 80100e35: 89 04 24 mov %eax,(%esp) 80100e38: e8 77 79 00 00 call 801087b4 <copyout> 80100e3d: 85 c0 test %eax,%eax 80100e3f: 79 05 jns 80100e46 <exec+0x33a> goto bad; 80100e41: e9 b3 00 00 00 jmp 80100ef9 <exec+0x3ed> // Save program name for debugging. for(last=s=path; *s; s++) 80100e46: 8b 45 08 mov 0x8(%ebp),%eax 80100e49: 89 45 f4 mov %eax,-0xc(%ebp) 80100e4c: 8b 45 f4 mov -0xc(%ebp),%eax 80100e4f: 89 45 f0 mov %eax,-0x10(%ebp) 80100e52: eb 17 jmp 80100e6b <exec+0x35f> if(*s == '/') 80100e54: 8b 45 f4 mov -0xc(%ebp),%eax 80100e57: 0f b6 00 movzbl (%eax),%eax 80100e5a: 3c 2f cmp $0x2f,%al 80100e5c: 75 09 jne 80100e67 <exec+0x35b> last = s+1; 80100e5e: 8b 45 f4 mov -0xc(%ebp),%eax 80100e61: 83 c0 01 add $0x1,%eax 80100e64: 89 45 f0 mov %eax,-0x10(%ebp) sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100e67: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80100e6b: 8b 45 f4 mov -0xc(%ebp),%eax 80100e6e: 0f b6 00 movzbl (%eax),%eax 80100e71: 84 c0 test %al,%al 80100e73: 75 df jne 80100e54 <exec+0x348> if(*s == '/') last = s+1; safestrcpy(proc->name, last, sizeof(proc->name)); 80100e75: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100e7b: 8d 50 6c lea 0x6c(%eax),%edx 80100e7e: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80100e85: 00 80100e86: 8b 45 f0 mov -0x10(%ebp),%eax 80100e89: 89 44 24 04 mov %eax,0x4(%esp) 80100e8d: 89 14 24 mov %edx,(%esp) 80100e90: e8 a1 47 00 00 call 80105636 <safestrcpy> // Commit to the user image. oldpgdir = proc->pgdir; 80100e95: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100e9b: 8b 40 04 mov 0x4(%eax),%eax 80100e9e: 89 45 d0 mov %eax,-0x30(%ebp) proc->pgdir = pgdir; 80100ea1: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100ea7: 8b 55 d4 mov -0x2c(%ebp),%edx 80100eaa: 89 50 04 mov %edx,0x4(%eax) proc->sz = sz; 80100ead: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100eb3: 8b 55 e0 mov -0x20(%ebp),%edx 80100eb6: 89 10 mov %edx,(%eax) proc->tf->eip = elf.entry; // main 80100eb8: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100ebe: 8b 40 18 mov 0x18(%eax),%eax 80100ec1: 8b 95 24 ff ff ff mov -0xdc(%ebp),%edx 80100ec7: 89 50 38 mov %edx,0x38(%eax) proc->tf->esp = sp; 80100eca: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100ed0: 8b 40 18 mov 0x18(%eax),%eax 80100ed3: 8b 55 dc mov -0x24(%ebp),%edx 80100ed6: 89 50 44 mov %edx,0x44(%eax) switchuvm(proc); 80100ed9: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100edf: 89 04 24 mov %eax,(%esp) 80100ee2: e8 fb 71 00 00 call 801080e2 <switchuvm> freevm(oldpgdir); 80100ee7: 8b 45 d0 mov -0x30(%ebp),%eax 80100eea: 89 04 24 mov %eax,(%esp) 80100eed: e8 63 76 00 00 call 80108555 <freevm> return 0; 80100ef2: b8 00 00 00 00 mov $0x0,%eax 80100ef7: eb 2c jmp 80100f25 <exec+0x419> bad: if(pgdir) 80100ef9: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp) 80100efd: 74 0b je 80100f0a <exec+0x3fe> freevm(pgdir); 80100eff: 8b 45 d4 mov -0x2c(%ebp),%eax 80100f02: 89 04 24 mov %eax,(%esp) 80100f05: e8 4b 76 00 00 call 80108555 <freevm> if(ip){ 80100f0a: 83 7d d8 00 cmpl $0x0,-0x28(%ebp) 80100f0e: 74 10 je 80100f20 <exec+0x414> iunlockput(ip); 80100f10: 8b 45 d8 mov -0x28(%ebp),%eax 80100f13: 89 04 24 mov %eax,(%esp) 80100f16: e8 47 0c 00 00 call 80101b62 <iunlockput> end_op(); 80100f1b: e8 2c 26 00 00 call 8010354c <end_op> } return -1; 80100f20: b8 ff ff ff ff mov $0xffffffff,%eax } 80100f25: c9 leave 80100f26: c3 ret 80100f27: 90 nop 80100f28 <fileinit>: struct file file[NFILE]; } ftable; void fileinit(void) { 80100f28: 55 push %ebp 80100f29: 89 e5 mov %esp,%ebp 80100f2b: 83 ec 18 sub $0x18,%esp initlock(&ftable.lock, "ftable"); 80100f2e: c7 44 24 04 c6 88 10 movl $0x801088c6,0x4(%esp) 80100f35: 80 80100f36: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 80100f3d: e8 5c 42 00 00 call 8010519e <initlock> } 80100f42: c9 leave 80100f43: c3 ret 80100f44 <filealloc>: // Allocate a file structure. struct file* filealloc(void) { 80100f44: 55 push %ebp 80100f45: 89 e5 mov %esp,%ebp 80100f47: 83 ec 28 sub $0x28,%esp struct file *f; acquire(&ftable.lock); 80100f4a: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 80100f51: e8 69 42 00 00 call 801051bf <acquire> for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100f56: c7 45 f4 54 08 11 80 movl $0x80110854,-0xc(%ebp) 80100f5d: eb 29 jmp 80100f88 <filealloc+0x44> if(f->ref == 0){ 80100f5f: 8b 45 f4 mov -0xc(%ebp),%eax 80100f62: 8b 40 04 mov 0x4(%eax),%eax 80100f65: 85 c0 test %eax,%eax 80100f67: 75 1b jne 80100f84 <filealloc+0x40> f->ref = 1; 80100f69: 8b 45 f4 mov -0xc(%ebp),%eax 80100f6c: c7 40 04 01 00 00 00 movl $0x1,0x4(%eax) release(&ftable.lock); 80100f73: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 80100f7a: e8 a2 42 00 00 call 80105221 <release> return f; 80100f7f: 8b 45 f4 mov -0xc(%ebp),%eax 80100f82: eb 1e jmp 80100fa2 <filealloc+0x5e> filealloc(void) { struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100f84: 83 45 f4 18 addl $0x18,-0xc(%ebp) 80100f88: 81 7d f4 b4 11 11 80 cmpl $0x801111b4,-0xc(%ebp) 80100f8f: 72 ce jb 80100f5f <filealloc+0x1b> f->ref = 1; release(&ftable.lock); return f; } } release(&ftable.lock); 80100f91: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 80100f98: e8 84 42 00 00 call 80105221 <release> return 0; 80100f9d: b8 00 00 00 00 mov $0x0,%eax } 80100fa2: c9 leave 80100fa3: c3 ret 80100fa4 <filedup>: // Increment ref count for file f. struct file* filedup(struct file *f) { 80100fa4: 55 push %ebp 80100fa5: 89 e5 mov %esp,%ebp 80100fa7: 83 ec 18 sub $0x18,%esp acquire(&ftable.lock); 80100faa: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 80100fb1: e8 09 42 00 00 call 801051bf <acquire> if(f->ref < 1) 80100fb6: 8b 45 08 mov 0x8(%ebp),%eax 80100fb9: 8b 40 04 mov 0x4(%eax),%eax 80100fbc: 85 c0 test %eax,%eax 80100fbe: 7f 0c jg 80100fcc <filedup+0x28> panic("filedup"); 80100fc0: c7 04 24 cd 88 10 80 movl $0x801088cd,(%esp) 80100fc7: e8 6e f5 ff ff call 8010053a <panic> f->ref++; 80100fcc: 8b 45 08 mov 0x8(%ebp),%eax 80100fcf: 8b 40 04 mov 0x4(%eax),%eax 80100fd2: 8d 50 01 lea 0x1(%eax),%edx 80100fd5: 8b 45 08 mov 0x8(%ebp),%eax 80100fd8: 89 50 04 mov %edx,0x4(%eax) release(&ftable.lock); 80100fdb: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 80100fe2: e8 3a 42 00 00 call 80105221 <release> return f; 80100fe7: 8b 45 08 mov 0x8(%ebp),%eax } 80100fea: c9 leave 80100feb: c3 ret 80100fec <fileclose>: // Close file f. (Decrement ref count, close when reaches 0.) void fileclose(struct file *f) { 80100fec: 55 push %ebp 80100fed: 89 e5 mov %esp,%ebp 80100fef: 83 ec 38 sub $0x38,%esp struct file ff; acquire(&ftable.lock); 80100ff2: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 80100ff9: e8 c1 41 00 00 call 801051bf <acquire> if(f->ref < 1) 80100ffe: 8b 45 08 mov 0x8(%ebp),%eax 80101001: 8b 40 04 mov 0x4(%eax),%eax 80101004: 85 c0 test %eax,%eax 80101006: 7f 0c jg 80101014 <fileclose+0x28> panic("fileclose"); 80101008: c7 04 24 d5 88 10 80 movl $0x801088d5,(%esp) 8010100f: e8 26 f5 ff ff call 8010053a <panic> if(--f->ref > 0){ 80101014: 8b 45 08 mov 0x8(%ebp),%eax 80101017: 8b 40 04 mov 0x4(%eax),%eax 8010101a: 8d 50 ff lea -0x1(%eax),%edx 8010101d: 8b 45 08 mov 0x8(%ebp),%eax 80101020: 89 50 04 mov %edx,0x4(%eax) 80101023: 8b 45 08 mov 0x8(%ebp),%eax 80101026: 8b 40 04 mov 0x4(%eax),%eax 80101029: 85 c0 test %eax,%eax 8010102b: 7e 11 jle 8010103e <fileclose+0x52> release(&ftable.lock); 8010102d: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 80101034: e8 e8 41 00 00 call 80105221 <release> 80101039: e9 82 00 00 00 jmp 801010c0 <fileclose+0xd4> return; } ff = *f; 8010103e: 8b 45 08 mov 0x8(%ebp),%eax 80101041: 8b 10 mov (%eax),%edx 80101043: 89 55 e0 mov %edx,-0x20(%ebp) 80101046: 8b 50 04 mov 0x4(%eax),%edx 80101049: 89 55 e4 mov %edx,-0x1c(%ebp) 8010104c: 8b 50 08 mov 0x8(%eax),%edx 8010104f: 89 55 e8 mov %edx,-0x18(%ebp) 80101052: 8b 50 0c mov 0xc(%eax),%edx 80101055: 89 55 ec mov %edx,-0x14(%ebp) 80101058: 8b 50 10 mov 0x10(%eax),%edx 8010105b: 89 55 f0 mov %edx,-0x10(%ebp) 8010105e: 8b 40 14 mov 0x14(%eax),%eax 80101061: 89 45 f4 mov %eax,-0xc(%ebp) f->ref = 0; 80101064: 8b 45 08 mov 0x8(%ebp),%eax 80101067: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) f->type = FD_NONE; 8010106e: 8b 45 08 mov 0x8(%ebp),%eax 80101071: c7 00 00 00 00 00 movl $0x0,(%eax) release(&ftable.lock); 80101077: c7 04 24 20 08 11 80 movl $0x80110820,(%esp) 8010107e: e8 9e 41 00 00 call 80105221 <release> if(ff.type == FD_PIPE) 80101083: 8b 45 e0 mov -0x20(%ebp),%eax 80101086: 83 f8 01 cmp $0x1,%eax 80101089: 75 18 jne 801010a3 <fileclose+0xb7> pipeclose(ff.pipe, ff.writable); 8010108b: 0f b6 45 e9 movzbl -0x17(%ebp),%eax 8010108f: 0f be d0 movsbl %al,%edx 80101092: 8b 45 ec mov -0x14(%ebp),%eax 80101095: 89 54 24 04 mov %edx,0x4(%esp) 80101099: 89 04 24 mov %eax,(%esp) 8010109c: e8 7e 30 00 00 call 8010411f <pipeclose> 801010a1: eb 1d jmp 801010c0 <fileclose+0xd4> else if(ff.type == FD_INODE){ 801010a3: 8b 45 e0 mov -0x20(%ebp),%eax 801010a6: 83 f8 02 cmp $0x2,%eax 801010a9: 75 15 jne 801010c0 <fileclose+0xd4> begin_op(); 801010ab: e8 18 24 00 00 call 801034c8 <begin_op> iput(ff.ip); 801010b0: 8b 45 f0 mov -0x10(%ebp),%eax 801010b3: 89 04 24 mov %eax,(%esp) 801010b6: e8 d6 09 00 00 call 80101a91 <iput> end_op(); 801010bb: e8 8c 24 00 00 call 8010354c <end_op> } } 801010c0: c9 leave 801010c1: c3 ret 801010c2 <filestat>: // Get metadata about file f. int filestat(struct file *f, struct stat *st) { 801010c2: 55 push %ebp 801010c3: 89 e5 mov %esp,%ebp 801010c5: 83 ec 18 sub $0x18,%esp if(f->type == FD_INODE){ 801010c8: 8b 45 08 mov 0x8(%ebp),%eax 801010cb: 8b 00 mov (%eax),%eax 801010cd: 83 f8 02 cmp $0x2,%eax 801010d0: 75 38 jne 8010110a <filestat+0x48> ilock(f->ip); 801010d2: 8b 45 08 mov 0x8(%ebp),%eax 801010d5: 8b 40 10 mov 0x10(%eax),%eax 801010d8: 89 04 24 mov %eax,(%esp) 801010db: e8 f8 07 00 00 call 801018d8 <ilock> stati(f->ip, st); 801010e0: 8b 45 08 mov 0x8(%ebp),%eax 801010e3: 8b 40 10 mov 0x10(%eax),%eax 801010e6: 8b 55 0c mov 0xc(%ebp),%edx 801010e9: 89 54 24 04 mov %edx,0x4(%esp) 801010ed: 89 04 24 mov %eax,(%esp) 801010f0: e8 b1 0c 00 00 call 80101da6 <stati> iunlock(f->ip); 801010f5: 8b 45 08 mov 0x8(%ebp),%eax 801010f8: 8b 40 10 mov 0x10(%eax),%eax 801010fb: 89 04 24 mov %eax,(%esp) 801010fe: e8 29 09 00 00 call 80101a2c <iunlock> return 0; 80101103: b8 00 00 00 00 mov $0x0,%eax 80101108: eb 05 jmp 8010110f <filestat+0x4d> } return -1; 8010110a: b8 ff ff ff ff mov $0xffffffff,%eax } 8010110f: c9 leave 80101110: c3 ret 80101111 <fileread>: // Read from file f. int fileread(struct file *f, char *addr, int n) { 80101111: 55 push %ebp 80101112: 89 e5 mov %esp,%ebp 80101114: 83 ec 28 sub $0x28,%esp int r; if(f->readable == 0) 80101117: 8b 45 08 mov 0x8(%ebp),%eax 8010111a: 0f b6 40 08 movzbl 0x8(%eax),%eax 8010111e: 84 c0 test %al,%al 80101120: 75 0a jne 8010112c <fileread+0x1b> return -1; 80101122: b8 ff ff ff ff mov $0xffffffff,%eax 80101127: e9 9f 00 00 00 jmp 801011cb <fileread+0xba> if(f->type == FD_PIPE) 8010112c: 8b 45 08 mov 0x8(%ebp),%eax 8010112f: 8b 00 mov (%eax),%eax 80101131: 83 f8 01 cmp $0x1,%eax 80101134: 75 1e jne 80101154 <fileread+0x43> return piperead(f->pipe, addr, n); 80101136: 8b 45 08 mov 0x8(%ebp),%eax 80101139: 8b 40 0c mov 0xc(%eax),%eax 8010113c: 8b 55 10 mov 0x10(%ebp),%edx 8010113f: 89 54 24 08 mov %edx,0x8(%esp) 80101143: 8b 55 0c mov 0xc(%ebp),%edx 80101146: 89 54 24 04 mov %edx,0x4(%esp) 8010114a: 89 04 24 mov %eax,(%esp) 8010114d: e8 4e 31 00 00 call 801042a0 <piperead> 80101152: eb 77 jmp 801011cb <fileread+0xba> if(f->type == FD_INODE){ 80101154: 8b 45 08 mov 0x8(%ebp),%eax 80101157: 8b 00 mov (%eax),%eax 80101159: 83 f8 02 cmp $0x2,%eax 8010115c: 75 61 jne 801011bf <fileread+0xae> ilock(f->ip); 8010115e: 8b 45 08 mov 0x8(%ebp),%eax 80101161: 8b 40 10 mov 0x10(%eax),%eax 80101164: 89 04 24 mov %eax,(%esp) 80101167: e8 6c 07 00 00 call 801018d8 <ilock> if((r = readi(f->ip, addr, f->off, n)) > 0) 8010116c: 8b 4d 10 mov 0x10(%ebp),%ecx 8010116f: 8b 45 08 mov 0x8(%ebp),%eax 80101172: 8b 50 14 mov 0x14(%eax),%edx 80101175: 8b 45 08 mov 0x8(%ebp),%eax 80101178: 8b 40 10 mov 0x10(%eax),%eax 8010117b: 89 4c 24 0c mov %ecx,0xc(%esp) 8010117f: 89 54 24 08 mov %edx,0x8(%esp) 80101183: 8b 55 0c mov 0xc(%ebp),%edx 80101186: 89 54 24 04 mov %edx,0x4(%esp) 8010118a: 89 04 24 mov %eax,(%esp) 8010118d: e8 59 0c 00 00 call 80101deb <readi> 80101192: 89 45 f4 mov %eax,-0xc(%ebp) 80101195: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80101199: 7e 11 jle 801011ac <fileread+0x9b> f->off += r; 8010119b: 8b 45 08 mov 0x8(%ebp),%eax 8010119e: 8b 50 14 mov 0x14(%eax),%edx 801011a1: 8b 45 f4 mov -0xc(%ebp),%eax 801011a4: 01 c2 add %eax,%edx 801011a6: 8b 45 08 mov 0x8(%ebp),%eax 801011a9: 89 50 14 mov %edx,0x14(%eax) iunlock(f->ip); 801011ac: 8b 45 08 mov 0x8(%ebp),%eax 801011af: 8b 40 10 mov 0x10(%eax),%eax 801011b2: 89 04 24 mov %eax,(%esp) 801011b5: e8 72 08 00 00 call 80101a2c <iunlock> return r; 801011ba: 8b 45 f4 mov -0xc(%ebp),%eax 801011bd: eb 0c jmp 801011cb <fileread+0xba> } panic("fileread"); 801011bf: c7 04 24 df 88 10 80 movl $0x801088df,(%esp) 801011c6: e8 6f f3 ff ff call 8010053a <panic> } 801011cb: c9 leave 801011cc: c3 ret 801011cd <filewrite>: //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 801011cd: 55 push %ebp 801011ce: 89 e5 mov %esp,%ebp 801011d0: 53 push %ebx 801011d1: 83 ec 24 sub $0x24,%esp int r; if(f->writable == 0) 801011d4: 8b 45 08 mov 0x8(%ebp),%eax 801011d7: 0f b6 40 09 movzbl 0x9(%eax),%eax 801011db: 84 c0 test %al,%al 801011dd: 75 0a jne 801011e9 <filewrite+0x1c> return -1; 801011df: b8 ff ff ff ff mov $0xffffffff,%eax 801011e4: e9 20 01 00 00 jmp 80101309 <filewrite+0x13c> if(f->type == FD_PIPE) 801011e9: 8b 45 08 mov 0x8(%ebp),%eax 801011ec: 8b 00 mov (%eax),%eax 801011ee: 83 f8 01 cmp $0x1,%eax 801011f1: 75 21 jne 80101214 <filewrite+0x47> return pipewrite(f->pipe, addr, n); 801011f3: 8b 45 08 mov 0x8(%ebp),%eax 801011f6: 8b 40 0c mov 0xc(%eax),%eax 801011f9: 8b 55 10 mov 0x10(%ebp),%edx 801011fc: 89 54 24 08 mov %edx,0x8(%esp) 80101200: 8b 55 0c mov 0xc(%ebp),%edx 80101203: 89 54 24 04 mov %edx,0x4(%esp) 80101207: 89 04 24 mov %eax,(%esp) 8010120a: e8 a2 2f 00 00 call 801041b1 <pipewrite> 8010120f: e9 f5 00 00 00 jmp 80101309 <filewrite+0x13c> if(f->type == FD_INODE){ 80101214: 8b 45 08 mov 0x8(%ebp),%eax 80101217: 8b 00 mov (%eax),%eax 80101219: 83 f8 02 cmp $0x2,%eax 8010121c: 0f 85 db 00 00 00 jne 801012fd <filewrite+0x130> // the maximum log transaction size, including // i-node, indirect block, allocation blocks, // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((LOGSIZE-1-1-2) / 2) * 512; 80101222: c7 45 ec 00 1a 00 00 movl $0x1a00,-0x14(%ebp) int i = 0; 80101229: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) while(i < n){ 80101230: e9 a8 00 00 00 jmp 801012dd <filewrite+0x110> int n1 = n - i; 80101235: 8b 45 f4 mov -0xc(%ebp),%eax 80101238: 8b 55 10 mov 0x10(%ebp),%edx 8010123b: 29 c2 sub %eax,%edx 8010123d: 89 d0 mov %edx,%eax 8010123f: 89 45 f0 mov %eax,-0x10(%ebp) if(n1 > max) 80101242: 8b 45 f0 mov -0x10(%ebp),%eax 80101245: 3b 45 ec cmp -0x14(%ebp),%eax 80101248: 7e 06 jle 80101250 <filewrite+0x83> n1 = max; 8010124a: 8b 45 ec mov -0x14(%ebp),%eax 8010124d: 89 45 f0 mov %eax,-0x10(%ebp) begin_op(); 80101250: e8 73 22 00 00 call 801034c8 <begin_op> ilock(f->ip); 80101255: 8b 45 08 mov 0x8(%ebp),%eax 80101258: 8b 40 10 mov 0x10(%eax),%eax 8010125b: 89 04 24 mov %eax,(%esp) 8010125e: e8 75 06 00 00 call 801018d8 <ilock> if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) 80101263: 8b 4d f0 mov -0x10(%ebp),%ecx 80101266: 8b 45 08 mov 0x8(%ebp),%eax 80101269: 8b 50 14 mov 0x14(%eax),%edx 8010126c: 8b 5d f4 mov -0xc(%ebp),%ebx 8010126f: 8b 45 0c mov 0xc(%ebp),%eax 80101272: 01 c3 add %eax,%ebx 80101274: 8b 45 08 mov 0x8(%ebp),%eax 80101277: 8b 40 10 mov 0x10(%eax),%eax 8010127a: 89 4c 24 0c mov %ecx,0xc(%esp) 8010127e: 89 54 24 08 mov %edx,0x8(%esp) 80101282: 89 5c 24 04 mov %ebx,0x4(%esp) 80101286: 89 04 24 mov %eax,(%esp) 80101289: e8 c1 0c 00 00 call 80101f4f <writei> 8010128e: 89 45 e8 mov %eax,-0x18(%ebp) 80101291: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 80101295: 7e 11 jle 801012a8 <filewrite+0xdb> f->off += r; 80101297: 8b 45 08 mov 0x8(%ebp),%eax 8010129a: 8b 50 14 mov 0x14(%eax),%edx 8010129d: 8b 45 e8 mov -0x18(%ebp),%eax 801012a0: 01 c2 add %eax,%edx 801012a2: 8b 45 08 mov 0x8(%ebp),%eax 801012a5: 89 50 14 mov %edx,0x14(%eax) iunlock(f->ip); 801012a8: 8b 45 08 mov 0x8(%ebp),%eax 801012ab: 8b 40 10 mov 0x10(%eax),%eax 801012ae: 89 04 24 mov %eax,(%esp) 801012b1: e8 76 07 00 00 call 80101a2c <iunlock> end_op(); 801012b6: e8 91 22 00 00 call 8010354c <end_op> if(r < 0) 801012bb: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 801012bf: 79 02 jns 801012c3 <filewrite+0xf6> break; 801012c1: eb 26 jmp 801012e9 <filewrite+0x11c> if(r != n1) 801012c3: 8b 45 e8 mov -0x18(%ebp),%eax 801012c6: 3b 45 f0 cmp -0x10(%ebp),%eax 801012c9: 74 0c je 801012d7 <filewrite+0x10a> panic("short filewrite"); 801012cb: c7 04 24 e8 88 10 80 movl $0x801088e8,(%esp) 801012d2: e8 63 f2 ff ff call 8010053a <panic> i += r; 801012d7: 8b 45 e8 mov -0x18(%ebp),%eax 801012da: 01 45 f4 add %eax,-0xc(%ebp) // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((LOGSIZE-1-1-2) / 2) * 512; int i = 0; while(i < n){ 801012dd: 8b 45 f4 mov -0xc(%ebp),%eax 801012e0: 3b 45 10 cmp 0x10(%ebp),%eax 801012e3: 0f 8c 4c ff ff ff jl 80101235 <filewrite+0x68> break; if(r != n1) panic("short filewrite"); i += r; } return i == n ? n : -1; 801012e9: 8b 45 f4 mov -0xc(%ebp),%eax 801012ec: 3b 45 10 cmp 0x10(%ebp),%eax 801012ef: 75 05 jne 801012f6 <filewrite+0x129> 801012f1: 8b 45 10 mov 0x10(%ebp),%eax 801012f4: eb 05 jmp 801012fb <filewrite+0x12e> 801012f6: b8 ff ff ff ff mov $0xffffffff,%eax 801012fb: eb 0c jmp 80101309 <filewrite+0x13c> } panic("filewrite"); 801012fd: c7 04 24 f8 88 10 80 movl $0x801088f8,(%esp) 80101304: e8 31 f2 ff ff call 8010053a <panic> } 80101309: 83 c4 24 add $0x24,%esp 8010130c: 5b pop %ebx 8010130d: 5d pop %ebp 8010130e: c3 ret 8010130f: 90 nop 80101310 <readsb>: struct superblock sb; // there should be one per dev, but we run with one dev // Read the super block. void readsb(int dev, struct superblock *sb) { 80101310: 55 push %ebp 80101311: 89 e5 mov %esp,%ebp 80101313: 83 ec 28 sub $0x28,%esp struct buf *bp; bp = bread(dev, 1); 80101316: 8b 45 08 mov 0x8(%ebp),%eax 80101319: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80101320: 00 80101321: 89 04 24 mov %eax,(%esp) 80101324: e8 7d ee ff ff call 801001a6 <bread> 80101329: 89 45 f4 mov %eax,-0xc(%ebp) memmove(sb, bp->data, sizeof(*sb)); 8010132c: 8b 45 f4 mov -0xc(%ebp),%eax 8010132f: 83 c0 18 add $0x18,%eax 80101332: c7 44 24 08 1c 00 00 movl $0x1c,0x8(%esp) 80101339: 00 8010133a: 89 44 24 04 mov %eax,0x4(%esp) 8010133e: 8b 45 0c mov 0xc(%ebp),%eax 80101341: 89 04 24 mov %eax,(%esp) 80101344: e8 9c 41 00 00 call 801054e5 <memmove> brelse(bp); 80101349: 8b 45 f4 mov -0xc(%ebp),%eax 8010134c: 89 04 24 mov %eax,(%esp) 8010134f: e8 c3 ee ff ff call 80100217 <brelse> } 80101354: c9 leave 80101355: c3 ret 80101356 <bzero>: // Zero a block. static void bzero(int dev, int bno) { 80101356: 55 push %ebp 80101357: 89 e5 mov %esp,%ebp 80101359: 83 ec 28 sub $0x28,%esp struct buf *bp; bp = bread(dev, bno); 8010135c: 8b 55 0c mov 0xc(%ebp),%edx 8010135f: 8b 45 08 mov 0x8(%ebp),%eax 80101362: 89 54 24 04 mov %edx,0x4(%esp) 80101366: 89 04 24 mov %eax,(%esp) 80101369: e8 38 ee ff ff call 801001a6 <bread> 8010136e: 89 45 f4 mov %eax,-0xc(%ebp) memset(bp->data, 0, BSIZE); 80101371: 8b 45 f4 mov -0xc(%ebp),%eax 80101374: 83 c0 18 add $0x18,%eax 80101377: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 8010137e: 00 8010137f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80101386: 00 80101387: 89 04 24 mov %eax,(%esp) 8010138a: e8 87 40 00 00 call 80105416 <memset> log_write(bp); 8010138f: 8b 45 f4 mov -0xc(%ebp),%eax 80101392: 89 04 24 mov %eax,(%esp) 80101395: e8 39 23 00 00 call 801036d3 <log_write> brelse(bp); 8010139a: 8b 45 f4 mov -0xc(%ebp),%eax 8010139d: 89 04 24 mov %eax,(%esp) 801013a0: e8 72 ee ff ff call 80100217 <brelse> } 801013a5: c9 leave 801013a6: c3 ret 801013a7 <balloc>: // Blocks. // Allocate a zeroed disk block. static uint balloc(uint dev) { 801013a7: 55 push %ebp 801013a8: 89 e5 mov %esp,%ebp 801013aa: 83 ec 28 sub $0x28,%esp int b, bi, m; struct buf *bp; bp = 0; 801013ad: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) for(b = 0; b < sb.size; b += BPB){ 801013b4: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 801013bb: e9 07 01 00 00 jmp 801014c7 <balloc+0x120> bp = bread(dev, BBLOCK(b, sb)); 801013c0: 8b 45 f4 mov -0xc(%ebp),%eax 801013c3: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 801013c9: 85 c0 test %eax,%eax 801013cb: 0f 48 c2 cmovs %edx,%eax 801013ce: c1 f8 0c sar $0xc,%eax 801013d1: 89 c2 mov %eax,%edx 801013d3: a1 38 12 11 80 mov 0x80111238,%eax 801013d8: 01 d0 add %edx,%eax 801013da: 89 44 24 04 mov %eax,0x4(%esp) 801013de: 8b 45 08 mov 0x8(%ebp),%eax 801013e1: 89 04 24 mov %eax,(%esp) 801013e4: e8 bd ed ff ff call 801001a6 <bread> 801013e9: 89 45 ec mov %eax,-0x14(%ebp) for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 801013ec: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 801013f3: e9 9d 00 00 00 jmp 80101495 <balloc+0xee> m = 1 << (bi % 8); 801013f8: 8b 45 f0 mov -0x10(%ebp),%eax 801013fb: 99 cltd 801013fc: c1 ea 1d shr $0x1d,%edx 801013ff: 01 d0 add %edx,%eax 80101401: 83 e0 07 and $0x7,%eax 80101404: 29 d0 sub %edx,%eax 80101406: ba 01 00 00 00 mov $0x1,%edx 8010140b: 89 c1 mov %eax,%ecx 8010140d: d3 e2 shl %cl,%edx 8010140f: 89 d0 mov %edx,%eax 80101411: 89 45 e8 mov %eax,-0x18(%ebp) if((bp->data[bi/8] & m) == 0){ // Is block free? 80101414: 8b 45 f0 mov -0x10(%ebp),%eax 80101417: 8d 50 07 lea 0x7(%eax),%edx 8010141a: 85 c0 test %eax,%eax 8010141c: 0f 48 c2 cmovs %edx,%eax 8010141f: c1 f8 03 sar $0x3,%eax 80101422: 8b 55 ec mov -0x14(%ebp),%edx 80101425: 0f b6 44 02 18 movzbl 0x18(%edx,%eax,1),%eax 8010142a: 0f b6 c0 movzbl %al,%eax 8010142d: 23 45 e8 and -0x18(%ebp),%eax 80101430: 85 c0 test %eax,%eax 80101432: 75 5d jne 80101491 <balloc+0xea> bp->data[bi/8] |= m; // Mark block in use. 80101434: 8b 45 f0 mov -0x10(%ebp),%eax 80101437: 8d 50 07 lea 0x7(%eax),%edx 8010143a: 85 c0 test %eax,%eax 8010143c: 0f 48 c2 cmovs %edx,%eax 8010143f: c1 f8 03 sar $0x3,%eax 80101442: 8b 55 ec mov -0x14(%ebp),%edx 80101445: 0f b6 54 02 18 movzbl 0x18(%edx,%eax,1),%edx 8010144a: 89 d1 mov %edx,%ecx 8010144c: 8b 55 e8 mov -0x18(%ebp),%edx 8010144f: 09 ca or %ecx,%edx 80101451: 89 d1 mov %edx,%ecx 80101453: 8b 55 ec mov -0x14(%ebp),%edx 80101456: 88 4c 02 18 mov %cl,0x18(%edx,%eax,1) log_write(bp); 8010145a: 8b 45 ec mov -0x14(%ebp),%eax 8010145d: 89 04 24 mov %eax,(%esp) 80101460: e8 6e 22 00 00 call 801036d3 <log_write> brelse(bp); 80101465: 8b 45 ec mov -0x14(%ebp),%eax 80101468: 89 04 24 mov %eax,(%esp) 8010146b: e8 a7 ed ff ff call 80100217 <brelse> bzero(dev, b + bi); 80101470: 8b 45 f0 mov -0x10(%ebp),%eax 80101473: 8b 55 f4 mov -0xc(%ebp),%edx 80101476: 01 c2 add %eax,%edx 80101478: 8b 45 08 mov 0x8(%ebp),%eax 8010147b: 89 54 24 04 mov %edx,0x4(%esp) 8010147f: 89 04 24 mov %eax,(%esp) 80101482: e8 cf fe ff ff call 80101356 <bzero> return b + bi; 80101487: 8b 45 f0 mov -0x10(%ebp),%eax 8010148a: 8b 55 f4 mov -0xc(%ebp),%edx 8010148d: 01 d0 add %edx,%eax 8010148f: eb 52 jmp 801014e3 <balloc+0x13c> struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 80101491: 83 45 f0 01 addl $0x1,-0x10(%ebp) 80101495: 81 7d f0 ff 0f 00 00 cmpl $0xfff,-0x10(%ebp) 8010149c: 7f 17 jg 801014b5 <balloc+0x10e> 8010149e: 8b 45 f0 mov -0x10(%ebp),%eax 801014a1: 8b 55 f4 mov -0xc(%ebp),%edx 801014a4: 01 d0 add %edx,%eax 801014a6: 89 c2 mov %eax,%edx 801014a8: a1 20 12 11 80 mov 0x80111220,%eax 801014ad: 39 c2 cmp %eax,%edx 801014af: 0f 82 43 ff ff ff jb 801013f8 <balloc+0x51> brelse(bp); bzero(dev, b + bi); return b + bi; } } brelse(bp); 801014b5: 8b 45 ec mov -0x14(%ebp),%eax 801014b8: 89 04 24 mov %eax,(%esp) 801014bb: e8 57 ed ff ff call 80100217 <brelse> { int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 801014c0: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) 801014c7: 8b 55 f4 mov -0xc(%ebp),%edx 801014ca: a1 20 12 11 80 mov 0x80111220,%eax 801014cf: 39 c2 cmp %eax,%edx 801014d1: 0f 82 e9 fe ff ff jb 801013c0 <balloc+0x19> return b + bi; } } brelse(bp); } panic("balloc: out of blocks"); 801014d7: c7 04 24 04 89 10 80 movl $0x80108904,(%esp) 801014de: e8 57 f0 ff ff call 8010053a <panic> } 801014e3: c9 leave 801014e4: c3 ret 801014e5 <bfree>: // Free a disk block. static void bfree(int dev, uint b) { 801014e5: 55 push %ebp 801014e6: 89 e5 mov %esp,%ebp 801014e8: 83 ec 28 sub $0x28,%esp struct buf *bp; int bi, m; readsb(dev, &sb); 801014eb: c7 44 24 04 20 12 11 movl $0x80111220,0x4(%esp) 801014f2: 80 801014f3: 8b 45 08 mov 0x8(%ebp),%eax 801014f6: 89 04 24 mov %eax,(%esp) 801014f9: e8 12 fe ff ff call 80101310 <readsb> bp = bread(dev, BBLOCK(b, sb)); 801014fe: 8b 45 0c mov 0xc(%ebp),%eax 80101501: c1 e8 0c shr $0xc,%eax 80101504: 89 c2 mov %eax,%edx 80101506: a1 38 12 11 80 mov 0x80111238,%eax 8010150b: 01 c2 add %eax,%edx 8010150d: 8b 45 08 mov 0x8(%ebp),%eax 80101510: 89 54 24 04 mov %edx,0x4(%esp) 80101514: 89 04 24 mov %eax,(%esp) 80101517: e8 8a ec ff ff call 801001a6 <bread> 8010151c: 89 45 f4 mov %eax,-0xc(%ebp) bi = b % BPB; 8010151f: 8b 45 0c mov 0xc(%ebp),%eax 80101522: 25 ff 0f 00 00 and $0xfff,%eax 80101527: 89 45 f0 mov %eax,-0x10(%ebp) m = 1 << (bi % 8); 8010152a: 8b 45 f0 mov -0x10(%ebp),%eax 8010152d: 99 cltd 8010152e: c1 ea 1d shr $0x1d,%edx 80101531: 01 d0 add %edx,%eax 80101533: 83 e0 07 and $0x7,%eax 80101536: 29 d0 sub %edx,%eax 80101538: ba 01 00 00 00 mov $0x1,%edx 8010153d: 89 c1 mov %eax,%ecx 8010153f: d3 e2 shl %cl,%edx 80101541: 89 d0 mov %edx,%eax 80101543: 89 45 ec mov %eax,-0x14(%ebp) if((bp->data[bi/8] & m) == 0) 80101546: 8b 45 f0 mov -0x10(%ebp),%eax 80101549: 8d 50 07 lea 0x7(%eax),%edx 8010154c: 85 c0 test %eax,%eax 8010154e: 0f 48 c2 cmovs %edx,%eax 80101551: c1 f8 03 sar $0x3,%eax 80101554: 8b 55 f4 mov -0xc(%ebp),%edx 80101557: 0f b6 44 02 18 movzbl 0x18(%edx,%eax,1),%eax 8010155c: 0f b6 c0 movzbl %al,%eax 8010155f: 23 45 ec and -0x14(%ebp),%eax 80101562: 85 c0 test %eax,%eax 80101564: 75 0c jne 80101572 <bfree+0x8d> panic("freeing free block"); 80101566: c7 04 24 1a 89 10 80 movl $0x8010891a,(%esp) 8010156d: e8 c8 ef ff ff call 8010053a <panic> bp->data[bi/8] &= ~m; 80101572: 8b 45 f0 mov -0x10(%ebp),%eax 80101575: 8d 50 07 lea 0x7(%eax),%edx 80101578: 85 c0 test %eax,%eax 8010157a: 0f 48 c2 cmovs %edx,%eax 8010157d: c1 f8 03 sar $0x3,%eax 80101580: 8b 55 f4 mov -0xc(%ebp),%edx 80101583: 0f b6 54 02 18 movzbl 0x18(%edx,%eax,1),%edx 80101588: 8b 4d ec mov -0x14(%ebp),%ecx 8010158b: f7 d1 not %ecx 8010158d: 21 ca and %ecx,%edx 8010158f: 89 d1 mov %edx,%ecx 80101591: 8b 55 f4 mov -0xc(%ebp),%edx 80101594: 88 4c 02 18 mov %cl,0x18(%edx,%eax,1) log_write(bp); 80101598: 8b 45 f4 mov -0xc(%ebp),%eax 8010159b: 89 04 24 mov %eax,(%esp) 8010159e: e8 30 21 00 00 call 801036d3 <log_write> brelse(bp); 801015a3: 8b 45 f4 mov -0xc(%ebp),%eax 801015a6: 89 04 24 mov %eax,(%esp) 801015a9: e8 69 ec ff ff call 80100217 <brelse> } 801015ae: c9 leave 801015af: c3 ret 801015b0 <iinit>: struct inode inode[NINODE]; } icache; void iinit(int dev) { 801015b0: 55 push %ebp 801015b1: 89 e5 mov %esp,%ebp 801015b3: 57 push %edi 801015b4: 56 push %esi 801015b5: 53 push %ebx 801015b6: 83 ec 3c sub $0x3c,%esp initlock(&icache.lock, "icache"); 801015b9: c7 44 24 04 2d 89 10 movl $0x8010892d,0x4(%esp) 801015c0: 80 801015c1: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 801015c8: e8 d1 3b 00 00 call 8010519e <initlock> readsb(dev, &sb); 801015cd: c7 44 24 04 20 12 11 movl $0x80111220,0x4(%esp) 801015d4: 80 801015d5: 8b 45 08 mov 0x8(%ebp),%eax 801015d8: 89 04 24 mov %eax,(%esp) 801015db: e8 30 fd ff ff call 80101310 <readsb> cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d inodestart %d bmap start %d\n", sb.size, 801015e0: a1 38 12 11 80 mov 0x80111238,%eax 801015e5: 8b 3d 34 12 11 80 mov 0x80111234,%edi 801015eb: 8b 35 30 12 11 80 mov 0x80111230,%esi 801015f1: 8b 1d 2c 12 11 80 mov 0x8011122c,%ebx 801015f7: 8b 0d 28 12 11 80 mov 0x80111228,%ecx 801015fd: 8b 15 24 12 11 80 mov 0x80111224,%edx 80101603: 89 55 e4 mov %edx,-0x1c(%ebp) 80101606: 8b 15 20 12 11 80 mov 0x80111220,%edx 8010160c: 89 44 24 1c mov %eax,0x1c(%esp) 80101610: 89 7c 24 18 mov %edi,0x18(%esp) 80101614: 89 74 24 14 mov %esi,0x14(%esp) 80101618: 89 5c 24 10 mov %ebx,0x10(%esp) 8010161c: 89 4c 24 0c mov %ecx,0xc(%esp) 80101620: 8b 45 e4 mov -0x1c(%ebp),%eax 80101623: 89 44 24 08 mov %eax,0x8(%esp) 80101627: 89 d0 mov %edx,%eax 80101629: 89 44 24 04 mov %eax,0x4(%esp) 8010162d: c7 04 24 34 89 10 80 movl $0x80108934,(%esp) 80101634: e8 67 ed ff ff call 801003a0 <cprintf> sb.nblocks, sb.ninodes, sb.nlog, sb.logstart, sb.inodestart, sb.bmapstart); } 80101639: 83 c4 3c add $0x3c,%esp 8010163c: 5b pop %ebx 8010163d: 5e pop %esi 8010163e: 5f pop %edi 8010163f: 5d pop %ebp 80101640: c3 ret 80101641 <ialloc>: //PAGEBREAK! // Allocate a new inode with the given type on device dev. // A free inode has a type of zero. struct inode* ialloc(uint dev, short type) { 80101641: 55 push %ebp 80101642: 89 e5 mov %esp,%ebp 80101644: 83 ec 28 sub $0x28,%esp 80101647: 8b 45 0c mov 0xc(%ebp),%eax 8010164a: 66 89 45 e4 mov %ax,-0x1c(%ebp) int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 8010164e: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) 80101655: e9 9e 00 00 00 jmp 801016f8 <ialloc+0xb7> bp = bread(dev, IBLOCK(inum, sb)); 8010165a: 8b 45 f4 mov -0xc(%ebp),%eax 8010165d: c1 e8 03 shr $0x3,%eax 80101660: 89 c2 mov %eax,%edx 80101662: a1 34 12 11 80 mov 0x80111234,%eax 80101667: 01 d0 add %edx,%eax 80101669: 89 44 24 04 mov %eax,0x4(%esp) 8010166d: 8b 45 08 mov 0x8(%ebp),%eax 80101670: 89 04 24 mov %eax,(%esp) 80101673: e8 2e eb ff ff call 801001a6 <bread> 80101678: 89 45 f0 mov %eax,-0x10(%ebp) dip = (struct dinode*)bp->data + inum%IPB; 8010167b: 8b 45 f0 mov -0x10(%ebp),%eax 8010167e: 8d 50 18 lea 0x18(%eax),%edx 80101681: 8b 45 f4 mov -0xc(%ebp),%eax 80101684: 83 e0 07 and $0x7,%eax 80101687: c1 e0 06 shl $0x6,%eax 8010168a: 01 d0 add %edx,%eax 8010168c: 89 45 ec mov %eax,-0x14(%ebp) if(dip->type == 0){ // a free inode 8010168f: 8b 45 ec mov -0x14(%ebp),%eax 80101692: 0f b7 00 movzwl (%eax),%eax 80101695: 66 85 c0 test %ax,%ax 80101698: 75 4f jne 801016e9 <ialloc+0xa8> memset(dip, 0, sizeof(*dip)); 8010169a: c7 44 24 08 40 00 00 movl $0x40,0x8(%esp) 801016a1: 00 801016a2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801016a9: 00 801016aa: 8b 45 ec mov -0x14(%ebp),%eax 801016ad: 89 04 24 mov %eax,(%esp) 801016b0: e8 61 3d 00 00 call 80105416 <memset> dip->type = type; 801016b5: 8b 45 ec mov -0x14(%ebp),%eax 801016b8: 0f b7 55 e4 movzwl -0x1c(%ebp),%edx 801016bc: 66 89 10 mov %dx,(%eax) log_write(bp); // mark it allocated on the disk 801016bf: 8b 45 f0 mov -0x10(%ebp),%eax 801016c2: 89 04 24 mov %eax,(%esp) 801016c5: e8 09 20 00 00 call 801036d3 <log_write> brelse(bp); 801016ca: 8b 45 f0 mov -0x10(%ebp),%eax 801016cd: 89 04 24 mov %eax,(%esp) 801016d0: e8 42 eb ff ff call 80100217 <brelse> return iget(dev, inum); 801016d5: 8b 45 f4 mov -0xc(%ebp),%eax 801016d8: 89 44 24 04 mov %eax,0x4(%esp) 801016dc: 8b 45 08 mov 0x8(%ebp),%eax 801016df: 89 04 24 mov %eax,(%esp) 801016e2: e8 ed 00 00 00 call 801017d4 <iget> 801016e7: eb 2b jmp 80101714 <ialloc+0xd3> } brelse(bp); 801016e9: 8b 45 f0 mov -0x10(%ebp),%eax 801016ec: 89 04 24 mov %eax,(%esp) 801016ef: e8 23 eb ff ff call 80100217 <brelse> { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 801016f4: 83 45 f4 01 addl $0x1,-0xc(%ebp) 801016f8: 8b 55 f4 mov -0xc(%ebp),%edx 801016fb: a1 28 12 11 80 mov 0x80111228,%eax 80101700: 39 c2 cmp %eax,%edx 80101702: 0f 82 52 ff ff ff jb 8010165a <ialloc+0x19> brelse(bp); return iget(dev, inum); } brelse(bp); } panic("ialloc: no inodes"); 80101708: c7 04 24 87 89 10 80 movl $0x80108987,(%esp) 8010170f: e8 26 ee ff ff call 8010053a <panic> } 80101714: c9 leave 80101715: c3 ret 80101716 <iupdate>: // Copy a modified in-memory inode to disk. void iupdate(struct inode *ip) { 80101716: 55 push %ebp 80101717: 89 e5 mov %esp,%ebp 80101719: 83 ec 28 sub $0x28,%esp struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 8010171c: 8b 45 08 mov 0x8(%ebp),%eax 8010171f: 8b 40 04 mov 0x4(%eax),%eax 80101722: c1 e8 03 shr $0x3,%eax 80101725: 89 c2 mov %eax,%edx 80101727: a1 34 12 11 80 mov 0x80111234,%eax 8010172c: 01 c2 add %eax,%edx 8010172e: 8b 45 08 mov 0x8(%ebp),%eax 80101731: 8b 00 mov (%eax),%eax 80101733: 89 54 24 04 mov %edx,0x4(%esp) 80101737: 89 04 24 mov %eax,(%esp) 8010173a: e8 67 ea ff ff call 801001a6 <bread> 8010173f: 89 45 f4 mov %eax,-0xc(%ebp) dip = (struct dinode*)bp->data + ip->inum%IPB; 80101742: 8b 45 f4 mov -0xc(%ebp),%eax 80101745: 8d 50 18 lea 0x18(%eax),%edx 80101748: 8b 45 08 mov 0x8(%ebp),%eax 8010174b: 8b 40 04 mov 0x4(%eax),%eax 8010174e: 83 e0 07 and $0x7,%eax 80101751: c1 e0 06 shl $0x6,%eax 80101754: 01 d0 add %edx,%eax 80101756: 89 45 f0 mov %eax,-0x10(%ebp) dip->type = ip->type; 80101759: 8b 45 08 mov 0x8(%ebp),%eax 8010175c: 0f b7 50 10 movzwl 0x10(%eax),%edx 80101760: 8b 45 f0 mov -0x10(%ebp),%eax 80101763: 66 89 10 mov %dx,(%eax) dip->major = ip->major; 80101766: 8b 45 08 mov 0x8(%ebp),%eax 80101769: 0f b7 50 12 movzwl 0x12(%eax),%edx 8010176d: 8b 45 f0 mov -0x10(%ebp),%eax 80101770: 66 89 50 02 mov %dx,0x2(%eax) dip->minor = ip->minor; 80101774: 8b 45 08 mov 0x8(%ebp),%eax 80101777: 0f b7 50 14 movzwl 0x14(%eax),%edx 8010177b: 8b 45 f0 mov -0x10(%ebp),%eax 8010177e: 66 89 50 04 mov %dx,0x4(%eax) dip->nlink = ip->nlink; 80101782: 8b 45 08 mov 0x8(%ebp),%eax 80101785: 0f b7 50 16 movzwl 0x16(%eax),%edx 80101789: 8b 45 f0 mov -0x10(%ebp),%eax 8010178c: 66 89 50 06 mov %dx,0x6(%eax) dip->size = ip->size; 80101790: 8b 45 08 mov 0x8(%ebp),%eax 80101793: 8b 50 18 mov 0x18(%eax),%edx 80101796: 8b 45 f0 mov -0x10(%ebp),%eax 80101799: 89 50 08 mov %edx,0x8(%eax) memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010179c: 8b 45 08 mov 0x8(%ebp),%eax 8010179f: 8d 50 1c lea 0x1c(%eax),%edx 801017a2: 8b 45 f0 mov -0x10(%ebp),%eax 801017a5: 83 c0 0c add $0xc,%eax 801017a8: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 801017af: 00 801017b0: 89 54 24 04 mov %edx,0x4(%esp) 801017b4: 89 04 24 mov %eax,(%esp) 801017b7: e8 29 3d 00 00 call 801054e5 <memmove> log_write(bp); 801017bc: 8b 45 f4 mov -0xc(%ebp),%eax 801017bf: 89 04 24 mov %eax,(%esp) 801017c2: e8 0c 1f 00 00 call 801036d3 <log_write> brelse(bp); 801017c7: 8b 45 f4 mov -0xc(%ebp),%eax 801017ca: 89 04 24 mov %eax,(%esp) 801017cd: e8 45 ea ff ff call 80100217 <brelse> } 801017d2: c9 leave 801017d3: c3 ret 801017d4 <iget>: // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 801017d4: 55 push %ebp 801017d5: 89 e5 mov %esp,%ebp 801017d7: 83 ec 28 sub $0x28,%esp struct inode *ip, *empty; acquire(&icache.lock); 801017da: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 801017e1: e8 d9 39 00 00 call 801051bf <acquire> // Is the inode already cached? empty = 0; 801017e6: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 801017ed: c7 45 f4 74 12 11 80 movl $0x80111274,-0xc(%ebp) 801017f4: eb 59 jmp 8010184f <iget+0x7b> if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ 801017f6: 8b 45 f4 mov -0xc(%ebp),%eax 801017f9: 8b 40 08 mov 0x8(%eax),%eax 801017fc: 85 c0 test %eax,%eax 801017fe: 7e 35 jle 80101835 <iget+0x61> 80101800: 8b 45 f4 mov -0xc(%ebp),%eax 80101803: 8b 00 mov (%eax),%eax 80101805: 3b 45 08 cmp 0x8(%ebp),%eax 80101808: 75 2b jne 80101835 <iget+0x61> 8010180a: 8b 45 f4 mov -0xc(%ebp),%eax 8010180d: 8b 40 04 mov 0x4(%eax),%eax 80101810: 3b 45 0c cmp 0xc(%ebp),%eax 80101813: 75 20 jne 80101835 <iget+0x61> ip->ref++; 80101815: 8b 45 f4 mov -0xc(%ebp),%eax 80101818: 8b 40 08 mov 0x8(%eax),%eax 8010181b: 8d 50 01 lea 0x1(%eax),%edx 8010181e: 8b 45 f4 mov -0xc(%ebp),%eax 80101821: 89 50 08 mov %edx,0x8(%eax) release(&icache.lock); 80101824: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 8010182b: e8 f1 39 00 00 call 80105221 <release> return ip; 80101830: 8b 45 f4 mov -0xc(%ebp),%eax 80101833: eb 6f jmp 801018a4 <iget+0xd0> } if(empty == 0 && ip->ref == 0) // Remember empty slot. 80101835: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80101839: 75 10 jne 8010184b <iget+0x77> 8010183b: 8b 45 f4 mov -0xc(%ebp),%eax 8010183e: 8b 40 08 mov 0x8(%eax),%eax 80101841: 85 c0 test %eax,%eax 80101843: 75 06 jne 8010184b <iget+0x77> empty = ip; 80101845: 8b 45 f4 mov -0xc(%ebp),%eax 80101848: 89 45 f0 mov %eax,-0x10(%ebp) acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010184b: 83 45 f4 50 addl $0x50,-0xc(%ebp) 8010184f: 81 7d f4 14 22 11 80 cmpl $0x80112214,-0xc(%ebp) 80101856: 72 9e jb 801017f6 <iget+0x22> if(empty == 0 && ip->ref == 0) // Remember empty slot. empty = ip; } // Recycle an inode cache entry. if(empty == 0) 80101858: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8010185c: 75 0c jne 8010186a <iget+0x96> panic("iget: no inodes"); 8010185e: c7 04 24 99 89 10 80 movl $0x80108999,(%esp) 80101865: e8 d0 ec ff ff call 8010053a <panic> ip = empty; 8010186a: 8b 45 f0 mov -0x10(%ebp),%eax 8010186d: 89 45 f4 mov %eax,-0xc(%ebp) ip->dev = dev; 80101870: 8b 45 f4 mov -0xc(%ebp),%eax 80101873: 8b 55 08 mov 0x8(%ebp),%edx 80101876: 89 10 mov %edx,(%eax) ip->inum = inum; 80101878: 8b 45 f4 mov -0xc(%ebp),%eax 8010187b: 8b 55 0c mov 0xc(%ebp),%edx 8010187e: 89 50 04 mov %edx,0x4(%eax) ip->ref = 1; 80101881: 8b 45 f4 mov -0xc(%ebp),%eax 80101884: c7 40 08 01 00 00 00 movl $0x1,0x8(%eax) ip->flags = 0; 8010188b: 8b 45 f4 mov -0xc(%ebp),%eax 8010188e: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) release(&icache.lock); 80101895: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 8010189c: e8 80 39 00 00 call 80105221 <release> return ip; 801018a1: 8b 45 f4 mov -0xc(%ebp),%eax } 801018a4: c9 leave 801018a5: c3 ret 801018a6 <idup>: // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { 801018a6: 55 push %ebp 801018a7: 89 e5 mov %esp,%ebp 801018a9: 83 ec 18 sub $0x18,%esp acquire(&icache.lock); 801018ac: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 801018b3: e8 07 39 00 00 call 801051bf <acquire> ip->ref++; 801018b8: 8b 45 08 mov 0x8(%ebp),%eax 801018bb: 8b 40 08 mov 0x8(%eax),%eax 801018be: 8d 50 01 lea 0x1(%eax),%edx 801018c1: 8b 45 08 mov 0x8(%ebp),%eax 801018c4: 89 50 08 mov %edx,0x8(%eax) release(&icache.lock); 801018c7: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 801018ce: e8 4e 39 00 00 call 80105221 <release> return ip; 801018d3: 8b 45 08 mov 0x8(%ebp),%eax } 801018d6: c9 leave 801018d7: c3 ret 801018d8 <ilock>: // Lock the given inode. // Reads the inode from disk if necessary. void ilock(struct inode *ip) { 801018d8: 55 push %ebp 801018d9: 89 e5 mov %esp,%ebp 801018db: 83 ec 28 sub $0x28,%esp struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) 801018de: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 801018e2: 74 0a je 801018ee <ilock+0x16> 801018e4: 8b 45 08 mov 0x8(%ebp),%eax 801018e7: 8b 40 08 mov 0x8(%eax),%eax 801018ea: 85 c0 test %eax,%eax 801018ec: 7f 0c jg 801018fa <ilock+0x22> panic("ilock"); 801018ee: c7 04 24 a9 89 10 80 movl $0x801089a9,(%esp) 801018f5: e8 40 ec ff ff call 8010053a <panic> acquire(&icache.lock); 801018fa: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 80101901: e8 b9 38 00 00 call 801051bf <acquire> while(ip->flags & I_BUSY) 80101906: eb 13 jmp 8010191b <ilock+0x43> sleep(ip, &icache.lock); 80101908: c7 44 24 04 40 12 11 movl $0x80111240,0x4(%esp) 8010190f: 80 80101910: 8b 45 08 mov 0x8(%ebp),%eax 80101913: 89 04 24 mov %eax,(%esp) 80101916: e8 d6 32 00 00 call 80104bf1 <sleep> if(ip == 0 || ip->ref < 1) panic("ilock"); acquire(&icache.lock); while(ip->flags & I_BUSY) 8010191b: 8b 45 08 mov 0x8(%ebp),%eax 8010191e: 8b 40 0c mov 0xc(%eax),%eax 80101921: 83 e0 01 and $0x1,%eax 80101924: 85 c0 test %eax,%eax 80101926: 75 e0 jne 80101908 <ilock+0x30> sleep(ip, &icache.lock); ip->flags |= I_BUSY; 80101928: 8b 45 08 mov 0x8(%ebp),%eax 8010192b: 8b 40 0c mov 0xc(%eax),%eax 8010192e: 83 c8 01 or $0x1,%eax 80101931: 89 c2 mov %eax,%edx 80101933: 8b 45 08 mov 0x8(%ebp),%eax 80101936: 89 50 0c mov %edx,0xc(%eax) release(&icache.lock); 80101939: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 80101940: e8 dc 38 00 00 call 80105221 <release> if(!(ip->flags & I_VALID)){ 80101945: 8b 45 08 mov 0x8(%ebp),%eax 80101948: 8b 40 0c mov 0xc(%eax),%eax 8010194b: 83 e0 02 and $0x2,%eax 8010194e: 85 c0 test %eax,%eax 80101950: 0f 85 d4 00 00 00 jne 80101a2a <ilock+0x152> bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101956: 8b 45 08 mov 0x8(%ebp),%eax 80101959: 8b 40 04 mov 0x4(%eax),%eax 8010195c: c1 e8 03 shr $0x3,%eax 8010195f: 89 c2 mov %eax,%edx 80101961: a1 34 12 11 80 mov 0x80111234,%eax 80101966: 01 c2 add %eax,%edx 80101968: 8b 45 08 mov 0x8(%ebp),%eax 8010196b: 8b 00 mov (%eax),%eax 8010196d: 89 54 24 04 mov %edx,0x4(%esp) 80101971: 89 04 24 mov %eax,(%esp) 80101974: e8 2d e8 ff ff call 801001a6 <bread> 80101979: 89 45 f4 mov %eax,-0xc(%ebp) dip = (struct dinode*)bp->data + ip->inum%IPB; 8010197c: 8b 45 f4 mov -0xc(%ebp),%eax 8010197f: 8d 50 18 lea 0x18(%eax),%edx 80101982: 8b 45 08 mov 0x8(%ebp),%eax 80101985: 8b 40 04 mov 0x4(%eax),%eax 80101988: 83 e0 07 and $0x7,%eax 8010198b: c1 e0 06 shl $0x6,%eax 8010198e: 01 d0 add %edx,%eax 80101990: 89 45 f0 mov %eax,-0x10(%ebp) ip->type = dip->type; 80101993: 8b 45 f0 mov -0x10(%ebp),%eax 80101996: 0f b7 10 movzwl (%eax),%edx 80101999: 8b 45 08 mov 0x8(%ebp),%eax 8010199c: 66 89 50 10 mov %dx,0x10(%eax) ip->major = dip->major; 801019a0: 8b 45 f0 mov -0x10(%ebp),%eax 801019a3: 0f b7 50 02 movzwl 0x2(%eax),%edx 801019a7: 8b 45 08 mov 0x8(%ebp),%eax 801019aa: 66 89 50 12 mov %dx,0x12(%eax) ip->minor = dip->minor; 801019ae: 8b 45 f0 mov -0x10(%ebp),%eax 801019b1: 0f b7 50 04 movzwl 0x4(%eax),%edx 801019b5: 8b 45 08 mov 0x8(%ebp),%eax 801019b8: 66 89 50 14 mov %dx,0x14(%eax) ip->nlink = dip->nlink; 801019bc: 8b 45 f0 mov -0x10(%ebp),%eax 801019bf: 0f b7 50 06 movzwl 0x6(%eax),%edx 801019c3: 8b 45 08 mov 0x8(%ebp),%eax 801019c6: 66 89 50 16 mov %dx,0x16(%eax) ip->size = dip->size; 801019ca: 8b 45 f0 mov -0x10(%ebp),%eax 801019cd: 8b 50 08 mov 0x8(%eax),%edx 801019d0: 8b 45 08 mov 0x8(%ebp),%eax 801019d3: 89 50 18 mov %edx,0x18(%eax) memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 801019d6: 8b 45 f0 mov -0x10(%ebp),%eax 801019d9: 8d 50 0c lea 0xc(%eax),%edx 801019dc: 8b 45 08 mov 0x8(%ebp),%eax 801019df: 83 c0 1c add $0x1c,%eax 801019e2: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 801019e9: 00 801019ea: 89 54 24 04 mov %edx,0x4(%esp) 801019ee: 89 04 24 mov %eax,(%esp) 801019f1: e8 ef 3a 00 00 call 801054e5 <memmove> brelse(bp); 801019f6: 8b 45 f4 mov -0xc(%ebp),%eax 801019f9: 89 04 24 mov %eax,(%esp) 801019fc: e8 16 e8 ff ff call 80100217 <brelse> ip->flags |= I_VALID; 80101a01: 8b 45 08 mov 0x8(%ebp),%eax 80101a04: 8b 40 0c mov 0xc(%eax),%eax 80101a07: 83 c8 02 or $0x2,%eax 80101a0a: 89 c2 mov %eax,%edx 80101a0c: 8b 45 08 mov 0x8(%ebp),%eax 80101a0f: 89 50 0c mov %edx,0xc(%eax) if(ip->type == 0) 80101a12: 8b 45 08 mov 0x8(%ebp),%eax 80101a15: 0f b7 40 10 movzwl 0x10(%eax),%eax 80101a19: 66 85 c0 test %ax,%ax 80101a1c: 75 0c jne 80101a2a <ilock+0x152> panic("ilock: no type"); 80101a1e: c7 04 24 af 89 10 80 movl $0x801089af,(%esp) 80101a25: e8 10 eb ff ff call 8010053a <panic> } } 80101a2a: c9 leave 80101a2b: c3 ret 80101a2c <iunlock>: // Unlock the given inode. void iunlock(struct inode *ip) { 80101a2c: 55 push %ebp 80101a2d: 89 e5 mov %esp,%ebp 80101a2f: 83 ec 18 sub $0x18,%esp if(ip == 0 || !(ip->flags & I_BUSY) || ip->ref < 1) 80101a32: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 80101a36: 74 17 je 80101a4f <iunlock+0x23> 80101a38: 8b 45 08 mov 0x8(%ebp),%eax 80101a3b: 8b 40 0c mov 0xc(%eax),%eax 80101a3e: 83 e0 01 and $0x1,%eax 80101a41: 85 c0 test %eax,%eax 80101a43: 74 0a je 80101a4f <iunlock+0x23> 80101a45: 8b 45 08 mov 0x8(%ebp),%eax 80101a48: 8b 40 08 mov 0x8(%eax),%eax 80101a4b: 85 c0 test %eax,%eax 80101a4d: 7f 0c jg 80101a5b <iunlock+0x2f> panic("iunlock"); 80101a4f: c7 04 24 be 89 10 80 movl $0x801089be,(%esp) 80101a56: e8 df ea ff ff call 8010053a <panic> acquire(&icache.lock); 80101a5b: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 80101a62: e8 58 37 00 00 call 801051bf <acquire> ip->flags &= ~I_BUSY; 80101a67: 8b 45 08 mov 0x8(%ebp),%eax 80101a6a: 8b 40 0c mov 0xc(%eax),%eax 80101a6d: 83 e0 fe and $0xfffffffe,%eax 80101a70: 89 c2 mov %eax,%edx 80101a72: 8b 45 08 mov 0x8(%ebp),%eax 80101a75: 89 50 0c mov %edx,0xc(%eax) wakeup(ip); 80101a78: 8b 45 08 mov 0x8(%ebp),%eax 80101a7b: 89 04 24 mov %eax,(%esp) 80101a7e: e8 47 32 00 00 call 80104cca <wakeup> release(&icache.lock); 80101a83: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 80101a8a: e8 92 37 00 00 call 80105221 <release> } 80101a8f: c9 leave 80101a90: c3 ret 80101a91 <iput>: // to it, free the inode (and its content) on disk. // All calls to iput() must be inside a transaction in // case it has to free the inode. void iput(struct inode *ip) { 80101a91: 55 push %ebp 80101a92: 89 e5 mov %esp,%ebp 80101a94: 83 ec 18 sub $0x18,%esp acquire(&icache.lock); 80101a97: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 80101a9e: e8 1c 37 00 00 call 801051bf <acquire> if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){ 80101aa3: 8b 45 08 mov 0x8(%ebp),%eax 80101aa6: 8b 40 08 mov 0x8(%eax),%eax 80101aa9: 83 f8 01 cmp $0x1,%eax 80101aac: 0f 85 93 00 00 00 jne 80101b45 <iput+0xb4> 80101ab2: 8b 45 08 mov 0x8(%ebp),%eax 80101ab5: 8b 40 0c mov 0xc(%eax),%eax 80101ab8: 83 e0 02 and $0x2,%eax 80101abb: 85 c0 test %eax,%eax 80101abd: 0f 84 82 00 00 00 je 80101b45 <iput+0xb4> 80101ac3: 8b 45 08 mov 0x8(%ebp),%eax 80101ac6: 0f b7 40 16 movzwl 0x16(%eax),%eax 80101aca: 66 85 c0 test %ax,%ax 80101acd: 75 76 jne 80101b45 <iput+0xb4> // inode has no links and no other references: truncate and free. if(ip->flags & I_BUSY) 80101acf: 8b 45 08 mov 0x8(%ebp),%eax 80101ad2: 8b 40 0c mov 0xc(%eax),%eax 80101ad5: 83 e0 01 and $0x1,%eax 80101ad8: 85 c0 test %eax,%eax 80101ada: 74 0c je 80101ae8 <iput+0x57> panic("iput busy"); 80101adc: c7 04 24 c6 89 10 80 movl $0x801089c6,(%esp) 80101ae3: e8 52 ea ff ff call 8010053a <panic> ip->flags |= I_BUSY; 80101ae8: 8b 45 08 mov 0x8(%ebp),%eax 80101aeb: 8b 40 0c mov 0xc(%eax),%eax 80101aee: 83 c8 01 or $0x1,%eax 80101af1: 89 c2 mov %eax,%edx 80101af3: 8b 45 08 mov 0x8(%ebp),%eax 80101af6: 89 50 0c mov %edx,0xc(%eax) release(&icache.lock); 80101af9: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 80101b00: e8 1c 37 00 00 call 80105221 <release> itrunc(ip); 80101b05: 8b 45 08 mov 0x8(%ebp),%eax 80101b08: 89 04 24 mov %eax,(%esp) 80101b0b: e8 7d 01 00 00 call 80101c8d <itrunc> ip->type = 0; 80101b10: 8b 45 08 mov 0x8(%ebp),%eax 80101b13: 66 c7 40 10 00 00 movw $0x0,0x10(%eax) iupdate(ip); 80101b19: 8b 45 08 mov 0x8(%ebp),%eax 80101b1c: 89 04 24 mov %eax,(%esp) 80101b1f: e8 f2 fb ff ff call 80101716 <iupdate> acquire(&icache.lock); 80101b24: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 80101b2b: e8 8f 36 00 00 call 801051bf <acquire> ip->flags = 0; 80101b30: 8b 45 08 mov 0x8(%ebp),%eax 80101b33: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) wakeup(ip); 80101b3a: 8b 45 08 mov 0x8(%ebp),%eax 80101b3d: 89 04 24 mov %eax,(%esp) 80101b40: e8 85 31 00 00 call 80104cca <wakeup> } ip->ref--; 80101b45: 8b 45 08 mov 0x8(%ebp),%eax 80101b48: 8b 40 08 mov 0x8(%eax),%eax 80101b4b: 8d 50 ff lea -0x1(%eax),%edx 80101b4e: 8b 45 08 mov 0x8(%ebp),%eax 80101b51: 89 50 08 mov %edx,0x8(%eax) release(&icache.lock); 80101b54: c7 04 24 40 12 11 80 movl $0x80111240,(%esp) 80101b5b: e8 c1 36 00 00 call 80105221 <release> } 80101b60: c9 leave 80101b61: c3 ret 80101b62 <iunlockput>: // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { 80101b62: 55 push %ebp 80101b63: 89 e5 mov %esp,%ebp 80101b65: 83 ec 18 sub $0x18,%esp iunlock(ip); 80101b68: 8b 45 08 mov 0x8(%ebp),%eax 80101b6b: 89 04 24 mov %eax,(%esp) 80101b6e: e8 b9 fe ff ff call 80101a2c <iunlock> iput(ip); 80101b73: 8b 45 08 mov 0x8(%ebp),%eax 80101b76: 89 04 24 mov %eax,(%esp) 80101b79: e8 13 ff ff ff call 80101a91 <iput> } 80101b7e: c9 leave 80101b7f: c3 ret 80101b80 <bmap>: // Return the disk block address of the nth block in inode ip. // If there is no such block, bmap allocates one. static uint bmap(struct inode *ip, uint bn) { 80101b80: 55 push %ebp 80101b81: 89 e5 mov %esp,%ebp 80101b83: 53 push %ebx 80101b84: 83 ec 24 sub $0x24,%esp uint addr, *a; struct buf *bp; if(bn < NDIRECT){ 80101b87: 83 7d 0c 0b cmpl $0xb,0xc(%ebp) 80101b8b: 77 3e ja 80101bcb <bmap+0x4b> if((addr = ip->addrs[bn]) == 0) 80101b8d: 8b 45 08 mov 0x8(%ebp),%eax 80101b90: 8b 55 0c mov 0xc(%ebp),%edx 80101b93: 83 c2 04 add $0x4,%edx 80101b96: 8b 44 90 0c mov 0xc(%eax,%edx,4),%eax 80101b9a: 89 45 f4 mov %eax,-0xc(%ebp) 80101b9d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80101ba1: 75 20 jne 80101bc3 <bmap+0x43> ip->addrs[bn] = addr = balloc(ip->dev); 80101ba3: 8b 45 08 mov 0x8(%ebp),%eax 80101ba6: 8b 00 mov (%eax),%eax 80101ba8: 89 04 24 mov %eax,(%esp) 80101bab: e8 f7 f7 ff ff call 801013a7 <balloc> 80101bb0: 89 45 f4 mov %eax,-0xc(%ebp) 80101bb3: 8b 45 08 mov 0x8(%ebp),%eax 80101bb6: 8b 55 0c mov 0xc(%ebp),%edx 80101bb9: 8d 4a 04 lea 0x4(%edx),%ecx 80101bbc: 8b 55 f4 mov -0xc(%ebp),%edx 80101bbf: 89 54 88 0c mov %edx,0xc(%eax,%ecx,4) return addr; 80101bc3: 8b 45 f4 mov -0xc(%ebp),%eax 80101bc6: e9 bc 00 00 00 jmp 80101c87 <bmap+0x107> } bn -= NDIRECT; 80101bcb: 83 6d 0c 0c subl $0xc,0xc(%ebp) if(bn < NINDIRECT){ 80101bcf: 83 7d 0c 7f cmpl $0x7f,0xc(%ebp) 80101bd3: 0f 87 a2 00 00 00 ja 80101c7b <bmap+0xfb> // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) 80101bd9: 8b 45 08 mov 0x8(%ebp),%eax 80101bdc: 8b 40 4c mov 0x4c(%eax),%eax 80101bdf: 89 45 f4 mov %eax,-0xc(%ebp) 80101be2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80101be6: 75 19 jne 80101c01 <bmap+0x81> ip->addrs[NDIRECT] = addr = balloc(ip->dev); 80101be8: 8b 45 08 mov 0x8(%ebp),%eax 80101beb: 8b 00 mov (%eax),%eax 80101bed: 89 04 24 mov %eax,(%esp) 80101bf0: e8 b2 f7 ff ff call 801013a7 <balloc> 80101bf5: 89 45 f4 mov %eax,-0xc(%ebp) 80101bf8: 8b 45 08 mov 0x8(%ebp),%eax 80101bfb: 8b 55 f4 mov -0xc(%ebp),%edx 80101bfe: 89 50 4c mov %edx,0x4c(%eax) bp = bread(ip->dev, addr); 80101c01: 8b 45 08 mov 0x8(%ebp),%eax 80101c04: 8b 00 mov (%eax),%eax 80101c06: 8b 55 f4 mov -0xc(%ebp),%edx 80101c09: 89 54 24 04 mov %edx,0x4(%esp) 80101c0d: 89 04 24 mov %eax,(%esp) 80101c10: e8 91 e5 ff ff call 801001a6 <bread> 80101c15: 89 45 f0 mov %eax,-0x10(%ebp) a = (uint*)bp->data; 80101c18: 8b 45 f0 mov -0x10(%ebp),%eax 80101c1b: 83 c0 18 add $0x18,%eax 80101c1e: 89 45 ec mov %eax,-0x14(%ebp) if((addr = a[bn]) == 0){ 80101c21: 8b 45 0c mov 0xc(%ebp),%eax 80101c24: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80101c2b: 8b 45 ec mov -0x14(%ebp),%eax 80101c2e: 01 d0 add %edx,%eax 80101c30: 8b 00 mov (%eax),%eax 80101c32: 89 45 f4 mov %eax,-0xc(%ebp) 80101c35: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80101c39: 75 30 jne 80101c6b <bmap+0xeb> a[bn] = addr = balloc(ip->dev); 80101c3b: 8b 45 0c mov 0xc(%ebp),%eax 80101c3e: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80101c45: 8b 45 ec mov -0x14(%ebp),%eax 80101c48: 8d 1c 02 lea (%edx,%eax,1),%ebx 80101c4b: 8b 45 08 mov 0x8(%ebp),%eax 80101c4e: 8b 00 mov (%eax),%eax 80101c50: 89 04 24 mov %eax,(%esp) 80101c53: e8 4f f7 ff ff call 801013a7 <balloc> 80101c58: 89 45 f4 mov %eax,-0xc(%ebp) 80101c5b: 8b 45 f4 mov -0xc(%ebp),%eax 80101c5e: 89 03 mov %eax,(%ebx) log_write(bp); 80101c60: 8b 45 f0 mov -0x10(%ebp),%eax 80101c63: 89 04 24 mov %eax,(%esp) 80101c66: e8 68 1a 00 00 call 801036d3 <log_write> } brelse(bp); 80101c6b: 8b 45 f0 mov -0x10(%ebp),%eax 80101c6e: 89 04 24 mov %eax,(%esp) 80101c71: e8 a1 e5 ff ff call 80100217 <brelse> return addr; 80101c76: 8b 45 f4 mov -0xc(%ebp),%eax 80101c79: eb 0c jmp 80101c87 <bmap+0x107> } panic("bmap: out of range"); 80101c7b: c7 04 24 d0 89 10 80 movl $0x801089d0,(%esp) 80101c82: e8 b3 e8 ff ff call 8010053a <panic> } 80101c87: 83 c4 24 add $0x24,%esp 80101c8a: 5b pop %ebx 80101c8b: 5d pop %ebp 80101c8c: c3 ret 80101c8d <itrunc>: // to it (no directory entries referring to it) // and has no in-memory reference to it (is // not an open file or current directory). static void itrunc(struct inode *ip) { 80101c8d: 55 push %ebp 80101c8e: 89 e5 mov %esp,%ebp 80101c90: 83 ec 28 sub $0x28,%esp int i, j; struct buf *bp; uint *a; for(i = 0; i < NDIRECT; i++){ 80101c93: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80101c9a: eb 44 jmp 80101ce0 <itrunc+0x53> if(ip->addrs[i]){ 80101c9c: 8b 45 08 mov 0x8(%ebp),%eax 80101c9f: 8b 55 f4 mov -0xc(%ebp),%edx 80101ca2: 83 c2 04 add $0x4,%edx 80101ca5: 8b 44 90 0c mov 0xc(%eax,%edx,4),%eax 80101ca9: 85 c0 test %eax,%eax 80101cab: 74 2f je 80101cdc <itrunc+0x4f> bfree(ip->dev, ip->addrs[i]); 80101cad: 8b 45 08 mov 0x8(%ebp),%eax 80101cb0: 8b 55 f4 mov -0xc(%ebp),%edx 80101cb3: 83 c2 04 add $0x4,%edx 80101cb6: 8b 54 90 0c mov 0xc(%eax,%edx,4),%edx 80101cba: 8b 45 08 mov 0x8(%ebp),%eax 80101cbd: 8b 00 mov (%eax),%eax 80101cbf: 89 54 24 04 mov %edx,0x4(%esp) 80101cc3: 89 04 24 mov %eax,(%esp) 80101cc6: e8 1a f8 ff ff call 801014e5 <bfree> ip->addrs[i] = 0; 80101ccb: 8b 45 08 mov 0x8(%ebp),%eax 80101cce: 8b 55 f4 mov -0xc(%ebp),%edx 80101cd1: 83 c2 04 add $0x4,%edx 80101cd4: c7 44 90 0c 00 00 00 movl $0x0,0xc(%eax,%edx,4) 80101cdb: 00 { int i, j; struct buf *bp; uint *a; for(i = 0; i < NDIRECT; i++){ 80101cdc: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80101ce0: 83 7d f4 0b cmpl $0xb,-0xc(%ebp) 80101ce4: 7e b6 jle 80101c9c <itrunc+0xf> bfree(ip->dev, ip->addrs[i]); ip->addrs[i] = 0; } } if(ip->addrs[NDIRECT]){ 80101ce6: 8b 45 08 mov 0x8(%ebp),%eax 80101ce9: 8b 40 4c mov 0x4c(%eax),%eax 80101cec: 85 c0 test %eax,%eax 80101cee: 0f 84 9b 00 00 00 je 80101d8f <itrunc+0x102> bp = bread(ip->dev, ip->addrs[NDIRECT]); 80101cf4: 8b 45 08 mov 0x8(%ebp),%eax 80101cf7: 8b 50 4c mov 0x4c(%eax),%edx 80101cfa: 8b 45 08 mov 0x8(%ebp),%eax 80101cfd: 8b 00 mov (%eax),%eax 80101cff: 89 54 24 04 mov %edx,0x4(%esp) 80101d03: 89 04 24 mov %eax,(%esp) 80101d06: e8 9b e4 ff ff call 801001a6 <bread> 80101d0b: 89 45 ec mov %eax,-0x14(%ebp) a = (uint*)bp->data; 80101d0e: 8b 45 ec mov -0x14(%ebp),%eax 80101d11: 83 c0 18 add $0x18,%eax 80101d14: 89 45 e8 mov %eax,-0x18(%ebp) for(j = 0; j < NINDIRECT; j++){ 80101d17: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 80101d1e: eb 3b jmp 80101d5b <itrunc+0xce> if(a[j]) 80101d20: 8b 45 f0 mov -0x10(%ebp),%eax 80101d23: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80101d2a: 8b 45 e8 mov -0x18(%ebp),%eax 80101d2d: 01 d0 add %edx,%eax 80101d2f: 8b 00 mov (%eax),%eax 80101d31: 85 c0 test %eax,%eax 80101d33: 74 22 je 80101d57 <itrunc+0xca> bfree(ip->dev, a[j]); 80101d35: 8b 45 f0 mov -0x10(%ebp),%eax 80101d38: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80101d3f: 8b 45 e8 mov -0x18(%ebp),%eax 80101d42: 01 d0 add %edx,%eax 80101d44: 8b 10 mov (%eax),%edx 80101d46: 8b 45 08 mov 0x8(%ebp),%eax 80101d49: 8b 00 mov (%eax),%eax 80101d4b: 89 54 24 04 mov %edx,0x4(%esp) 80101d4f: 89 04 24 mov %eax,(%esp) 80101d52: e8 8e f7 ff ff call 801014e5 <bfree> } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); a = (uint*)bp->data; for(j = 0; j < NINDIRECT; j++){ 80101d57: 83 45 f0 01 addl $0x1,-0x10(%ebp) 80101d5b: 8b 45 f0 mov -0x10(%ebp),%eax 80101d5e: 83 f8 7f cmp $0x7f,%eax 80101d61: 76 bd jbe 80101d20 <itrunc+0x93> if(a[j]) bfree(ip->dev, a[j]); } brelse(bp); 80101d63: 8b 45 ec mov -0x14(%ebp),%eax 80101d66: 89 04 24 mov %eax,(%esp) 80101d69: e8 a9 e4 ff ff call 80100217 <brelse> bfree(ip->dev, ip->addrs[NDIRECT]); 80101d6e: 8b 45 08 mov 0x8(%ebp),%eax 80101d71: 8b 50 4c mov 0x4c(%eax),%edx 80101d74: 8b 45 08 mov 0x8(%ebp),%eax 80101d77: 8b 00 mov (%eax),%eax 80101d79: 89 54 24 04 mov %edx,0x4(%esp) 80101d7d: 89 04 24 mov %eax,(%esp) 80101d80: e8 60 f7 ff ff call 801014e5 <bfree> ip->addrs[NDIRECT] = 0; 80101d85: 8b 45 08 mov 0x8(%ebp),%eax 80101d88: c7 40 4c 00 00 00 00 movl $0x0,0x4c(%eax) } ip->size = 0; 80101d8f: 8b 45 08 mov 0x8(%ebp),%eax 80101d92: c7 40 18 00 00 00 00 movl $0x0,0x18(%eax) iupdate(ip); 80101d99: 8b 45 08 mov 0x8(%ebp),%eax 80101d9c: 89 04 24 mov %eax,(%esp) 80101d9f: e8 72 f9 ff ff call 80101716 <iupdate> } 80101da4: c9 leave 80101da5: c3 ret 80101da6 <stati>: // Copy stat information from inode. void stati(struct inode *ip, struct stat *st) { 80101da6: 55 push %ebp 80101da7: 89 e5 mov %esp,%ebp st->dev = ip->dev; 80101da9: 8b 45 08 mov 0x8(%ebp),%eax 80101dac: 8b 00 mov (%eax),%eax 80101dae: 89 c2 mov %eax,%edx 80101db0: 8b 45 0c mov 0xc(%ebp),%eax 80101db3: 89 50 04 mov %edx,0x4(%eax) st->ino = ip->inum; 80101db6: 8b 45 08 mov 0x8(%ebp),%eax 80101db9: 8b 50 04 mov 0x4(%eax),%edx 80101dbc: 8b 45 0c mov 0xc(%ebp),%eax 80101dbf: 89 50 08 mov %edx,0x8(%eax) st->type = ip->type; 80101dc2: 8b 45 08 mov 0x8(%ebp),%eax 80101dc5: 0f b7 50 10 movzwl 0x10(%eax),%edx 80101dc9: 8b 45 0c mov 0xc(%ebp),%eax 80101dcc: 66 89 10 mov %dx,(%eax) st->nlink = ip->nlink; 80101dcf: 8b 45 08 mov 0x8(%ebp),%eax 80101dd2: 0f b7 50 16 movzwl 0x16(%eax),%edx 80101dd6: 8b 45 0c mov 0xc(%ebp),%eax 80101dd9: 66 89 50 0c mov %dx,0xc(%eax) st->size = ip->size; 80101ddd: 8b 45 08 mov 0x8(%ebp),%eax 80101de0: 8b 50 18 mov 0x18(%eax),%edx 80101de3: 8b 45 0c mov 0xc(%ebp),%eax 80101de6: 89 50 10 mov %edx,0x10(%eax) } 80101de9: 5d pop %ebp 80101dea: c3 ret 80101deb <readi>: //PAGEBREAK! // Read data from inode. int readi(struct inode *ip, char *dst, uint off, uint n) { 80101deb: 55 push %ebp 80101dec: 89 e5 mov %esp,%ebp 80101dee: 83 ec 28 sub $0x28,%esp uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101df1: 8b 45 08 mov 0x8(%ebp),%eax 80101df4: 0f b7 40 10 movzwl 0x10(%eax),%eax 80101df8: 66 83 f8 03 cmp $0x3,%ax 80101dfc: 75 60 jne 80101e5e <readi+0x73> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) 80101dfe: 8b 45 08 mov 0x8(%ebp),%eax 80101e01: 0f b7 40 12 movzwl 0x12(%eax),%eax 80101e05: 66 85 c0 test %ax,%ax 80101e08: 78 20 js 80101e2a <readi+0x3f> 80101e0a: 8b 45 08 mov 0x8(%ebp),%eax 80101e0d: 0f b7 40 12 movzwl 0x12(%eax),%eax 80101e11: 66 83 f8 09 cmp $0x9,%ax 80101e15: 7f 13 jg 80101e2a <readi+0x3f> 80101e17: 8b 45 08 mov 0x8(%ebp),%eax 80101e1a: 0f b7 40 12 movzwl 0x12(%eax),%eax 80101e1e: 98 cwtl 80101e1f: 8b 04 c5 c0 11 11 80 mov -0x7feeee40(,%eax,8),%eax 80101e26: 85 c0 test %eax,%eax 80101e28: 75 0a jne 80101e34 <readi+0x49> return -1; 80101e2a: b8 ff ff ff ff mov $0xffffffff,%eax 80101e2f: e9 19 01 00 00 jmp 80101f4d <readi+0x162> return devsw[ip->major].read(ip, dst, n); 80101e34: 8b 45 08 mov 0x8(%ebp),%eax 80101e37: 0f b7 40 12 movzwl 0x12(%eax),%eax 80101e3b: 98 cwtl 80101e3c: 8b 04 c5 c0 11 11 80 mov -0x7feeee40(,%eax,8),%eax 80101e43: 8b 55 14 mov 0x14(%ebp),%edx 80101e46: 89 54 24 08 mov %edx,0x8(%esp) 80101e4a: 8b 55 0c mov 0xc(%ebp),%edx 80101e4d: 89 54 24 04 mov %edx,0x4(%esp) 80101e51: 8b 55 08 mov 0x8(%ebp),%edx 80101e54: 89 14 24 mov %edx,(%esp) 80101e57: ff d0 call *%eax 80101e59: e9 ef 00 00 00 jmp 80101f4d <readi+0x162> } if(off > ip->size || off + n < off) 80101e5e: 8b 45 08 mov 0x8(%ebp),%eax 80101e61: 8b 40 18 mov 0x18(%eax),%eax 80101e64: 3b 45 10 cmp 0x10(%ebp),%eax 80101e67: 72 0d jb 80101e76 <readi+0x8b> 80101e69: 8b 45 14 mov 0x14(%ebp),%eax 80101e6c: 8b 55 10 mov 0x10(%ebp),%edx 80101e6f: 01 d0 add %edx,%eax 80101e71: 3b 45 10 cmp 0x10(%ebp),%eax 80101e74: 73 0a jae 80101e80 <readi+0x95> return -1; 80101e76: b8 ff ff ff ff mov $0xffffffff,%eax 80101e7b: e9 cd 00 00 00 jmp 80101f4d <readi+0x162> if(off + n > ip->size) 80101e80: 8b 45 14 mov 0x14(%ebp),%eax 80101e83: 8b 55 10 mov 0x10(%ebp),%edx 80101e86: 01 c2 add %eax,%edx 80101e88: 8b 45 08 mov 0x8(%ebp),%eax 80101e8b: 8b 40 18 mov 0x18(%eax),%eax 80101e8e: 39 c2 cmp %eax,%edx 80101e90: 76 0c jbe 80101e9e <readi+0xb3> n = ip->size - off; 80101e92: 8b 45 08 mov 0x8(%ebp),%eax 80101e95: 8b 40 18 mov 0x18(%eax),%eax 80101e98: 2b 45 10 sub 0x10(%ebp),%eax 80101e9b: 89 45 14 mov %eax,0x14(%ebp) for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101e9e: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80101ea5: e9 94 00 00 00 jmp 80101f3e <readi+0x153> bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101eaa: 8b 45 10 mov 0x10(%ebp),%eax 80101ead: c1 e8 09 shr $0x9,%eax 80101eb0: 89 44 24 04 mov %eax,0x4(%esp) 80101eb4: 8b 45 08 mov 0x8(%ebp),%eax 80101eb7: 89 04 24 mov %eax,(%esp) 80101eba: e8 c1 fc ff ff call 80101b80 <bmap> 80101ebf: 8b 55 08 mov 0x8(%ebp),%edx 80101ec2: 8b 12 mov (%edx),%edx 80101ec4: 89 44 24 04 mov %eax,0x4(%esp) 80101ec8: 89 14 24 mov %edx,(%esp) 80101ecb: e8 d6 e2 ff ff call 801001a6 <bread> 80101ed0: 89 45 f0 mov %eax,-0x10(%ebp) m = min(n - tot, BSIZE - off%BSIZE); 80101ed3: 8b 45 10 mov 0x10(%ebp),%eax 80101ed6: 25 ff 01 00 00 and $0x1ff,%eax 80101edb: 89 c2 mov %eax,%edx 80101edd: b8 00 02 00 00 mov $0x200,%eax 80101ee2: 29 d0 sub %edx,%eax 80101ee4: 89 c2 mov %eax,%edx 80101ee6: 8b 45 f4 mov -0xc(%ebp),%eax 80101ee9: 8b 4d 14 mov 0x14(%ebp),%ecx 80101eec: 29 c1 sub %eax,%ecx 80101eee: 89 c8 mov %ecx,%eax 80101ef0: 39 c2 cmp %eax,%edx 80101ef2: 0f 46 c2 cmovbe %edx,%eax 80101ef5: 89 45 ec mov %eax,-0x14(%ebp) memmove(dst, bp->data + off%BSIZE, m); 80101ef8: 8b 45 10 mov 0x10(%ebp),%eax 80101efb: 25 ff 01 00 00 and $0x1ff,%eax 80101f00: 8d 50 10 lea 0x10(%eax),%edx 80101f03: 8b 45 f0 mov -0x10(%ebp),%eax 80101f06: 01 d0 add %edx,%eax 80101f08: 8d 50 08 lea 0x8(%eax),%edx 80101f0b: 8b 45 ec mov -0x14(%ebp),%eax 80101f0e: 89 44 24 08 mov %eax,0x8(%esp) 80101f12: 89 54 24 04 mov %edx,0x4(%esp) 80101f16: 8b 45 0c mov 0xc(%ebp),%eax 80101f19: 89 04 24 mov %eax,(%esp) 80101f1c: e8 c4 35 00 00 call 801054e5 <memmove> brelse(bp); 80101f21: 8b 45 f0 mov -0x10(%ebp),%eax 80101f24: 89 04 24 mov %eax,(%esp) 80101f27: e8 eb e2 ff ff call 80100217 <brelse> if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101f2c: 8b 45 ec mov -0x14(%ebp),%eax 80101f2f: 01 45 f4 add %eax,-0xc(%ebp) 80101f32: 8b 45 ec mov -0x14(%ebp),%eax 80101f35: 01 45 10 add %eax,0x10(%ebp) 80101f38: 8b 45 ec mov -0x14(%ebp),%eax 80101f3b: 01 45 0c add %eax,0xc(%ebp) 80101f3e: 8b 45 f4 mov -0xc(%ebp),%eax 80101f41: 3b 45 14 cmp 0x14(%ebp),%eax 80101f44: 0f 82 60 ff ff ff jb 80101eaa <readi+0xbf> bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); memmove(dst, bp->data + off%BSIZE, m); brelse(bp); } return n; 80101f4a: 8b 45 14 mov 0x14(%ebp),%eax } 80101f4d: c9 leave 80101f4e: c3 ret 80101f4f <writei>: // PAGEBREAK! // Write data to inode. int writei(struct inode *ip, char *src, uint off, uint n) { 80101f4f: 55 push %ebp 80101f50: 89 e5 mov %esp,%ebp 80101f52: 83 ec 28 sub $0x28,%esp uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101f55: 8b 45 08 mov 0x8(%ebp),%eax 80101f58: 0f b7 40 10 movzwl 0x10(%eax),%eax 80101f5c: 66 83 f8 03 cmp $0x3,%ax 80101f60: 75 60 jne 80101fc2 <writei+0x73> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) 80101f62: 8b 45 08 mov 0x8(%ebp),%eax 80101f65: 0f b7 40 12 movzwl 0x12(%eax),%eax 80101f69: 66 85 c0 test %ax,%ax 80101f6c: 78 20 js 80101f8e <writei+0x3f> 80101f6e: 8b 45 08 mov 0x8(%ebp),%eax 80101f71: 0f b7 40 12 movzwl 0x12(%eax),%eax 80101f75: 66 83 f8 09 cmp $0x9,%ax 80101f79: 7f 13 jg 80101f8e <writei+0x3f> 80101f7b: 8b 45 08 mov 0x8(%ebp),%eax 80101f7e: 0f b7 40 12 movzwl 0x12(%eax),%eax 80101f82: 98 cwtl 80101f83: 8b 04 c5 c4 11 11 80 mov -0x7feeee3c(,%eax,8),%eax 80101f8a: 85 c0 test %eax,%eax 80101f8c: 75 0a jne 80101f98 <writei+0x49> return -1; 80101f8e: b8 ff ff ff ff mov $0xffffffff,%eax 80101f93: e9 44 01 00 00 jmp 801020dc <writei+0x18d> return devsw[ip->major].write(ip, src, n); 80101f98: 8b 45 08 mov 0x8(%ebp),%eax 80101f9b: 0f b7 40 12 movzwl 0x12(%eax),%eax 80101f9f: 98 cwtl 80101fa0: 8b 04 c5 c4 11 11 80 mov -0x7feeee3c(,%eax,8),%eax 80101fa7: 8b 55 14 mov 0x14(%ebp),%edx 80101faa: 89 54 24 08 mov %edx,0x8(%esp) 80101fae: 8b 55 0c mov 0xc(%ebp),%edx 80101fb1: 89 54 24 04 mov %edx,0x4(%esp) 80101fb5: 8b 55 08 mov 0x8(%ebp),%edx 80101fb8: 89 14 24 mov %edx,(%esp) 80101fbb: ff d0 call *%eax 80101fbd: e9 1a 01 00 00 jmp 801020dc <writei+0x18d> } if(off > ip->size || off + n < off) 80101fc2: 8b 45 08 mov 0x8(%ebp),%eax 80101fc5: 8b 40 18 mov 0x18(%eax),%eax 80101fc8: 3b 45 10 cmp 0x10(%ebp),%eax 80101fcb: 72 0d jb 80101fda <writei+0x8b> 80101fcd: 8b 45 14 mov 0x14(%ebp),%eax 80101fd0: 8b 55 10 mov 0x10(%ebp),%edx 80101fd3: 01 d0 add %edx,%eax 80101fd5: 3b 45 10 cmp 0x10(%ebp),%eax 80101fd8: 73 0a jae 80101fe4 <writei+0x95> return -1; 80101fda: b8 ff ff ff ff mov $0xffffffff,%eax 80101fdf: e9 f8 00 00 00 jmp 801020dc <writei+0x18d> if(off + n > MAXFILE*BSIZE) 80101fe4: 8b 45 14 mov 0x14(%ebp),%eax 80101fe7: 8b 55 10 mov 0x10(%ebp),%edx 80101fea: 01 d0 add %edx,%eax 80101fec: 3d 00 18 01 00 cmp $0x11800,%eax 80101ff1: 76 0a jbe 80101ffd <writei+0xae> return -1; 80101ff3: b8 ff ff ff ff mov $0xffffffff,%eax 80101ff8: e9 df 00 00 00 jmp 801020dc <writei+0x18d> for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101ffd: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80102004: e9 9f 00 00 00 jmp 801020a8 <writei+0x159> bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80102009: 8b 45 10 mov 0x10(%ebp),%eax 8010200c: c1 e8 09 shr $0x9,%eax 8010200f: 89 44 24 04 mov %eax,0x4(%esp) 80102013: 8b 45 08 mov 0x8(%ebp),%eax 80102016: 89 04 24 mov %eax,(%esp) 80102019: e8 62 fb ff ff call 80101b80 <bmap> 8010201e: 8b 55 08 mov 0x8(%ebp),%edx 80102021: 8b 12 mov (%edx),%edx 80102023: 89 44 24 04 mov %eax,0x4(%esp) 80102027: 89 14 24 mov %edx,(%esp) 8010202a: e8 77 e1 ff ff call 801001a6 <bread> 8010202f: 89 45 f0 mov %eax,-0x10(%ebp) m = min(n - tot, BSIZE - off%BSIZE); 80102032: 8b 45 10 mov 0x10(%ebp),%eax 80102035: 25 ff 01 00 00 and $0x1ff,%eax 8010203a: 89 c2 mov %eax,%edx 8010203c: b8 00 02 00 00 mov $0x200,%eax 80102041: 29 d0 sub %edx,%eax 80102043: 89 c2 mov %eax,%edx 80102045: 8b 45 f4 mov -0xc(%ebp),%eax 80102048: 8b 4d 14 mov 0x14(%ebp),%ecx 8010204b: 29 c1 sub %eax,%ecx 8010204d: 89 c8 mov %ecx,%eax 8010204f: 39 c2 cmp %eax,%edx 80102051: 0f 46 c2 cmovbe %edx,%eax 80102054: 89 45 ec mov %eax,-0x14(%ebp) memmove(bp->data + off%BSIZE, src, m); 80102057: 8b 45 10 mov 0x10(%ebp),%eax 8010205a: 25 ff 01 00 00 and $0x1ff,%eax 8010205f: 8d 50 10 lea 0x10(%eax),%edx 80102062: 8b 45 f0 mov -0x10(%ebp),%eax 80102065: 01 d0 add %edx,%eax 80102067: 8d 50 08 lea 0x8(%eax),%edx 8010206a: 8b 45 ec mov -0x14(%ebp),%eax 8010206d: 89 44 24 08 mov %eax,0x8(%esp) 80102071: 8b 45 0c mov 0xc(%ebp),%eax 80102074: 89 44 24 04 mov %eax,0x4(%esp) 80102078: 89 14 24 mov %edx,(%esp) 8010207b: e8 65 34 00 00 call 801054e5 <memmove> log_write(bp); 80102080: 8b 45 f0 mov -0x10(%ebp),%eax 80102083: 89 04 24 mov %eax,(%esp) 80102086: e8 48 16 00 00 call 801036d3 <log_write> brelse(bp); 8010208b: 8b 45 f0 mov -0x10(%ebp),%eax 8010208e: 89 04 24 mov %eax,(%esp) 80102091: e8 81 e1 ff ff call 80100217 <brelse> if(off > ip->size || off + n < off) return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80102096: 8b 45 ec mov -0x14(%ebp),%eax 80102099: 01 45 f4 add %eax,-0xc(%ebp) 8010209c: 8b 45 ec mov -0x14(%ebp),%eax 8010209f: 01 45 10 add %eax,0x10(%ebp) 801020a2: 8b 45 ec mov -0x14(%ebp),%eax 801020a5: 01 45 0c add %eax,0xc(%ebp) 801020a8: 8b 45 f4 mov -0xc(%ebp),%eax 801020ab: 3b 45 14 cmp 0x14(%ebp),%eax 801020ae: 0f 82 55 ff ff ff jb 80102009 <writei+0xba> memmove(bp->data + off%BSIZE, src, m); log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ 801020b4: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 801020b8: 74 1f je 801020d9 <writei+0x18a> 801020ba: 8b 45 08 mov 0x8(%ebp),%eax 801020bd: 8b 40 18 mov 0x18(%eax),%eax 801020c0: 3b 45 10 cmp 0x10(%ebp),%eax 801020c3: 73 14 jae 801020d9 <writei+0x18a> ip->size = off; 801020c5: 8b 45 08 mov 0x8(%ebp),%eax 801020c8: 8b 55 10 mov 0x10(%ebp),%edx 801020cb: 89 50 18 mov %edx,0x18(%eax) iupdate(ip); 801020ce: 8b 45 08 mov 0x8(%ebp),%eax 801020d1: 89 04 24 mov %eax,(%esp) 801020d4: e8 3d f6 ff ff call 80101716 <iupdate> } return n; 801020d9: 8b 45 14 mov 0x14(%ebp),%eax } 801020dc: c9 leave 801020dd: c3 ret 801020de <namecmp>: //PAGEBREAK! // Directories int namecmp(const char *s, const char *t) { 801020de: 55 push %ebp 801020df: 89 e5 mov %esp,%ebp 801020e1: 83 ec 18 sub $0x18,%esp return strncmp(s, t, DIRSIZ); 801020e4: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 801020eb: 00 801020ec: 8b 45 0c mov 0xc(%ebp),%eax 801020ef: 89 44 24 04 mov %eax,0x4(%esp) 801020f3: 8b 45 08 mov 0x8(%ebp),%eax 801020f6: 89 04 24 mov %eax,(%esp) 801020f9: e8 8a 34 00 00 call 80105588 <strncmp> } 801020fe: c9 leave 801020ff: c3 ret 80102100 <dirlookup>: // Look for a directory entry in a directory. // If found, set *poff to byte offset of entry. struct inode* dirlookup(struct inode *dp, char *name, uint *poff) { 80102100: 55 push %ebp 80102101: 89 e5 mov %esp,%ebp 80102103: 83 ec 38 sub $0x38,%esp uint off, inum; struct dirent de; if(dp->type != T_DIR) 80102106: 8b 45 08 mov 0x8(%ebp),%eax 80102109: 0f b7 40 10 movzwl 0x10(%eax),%eax 8010210d: 66 83 f8 01 cmp $0x1,%ax 80102111: 74 0c je 8010211f <dirlookup+0x1f> panic("dirlookup not DIR"); 80102113: c7 04 24 e3 89 10 80 movl $0x801089e3,(%esp) 8010211a: e8 1b e4 ff ff call 8010053a <panic> for(off = 0; off < dp->size; off += sizeof(de)){ 8010211f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80102126: e9 88 00 00 00 jmp 801021b3 <dirlookup+0xb3> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 8010212b: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80102132: 00 80102133: 8b 45 f4 mov -0xc(%ebp),%eax 80102136: 89 44 24 08 mov %eax,0x8(%esp) 8010213a: 8d 45 e0 lea -0x20(%ebp),%eax 8010213d: 89 44 24 04 mov %eax,0x4(%esp) 80102141: 8b 45 08 mov 0x8(%ebp),%eax 80102144: 89 04 24 mov %eax,(%esp) 80102147: e8 9f fc ff ff call 80101deb <readi> 8010214c: 83 f8 10 cmp $0x10,%eax 8010214f: 74 0c je 8010215d <dirlookup+0x5d> panic("dirlink read"); 80102151: c7 04 24 f5 89 10 80 movl $0x801089f5,(%esp) 80102158: e8 dd e3 ff ff call 8010053a <panic> if(de.inum == 0) 8010215d: 0f b7 45 e0 movzwl -0x20(%ebp),%eax 80102161: 66 85 c0 test %ax,%ax 80102164: 75 02 jne 80102168 <dirlookup+0x68> continue; 80102166: eb 47 jmp 801021af <dirlookup+0xaf> if(namecmp(name, de.name) == 0){ 80102168: 8d 45 e0 lea -0x20(%ebp),%eax 8010216b: 83 c0 02 add $0x2,%eax 8010216e: 89 44 24 04 mov %eax,0x4(%esp) 80102172: 8b 45 0c mov 0xc(%ebp),%eax 80102175: 89 04 24 mov %eax,(%esp) 80102178: e8 61 ff ff ff call 801020de <namecmp> 8010217d: 85 c0 test %eax,%eax 8010217f: 75 2e jne 801021af <dirlookup+0xaf> // entry matches path element if(poff) 80102181: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 80102185: 74 08 je 8010218f <dirlookup+0x8f> *poff = off; 80102187: 8b 45 10 mov 0x10(%ebp),%eax 8010218a: 8b 55 f4 mov -0xc(%ebp),%edx 8010218d: 89 10 mov %edx,(%eax) inum = de.inum; 8010218f: 0f b7 45 e0 movzwl -0x20(%ebp),%eax 80102193: 0f b7 c0 movzwl %ax,%eax 80102196: 89 45 f0 mov %eax,-0x10(%ebp) return iget(dp->dev, inum); 80102199: 8b 45 08 mov 0x8(%ebp),%eax 8010219c: 8b 00 mov (%eax),%eax 8010219e: 8b 55 f0 mov -0x10(%ebp),%edx 801021a1: 89 54 24 04 mov %edx,0x4(%esp) 801021a5: 89 04 24 mov %eax,(%esp) 801021a8: e8 27 f6 ff ff call 801017d4 <iget> 801021ad: eb 18 jmp 801021c7 <dirlookup+0xc7> struct dirent de; if(dp->type != T_DIR) panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 801021af: 83 45 f4 10 addl $0x10,-0xc(%ebp) 801021b3: 8b 45 08 mov 0x8(%ebp),%eax 801021b6: 8b 40 18 mov 0x18(%eax),%eax 801021b9: 3b 45 f4 cmp -0xc(%ebp),%eax 801021bc: 0f 87 69 ff ff ff ja 8010212b <dirlookup+0x2b> inum = de.inum; return iget(dp->dev, inum); } } return 0; 801021c2: b8 00 00 00 00 mov $0x0,%eax } 801021c7: c9 leave 801021c8: c3 ret 801021c9 <dirlink>: // Write a new directory entry (name, inum) into the directory dp. int dirlink(struct inode *dp, char *name, uint inum) { 801021c9: 55 push %ebp 801021ca: 89 e5 mov %esp,%ebp 801021cc: 83 ec 38 sub $0x38,%esp int off; struct dirent de; struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ 801021cf: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 801021d6: 00 801021d7: 8b 45 0c mov 0xc(%ebp),%eax 801021da: 89 44 24 04 mov %eax,0x4(%esp) 801021de: 8b 45 08 mov 0x8(%ebp),%eax 801021e1: 89 04 24 mov %eax,(%esp) 801021e4: e8 17 ff ff ff call 80102100 <dirlookup> 801021e9: 89 45 f0 mov %eax,-0x10(%ebp) 801021ec: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 801021f0: 74 15 je 80102207 <dirlink+0x3e> iput(ip); 801021f2: 8b 45 f0 mov -0x10(%ebp),%eax 801021f5: 89 04 24 mov %eax,(%esp) 801021f8: e8 94 f8 ff ff call 80101a91 <iput> return -1; 801021fd: b8 ff ff ff ff mov $0xffffffff,%eax 80102202: e9 b7 00 00 00 jmp 801022be <dirlink+0xf5> } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ 80102207: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 8010220e: eb 46 jmp 80102256 <dirlink+0x8d> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80102210: 8b 45 f4 mov -0xc(%ebp),%eax 80102213: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 8010221a: 00 8010221b: 89 44 24 08 mov %eax,0x8(%esp) 8010221f: 8d 45 e0 lea -0x20(%ebp),%eax 80102222: 89 44 24 04 mov %eax,0x4(%esp) 80102226: 8b 45 08 mov 0x8(%ebp),%eax 80102229: 89 04 24 mov %eax,(%esp) 8010222c: e8 ba fb ff ff call 80101deb <readi> 80102231: 83 f8 10 cmp $0x10,%eax 80102234: 74 0c je 80102242 <dirlink+0x79> panic("dirlink read"); 80102236: c7 04 24 f5 89 10 80 movl $0x801089f5,(%esp) 8010223d: e8 f8 e2 ff ff call 8010053a <panic> if(de.inum == 0) 80102242: 0f b7 45 e0 movzwl -0x20(%ebp),%eax 80102246: 66 85 c0 test %ax,%ax 80102249: 75 02 jne 8010224d <dirlink+0x84> break; 8010224b: eb 16 jmp 80102263 <dirlink+0x9a> iput(ip); return -1; } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ 8010224d: 8b 45 f4 mov -0xc(%ebp),%eax 80102250: 83 c0 10 add $0x10,%eax 80102253: 89 45 f4 mov %eax,-0xc(%ebp) 80102256: 8b 55 f4 mov -0xc(%ebp),%edx 80102259: 8b 45 08 mov 0x8(%ebp),%eax 8010225c: 8b 40 18 mov 0x18(%eax),%eax 8010225f: 39 c2 cmp %eax,%edx 80102261: 72 ad jb 80102210 <dirlink+0x47> panic("dirlink read"); if(de.inum == 0) break; } strncpy(de.name, name, DIRSIZ); 80102263: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 8010226a: 00 8010226b: 8b 45 0c mov 0xc(%ebp),%eax 8010226e: 89 44 24 04 mov %eax,0x4(%esp) 80102272: 8d 45 e0 lea -0x20(%ebp),%eax 80102275: 83 c0 02 add $0x2,%eax 80102278: 89 04 24 mov %eax,(%esp) 8010227b: e8 5e 33 00 00 call 801055de <strncpy> de.inum = inum; 80102280: 8b 45 10 mov 0x10(%ebp),%eax 80102283: 66 89 45 e0 mov %ax,-0x20(%ebp) if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80102287: 8b 45 f4 mov -0xc(%ebp),%eax 8010228a: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80102291: 00 80102292: 89 44 24 08 mov %eax,0x8(%esp) 80102296: 8d 45 e0 lea -0x20(%ebp),%eax 80102299: 89 44 24 04 mov %eax,0x4(%esp) 8010229d: 8b 45 08 mov 0x8(%ebp),%eax 801022a0: 89 04 24 mov %eax,(%esp) 801022a3: e8 a7 fc ff ff call 80101f4f <writei> 801022a8: 83 f8 10 cmp $0x10,%eax 801022ab: 74 0c je 801022b9 <dirlink+0xf0> panic("dirlink"); 801022ad: c7 04 24 02 8a 10 80 movl $0x80108a02,(%esp) 801022b4: e8 81 e2 ff ff call 8010053a <panic> return 0; 801022b9: b8 00 00 00 00 mov $0x0,%eax } 801022be: c9 leave 801022bf: c3 ret 801022c0 <skipelem>: // skipelem("a", name) = "", setting name = "a" // skipelem("", name) = skipelem("////", name) = 0 // static char* skipelem(char *path, char *name) { 801022c0: 55 push %ebp 801022c1: 89 e5 mov %esp,%ebp 801022c3: 83 ec 28 sub $0x28,%esp char *s; int len; while(*path == '/') 801022c6: eb 04 jmp 801022cc <skipelem+0xc> path++; 801022c8: 83 45 08 01 addl $0x1,0x8(%ebp) skipelem(char *path, char *name) { char *s; int len; while(*path == '/') 801022cc: 8b 45 08 mov 0x8(%ebp),%eax 801022cf: 0f b6 00 movzbl (%eax),%eax 801022d2: 3c 2f cmp $0x2f,%al 801022d4: 74 f2 je 801022c8 <skipelem+0x8> path++; if(*path == 0) 801022d6: 8b 45 08 mov 0x8(%ebp),%eax 801022d9: 0f b6 00 movzbl (%eax),%eax 801022dc: 84 c0 test %al,%al 801022de: 75 0a jne 801022ea <skipelem+0x2a> return 0; 801022e0: b8 00 00 00 00 mov $0x0,%eax 801022e5: e9 86 00 00 00 jmp 80102370 <skipelem+0xb0> s = path; 801022ea: 8b 45 08 mov 0x8(%ebp),%eax 801022ed: 89 45 f4 mov %eax,-0xc(%ebp) while(*path != '/' && *path != 0) 801022f0: eb 04 jmp 801022f6 <skipelem+0x36> path++; 801022f2: 83 45 08 01 addl $0x1,0x8(%ebp) while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 801022f6: 8b 45 08 mov 0x8(%ebp),%eax 801022f9: 0f b6 00 movzbl (%eax),%eax 801022fc: 3c 2f cmp $0x2f,%al 801022fe: 74 0a je 8010230a <skipelem+0x4a> 80102300: 8b 45 08 mov 0x8(%ebp),%eax 80102303: 0f b6 00 movzbl (%eax),%eax 80102306: 84 c0 test %al,%al 80102308: 75 e8 jne 801022f2 <skipelem+0x32> path++; len = path - s; 8010230a: 8b 55 08 mov 0x8(%ebp),%edx 8010230d: 8b 45 f4 mov -0xc(%ebp),%eax 80102310: 29 c2 sub %eax,%edx 80102312: 89 d0 mov %edx,%eax 80102314: 89 45 f0 mov %eax,-0x10(%ebp) if(len >= DIRSIZ) 80102317: 83 7d f0 0d cmpl $0xd,-0x10(%ebp) 8010231b: 7e 1c jle 80102339 <skipelem+0x79> memmove(name, s, DIRSIZ); 8010231d: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80102324: 00 80102325: 8b 45 f4 mov -0xc(%ebp),%eax 80102328: 89 44 24 04 mov %eax,0x4(%esp) 8010232c: 8b 45 0c mov 0xc(%ebp),%eax 8010232f: 89 04 24 mov %eax,(%esp) 80102332: e8 ae 31 00 00 call 801054e5 <memmove> else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80102337: eb 2a jmp 80102363 <skipelem+0xa3> path++; len = path - s; if(len >= DIRSIZ) memmove(name, s, DIRSIZ); else { memmove(name, s, len); 80102339: 8b 45 f0 mov -0x10(%ebp),%eax 8010233c: 89 44 24 08 mov %eax,0x8(%esp) 80102340: 8b 45 f4 mov -0xc(%ebp),%eax 80102343: 89 44 24 04 mov %eax,0x4(%esp) 80102347: 8b 45 0c mov 0xc(%ebp),%eax 8010234a: 89 04 24 mov %eax,(%esp) 8010234d: e8 93 31 00 00 call 801054e5 <memmove> name[len] = 0; 80102352: 8b 55 f0 mov -0x10(%ebp),%edx 80102355: 8b 45 0c mov 0xc(%ebp),%eax 80102358: 01 d0 add %edx,%eax 8010235a: c6 00 00 movb $0x0,(%eax) } while(*path == '/') 8010235d: eb 04 jmp 80102363 <skipelem+0xa3> path++; 8010235f: 83 45 08 01 addl $0x1,0x8(%ebp) memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80102363: 8b 45 08 mov 0x8(%ebp),%eax 80102366: 0f b6 00 movzbl (%eax),%eax 80102369: 3c 2f cmp $0x2f,%al 8010236b: 74 f2 je 8010235f <skipelem+0x9f> path++; return path; 8010236d: 8b 45 08 mov 0x8(%ebp),%eax } 80102370: c9 leave 80102371: c3 ret 80102372 <namex>: // If parent != 0, return the inode for the parent and copy the final // path element into name, which must have room for DIRSIZ bytes. // Must be called inside a transaction since it calls iput(). static struct inode* namex(char *path, int nameiparent, char *name) { 80102372: 55 push %ebp 80102373: 89 e5 mov %esp,%ebp 80102375: 83 ec 28 sub $0x28,%esp struct inode *ip, *next; if(*path == '/') 80102378: 8b 45 08 mov 0x8(%ebp),%eax 8010237b: 0f b6 00 movzbl (%eax),%eax 8010237e: 3c 2f cmp $0x2f,%al 80102380: 75 1c jne 8010239e <namex+0x2c> ip = iget(ROOTDEV, ROOTINO); 80102382: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80102389: 00 8010238a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80102391: e8 3e f4 ff ff call 801017d4 <iget> 80102396: 89 45 f4 mov %eax,-0xc(%ebp) else ip = idup(proc->cwd); while((path = skipelem(path, name)) != 0){ 80102399: e9 af 00 00 00 jmp 8010244d <namex+0xdb> struct inode *ip, *next; if(*path == '/') ip = iget(ROOTDEV, ROOTINO); else ip = idup(proc->cwd); 8010239e: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801023a4: 8b 40 68 mov 0x68(%eax),%eax 801023a7: 89 04 24 mov %eax,(%esp) 801023aa: e8 f7 f4 ff ff call 801018a6 <idup> 801023af: 89 45 f4 mov %eax,-0xc(%ebp) while((path = skipelem(path, name)) != 0){ 801023b2: e9 96 00 00 00 jmp 8010244d <namex+0xdb> ilock(ip); 801023b7: 8b 45 f4 mov -0xc(%ebp),%eax 801023ba: 89 04 24 mov %eax,(%esp) 801023bd: e8 16 f5 ff ff call 801018d8 <ilock> if(ip->type != T_DIR){ 801023c2: 8b 45 f4 mov -0xc(%ebp),%eax 801023c5: 0f b7 40 10 movzwl 0x10(%eax),%eax 801023c9: 66 83 f8 01 cmp $0x1,%ax 801023cd: 74 15 je 801023e4 <namex+0x72> iunlockput(ip); 801023cf: 8b 45 f4 mov -0xc(%ebp),%eax 801023d2: 89 04 24 mov %eax,(%esp) 801023d5: e8 88 f7 ff ff call 80101b62 <iunlockput> return 0; 801023da: b8 00 00 00 00 mov $0x0,%eax 801023df: e9 a3 00 00 00 jmp 80102487 <namex+0x115> } if(nameiparent && *path == '\0'){ 801023e4: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 801023e8: 74 1d je 80102407 <namex+0x95> 801023ea: 8b 45 08 mov 0x8(%ebp),%eax 801023ed: 0f b6 00 movzbl (%eax),%eax 801023f0: 84 c0 test %al,%al 801023f2: 75 13 jne 80102407 <namex+0x95> // Stop one level early. iunlock(ip); 801023f4: 8b 45 f4 mov -0xc(%ebp),%eax 801023f7: 89 04 24 mov %eax,(%esp) 801023fa: e8 2d f6 ff ff call 80101a2c <iunlock> return ip; 801023ff: 8b 45 f4 mov -0xc(%ebp),%eax 80102402: e9 80 00 00 00 jmp 80102487 <namex+0x115> } if((next = dirlookup(ip, name, 0)) == 0){ 80102407: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 8010240e: 00 8010240f: 8b 45 10 mov 0x10(%ebp),%eax 80102412: 89 44 24 04 mov %eax,0x4(%esp) 80102416: 8b 45 f4 mov -0xc(%ebp),%eax 80102419: 89 04 24 mov %eax,(%esp) 8010241c: e8 df fc ff ff call 80102100 <dirlookup> 80102421: 89 45 f0 mov %eax,-0x10(%ebp) 80102424: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80102428: 75 12 jne 8010243c <namex+0xca> iunlockput(ip); 8010242a: 8b 45 f4 mov -0xc(%ebp),%eax 8010242d: 89 04 24 mov %eax,(%esp) 80102430: e8 2d f7 ff ff call 80101b62 <iunlockput> return 0; 80102435: b8 00 00 00 00 mov $0x0,%eax 8010243a: eb 4b jmp 80102487 <namex+0x115> } iunlockput(ip); 8010243c: 8b 45 f4 mov -0xc(%ebp),%eax 8010243f: 89 04 24 mov %eax,(%esp) 80102442: e8 1b f7 ff ff call 80101b62 <iunlockput> ip = next; 80102447: 8b 45 f0 mov -0x10(%ebp),%eax 8010244a: 89 45 f4 mov %eax,-0xc(%ebp) if(*path == '/') ip = iget(ROOTDEV, ROOTINO); else ip = idup(proc->cwd); while((path = skipelem(path, name)) != 0){ 8010244d: 8b 45 10 mov 0x10(%ebp),%eax 80102450: 89 44 24 04 mov %eax,0x4(%esp) 80102454: 8b 45 08 mov 0x8(%ebp),%eax 80102457: 89 04 24 mov %eax,(%esp) 8010245a: e8 61 fe ff ff call 801022c0 <skipelem> 8010245f: 89 45 08 mov %eax,0x8(%ebp) 80102462: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 80102466: 0f 85 4b ff ff ff jne 801023b7 <namex+0x45> return 0; } iunlockput(ip); ip = next; } if(nameiparent){ 8010246c: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 80102470: 74 12 je 80102484 <namex+0x112> iput(ip); 80102472: 8b 45 f4 mov -0xc(%ebp),%eax 80102475: 89 04 24 mov %eax,(%esp) 80102478: e8 14 f6 ff ff call 80101a91 <iput> return 0; 8010247d: b8 00 00 00 00 mov $0x0,%eax 80102482: eb 03 jmp 80102487 <namex+0x115> } return ip; 80102484: 8b 45 f4 mov -0xc(%ebp),%eax } 80102487: c9 leave 80102488: c3 ret 80102489 <namei>: struct inode* namei(char *path) { 80102489: 55 push %ebp 8010248a: 89 e5 mov %esp,%ebp 8010248c: 83 ec 28 sub $0x28,%esp char name[DIRSIZ]; return namex(path, 0, name); 8010248f: 8d 45 ea lea -0x16(%ebp),%eax 80102492: 89 44 24 08 mov %eax,0x8(%esp) 80102496: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 8010249d: 00 8010249e: 8b 45 08 mov 0x8(%ebp),%eax 801024a1: 89 04 24 mov %eax,(%esp) 801024a4: e8 c9 fe ff ff call 80102372 <namex> } 801024a9: c9 leave 801024aa: c3 ret 801024ab <nameiparent>: struct inode* nameiparent(char *path, char *name) { 801024ab: 55 push %ebp 801024ac: 89 e5 mov %esp,%ebp 801024ae: 83 ec 18 sub $0x18,%esp return namex(path, 1, name); 801024b1: 8b 45 0c mov 0xc(%ebp),%eax 801024b4: 89 44 24 08 mov %eax,0x8(%esp) 801024b8: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 801024bf: 00 801024c0: 8b 45 08 mov 0x8(%ebp),%eax 801024c3: 89 04 24 mov %eax,(%esp) 801024c6: e8 a7 fe ff ff call 80102372 <namex> } 801024cb: c9 leave 801024cc: c3 ret 801024cd: 66 90 xchg %ax,%ax 801024cf: 90 nop 801024d0 <inb>: // Routines to let C code use special x86 instructions. static inline uchar inb(ushort port) { 801024d0: 55 push %ebp 801024d1: 89 e5 mov %esp,%ebp 801024d3: 83 ec 14 sub $0x14,%esp 801024d6: 8b 45 08 mov 0x8(%ebp),%eax 801024d9: 66 89 45 ec mov %ax,-0x14(%ebp) uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801024dd: 0f b7 45 ec movzwl -0x14(%ebp),%eax 801024e1: 89 c2 mov %eax,%edx 801024e3: ec in (%dx),%al 801024e4: 88 45 ff mov %al,-0x1(%ebp) return data; 801024e7: 0f b6 45 ff movzbl -0x1(%ebp),%eax } 801024eb: c9 leave 801024ec: c3 ret 801024ed <insl>: static inline void insl(int port, void *addr, int cnt) { 801024ed: 55 push %ebp 801024ee: 89 e5 mov %esp,%ebp 801024f0: 57 push %edi 801024f1: 53 push %ebx asm volatile("cld; rep insl" : 801024f2: 8b 55 08 mov 0x8(%ebp),%edx 801024f5: 8b 4d 0c mov 0xc(%ebp),%ecx 801024f8: 8b 45 10 mov 0x10(%ebp),%eax 801024fb: 89 cb mov %ecx,%ebx 801024fd: 89 df mov %ebx,%edi 801024ff: 89 c1 mov %eax,%ecx 80102501: fc cld 80102502: f3 6d rep insl (%dx),%es:(%edi) 80102504: 89 c8 mov %ecx,%eax 80102506: 89 fb mov %edi,%ebx 80102508: 89 5d 0c mov %ebx,0xc(%ebp) 8010250b: 89 45 10 mov %eax,0x10(%ebp) "=D" (addr), "=c" (cnt) : "d" (port), "0" (addr), "1" (cnt) : "memory", "cc"); } 8010250e: 5b pop %ebx 8010250f: 5f pop %edi 80102510: 5d pop %ebp 80102511: c3 ret 80102512 <outb>: static inline void outb(ushort port, uchar data) { 80102512: 55 push %ebp 80102513: 89 e5 mov %esp,%ebp 80102515: 83 ec 08 sub $0x8,%esp 80102518: 8b 55 08 mov 0x8(%ebp),%edx 8010251b: 8b 45 0c mov 0xc(%ebp),%eax 8010251e: 66 89 55 fc mov %dx,-0x4(%ebp) 80102522: 88 45 f8 mov %al,-0x8(%ebp) asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102525: 0f b6 45 f8 movzbl -0x8(%ebp),%eax 80102529: 0f b7 55 fc movzwl -0x4(%ebp),%edx 8010252d: ee out %al,(%dx) } 8010252e: c9 leave 8010252f: c3 ret 80102530 <outsl>: asm volatile("out %0,%1" : : "a" (data), "d" (port)); } static inline void outsl(int port, const void *addr, int cnt) { 80102530: 55 push %ebp 80102531: 89 e5 mov %esp,%ebp 80102533: 56 push %esi 80102534: 53 push %ebx asm volatile("cld; rep outsl" : 80102535: 8b 55 08 mov 0x8(%ebp),%edx 80102538: 8b 4d 0c mov 0xc(%ebp),%ecx 8010253b: 8b 45 10 mov 0x10(%ebp),%eax 8010253e: 89 cb mov %ecx,%ebx 80102540: 89 de mov %ebx,%esi 80102542: 89 c1 mov %eax,%ecx 80102544: fc cld 80102545: f3 6f rep outsl %ds:(%esi),(%dx) 80102547: 89 c8 mov %ecx,%eax 80102549: 89 f3 mov %esi,%ebx 8010254b: 89 5d 0c mov %ebx,0xc(%ebp) 8010254e: 89 45 10 mov %eax,0x10(%ebp) "=S" (addr), "=c" (cnt) : "d" (port), "0" (addr), "1" (cnt) : "cc"); } 80102551: 5b pop %ebx 80102552: 5e pop %esi 80102553: 5d pop %ebp 80102554: c3 ret 80102555 <idewait>: static void idestart(struct buf*); // Wait for IDE disk to become ready. static int idewait(int checkerr) { 80102555: 55 push %ebp 80102556: 89 e5 mov %esp,%ebp 80102558: 83 ec 14 sub $0x14,%esp int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 8010255b: 90 nop 8010255c: c7 04 24 f7 01 00 00 movl $0x1f7,(%esp) 80102563: e8 68 ff ff ff call 801024d0 <inb> 80102568: 0f b6 c0 movzbl %al,%eax 8010256b: 89 45 fc mov %eax,-0x4(%ebp) 8010256e: 8b 45 fc mov -0x4(%ebp),%eax 80102571: 25 c0 00 00 00 and $0xc0,%eax 80102576: 83 f8 40 cmp $0x40,%eax 80102579: 75 e1 jne 8010255c <idewait+0x7> ; if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0) 8010257b: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 8010257f: 74 11 je 80102592 <idewait+0x3d> 80102581: 8b 45 fc mov -0x4(%ebp),%eax 80102584: 83 e0 21 and $0x21,%eax 80102587: 85 c0 test %eax,%eax 80102589: 74 07 je 80102592 <idewait+0x3d> return -1; 8010258b: b8 ff ff ff ff mov $0xffffffff,%eax 80102590: eb 05 jmp 80102597 <idewait+0x42> return 0; 80102592: b8 00 00 00 00 mov $0x0,%eax } 80102597: c9 leave 80102598: c3 ret 80102599 <ideinit>: void ideinit(void) { 80102599: 55 push %ebp 8010259a: 89 e5 mov %esp,%ebp 8010259c: 83 ec 28 sub $0x28,%esp int i; initlock(&idelock, "ide"); 8010259f: c7 44 24 04 0a 8a 10 movl $0x80108a0a,0x4(%esp) 801025a6: 80 801025a7: c7 04 24 00 b6 10 80 movl $0x8010b600,(%esp) 801025ae: e8 eb 2b 00 00 call 8010519e <initlock> picenable(IRQ_IDE); 801025b3: c7 04 24 0e 00 00 00 movl $0xe,(%esp) 801025ba: e8 ae 18 00 00 call 80103e6d <picenable> ioapicenable(IRQ_IDE, ncpu - 1); 801025bf: a1 40 29 11 80 mov 0x80112940,%eax 801025c4: 83 e8 01 sub $0x1,%eax 801025c7: 89 44 24 04 mov %eax,0x4(%esp) 801025cb: c7 04 24 0e 00 00 00 movl $0xe,(%esp) 801025d2: e8 45 04 00 00 call 80102a1c <ioapicenable> idewait(0); 801025d7: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801025de: e8 72 ff ff ff call 80102555 <idewait> // Check if disk 1 is present outb(0x1f6, 0xe0 | (1<<4)); 801025e3: c7 44 24 04 f0 00 00 movl $0xf0,0x4(%esp) 801025ea: 00 801025eb: c7 04 24 f6 01 00 00 movl $0x1f6,(%esp) 801025f2: e8 1b ff ff ff call 80102512 <outb> for(i=0; i<1000; i++){ 801025f7: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 801025fe: eb 20 jmp 80102620 <ideinit+0x87> if(inb(0x1f7) != 0){ 80102600: c7 04 24 f7 01 00 00 movl $0x1f7,(%esp) 80102607: e8 c4 fe ff ff call 801024d0 <inb> 8010260c: 84 c0 test %al,%al 8010260e: 74 0c je 8010261c <ideinit+0x83> havedisk1 = 1; 80102610: c7 05 38 b6 10 80 01 movl $0x1,0x8010b638 80102617: 00 00 00 break; 8010261a: eb 0d jmp 80102629 <ideinit+0x90> ioapicenable(IRQ_IDE, ncpu - 1); idewait(0); // Check if disk 1 is present outb(0x1f6, 0xe0 | (1<<4)); for(i=0; i<1000; i++){ 8010261c: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80102620: 81 7d f4 e7 03 00 00 cmpl $0x3e7,-0xc(%ebp) 80102627: 7e d7 jle 80102600 <ideinit+0x67> break; } } // Switch back to disk 0. outb(0x1f6, 0xe0 | (0<<4)); 80102629: c7 44 24 04 e0 00 00 movl $0xe0,0x4(%esp) 80102630: 00 80102631: c7 04 24 f6 01 00 00 movl $0x1f6,(%esp) 80102638: e8 d5 fe ff ff call 80102512 <outb> } 8010263d: c9 leave 8010263e: c3 ret 8010263f <idestart>: // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 8010263f: 55 push %ebp 80102640: 89 e5 mov %esp,%ebp 80102642: 83 ec 28 sub $0x28,%esp if(b == 0) 80102645: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 80102649: 75 0c jne 80102657 <idestart+0x18> panic("idestart"); 8010264b: c7 04 24 0e 8a 10 80 movl $0x80108a0e,(%esp) 80102652: e8 e3 de ff ff call 8010053a <panic> if(b->blockno >= FSSIZE) 80102657: 8b 45 08 mov 0x8(%ebp),%eax 8010265a: 8b 40 08 mov 0x8(%eax),%eax 8010265d: 3d e7 03 00 00 cmp $0x3e7,%eax 80102662: 76 0c jbe 80102670 <idestart+0x31> panic("incorrect blockno"); 80102664: c7 04 24 17 8a 10 80 movl $0x80108a17,(%esp) 8010266b: e8 ca de ff ff call 8010053a <panic> int sector_per_block = BSIZE/SECTOR_SIZE; 80102670: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) int sector = b->blockno * sector_per_block; 80102677: 8b 45 08 mov 0x8(%ebp),%eax 8010267a: 8b 50 08 mov 0x8(%eax),%edx 8010267d: 8b 45 f4 mov -0xc(%ebp),%eax 80102680: 0f af c2 imul %edx,%eax 80102683: 89 45 f0 mov %eax,-0x10(%ebp) if (sector_per_block > 7) panic("idestart"); 80102686: 83 7d f4 07 cmpl $0x7,-0xc(%ebp) 8010268a: 7e 0c jle 80102698 <idestart+0x59> 8010268c: c7 04 24 0e 8a 10 80 movl $0x80108a0e,(%esp) 80102693: e8 a2 de ff ff call 8010053a <panic> idewait(0); 80102698: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010269f: e8 b1 fe ff ff call 80102555 <idewait> outb(0x3f6, 0); // generate interrupt 801026a4: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801026ab: 00 801026ac: c7 04 24 f6 03 00 00 movl $0x3f6,(%esp) 801026b3: e8 5a fe ff ff call 80102512 <outb> outb(0x1f2, sector_per_block); // number of sectors 801026b8: 8b 45 f4 mov -0xc(%ebp),%eax 801026bb: 0f b6 c0 movzbl %al,%eax 801026be: 89 44 24 04 mov %eax,0x4(%esp) 801026c2: c7 04 24 f2 01 00 00 movl $0x1f2,(%esp) 801026c9: e8 44 fe ff ff call 80102512 <outb> outb(0x1f3, sector & 0xff); 801026ce: 8b 45 f0 mov -0x10(%ebp),%eax 801026d1: 0f b6 c0 movzbl %al,%eax 801026d4: 89 44 24 04 mov %eax,0x4(%esp) 801026d8: c7 04 24 f3 01 00 00 movl $0x1f3,(%esp) 801026df: e8 2e fe ff ff call 80102512 <outb> outb(0x1f4, (sector >> 8) & 0xff); 801026e4: 8b 45 f0 mov -0x10(%ebp),%eax 801026e7: c1 f8 08 sar $0x8,%eax 801026ea: 0f b6 c0 movzbl %al,%eax 801026ed: 89 44 24 04 mov %eax,0x4(%esp) 801026f1: c7 04 24 f4 01 00 00 movl $0x1f4,(%esp) 801026f8: e8 15 fe ff ff call 80102512 <outb> outb(0x1f5, (sector >> 16) & 0xff); 801026fd: 8b 45 f0 mov -0x10(%ebp),%eax 80102700: c1 f8 10 sar $0x10,%eax 80102703: 0f b6 c0 movzbl %al,%eax 80102706: 89 44 24 04 mov %eax,0x4(%esp) 8010270a: c7 04 24 f5 01 00 00 movl $0x1f5,(%esp) 80102711: e8 fc fd ff ff call 80102512 <outb> outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); 80102716: 8b 45 08 mov 0x8(%ebp),%eax 80102719: 8b 40 04 mov 0x4(%eax),%eax 8010271c: 83 e0 01 and $0x1,%eax 8010271f: c1 e0 04 shl $0x4,%eax 80102722: 89 c2 mov %eax,%edx 80102724: 8b 45 f0 mov -0x10(%ebp),%eax 80102727: c1 f8 18 sar $0x18,%eax 8010272a: 83 e0 0f and $0xf,%eax 8010272d: 09 d0 or %edx,%eax 8010272f: 83 c8 e0 or $0xffffffe0,%eax 80102732: 0f b6 c0 movzbl %al,%eax 80102735: 89 44 24 04 mov %eax,0x4(%esp) 80102739: c7 04 24 f6 01 00 00 movl $0x1f6,(%esp) 80102740: e8 cd fd ff ff call 80102512 <outb> if(b->flags & B_DIRTY){ 80102745: 8b 45 08 mov 0x8(%ebp),%eax 80102748: 8b 00 mov (%eax),%eax 8010274a: 83 e0 04 and $0x4,%eax 8010274d: 85 c0 test %eax,%eax 8010274f: 74 34 je 80102785 <idestart+0x146> outb(0x1f7, IDE_CMD_WRITE); 80102751: c7 44 24 04 30 00 00 movl $0x30,0x4(%esp) 80102758: 00 80102759: c7 04 24 f7 01 00 00 movl $0x1f7,(%esp) 80102760: e8 ad fd ff ff call 80102512 <outb> outsl(0x1f0, b->data, BSIZE/4); 80102765: 8b 45 08 mov 0x8(%ebp),%eax 80102768: 83 c0 18 add $0x18,%eax 8010276b: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) 80102772: 00 80102773: 89 44 24 04 mov %eax,0x4(%esp) 80102777: c7 04 24 f0 01 00 00 movl $0x1f0,(%esp) 8010277e: e8 ad fd ff ff call 80102530 <outsl> 80102783: eb 14 jmp 80102799 <idestart+0x15a> } else { outb(0x1f7, IDE_CMD_READ); 80102785: c7 44 24 04 20 00 00 movl $0x20,0x4(%esp) 8010278c: 00 8010278d: c7 04 24 f7 01 00 00 movl $0x1f7,(%esp) 80102794: e8 79 fd ff ff call 80102512 <outb> } } 80102799: c9 leave 8010279a: c3 ret 8010279b <ideintr>: // Interrupt handler. void ideintr(void) { 8010279b: 55 push %ebp 8010279c: 89 e5 mov %esp,%ebp 8010279e: 83 ec 28 sub $0x28,%esp struct buf *b; // First queued buffer is the active request. acquire(&idelock); 801027a1: c7 04 24 00 b6 10 80 movl $0x8010b600,(%esp) 801027a8: e8 12 2a 00 00 call 801051bf <acquire> if((b = idequeue) == 0){ 801027ad: a1 34 b6 10 80 mov 0x8010b634,%eax 801027b2: 89 45 f4 mov %eax,-0xc(%ebp) 801027b5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801027b9: 75 11 jne 801027cc <ideintr+0x31> release(&idelock); 801027bb: c7 04 24 00 b6 10 80 movl $0x8010b600,(%esp) 801027c2: e8 5a 2a 00 00 call 80105221 <release> // cprintf("spurious IDE interrupt\n"); return; 801027c7: e9 90 00 00 00 jmp 8010285c <ideintr+0xc1> } idequeue = b->qnext; 801027cc: 8b 45 f4 mov -0xc(%ebp),%eax 801027cf: 8b 40 14 mov 0x14(%eax),%eax 801027d2: a3 34 b6 10 80 mov %eax,0x8010b634 // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) 801027d7: 8b 45 f4 mov -0xc(%ebp),%eax 801027da: 8b 00 mov (%eax),%eax 801027dc: 83 e0 04 and $0x4,%eax 801027df: 85 c0 test %eax,%eax 801027e1: 75 2e jne 80102811 <ideintr+0x76> 801027e3: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801027ea: e8 66 fd ff ff call 80102555 <idewait> 801027ef: 85 c0 test %eax,%eax 801027f1: 78 1e js 80102811 <ideintr+0x76> insl(0x1f0, b->data, BSIZE/4); 801027f3: 8b 45 f4 mov -0xc(%ebp),%eax 801027f6: 83 c0 18 add $0x18,%eax 801027f9: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) 80102800: 00 80102801: 89 44 24 04 mov %eax,0x4(%esp) 80102805: c7 04 24 f0 01 00 00 movl $0x1f0,(%esp) 8010280c: e8 dc fc ff ff call 801024ed <insl> // Wake process waiting for this buf. b->flags |= B_VALID; 80102811: 8b 45 f4 mov -0xc(%ebp),%eax 80102814: 8b 00 mov (%eax),%eax 80102816: 83 c8 02 or $0x2,%eax 80102819: 89 c2 mov %eax,%edx 8010281b: 8b 45 f4 mov -0xc(%ebp),%eax 8010281e: 89 10 mov %edx,(%eax) b->flags &= ~B_DIRTY; 80102820: 8b 45 f4 mov -0xc(%ebp),%eax 80102823: 8b 00 mov (%eax),%eax 80102825: 83 e0 fb and $0xfffffffb,%eax 80102828: 89 c2 mov %eax,%edx 8010282a: 8b 45 f4 mov -0xc(%ebp),%eax 8010282d: 89 10 mov %edx,(%eax) wakeup(b); 8010282f: 8b 45 f4 mov -0xc(%ebp),%eax 80102832: 89 04 24 mov %eax,(%esp) 80102835: e8 90 24 00 00 call 80104cca <wakeup> // Start disk on next buf in queue. if(idequeue != 0) 8010283a: a1 34 b6 10 80 mov 0x8010b634,%eax 8010283f: 85 c0 test %eax,%eax 80102841: 74 0d je 80102850 <ideintr+0xb5> idestart(idequeue); 80102843: a1 34 b6 10 80 mov 0x8010b634,%eax 80102848: 89 04 24 mov %eax,(%esp) 8010284b: e8 ef fd ff ff call 8010263f <idestart> release(&idelock); 80102850: c7 04 24 00 b6 10 80 movl $0x8010b600,(%esp) 80102857: e8 c5 29 00 00 call 80105221 <release> } 8010285c: c9 leave 8010285d: c3 ret 8010285e <iderw>: // Sync buf with disk. // If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. // Else if B_VALID is not set, read buf from disk, set B_VALID. void iderw(struct buf *b) { 8010285e: 55 push %ebp 8010285f: 89 e5 mov %esp,%ebp 80102861: 83 ec 28 sub $0x28,%esp struct buf **pp; if(!(b->flags & B_BUSY)) 80102864: 8b 45 08 mov 0x8(%ebp),%eax 80102867: 8b 00 mov (%eax),%eax 80102869: 83 e0 01 and $0x1,%eax 8010286c: 85 c0 test %eax,%eax 8010286e: 75 0c jne 8010287c <iderw+0x1e> panic("iderw: buf not busy"); 80102870: c7 04 24 29 8a 10 80 movl $0x80108a29,(%esp) 80102877: e8 be dc ff ff call 8010053a <panic> if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) 8010287c: 8b 45 08 mov 0x8(%ebp),%eax 8010287f: 8b 00 mov (%eax),%eax 80102881: 83 e0 06 and $0x6,%eax 80102884: 83 f8 02 cmp $0x2,%eax 80102887: 75 0c jne 80102895 <iderw+0x37> panic("iderw: nothing to do"); 80102889: c7 04 24 3d 8a 10 80 movl $0x80108a3d,(%esp) 80102890: e8 a5 dc ff ff call 8010053a <panic> if(b->dev != 0 && !havedisk1) 80102895: 8b 45 08 mov 0x8(%ebp),%eax 80102898: 8b 40 04 mov 0x4(%eax),%eax 8010289b: 85 c0 test %eax,%eax 8010289d: 74 15 je 801028b4 <iderw+0x56> 8010289f: a1 38 b6 10 80 mov 0x8010b638,%eax 801028a4: 85 c0 test %eax,%eax 801028a6: 75 0c jne 801028b4 <iderw+0x56> panic("iderw: ide disk 1 not present"); 801028a8: c7 04 24 52 8a 10 80 movl $0x80108a52,(%esp) 801028af: e8 86 dc ff ff call 8010053a <panic> acquire(&idelock); //DOC:acquire-lock 801028b4: c7 04 24 00 b6 10 80 movl $0x8010b600,(%esp) 801028bb: e8 ff 28 00 00 call 801051bf <acquire> // Append b to idequeue. b->qnext = 0; 801028c0: 8b 45 08 mov 0x8(%ebp),%eax 801028c3: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 801028ca: c7 45 f4 34 b6 10 80 movl $0x8010b634,-0xc(%ebp) 801028d1: eb 0b jmp 801028de <iderw+0x80> 801028d3: 8b 45 f4 mov -0xc(%ebp),%eax 801028d6: 8b 00 mov (%eax),%eax 801028d8: 83 c0 14 add $0x14,%eax 801028db: 89 45 f4 mov %eax,-0xc(%ebp) 801028de: 8b 45 f4 mov -0xc(%ebp),%eax 801028e1: 8b 00 mov (%eax),%eax 801028e3: 85 c0 test %eax,%eax 801028e5: 75 ec jne 801028d3 <iderw+0x75> ; *pp = b; 801028e7: 8b 45 f4 mov -0xc(%ebp),%eax 801028ea: 8b 55 08 mov 0x8(%ebp),%edx 801028ed: 89 10 mov %edx,(%eax) // Start disk if necessary. if(idequeue == b) 801028ef: a1 34 b6 10 80 mov 0x8010b634,%eax 801028f4: 3b 45 08 cmp 0x8(%ebp),%eax 801028f7: 75 0d jne 80102906 <iderw+0xa8> idestart(b); 801028f9: 8b 45 08 mov 0x8(%ebp),%eax 801028fc: 89 04 24 mov %eax,(%esp) 801028ff: e8 3b fd ff ff call 8010263f <idestart> // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 80102904: eb 15 jmp 8010291b <iderw+0xbd> 80102906: eb 13 jmp 8010291b <iderw+0xbd> sleep(b, &idelock); 80102908: c7 44 24 04 00 b6 10 movl $0x8010b600,0x4(%esp) 8010290f: 80 80102910: 8b 45 08 mov 0x8(%ebp),%eax 80102913: 89 04 24 mov %eax,(%esp) 80102916: e8 d6 22 00 00 call 80104bf1 <sleep> // Start disk if necessary. if(idequeue == b) idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 8010291b: 8b 45 08 mov 0x8(%ebp),%eax 8010291e: 8b 00 mov (%eax),%eax 80102920: 83 e0 06 and $0x6,%eax 80102923: 83 f8 02 cmp $0x2,%eax 80102926: 75 e0 jne 80102908 <iderw+0xaa> sleep(b, &idelock); } release(&idelock); 80102928: c7 04 24 00 b6 10 80 movl $0x8010b600,(%esp) 8010292f: e8 ed 28 00 00 call 80105221 <release> } 80102934: c9 leave 80102935: c3 ret 80102936: 66 90 xchg %ax,%ax 80102938 <ioapicread>: uint data; }; static uint ioapicread(int reg) { 80102938: 55 push %ebp 80102939: 89 e5 mov %esp,%ebp ioapic->reg = reg; 8010293b: a1 14 22 11 80 mov 0x80112214,%eax 80102940: 8b 55 08 mov 0x8(%ebp),%edx 80102943: 89 10 mov %edx,(%eax) return ioapic->data; 80102945: a1 14 22 11 80 mov 0x80112214,%eax 8010294a: 8b 40 10 mov 0x10(%eax),%eax } 8010294d: 5d pop %ebp 8010294e: c3 ret 8010294f <ioapicwrite>: static void ioapicwrite(int reg, uint data) { 8010294f: 55 push %ebp 80102950: 89 e5 mov %esp,%ebp ioapic->reg = reg; 80102952: a1 14 22 11 80 mov 0x80112214,%eax 80102957: 8b 55 08 mov 0x8(%ebp),%edx 8010295a: 89 10 mov %edx,(%eax) ioapic->data = data; 8010295c: a1 14 22 11 80 mov 0x80112214,%eax 80102961: 8b 55 0c mov 0xc(%ebp),%edx 80102964: 89 50 10 mov %edx,0x10(%eax) } 80102967: 5d pop %ebp 80102968: c3 ret 80102969 <ioapicinit>: void ioapicinit(void) { 80102969: 55 push %ebp 8010296a: 89 e5 mov %esp,%ebp 8010296c: 83 ec 28 sub $0x28,%esp int i, id, maxintr; if(!ismp) 8010296f: a1 44 23 11 80 mov 0x80112344,%eax 80102974: 85 c0 test %eax,%eax 80102976: 75 05 jne 8010297d <ioapicinit+0x14> return; 80102978: e9 9d 00 00 00 jmp 80102a1a <ioapicinit+0xb1> ioapic = (volatile struct ioapic*)IOAPIC; 8010297d: c7 05 14 22 11 80 00 movl $0xfec00000,0x80112214 80102984: 00 c0 fe maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; 80102987: c7 04 24 01 00 00 00 movl $0x1,(%esp) 8010298e: e8 a5 ff ff ff call 80102938 <ioapicread> 80102993: c1 e8 10 shr $0x10,%eax 80102996: 25 ff 00 00 00 and $0xff,%eax 8010299b: 89 45 f0 mov %eax,-0x10(%ebp) id = ioapicread(REG_ID) >> 24; 8010299e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801029a5: e8 8e ff ff ff call 80102938 <ioapicread> 801029aa: c1 e8 18 shr $0x18,%eax 801029ad: 89 45 ec mov %eax,-0x14(%ebp) if(id != ioapicid) 801029b0: 0f b6 05 40 23 11 80 movzbl 0x80112340,%eax 801029b7: 0f b6 c0 movzbl %al,%eax 801029ba: 3b 45 ec cmp -0x14(%ebp),%eax 801029bd: 74 0c je 801029cb <ioapicinit+0x62> cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); 801029bf: c7 04 24 70 8a 10 80 movl $0x80108a70,(%esp) 801029c6: e8 d5 d9 ff ff call 801003a0 <cprintf> // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 801029cb: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 801029d2: eb 3e jmp 80102a12 <ioapicinit+0xa9> ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); 801029d4: 8b 45 f4 mov -0xc(%ebp),%eax 801029d7: 83 c0 20 add $0x20,%eax 801029da: 0d 00 00 01 00 or $0x10000,%eax 801029df: 8b 55 f4 mov -0xc(%ebp),%edx 801029e2: 83 c2 08 add $0x8,%edx 801029e5: 01 d2 add %edx,%edx 801029e7: 89 44 24 04 mov %eax,0x4(%esp) 801029eb: 89 14 24 mov %edx,(%esp) 801029ee: e8 5c ff ff ff call 8010294f <ioapicwrite> ioapicwrite(REG_TABLE+2*i+1, 0); 801029f3: 8b 45 f4 mov -0xc(%ebp),%eax 801029f6: 83 c0 08 add $0x8,%eax 801029f9: 01 c0 add %eax,%eax 801029fb: 83 c0 01 add $0x1,%eax 801029fe: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80102a05: 00 80102a06: 89 04 24 mov %eax,(%esp) 80102a09: e8 41 ff ff ff call 8010294f <ioapicwrite> if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 80102a0e: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80102a12: 8b 45 f4 mov -0xc(%ebp),%eax 80102a15: 3b 45 f0 cmp -0x10(%ebp),%eax 80102a18: 7e ba jle 801029d4 <ioapicinit+0x6b> ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); ioapicwrite(REG_TABLE+2*i+1, 0); } } 80102a1a: c9 leave 80102a1b: c3 ret 80102a1c <ioapicenable>: void ioapicenable(int irq, int cpunum) { 80102a1c: 55 push %ebp 80102a1d: 89 e5 mov %esp,%ebp 80102a1f: 83 ec 08 sub $0x8,%esp if(!ismp) 80102a22: a1 44 23 11 80 mov 0x80112344,%eax 80102a27: 85 c0 test %eax,%eax 80102a29: 75 02 jne 80102a2d <ioapicenable+0x11> return; 80102a2b: eb 37 jmp 80102a64 <ioapicenable+0x48> // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); 80102a2d: 8b 45 08 mov 0x8(%ebp),%eax 80102a30: 83 c0 20 add $0x20,%eax 80102a33: 8b 55 08 mov 0x8(%ebp),%edx 80102a36: 83 c2 08 add $0x8,%edx 80102a39: 01 d2 add %edx,%edx 80102a3b: 89 44 24 04 mov %eax,0x4(%esp) 80102a3f: 89 14 24 mov %edx,(%esp) 80102a42: e8 08 ff ff ff call 8010294f <ioapicwrite> ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 80102a47: 8b 45 0c mov 0xc(%ebp),%eax 80102a4a: c1 e0 18 shl $0x18,%eax 80102a4d: 8b 55 08 mov 0x8(%ebp),%edx 80102a50: 83 c2 08 add $0x8,%edx 80102a53: 01 d2 add %edx,%edx 80102a55: 83 c2 01 add $0x1,%edx 80102a58: 89 44 24 04 mov %eax,0x4(%esp) 80102a5c: 89 14 24 mov %edx,(%esp) 80102a5f: e8 eb fe ff ff call 8010294f <ioapicwrite> } 80102a64: c9 leave 80102a65: c3 ret 80102a66: 66 90 xchg %ax,%ax 80102a68 <v2p>: #define KERNBASE 0x80000000 // First kernel virtual address #define KERNLINK (KERNBASE+EXTMEM) // Address where kernel is linked #ifndef __ASSEMBLER__ static inline uint v2p(void *a) { return ((uint) (a)) - KERNBASE; } 80102a68: 55 push %ebp 80102a69: 89 e5 mov %esp,%ebp 80102a6b: 8b 45 08 mov 0x8(%ebp),%eax 80102a6e: 05 00 00 00 80 add $0x80000000,%eax 80102a73: 5d pop %ebp 80102a74: c3 ret 80102a75 <kinit1>: // the pages mapped by entrypgdir on free list. // 2. main() calls kinit2() with the rest of the physical pages // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { 80102a75: 55 push %ebp 80102a76: 89 e5 mov %esp,%ebp 80102a78: 83 ec 18 sub $0x18,%esp initlock(&kmem.lock, "kmem"); 80102a7b: c7 44 24 04 a2 8a 10 movl $0x80108aa2,0x4(%esp) 80102a82: 80 80102a83: c7 04 24 20 22 11 80 movl $0x80112220,(%esp) 80102a8a: e8 0f 27 00 00 call 8010519e <initlock> kmem.use_lock = 0; 80102a8f: c7 05 54 22 11 80 00 movl $0x0,0x80112254 80102a96: 00 00 00 freerange(vstart, vend); 80102a99: 8b 45 0c mov 0xc(%ebp),%eax 80102a9c: 89 44 24 04 mov %eax,0x4(%esp) 80102aa0: 8b 45 08 mov 0x8(%ebp),%eax 80102aa3: 89 04 24 mov %eax,(%esp) 80102aa6: e8 26 00 00 00 call 80102ad1 <freerange> } 80102aab: c9 leave 80102aac: c3 ret 80102aad <kinit2>: void kinit2(void *vstart, void *vend) { 80102aad: 55 push %ebp 80102aae: 89 e5 mov %esp,%ebp 80102ab0: 83 ec 18 sub $0x18,%esp freerange(vstart, vend); 80102ab3: 8b 45 0c mov 0xc(%ebp),%eax 80102ab6: 89 44 24 04 mov %eax,0x4(%esp) 80102aba: 8b 45 08 mov 0x8(%ebp),%eax 80102abd: 89 04 24 mov %eax,(%esp) 80102ac0: e8 0c 00 00 00 call 80102ad1 <freerange> kmem.use_lock = 1; 80102ac5: c7 05 54 22 11 80 01 movl $0x1,0x80112254 80102acc: 00 00 00 } 80102acf: c9 leave 80102ad0: c3 ret 80102ad1 <freerange>: void freerange(void *vstart, void *vend) { 80102ad1: 55 push %ebp 80102ad2: 89 e5 mov %esp,%ebp 80102ad4: 83 ec 28 sub $0x28,%esp char *p; p = (char*)PGROUNDUP((uint)vstart); 80102ad7: 8b 45 08 mov 0x8(%ebp),%eax 80102ada: 05 ff 0f 00 00 add $0xfff,%eax 80102adf: 25 00 f0 ff ff and $0xfffff000,%eax 80102ae4: 89 45 f4 mov %eax,-0xc(%ebp) for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102ae7: eb 12 jmp 80102afb <freerange+0x2a> kfree(p); 80102ae9: 8b 45 f4 mov -0xc(%ebp),%eax 80102aec: 89 04 24 mov %eax,(%esp) 80102aef: e8 16 00 00 00 call 80102b0a <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102af4: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) 80102afb: 8b 45 f4 mov -0xc(%ebp),%eax 80102afe: 05 00 10 00 00 add $0x1000,%eax 80102b03: 3b 45 0c cmp 0xc(%ebp),%eax 80102b06: 76 e1 jbe 80102ae9 <freerange+0x18> kfree(p); } 80102b08: c9 leave 80102b09: c3 ret 80102b0a <kfree>: // which normally should have been returned by a // call to kalloc(). (The exception is when // initializing the allocator; see kinit above.) void kfree(char *v) { 80102b0a: 55 push %ebp 80102b0b: 89 e5 mov %esp,%ebp 80102b0d: 83 ec 28 sub $0x28,%esp struct run *r; if((uint)v % PGSIZE || v < end || v2p(v) >= PHYSTOP) 80102b10: 8b 45 08 mov 0x8(%ebp),%eax 80102b13: 25 ff 0f 00 00 and $0xfff,%eax 80102b18: 85 c0 test %eax,%eax 80102b1a: 75 1b jne 80102b37 <kfree+0x2d> 80102b1c: 81 7d 08 3c 51 11 80 cmpl $0x8011513c,0x8(%ebp) 80102b23: 72 12 jb 80102b37 <kfree+0x2d> 80102b25: 8b 45 08 mov 0x8(%ebp),%eax 80102b28: 89 04 24 mov %eax,(%esp) 80102b2b: e8 38 ff ff ff call 80102a68 <v2p> 80102b30: 3d ff ff ff 0d cmp $0xdffffff,%eax 80102b35: 76 0c jbe 80102b43 <kfree+0x39> panic("kfree"); 80102b37: c7 04 24 a7 8a 10 80 movl $0x80108aa7,(%esp) 80102b3e: e8 f7 d9 ff ff call 8010053a <panic> // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); 80102b43: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80102b4a: 00 80102b4b: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80102b52: 00 80102b53: 8b 45 08 mov 0x8(%ebp),%eax 80102b56: 89 04 24 mov %eax,(%esp) 80102b59: e8 b8 28 00 00 call 80105416 <memset> if(kmem.use_lock) 80102b5e: a1 54 22 11 80 mov 0x80112254,%eax 80102b63: 85 c0 test %eax,%eax 80102b65: 74 0c je 80102b73 <kfree+0x69> acquire(&kmem.lock); 80102b67: c7 04 24 20 22 11 80 movl $0x80112220,(%esp) 80102b6e: e8 4c 26 00 00 call 801051bf <acquire> r = (struct run*)v; 80102b73: 8b 45 08 mov 0x8(%ebp),%eax 80102b76: 89 45 f4 mov %eax,-0xc(%ebp) r->next = kmem.freelist; 80102b79: 8b 15 58 22 11 80 mov 0x80112258,%edx 80102b7f: 8b 45 f4 mov -0xc(%ebp),%eax 80102b82: 89 10 mov %edx,(%eax) kmem.freelist = r; 80102b84: 8b 45 f4 mov -0xc(%ebp),%eax 80102b87: a3 58 22 11 80 mov %eax,0x80112258 if(kmem.use_lock) 80102b8c: a1 54 22 11 80 mov 0x80112254,%eax 80102b91: 85 c0 test %eax,%eax 80102b93: 74 0c je 80102ba1 <kfree+0x97> release(&kmem.lock); 80102b95: c7 04 24 20 22 11 80 movl $0x80112220,(%esp) 80102b9c: e8 80 26 00 00 call 80105221 <release> } 80102ba1: c9 leave 80102ba2: c3 ret 80102ba3 <kalloc>: // Allocate one 4096-byte page of physical memory. // Returns a pointer that the kernel can use. // Returns 0 if the memory cannot be allocated. char* kalloc(void) { 80102ba3: 55 push %ebp 80102ba4: 89 e5 mov %esp,%ebp 80102ba6: 83 ec 28 sub $0x28,%esp struct run *r; if(kmem.use_lock) 80102ba9: a1 54 22 11 80 mov 0x80112254,%eax 80102bae: 85 c0 test %eax,%eax 80102bb0: 74 0c je 80102bbe <kalloc+0x1b> acquire(&kmem.lock); 80102bb2: c7 04 24 20 22 11 80 movl $0x80112220,(%esp) 80102bb9: e8 01 26 00 00 call 801051bf <acquire> r = kmem.freelist; 80102bbe: a1 58 22 11 80 mov 0x80112258,%eax 80102bc3: 89 45 f4 mov %eax,-0xc(%ebp) if(r) 80102bc6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80102bca: 74 0a je 80102bd6 <kalloc+0x33> kmem.freelist = r->next; 80102bcc: 8b 45 f4 mov -0xc(%ebp),%eax 80102bcf: 8b 00 mov (%eax),%eax 80102bd1: a3 58 22 11 80 mov %eax,0x80112258 if(kmem.use_lock) 80102bd6: a1 54 22 11 80 mov 0x80112254,%eax 80102bdb: 85 c0 test %eax,%eax 80102bdd: 74 0c je 80102beb <kalloc+0x48> release(&kmem.lock); 80102bdf: c7 04 24 20 22 11 80 movl $0x80112220,(%esp) 80102be6: e8 36 26 00 00 call 80105221 <release> return (char*)r; 80102beb: 8b 45 f4 mov -0xc(%ebp),%eax } 80102bee: c9 leave 80102bef: c3 ret 80102bf0 <inb>: // Routines to let C code use special x86 instructions. static inline uchar inb(ushort port) { 80102bf0: 55 push %ebp 80102bf1: 89 e5 mov %esp,%ebp 80102bf3: 83 ec 14 sub $0x14,%esp 80102bf6: 8b 45 08 mov 0x8(%ebp),%eax 80102bf9: 66 89 45 ec mov %ax,-0x14(%ebp) uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102bfd: 0f b7 45 ec movzwl -0x14(%ebp),%eax 80102c01: 89 c2 mov %eax,%edx 80102c03: ec in (%dx),%al 80102c04: 88 45 ff mov %al,-0x1(%ebp) return data; 80102c07: 0f b6 45 ff movzbl -0x1(%ebp),%eax } 80102c0b: c9 leave 80102c0c: c3 ret 80102c0d <kbdgetc>: #include "defs.h" #include "kbd.h" int kbdgetc(void) { 80102c0d: 55 push %ebp 80102c0e: 89 e5 mov %esp,%ebp 80102c10: 83 ec 14 sub $0x14,%esp static uchar *charcode[4] = { normalmap, shiftmap, ctlmap, ctlmap }; uint st, data, c; st = inb(KBSTATP); 80102c13: c7 04 24 64 00 00 00 movl $0x64,(%esp) 80102c1a: e8 d1 ff ff ff call 80102bf0 <inb> 80102c1f: 0f b6 c0 movzbl %al,%eax 80102c22: 89 45 f4 mov %eax,-0xc(%ebp) if((st & KBS_DIB) == 0) 80102c25: 8b 45 f4 mov -0xc(%ebp),%eax 80102c28: 83 e0 01 and $0x1,%eax 80102c2b: 85 c0 test %eax,%eax 80102c2d: 75 0a jne 80102c39 <kbdgetc+0x2c> return -1; 80102c2f: b8 ff ff ff ff mov $0xffffffff,%eax 80102c34: e9 25 01 00 00 jmp 80102d5e <kbdgetc+0x151> data = inb(KBDATAP); 80102c39: c7 04 24 60 00 00 00 movl $0x60,(%esp) 80102c40: e8 ab ff ff ff call 80102bf0 <inb> 80102c45: 0f b6 c0 movzbl %al,%eax 80102c48: 89 45 fc mov %eax,-0x4(%ebp) if(data == 0xE0){ 80102c4b: 81 7d fc e0 00 00 00 cmpl $0xe0,-0x4(%ebp) 80102c52: 75 17 jne 80102c6b <kbdgetc+0x5e> shift |= E0ESC; 80102c54: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102c59: 83 c8 40 or $0x40,%eax 80102c5c: a3 3c b6 10 80 mov %eax,0x8010b63c return 0; 80102c61: b8 00 00 00 00 mov $0x0,%eax 80102c66: e9 f3 00 00 00 jmp 80102d5e <kbdgetc+0x151> } else if(data & 0x80){ 80102c6b: 8b 45 fc mov -0x4(%ebp),%eax 80102c6e: 25 80 00 00 00 and $0x80,%eax 80102c73: 85 c0 test %eax,%eax 80102c75: 74 45 je 80102cbc <kbdgetc+0xaf> // Key released data = (shift & E0ESC ? data : data & 0x7F); 80102c77: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102c7c: 83 e0 40 and $0x40,%eax 80102c7f: 85 c0 test %eax,%eax 80102c81: 75 08 jne 80102c8b <kbdgetc+0x7e> 80102c83: 8b 45 fc mov -0x4(%ebp),%eax 80102c86: 83 e0 7f and $0x7f,%eax 80102c89: eb 03 jmp 80102c8e <kbdgetc+0x81> 80102c8b: 8b 45 fc mov -0x4(%ebp),%eax 80102c8e: 89 45 fc mov %eax,-0x4(%ebp) shift &= ~(shiftcode[data] | E0ESC); 80102c91: 8b 45 fc mov -0x4(%ebp),%eax 80102c94: 05 20 90 10 80 add $0x80109020,%eax 80102c99: 0f b6 00 movzbl (%eax),%eax 80102c9c: 83 c8 40 or $0x40,%eax 80102c9f: 0f b6 c0 movzbl %al,%eax 80102ca2: f7 d0 not %eax 80102ca4: 89 c2 mov %eax,%edx 80102ca6: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102cab: 21 d0 and %edx,%eax 80102cad: a3 3c b6 10 80 mov %eax,0x8010b63c return 0; 80102cb2: b8 00 00 00 00 mov $0x0,%eax 80102cb7: e9 a2 00 00 00 jmp 80102d5e <kbdgetc+0x151> } else if(shift & E0ESC){ 80102cbc: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102cc1: 83 e0 40 and $0x40,%eax 80102cc4: 85 c0 test %eax,%eax 80102cc6: 74 14 je 80102cdc <kbdgetc+0xcf> // Last character was an E0 escape; or with 0x80 data |= 0x80; 80102cc8: 81 4d fc 80 00 00 00 orl $0x80,-0x4(%ebp) shift &= ~E0ESC; 80102ccf: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102cd4: 83 e0 bf and $0xffffffbf,%eax 80102cd7: a3 3c b6 10 80 mov %eax,0x8010b63c } shift |= shiftcode[data]; 80102cdc: 8b 45 fc mov -0x4(%ebp),%eax 80102cdf: 05 20 90 10 80 add $0x80109020,%eax 80102ce4: 0f b6 00 movzbl (%eax),%eax 80102ce7: 0f b6 d0 movzbl %al,%edx 80102cea: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102cef: 09 d0 or %edx,%eax 80102cf1: a3 3c b6 10 80 mov %eax,0x8010b63c shift ^= togglecode[data]; 80102cf6: 8b 45 fc mov -0x4(%ebp),%eax 80102cf9: 05 20 91 10 80 add $0x80109120,%eax 80102cfe: 0f b6 00 movzbl (%eax),%eax 80102d01: 0f b6 d0 movzbl %al,%edx 80102d04: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102d09: 31 d0 xor %edx,%eax 80102d0b: a3 3c b6 10 80 mov %eax,0x8010b63c c = charcode[shift & (CTL | SHIFT)][data]; 80102d10: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102d15: 83 e0 03 and $0x3,%eax 80102d18: 8b 14 85 20 95 10 80 mov -0x7fef6ae0(,%eax,4),%edx 80102d1f: 8b 45 fc mov -0x4(%ebp),%eax 80102d22: 01 d0 add %edx,%eax 80102d24: 0f b6 00 movzbl (%eax),%eax 80102d27: 0f b6 c0 movzbl %al,%eax 80102d2a: 89 45 f8 mov %eax,-0x8(%ebp) if(shift & CAPSLOCK){ 80102d2d: a1 3c b6 10 80 mov 0x8010b63c,%eax 80102d32: 83 e0 08 and $0x8,%eax 80102d35: 85 c0 test %eax,%eax 80102d37: 74 22 je 80102d5b <kbdgetc+0x14e> if('a' <= c && c <= 'z') 80102d39: 83 7d f8 60 cmpl $0x60,-0x8(%ebp) 80102d3d: 76 0c jbe 80102d4b <kbdgetc+0x13e> 80102d3f: 83 7d f8 7a cmpl $0x7a,-0x8(%ebp) 80102d43: 77 06 ja 80102d4b <kbdgetc+0x13e> c += 'A' - 'a'; 80102d45: 83 6d f8 20 subl $0x20,-0x8(%ebp) 80102d49: eb 10 jmp 80102d5b <kbdgetc+0x14e> else if('A' <= c && c <= 'Z') 80102d4b: 83 7d f8 40 cmpl $0x40,-0x8(%ebp) 80102d4f: 76 0a jbe 80102d5b <kbdgetc+0x14e> 80102d51: 83 7d f8 5a cmpl $0x5a,-0x8(%ebp) 80102d55: 77 04 ja 80102d5b <kbdgetc+0x14e> c += 'a' - 'A'; 80102d57: 83 45 f8 20 addl $0x20,-0x8(%ebp) } return c; 80102d5b: 8b 45 f8 mov -0x8(%ebp),%eax } 80102d5e: c9 leave 80102d5f: c3 ret 80102d60 <kbdintr>: void kbdintr(void) { 80102d60: 55 push %ebp 80102d61: 89 e5 mov %esp,%ebp 80102d63: 83 ec 18 sub $0x18,%esp consoleintr(kbdgetc); 80102d66: c7 04 24 0d 2c 10 80 movl $0x80102c0d,(%esp) 80102d6d: e8 56 da ff ff call 801007c8 <consoleintr> } 80102d72: c9 leave 80102d73: c3 ret 80102d74 <inb>: // Routines to let C code use special x86 instructions. static inline uchar inb(ushort port) { 80102d74: 55 push %ebp 80102d75: 89 e5 mov %esp,%ebp 80102d77: 83 ec 14 sub $0x14,%esp 80102d7a: 8b 45 08 mov 0x8(%ebp),%eax 80102d7d: 66 89 45 ec mov %ax,-0x14(%ebp) uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102d81: 0f b7 45 ec movzwl -0x14(%ebp),%eax 80102d85: 89 c2 mov %eax,%edx 80102d87: ec in (%dx),%al 80102d88: 88 45 ff mov %al,-0x1(%ebp) return data; 80102d8b: 0f b6 45 ff movzbl -0x1(%ebp),%eax } 80102d8f: c9 leave 80102d90: c3 ret 80102d91 <outb>: "memory", "cc"); } static inline void outb(ushort port, uchar data) { 80102d91: 55 push %ebp 80102d92: 89 e5 mov %esp,%ebp 80102d94: 83 ec 08 sub $0x8,%esp 80102d97: 8b 55 08 mov 0x8(%ebp),%edx 80102d9a: 8b 45 0c mov 0xc(%ebp),%eax 80102d9d: 66 89 55 fc mov %dx,-0x4(%ebp) 80102da1: 88 45 f8 mov %al,-0x8(%ebp) asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102da4: 0f b6 45 f8 movzbl -0x8(%ebp),%eax 80102da8: 0f b7 55 fc movzwl -0x4(%ebp),%edx 80102dac: ee out %al,(%dx) } 80102dad: c9 leave 80102dae: c3 ret 80102daf <readeflags>: asm volatile("ltr %0" : : "r" (sel)); } static inline uint readeflags(void) { 80102daf: 55 push %ebp 80102db0: 89 e5 mov %esp,%ebp 80102db2: 83 ec 10 sub $0x10,%esp uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80102db5: 9c pushf 80102db6: 58 pop %eax 80102db7: 89 45 fc mov %eax,-0x4(%ebp) return eflags; 80102dba: 8b 45 fc mov -0x4(%ebp),%eax } 80102dbd: c9 leave 80102dbe: c3 ret 80102dbf <lapicw>: volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { 80102dbf: 55 push %ebp 80102dc0: 89 e5 mov %esp,%ebp lapic[index] = value; 80102dc2: a1 5c 22 11 80 mov 0x8011225c,%eax 80102dc7: 8b 55 08 mov 0x8(%ebp),%edx 80102dca: c1 e2 02 shl $0x2,%edx 80102dcd: 01 c2 add %eax,%edx 80102dcf: 8b 45 0c mov 0xc(%ebp),%eax 80102dd2: 89 02 mov %eax,(%edx) lapic[ID]; // wait for write to finish, by reading 80102dd4: a1 5c 22 11 80 mov 0x8011225c,%eax 80102dd9: 83 c0 20 add $0x20,%eax 80102ddc: 8b 00 mov (%eax),%eax } 80102dde: 5d pop %ebp 80102ddf: c3 ret 80102de0 <lapicinit>: //PAGEBREAK! void lapicinit(void) { 80102de0: 55 push %ebp 80102de1: 89 e5 mov %esp,%ebp 80102de3: 83 ec 08 sub $0x8,%esp if(!lapic) 80102de6: a1 5c 22 11 80 mov 0x8011225c,%eax 80102deb: 85 c0 test %eax,%eax 80102ded: 75 05 jne 80102df4 <lapicinit+0x14> return; 80102def: e9 43 01 00 00 jmp 80102f37 <lapicinit+0x157> // Enable local APIC; set spurious interrupt vector. lapicw(SVR, ENABLE | (T_IRQ0 + IRQ_SPURIOUS)); 80102df4: c7 44 24 04 3f 01 00 movl $0x13f,0x4(%esp) 80102dfb: 00 80102dfc: c7 04 24 3c 00 00 00 movl $0x3c,(%esp) 80102e03: e8 b7 ff ff ff call 80102dbf <lapicw> // The timer repeatedly counts down at bus frequency // from lapic[TICR] and then issues an interrupt. // If xv6 cared more about precise timekeeping, // TICR would be calibrated using an external time source. lapicw(TDCR, X1); 80102e08: c7 44 24 04 0b 00 00 movl $0xb,0x4(%esp) 80102e0f: 00 80102e10: c7 04 24 f8 00 00 00 movl $0xf8,(%esp) 80102e17: e8 a3 ff ff ff call 80102dbf <lapicw> lapicw(TIMER, PERIODIC | (T_IRQ0 + IRQ_TIMER)); 80102e1c: c7 44 24 04 20 00 02 movl $0x20020,0x4(%esp) 80102e23: 00 80102e24: c7 04 24 c8 00 00 00 movl $0xc8,(%esp) 80102e2b: e8 8f ff ff ff call 80102dbf <lapicw> lapicw(TICR, 10000000); 80102e30: c7 44 24 04 80 96 98 movl $0x989680,0x4(%esp) 80102e37: 00 80102e38: c7 04 24 e0 00 00 00 movl $0xe0,(%esp) 80102e3f: e8 7b ff ff ff call 80102dbf <lapicw> // Disable logical interrupt lines. lapicw(LINT0, MASKED); 80102e44: c7 44 24 04 00 00 01 movl $0x10000,0x4(%esp) 80102e4b: 00 80102e4c: c7 04 24 d4 00 00 00 movl $0xd4,(%esp) 80102e53: e8 67 ff ff ff call 80102dbf <lapicw> lapicw(LINT1, MASKED); 80102e58: c7 44 24 04 00 00 01 movl $0x10000,0x4(%esp) 80102e5f: 00 80102e60: c7 04 24 d8 00 00 00 movl $0xd8,(%esp) 80102e67: e8 53 ff ff ff call 80102dbf <lapicw> // Disable performance counter overflow interrupts // on machines that provide that interrupt entry. if(((lapic[VER]>>16) & 0xFF) >= 4) 80102e6c: a1 5c 22 11 80 mov 0x8011225c,%eax 80102e71: 83 c0 30 add $0x30,%eax 80102e74: 8b 00 mov (%eax),%eax 80102e76: c1 e8 10 shr $0x10,%eax 80102e79: 0f b6 c0 movzbl %al,%eax 80102e7c: 83 f8 03 cmp $0x3,%eax 80102e7f: 76 14 jbe 80102e95 <lapicinit+0xb5> lapicw(PCINT, MASKED); 80102e81: c7 44 24 04 00 00 01 movl $0x10000,0x4(%esp) 80102e88: 00 80102e89: c7 04 24 d0 00 00 00 movl $0xd0,(%esp) 80102e90: e8 2a ff ff ff call 80102dbf <lapicw> // Map error interrupt to IRQ_ERROR. lapicw(ERROR, T_IRQ0 + IRQ_ERROR); 80102e95: c7 44 24 04 33 00 00 movl $0x33,0x4(%esp) 80102e9c: 00 80102e9d: c7 04 24 dc 00 00 00 movl $0xdc,(%esp) 80102ea4: e8 16 ff ff ff call 80102dbf <lapicw> // Clear error status register (requires back-to-back writes). lapicw(ESR, 0); 80102ea9: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80102eb0: 00 80102eb1: c7 04 24 a0 00 00 00 movl $0xa0,(%esp) 80102eb8: e8 02 ff ff ff call 80102dbf <lapicw> lapicw(ESR, 0); 80102ebd: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80102ec4: 00 80102ec5: c7 04 24 a0 00 00 00 movl $0xa0,(%esp) 80102ecc: e8 ee fe ff ff call 80102dbf <lapicw> // Ack any outstanding interrupts. lapicw(EOI, 0); 80102ed1: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80102ed8: 00 80102ed9: c7 04 24 2c 00 00 00 movl $0x2c,(%esp) 80102ee0: e8 da fe ff ff call 80102dbf <lapicw> // Send an Init Level De-Assert to synchronise arbitration ID's. lapicw(ICRHI, 0); 80102ee5: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80102eec: 00 80102eed: c7 04 24 c4 00 00 00 movl $0xc4,(%esp) 80102ef4: e8 c6 fe ff ff call 80102dbf <lapicw> lapicw(ICRLO, BCAST | INIT | LEVEL); 80102ef9: c7 44 24 04 00 85 08 movl $0x88500,0x4(%esp) 80102f00: 00 80102f01: c7 04 24 c0 00 00 00 movl $0xc0,(%esp) 80102f08: e8 b2 fe ff ff call 80102dbf <lapicw> while(lapic[ICRLO] & DELIVS) 80102f0d: 90 nop 80102f0e: a1 5c 22 11 80 mov 0x8011225c,%eax 80102f13: 05 00 03 00 00 add $0x300,%eax 80102f18: 8b 00 mov (%eax),%eax 80102f1a: 25 00 10 00 00 and $0x1000,%eax 80102f1f: 85 c0 test %eax,%eax 80102f21: 75 eb jne 80102f0e <lapicinit+0x12e> ; // Enable interrupts on the APIC (but not on the processor). lapicw(TPR, 0); 80102f23: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80102f2a: 00 80102f2b: c7 04 24 20 00 00 00 movl $0x20,(%esp) 80102f32: e8 88 fe ff ff call 80102dbf <lapicw> } 80102f37: c9 leave 80102f38: c3 ret 80102f39 <cpunum>: int cpunum(void) { 80102f39: 55 push %ebp 80102f3a: 89 e5 mov %esp,%ebp 80102f3c: 83 ec 18 sub $0x18,%esp // Cannot call cpu when interrupts are enabled: // result not guaranteed to last long enough to be used! // Would prefer to panic but even printing is chancy here: // almost everything, including cprintf and panic, calls cpu, // often indirectly through acquire and release. if(readeflags()&FL_IF){ 80102f3f: e8 6b fe ff ff call 80102daf <readeflags> 80102f44: 25 00 02 00 00 and $0x200,%eax 80102f49: 85 c0 test %eax,%eax 80102f4b: 74 25 je 80102f72 <cpunum+0x39> static int n; if(n++ == 0) 80102f4d: a1 40 b6 10 80 mov 0x8010b640,%eax 80102f52: 8d 50 01 lea 0x1(%eax),%edx 80102f55: 89 15 40 b6 10 80 mov %edx,0x8010b640 80102f5b: 85 c0 test %eax,%eax 80102f5d: 75 13 jne 80102f72 <cpunum+0x39> cprintf("cpu called from %x with interrupts enabled\n", 80102f5f: 8b 45 04 mov 0x4(%ebp),%eax 80102f62: 89 44 24 04 mov %eax,0x4(%esp) 80102f66: c7 04 24 b0 8a 10 80 movl $0x80108ab0,(%esp) 80102f6d: e8 2e d4 ff ff call 801003a0 <cprintf> __builtin_return_address(0)); } if(lapic) 80102f72: a1 5c 22 11 80 mov 0x8011225c,%eax 80102f77: 85 c0 test %eax,%eax 80102f79: 74 0f je 80102f8a <cpunum+0x51> return lapic[ID]>>24; 80102f7b: a1 5c 22 11 80 mov 0x8011225c,%eax 80102f80: 83 c0 20 add $0x20,%eax 80102f83: 8b 00 mov (%eax),%eax 80102f85: c1 e8 18 shr $0x18,%eax 80102f88: eb 05 jmp 80102f8f <cpunum+0x56> return 0; 80102f8a: b8 00 00 00 00 mov $0x0,%eax } 80102f8f: c9 leave 80102f90: c3 ret 80102f91 <lapiceoi>: // Acknowledge interrupt. void lapiceoi(void) { 80102f91: 55 push %ebp 80102f92: 89 e5 mov %esp,%ebp 80102f94: 83 ec 08 sub $0x8,%esp if(lapic) 80102f97: a1 5c 22 11 80 mov 0x8011225c,%eax 80102f9c: 85 c0 test %eax,%eax 80102f9e: 74 14 je 80102fb4 <lapiceoi+0x23> lapicw(EOI, 0); 80102fa0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80102fa7: 00 80102fa8: c7 04 24 2c 00 00 00 movl $0x2c,(%esp) 80102faf: e8 0b fe ff ff call 80102dbf <lapicw> } 80102fb4: c9 leave 80102fb5: c3 ret 80102fb6 <microdelay>: // Spin for a given number of microseconds. // On real hardware would want to tune this dynamically. void microdelay(int us) { 80102fb6: 55 push %ebp 80102fb7: 89 e5 mov %esp,%ebp } 80102fb9: 5d pop %ebp 80102fba: c3 ret 80102fbb <lapicstartap>: // Start additional processor running entry code at addr. // See Appendix B of MultiProcessor Specification. void lapicstartap(uchar apicid, uint addr) { 80102fbb: 55 push %ebp 80102fbc: 89 e5 mov %esp,%ebp 80102fbe: 83 ec 1c sub $0x1c,%esp 80102fc1: 8b 45 08 mov 0x8(%ebp),%eax 80102fc4: 88 45 ec mov %al,-0x14(%ebp) ushort *wrv; // "The BSP must initialize CMOS shutdown code to 0AH // and the warm reset vector (DWORD based at 40:67) to point at // the AP startup code prior to the [universal startup algorithm]." outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code 80102fc7: c7 44 24 04 0f 00 00 movl $0xf,0x4(%esp) 80102fce: 00 80102fcf: c7 04 24 70 00 00 00 movl $0x70,(%esp) 80102fd6: e8 b6 fd ff ff call 80102d91 <outb> outb(CMOS_PORT+1, 0x0A); 80102fdb: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) 80102fe2: 00 80102fe3: c7 04 24 71 00 00 00 movl $0x71,(%esp) 80102fea: e8 a2 fd ff ff call 80102d91 <outb> wrv = (ushort*)P2V((0x40<<4 | 0x67)); // Warm reset vector 80102fef: c7 45 f8 67 04 00 80 movl $0x80000467,-0x8(%ebp) wrv[0] = 0; 80102ff6: 8b 45 f8 mov -0x8(%ebp),%eax 80102ff9: 66 c7 00 00 00 movw $0x0,(%eax) wrv[1] = addr >> 4; 80102ffe: 8b 45 f8 mov -0x8(%ebp),%eax 80103001: 8d 50 02 lea 0x2(%eax),%edx 80103004: 8b 45 0c mov 0xc(%ebp),%eax 80103007: c1 e8 04 shr $0x4,%eax 8010300a: 66 89 02 mov %ax,(%edx) // "Universal startup algorithm." // Send INIT (level-triggered) interrupt to reset other CPU. lapicw(ICRHI, apicid<<24); 8010300d: 0f b6 45 ec movzbl -0x14(%ebp),%eax 80103011: c1 e0 18 shl $0x18,%eax 80103014: 89 44 24 04 mov %eax,0x4(%esp) 80103018: c7 04 24 c4 00 00 00 movl $0xc4,(%esp) 8010301f: e8 9b fd ff ff call 80102dbf <lapicw> lapicw(ICRLO, INIT | LEVEL | ASSERT); 80103024: c7 44 24 04 00 c5 00 movl $0xc500,0x4(%esp) 8010302b: 00 8010302c: c7 04 24 c0 00 00 00 movl $0xc0,(%esp) 80103033: e8 87 fd ff ff call 80102dbf <lapicw> microdelay(200); 80103038: c7 04 24 c8 00 00 00 movl $0xc8,(%esp) 8010303f: e8 72 ff ff ff call 80102fb6 <microdelay> lapicw(ICRLO, INIT | LEVEL); 80103044: c7 44 24 04 00 85 00 movl $0x8500,0x4(%esp) 8010304b: 00 8010304c: c7 04 24 c0 00 00 00 movl $0xc0,(%esp) 80103053: e8 67 fd ff ff call 80102dbf <lapicw> microdelay(100); // should be 10ms, but too slow in Bochs! 80103058: c7 04 24 64 00 00 00 movl $0x64,(%esp) 8010305f: e8 52 ff ff ff call 80102fb6 <microdelay> // Send startup IPI (twice!) to enter code. // Regular hardware is supposed to only accept a STARTUP // when it is in the halted state due to an INIT. So the second // should be ignored, but it is part of the official Intel algorithm. // Bochs complains about the second one. Too bad for Bochs. for(i = 0; i < 2; i++){ 80103064: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 8010306b: eb 40 jmp 801030ad <lapicstartap+0xf2> lapicw(ICRHI, apicid<<24); 8010306d: 0f b6 45 ec movzbl -0x14(%ebp),%eax 80103071: c1 e0 18 shl $0x18,%eax 80103074: 89 44 24 04 mov %eax,0x4(%esp) 80103078: c7 04 24 c4 00 00 00 movl $0xc4,(%esp) 8010307f: e8 3b fd ff ff call 80102dbf <lapicw> lapicw(ICRLO, STARTUP | (addr>>12)); 80103084: 8b 45 0c mov 0xc(%ebp),%eax 80103087: c1 e8 0c shr $0xc,%eax 8010308a: 80 cc 06 or $0x6,%ah 8010308d: 89 44 24 04 mov %eax,0x4(%esp) 80103091: c7 04 24 c0 00 00 00 movl $0xc0,(%esp) 80103098: e8 22 fd ff ff call 80102dbf <lapicw> microdelay(200); 8010309d: c7 04 24 c8 00 00 00 movl $0xc8,(%esp) 801030a4: e8 0d ff ff ff call 80102fb6 <microdelay> // Send startup IPI (twice!) to enter code. // Regular hardware is supposed to only accept a STARTUP // when it is in the halted state due to an INIT. So the second // should be ignored, but it is part of the official Intel algorithm. // Bochs complains about the second one. Too bad for Bochs. for(i = 0; i < 2; i++){ 801030a9: 83 45 fc 01 addl $0x1,-0x4(%ebp) 801030ad: 83 7d fc 01 cmpl $0x1,-0x4(%ebp) 801030b1: 7e ba jle 8010306d <lapicstartap+0xb2> lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); microdelay(200); } } 801030b3: c9 leave 801030b4: c3 ret 801030b5 <cmos_read>: #define DAY 0x07 #define MONTH 0x08 #define YEAR 0x09 static uint cmos_read(uint reg) { 801030b5: 55 push %ebp 801030b6: 89 e5 mov %esp,%ebp 801030b8: 83 ec 08 sub $0x8,%esp outb(CMOS_PORT, reg); 801030bb: 8b 45 08 mov 0x8(%ebp),%eax 801030be: 0f b6 c0 movzbl %al,%eax 801030c1: 89 44 24 04 mov %eax,0x4(%esp) 801030c5: c7 04 24 70 00 00 00 movl $0x70,(%esp) 801030cc: e8 c0 fc ff ff call 80102d91 <outb> microdelay(200); 801030d1: c7 04 24 c8 00 00 00 movl $0xc8,(%esp) 801030d8: e8 d9 fe ff ff call 80102fb6 <microdelay> return inb(CMOS_RETURN); 801030dd: c7 04 24 71 00 00 00 movl $0x71,(%esp) 801030e4: e8 8b fc ff ff call 80102d74 <inb> 801030e9: 0f b6 c0 movzbl %al,%eax } 801030ec: c9 leave 801030ed: c3 ret 801030ee <fill_rtcdate>: static void fill_rtcdate(struct rtcdate *r) { 801030ee: 55 push %ebp 801030ef: 89 e5 mov %esp,%ebp 801030f1: 83 ec 04 sub $0x4,%esp r->second = cmos_read(SECS); 801030f4: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801030fb: e8 b5 ff ff ff call 801030b5 <cmos_read> 80103100: 8b 55 08 mov 0x8(%ebp),%edx 80103103: 89 02 mov %eax,(%edx) r->minute = cmos_read(MINS); 80103105: c7 04 24 02 00 00 00 movl $0x2,(%esp) 8010310c: e8 a4 ff ff ff call 801030b5 <cmos_read> 80103111: 8b 55 08 mov 0x8(%ebp),%edx 80103114: 89 42 04 mov %eax,0x4(%edx) r->hour = cmos_read(HOURS); 80103117: c7 04 24 04 00 00 00 movl $0x4,(%esp) 8010311e: e8 92 ff ff ff call 801030b5 <cmos_read> 80103123: 8b 55 08 mov 0x8(%ebp),%edx 80103126: 89 42 08 mov %eax,0x8(%edx) r->day = cmos_read(DAY); 80103129: c7 04 24 07 00 00 00 movl $0x7,(%esp) 80103130: e8 80 ff ff ff call 801030b5 <cmos_read> 80103135: 8b 55 08 mov 0x8(%ebp),%edx 80103138: 89 42 0c mov %eax,0xc(%edx) r->month = cmos_read(MONTH); 8010313b: c7 04 24 08 00 00 00 movl $0x8,(%esp) 80103142: e8 6e ff ff ff call 801030b5 <cmos_read> 80103147: 8b 55 08 mov 0x8(%ebp),%edx 8010314a: 89 42 10 mov %eax,0x10(%edx) r->year = cmos_read(YEAR); 8010314d: c7 04 24 09 00 00 00 movl $0x9,(%esp) 80103154: e8 5c ff ff ff call 801030b5 <cmos_read> 80103159: 8b 55 08 mov 0x8(%ebp),%edx 8010315c: 89 42 14 mov %eax,0x14(%edx) } 8010315f: c9 leave 80103160: c3 ret 80103161 <cmostime>: // qemu seems to use 24-hour GWT and the values are BCD encoded void cmostime(struct rtcdate *r) { 80103161: 55 push %ebp 80103162: 89 e5 mov %esp,%ebp 80103164: 83 ec 58 sub $0x58,%esp struct rtcdate t1, t2; int sb, bcd; sb = cmos_read(CMOS_STATB); 80103167: c7 04 24 0b 00 00 00 movl $0xb,(%esp) 8010316e: e8 42 ff ff ff call 801030b5 <cmos_read> 80103173: 89 45 f4 mov %eax,-0xc(%ebp) bcd = (sb & (1 << 2)) == 0; 80103176: 8b 45 f4 mov -0xc(%ebp),%eax 80103179: 83 e0 04 and $0x4,%eax 8010317c: 85 c0 test %eax,%eax 8010317e: 0f 94 c0 sete %al 80103181: 0f b6 c0 movzbl %al,%eax 80103184: 89 45 f0 mov %eax,-0x10(%ebp) // make sure CMOS doesn't modify time while we read it for (;;) { fill_rtcdate(&t1); 80103187: 8d 45 d8 lea -0x28(%ebp),%eax 8010318a: 89 04 24 mov %eax,(%esp) 8010318d: e8 5c ff ff ff call 801030ee <fill_rtcdate> if (cmos_read(CMOS_STATA) & CMOS_UIP) 80103192: c7 04 24 0a 00 00 00 movl $0xa,(%esp) 80103199: e8 17 ff ff ff call 801030b5 <cmos_read> 8010319e: 25 80 00 00 00 and $0x80,%eax 801031a3: 85 c0 test %eax,%eax 801031a5: 74 02 je 801031a9 <cmostime+0x48> continue; 801031a7: eb 36 jmp 801031df <cmostime+0x7e> fill_rtcdate(&t2); 801031a9: 8d 45 c0 lea -0x40(%ebp),%eax 801031ac: 89 04 24 mov %eax,(%esp) 801031af: e8 3a ff ff ff call 801030ee <fill_rtcdate> if (memcmp(&t1, &t2, sizeof(t1)) == 0) 801031b4: c7 44 24 08 18 00 00 movl $0x18,0x8(%esp) 801031bb: 00 801031bc: 8d 45 c0 lea -0x40(%ebp),%eax 801031bf: 89 44 24 04 mov %eax,0x4(%esp) 801031c3: 8d 45 d8 lea -0x28(%ebp),%eax 801031c6: 89 04 24 mov %eax,(%esp) 801031c9: e8 bf 22 00 00 call 8010548d <memcmp> 801031ce: 85 c0 test %eax,%eax 801031d0: 75 0d jne 801031df <cmostime+0x7e> break; 801031d2: 90 nop } // convert if (bcd) { 801031d3: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 801031d7: 0f 84 ac 00 00 00 je 80103289 <cmostime+0x128> 801031dd: eb 02 jmp 801031e1 <cmostime+0x80> if (cmos_read(CMOS_STATA) & CMOS_UIP) continue; fill_rtcdate(&t2); if (memcmp(&t1, &t2, sizeof(t1)) == 0) break; } 801031df: eb a6 jmp 80103187 <cmostime+0x26> // convert if (bcd) { #define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) CONV(second); 801031e1: 8b 45 d8 mov -0x28(%ebp),%eax 801031e4: c1 e8 04 shr $0x4,%eax 801031e7: 89 c2 mov %eax,%edx 801031e9: 89 d0 mov %edx,%eax 801031eb: c1 e0 02 shl $0x2,%eax 801031ee: 01 d0 add %edx,%eax 801031f0: 01 c0 add %eax,%eax 801031f2: 8b 55 d8 mov -0x28(%ebp),%edx 801031f5: 83 e2 0f and $0xf,%edx 801031f8: 01 d0 add %edx,%eax 801031fa: 89 45 d8 mov %eax,-0x28(%ebp) CONV(minute); 801031fd: 8b 45 dc mov -0x24(%ebp),%eax 80103200: c1 e8 04 shr $0x4,%eax 80103203: 89 c2 mov %eax,%edx 80103205: 89 d0 mov %edx,%eax 80103207: c1 e0 02 shl $0x2,%eax 8010320a: 01 d0 add %edx,%eax 8010320c: 01 c0 add %eax,%eax 8010320e: 8b 55 dc mov -0x24(%ebp),%edx 80103211: 83 e2 0f and $0xf,%edx 80103214: 01 d0 add %edx,%eax 80103216: 89 45 dc mov %eax,-0x24(%ebp) CONV(hour ); 80103219: 8b 45 e0 mov -0x20(%ebp),%eax 8010321c: c1 e8 04 shr $0x4,%eax 8010321f: 89 c2 mov %eax,%edx 80103221: 89 d0 mov %edx,%eax 80103223: c1 e0 02 shl $0x2,%eax 80103226: 01 d0 add %edx,%eax 80103228: 01 c0 add %eax,%eax 8010322a: 8b 55 e0 mov -0x20(%ebp),%edx 8010322d: 83 e2 0f and $0xf,%edx 80103230: 01 d0 add %edx,%eax 80103232: 89 45 e0 mov %eax,-0x20(%ebp) CONV(day ); 80103235: 8b 45 e4 mov -0x1c(%ebp),%eax 80103238: c1 e8 04 shr $0x4,%eax 8010323b: 89 c2 mov %eax,%edx 8010323d: 89 d0 mov %edx,%eax 8010323f: c1 e0 02 shl $0x2,%eax 80103242: 01 d0 add %edx,%eax 80103244: 01 c0 add %eax,%eax 80103246: 8b 55 e4 mov -0x1c(%ebp),%edx 80103249: 83 e2 0f and $0xf,%edx 8010324c: 01 d0 add %edx,%eax 8010324e: 89 45 e4 mov %eax,-0x1c(%ebp) CONV(month ); 80103251: 8b 45 e8 mov -0x18(%ebp),%eax 80103254: c1 e8 04 shr $0x4,%eax 80103257: 89 c2 mov %eax,%edx 80103259: 89 d0 mov %edx,%eax 8010325b: c1 e0 02 shl $0x2,%eax 8010325e: 01 d0 add %edx,%eax 80103260: 01 c0 add %eax,%eax 80103262: 8b 55 e8 mov -0x18(%ebp),%edx 80103265: 83 e2 0f and $0xf,%edx 80103268: 01 d0 add %edx,%eax 8010326a: 89 45 e8 mov %eax,-0x18(%ebp) CONV(year ); 8010326d: 8b 45 ec mov -0x14(%ebp),%eax 80103270: c1 e8 04 shr $0x4,%eax 80103273: 89 c2 mov %eax,%edx 80103275: 89 d0 mov %edx,%eax 80103277: c1 e0 02 shl $0x2,%eax 8010327a: 01 d0 add %edx,%eax 8010327c: 01 c0 add %eax,%eax 8010327e: 8b 55 ec mov -0x14(%ebp),%edx 80103281: 83 e2 0f and $0xf,%edx 80103284: 01 d0 add %edx,%eax 80103286: 89 45 ec mov %eax,-0x14(%ebp) #undef CONV } *r = t1; 80103289: 8b 45 08 mov 0x8(%ebp),%eax 8010328c: 8b 55 d8 mov -0x28(%ebp),%edx 8010328f: 89 10 mov %edx,(%eax) 80103291: 8b 55 dc mov -0x24(%ebp),%edx 80103294: 89 50 04 mov %edx,0x4(%eax) 80103297: 8b 55 e0 mov -0x20(%ebp),%edx 8010329a: 89 50 08 mov %edx,0x8(%eax) 8010329d: 8b 55 e4 mov -0x1c(%ebp),%edx 801032a0: 89 50 0c mov %edx,0xc(%eax) 801032a3: 8b 55 e8 mov -0x18(%ebp),%edx 801032a6: 89 50 10 mov %edx,0x10(%eax) 801032a9: 8b 55 ec mov -0x14(%ebp),%edx 801032ac: 89 50 14 mov %edx,0x14(%eax) r->year += 2000; 801032af: 8b 45 08 mov 0x8(%ebp),%eax 801032b2: 8b 40 14 mov 0x14(%eax),%eax 801032b5: 8d 90 d0 07 00 00 lea 0x7d0(%eax),%edx 801032bb: 8b 45 08 mov 0x8(%ebp),%eax 801032be: 89 50 14 mov %edx,0x14(%eax) } 801032c1: c9 leave 801032c2: c3 ret 801032c3: 90 nop 801032c4 <initlog>: static void recover_from_log(void); static void commit(); void initlog(int dev) { 801032c4: 55 push %ebp 801032c5: 89 e5 mov %esp,%ebp 801032c7: 83 ec 38 sub $0x38,%esp if (sizeof(struct logheader) >= BSIZE) panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); 801032ca: c7 44 24 04 dc 8a 10 movl $0x80108adc,0x4(%esp) 801032d1: 80 801032d2: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 801032d9: e8 c0 1e 00 00 call 8010519e <initlock> readsb(dev, &sb); 801032de: 8d 45 dc lea -0x24(%ebp),%eax 801032e1: 89 44 24 04 mov %eax,0x4(%esp) 801032e5: 8b 45 08 mov 0x8(%ebp),%eax 801032e8: 89 04 24 mov %eax,(%esp) 801032eb: e8 20 e0 ff ff call 80101310 <readsb> log.start = sb.logstart; 801032f0: 8b 45 ec mov -0x14(%ebp),%eax 801032f3: a3 94 22 11 80 mov %eax,0x80112294 log.size = sb.nlog; 801032f8: 8b 45 e8 mov -0x18(%ebp),%eax 801032fb: a3 98 22 11 80 mov %eax,0x80112298 log.dev = dev; 80103300: 8b 45 08 mov 0x8(%ebp),%eax 80103303: a3 a4 22 11 80 mov %eax,0x801122a4 recover_from_log(); 80103308: e8 9a 01 00 00 call 801034a7 <recover_from_log> } 8010330d: c9 leave 8010330e: c3 ret 8010330f <install_trans>: // Copy committed blocks from log to their home location static void install_trans(void) { 8010330f: 55 push %ebp 80103310: 89 e5 mov %esp,%ebp 80103312: 83 ec 28 sub $0x28,%esp int tail; for (tail = 0; tail < log.lh.n; tail++) { 80103315: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 8010331c: e9 8c 00 00 00 jmp 801033ad <install_trans+0x9e> struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block 80103321: 8b 15 94 22 11 80 mov 0x80112294,%edx 80103327: 8b 45 f4 mov -0xc(%ebp),%eax 8010332a: 01 d0 add %edx,%eax 8010332c: 83 c0 01 add $0x1,%eax 8010332f: 89 c2 mov %eax,%edx 80103331: a1 a4 22 11 80 mov 0x801122a4,%eax 80103336: 89 54 24 04 mov %edx,0x4(%esp) 8010333a: 89 04 24 mov %eax,(%esp) 8010333d: e8 64 ce ff ff call 801001a6 <bread> 80103342: 89 45 f0 mov %eax,-0x10(%ebp) struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 80103345: 8b 45 f4 mov -0xc(%ebp),%eax 80103348: 83 c0 10 add $0x10,%eax 8010334b: 8b 04 85 6c 22 11 80 mov -0x7feedd94(,%eax,4),%eax 80103352: 89 c2 mov %eax,%edx 80103354: a1 a4 22 11 80 mov 0x801122a4,%eax 80103359: 89 54 24 04 mov %edx,0x4(%esp) 8010335d: 89 04 24 mov %eax,(%esp) 80103360: e8 41 ce ff ff call 801001a6 <bread> 80103365: 89 45 ec mov %eax,-0x14(%ebp) memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 80103368: 8b 45 f0 mov -0x10(%ebp),%eax 8010336b: 8d 50 18 lea 0x18(%eax),%edx 8010336e: 8b 45 ec mov -0x14(%ebp),%eax 80103371: 83 c0 18 add $0x18,%eax 80103374: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 8010337b: 00 8010337c: 89 54 24 04 mov %edx,0x4(%esp) 80103380: 89 04 24 mov %eax,(%esp) 80103383: e8 5d 21 00 00 call 801054e5 <memmove> bwrite(dbuf); // write dst to disk 80103388: 8b 45 ec mov -0x14(%ebp),%eax 8010338b: 89 04 24 mov %eax,(%esp) 8010338e: e8 4a ce ff ff call 801001dd <bwrite> brelse(lbuf); 80103393: 8b 45 f0 mov -0x10(%ebp),%eax 80103396: 89 04 24 mov %eax,(%esp) 80103399: e8 79 ce ff ff call 80100217 <brelse> brelse(dbuf); 8010339e: 8b 45 ec mov -0x14(%ebp),%eax 801033a1: 89 04 24 mov %eax,(%esp) 801033a4: e8 6e ce ff ff call 80100217 <brelse> static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 801033a9: 83 45 f4 01 addl $0x1,-0xc(%ebp) 801033ad: a1 a8 22 11 80 mov 0x801122a8,%eax 801033b2: 3b 45 f4 cmp -0xc(%ebp),%eax 801033b5: 0f 8f 66 ff ff ff jg 80103321 <install_trans+0x12> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst bwrite(dbuf); // write dst to disk brelse(lbuf); brelse(dbuf); } } 801033bb: c9 leave 801033bc: c3 ret 801033bd <read_head>: // Read the log header from disk into the in-memory log header static void read_head(void) { 801033bd: 55 push %ebp 801033be: 89 e5 mov %esp,%ebp 801033c0: 83 ec 28 sub $0x28,%esp struct buf *buf = bread(log.dev, log.start); 801033c3: a1 94 22 11 80 mov 0x80112294,%eax 801033c8: 89 c2 mov %eax,%edx 801033ca: a1 a4 22 11 80 mov 0x801122a4,%eax 801033cf: 89 54 24 04 mov %edx,0x4(%esp) 801033d3: 89 04 24 mov %eax,(%esp) 801033d6: e8 cb cd ff ff call 801001a6 <bread> 801033db: 89 45 f0 mov %eax,-0x10(%ebp) struct logheader *lh = (struct logheader *) (buf->data); 801033de: 8b 45 f0 mov -0x10(%ebp),%eax 801033e1: 83 c0 18 add $0x18,%eax 801033e4: 89 45 ec mov %eax,-0x14(%ebp) int i; log.lh.n = lh->n; 801033e7: 8b 45 ec mov -0x14(%ebp),%eax 801033ea: 8b 00 mov (%eax),%eax 801033ec: a3 a8 22 11 80 mov %eax,0x801122a8 for (i = 0; i < log.lh.n; i++) { 801033f1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 801033f8: eb 1b jmp 80103415 <read_head+0x58> log.lh.block[i] = lh->block[i]; 801033fa: 8b 45 ec mov -0x14(%ebp),%eax 801033fd: 8b 55 f4 mov -0xc(%ebp),%edx 80103400: 8b 44 90 04 mov 0x4(%eax,%edx,4),%eax 80103404: 8b 55 f4 mov -0xc(%ebp),%edx 80103407: 83 c2 10 add $0x10,%edx 8010340a: 89 04 95 6c 22 11 80 mov %eax,-0x7feedd94(,%edx,4) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; for (i = 0; i < log.lh.n; i++) { 80103411: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80103415: a1 a8 22 11 80 mov 0x801122a8,%eax 8010341a: 3b 45 f4 cmp -0xc(%ebp),%eax 8010341d: 7f db jg 801033fa <read_head+0x3d> log.lh.block[i] = lh->block[i]; } brelse(buf); 8010341f: 8b 45 f0 mov -0x10(%ebp),%eax 80103422: 89 04 24 mov %eax,(%esp) 80103425: e8 ed cd ff ff call 80100217 <brelse> } 8010342a: c9 leave 8010342b: c3 ret 8010342c <write_head>: // Write in-memory log header to disk. // This is the true point at which the // current transaction commits. static void write_head(void) { 8010342c: 55 push %ebp 8010342d: 89 e5 mov %esp,%ebp 8010342f: 83 ec 28 sub $0x28,%esp struct buf *buf = bread(log.dev, log.start); 80103432: a1 94 22 11 80 mov 0x80112294,%eax 80103437: 89 c2 mov %eax,%edx 80103439: a1 a4 22 11 80 mov 0x801122a4,%eax 8010343e: 89 54 24 04 mov %edx,0x4(%esp) 80103442: 89 04 24 mov %eax,(%esp) 80103445: e8 5c cd ff ff call 801001a6 <bread> 8010344a: 89 45 f0 mov %eax,-0x10(%ebp) struct logheader *hb = (struct logheader *) (buf->data); 8010344d: 8b 45 f0 mov -0x10(%ebp),%eax 80103450: 83 c0 18 add $0x18,%eax 80103453: 89 45 ec mov %eax,-0x14(%ebp) int i; hb->n = log.lh.n; 80103456: 8b 15 a8 22 11 80 mov 0x801122a8,%edx 8010345c: 8b 45 ec mov -0x14(%ebp),%eax 8010345f: 89 10 mov %edx,(%eax) for (i = 0; i < log.lh.n; i++) { 80103461: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80103468: eb 1b jmp 80103485 <write_head+0x59> hb->block[i] = log.lh.block[i]; 8010346a: 8b 45 f4 mov -0xc(%ebp),%eax 8010346d: 83 c0 10 add $0x10,%eax 80103470: 8b 0c 85 6c 22 11 80 mov -0x7feedd94(,%eax,4),%ecx 80103477: 8b 45 ec mov -0x14(%ebp),%eax 8010347a: 8b 55 f4 mov -0xc(%ebp),%edx 8010347d: 89 4c 90 04 mov %ecx,0x4(%eax,%edx,4) { struct buf *buf = bread(log.dev, log.start); struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; for (i = 0; i < log.lh.n; i++) { 80103481: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80103485: a1 a8 22 11 80 mov 0x801122a8,%eax 8010348a: 3b 45 f4 cmp -0xc(%ebp),%eax 8010348d: 7f db jg 8010346a <write_head+0x3e> hb->block[i] = log.lh.block[i]; } bwrite(buf); 8010348f: 8b 45 f0 mov -0x10(%ebp),%eax 80103492: 89 04 24 mov %eax,(%esp) 80103495: e8 43 cd ff ff call 801001dd <bwrite> brelse(buf); 8010349a: 8b 45 f0 mov -0x10(%ebp),%eax 8010349d: 89 04 24 mov %eax,(%esp) 801034a0: e8 72 cd ff ff call 80100217 <brelse> } 801034a5: c9 leave 801034a6: c3 ret 801034a7 <recover_from_log>: static void recover_from_log(void) { 801034a7: 55 push %ebp 801034a8: 89 e5 mov %esp,%ebp 801034aa: 83 ec 08 sub $0x8,%esp read_head(); 801034ad: e8 0b ff ff ff call 801033bd <read_head> install_trans(); // if committed, copy from log to disk 801034b2: e8 58 fe ff ff call 8010330f <install_trans> log.lh.n = 0; 801034b7: c7 05 a8 22 11 80 00 movl $0x0,0x801122a8 801034be: 00 00 00 write_head(); // clear the log 801034c1: e8 66 ff ff ff call 8010342c <write_head> } 801034c6: c9 leave 801034c7: c3 ret 801034c8 <begin_op>: // called at the start of each FS system call. void begin_op(void) { 801034c8: 55 push %ebp 801034c9: 89 e5 mov %esp,%ebp 801034cb: 83 ec 18 sub $0x18,%esp acquire(&log.lock); 801034ce: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 801034d5: e8 e5 1c 00 00 call 801051bf <acquire> while(1){ if(log.committing){ 801034da: a1 a0 22 11 80 mov 0x801122a0,%eax 801034df: 85 c0 test %eax,%eax 801034e1: 74 16 je 801034f9 <begin_op+0x31> sleep(&log, &log.lock); 801034e3: c7 44 24 04 60 22 11 movl $0x80112260,0x4(%esp) 801034ea: 80 801034eb: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 801034f2: e8 fa 16 00 00 call 80104bf1 <sleep> 801034f7: eb 4f jmp 80103548 <begin_op+0x80> } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ 801034f9: 8b 0d a8 22 11 80 mov 0x801122a8,%ecx 801034ff: a1 9c 22 11 80 mov 0x8011229c,%eax 80103504: 8d 50 01 lea 0x1(%eax),%edx 80103507: 89 d0 mov %edx,%eax 80103509: c1 e0 02 shl $0x2,%eax 8010350c: 01 d0 add %edx,%eax 8010350e: 01 c0 add %eax,%eax 80103510: 01 c8 add %ecx,%eax 80103512: 83 f8 1e cmp $0x1e,%eax 80103515: 7e 16 jle 8010352d <begin_op+0x65> // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); 80103517: c7 44 24 04 60 22 11 movl $0x80112260,0x4(%esp) 8010351e: 80 8010351f: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 80103526: e8 c6 16 00 00 call 80104bf1 <sleep> 8010352b: eb 1b jmp 80103548 <begin_op+0x80> } else { log.outstanding += 1; 8010352d: a1 9c 22 11 80 mov 0x8011229c,%eax 80103532: 83 c0 01 add $0x1,%eax 80103535: a3 9c 22 11 80 mov %eax,0x8011229c release(&log.lock); 8010353a: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 80103541: e8 db 1c 00 00 call 80105221 <release> break; 80103546: eb 02 jmp 8010354a <begin_op+0x82> } } 80103548: eb 90 jmp 801034da <begin_op+0x12> } 8010354a: c9 leave 8010354b: c3 ret 8010354c <end_op>: // called at the end of each FS system call. // commits if this was the last outstanding operation. void end_op(void) { 8010354c: 55 push %ebp 8010354d: 89 e5 mov %esp,%ebp 8010354f: 83 ec 28 sub $0x28,%esp int do_commit = 0; 80103552: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) acquire(&log.lock); 80103559: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 80103560: e8 5a 1c 00 00 call 801051bf <acquire> log.outstanding -= 1; 80103565: a1 9c 22 11 80 mov 0x8011229c,%eax 8010356a: 83 e8 01 sub $0x1,%eax 8010356d: a3 9c 22 11 80 mov %eax,0x8011229c if(log.committing) 80103572: a1 a0 22 11 80 mov 0x801122a0,%eax 80103577: 85 c0 test %eax,%eax 80103579: 74 0c je 80103587 <end_op+0x3b> panic("log.committing"); 8010357b: c7 04 24 e0 8a 10 80 movl $0x80108ae0,(%esp) 80103582: e8 b3 cf ff ff call 8010053a <panic> if(log.outstanding == 0){ 80103587: a1 9c 22 11 80 mov 0x8011229c,%eax 8010358c: 85 c0 test %eax,%eax 8010358e: 75 13 jne 801035a3 <end_op+0x57> do_commit = 1; 80103590: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) log.committing = 1; 80103597: c7 05 a0 22 11 80 01 movl $0x1,0x801122a0 8010359e: 00 00 00 801035a1: eb 0c jmp 801035af <end_op+0x63> } else { // begin_op() may be waiting for log space. wakeup(&log); 801035a3: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 801035aa: e8 1b 17 00 00 call 80104cca <wakeup> } release(&log.lock); 801035af: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 801035b6: e8 66 1c 00 00 call 80105221 <release> if(do_commit){ 801035bb: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801035bf: 74 33 je 801035f4 <end_op+0xa8> // call commit w/o holding locks, since not allowed // to sleep with locks. commit(); 801035c1: e8 de 00 00 00 call 801036a4 <commit> acquire(&log.lock); 801035c6: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 801035cd: e8 ed 1b 00 00 call 801051bf <acquire> log.committing = 0; 801035d2: c7 05 a0 22 11 80 00 movl $0x0,0x801122a0 801035d9: 00 00 00 wakeup(&log); 801035dc: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 801035e3: e8 e2 16 00 00 call 80104cca <wakeup> release(&log.lock); 801035e8: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 801035ef: e8 2d 1c 00 00 call 80105221 <release> } } 801035f4: c9 leave 801035f5: c3 ret 801035f6 <write_log>: // Copy modified blocks from cache to log. static void write_log(void) { 801035f6: 55 push %ebp 801035f7: 89 e5 mov %esp,%ebp 801035f9: 83 ec 28 sub $0x28,%esp int tail; for (tail = 0; tail < log.lh.n; tail++) { 801035fc: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80103603: e9 8c 00 00 00 jmp 80103694 <write_log+0x9e> struct buf *to = bread(log.dev, log.start+tail+1); // log block 80103608: 8b 15 94 22 11 80 mov 0x80112294,%edx 8010360e: 8b 45 f4 mov -0xc(%ebp),%eax 80103611: 01 d0 add %edx,%eax 80103613: 83 c0 01 add $0x1,%eax 80103616: 89 c2 mov %eax,%edx 80103618: a1 a4 22 11 80 mov 0x801122a4,%eax 8010361d: 89 54 24 04 mov %edx,0x4(%esp) 80103621: 89 04 24 mov %eax,(%esp) 80103624: e8 7d cb ff ff call 801001a6 <bread> 80103629: 89 45 f0 mov %eax,-0x10(%ebp) struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 8010362c: 8b 45 f4 mov -0xc(%ebp),%eax 8010362f: 83 c0 10 add $0x10,%eax 80103632: 8b 04 85 6c 22 11 80 mov -0x7feedd94(,%eax,4),%eax 80103639: 89 c2 mov %eax,%edx 8010363b: a1 a4 22 11 80 mov 0x801122a4,%eax 80103640: 89 54 24 04 mov %edx,0x4(%esp) 80103644: 89 04 24 mov %eax,(%esp) 80103647: e8 5a cb ff ff call 801001a6 <bread> 8010364c: 89 45 ec mov %eax,-0x14(%ebp) memmove(to->data, from->data, BSIZE); 8010364f: 8b 45 ec mov -0x14(%ebp),%eax 80103652: 8d 50 18 lea 0x18(%eax),%edx 80103655: 8b 45 f0 mov -0x10(%ebp),%eax 80103658: 83 c0 18 add $0x18,%eax 8010365b: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 80103662: 00 80103663: 89 54 24 04 mov %edx,0x4(%esp) 80103667: 89 04 24 mov %eax,(%esp) 8010366a: e8 76 1e 00 00 call 801054e5 <memmove> bwrite(to); // write the log 8010366f: 8b 45 f0 mov -0x10(%ebp),%eax 80103672: 89 04 24 mov %eax,(%esp) 80103675: e8 63 cb ff ff call 801001dd <bwrite> brelse(from); 8010367a: 8b 45 ec mov -0x14(%ebp),%eax 8010367d: 89 04 24 mov %eax,(%esp) 80103680: e8 92 cb ff ff call 80100217 <brelse> brelse(to); 80103685: 8b 45 f0 mov -0x10(%ebp),%eax 80103688: 89 04 24 mov %eax,(%esp) 8010368b: e8 87 cb ff ff call 80100217 <brelse> static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80103690: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80103694: a1 a8 22 11 80 mov 0x801122a8,%eax 80103699: 3b 45 f4 cmp -0xc(%ebp),%eax 8010369c: 0f 8f 66 ff ff ff jg 80103608 <write_log+0x12> memmove(to->data, from->data, BSIZE); bwrite(to); // write the log brelse(from); brelse(to); } } 801036a2: c9 leave 801036a3: c3 ret 801036a4 <commit>: static void commit() { 801036a4: 55 push %ebp 801036a5: 89 e5 mov %esp,%ebp 801036a7: 83 ec 08 sub $0x8,%esp if (log.lh.n > 0) { 801036aa: a1 a8 22 11 80 mov 0x801122a8,%eax 801036af: 85 c0 test %eax,%eax 801036b1: 7e 1e jle 801036d1 <commit+0x2d> write_log(); // Write modified blocks from cache to log 801036b3: e8 3e ff ff ff call 801035f6 <write_log> write_head(); // Write header to disk -- the real commit 801036b8: e8 6f fd ff ff call 8010342c <write_head> install_trans(); // Now install writes to home locations 801036bd: e8 4d fc ff ff call 8010330f <install_trans> log.lh.n = 0; 801036c2: c7 05 a8 22 11 80 00 movl $0x0,0x801122a8 801036c9: 00 00 00 write_head(); // Erase the transaction from the log 801036cc: e8 5b fd ff ff call 8010342c <write_head> } } 801036d1: c9 leave 801036d2: c3 ret 801036d3 <log_write>: // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 801036d3: 55 push %ebp 801036d4: 89 e5 mov %esp,%ebp 801036d6: 83 ec 28 sub $0x28,%esp int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 801036d9: a1 a8 22 11 80 mov 0x801122a8,%eax 801036de: 83 f8 1d cmp $0x1d,%eax 801036e1: 7f 12 jg 801036f5 <log_write+0x22> 801036e3: a1 a8 22 11 80 mov 0x801122a8,%eax 801036e8: 8b 15 98 22 11 80 mov 0x80112298,%edx 801036ee: 83 ea 01 sub $0x1,%edx 801036f1: 39 d0 cmp %edx,%eax 801036f3: 7c 0c jl 80103701 <log_write+0x2e> panic("too big a transaction"); 801036f5: c7 04 24 ef 8a 10 80 movl $0x80108aef,(%esp) 801036fc: e8 39 ce ff ff call 8010053a <panic> if (log.outstanding < 1) 80103701: a1 9c 22 11 80 mov 0x8011229c,%eax 80103706: 85 c0 test %eax,%eax 80103708: 7f 0c jg 80103716 <log_write+0x43> panic("log_write outside of trans"); 8010370a: c7 04 24 05 8b 10 80 movl $0x80108b05,(%esp) 80103711: e8 24 ce ff ff call 8010053a <panic> acquire(&log.lock); 80103716: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 8010371d: e8 9d 1a 00 00 call 801051bf <acquire> for (i = 0; i < log.lh.n; i++) { 80103722: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80103729: eb 1f jmp 8010374a <log_write+0x77> if (log.lh.block[i] == b->blockno) // log absorbtion 8010372b: 8b 45 f4 mov -0xc(%ebp),%eax 8010372e: 83 c0 10 add $0x10,%eax 80103731: 8b 04 85 6c 22 11 80 mov -0x7feedd94(,%eax,4),%eax 80103738: 89 c2 mov %eax,%edx 8010373a: 8b 45 08 mov 0x8(%ebp),%eax 8010373d: 8b 40 08 mov 0x8(%eax),%eax 80103740: 39 c2 cmp %eax,%edx 80103742: 75 02 jne 80103746 <log_write+0x73> break; 80103744: eb 0e jmp 80103754 <log_write+0x81> panic("too big a transaction"); if (log.outstanding < 1) panic("log_write outside of trans"); acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { 80103746: 83 45 f4 01 addl $0x1,-0xc(%ebp) 8010374a: a1 a8 22 11 80 mov 0x801122a8,%eax 8010374f: 3b 45 f4 cmp -0xc(%ebp),%eax 80103752: 7f d7 jg 8010372b <log_write+0x58> if (log.lh.block[i] == b->blockno) // log absorbtion break; } log.lh.block[i] = b->blockno; 80103754: 8b 45 08 mov 0x8(%ebp),%eax 80103757: 8b 40 08 mov 0x8(%eax),%eax 8010375a: 8b 55 f4 mov -0xc(%ebp),%edx 8010375d: 83 c2 10 add $0x10,%edx 80103760: 89 04 95 6c 22 11 80 mov %eax,-0x7feedd94(,%edx,4) if (i == log.lh.n) 80103767: a1 a8 22 11 80 mov 0x801122a8,%eax 8010376c: 3b 45 f4 cmp -0xc(%ebp),%eax 8010376f: 75 0d jne 8010377e <log_write+0xab> log.lh.n++; 80103771: a1 a8 22 11 80 mov 0x801122a8,%eax 80103776: 83 c0 01 add $0x1,%eax 80103779: a3 a8 22 11 80 mov %eax,0x801122a8 b->flags |= B_DIRTY; // prevent eviction 8010377e: 8b 45 08 mov 0x8(%ebp),%eax 80103781: 8b 00 mov (%eax),%eax 80103783: 83 c8 04 or $0x4,%eax 80103786: 89 c2 mov %eax,%edx 80103788: 8b 45 08 mov 0x8(%ebp),%eax 8010378b: 89 10 mov %edx,(%eax) release(&log.lock); 8010378d: c7 04 24 60 22 11 80 movl $0x80112260,(%esp) 80103794: e8 88 1a 00 00 call 80105221 <release> } 80103799: c9 leave 8010379a: c3 ret 8010379b: 90 nop 8010379c <v2p>: 8010379c: 55 push %ebp 8010379d: 89 e5 mov %esp,%ebp 8010379f: 8b 45 08 mov 0x8(%ebp),%eax 801037a2: 05 00 00 00 80 add $0x80000000,%eax 801037a7: 5d pop %ebp 801037a8: c3 ret 801037a9 <p2v>: static inline void *p2v(uint a) { return (void *) ((a) + KERNBASE); } 801037a9: 55 push %ebp 801037aa: 89 e5 mov %esp,%ebp 801037ac: 8b 45 08 mov 0x8(%ebp),%eax 801037af: 05 00 00 00 80 add $0x80000000,%eax 801037b4: 5d pop %ebp 801037b5: c3 ret 801037b6 <xchg>: asm volatile("sti"); } static inline uint xchg(volatile uint *addr, uint newval) { 801037b6: 55 push %ebp 801037b7: 89 e5 mov %esp,%ebp 801037b9: 83 ec 10 sub $0x10,%esp uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 801037bc: 8b 55 08 mov 0x8(%ebp),%edx 801037bf: 8b 45 0c mov 0xc(%ebp),%eax 801037c2: 8b 4d 08 mov 0x8(%ebp),%ecx 801037c5: f0 87 02 lock xchg %eax,(%edx) 801037c8: 89 45 fc mov %eax,-0x4(%ebp) "+m" (*addr), "=a" (result) : "1" (newval) : "cc"); return result; 801037cb: 8b 45 fc mov -0x4(%ebp),%eax } 801037ce: c9 leave 801037cf: c3 ret 801037d0 <main>: // Bootstrap processor starts running C code here. // Allocate a real stack and switch to it, first // doing some setup required for memory allocator to work. int main(void) { 801037d0: 55 push %ebp 801037d1: 89 e5 mov %esp,%ebp 801037d3: 83 e4 f0 and $0xfffffff0,%esp 801037d6: 83 ec 10 sub $0x10,%esp kinit1(end, P2V(4*1024*1024)); // phys page allocator 801037d9: c7 44 24 04 00 00 40 movl $0x80400000,0x4(%esp) 801037e0: 80 801037e1: c7 04 24 3c 51 11 80 movl $0x8011513c,(%esp) 801037e8: e8 88 f2 ff ff call 80102a75 <kinit1> kvmalloc(); // kernel page table 801037ed: e8 bc 48 00 00 call 801080ae <kvmalloc> mpinit(); // collect info about this machine 801037f2: e8 43 04 00 00 call 80103c3a <mpinit> lapicinit(); 801037f7: e8 e4 f5 ff ff call 80102de0 <lapicinit> seginit(); // set up segments 801037fc: e8 40 42 00 00 call 80107a41 <seginit> cprintf("\ncpu%d: starting xv6\n\n", cpu->id); 80103801: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80103807: 0f b6 00 movzbl (%eax),%eax 8010380a: 0f b6 c0 movzbl %al,%eax 8010380d: 89 44 24 04 mov %eax,0x4(%esp) 80103811: c7 04 24 20 8b 10 80 movl $0x80108b20,(%esp) 80103818: e8 83 cb ff ff call 801003a0 <cprintf> picinit(); // interrupt controller 8010381d: e8 79 06 00 00 call 80103e9b <picinit> ioapicinit(); // another interrupt controller 80103822: e8 42 f1 ff ff call 80102969 <ioapicinit> consoleinit(); // I/O devices & their interrupts 80103827: e8 84 d2 ff ff call 80100ab0 <consoleinit> uartinit(); // serial port 8010382c: e8 5a 35 00 00 call 80106d8b <uartinit> pinit(); // process table 80103831: e8 74 0b 00 00 call 801043aa <pinit> tvinit(); // trap vectors 80103836: e8 ff 30 00 00 call 8010693a <tvinit> binit(); // buffer cache 8010383b: e8 f4 c7 ff ff call 80100034 <binit> fileinit(); // file table 80103840: e8 e3 d6 ff ff call 80100f28 <fileinit> ideinit(); // disk 80103845: e8 4f ed ff ff call 80102599 <ideinit> if(!ismp) 8010384a: a1 44 23 11 80 mov 0x80112344,%eax 8010384f: 85 c0 test %eax,%eax 80103851: 75 05 jne 80103858 <main+0x88> timerinit(); // uniprocessor timer 80103853: e8 2a 30 00 00 call 80106882 <timerinit> startothers(); // start other processors 80103858: e8 7f 00 00 00 call 801038dc <startothers> kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers() 8010385d: c7 44 24 04 00 00 00 movl $0x8e000000,0x4(%esp) 80103864: 8e 80103865: c7 04 24 00 00 40 80 movl $0x80400000,(%esp) 8010386c: e8 3c f2 ff ff call 80102aad <kinit2> userinit(); // first user process 80103871: e8 4f 0c 00 00 call 801044c5 <userinit> // Finish setting up this processor in mpmain. mpmain(); 80103876: e8 1a 00 00 00 call 80103895 <mpmain> 8010387b <mpenter>: } // Other CPUs jump here from entryother.S. static void mpenter(void) { 8010387b: 55 push %ebp 8010387c: 89 e5 mov %esp,%ebp 8010387e: 83 ec 08 sub $0x8,%esp switchkvm(); 80103881: e8 3f 48 00 00 call 801080c5 <switchkvm> seginit(); 80103886: e8 b6 41 00 00 call 80107a41 <seginit> lapicinit(); 8010388b: e8 50 f5 ff ff call 80102de0 <lapicinit> mpmain(); 80103890: e8 00 00 00 00 call 80103895 <mpmain> 80103895 <mpmain>: } // Common CPU setup code. static void mpmain(void) { 80103895: 55 push %ebp 80103896: 89 e5 mov %esp,%ebp 80103898: 83 ec 18 sub $0x18,%esp cprintf("cpu%d: starting\n", cpu->id); 8010389b: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801038a1: 0f b6 00 movzbl (%eax),%eax 801038a4: 0f b6 c0 movzbl %al,%eax 801038a7: 89 44 24 04 mov %eax,0x4(%esp) 801038ab: c7 04 24 37 8b 10 80 movl $0x80108b37,(%esp) 801038b2: e8 e9 ca ff ff call 801003a0 <cprintf> idtinit(); // load idt register 801038b7: e8 f2 31 00 00 call 80106aae <idtinit> xchg(&cpu->started, 1); // tell startothers() we're up 801038bc: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801038c2: 05 a8 00 00 00 add $0xa8,%eax 801038c7: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 801038ce: 00 801038cf: 89 04 24 mov %eax,(%esp) 801038d2: e8 df fe ff ff call 801037b6 <xchg> scheduler(); // start running processes 801038d7: e8 5a 11 00 00 call 80104a36 <scheduler> 801038dc <startothers>: pde_t entrypgdir[]; // For entry.S // Start the non-boot (AP) processors. static void startothers(void) { 801038dc: 55 push %ebp 801038dd: 89 e5 mov %esp,%ebp 801038df: 53 push %ebx 801038e0: 83 ec 24 sub $0x24,%esp char *stack; // Write entry code to unused memory at 0x7000. // The linker has placed the image of entryother.S in // _binary_entryother_start. code = p2v(0x7000); 801038e3: c7 04 24 00 70 00 00 movl $0x7000,(%esp) 801038ea: e8 ba fe ff ff call 801037a9 <p2v> 801038ef: 89 45 f0 mov %eax,-0x10(%ebp) memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); 801038f2: b8 8a 00 00 00 mov $0x8a,%eax 801038f7: 89 44 24 08 mov %eax,0x8(%esp) 801038fb: c7 44 24 04 0c b5 10 movl $0x8010b50c,0x4(%esp) 80103902: 80 80103903: 8b 45 f0 mov -0x10(%ebp),%eax 80103906: 89 04 24 mov %eax,(%esp) 80103909: e8 d7 1b 00 00 call 801054e5 <memmove> for(c = cpus; c < cpus+ncpu; c++){ 8010390e: c7 45 f4 60 23 11 80 movl $0x80112360,-0xc(%ebp) 80103915: e9 85 00 00 00 jmp 8010399f <startothers+0xc3> if(c == cpus+cpunum()) // We've started already. 8010391a: e8 1a f6 ff ff call 80102f39 <cpunum> 8010391f: 69 c0 bc 00 00 00 imul $0xbc,%eax,%eax 80103925: 05 60 23 11 80 add $0x80112360,%eax 8010392a: 3b 45 f4 cmp -0xc(%ebp),%eax 8010392d: 75 02 jne 80103931 <startothers+0x55> continue; 8010392f: eb 67 jmp 80103998 <startothers+0xbc> // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); 80103931: e8 6d f2 ff ff call 80102ba3 <kalloc> 80103936: 89 45 ec mov %eax,-0x14(%ebp) *(void**)(code-4) = stack + KSTACKSIZE; 80103939: 8b 45 f0 mov -0x10(%ebp),%eax 8010393c: 83 e8 04 sub $0x4,%eax 8010393f: 8b 55 ec mov -0x14(%ebp),%edx 80103942: 81 c2 00 10 00 00 add $0x1000,%edx 80103948: 89 10 mov %edx,(%eax) *(void**)(code-8) = mpenter; 8010394a: 8b 45 f0 mov -0x10(%ebp),%eax 8010394d: 83 e8 08 sub $0x8,%eax 80103950: c7 00 7b 38 10 80 movl $0x8010387b,(%eax) *(int**)(code-12) = (void *) v2p(entrypgdir); 80103956: 8b 45 f0 mov -0x10(%ebp),%eax 80103959: 8d 58 f4 lea -0xc(%eax),%ebx 8010395c: c7 04 24 00 a0 10 80 movl $0x8010a000,(%esp) 80103963: e8 34 fe ff ff call 8010379c <v2p> 80103968: 89 03 mov %eax,(%ebx) lapicstartap(c->id, v2p(code)); 8010396a: 8b 45 f0 mov -0x10(%ebp),%eax 8010396d: 89 04 24 mov %eax,(%esp) 80103970: e8 27 fe ff ff call 8010379c <v2p> 80103975: 8b 55 f4 mov -0xc(%ebp),%edx 80103978: 0f b6 12 movzbl (%edx),%edx 8010397b: 0f b6 d2 movzbl %dl,%edx 8010397e: 89 44 24 04 mov %eax,0x4(%esp) 80103982: 89 14 24 mov %edx,(%esp) 80103985: e8 31 f6 ff ff call 80102fbb <lapicstartap> // wait for cpu to finish mpmain() while(c->started == 0) 8010398a: 90 nop 8010398b: 8b 45 f4 mov -0xc(%ebp),%eax 8010398e: 8b 80 a8 00 00 00 mov 0xa8(%eax),%eax 80103994: 85 c0 test %eax,%eax 80103996: 74 f3 je 8010398b <startothers+0xaf> // The linker has placed the image of entryother.S in // _binary_entryother_start. code = p2v(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); for(c = cpus; c < cpus+ncpu; c++){ 80103998: 81 45 f4 bc 00 00 00 addl $0xbc,-0xc(%ebp) 8010399f: a1 40 29 11 80 mov 0x80112940,%eax 801039a4: 69 c0 bc 00 00 00 imul $0xbc,%eax,%eax 801039aa: 05 60 23 11 80 add $0x80112360,%eax 801039af: 3b 45 f4 cmp -0xc(%ebp),%eax 801039b2: 0f 87 62 ff ff ff ja 8010391a <startothers+0x3e> // wait for cpu to finish mpmain() while(c->started == 0) ; } } 801039b8: 83 c4 24 add $0x24,%esp 801039bb: 5b pop %ebx 801039bc: 5d pop %ebp 801039bd: c3 ret 801039be: 66 90 xchg %ax,%ax 801039c0 <p2v>: 801039c0: 55 push %ebp 801039c1: 89 e5 mov %esp,%ebp 801039c3: 8b 45 08 mov 0x8(%ebp),%eax 801039c6: 05 00 00 00 80 add $0x80000000,%eax 801039cb: 5d pop %ebp 801039cc: c3 ret 801039cd <inb>: // Routines to let C code use special x86 instructions. static inline uchar inb(ushort port) { 801039cd: 55 push %ebp 801039ce: 89 e5 mov %esp,%ebp 801039d0: 83 ec 14 sub $0x14,%esp 801039d3: 8b 45 08 mov 0x8(%ebp),%eax 801039d6: 66 89 45 ec mov %ax,-0x14(%ebp) uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801039da: 0f b7 45 ec movzwl -0x14(%ebp),%eax 801039de: 89 c2 mov %eax,%edx 801039e0: ec in (%dx),%al 801039e1: 88 45 ff mov %al,-0x1(%ebp) return data; 801039e4: 0f b6 45 ff movzbl -0x1(%ebp),%eax } 801039e8: c9 leave 801039e9: c3 ret 801039ea <outb>: "memory", "cc"); } static inline void outb(ushort port, uchar data) { 801039ea: 55 push %ebp 801039eb: 89 e5 mov %esp,%ebp 801039ed: 83 ec 08 sub $0x8,%esp 801039f0: 8b 55 08 mov 0x8(%ebp),%edx 801039f3: 8b 45 0c mov 0xc(%ebp),%eax 801039f6: 66 89 55 fc mov %dx,-0x4(%ebp) 801039fa: 88 45 f8 mov %al,-0x8(%ebp) asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801039fd: 0f b6 45 f8 movzbl -0x8(%ebp),%eax 80103a01: 0f b7 55 fc movzwl -0x4(%ebp),%edx 80103a05: ee out %al,(%dx) } 80103a06: c9 leave 80103a07: c3 ret 80103a08 <mpbcpu>: int ncpu; uchar ioapicid; int mpbcpu(void) { 80103a08: 55 push %ebp 80103a09: 89 e5 mov %esp,%ebp return bcpu-cpus; 80103a0b: a1 44 b6 10 80 mov 0x8010b644,%eax 80103a10: 89 c2 mov %eax,%edx 80103a12: b8 60 23 11 80 mov $0x80112360,%eax 80103a17: 29 c2 sub %eax,%edx 80103a19: 89 d0 mov %edx,%eax 80103a1b: c1 f8 02 sar $0x2,%eax 80103a1e: 69 c0 cf 46 7d 67 imul $0x677d46cf,%eax,%eax } 80103a24: 5d pop %ebp 80103a25: c3 ret 80103a26 <sum>: static uchar sum(uchar *addr, int len) { 80103a26: 55 push %ebp 80103a27: 89 e5 mov %esp,%ebp 80103a29: 83 ec 10 sub $0x10,%esp int i, sum; sum = 0; 80103a2c: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp) for(i=0; i<len; i++) 80103a33: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 80103a3a: eb 15 jmp 80103a51 <sum+0x2b> sum += addr[i]; 80103a3c: 8b 55 fc mov -0x4(%ebp),%edx 80103a3f: 8b 45 08 mov 0x8(%ebp),%eax 80103a42: 01 d0 add %edx,%eax 80103a44: 0f b6 00 movzbl (%eax),%eax 80103a47: 0f b6 c0 movzbl %al,%eax 80103a4a: 01 45 f8 add %eax,-0x8(%ebp) sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80103a4d: 83 45 fc 01 addl $0x1,-0x4(%ebp) 80103a51: 8b 45 fc mov -0x4(%ebp),%eax 80103a54: 3b 45 0c cmp 0xc(%ebp),%eax 80103a57: 7c e3 jl 80103a3c <sum+0x16> sum += addr[i]; return sum; 80103a59: 8b 45 f8 mov -0x8(%ebp),%eax } 80103a5c: c9 leave 80103a5d: c3 ret 80103a5e <mpsearch1>: // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80103a5e: 55 push %ebp 80103a5f: 89 e5 mov %esp,%ebp 80103a61: 83 ec 28 sub $0x28,%esp uchar *e, *p, *addr; addr = p2v(a); 80103a64: 8b 45 08 mov 0x8(%ebp),%eax 80103a67: 89 04 24 mov %eax,(%esp) 80103a6a: e8 51 ff ff ff call 801039c0 <p2v> 80103a6f: 89 45 f0 mov %eax,-0x10(%ebp) e = addr+len; 80103a72: 8b 55 0c mov 0xc(%ebp),%edx 80103a75: 8b 45 f0 mov -0x10(%ebp),%eax 80103a78: 01 d0 add %edx,%eax 80103a7a: 89 45 ec mov %eax,-0x14(%ebp) for(p = addr; p < e; p += sizeof(struct mp)) 80103a7d: 8b 45 f0 mov -0x10(%ebp),%eax 80103a80: 89 45 f4 mov %eax,-0xc(%ebp) 80103a83: eb 3f jmp 80103ac4 <mpsearch1+0x66> if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80103a85: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 80103a8c: 00 80103a8d: c7 44 24 04 48 8b 10 movl $0x80108b48,0x4(%esp) 80103a94: 80 80103a95: 8b 45 f4 mov -0xc(%ebp),%eax 80103a98: 89 04 24 mov %eax,(%esp) 80103a9b: e8 ed 19 00 00 call 8010548d <memcmp> 80103aa0: 85 c0 test %eax,%eax 80103aa2: 75 1c jne 80103ac0 <mpsearch1+0x62> 80103aa4: c7 44 24 04 10 00 00 movl $0x10,0x4(%esp) 80103aab: 00 80103aac: 8b 45 f4 mov -0xc(%ebp),%eax 80103aaf: 89 04 24 mov %eax,(%esp) 80103ab2: e8 6f ff ff ff call 80103a26 <sum> 80103ab7: 84 c0 test %al,%al 80103ab9: 75 05 jne 80103ac0 <mpsearch1+0x62> return (struct mp*)p; 80103abb: 8b 45 f4 mov -0xc(%ebp),%eax 80103abe: eb 11 jmp 80103ad1 <mpsearch1+0x73> { uchar *e, *p, *addr; addr = p2v(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) 80103ac0: 83 45 f4 10 addl $0x10,-0xc(%ebp) 80103ac4: 8b 45 f4 mov -0xc(%ebp),%eax 80103ac7: 3b 45 ec cmp -0x14(%ebp),%eax 80103aca: 72 b9 jb 80103a85 <mpsearch1+0x27> if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; return 0; 80103acc: b8 00 00 00 00 mov $0x0,%eax } 80103ad1: c9 leave 80103ad2: c3 ret 80103ad3 <mpsearch>: // 1) in the first KB of the EBDA; // 2) in the last KB of system base memory; // 3) in the BIOS ROM between 0xE0000 and 0xFFFFF. static struct mp* mpsearch(void) { 80103ad3: 55 push %ebp 80103ad4: 89 e5 mov %esp,%ebp 80103ad6: 83 ec 28 sub $0x28,%esp uchar *bda; uint p; struct mp *mp; bda = (uchar *) P2V(0x400); 80103ad9: c7 45 f4 00 04 00 80 movl $0x80000400,-0xc(%ebp) if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ 80103ae0: 8b 45 f4 mov -0xc(%ebp),%eax 80103ae3: 83 c0 0f add $0xf,%eax 80103ae6: 0f b6 00 movzbl (%eax),%eax 80103ae9: 0f b6 c0 movzbl %al,%eax 80103aec: c1 e0 08 shl $0x8,%eax 80103aef: 89 c2 mov %eax,%edx 80103af1: 8b 45 f4 mov -0xc(%ebp),%eax 80103af4: 83 c0 0e add $0xe,%eax 80103af7: 0f b6 00 movzbl (%eax),%eax 80103afa: 0f b6 c0 movzbl %al,%eax 80103afd: 09 d0 or %edx,%eax 80103aff: c1 e0 04 shl $0x4,%eax 80103b02: 89 45 f0 mov %eax,-0x10(%ebp) 80103b05: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80103b09: 74 21 je 80103b2c <mpsearch+0x59> if((mp = mpsearch1(p, 1024))) 80103b0b: c7 44 24 04 00 04 00 movl $0x400,0x4(%esp) 80103b12: 00 80103b13: 8b 45 f0 mov -0x10(%ebp),%eax 80103b16: 89 04 24 mov %eax,(%esp) 80103b19: e8 40 ff ff ff call 80103a5e <mpsearch1> 80103b1e: 89 45 ec mov %eax,-0x14(%ebp) 80103b21: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 80103b25: 74 50 je 80103b77 <mpsearch+0xa4> return mp; 80103b27: 8b 45 ec mov -0x14(%ebp),%eax 80103b2a: eb 5f jmp 80103b8b <mpsearch+0xb8> } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; 80103b2c: 8b 45 f4 mov -0xc(%ebp),%eax 80103b2f: 83 c0 14 add $0x14,%eax 80103b32: 0f b6 00 movzbl (%eax),%eax 80103b35: 0f b6 c0 movzbl %al,%eax 80103b38: c1 e0 08 shl $0x8,%eax 80103b3b: 89 c2 mov %eax,%edx 80103b3d: 8b 45 f4 mov -0xc(%ebp),%eax 80103b40: 83 c0 13 add $0x13,%eax 80103b43: 0f b6 00 movzbl (%eax),%eax 80103b46: 0f b6 c0 movzbl %al,%eax 80103b49: 09 d0 or %edx,%eax 80103b4b: c1 e0 0a shl $0xa,%eax 80103b4e: 89 45 f0 mov %eax,-0x10(%ebp) if((mp = mpsearch1(p-1024, 1024))) 80103b51: 8b 45 f0 mov -0x10(%ebp),%eax 80103b54: 2d 00 04 00 00 sub $0x400,%eax 80103b59: c7 44 24 04 00 04 00 movl $0x400,0x4(%esp) 80103b60: 00 80103b61: 89 04 24 mov %eax,(%esp) 80103b64: e8 f5 fe ff ff call 80103a5e <mpsearch1> 80103b69: 89 45 ec mov %eax,-0x14(%ebp) 80103b6c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 80103b70: 74 05 je 80103b77 <mpsearch+0xa4> return mp; 80103b72: 8b 45 ec mov -0x14(%ebp),%eax 80103b75: eb 14 jmp 80103b8b <mpsearch+0xb8> } return mpsearch1(0xF0000, 0x10000); 80103b77: c7 44 24 04 00 00 01 movl $0x10000,0x4(%esp) 80103b7e: 00 80103b7f: c7 04 24 00 00 0f 00 movl $0xf0000,(%esp) 80103b86: e8 d3 fe ff ff call 80103a5e <mpsearch1> } 80103b8b: c9 leave 80103b8c: c3 ret 80103b8d <mpconfig>: // Check for correct signature, calculate the checksum and, // if correct, check the version. // To do: check extended table checksum. static struct mpconf* mpconfig(struct mp **pmp) { 80103b8d: 55 push %ebp 80103b8e: 89 e5 mov %esp,%ebp 80103b90: 83 ec 28 sub $0x28,%esp struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103b93: e8 3b ff ff ff call 80103ad3 <mpsearch> 80103b98: 89 45 f4 mov %eax,-0xc(%ebp) 80103b9b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80103b9f: 74 0a je 80103bab <mpconfig+0x1e> 80103ba1: 8b 45 f4 mov -0xc(%ebp),%eax 80103ba4: 8b 40 04 mov 0x4(%eax),%eax 80103ba7: 85 c0 test %eax,%eax 80103ba9: 75 0a jne 80103bb5 <mpconfig+0x28> return 0; 80103bab: b8 00 00 00 00 mov $0x0,%eax 80103bb0: e9 83 00 00 00 jmp 80103c38 <mpconfig+0xab> conf = (struct mpconf*) p2v((uint) mp->physaddr); 80103bb5: 8b 45 f4 mov -0xc(%ebp),%eax 80103bb8: 8b 40 04 mov 0x4(%eax),%eax 80103bbb: 89 04 24 mov %eax,(%esp) 80103bbe: e8 fd fd ff ff call 801039c0 <p2v> 80103bc3: 89 45 f0 mov %eax,-0x10(%ebp) if(memcmp(conf, "PCMP", 4) != 0) 80103bc6: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 80103bcd: 00 80103bce: c7 44 24 04 4d 8b 10 movl $0x80108b4d,0x4(%esp) 80103bd5: 80 80103bd6: 8b 45 f0 mov -0x10(%ebp),%eax 80103bd9: 89 04 24 mov %eax,(%esp) 80103bdc: e8 ac 18 00 00 call 8010548d <memcmp> 80103be1: 85 c0 test %eax,%eax 80103be3: 74 07 je 80103bec <mpconfig+0x5f> return 0; 80103be5: b8 00 00 00 00 mov $0x0,%eax 80103bea: eb 4c jmp 80103c38 <mpconfig+0xab> if(conf->version != 1 && conf->version != 4) 80103bec: 8b 45 f0 mov -0x10(%ebp),%eax 80103bef: 0f b6 40 06 movzbl 0x6(%eax),%eax 80103bf3: 3c 01 cmp $0x1,%al 80103bf5: 74 12 je 80103c09 <mpconfig+0x7c> 80103bf7: 8b 45 f0 mov -0x10(%ebp),%eax 80103bfa: 0f b6 40 06 movzbl 0x6(%eax),%eax 80103bfe: 3c 04 cmp $0x4,%al 80103c00: 74 07 je 80103c09 <mpconfig+0x7c> return 0; 80103c02: b8 00 00 00 00 mov $0x0,%eax 80103c07: eb 2f jmp 80103c38 <mpconfig+0xab> if(sum((uchar*)conf, conf->length) != 0) 80103c09: 8b 45 f0 mov -0x10(%ebp),%eax 80103c0c: 0f b7 40 04 movzwl 0x4(%eax),%eax 80103c10: 0f b7 c0 movzwl %ax,%eax 80103c13: 89 44 24 04 mov %eax,0x4(%esp) 80103c17: 8b 45 f0 mov -0x10(%ebp),%eax 80103c1a: 89 04 24 mov %eax,(%esp) 80103c1d: e8 04 fe ff ff call 80103a26 <sum> 80103c22: 84 c0 test %al,%al 80103c24: 74 07 je 80103c2d <mpconfig+0xa0> return 0; 80103c26: b8 00 00 00 00 mov $0x0,%eax 80103c2b: eb 0b jmp 80103c38 <mpconfig+0xab> *pmp = mp; 80103c2d: 8b 45 08 mov 0x8(%ebp),%eax 80103c30: 8b 55 f4 mov -0xc(%ebp),%edx 80103c33: 89 10 mov %edx,(%eax) return conf; 80103c35: 8b 45 f0 mov -0x10(%ebp),%eax } 80103c38: c9 leave 80103c39: c3 ret 80103c3a <mpinit>: void mpinit(void) { 80103c3a: 55 push %ebp 80103c3b: 89 e5 mov %esp,%ebp 80103c3d: 83 ec 38 sub $0x38,%esp struct mp *mp; struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; bcpu = &cpus[0]; 80103c40: c7 05 44 b6 10 80 60 movl $0x80112360,0x8010b644 80103c47: 23 11 80 if((conf = mpconfig(&mp)) == 0) 80103c4a: 8d 45 e0 lea -0x20(%ebp),%eax 80103c4d: 89 04 24 mov %eax,(%esp) 80103c50: e8 38 ff ff ff call 80103b8d <mpconfig> 80103c55: 89 45 f0 mov %eax,-0x10(%ebp) 80103c58: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80103c5c: 75 05 jne 80103c63 <mpinit+0x29> return; 80103c5e: e9 9c 01 00 00 jmp 80103dff <mpinit+0x1c5> ismp = 1; 80103c63: c7 05 44 23 11 80 01 movl $0x1,0x80112344 80103c6a: 00 00 00 lapic = (uint*)conf->lapicaddr; 80103c6d: 8b 45 f0 mov -0x10(%ebp),%eax 80103c70: 8b 40 24 mov 0x24(%eax),%eax 80103c73: a3 5c 22 11 80 mov %eax,0x8011225c for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 80103c78: 8b 45 f0 mov -0x10(%ebp),%eax 80103c7b: 83 c0 2c add $0x2c,%eax 80103c7e: 89 45 f4 mov %eax,-0xc(%ebp) 80103c81: 8b 45 f0 mov -0x10(%ebp),%eax 80103c84: 0f b7 40 04 movzwl 0x4(%eax),%eax 80103c88: 0f b7 d0 movzwl %ax,%edx 80103c8b: 8b 45 f0 mov -0x10(%ebp),%eax 80103c8e: 01 d0 add %edx,%eax 80103c90: 89 45 ec mov %eax,-0x14(%ebp) 80103c93: e9 f4 00 00 00 jmp 80103d8c <mpinit+0x152> switch(*p){ 80103c98: 8b 45 f4 mov -0xc(%ebp),%eax 80103c9b: 0f b6 00 movzbl (%eax),%eax 80103c9e: 0f b6 c0 movzbl %al,%eax 80103ca1: 83 f8 04 cmp $0x4,%eax 80103ca4: 0f 87 bf 00 00 00 ja 80103d69 <mpinit+0x12f> 80103caa: 8b 04 85 90 8b 10 80 mov -0x7fef7470(,%eax,4),%eax 80103cb1: ff e0 jmp *%eax case MPPROC: proc = (struct mpproc*)p; 80103cb3: 8b 45 f4 mov -0xc(%ebp),%eax 80103cb6: 89 45 e8 mov %eax,-0x18(%ebp) if(ncpu != proc->apicid){ 80103cb9: 8b 45 e8 mov -0x18(%ebp),%eax 80103cbc: 0f b6 40 01 movzbl 0x1(%eax),%eax 80103cc0: 0f b6 d0 movzbl %al,%edx 80103cc3: a1 40 29 11 80 mov 0x80112940,%eax 80103cc8: 39 c2 cmp %eax,%edx 80103cca: 74 2d je 80103cf9 <mpinit+0xbf> cprintf("mpinit: ncpu=%d apicid=%d\n", ncpu, proc->apicid); 80103ccc: 8b 45 e8 mov -0x18(%ebp),%eax 80103ccf: 0f b6 40 01 movzbl 0x1(%eax),%eax 80103cd3: 0f b6 d0 movzbl %al,%edx 80103cd6: a1 40 29 11 80 mov 0x80112940,%eax 80103cdb: 89 54 24 08 mov %edx,0x8(%esp) 80103cdf: 89 44 24 04 mov %eax,0x4(%esp) 80103ce3: c7 04 24 52 8b 10 80 movl $0x80108b52,(%esp) 80103cea: e8 b1 c6 ff ff call 801003a0 <cprintf> ismp = 0; 80103cef: c7 05 44 23 11 80 00 movl $0x0,0x80112344 80103cf6: 00 00 00 } if(proc->flags & MPBOOT) 80103cf9: 8b 45 e8 mov -0x18(%ebp),%eax 80103cfc: 0f b6 40 03 movzbl 0x3(%eax),%eax 80103d00: 0f b6 c0 movzbl %al,%eax 80103d03: 83 e0 02 and $0x2,%eax 80103d06: 85 c0 test %eax,%eax 80103d08: 74 15 je 80103d1f <mpinit+0xe5> bcpu = &cpus[ncpu]; 80103d0a: a1 40 29 11 80 mov 0x80112940,%eax 80103d0f: 69 c0 bc 00 00 00 imul $0xbc,%eax,%eax 80103d15: 05 60 23 11 80 add $0x80112360,%eax 80103d1a: a3 44 b6 10 80 mov %eax,0x8010b644 cpus[ncpu].id = ncpu; 80103d1f: 8b 15 40 29 11 80 mov 0x80112940,%edx 80103d25: a1 40 29 11 80 mov 0x80112940,%eax 80103d2a: 69 d2 bc 00 00 00 imul $0xbc,%edx,%edx 80103d30: 81 c2 60 23 11 80 add $0x80112360,%edx 80103d36: 88 02 mov %al,(%edx) ncpu++; 80103d38: a1 40 29 11 80 mov 0x80112940,%eax 80103d3d: 83 c0 01 add $0x1,%eax 80103d40: a3 40 29 11 80 mov %eax,0x80112940 p += sizeof(struct mpproc); 80103d45: 83 45 f4 14 addl $0x14,-0xc(%ebp) continue; 80103d49: eb 41 jmp 80103d8c <mpinit+0x152> case MPIOAPIC: ioapic = (struct mpioapic*)p; 80103d4b: 8b 45 f4 mov -0xc(%ebp),%eax 80103d4e: 89 45 e4 mov %eax,-0x1c(%ebp) ioapicid = ioapic->apicno; 80103d51: 8b 45 e4 mov -0x1c(%ebp),%eax 80103d54: 0f b6 40 01 movzbl 0x1(%eax),%eax 80103d58: a2 40 23 11 80 mov %al,0x80112340 p += sizeof(struct mpioapic); 80103d5d: 83 45 f4 08 addl $0x8,-0xc(%ebp) continue; 80103d61: eb 29 jmp 80103d8c <mpinit+0x152> case MPBUS: case MPIOINTR: case MPLINTR: p += 8; 80103d63: 83 45 f4 08 addl $0x8,-0xc(%ebp) continue; 80103d67: eb 23 jmp 80103d8c <mpinit+0x152> default: cprintf("mpinit: unknown config type %x\n", *p); 80103d69: 8b 45 f4 mov -0xc(%ebp),%eax 80103d6c: 0f b6 00 movzbl (%eax),%eax 80103d6f: 0f b6 c0 movzbl %al,%eax 80103d72: 89 44 24 04 mov %eax,0x4(%esp) 80103d76: c7 04 24 70 8b 10 80 movl $0x80108b70,(%esp) 80103d7d: e8 1e c6 ff ff call 801003a0 <cprintf> ismp = 0; 80103d82: c7 05 44 23 11 80 00 movl $0x0,0x80112344 80103d89: 00 00 00 bcpu = &cpus[0]; if((conf = mpconfig(&mp)) == 0) return; ismp = 1; lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 80103d8c: 8b 45 f4 mov -0xc(%ebp),%eax 80103d8f: 3b 45 ec cmp -0x14(%ebp),%eax 80103d92: 0f 82 00 ff ff ff jb 80103c98 <mpinit+0x5e> default: cprintf("mpinit: unknown config type %x\n", *p); ismp = 0; } } if(!ismp){ 80103d98: a1 44 23 11 80 mov 0x80112344,%eax 80103d9d: 85 c0 test %eax,%eax 80103d9f: 75 1d jne 80103dbe <mpinit+0x184> // Didn't like what we found; fall back to no MP. ncpu = 1; 80103da1: c7 05 40 29 11 80 01 movl $0x1,0x80112940 80103da8: 00 00 00 lapic = 0; 80103dab: c7 05 5c 22 11 80 00 movl $0x0,0x8011225c 80103db2: 00 00 00 ioapicid = 0; 80103db5: c6 05 40 23 11 80 00 movb $0x0,0x80112340 return; 80103dbc: eb 41 jmp 80103dff <mpinit+0x1c5> } if(mp->imcrp){ 80103dbe: 8b 45 e0 mov -0x20(%ebp),%eax 80103dc1: 0f b6 40 0c movzbl 0xc(%eax),%eax 80103dc5: 84 c0 test %al,%al 80103dc7: 74 36 je 80103dff <mpinit+0x1c5> // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR 80103dc9: c7 44 24 04 70 00 00 movl $0x70,0x4(%esp) 80103dd0: 00 80103dd1: c7 04 24 22 00 00 00 movl $0x22,(%esp) 80103dd8: e8 0d fc ff ff call 801039ea <outb> outb(0x23, inb(0x23) | 1); // Mask external interrupts. 80103ddd: c7 04 24 23 00 00 00 movl $0x23,(%esp) 80103de4: e8 e4 fb ff ff call 801039cd <inb> 80103de9: 83 c8 01 or $0x1,%eax 80103dec: 0f b6 c0 movzbl %al,%eax 80103def: 89 44 24 04 mov %eax,0x4(%esp) 80103df3: c7 04 24 23 00 00 00 movl $0x23,(%esp) 80103dfa: e8 eb fb ff ff call 801039ea <outb> } } 80103dff: c9 leave 80103e00: c3 ret 80103e01: 66 90 xchg %ax,%ax 80103e03: 90 nop 80103e04 <outb>: "memory", "cc"); } static inline void outb(ushort port, uchar data) { 80103e04: 55 push %ebp 80103e05: 89 e5 mov %esp,%ebp 80103e07: 83 ec 08 sub $0x8,%esp 80103e0a: 8b 55 08 mov 0x8(%ebp),%edx 80103e0d: 8b 45 0c mov 0xc(%ebp),%eax 80103e10: 66 89 55 fc mov %dx,-0x4(%ebp) 80103e14: 88 45 f8 mov %al,-0x8(%ebp) asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80103e17: 0f b6 45 f8 movzbl -0x8(%ebp),%eax 80103e1b: 0f b7 55 fc movzwl -0x4(%ebp),%edx 80103e1f: ee out %al,(%dx) } 80103e20: c9 leave 80103e21: c3 ret 80103e22 <picsetmask>: // Initial IRQ mask has interrupt 2 enabled (for slave 8259A). static ushort irqmask = 0xFFFF & ~(1<<IRQ_SLAVE); static void picsetmask(ushort mask) { 80103e22: 55 push %ebp 80103e23: 89 e5 mov %esp,%ebp 80103e25: 83 ec 0c sub $0xc,%esp 80103e28: 8b 45 08 mov 0x8(%ebp),%eax 80103e2b: 66 89 45 fc mov %ax,-0x4(%ebp) irqmask = mask; 80103e2f: 0f b7 45 fc movzwl -0x4(%ebp),%eax 80103e33: 66 a3 00 b0 10 80 mov %ax,0x8010b000 outb(IO_PIC1+1, mask); 80103e39: 0f b7 45 fc movzwl -0x4(%ebp),%eax 80103e3d: 0f b6 c0 movzbl %al,%eax 80103e40: 89 44 24 04 mov %eax,0x4(%esp) 80103e44: c7 04 24 21 00 00 00 movl $0x21,(%esp) 80103e4b: e8 b4 ff ff ff call 80103e04 <outb> outb(IO_PIC2+1, mask >> 8); 80103e50: 0f b7 45 fc movzwl -0x4(%ebp),%eax 80103e54: 66 c1 e8 08 shr $0x8,%ax 80103e58: 0f b6 c0 movzbl %al,%eax 80103e5b: 89 44 24 04 mov %eax,0x4(%esp) 80103e5f: c7 04 24 a1 00 00 00 movl $0xa1,(%esp) 80103e66: e8 99 ff ff ff call 80103e04 <outb> } 80103e6b: c9 leave 80103e6c: c3 ret 80103e6d <picenable>: void picenable(int irq) { 80103e6d: 55 push %ebp 80103e6e: 89 e5 mov %esp,%ebp 80103e70: 83 ec 04 sub $0x4,%esp picsetmask(irqmask & ~(1<<irq)); 80103e73: 8b 45 08 mov 0x8(%ebp),%eax 80103e76: ba 01 00 00 00 mov $0x1,%edx 80103e7b: 89 c1 mov %eax,%ecx 80103e7d: d3 e2 shl %cl,%edx 80103e7f: 89 d0 mov %edx,%eax 80103e81: f7 d0 not %eax 80103e83: 89 c2 mov %eax,%edx 80103e85: 0f b7 05 00 b0 10 80 movzwl 0x8010b000,%eax 80103e8c: 21 d0 and %edx,%eax 80103e8e: 0f b7 c0 movzwl %ax,%eax 80103e91: 89 04 24 mov %eax,(%esp) 80103e94: e8 89 ff ff ff call 80103e22 <picsetmask> } 80103e99: c9 leave 80103e9a: c3 ret 80103e9b <picinit>: // Initialize the 8259A interrupt controllers. void picinit(void) { 80103e9b: 55 push %ebp 80103e9c: 89 e5 mov %esp,%ebp 80103e9e: 83 ec 08 sub $0x8,%esp // mask all interrupts outb(IO_PIC1+1, 0xFF); 80103ea1: c7 44 24 04 ff 00 00 movl $0xff,0x4(%esp) 80103ea8: 00 80103ea9: c7 04 24 21 00 00 00 movl $0x21,(%esp) 80103eb0: e8 4f ff ff ff call 80103e04 <outb> outb(IO_PIC2+1, 0xFF); 80103eb5: c7 44 24 04 ff 00 00 movl $0xff,0x4(%esp) 80103ebc: 00 80103ebd: c7 04 24 a1 00 00 00 movl $0xa1,(%esp) 80103ec4: e8 3b ff ff ff call 80103e04 <outb> // ICW1: 0001g0hi // g: 0 = edge triggering, 1 = level triggering // h: 0 = cascaded PICs, 1 = master only // i: 0 = no ICW4, 1 = ICW4 required outb(IO_PIC1, 0x11); 80103ec9: c7 44 24 04 11 00 00 movl $0x11,0x4(%esp) 80103ed0: 00 80103ed1: c7 04 24 20 00 00 00 movl $0x20,(%esp) 80103ed8: e8 27 ff ff ff call 80103e04 <outb> // ICW2: Vector offset outb(IO_PIC1+1, T_IRQ0); 80103edd: c7 44 24 04 20 00 00 movl $0x20,0x4(%esp) 80103ee4: 00 80103ee5: c7 04 24 21 00 00 00 movl $0x21,(%esp) 80103eec: e8 13 ff ff ff call 80103e04 <outb> // ICW3: (master PIC) bit mask of IR lines connected to slaves // (slave PIC) 3-bit # of slave's connection to master outb(IO_PIC1+1, 1<<IRQ_SLAVE); 80103ef1: c7 44 24 04 04 00 00 movl $0x4,0x4(%esp) 80103ef8: 00 80103ef9: c7 04 24 21 00 00 00 movl $0x21,(%esp) 80103f00: e8 ff fe ff ff call 80103e04 <outb> // m: 0 = slave PIC, 1 = master PIC // (ignored when b is 0, as the master/slave role // can be hardwired). // a: 1 = Automatic EOI mode // p: 0 = MCS-80/85 mode, 1 = intel x86 mode outb(IO_PIC1+1, 0x3); 80103f05: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp) 80103f0c: 00 80103f0d: c7 04 24 21 00 00 00 movl $0x21,(%esp) 80103f14: e8 eb fe ff ff call 80103e04 <outb> // Set up slave (8259A-2) outb(IO_PIC2, 0x11); // ICW1 80103f19: c7 44 24 04 11 00 00 movl $0x11,0x4(%esp) 80103f20: 00 80103f21: c7 04 24 a0 00 00 00 movl $0xa0,(%esp) 80103f28: e8 d7 fe ff ff call 80103e04 <outb> outb(IO_PIC2+1, T_IRQ0 + 8); // ICW2 80103f2d: c7 44 24 04 28 00 00 movl $0x28,0x4(%esp) 80103f34: 00 80103f35: c7 04 24 a1 00 00 00 movl $0xa1,(%esp) 80103f3c: e8 c3 fe ff ff call 80103e04 <outb> outb(IO_PIC2+1, IRQ_SLAVE); // ICW3 80103f41: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 80103f48: 00 80103f49: c7 04 24 a1 00 00 00 movl $0xa1,(%esp) 80103f50: e8 af fe ff ff call 80103e04 <outb> // NB Automatic EOI mode doesn't tend to work on the slave. // Linux source code says it's "to be investigated". outb(IO_PIC2+1, 0x3); // ICW4 80103f55: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp) 80103f5c: 00 80103f5d: c7 04 24 a1 00 00 00 movl $0xa1,(%esp) 80103f64: e8 9b fe ff ff call 80103e04 <outb> // OCW3: 0ef01prs // ef: 0x = NOP, 10 = clear specific mask, 11 = set specific mask // p: 0 = no polling, 1 = polling mode // rs: 0x = NOP, 10 = read IRR, 11 = read ISR outb(IO_PIC1, 0x68); // clear specific mask 80103f69: c7 44 24 04 68 00 00 movl $0x68,0x4(%esp) 80103f70: 00 80103f71: c7 04 24 20 00 00 00 movl $0x20,(%esp) 80103f78: e8 87 fe ff ff call 80103e04 <outb> outb(IO_PIC1, 0x0a); // read IRR by default 80103f7d: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) 80103f84: 00 80103f85: c7 04 24 20 00 00 00 movl $0x20,(%esp) 80103f8c: e8 73 fe ff ff call 80103e04 <outb> outb(IO_PIC2, 0x68); // OCW3 80103f91: c7 44 24 04 68 00 00 movl $0x68,0x4(%esp) 80103f98: 00 80103f99: c7 04 24 a0 00 00 00 movl $0xa0,(%esp) 80103fa0: e8 5f fe ff ff call 80103e04 <outb> outb(IO_PIC2, 0x0a); // OCW3 80103fa5: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) 80103fac: 00 80103fad: c7 04 24 a0 00 00 00 movl $0xa0,(%esp) 80103fb4: e8 4b fe ff ff call 80103e04 <outb> if(irqmask != 0xFFFF) 80103fb9: 0f b7 05 00 b0 10 80 movzwl 0x8010b000,%eax 80103fc0: 66 83 f8 ff cmp $0xffff,%ax 80103fc4: 74 12 je 80103fd8 <picinit+0x13d> picsetmask(irqmask); 80103fc6: 0f b7 05 00 b0 10 80 movzwl 0x8010b000,%eax 80103fcd: 0f b7 c0 movzwl %ax,%eax 80103fd0: 89 04 24 mov %eax,(%esp) 80103fd3: e8 4a fe ff ff call 80103e22 <picsetmask> } 80103fd8: c9 leave 80103fd9: c3 ret 80103fda: 66 90 xchg %ax,%ax 80103fdc <pipealloc>: int writeopen; // write fd is still open }; int pipealloc(struct file **f0, struct file **f1) { 80103fdc: 55 push %ebp 80103fdd: 89 e5 mov %esp,%ebp 80103fdf: 83 ec 28 sub $0x28,%esp struct pipe *p; p = 0; 80103fe2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) *f0 = *f1 = 0; 80103fe9: 8b 45 0c mov 0xc(%ebp),%eax 80103fec: c7 00 00 00 00 00 movl $0x0,(%eax) 80103ff2: 8b 45 0c mov 0xc(%ebp),%eax 80103ff5: 8b 10 mov (%eax),%edx 80103ff7: 8b 45 08 mov 0x8(%ebp),%eax 80103ffa: 89 10 mov %edx,(%eax) if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) 80103ffc: e8 43 cf ff ff call 80100f44 <filealloc> 80104001: 8b 55 08 mov 0x8(%ebp),%edx 80104004: 89 02 mov %eax,(%edx) 80104006: 8b 45 08 mov 0x8(%ebp),%eax 80104009: 8b 00 mov (%eax),%eax 8010400b: 85 c0 test %eax,%eax 8010400d: 0f 84 c8 00 00 00 je 801040db <pipealloc+0xff> 80104013: e8 2c cf ff ff call 80100f44 <filealloc> 80104018: 8b 55 0c mov 0xc(%ebp),%edx 8010401b: 89 02 mov %eax,(%edx) 8010401d: 8b 45 0c mov 0xc(%ebp),%eax 80104020: 8b 00 mov (%eax),%eax 80104022: 85 c0 test %eax,%eax 80104024: 0f 84 b1 00 00 00 je 801040db <pipealloc+0xff> goto bad; if((p = (struct pipe*)kalloc()) == 0) 8010402a: e8 74 eb ff ff call 80102ba3 <kalloc> 8010402f: 89 45 f4 mov %eax,-0xc(%ebp) 80104032: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80104036: 75 05 jne 8010403d <pipealloc+0x61> goto bad; 80104038: e9 9e 00 00 00 jmp 801040db <pipealloc+0xff> p->readopen = 1; 8010403d: 8b 45 f4 mov -0xc(%ebp),%eax 80104040: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) 80104047: 00 00 00 p->writeopen = 1; 8010404a: 8b 45 f4 mov -0xc(%ebp),%eax 8010404d: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) 80104054: 00 00 00 p->nwrite = 0; 80104057: 8b 45 f4 mov -0xc(%ebp),%eax 8010405a: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) 80104061: 00 00 00 p->nread = 0; 80104064: 8b 45 f4 mov -0xc(%ebp),%eax 80104067: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) 8010406e: 00 00 00 initlock(&p->lock, "pipe"); 80104071: 8b 45 f4 mov -0xc(%ebp),%eax 80104074: c7 44 24 04 a4 8b 10 movl $0x80108ba4,0x4(%esp) 8010407b: 80 8010407c: 89 04 24 mov %eax,(%esp) 8010407f: e8 1a 11 00 00 call 8010519e <initlock> (*f0)->type = FD_PIPE; 80104084: 8b 45 08 mov 0x8(%ebp),%eax 80104087: 8b 00 mov (%eax),%eax 80104089: c7 00 01 00 00 00 movl $0x1,(%eax) (*f0)->readable = 1; 8010408f: 8b 45 08 mov 0x8(%ebp),%eax 80104092: 8b 00 mov (%eax),%eax 80104094: c6 40 08 01 movb $0x1,0x8(%eax) (*f0)->writable = 0; 80104098: 8b 45 08 mov 0x8(%ebp),%eax 8010409b: 8b 00 mov (%eax),%eax 8010409d: c6 40 09 00 movb $0x0,0x9(%eax) (*f0)->pipe = p; 801040a1: 8b 45 08 mov 0x8(%ebp),%eax 801040a4: 8b 00 mov (%eax),%eax 801040a6: 8b 55 f4 mov -0xc(%ebp),%edx 801040a9: 89 50 0c mov %edx,0xc(%eax) (*f1)->type = FD_PIPE; 801040ac: 8b 45 0c mov 0xc(%ebp),%eax 801040af: 8b 00 mov (%eax),%eax 801040b1: c7 00 01 00 00 00 movl $0x1,(%eax) (*f1)->readable = 0; 801040b7: 8b 45 0c mov 0xc(%ebp),%eax 801040ba: 8b 00 mov (%eax),%eax 801040bc: c6 40 08 00 movb $0x0,0x8(%eax) (*f1)->writable = 1; 801040c0: 8b 45 0c mov 0xc(%ebp),%eax 801040c3: 8b 00 mov (%eax),%eax 801040c5: c6 40 09 01 movb $0x1,0x9(%eax) (*f1)->pipe = p; 801040c9: 8b 45 0c mov 0xc(%ebp),%eax 801040cc: 8b 00 mov (%eax),%eax 801040ce: 8b 55 f4 mov -0xc(%ebp),%edx 801040d1: 89 50 0c mov %edx,0xc(%eax) return 0; 801040d4: b8 00 00 00 00 mov $0x0,%eax 801040d9: eb 42 jmp 8010411d <pipealloc+0x141> //PAGEBREAK: 20 bad: if(p) 801040db: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801040df: 74 0b je 801040ec <pipealloc+0x110> kfree((char*)p); 801040e1: 8b 45 f4 mov -0xc(%ebp),%eax 801040e4: 89 04 24 mov %eax,(%esp) 801040e7: e8 1e ea ff ff call 80102b0a <kfree> if(*f0) 801040ec: 8b 45 08 mov 0x8(%ebp),%eax 801040ef: 8b 00 mov (%eax),%eax 801040f1: 85 c0 test %eax,%eax 801040f3: 74 0d je 80104102 <pipealloc+0x126> fileclose(*f0); 801040f5: 8b 45 08 mov 0x8(%ebp),%eax 801040f8: 8b 00 mov (%eax),%eax 801040fa: 89 04 24 mov %eax,(%esp) 801040fd: e8 ea ce ff ff call 80100fec <fileclose> if(*f1) 80104102: 8b 45 0c mov 0xc(%ebp),%eax 80104105: 8b 00 mov (%eax),%eax 80104107: 85 c0 test %eax,%eax 80104109: 74 0d je 80104118 <pipealloc+0x13c> fileclose(*f1); 8010410b: 8b 45 0c mov 0xc(%ebp),%eax 8010410e: 8b 00 mov (%eax),%eax 80104110: 89 04 24 mov %eax,(%esp) 80104113: e8 d4 ce ff ff call 80100fec <fileclose> return -1; 80104118: b8 ff ff ff ff mov $0xffffffff,%eax } 8010411d: c9 leave 8010411e: c3 ret 8010411f <pipeclose>: void pipeclose(struct pipe *p, int writable) { 8010411f: 55 push %ebp 80104120: 89 e5 mov %esp,%ebp 80104122: 83 ec 18 sub $0x18,%esp acquire(&p->lock); 80104125: 8b 45 08 mov 0x8(%ebp),%eax 80104128: 89 04 24 mov %eax,(%esp) 8010412b: e8 8f 10 00 00 call 801051bf <acquire> if(writable){ 80104130: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 80104134: 74 1f je 80104155 <pipeclose+0x36> p->writeopen = 0; 80104136: 8b 45 08 mov 0x8(%ebp),%eax 80104139: c7 80 40 02 00 00 00 movl $0x0,0x240(%eax) 80104140: 00 00 00 wakeup(&p->nread); 80104143: 8b 45 08 mov 0x8(%ebp),%eax 80104146: 05 34 02 00 00 add $0x234,%eax 8010414b: 89 04 24 mov %eax,(%esp) 8010414e: e8 77 0b 00 00 call 80104cca <wakeup> 80104153: eb 1d jmp 80104172 <pipeclose+0x53> } else { p->readopen = 0; 80104155: 8b 45 08 mov 0x8(%ebp),%eax 80104158: c7 80 3c 02 00 00 00 movl $0x0,0x23c(%eax) 8010415f: 00 00 00 wakeup(&p->nwrite); 80104162: 8b 45 08 mov 0x8(%ebp),%eax 80104165: 05 38 02 00 00 add $0x238,%eax 8010416a: 89 04 24 mov %eax,(%esp) 8010416d: e8 58 0b 00 00 call 80104cca <wakeup> } if(p->readopen == 0 && p->writeopen == 0){ 80104172: 8b 45 08 mov 0x8(%ebp),%eax 80104175: 8b 80 3c 02 00 00 mov 0x23c(%eax),%eax 8010417b: 85 c0 test %eax,%eax 8010417d: 75 25 jne 801041a4 <pipeclose+0x85> 8010417f: 8b 45 08 mov 0x8(%ebp),%eax 80104182: 8b 80 40 02 00 00 mov 0x240(%eax),%eax 80104188: 85 c0 test %eax,%eax 8010418a: 75 18 jne 801041a4 <pipeclose+0x85> release(&p->lock); 8010418c: 8b 45 08 mov 0x8(%ebp),%eax 8010418f: 89 04 24 mov %eax,(%esp) 80104192: e8 8a 10 00 00 call 80105221 <release> kfree((char*)p); 80104197: 8b 45 08 mov 0x8(%ebp),%eax 8010419a: 89 04 24 mov %eax,(%esp) 8010419d: e8 68 e9 ff ff call 80102b0a <kfree> 801041a2: eb 0b jmp 801041af <pipeclose+0x90> } else release(&p->lock); 801041a4: 8b 45 08 mov 0x8(%ebp),%eax 801041a7: 89 04 24 mov %eax,(%esp) 801041aa: e8 72 10 00 00 call 80105221 <release> } 801041af: c9 leave 801041b0: c3 ret 801041b1 <pipewrite>: //PAGEBREAK: 40 int pipewrite(struct pipe *p, char *addr, int n) { 801041b1: 55 push %ebp 801041b2: 89 e5 mov %esp,%ebp 801041b4: 83 ec 28 sub $0x28,%esp int i; acquire(&p->lock); 801041b7: 8b 45 08 mov 0x8(%ebp),%eax 801041ba: 89 04 24 mov %eax,(%esp) 801041bd: e8 fd 0f 00 00 call 801051bf <acquire> for(i = 0; i < n; i++){ 801041c2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 801041c9: e9 a6 00 00 00 jmp 80104274 <pipewrite+0xc3> while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 801041ce: eb 57 jmp 80104227 <pipewrite+0x76> if(p->readopen == 0 || proc->killed){ 801041d0: 8b 45 08 mov 0x8(%ebp),%eax 801041d3: 8b 80 3c 02 00 00 mov 0x23c(%eax),%eax 801041d9: 85 c0 test %eax,%eax 801041db: 74 0d je 801041ea <pipewrite+0x39> 801041dd: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801041e3: 8b 40 24 mov 0x24(%eax),%eax 801041e6: 85 c0 test %eax,%eax 801041e8: 74 15 je 801041ff <pipewrite+0x4e> release(&p->lock); 801041ea: 8b 45 08 mov 0x8(%ebp),%eax 801041ed: 89 04 24 mov %eax,(%esp) 801041f0: e8 2c 10 00 00 call 80105221 <release> return -1; 801041f5: b8 ff ff ff ff mov $0xffffffff,%eax 801041fa: e9 9f 00 00 00 jmp 8010429e <pipewrite+0xed> } wakeup(&p->nread); 801041ff: 8b 45 08 mov 0x8(%ebp),%eax 80104202: 05 34 02 00 00 add $0x234,%eax 80104207: 89 04 24 mov %eax,(%esp) 8010420a: e8 bb 0a 00 00 call 80104cca <wakeup> sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 8010420f: 8b 45 08 mov 0x8(%ebp),%eax 80104212: 8b 55 08 mov 0x8(%ebp),%edx 80104215: 81 c2 38 02 00 00 add $0x238,%edx 8010421b: 89 44 24 04 mov %eax,0x4(%esp) 8010421f: 89 14 24 mov %edx,(%esp) 80104222: e8 ca 09 00 00 call 80104bf1 <sleep> { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 80104227: 8b 45 08 mov 0x8(%ebp),%eax 8010422a: 8b 90 38 02 00 00 mov 0x238(%eax),%edx 80104230: 8b 45 08 mov 0x8(%ebp),%eax 80104233: 8b 80 34 02 00 00 mov 0x234(%eax),%eax 80104239: 05 00 02 00 00 add $0x200,%eax 8010423e: 39 c2 cmp %eax,%edx 80104240: 74 8e je 801041d0 <pipewrite+0x1f> return -1; } wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep } p->data[p->nwrite++ % PIPESIZE] = addr[i]; 80104242: 8b 45 08 mov 0x8(%ebp),%eax 80104245: 8b 80 38 02 00 00 mov 0x238(%eax),%eax 8010424b: 8d 48 01 lea 0x1(%eax),%ecx 8010424e: 8b 55 08 mov 0x8(%ebp),%edx 80104251: 89 8a 38 02 00 00 mov %ecx,0x238(%edx) 80104257: 25 ff 01 00 00 and $0x1ff,%eax 8010425c: 89 c1 mov %eax,%ecx 8010425e: 8b 55 f4 mov -0xc(%ebp),%edx 80104261: 8b 45 0c mov 0xc(%ebp),%eax 80104264: 01 d0 add %edx,%eax 80104266: 0f b6 10 movzbl (%eax),%edx 80104269: 8b 45 08 mov 0x8(%ebp),%eax 8010426c: 88 54 08 34 mov %dl,0x34(%eax,%ecx,1) pipewrite(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); for(i = 0; i < n; i++){ 80104270: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80104274: 8b 45 f4 mov -0xc(%ebp),%eax 80104277: 3b 45 10 cmp 0x10(%ebp),%eax 8010427a: 0f 8c 4e ff ff ff jl 801041ce <pipewrite+0x1d> wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep } p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 80104280: 8b 45 08 mov 0x8(%ebp),%eax 80104283: 05 34 02 00 00 add $0x234,%eax 80104288: 89 04 24 mov %eax,(%esp) 8010428b: e8 3a 0a 00 00 call 80104cca <wakeup> release(&p->lock); 80104290: 8b 45 08 mov 0x8(%ebp),%eax 80104293: 89 04 24 mov %eax,(%esp) 80104296: e8 86 0f 00 00 call 80105221 <release> return n; 8010429b: 8b 45 10 mov 0x10(%ebp),%eax } 8010429e: c9 leave 8010429f: c3 ret 801042a0 <piperead>: int piperead(struct pipe *p, char *addr, int n) { 801042a0: 55 push %ebp 801042a1: 89 e5 mov %esp,%ebp 801042a3: 53 push %ebx 801042a4: 83 ec 24 sub $0x24,%esp int i; acquire(&p->lock); 801042a7: 8b 45 08 mov 0x8(%ebp),%eax 801042aa: 89 04 24 mov %eax,(%esp) 801042ad: e8 0d 0f 00 00 call 801051bf <acquire> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801042b2: eb 3a jmp 801042ee <piperead+0x4e> if(proc->killed){ 801042b4: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801042ba: 8b 40 24 mov 0x24(%eax),%eax 801042bd: 85 c0 test %eax,%eax 801042bf: 74 15 je 801042d6 <piperead+0x36> release(&p->lock); 801042c1: 8b 45 08 mov 0x8(%ebp),%eax 801042c4: 89 04 24 mov %eax,(%esp) 801042c7: e8 55 0f 00 00 call 80105221 <release> return -1; 801042cc: b8 ff ff ff ff mov $0xffffffff,%eax 801042d1: e9 b5 00 00 00 jmp 8010438b <piperead+0xeb> } sleep(&p->nread, &p->lock); //DOC: piperead-sleep 801042d6: 8b 45 08 mov 0x8(%ebp),%eax 801042d9: 8b 55 08 mov 0x8(%ebp),%edx 801042dc: 81 c2 34 02 00 00 add $0x234,%edx 801042e2: 89 44 24 04 mov %eax,0x4(%esp) 801042e6: 89 14 24 mov %edx,(%esp) 801042e9: e8 03 09 00 00 call 80104bf1 <sleep> piperead(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801042ee: 8b 45 08 mov 0x8(%ebp),%eax 801042f1: 8b 90 34 02 00 00 mov 0x234(%eax),%edx 801042f7: 8b 45 08 mov 0x8(%ebp),%eax 801042fa: 8b 80 38 02 00 00 mov 0x238(%eax),%eax 80104300: 39 c2 cmp %eax,%edx 80104302: 75 0d jne 80104311 <piperead+0x71> 80104304: 8b 45 08 mov 0x8(%ebp),%eax 80104307: 8b 80 40 02 00 00 mov 0x240(%eax),%eax 8010430d: 85 c0 test %eax,%eax 8010430f: 75 a3 jne 801042b4 <piperead+0x14> release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80104311: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80104318: eb 4b jmp 80104365 <piperead+0xc5> if(p->nread == p->nwrite) 8010431a: 8b 45 08 mov 0x8(%ebp),%eax 8010431d: 8b 90 34 02 00 00 mov 0x234(%eax),%edx 80104323: 8b 45 08 mov 0x8(%ebp),%eax 80104326: 8b 80 38 02 00 00 mov 0x238(%eax),%eax 8010432c: 39 c2 cmp %eax,%edx 8010432e: 75 02 jne 80104332 <piperead+0x92> break; 80104330: eb 3b jmp 8010436d <piperead+0xcd> addr[i] = p->data[p->nread++ % PIPESIZE]; 80104332: 8b 55 f4 mov -0xc(%ebp),%edx 80104335: 8b 45 0c mov 0xc(%ebp),%eax 80104338: 8d 1c 02 lea (%edx,%eax,1),%ebx 8010433b: 8b 45 08 mov 0x8(%ebp),%eax 8010433e: 8b 80 34 02 00 00 mov 0x234(%eax),%eax 80104344: 8d 48 01 lea 0x1(%eax),%ecx 80104347: 8b 55 08 mov 0x8(%ebp),%edx 8010434a: 89 8a 34 02 00 00 mov %ecx,0x234(%edx) 80104350: 25 ff 01 00 00 and $0x1ff,%eax 80104355: 89 c2 mov %eax,%edx 80104357: 8b 45 08 mov 0x8(%ebp),%eax 8010435a: 0f b6 44 10 34 movzbl 0x34(%eax,%edx,1),%eax 8010435f: 88 03 mov %al,(%ebx) release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80104361: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80104365: 8b 45 f4 mov -0xc(%ebp),%eax 80104368: 3b 45 10 cmp 0x10(%ebp),%eax 8010436b: 7c ad jl 8010431a <piperead+0x7a> if(p->nread == p->nwrite) break; addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup 8010436d: 8b 45 08 mov 0x8(%ebp),%eax 80104370: 05 38 02 00 00 add $0x238,%eax 80104375: 89 04 24 mov %eax,(%esp) 80104378: e8 4d 09 00 00 call 80104cca <wakeup> release(&p->lock); 8010437d: 8b 45 08 mov 0x8(%ebp),%eax 80104380: 89 04 24 mov %eax,(%esp) 80104383: e8 99 0e 00 00 call 80105221 <release> return i; 80104388: 8b 45 f4 mov -0xc(%ebp),%eax } 8010438b: 83 c4 24 add $0x24,%esp 8010438e: 5b pop %ebx 8010438f: 5d pop %ebp 80104390: c3 ret 80104391: 66 90 xchg %ax,%ax 80104393: 90 nop 80104394 <readeflags>: asm volatile("ltr %0" : : "r" (sel)); } static inline uint readeflags(void) { 80104394: 55 push %ebp 80104395: 89 e5 mov %esp,%ebp 80104397: 83 ec 10 sub $0x10,%esp uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 8010439a: 9c pushf 8010439b: 58 pop %eax 8010439c: 89 45 fc mov %eax,-0x4(%ebp) return eflags; 8010439f: 8b 45 fc mov -0x4(%ebp),%eax } 801043a2: c9 leave 801043a3: c3 ret 801043a4 <sti>: asm volatile("cli"); } static inline void sti(void) { 801043a4: 55 push %ebp 801043a5: 89 e5 mov %esp,%ebp asm volatile("sti"); 801043a7: fb sti } 801043a8: 5d pop %ebp 801043a9: c3 ret 801043aa <pinit>: static void wakeup1(void *chan); void pinit(void) { 801043aa: 55 push %ebp 801043ab: 89 e5 mov %esp,%ebp 801043ad: 83 ec 18 sub $0x18,%esp initlock(&ptable.lock, "ptable"); 801043b0: c7 44 24 04 a9 8b 10 movl $0x80108ba9,0x4(%esp) 801043b7: 80 801043b8: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 801043bf: e8 da 0d 00 00 call 8010519e <initlock> } 801043c4: c9 leave 801043c5: c3 ret 801043c6 <allocproc>: // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 801043c6: 55 push %ebp 801043c7: 89 e5 mov %esp,%ebp 801043c9: 83 ec 28 sub $0x28,%esp struct proc *p; char *sp; acquire(&ptable.lock); 801043cc: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 801043d3: e8 e7 0d 00 00 call 801051bf <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801043d8: c7 45 f4 94 29 11 80 movl $0x80112994,-0xc(%ebp) 801043df: eb 50 jmp 80104431 <allocproc+0x6b> if(p->state == UNUSED) 801043e1: 8b 45 f4 mov -0xc(%ebp),%eax 801043e4: 8b 40 0c mov 0xc(%eax),%eax 801043e7: 85 c0 test %eax,%eax 801043e9: 75 42 jne 8010442d <allocproc+0x67> goto found; 801043eb: 90 nop release(&ptable.lock); return 0; found: p->state = EMBRYO; 801043ec: 8b 45 f4 mov -0xc(%ebp),%eax 801043ef: c7 40 0c 01 00 00 00 movl $0x1,0xc(%eax) p->pid = nextpid++; 801043f6: a1 04 b0 10 80 mov 0x8010b004,%eax 801043fb: 8d 50 01 lea 0x1(%eax),%edx 801043fe: 89 15 04 b0 10 80 mov %edx,0x8010b004 80104404: 8b 55 f4 mov -0xc(%ebp),%edx 80104407: 89 42 10 mov %eax,0x10(%edx) release(&ptable.lock); 8010440a: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104411: e8 0b 0e 00 00 call 80105221 <release> // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ 80104416: e8 88 e7 ff ff call 80102ba3 <kalloc> 8010441b: 8b 55 f4 mov -0xc(%ebp),%edx 8010441e: 89 42 08 mov %eax,0x8(%edx) 80104421: 8b 45 f4 mov -0xc(%ebp),%eax 80104424: 8b 40 08 mov 0x8(%eax),%eax 80104427: 85 c0 test %eax,%eax 80104429: 75 33 jne 8010445e <allocproc+0x98> 8010442b: eb 20 jmp 8010444d <allocproc+0x87> { struct proc *p; char *sp; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 8010442d: 83 45 f4 7c addl $0x7c,-0xc(%ebp) 80104431: 81 7d f4 94 48 11 80 cmpl $0x80114894,-0xc(%ebp) 80104438: 72 a7 jb 801043e1 <allocproc+0x1b> if(p->state == UNUSED) goto found; release(&ptable.lock); 8010443a: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104441: e8 db 0d 00 00 call 80105221 <release> return 0; 80104446: b8 00 00 00 00 mov $0x0,%eax 8010444b: eb 76 jmp 801044c3 <allocproc+0xfd> p->pid = nextpid++; release(&ptable.lock); // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ p->state = UNUSED; 8010444d: 8b 45 f4 mov -0xc(%ebp),%eax 80104450: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) return 0; 80104457: b8 00 00 00 00 mov $0x0,%eax 8010445c: eb 65 jmp 801044c3 <allocproc+0xfd> } sp = p->kstack + KSTACKSIZE; 8010445e: 8b 45 f4 mov -0xc(%ebp),%eax 80104461: 8b 40 08 mov 0x8(%eax),%eax 80104464: 05 00 10 00 00 add $0x1000,%eax 80104469: 89 45 f0 mov %eax,-0x10(%ebp) // Leave room for trap frame. sp -= sizeof *p->tf; 8010446c: 83 6d f0 4c subl $0x4c,-0x10(%ebp) p->tf = (struct trapframe*)sp; 80104470: 8b 45 f4 mov -0xc(%ebp),%eax 80104473: 8b 55 f0 mov -0x10(%ebp),%edx 80104476: 89 50 18 mov %edx,0x18(%eax) // Set up new context to start executing at forkret, // which returns to trapret. sp -= 4; 80104479: 83 6d f0 04 subl $0x4,-0x10(%ebp) *(uint*)sp = (uint)trapret; 8010447d: ba f4 68 10 80 mov $0x801068f4,%edx 80104482: 8b 45 f0 mov -0x10(%ebp),%eax 80104485: 89 10 mov %edx,(%eax) sp -= sizeof *p->context; 80104487: 83 6d f0 14 subl $0x14,-0x10(%ebp) p->context = (struct context*)sp; 8010448b: 8b 45 f4 mov -0xc(%ebp),%eax 8010448e: 8b 55 f0 mov -0x10(%ebp),%edx 80104491: 89 50 1c mov %edx,0x1c(%eax) memset(p->context, 0, sizeof *p->context); 80104494: 8b 45 f4 mov -0xc(%ebp),%eax 80104497: 8b 40 1c mov 0x1c(%eax),%eax 8010449a: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 801044a1: 00 801044a2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801044a9: 00 801044aa: 89 04 24 mov %eax,(%esp) 801044ad: e8 64 0f 00 00 call 80105416 <memset> p->context->eip = (uint)forkret; 801044b2: 8b 45 f4 mov -0xc(%ebp),%eax 801044b5: 8b 40 1c mov 0x1c(%eax),%eax 801044b8: ba b2 4b 10 80 mov $0x80104bb2,%edx 801044bd: 89 50 10 mov %edx,0x10(%eax) return p; 801044c0: 8b 45 f4 mov -0xc(%ebp),%eax } 801044c3: c9 leave 801044c4: c3 ret 801044c5 <userinit>: //PAGEBREAK: 32 // Set up first user process. void userinit(void) { 801044c5: 55 push %ebp 801044c6: 89 e5 mov %esp,%ebp 801044c8: 83 ec 28 sub $0x28,%esp struct proc *p; extern char _binary_initcode_start[], _binary_initcode_size[]; p = allocproc(); 801044cb: e8 f6 fe ff ff call 801043c6 <allocproc> 801044d0: 89 45 f4 mov %eax,-0xc(%ebp) initproc = p; 801044d3: 8b 45 f4 mov -0xc(%ebp),%eax 801044d6: a3 48 b6 10 80 mov %eax,0x8010b648 if((p->pgdir = setupkvm()) == 0) 801044db: e8 11 3b 00 00 call 80107ff1 <setupkvm> 801044e0: 8b 55 f4 mov -0xc(%ebp),%edx 801044e3: 89 42 04 mov %eax,0x4(%edx) 801044e6: 8b 45 f4 mov -0xc(%ebp),%eax 801044e9: 8b 40 04 mov 0x4(%eax),%eax 801044ec: 85 c0 test %eax,%eax 801044ee: 75 0c jne 801044fc <userinit+0x37> panic("userinit: out of memory?"); 801044f0: c7 04 24 b0 8b 10 80 movl $0x80108bb0,(%esp) 801044f7: e8 3e c0 ff ff call 8010053a <panic> inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); 801044fc: ba 2c 00 00 00 mov $0x2c,%edx 80104501: 8b 45 f4 mov -0xc(%ebp),%eax 80104504: 8b 40 04 mov 0x4(%eax),%eax 80104507: 89 54 24 08 mov %edx,0x8(%esp) 8010450b: c7 44 24 04 e0 b4 10 movl $0x8010b4e0,0x4(%esp) 80104512: 80 80104513: 89 04 24 mov %eax,(%esp) 80104516: e8 2e 3d 00 00 call 80108249 <inituvm> p->sz = PGSIZE; 8010451b: 8b 45 f4 mov -0xc(%ebp),%eax 8010451e: c7 00 00 10 00 00 movl $0x1000,(%eax) memset(p->tf, 0, sizeof(*p->tf)); 80104524: 8b 45 f4 mov -0xc(%ebp),%eax 80104527: 8b 40 18 mov 0x18(%eax),%eax 8010452a: c7 44 24 08 4c 00 00 movl $0x4c,0x8(%esp) 80104531: 00 80104532: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80104539: 00 8010453a: 89 04 24 mov %eax,(%esp) 8010453d: e8 d4 0e 00 00 call 80105416 <memset> p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 80104542: 8b 45 f4 mov -0xc(%ebp),%eax 80104545: 8b 40 18 mov 0x18(%eax),%eax 80104548: 66 c7 40 3c 23 00 movw $0x23,0x3c(%eax) p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 8010454e: 8b 45 f4 mov -0xc(%ebp),%eax 80104551: 8b 40 18 mov 0x18(%eax),%eax 80104554: 66 c7 40 2c 2b 00 movw $0x2b,0x2c(%eax) p->tf->es = p->tf->ds; 8010455a: 8b 45 f4 mov -0xc(%ebp),%eax 8010455d: 8b 40 18 mov 0x18(%eax),%eax 80104560: 8b 55 f4 mov -0xc(%ebp),%edx 80104563: 8b 52 18 mov 0x18(%edx),%edx 80104566: 0f b7 52 2c movzwl 0x2c(%edx),%edx 8010456a: 66 89 50 28 mov %dx,0x28(%eax) p->tf->ss = p->tf->ds; 8010456e: 8b 45 f4 mov -0xc(%ebp),%eax 80104571: 8b 40 18 mov 0x18(%eax),%eax 80104574: 8b 55 f4 mov -0xc(%ebp),%edx 80104577: 8b 52 18 mov 0x18(%edx),%edx 8010457a: 0f b7 52 2c movzwl 0x2c(%edx),%edx 8010457e: 66 89 50 48 mov %dx,0x48(%eax) p->tf->eflags = FL_IF; 80104582: 8b 45 f4 mov -0xc(%ebp),%eax 80104585: 8b 40 18 mov 0x18(%eax),%eax 80104588: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) p->tf->esp = PGSIZE; 8010458f: 8b 45 f4 mov -0xc(%ebp),%eax 80104592: 8b 40 18 mov 0x18(%eax),%eax 80104595: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) p->tf->eip = 0; // beginning of initcode.S 8010459c: 8b 45 f4 mov -0xc(%ebp),%eax 8010459f: 8b 40 18 mov 0x18(%eax),%eax 801045a2: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) safestrcpy(p->name, "initcode", sizeof(p->name)); 801045a9: 8b 45 f4 mov -0xc(%ebp),%eax 801045ac: 83 c0 6c add $0x6c,%eax 801045af: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 801045b6: 00 801045b7: c7 44 24 04 c9 8b 10 movl $0x80108bc9,0x4(%esp) 801045be: 80 801045bf: 89 04 24 mov %eax,(%esp) 801045c2: e8 6f 10 00 00 call 80105636 <safestrcpy> p->cwd = namei("/"); 801045c7: c7 04 24 d2 8b 10 80 movl $0x80108bd2,(%esp) 801045ce: e8 b6 de ff ff call 80102489 <namei> 801045d3: 8b 55 f4 mov -0xc(%ebp),%edx 801045d6: 89 42 68 mov %eax,0x68(%edx) p->state = RUNNABLE; 801045d9: 8b 45 f4 mov -0xc(%ebp),%eax 801045dc: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) } 801045e3: c9 leave 801045e4: c3 ret 801045e5 <growproc>: // Grow current process's memory by n bytes. // Return 0 on success, -1 on failure. int growproc(int n) { 801045e5: 55 push %ebp 801045e6: 89 e5 mov %esp,%ebp 801045e8: 83 ec 28 sub $0x28,%esp uint sz; sz = proc->sz; 801045eb: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801045f1: 8b 00 mov (%eax),%eax 801045f3: 89 45 f4 mov %eax,-0xc(%ebp) if(n > 0){ 801045f6: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 801045fa: 7e 34 jle 80104630 <growproc+0x4b> if((sz = allocuvm(proc->pgdir, sz, sz + n)) == 0) 801045fc: 8b 55 08 mov 0x8(%ebp),%edx 801045ff: 8b 45 f4 mov -0xc(%ebp),%eax 80104602: 01 c2 add %eax,%edx 80104604: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010460a: 8b 40 04 mov 0x4(%eax),%eax 8010460d: 89 54 24 08 mov %edx,0x8(%esp) 80104611: 8b 55 f4 mov -0xc(%ebp),%edx 80104614: 89 54 24 04 mov %edx,0x4(%esp) 80104618: 89 04 24 mov %eax,(%esp) 8010461b: e8 9f 3d 00 00 call 801083bf <allocuvm> 80104620: 89 45 f4 mov %eax,-0xc(%ebp) 80104623: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80104627: 75 41 jne 8010466a <growproc+0x85> return -1; 80104629: b8 ff ff ff ff mov $0xffffffff,%eax 8010462e: eb 58 jmp 80104688 <growproc+0xa3> } else if(n < 0){ 80104630: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 80104634: 79 34 jns 8010466a <growproc+0x85> if((sz = deallocuvm(proc->pgdir, sz, sz + n)) == 0) 80104636: 8b 55 08 mov 0x8(%ebp),%edx 80104639: 8b 45 f4 mov -0xc(%ebp),%eax 8010463c: 01 c2 add %eax,%edx 8010463e: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104644: 8b 40 04 mov 0x4(%eax),%eax 80104647: 89 54 24 08 mov %edx,0x8(%esp) 8010464b: 8b 55 f4 mov -0xc(%ebp),%edx 8010464e: 89 54 24 04 mov %edx,0x4(%esp) 80104652: 89 04 24 mov %eax,(%esp) 80104655: e8 3f 3e 00 00 call 80108499 <deallocuvm> 8010465a: 89 45 f4 mov %eax,-0xc(%ebp) 8010465d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80104661: 75 07 jne 8010466a <growproc+0x85> return -1; 80104663: b8 ff ff ff ff mov $0xffffffff,%eax 80104668: eb 1e jmp 80104688 <growproc+0xa3> } proc->sz = sz; 8010466a: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104670: 8b 55 f4 mov -0xc(%ebp),%edx 80104673: 89 10 mov %edx,(%eax) switchuvm(proc); 80104675: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010467b: 89 04 24 mov %eax,(%esp) 8010467e: e8 5f 3a 00 00 call 801080e2 <switchuvm> return 0; 80104683: b8 00 00 00 00 mov $0x0,%eax } 80104688: c9 leave 80104689: c3 ret 8010468a <fork>: // Create a new process copying p as the parent. // Sets up stack to return as if from system call. // Caller must set state of returned proc to RUNNABLE. int fork(void) { 8010468a: 55 push %ebp 8010468b: 89 e5 mov %esp,%ebp 8010468d: 57 push %edi 8010468e: 56 push %esi 8010468f: 53 push %ebx 80104690: 83 ec 2c sub $0x2c,%esp int i, pid; struct proc *np; // Allocate process. if((np = allocproc()) == 0) 80104693: e8 2e fd ff ff call 801043c6 <allocproc> 80104698: 89 45 e0 mov %eax,-0x20(%ebp) 8010469b: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 8010469f: 75 0a jne 801046ab <fork+0x21> return -1; 801046a1: b8 ff ff ff ff mov $0xffffffff,%eax 801046a6: e9 52 01 00 00 jmp 801047fd <fork+0x173> // Copy process state from p. if((np->pgdir = copyuvm(proc->pgdir, proc->sz)) == 0){ 801046ab: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801046b1: 8b 10 mov (%eax),%edx 801046b3: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801046b9: 8b 40 04 mov 0x4(%eax),%eax 801046bc: 89 54 24 04 mov %edx,0x4(%esp) 801046c0: 89 04 24 mov %eax,(%esp) 801046c3: e8 6d 3f 00 00 call 80108635 <copyuvm> 801046c8: 8b 55 e0 mov -0x20(%ebp),%edx 801046cb: 89 42 04 mov %eax,0x4(%edx) 801046ce: 8b 45 e0 mov -0x20(%ebp),%eax 801046d1: 8b 40 04 mov 0x4(%eax),%eax 801046d4: 85 c0 test %eax,%eax 801046d6: 75 2c jne 80104704 <fork+0x7a> kfree(np->kstack); 801046d8: 8b 45 e0 mov -0x20(%ebp),%eax 801046db: 8b 40 08 mov 0x8(%eax),%eax 801046de: 89 04 24 mov %eax,(%esp) 801046e1: e8 24 e4 ff ff call 80102b0a <kfree> np->kstack = 0; 801046e6: 8b 45 e0 mov -0x20(%ebp),%eax 801046e9: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) np->state = UNUSED; 801046f0: 8b 45 e0 mov -0x20(%ebp),%eax 801046f3: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) return -1; 801046fa: b8 ff ff ff ff mov $0xffffffff,%eax 801046ff: e9 f9 00 00 00 jmp 801047fd <fork+0x173> } np->sz = proc->sz; 80104704: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010470a: 8b 10 mov (%eax),%edx 8010470c: 8b 45 e0 mov -0x20(%ebp),%eax 8010470f: 89 10 mov %edx,(%eax) np->parent = proc; 80104711: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80104718: 8b 45 e0 mov -0x20(%ebp),%eax 8010471b: 89 50 14 mov %edx,0x14(%eax) *np->tf = *proc->tf; 8010471e: 8b 45 e0 mov -0x20(%ebp),%eax 80104721: 8b 50 18 mov 0x18(%eax),%edx 80104724: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010472a: 8b 40 18 mov 0x18(%eax),%eax 8010472d: 89 c3 mov %eax,%ebx 8010472f: b8 13 00 00 00 mov $0x13,%eax 80104734: 89 d7 mov %edx,%edi 80104736: 89 de mov %ebx,%esi 80104738: 89 c1 mov %eax,%ecx 8010473a: f3 a5 rep movsl %ds:(%esi),%es:(%edi) // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; 8010473c: 8b 45 e0 mov -0x20(%ebp),%eax 8010473f: 8b 40 18 mov 0x18(%eax),%eax 80104742: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) for(i = 0; i < NOFILE; i++) 80104749: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 80104750: eb 3d jmp 8010478f <fork+0x105> if(proc->ofile[i]) 80104752: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104758: 8b 55 e4 mov -0x1c(%ebp),%edx 8010475b: 83 c2 08 add $0x8,%edx 8010475e: 8b 44 90 08 mov 0x8(%eax,%edx,4),%eax 80104762: 85 c0 test %eax,%eax 80104764: 74 25 je 8010478b <fork+0x101> np->ofile[i] = filedup(proc->ofile[i]); 80104766: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010476c: 8b 55 e4 mov -0x1c(%ebp),%edx 8010476f: 83 c2 08 add $0x8,%edx 80104772: 8b 44 90 08 mov 0x8(%eax,%edx,4),%eax 80104776: 89 04 24 mov %eax,(%esp) 80104779: e8 26 c8 ff ff call 80100fa4 <filedup> 8010477e: 8b 55 e0 mov -0x20(%ebp),%edx 80104781: 8b 4d e4 mov -0x1c(%ebp),%ecx 80104784: 83 c1 08 add $0x8,%ecx 80104787: 89 44 8a 08 mov %eax,0x8(%edx,%ecx,4) *np->tf = *proc->tf; // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; for(i = 0; i < NOFILE; i++) 8010478b: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 8010478f: 83 7d e4 0f cmpl $0xf,-0x1c(%ebp) 80104793: 7e bd jle 80104752 <fork+0xc8> if(proc->ofile[i]) np->ofile[i] = filedup(proc->ofile[i]); np->cwd = idup(proc->cwd); 80104795: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010479b: 8b 40 68 mov 0x68(%eax),%eax 8010479e: 89 04 24 mov %eax,(%esp) 801047a1: e8 00 d1 ff ff call 801018a6 <idup> 801047a6: 8b 55 e0 mov -0x20(%ebp),%edx 801047a9: 89 42 68 mov %eax,0x68(%edx) safestrcpy(np->name, proc->name, sizeof(proc->name)); 801047ac: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801047b2: 8d 50 6c lea 0x6c(%eax),%edx 801047b5: 8b 45 e0 mov -0x20(%ebp),%eax 801047b8: 83 c0 6c add $0x6c,%eax 801047bb: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 801047c2: 00 801047c3: 89 54 24 04 mov %edx,0x4(%esp) 801047c7: 89 04 24 mov %eax,(%esp) 801047ca: e8 67 0e 00 00 call 80105636 <safestrcpy> pid = np->pid; 801047cf: 8b 45 e0 mov -0x20(%ebp),%eax 801047d2: 8b 40 10 mov 0x10(%eax),%eax 801047d5: 89 45 dc mov %eax,-0x24(%ebp) // lock to force the compiler to emit the np->state write last. acquire(&ptable.lock); 801047d8: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 801047df: e8 db 09 00 00 call 801051bf <acquire> np->state = RUNNABLE; 801047e4: 8b 45 e0 mov -0x20(%ebp),%eax 801047e7: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) release(&ptable.lock); 801047ee: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 801047f5: e8 27 0a 00 00 call 80105221 <release> return pid; 801047fa: 8b 45 dc mov -0x24(%ebp),%eax } 801047fd: 83 c4 2c add $0x2c,%esp 80104800: 5b pop %ebx 80104801: 5e pop %esi 80104802: 5f pop %edi 80104803: 5d pop %ebp 80104804: c3 ret 80104805 <exit>: // Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { 80104805: 55 push %ebp 80104806: 89 e5 mov %esp,%ebp 80104808: 83 ec 28 sub $0x28,%esp struct proc *p; int fd; if(proc == initproc) 8010480b: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80104812: a1 48 b6 10 80 mov 0x8010b648,%eax 80104817: 39 c2 cmp %eax,%edx 80104819: 75 0c jne 80104827 <exit+0x22> panic("init exiting"); 8010481b: c7 04 24 d4 8b 10 80 movl $0x80108bd4,(%esp) 80104822: e8 13 bd ff ff call 8010053a <panic> // Close all open files. for(fd = 0; fd < NOFILE; fd++){ 80104827: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 8010482e: eb 44 jmp 80104874 <exit+0x6f> if(proc->ofile[fd]){ 80104830: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104836: 8b 55 f0 mov -0x10(%ebp),%edx 80104839: 83 c2 08 add $0x8,%edx 8010483c: 8b 44 90 08 mov 0x8(%eax,%edx,4),%eax 80104840: 85 c0 test %eax,%eax 80104842: 74 2c je 80104870 <exit+0x6b> fileclose(proc->ofile[fd]); 80104844: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010484a: 8b 55 f0 mov -0x10(%ebp),%edx 8010484d: 83 c2 08 add $0x8,%edx 80104850: 8b 44 90 08 mov 0x8(%eax,%edx,4),%eax 80104854: 89 04 24 mov %eax,(%esp) 80104857: e8 90 c7 ff ff call 80100fec <fileclose> proc->ofile[fd] = 0; 8010485c: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104862: 8b 55 f0 mov -0x10(%ebp),%edx 80104865: 83 c2 08 add $0x8,%edx 80104868: c7 44 90 08 00 00 00 movl $0x0,0x8(%eax,%edx,4) 8010486f: 00 if(proc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ 80104870: 83 45 f0 01 addl $0x1,-0x10(%ebp) 80104874: 83 7d f0 0f cmpl $0xf,-0x10(%ebp) 80104878: 7e b6 jle 80104830 <exit+0x2b> fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } begin_op(); 8010487a: e8 49 ec ff ff call 801034c8 <begin_op> iput(proc->cwd); 8010487f: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104885: 8b 40 68 mov 0x68(%eax),%eax 80104888: 89 04 24 mov %eax,(%esp) 8010488b: e8 01 d2 ff ff call 80101a91 <iput> end_op(); 80104890: e8 b7 ec ff ff call 8010354c <end_op> proc->cwd = 0; 80104895: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010489b: c7 40 68 00 00 00 00 movl $0x0,0x68(%eax) acquire(&ptable.lock); 801048a2: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 801048a9: e8 11 09 00 00 call 801051bf <acquire> // Parent might be sleeping in wait(). wakeup1(proc->parent); 801048ae: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801048b4: 8b 40 14 mov 0x14(%eax),%eax 801048b7: 89 04 24 mov %eax,(%esp) 801048ba: e8 cd 03 00 00 call 80104c8c <wakeup1> // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801048bf: c7 45 f4 94 29 11 80 movl $0x80112994,-0xc(%ebp) 801048c6: eb 38 jmp 80104900 <exit+0xfb> if(p->parent == proc){ 801048c8: 8b 45 f4 mov -0xc(%ebp),%eax 801048cb: 8b 50 14 mov 0x14(%eax),%edx 801048ce: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801048d4: 39 c2 cmp %eax,%edx 801048d6: 75 24 jne 801048fc <exit+0xf7> p->parent = initproc; 801048d8: 8b 15 48 b6 10 80 mov 0x8010b648,%edx 801048de: 8b 45 f4 mov -0xc(%ebp),%eax 801048e1: 89 50 14 mov %edx,0x14(%eax) if(p->state == ZOMBIE) 801048e4: 8b 45 f4 mov -0xc(%ebp),%eax 801048e7: 8b 40 0c mov 0xc(%eax),%eax 801048ea: 83 f8 05 cmp $0x5,%eax 801048ed: 75 0d jne 801048fc <exit+0xf7> wakeup1(initproc); 801048ef: a1 48 b6 10 80 mov 0x8010b648,%eax 801048f4: 89 04 24 mov %eax,(%esp) 801048f7: e8 90 03 00 00 call 80104c8c <wakeup1> // Parent might be sleeping in wait(). wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801048fc: 83 45 f4 7c addl $0x7c,-0xc(%ebp) 80104900: 81 7d f4 94 48 11 80 cmpl $0x80114894,-0xc(%ebp) 80104907: 72 bf jb 801048c8 <exit+0xc3> wakeup1(initproc); } } // Jump into the scheduler, never to return. proc->state = ZOMBIE; 80104909: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010490f: c7 40 0c 05 00 00 00 movl $0x5,0xc(%eax) sched(); 80104916: e8 b3 01 00 00 call 80104ace <sched> panic("zombie exit"); 8010491b: c7 04 24 e1 8b 10 80 movl $0x80108be1,(%esp) 80104922: e8 13 bc ff ff call 8010053a <panic> 80104927 <wait>: // Wait for a child process to exit and return its pid. // Return -1 if this process has no children. int wait(void) { 80104927: 55 push %ebp 80104928: 89 e5 mov %esp,%ebp 8010492a: 83 ec 28 sub $0x28,%esp struct proc *p; int havekids, pid; acquire(&ptable.lock); 8010492d: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104934: e8 86 08 00 00 call 801051bf <acquire> for(;;){ // Scan through table looking for zombie children. havekids = 0; 80104939: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104940: c7 45 f4 94 29 11 80 movl $0x80112994,-0xc(%ebp) 80104947: e9 9a 00 00 00 jmp 801049e6 <wait+0xbf> if(p->parent != proc) 8010494c: 8b 45 f4 mov -0xc(%ebp),%eax 8010494f: 8b 50 14 mov 0x14(%eax),%edx 80104952: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104958: 39 c2 cmp %eax,%edx 8010495a: 74 05 je 80104961 <wait+0x3a> continue; 8010495c: e9 81 00 00 00 jmp 801049e2 <wait+0xbb> havekids = 1; 80104961: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) if(p->state == ZOMBIE){ 80104968: 8b 45 f4 mov -0xc(%ebp),%eax 8010496b: 8b 40 0c mov 0xc(%eax),%eax 8010496e: 83 f8 05 cmp $0x5,%eax 80104971: 75 6f jne 801049e2 <wait+0xbb> // Found one. pid = p->pid; 80104973: 8b 45 f4 mov -0xc(%ebp),%eax 80104976: 8b 40 10 mov 0x10(%eax),%eax 80104979: 89 45 ec mov %eax,-0x14(%ebp) kfree(p->kstack); 8010497c: 8b 45 f4 mov -0xc(%ebp),%eax 8010497f: 8b 40 08 mov 0x8(%eax),%eax 80104982: 89 04 24 mov %eax,(%esp) 80104985: e8 80 e1 ff ff call 80102b0a <kfree> p->kstack = 0; 8010498a: 8b 45 f4 mov -0xc(%ebp),%eax 8010498d: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) freevm(p->pgdir); 80104994: 8b 45 f4 mov -0xc(%ebp),%eax 80104997: 8b 40 04 mov 0x4(%eax),%eax 8010499a: 89 04 24 mov %eax,(%esp) 8010499d: e8 b3 3b 00 00 call 80108555 <freevm> p->state = UNUSED; 801049a2: 8b 45 f4 mov -0xc(%ebp),%eax 801049a5: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) p->pid = 0; 801049ac: 8b 45 f4 mov -0xc(%ebp),%eax 801049af: c7 40 10 00 00 00 00 movl $0x0,0x10(%eax) p->parent = 0; 801049b6: 8b 45 f4 mov -0xc(%ebp),%eax 801049b9: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) p->name[0] = 0; 801049c0: 8b 45 f4 mov -0xc(%ebp),%eax 801049c3: c6 40 6c 00 movb $0x0,0x6c(%eax) p->killed = 0; 801049c7: 8b 45 f4 mov -0xc(%ebp),%eax 801049ca: c7 40 24 00 00 00 00 movl $0x0,0x24(%eax) release(&ptable.lock); 801049d1: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 801049d8: e8 44 08 00 00 call 80105221 <release> return pid; 801049dd: 8b 45 ec mov -0x14(%ebp),%eax 801049e0: eb 52 jmp 80104a34 <wait+0x10d> acquire(&ptable.lock); for(;;){ // Scan through table looking for zombie children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801049e2: 83 45 f4 7c addl $0x7c,-0xc(%ebp) 801049e6: 81 7d f4 94 48 11 80 cmpl $0x80114894,-0xc(%ebp) 801049ed: 0f 82 59 ff ff ff jb 8010494c <wait+0x25> return pid; } } // No point waiting if we don't have any children. if(!havekids || proc->killed){ 801049f3: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 801049f7: 74 0d je 80104a06 <wait+0xdf> 801049f9: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801049ff: 8b 40 24 mov 0x24(%eax),%eax 80104a02: 85 c0 test %eax,%eax 80104a04: 74 13 je 80104a19 <wait+0xf2> release(&ptable.lock); 80104a06: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104a0d: e8 0f 08 00 00 call 80105221 <release> return -1; 80104a12: b8 ff ff ff ff mov $0xffffffff,%eax 80104a17: eb 1b jmp 80104a34 <wait+0x10d> } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(proc, &ptable.lock); //DOC: wait-sleep 80104a19: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104a1f: c7 44 24 04 60 29 11 movl $0x80112960,0x4(%esp) 80104a26: 80 80104a27: 89 04 24 mov %eax,(%esp) 80104a2a: e8 c2 01 00 00 call 80104bf1 <sleep> } 80104a2f: e9 05 ff ff ff jmp 80104939 <wait+0x12> } 80104a34: c9 leave 80104a35: c3 ret 80104a36 <scheduler>: // - swtch to start running that process // - eventually that process transfers control // via swtch back to the scheduler. void scheduler(void) { 80104a36: 55 push %ebp 80104a37: 89 e5 mov %esp,%ebp 80104a39: 83 ec 28 sub $0x28,%esp struct proc *p; for(;;){ // Enable interrupts on this processor. sti(); 80104a3c: e8 63 f9 ff ff call 801043a4 <sti> // Loop over process table looking for process to run. acquire(&ptable.lock); 80104a41: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104a48: e8 72 07 00 00 call 801051bf <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104a4d: c7 45 f4 94 29 11 80 movl $0x80112994,-0xc(%ebp) 80104a54: eb 5e jmp 80104ab4 <scheduler+0x7e> if(p->state != RUNNABLE) 80104a56: 8b 45 f4 mov -0xc(%ebp),%eax 80104a59: 8b 40 0c mov 0xc(%eax),%eax 80104a5c: 83 f8 03 cmp $0x3,%eax 80104a5f: 74 02 je 80104a63 <scheduler+0x2d> continue; 80104a61: eb 4d jmp 80104ab0 <scheduler+0x7a> // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. proc = p; 80104a63: 8b 45 f4 mov -0xc(%ebp),%eax 80104a66: 65 a3 04 00 00 00 mov %eax,%gs:0x4 switchuvm(p); 80104a6c: 8b 45 f4 mov -0xc(%ebp),%eax 80104a6f: 89 04 24 mov %eax,(%esp) 80104a72: e8 6b 36 00 00 call 801080e2 <switchuvm> p->state = RUNNING; 80104a77: 8b 45 f4 mov -0xc(%ebp),%eax 80104a7a: c7 40 0c 04 00 00 00 movl $0x4,0xc(%eax) swtch(&cpu->scheduler, proc->context); 80104a81: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104a87: 8b 40 1c mov 0x1c(%eax),%eax 80104a8a: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 80104a91: 83 c2 04 add $0x4,%edx 80104a94: 89 44 24 04 mov %eax,0x4(%esp) 80104a98: 89 14 24 mov %edx,(%esp) 80104a9b: e8 08 0c 00 00 call 801056a8 <swtch> switchkvm(); 80104aa0: e8 20 36 00 00 call 801080c5 <switchkvm> // Process is done running for now. // It should have changed its p->state before coming back. proc = 0; 80104aa5: 65 c7 05 04 00 00 00 movl $0x0,%gs:0x4 80104aac: 00 00 00 00 // Enable interrupts on this processor. sti(); // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104ab0: 83 45 f4 7c addl $0x7c,-0xc(%ebp) 80104ab4: 81 7d f4 94 48 11 80 cmpl $0x80114894,-0xc(%ebp) 80104abb: 72 99 jb 80104a56 <scheduler+0x20> // Process is done running for now. // It should have changed its p->state before coming back. proc = 0; } release(&ptable.lock); 80104abd: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104ac4: e8 58 07 00 00 call 80105221 <release> } 80104ac9: e9 6e ff ff ff jmp 80104a3c <scheduler+0x6> 80104ace <sched>: // Enter scheduler. Must hold only ptable.lock // and have changed proc->state. void sched(void) { 80104ace: 55 push %ebp 80104acf: 89 e5 mov %esp,%ebp 80104ad1: 83 ec 28 sub $0x28,%esp int intena; if(!holding(&ptable.lock)) 80104ad4: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104adb: e8 09 08 00 00 call 801052e9 <holding> 80104ae0: 85 c0 test %eax,%eax 80104ae2: 75 0c jne 80104af0 <sched+0x22> panic("sched ptable.lock"); 80104ae4: c7 04 24 ed 8b 10 80 movl $0x80108bed,(%esp) 80104aeb: e8 4a ba ff ff call 8010053a <panic> if(cpu->ncli != 1) 80104af0: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80104af6: 8b 80 ac 00 00 00 mov 0xac(%eax),%eax 80104afc: 83 f8 01 cmp $0x1,%eax 80104aff: 74 0c je 80104b0d <sched+0x3f> panic("sched locks"); 80104b01: c7 04 24 ff 8b 10 80 movl $0x80108bff,(%esp) 80104b08: e8 2d ba ff ff call 8010053a <panic> if(proc->state == RUNNING) 80104b0d: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104b13: 8b 40 0c mov 0xc(%eax),%eax 80104b16: 83 f8 04 cmp $0x4,%eax 80104b19: 75 0c jne 80104b27 <sched+0x59> panic("sched running"); 80104b1b: c7 04 24 0b 8c 10 80 movl $0x80108c0b,(%esp) 80104b22: e8 13 ba ff ff call 8010053a <panic> if(readeflags()&FL_IF) 80104b27: e8 68 f8 ff ff call 80104394 <readeflags> 80104b2c: 25 00 02 00 00 and $0x200,%eax 80104b31: 85 c0 test %eax,%eax 80104b33: 74 0c je 80104b41 <sched+0x73> panic("sched interruptible"); 80104b35: c7 04 24 19 8c 10 80 movl $0x80108c19,(%esp) 80104b3c: e8 f9 b9 ff ff call 8010053a <panic> intena = cpu->intena; 80104b41: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80104b47: 8b 80 b0 00 00 00 mov 0xb0(%eax),%eax 80104b4d: 89 45 f4 mov %eax,-0xc(%ebp) swtch(&proc->context, cpu->scheduler); 80104b50: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80104b56: 8b 40 04 mov 0x4(%eax),%eax 80104b59: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80104b60: 83 c2 1c add $0x1c,%edx 80104b63: 89 44 24 04 mov %eax,0x4(%esp) 80104b67: 89 14 24 mov %edx,(%esp) 80104b6a: e8 39 0b 00 00 call 801056a8 <swtch> cpu->intena = intena; 80104b6f: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80104b75: 8b 55 f4 mov -0xc(%ebp),%edx 80104b78: 89 90 b0 00 00 00 mov %edx,0xb0(%eax) } 80104b7e: c9 leave 80104b7f: c3 ret 80104b80 <yield>: // Give up the CPU for one scheduling round. void yield(void) { 80104b80: 55 push %ebp 80104b81: 89 e5 mov %esp,%ebp 80104b83: 83 ec 18 sub $0x18,%esp acquire(&ptable.lock); //DOC: yieldlock 80104b86: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104b8d: e8 2d 06 00 00 call 801051bf <acquire> proc->state = RUNNABLE; 80104b92: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104b98: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) sched(); 80104b9f: e8 2a ff ff ff call 80104ace <sched> release(&ptable.lock); 80104ba4: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104bab: e8 71 06 00 00 call 80105221 <release> } 80104bb0: c9 leave 80104bb1: c3 ret 80104bb2 <forkret>: // A fork child's very first scheduling by scheduler() // will swtch here. "Return" to user space. void forkret(void) { 80104bb2: 55 push %ebp 80104bb3: 89 e5 mov %esp,%ebp 80104bb5: 83 ec 18 sub $0x18,%esp static int first = 1; // Still holding ptable.lock from scheduler. release(&ptable.lock); 80104bb8: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104bbf: e8 5d 06 00 00 call 80105221 <release> if (first) { 80104bc4: a1 08 b0 10 80 mov 0x8010b008,%eax 80104bc9: 85 c0 test %eax,%eax 80104bcb: 74 22 je 80104bef <forkret+0x3d> // Some initialization functions must be run in the context // of a regular process (e.g., they call sleep), and thus cannot // be run from main(). first = 0; 80104bcd: c7 05 08 b0 10 80 00 movl $0x0,0x8010b008 80104bd4: 00 00 00 iinit(ROOTDEV); 80104bd7: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104bde: e8 cd c9 ff ff call 801015b0 <iinit> initlog(ROOTDEV); 80104be3: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104bea: e8 d5 e6 ff ff call 801032c4 <initlog> } // Return to "caller", actually trapret (see allocproc). } 80104bef: c9 leave 80104bf0: c3 ret 80104bf1 <sleep>: // Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { 80104bf1: 55 push %ebp 80104bf2: 89 e5 mov %esp,%ebp 80104bf4: 83 ec 18 sub $0x18,%esp if(proc == 0) 80104bf7: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104bfd: 85 c0 test %eax,%eax 80104bff: 75 0c jne 80104c0d <sleep+0x1c> panic("sleep"); 80104c01: c7 04 24 2d 8c 10 80 movl $0x80108c2d,(%esp) 80104c08: e8 2d b9 ff ff call 8010053a <panic> if(lk == 0) 80104c0d: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 80104c11: 75 0c jne 80104c1f <sleep+0x2e> panic("sleep without lk"); 80104c13: c7 04 24 33 8c 10 80 movl $0x80108c33,(%esp) 80104c1a: e8 1b b9 ff ff call 8010053a <panic> // change p->state and then call sched. // Once we hold ptable.lock, we can be // guaranteed that we won't miss any wakeup // (wakeup runs with ptable.lock locked), // so it's okay to release lk. if(lk != &ptable.lock){ //DOC: sleeplock0 80104c1f: 81 7d 0c 60 29 11 80 cmpl $0x80112960,0xc(%ebp) 80104c26: 74 17 je 80104c3f <sleep+0x4e> acquire(&ptable.lock); //DOC: sleeplock1 80104c28: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104c2f: e8 8b 05 00 00 call 801051bf <acquire> release(lk); 80104c34: 8b 45 0c mov 0xc(%ebp),%eax 80104c37: 89 04 24 mov %eax,(%esp) 80104c3a: e8 e2 05 00 00 call 80105221 <release> } // Go to sleep. proc->chan = chan; 80104c3f: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104c45: 8b 55 08 mov 0x8(%ebp),%edx 80104c48: 89 50 20 mov %edx,0x20(%eax) proc->state = SLEEPING; 80104c4b: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104c51: c7 40 0c 02 00 00 00 movl $0x2,0xc(%eax) sched(); 80104c58: e8 71 fe ff ff call 80104ace <sched> // Tidy up. proc->chan = 0; 80104c5d: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104c63: c7 40 20 00 00 00 00 movl $0x0,0x20(%eax) // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 80104c6a: 81 7d 0c 60 29 11 80 cmpl $0x80112960,0xc(%ebp) 80104c71: 74 17 je 80104c8a <sleep+0x99> release(&ptable.lock); 80104c73: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104c7a: e8 a2 05 00 00 call 80105221 <release> acquire(lk); 80104c7f: 8b 45 0c mov 0xc(%ebp),%eax 80104c82: 89 04 24 mov %eax,(%esp) 80104c85: e8 35 05 00 00 call 801051bf <acquire> } } 80104c8a: c9 leave 80104c8b: c3 ret 80104c8c <wakeup1>: //PAGEBREAK! // Wake up all processes sleeping on chan. // The ptable lock must be held. static void wakeup1(void *chan) { 80104c8c: 55 push %ebp 80104c8d: 89 e5 mov %esp,%ebp 80104c8f: 83 ec 10 sub $0x10,%esp struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80104c92: c7 45 fc 94 29 11 80 movl $0x80112994,-0x4(%ebp) 80104c99: eb 24 jmp 80104cbf <wakeup1+0x33> if(p->state == SLEEPING && p->chan == chan) 80104c9b: 8b 45 fc mov -0x4(%ebp),%eax 80104c9e: 8b 40 0c mov 0xc(%eax),%eax 80104ca1: 83 f8 02 cmp $0x2,%eax 80104ca4: 75 15 jne 80104cbb <wakeup1+0x2f> 80104ca6: 8b 45 fc mov -0x4(%ebp),%eax 80104ca9: 8b 40 20 mov 0x20(%eax),%eax 80104cac: 3b 45 08 cmp 0x8(%ebp),%eax 80104caf: 75 0a jne 80104cbb <wakeup1+0x2f> p->state = RUNNABLE; 80104cb1: 8b 45 fc mov -0x4(%ebp),%eax 80104cb4: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80104cbb: 83 45 fc 7c addl $0x7c,-0x4(%ebp) 80104cbf: 81 7d fc 94 48 11 80 cmpl $0x80114894,-0x4(%ebp) 80104cc6: 72 d3 jb 80104c9b <wakeup1+0xf> if(p->state == SLEEPING && p->chan == chan) p->state = RUNNABLE; } 80104cc8: c9 leave 80104cc9: c3 ret 80104cca <wakeup>: // Wake up all processes sleeping on chan. void wakeup(void *chan) { 80104cca: 55 push %ebp 80104ccb: 89 e5 mov %esp,%ebp 80104ccd: 83 ec 18 sub $0x18,%esp acquire(&ptable.lock); 80104cd0: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104cd7: e8 e3 04 00 00 call 801051bf <acquire> wakeup1(chan); 80104cdc: 8b 45 08 mov 0x8(%ebp),%eax 80104cdf: 89 04 24 mov %eax,(%esp) 80104ce2: e8 a5 ff ff ff call 80104c8c <wakeup1> release(&ptable.lock); 80104ce7: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104cee: e8 2e 05 00 00 call 80105221 <release> } 80104cf3: c9 leave 80104cf4: c3 ret 80104cf5 <join>: int join(void** stack) { 80104cf5: 55 push %ebp 80104cf6: 89 e5 mov %esp,%ebp 80104cf8: 83 ec 28 sub $0x28,%esp struct proc *p; int y, pid; acquire(&ptable.lock); 80104cfb: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104d02: e8 b8 04 00 00 call 801051bf <acquire> for(;;){ y = 0; 80104d07: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104d0e: c7 45 f4 94 29 11 80 movl $0x80112994,-0xc(%ebp) 80104d15: e9 d3 00 00 00 jmp 80104ded <join+0xf8> if(p->parent != proc || p->pgdir != p->parent->pgdir){continue;} 80104d1a: 8b 45 f4 mov -0xc(%ebp),%eax 80104d1d: 8b 50 14 mov 0x14(%eax),%edx 80104d20: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104d26: 39 c2 cmp %eax,%edx 80104d28: 75 13 jne 80104d3d <join+0x48> 80104d2a: 8b 45 f4 mov -0xc(%ebp),%eax 80104d2d: 8b 50 04 mov 0x4(%eax),%edx 80104d30: 8b 45 f4 mov -0xc(%ebp),%eax 80104d33: 8b 40 14 mov 0x14(%eax),%eax 80104d36: 8b 40 04 mov 0x4(%eax),%eax 80104d39: 39 c2 cmp %eax,%edx 80104d3b: 74 05 je 80104d42 <join+0x4d> 80104d3d: e9 a7 00 00 00 jmp 80104de9 <join+0xf4> y = 1; 80104d42: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) if(p->state == ZOMBIE){ 80104d49: 8b 45 f4 mov -0xc(%ebp),%eax 80104d4c: 8b 40 0c mov 0xc(%eax),%eax 80104d4f: 83 f8 05 cmp $0x5,%eax 80104d52: 0f 85 91 00 00 00 jne 80104de9 <join+0xf4> void * stackAddr = (void*) p->parent->tf->esp + 7*sizeof(void*); 80104d58: 8b 45 f4 mov -0xc(%ebp),%eax 80104d5b: 8b 40 14 mov 0x14(%eax),%eax 80104d5e: 8b 40 18 mov 0x18(%eax),%eax 80104d61: 8b 40 44 mov 0x44(%eax),%eax 80104d64: 83 c0 1c add $0x1c,%eax 80104d67: 89 45 ec mov %eax,-0x14(%ebp) *(uint*)stackAddr = p->tf->ebp; 80104d6a: 8b 45 f4 mov -0xc(%ebp),%eax 80104d6d: 8b 40 18 mov 0x18(%eax),%eax 80104d70: 8b 50 08 mov 0x8(%eax),%edx 80104d73: 8b 45 ec mov -0x14(%ebp),%eax 80104d76: 89 10 mov %edx,(%eax) *(uint*)stackAddr += 3*sizeof(void*) -PGSIZE ; 80104d78: 8b 45 ec mov -0x14(%ebp),%eax 80104d7b: 8b 00 mov (%eax),%eax 80104d7d: 8d 90 0c f0 ff ff lea -0xff4(%eax),%edx 80104d83: 8b 45 ec mov -0x14(%ebp),%eax 80104d86: 89 10 mov %edx,(%eax) pid = p->pid; 80104d88: 8b 45 f4 mov -0xc(%ebp),%eax 80104d8b: 8b 40 10 mov 0x10(%eax),%eax 80104d8e: 89 45 e8 mov %eax,-0x18(%ebp) kfree(p->kstack); 80104d91: 8b 45 f4 mov -0xc(%ebp),%eax 80104d94: 8b 40 08 mov 0x8(%eax),%eax 80104d97: 89 04 24 mov %eax,(%esp) 80104d9a: e8 6b dd ff ff call 80102b0a <kfree> p->kstack = 0; 80104d9f: 8b 45 f4 mov -0xc(%ebp),%eax 80104da2: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) p->state = UNUSED; 80104da9: 8b 45 f4 mov -0xc(%ebp),%eax 80104dac: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) p->pid = 0; 80104db3: 8b 45 f4 mov -0xc(%ebp),%eax 80104db6: c7 40 10 00 00 00 00 movl $0x0,0x10(%eax) p->parent = 0; 80104dbd: 8b 45 f4 mov -0xc(%ebp),%eax 80104dc0: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) p->name[0] = 0; 80104dc7: 8b 45 f4 mov -0xc(%ebp),%eax 80104dca: c6 40 6c 00 movb $0x0,0x6c(%eax) p->killed = 0; 80104dce: 8b 45 f4 mov -0xc(%ebp),%eax 80104dd1: c7 40 24 00 00 00 00 movl $0x0,0x24(%eax) release(&ptable.lock); 80104dd8: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104ddf: e8 3d 04 00 00 call 80105221 <release> return pid; 80104de4: 8b 45 e8 mov -0x18(%ebp),%eax 80104de7: eb 52 jmp 80104e3b <join+0x146> struct proc *p; int y, pid; acquire(&ptable.lock); for(;;){ y = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104de9: 83 45 f4 7c addl $0x7c,-0xc(%ebp) 80104ded: 81 7d f4 94 48 11 80 cmpl $0x80114894,-0xc(%ebp) 80104df4: 0f 82 20 ff ff ff jb 80104d1a <join+0x25> p->killed = 0; release(&ptable.lock); return pid; } } if(!y || proc->killed){ 80104dfa: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80104dfe: 74 0d je 80104e0d <join+0x118> 80104e00: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104e06: 8b 40 24 mov 0x24(%eax),%eax 80104e09: 85 c0 test %eax,%eax 80104e0b: 74 13 je 80104e20 <join+0x12b> release(&ptable.lock); 80104e0d: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104e14: e8 08 04 00 00 call 80105221 <release> return -1; 80104e19: b8 ff ff ff ff mov $0xffffffff,%eax 80104e1e: eb 1b jmp 80104e3b <join+0x146> } sleep(proc, &ptable.lock); 80104e20: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104e26: c7 44 24 04 60 29 11 movl $0x80112960,0x4(%esp) 80104e2d: 80 80104e2e: 89 04 24 mov %eax,(%esp) 80104e31: e8 bb fd ff ff call 80104bf1 <sleep> } 80104e36: e9 cc fe ff ff jmp 80104d07 <join+0x12> } 80104e3b: c9 leave 80104e3c: c3 ret 80104e3d <kill>: // Kill the process with the given pid. // Process won't exit until it returns // to user space (see trap in trap.c). int kill(int pid) { 80104e3d: 55 push %ebp 80104e3e: 89 e5 mov %esp,%ebp 80104e40: 83 ec 28 sub $0x28,%esp struct proc *p; acquire(&ptable.lock); 80104e43: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104e4a: e8 70 03 00 00 call 801051bf <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104e4f: c7 45 f4 94 29 11 80 movl $0x80112994,-0xc(%ebp) 80104e56: eb 41 jmp 80104e99 <kill+0x5c> if(p->pid == pid){ 80104e58: 8b 45 f4 mov -0xc(%ebp),%eax 80104e5b: 8b 40 10 mov 0x10(%eax),%eax 80104e5e: 3b 45 08 cmp 0x8(%ebp),%eax 80104e61: 75 32 jne 80104e95 <kill+0x58> p->killed = 1; 80104e63: 8b 45 f4 mov -0xc(%ebp),%eax 80104e66: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) // Wake process from sleep if necessary. if(p->state == SLEEPING) 80104e6d: 8b 45 f4 mov -0xc(%ebp),%eax 80104e70: 8b 40 0c mov 0xc(%eax),%eax 80104e73: 83 f8 02 cmp $0x2,%eax 80104e76: 75 0a jne 80104e82 <kill+0x45> p->state = RUNNABLE; 80104e78: 8b 45 f4 mov -0xc(%ebp),%eax 80104e7b: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) release(&ptable.lock); 80104e82: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104e89: e8 93 03 00 00 call 80105221 <release> return 0; 80104e8e: b8 00 00 00 00 mov $0x0,%eax 80104e93: eb 1e jmp 80104eb3 <kill+0x76> kill(int pid) { struct proc *p; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104e95: 83 45 f4 7c addl $0x7c,-0xc(%ebp) 80104e99: 81 7d f4 94 48 11 80 cmpl $0x80114894,-0xc(%ebp) 80104ea0: 72 b6 jb 80104e58 <kill+0x1b> p->state = RUNNABLE; release(&ptable.lock); return 0; } } release(&ptable.lock); 80104ea2: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80104ea9: e8 73 03 00 00 call 80105221 <release> return -1; 80104eae: b8 ff ff ff ff mov $0xffffffff,%eax } 80104eb3: c9 leave 80104eb4: c3 ret 80104eb5 <procdump>: // Print a process listing to console. For debugging. // Runs when user types ^P on console. // No lock to avoid wedging a stuck machine further. void procdump(void) { 80104eb5: 55 push %ebp 80104eb6: 89 e5 mov %esp,%ebp 80104eb8: 83 ec 58 sub $0x58,%esp int i; struct proc *p; char *state; uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104ebb: c7 45 f0 94 29 11 80 movl $0x80112994,-0x10(%ebp) 80104ec2: e9 d6 00 00 00 jmp 80104f9d <procdump+0xe8> if(p->state == UNUSED) 80104ec7: 8b 45 f0 mov -0x10(%ebp),%eax 80104eca: 8b 40 0c mov 0xc(%eax),%eax 80104ecd: 85 c0 test %eax,%eax 80104ecf: 75 05 jne 80104ed6 <procdump+0x21> continue; 80104ed1: e9 c3 00 00 00 jmp 80104f99 <procdump+0xe4> if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80104ed6: 8b 45 f0 mov -0x10(%ebp),%eax 80104ed9: 8b 40 0c mov 0xc(%eax),%eax 80104edc: 83 f8 05 cmp $0x5,%eax 80104edf: 77 23 ja 80104f04 <procdump+0x4f> 80104ee1: 8b 45 f0 mov -0x10(%ebp),%eax 80104ee4: 8b 40 0c mov 0xc(%eax),%eax 80104ee7: 8b 04 85 0c b0 10 80 mov -0x7fef4ff4(,%eax,4),%eax 80104eee: 85 c0 test %eax,%eax 80104ef0: 74 12 je 80104f04 <procdump+0x4f> state = states[p->state]; 80104ef2: 8b 45 f0 mov -0x10(%ebp),%eax 80104ef5: 8b 40 0c mov 0xc(%eax),%eax 80104ef8: 8b 04 85 0c b0 10 80 mov -0x7fef4ff4(,%eax,4),%eax 80104eff: 89 45 ec mov %eax,-0x14(%ebp) 80104f02: eb 07 jmp 80104f0b <procdump+0x56> else state = "???"; 80104f04: c7 45 ec 44 8c 10 80 movl $0x80108c44,-0x14(%ebp) cprintf("%d %s %s", p->pid, state, p->name); 80104f0b: 8b 45 f0 mov -0x10(%ebp),%eax 80104f0e: 8d 50 6c lea 0x6c(%eax),%edx 80104f11: 8b 45 f0 mov -0x10(%ebp),%eax 80104f14: 8b 40 10 mov 0x10(%eax),%eax 80104f17: 89 54 24 0c mov %edx,0xc(%esp) 80104f1b: 8b 55 ec mov -0x14(%ebp),%edx 80104f1e: 89 54 24 08 mov %edx,0x8(%esp) 80104f22: 89 44 24 04 mov %eax,0x4(%esp) 80104f26: c7 04 24 48 8c 10 80 movl $0x80108c48,(%esp) 80104f2d: e8 6e b4 ff ff call 801003a0 <cprintf> if(p->state == SLEEPING){ 80104f32: 8b 45 f0 mov -0x10(%ebp),%eax 80104f35: 8b 40 0c mov 0xc(%eax),%eax 80104f38: 83 f8 02 cmp $0x2,%eax 80104f3b: 75 50 jne 80104f8d <procdump+0xd8> getcallerpcs((uint*)p->context->ebp+2, pc); 80104f3d: 8b 45 f0 mov -0x10(%ebp),%eax 80104f40: 8b 40 1c mov 0x1c(%eax),%eax 80104f43: 8b 40 0c mov 0xc(%eax),%eax 80104f46: 83 c0 08 add $0x8,%eax 80104f49: 8d 55 c4 lea -0x3c(%ebp),%edx 80104f4c: 89 54 24 04 mov %edx,0x4(%esp) 80104f50: 89 04 24 mov %eax,(%esp) 80104f53: e8 18 03 00 00 call 80105270 <getcallerpcs> for(i=0; i<10 && pc[i] != 0; i++) 80104f58: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80104f5f: eb 1b jmp 80104f7c <procdump+0xc7> cprintf(" %p", pc[i]); 80104f61: 8b 45 f4 mov -0xc(%ebp),%eax 80104f64: 8b 44 85 c4 mov -0x3c(%ebp,%eax,4),%eax 80104f68: 89 44 24 04 mov %eax,0x4(%esp) 80104f6c: c7 04 24 51 8c 10 80 movl $0x80108c51,(%esp) 80104f73: e8 28 b4 ff ff call 801003a0 <cprintf> else state = "???"; cprintf("%d %s %s", p->pid, state, p->name); if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) 80104f78: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80104f7c: 83 7d f4 09 cmpl $0x9,-0xc(%ebp) 80104f80: 7f 0b jg 80104f8d <procdump+0xd8> 80104f82: 8b 45 f4 mov -0xc(%ebp),%eax 80104f85: 8b 44 85 c4 mov -0x3c(%ebp,%eax,4),%eax 80104f89: 85 c0 test %eax,%eax 80104f8b: 75 d4 jne 80104f61 <procdump+0xac> cprintf(" %p", pc[i]); } cprintf("\n"); 80104f8d: c7 04 24 55 8c 10 80 movl $0x80108c55,(%esp) 80104f94: e8 07 b4 ff ff call 801003a0 <cprintf> int i; struct proc *p; char *state; uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80104f99: 83 45 f0 7c addl $0x7c,-0x10(%ebp) 80104f9d: 81 7d f0 94 48 11 80 cmpl $0x80114894,-0x10(%ebp) 80104fa4: 0f 82 1d ff ff ff jb 80104ec7 <procdump+0x12> for(i=0; i<10 && pc[i] != 0; i++) cprintf(" %p", pc[i]); } cprintf("\n"); } } 80104faa: c9 leave 80104fab: c3 ret 80104fac <clone>: int clone(void(*fn)(void*), void *arg, void*stack) { 80104fac: 55 push %ebp 80104fad: 89 e5 mov %esp,%ebp 80104faf: 57 push %edi 80104fb0: 56 push %esi 80104fb1: 53 push %ebx 80104fb2: 83 ec 3c sub $0x3c,%esp int i, pid; struct proc *np; if((np = allocproc()) == 0) 80104fb5: e8 0c f4 ff ff call 801043c6 <allocproc> 80104fba: 89 45 e0 mov %eax,-0x20(%ebp) 80104fbd: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 80104fc1: 75 0a jne 80104fcd <clone+0x21> return -1; 80104fc3: b8 ff ff ff ff mov $0xffffffff,%eax 80104fc8: e9 91 01 00 00 jmp 8010515e <clone+0x1b2> np->pgdir = proc->pgdir; 80104fcd: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104fd3: 8b 50 04 mov 0x4(%eax),%edx 80104fd6: 8b 45 e0 mov -0x20(%ebp),%eax 80104fd9: 89 50 04 mov %edx,0x4(%eax) np->sz = proc->sz; 80104fdc: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104fe2: 8b 10 mov (%eax),%edx 80104fe4: 8b 45 e0 mov -0x20(%ebp),%eax 80104fe7: 89 10 mov %edx,(%eax) np->parent = proc; 80104fe9: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80104ff0: 8b 45 e0 mov -0x20(%ebp),%eax 80104ff3: 89 50 14 mov %edx,0x14(%eax) *np->tf = *proc->tf; 80104ff6: 8b 45 e0 mov -0x20(%ebp),%eax 80104ff9: 8b 50 18 mov 0x18(%eax),%edx 80104ffc: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105002: 8b 40 18 mov 0x18(%eax),%eax 80105005: 89 c3 mov %eax,%ebx 80105007: b8 13 00 00 00 mov $0x13,%eax 8010500c: 89 d7 mov %edx,%edi 8010500e: 89 de mov %ebx,%esi 80105010: 89 c1 mov %eax,%ecx 80105012: f3 a5 rep movsl %ds:(%esi),%es:(%edi) void * stackArg, *stackReturn; stackReturn = stack + 4096 -2* sizeof(void *); 80105014: 8b 45 10 mov 0x10(%ebp),%eax 80105017: 05 f8 0f 00 00 add $0xff8,%eax 8010501c: 89 45 dc mov %eax,-0x24(%ebp) *(uint*)stackReturn = 0xFFFFFFF; 8010501f: 8b 45 dc mov -0x24(%ebp),%eax 80105022: c7 00 ff ff ff 0f movl $0xfffffff,(%eax) stackArg = stack + 4096 - sizeof(void *); 80105028: 8b 45 10 mov 0x10(%ebp),%eax 8010502b: 05 fc 0f 00 00 add $0xffc,%eax 80105030: 89 45 d8 mov %eax,-0x28(%ebp) *(uint*)stackArg = (uint)arg; 80105033: 8b 55 0c mov 0xc(%ebp),%edx 80105036: 8b 45 d8 mov -0x28(%ebp),%eax 80105039: 89 10 mov %edx,(%eax) np->tf->esp = (int) stack; 8010503b: 8b 45 e0 mov -0x20(%ebp),%eax 8010503e: 8b 40 18 mov 0x18(%eax),%eax 80105041: 8b 55 10 mov 0x10(%ebp),%edx 80105044: 89 50 44 mov %edx,0x44(%eax) memmove((void*)np->tf->esp, stack, PGSIZE); 80105047: 8b 45 e0 mov -0x20(%ebp),%eax 8010504a: 8b 40 18 mov 0x18(%eax),%eax 8010504d: 8b 40 44 mov 0x44(%eax),%eax 80105050: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80105057: 00 80105058: 8b 55 10 mov 0x10(%ebp),%edx 8010505b: 89 54 24 04 mov %edx,0x4(%esp) 8010505f: 89 04 24 mov %eax,(%esp) 80105062: e8 7e 04 00 00 call 801054e5 <memmove> np->tf->esp += PGSIZE -2*sizeof(void*) ; 80105067: 8b 45 e0 mov -0x20(%ebp),%eax 8010506a: 8b 40 18 mov 0x18(%eax),%eax 8010506d: 8b 55 e0 mov -0x20(%ebp),%edx 80105070: 8b 52 18 mov 0x18(%edx),%edx 80105073: 8b 52 44 mov 0x44(%edx),%edx 80105076: 81 c2 f8 0f 00 00 add $0xff8,%edx 8010507c: 89 50 44 mov %edx,0x44(%eax) np->tf->ebp = np->tf->esp; 8010507f: 8b 45 e0 mov -0x20(%ebp),%eax 80105082: 8b 40 18 mov 0x18(%eax),%eax 80105085: 8b 55 e0 mov -0x20(%ebp),%edx 80105088: 8b 52 18 mov 0x18(%edx),%edx 8010508b: 8b 52 44 mov 0x44(%edx),%edx 8010508e: 89 50 08 mov %edx,0x8(%eax) np->tf->eip = (int) fn; 80105091: 8b 45 e0 mov -0x20(%ebp),%eax 80105094: 8b 40 18 mov 0x18(%eax),%eax 80105097: 8b 55 08 mov 0x8(%ebp),%edx 8010509a: 89 50 38 mov %edx,0x38(%eax) for(i = 0; i < NOFILE; i++) 8010509d: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 801050a4: eb 3d jmp 801050e3 <clone+0x137> if(proc->ofile[i]) 801050a6: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801050ac: 8b 55 e4 mov -0x1c(%ebp),%edx 801050af: 83 c2 08 add $0x8,%edx 801050b2: 8b 44 90 08 mov 0x8(%eax,%edx,4),%eax 801050b6: 85 c0 test %eax,%eax 801050b8: 74 25 je 801050df <clone+0x133> np->ofile[i] = filedup(proc->ofile[i]); 801050ba: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801050c0: 8b 55 e4 mov -0x1c(%ebp),%edx 801050c3: 83 c2 08 add $0x8,%edx 801050c6: 8b 44 90 08 mov 0x8(%eax,%edx,4),%eax 801050ca: 89 04 24 mov %eax,(%esp) 801050cd: e8 d2 be ff ff call 80100fa4 <filedup> 801050d2: 8b 55 e0 mov -0x20(%ebp),%edx 801050d5: 8b 4d e4 mov -0x1c(%ebp),%ecx 801050d8: 83 c1 08 add $0x8,%ecx 801050db: 89 44 8a 08 mov %eax,0x8(%edx,%ecx,4) memmove((void*)np->tf->esp, stack, PGSIZE); np->tf->esp += PGSIZE -2*sizeof(void*) ; np->tf->ebp = np->tf->esp; np->tf->eip = (int) fn; for(i = 0; i < NOFILE; i++) 801050df: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 801050e3: 83 7d e4 0f cmpl $0xf,-0x1c(%ebp) 801050e7: 7e bd jle 801050a6 <clone+0xfa> if(proc->ofile[i]) np->ofile[i] = filedup(proc->ofile[i]); np->cwd = idup(proc->cwd); 801050e9: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801050ef: 8b 40 68 mov 0x68(%eax),%eax 801050f2: 89 04 24 mov %eax,(%esp) 801050f5: e8 ac c7 ff ff call 801018a6 <idup> 801050fa: 8b 55 e0 mov -0x20(%ebp),%edx 801050fd: 89 42 68 mov %eax,0x68(%edx) safestrcpy(np->name, proc->name, sizeof(proc->name)); 80105100: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105106: 8d 50 6c lea 0x6c(%eax),%edx 80105109: 8b 45 e0 mov -0x20(%ebp),%eax 8010510c: 83 c0 6c add $0x6c,%eax 8010510f: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80105116: 00 80105117: 89 54 24 04 mov %edx,0x4(%esp) 8010511b: 89 04 24 mov %eax,(%esp) 8010511e: e8 13 05 00 00 call 80105636 <safestrcpy> pid = np->pid; 80105123: 8b 45 e0 mov -0x20(%ebp),%eax 80105126: 8b 40 10 mov 0x10(%eax),%eax 80105129: 89 45 d4 mov %eax,-0x2c(%ebp) np->tf->eax = 0; 8010512c: 8b 45 e0 mov -0x20(%ebp),%eax 8010512f: 8b 40 18 mov 0x18(%eax),%eax 80105132: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) acquire(&ptable.lock); 80105139: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80105140: e8 7a 00 00 00 call 801051bf <acquire> np->state = RUNNABLE; 80105145: 8b 45 e0 mov -0x20(%ebp),%eax 80105148: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) release(&ptable.lock); 8010514f: c7 04 24 60 29 11 80 movl $0x80112960,(%esp) 80105156: e8 c6 00 00 00 call 80105221 <release> return pid; 8010515b: 8b 45 d4 mov -0x2c(%ebp),%eax 8010515e: 83 c4 3c add $0x3c,%esp 80105161: 5b pop %ebx 80105162: 5e pop %esi 80105163: 5f pop %edi 80105164: 5d pop %ebp 80105165: c3 ret 80105166: 66 90 xchg %ax,%ax 80105168 <readeflags>: asm volatile("ltr %0" : : "r" (sel)); } static inline uint readeflags(void) { 80105168: 55 push %ebp 80105169: 89 e5 mov %esp,%ebp 8010516b: 83 ec 10 sub $0x10,%esp uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 8010516e: 9c pushf 8010516f: 58 pop %eax 80105170: 89 45 fc mov %eax,-0x4(%ebp) return eflags; 80105173: 8b 45 fc mov -0x4(%ebp),%eax } 80105176: c9 leave 80105177: c3 ret 80105178 <cli>: asm volatile("movw %0, %%gs" : : "r" (v)); } static inline void cli(void) { 80105178: 55 push %ebp 80105179: 89 e5 mov %esp,%ebp asm volatile("cli"); 8010517b: fa cli } 8010517c: 5d pop %ebp 8010517d: c3 ret 8010517e <sti>: static inline void sti(void) { 8010517e: 55 push %ebp 8010517f: 89 e5 mov %esp,%ebp asm volatile("sti"); 80105181: fb sti } 80105182: 5d pop %ebp 80105183: c3 ret 80105184 <xchg>: static inline uint xchg(volatile uint *addr, uint newval) { 80105184: 55 push %ebp 80105185: 89 e5 mov %esp,%ebp 80105187: 83 ec 10 sub $0x10,%esp uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 8010518a: 8b 55 08 mov 0x8(%ebp),%edx 8010518d: 8b 45 0c mov 0xc(%ebp),%eax 80105190: 8b 4d 08 mov 0x8(%ebp),%ecx 80105193: f0 87 02 lock xchg %eax,(%edx) 80105196: 89 45 fc mov %eax,-0x4(%ebp) "+m" (*addr), "=a" (result) : "1" (newval) : "cc"); return result; 80105199: 8b 45 fc mov -0x4(%ebp),%eax } 8010519c: c9 leave 8010519d: c3 ret 8010519e <initlock>: #include "proc.h" #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { 8010519e: 55 push %ebp 8010519f: 89 e5 mov %esp,%ebp lk->name = name; 801051a1: 8b 45 08 mov 0x8(%ebp),%eax 801051a4: 8b 55 0c mov 0xc(%ebp),%edx 801051a7: 89 50 04 mov %edx,0x4(%eax) lk->locked = 0; 801051aa: 8b 45 08 mov 0x8(%ebp),%eax 801051ad: c7 00 00 00 00 00 movl $0x0,(%eax) lk->cpu = 0; 801051b3: 8b 45 08 mov 0x8(%ebp),%eax 801051b6: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } 801051bd: 5d pop %ebp 801051be: c3 ret 801051bf <acquire>: // Loops (spins) until the lock is acquired. // Holding a lock for a long time may cause // other CPUs to waste time spinning to acquire it. void acquire(struct spinlock *lk) { 801051bf: 55 push %ebp 801051c0: 89 e5 mov %esp,%ebp 801051c2: 83 ec 18 sub $0x18,%esp pushcli(); // disable interrupts to avoid deadlock. 801051c5: e8 49 01 00 00 call 80105313 <pushcli> if(holding(lk)) 801051ca: 8b 45 08 mov 0x8(%ebp),%eax 801051cd: 89 04 24 mov %eax,(%esp) 801051d0: e8 14 01 00 00 call 801052e9 <holding> 801051d5: 85 c0 test %eax,%eax 801051d7: 74 0c je 801051e5 <acquire+0x26> panic("acquire"); 801051d9: c7 04 24 81 8c 10 80 movl $0x80108c81,(%esp) 801051e0: e8 55 b3 ff ff call 8010053a <panic> // The xchg is atomic. // It also serializes, so that reads after acquire are not // reordered before it. while(xchg(&lk->locked, 1) != 0) 801051e5: 90 nop 801051e6: 8b 45 08 mov 0x8(%ebp),%eax 801051e9: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 801051f0: 00 801051f1: 89 04 24 mov %eax,(%esp) 801051f4: e8 8b ff ff ff call 80105184 <xchg> 801051f9: 85 c0 test %eax,%eax 801051fb: 75 e9 jne 801051e6 <acquire+0x27> ; // Record info about lock acquisition for debugging. lk->cpu = cpu; 801051fd: 8b 45 08 mov 0x8(%ebp),%eax 80105200: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 80105207: 89 50 08 mov %edx,0x8(%eax) getcallerpcs(&lk, lk->pcs); 8010520a: 8b 45 08 mov 0x8(%ebp),%eax 8010520d: 83 c0 0c add $0xc,%eax 80105210: 89 44 24 04 mov %eax,0x4(%esp) 80105214: 8d 45 08 lea 0x8(%ebp),%eax 80105217: 89 04 24 mov %eax,(%esp) 8010521a: e8 51 00 00 00 call 80105270 <getcallerpcs> } 8010521f: c9 leave 80105220: c3 ret 80105221 <release>: // Release the lock. void release(struct spinlock *lk) { 80105221: 55 push %ebp 80105222: 89 e5 mov %esp,%ebp 80105224: 83 ec 18 sub $0x18,%esp if(!holding(lk)) 80105227: 8b 45 08 mov 0x8(%ebp),%eax 8010522a: 89 04 24 mov %eax,(%esp) 8010522d: e8 b7 00 00 00 call 801052e9 <holding> 80105232: 85 c0 test %eax,%eax 80105234: 75 0c jne 80105242 <release+0x21> panic("release"); 80105236: c7 04 24 89 8c 10 80 movl $0x80108c89,(%esp) 8010523d: e8 f8 b2 ff ff call 8010053a <panic> lk->pcs[0] = 0; 80105242: 8b 45 08 mov 0x8(%ebp),%eax 80105245: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) lk->cpu = 0; 8010524c: 8b 45 08 mov 0x8(%ebp),%eax 8010524f: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) // But the 2007 Intel 64 Architecture Memory Ordering White // Paper says that Intel 64 and IA-32 will not move a load // after a store. So lock->locked = 0 would work here. // The xchg being asm volatile ensures gcc emits it after // the above assignments (and after the critical section). xchg(&lk->locked, 0); 80105256: 8b 45 08 mov 0x8(%ebp),%eax 80105259: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105260: 00 80105261: 89 04 24 mov %eax,(%esp) 80105264: e8 1b ff ff ff call 80105184 <xchg> popcli(); 80105269: e8 e9 00 00 00 call 80105357 <popcli> } 8010526e: c9 leave 8010526f: c3 ret 80105270 <getcallerpcs>: // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80105270: 55 push %ebp 80105271: 89 e5 mov %esp,%ebp 80105273: 83 ec 10 sub $0x10,%esp uint *ebp; int i; ebp = (uint*)v - 2; 80105276: 8b 45 08 mov 0x8(%ebp),%eax 80105279: 83 e8 08 sub $0x8,%eax 8010527c: 89 45 fc mov %eax,-0x4(%ebp) for(i = 0; i < 10; i++){ 8010527f: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp) 80105286: eb 38 jmp 801052c0 <getcallerpcs+0x50> if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 80105288: 83 7d fc 00 cmpl $0x0,-0x4(%ebp) 8010528c: 74 38 je 801052c6 <getcallerpcs+0x56> 8010528e: 81 7d fc ff ff ff 7f cmpl $0x7fffffff,-0x4(%ebp) 80105295: 76 2f jbe 801052c6 <getcallerpcs+0x56> 80105297: 83 7d fc ff cmpl $0xffffffff,-0x4(%ebp) 8010529b: 74 29 je 801052c6 <getcallerpcs+0x56> break; pcs[i] = ebp[1]; // saved %eip 8010529d: 8b 45 f8 mov -0x8(%ebp),%eax 801052a0: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 801052a7: 8b 45 0c mov 0xc(%ebp),%eax 801052aa: 01 c2 add %eax,%edx 801052ac: 8b 45 fc mov -0x4(%ebp),%eax 801052af: 8b 40 04 mov 0x4(%eax),%eax 801052b2: 89 02 mov %eax,(%edx) ebp = (uint*)ebp[0]; // saved %ebp 801052b4: 8b 45 fc mov -0x4(%ebp),%eax 801052b7: 8b 00 mov (%eax),%eax 801052b9: 89 45 fc mov %eax,-0x4(%ebp) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 801052bc: 83 45 f8 01 addl $0x1,-0x8(%ebp) 801052c0: 83 7d f8 09 cmpl $0x9,-0x8(%ebp) 801052c4: 7e c2 jle 80105288 <getcallerpcs+0x18> if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 801052c6: eb 19 jmp 801052e1 <getcallerpcs+0x71> pcs[i] = 0; 801052c8: 8b 45 f8 mov -0x8(%ebp),%eax 801052cb: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 801052d2: 8b 45 0c mov 0xc(%ebp),%eax 801052d5: 01 d0 add %edx,%eax 801052d7: c7 00 00 00 00 00 movl $0x0,(%eax) if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 801052dd: 83 45 f8 01 addl $0x1,-0x8(%ebp) 801052e1: 83 7d f8 09 cmpl $0x9,-0x8(%ebp) 801052e5: 7e e1 jle 801052c8 <getcallerpcs+0x58> pcs[i] = 0; } 801052e7: c9 leave 801052e8: c3 ret 801052e9 <holding>: // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { 801052e9: 55 push %ebp 801052ea: 89 e5 mov %esp,%ebp return lock->locked && lock->cpu == cpu; 801052ec: 8b 45 08 mov 0x8(%ebp),%eax 801052ef: 8b 00 mov (%eax),%eax 801052f1: 85 c0 test %eax,%eax 801052f3: 74 17 je 8010530c <holding+0x23> 801052f5: 8b 45 08 mov 0x8(%ebp),%eax 801052f8: 8b 50 08 mov 0x8(%eax),%edx 801052fb: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80105301: 39 c2 cmp %eax,%edx 80105303: 75 07 jne 8010530c <holding+0x23> 80105305: b8 01 00 00 00 mov $0x1,%eax 8010530a: eb 05 jmp 80105311 <holding+0x28> 8010530c: b8 00 00 00 00 mov $0x0,%eax } 80105311: 5d pop %ebp 80105312: c3 ret 80105313 <pushcli>: // it takes two popcli to undo two pushcli. Also, if interrupts // are off, then pushcli, popcli leaves them off. void pushcli(void) { 80105313: 55 push %ebp 80105314: 89 e5 mov %esp,%ebp 80105316: 83 ec 10 sub $0x10,%esp int eflags; eflags = readeflags(); 80105319: e8 4a fe ff ff call 80105168 <readeflags> 8010531e: 89 45 fc mov %eax,-0x4(%ebp) cli(); 80105321: e8 52 fe ff ff call 80105178 <cli> if(cpu->ncli++ == 0) 80105326: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 8010532d: 8b 82 ac 00 00 00 mov 0xac(%edx),%eax 80105333: 8d 48 01 lea 0x1(%eax),%ecx 80105336: 89 8a ac 00 00 00 mov %ecx,0xac(%edx) 8010533c: 85 c0 test %eax,%eax 8010533e: 75 15 jne 80105355 <pushcli+0x42> cpu->intena = eflags & FL_IF; 80105340: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80105346: 8b 55 fc mov -0x4(%ebp),%edx 80105349: 81 e2 00 02 00 00 and $0x200,%edx 8010534f: 89 90 b0 00 00 00 mov %edx,0xb0(%eax) } 80105355: c9 leave 80105356: c3 ret 80105357 <popcli>: void popcli(void) { 80105357: 55 push %ebp 80105358: 89 e5 mov %esp,%ebp 8010535a: 83 ec 18 sub $0x18,%esp if(readeflags()&FL_IF) 8010535d: e8 06 fe ff ff call 80105168 <readeflags> 80105362: 25 00 02 00 00 and $0x200,%eax 80105367: 85 c0 test %eax,%eax 80105369: 74 0c je 80105377 <popcli+0x20> panic("popcli - interruptible"); 8010536b: c7 04 24 91 8c 10 80 movl $0x80108c91,(%esp) 80105372: e8 c3 b1 ff ff call 8010053a <panic> if(--cpu->ncli < 0) 80105377: 65 a1 00 00 00 00 mov %gs:0x0,%eax 8010537d: 8b 90 ac 00 00 00 mov 0xac(%eax),%edx 80105383: 83 ea 01 sub $0x1,%edx 80105386: 89 90 ac 00 00 00 mov %edx,0xac(%eax) 8010538c: 8b 80 ac 00 00 00 mov 0xac(%eax),%eax 80105392: 85 c0 test %eax,%eax 80105394: 79 0c jns 801053a2 <popcli+0x4b> panic("popcli"); 80105396: c7 04 24 a8 8c 10 80 movl $0x80108ca8,(%esp) 8010539d: e8 98 b1 ff ff call 8010053a <panic> if(cpu->ncli == 0 && cpu->intena) 801053a2: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801053a8: 8b 80 ac 00 00 00 mov 0xac(%eax),%eax 801053ae: 85 c0 test %eax,%eax 801053b0: 75 15 jne 801053c7 <popcli+0x70> 801053b2: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801053b8: 8b 80 b0 00 00 00 mov 0xb0(%eax),%eax 801053be: 85 c0 test %eax,%eax 801053c0: 74 05 je 801053c7 <popcli+0x70> sti(); 801053c2: e8 b7 fd ff ff call 8010517e <sti> } 801053c7: c9 leave 801053c8: c3 ret 801053c9: 66 90 xchg %ax,%ax 801053cb: 90 nop 801053cc <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 801053cc: 55 push %ebp 801053cd: 89 e5 mov %esp,%ebp 801053cf: 57 push %edi 801053d0: 53 push %ebx asm volatile("cld; rep stosb" : 801053d1: 8b 4d 08 mov 0x8(%ebp),%ecx 801053d4: 8b 55 10 mov 0x10(%ebp),%edx 801053d7: 8b 45 0c mov 0xc(%ebp),%eax 801053da: 89 cb mov %ecx,%ebx 801053dc: 89 df mov %ebx,%edi 801053de: 89 d1 mov %edx,%ecx 801053e0: fc cld 801053e1: f3 aa rep stos %al,%es:(%edi) 801053e3: 89 ca mov %ecx,%edx 801053e5: 89 fb mov %edi,%ebx 801053e7: 89 5d 08 mov %ebx,0x8(%ebp) 801053ea: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 801053ed: 5b pop %ebx 801053ee: 5f pop %edi 801053ef: 5d pop %ebp 801053f0: c3 ret 801053f1 <stosl>: static inline void stosl(void *addr, int data, int cnt) { 801053f1: 55 push %ebp 801053f2: 89 e5 mov %esp,%ebp 801053f4: 57 push %edi 801053f5: 53 push %ebx asm volatile("cld; rep stosl" : 801053f6: 8b 4d 08 mov 0x8(%ebp),%ecx 801053f9: 8b 55 10 mov 0x10(%ebp),%edx 801053fc: 8b 45 0c mov 0xc(%ebp),%eax 801053ff: 89 cb mov %ecx,%ebx 80105401: 89 df mov %ebx,%edi 80105403: 89 d1 mov %edx,%ecx 80105405: fc cld 80105406: f3 ab rep stos %eax,%es:(%edi) 80105408: 89 ca mov %ecx,%edx 8010540a: 89 fb mov %edi,%ebx 8010540c: 89 5d 08 mov %ebx,0x8(%ebp) 8010540f: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 80105412: 5b pop %ebx 80105413: 5f pop %edi 80105414: 5d pop %ebp 80105415: c3 ret 80105416 <memset>: #include "types.h" #include "x86.h" void* memset(void *dst, int c, uint n) { 80105416: 55 push %ebp 80105417: 89 e5 mov %esp,%ebp 80105419: 83 ec 0c sub $0xc,%esp if ((int)dst%4 == 0 && n%4 == 0){ 8010541c: 8b 45 08 mov 0x8(%ebp),%eax 8010541f: 83 e0 03 and $0x3,%eax 80105422: 85 c0 test %eax,%eax 80105424: 75 49 jne 8010546f <memset+0x59> 80105426: 8b 45 10 mov 0x10(%ebp),%eax 80105429: 83 e0 03 and $0x3,%eax 8010542c: 85 c0 test %eax,%eax 8010542e: 75 3f jne 8010546f <memset+0x59> c &= 0xFF; 80105430: 81 65 0c ff 00 00 00 andl $0xff,0xc(%ebp) stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); 80105437: 8b 45 10 mov 0x10(%ebp),%eax 8010543a: c1 e8 02 shr $0x2,%eax 8010543d: 89 c2 mov %eax,%edx 8010543f: 8b 45 0c mov 0xc(%ebp),%eax 80105442: c1 e0 18 shl $0x18,%eax 80105445: 89 c1 mov %eax,%ecx 80105447: 8b 45 0c mov 0xc(%ebp),%eax 8010544a: c1 e0 10 shl $0x10,%eax 8010544d: 09 c1 or %eax,%ecx 8010544f: 8b 45 0c mov 0xc(%ebp),%eax 80105452: c1 e0 08 shl $0x8,%eax 80105455: 09 c8 or %ecx,%eax 80105457: 0b 45 0c or 0xc(%ebp),%eax 8010545a: 89 54 24 08 mov %edx,0x8(%esp) 8010545e: 89 44 24 04 mov %eax,0x4(%esp) 80105462: 8b 45 08 mov 0x8(%ebp),%eax 80105465: 89 04 24 mov %eax,(%esp) 80105468: e8 84 ff ff ff call 801053f1 <stosl> 8010546d: eb 19 jmp 80105488 <memset+0x72> } else stosb(dst, c, n); 8010546f: 8b 45 10 mov 0x10(%ebp),%eax 80105472: 89 44 24 08 mov %eax,0x8(%esp) 80105476: 8b 45 0c mov 0xc(%ebp),%eax 80105479: 89 44 24 04 mov %eax,0x4(%esp) 8010547d: 8b 45 08 mov 0x8(%ebp),%eax 80105480: 89 04 24 mov %eax,(%esp) 80105483: e8 44 ff ff ff call 801053cc <stosb> return dst; 80105488: 8b 45 08 mov 0x8(%ebp),%eax } 8010548b: c9 leave 8010548c: c3 ret 8010548d <memcmp>: int memcmp(const void *v1, const void *v2, uint n) { 8010548d: 55 push %ebp 8010548e: 89 e5 mov %esp,%ebp 80105490: 83 ec 10 sub $0x10,%esp const uchar *s1, *s2; s1 = v1; 80105493: 8b 45 08 mov 0x8(%ebp),%eax 80105496: 89 45 fc mov %eax,-0x4(%ebp) s2 = v2; 80105499: 8b 45 0c mov 0xc(%ebp),%eax 8010549c: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0){ 8010549f: eb 30 jmp 801054d1 <memcmp+0x44> if(*s1 != *s2) 801054a1: 8b 45 fc mov -0x4(%ebp),%eax 801054a4: 0f b6 10 movzbl (%eax),%edx 801054a7: 8b 45 f8 mov -0x8(%ebp),%eax 801054aa: 0f b6 00 movzbl (%eax),%eax 801054ad: 38 c2 cmp %al,%dl 801054af: 74 18 je 801054c9 <memcmp+0x3c> return *s1 - *s2; 801054b1: 8b 45 fc mov -0x4(%ebp),%eax 801054b4: 0f b6 00 movzbl (%eax),%eax 801054b7: 0f b6 d0 movzbl %al,%edx 801054ba: 8b 45 f8 mov -0x8(%ebp),%eax 801054bd: 0f b6 00 movzbl (%eax),%eax 801054c0: 0f b6 c0 movzbl %al,%eax 801054c3: 29 c2 sub %eax,%edx 801054c5: 89 d0 mov %edx,%eax 801054c7: eb 1a jmp 801054e3 <memcmp+0x56> s1++, s2++; 801054c9: 83 45 fc 01 addl $0x1,-0x4(%ebp) 801054cd: 83 45 f8 01 addl $0x1,-0x8(%ebp) { const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 801054d1: 8b 45 10 mov 0x10(%ebp),%eax 801054d4: 8d 50 ff lea -0x1(%eax),%edx 801054d7: 89 55 10 mov %edx,0x10(%ebp) 801054da: 85 c0 test %eax,%eax 801054dc: 75 c3 jne 801054a1 <memcmp+0x14> if(*s1 != *s2) return *s1 - *s2; s1++, s2++; } return 0; 801054de: b8 00 00 00 00 mov $0x0,%eax } 801054e3: c9 leave 801054e4: c3 ret 801054e5 <memmove>: void* memmove(void *dst, const void *src, uint n) { 801054e5: 55 push %ebp 801054e6: 89 e5 mov %esp,%ebp 801054e8: 83 ec 10 sub $0x10,%esp const char *s; char *d; s = src; 801054eb: 8b 45 0c mov 0xc(%ebp),%eax 801054ee: 89 45 fc mov %eax,-0x4(%ebp) d = dst; 801054f1: 8b 45 08 mov 0x8(%ebp),%eax 801054f4: 89 45 f8 mov %eax,-0x8(%ebp) if(s < d && s + n > d){ 801054f7: 8b 45 fc mov -0x4(%ebp),%eax 801054fa: 3b 45 f8 cmp -0x8(%ebp),%eax 801054fd: 73 3d jae 8010553c <memmove+0x57> 801054ff: 8b 45 10 mov 0x10(%ebp),%eax 80105502: 8b 55 fc mov -0x4(%ebp),%edx 80105505: 01 d0 add %edx,%eax 80105507: 3b 45 f8 cmp -0x8(%ebp),%eax 8010550a: 76 30 jbe 8010553c <memmove+0x57> s += n; 8010550c: 8b 45 10 mov 0x10(%ebp),%eax 8010550f: 01 45 fc add %eax,-0x4(%ebp) d += n; 80105512: 8b 45 10 mov 0x10(%ebp),%eax 80105515: 01 45 f8 add %eax,-0x8(%ebp) while(n-- > 0) 80105518: eb 13 jmp 8010552d <memmove+0x48> *--d = *--s; 8010551a: 83 6d f8 01 subl $0x1,-0x8(%ebp) 8010551e: 83 6d fc 01 subl $0x1,-0x4(%ebp) 80105522: 8b 45 fc mov -0x4(%ebp),%eax 80105525: 0f b6 10 movzbl (%eax),%edx 80105528: 8b 45 f8 mov -0x8(%ebp),%eax 8010552b: 88 10 mov %dl,(%eax) s = src; d = dst; if(s < d && s + n > d){ s += n; d += n; while(n-- > 0) 8010552d: 8b 45 10 mov 0x10(%ebp),%eax 80105530: 8d 50 ff lea -0x1(%eax),%edx 80105533: 89 55 10 mov %edx,0x10(%ebp) 80105536: 85 c0 test %eax,%eax 80105538: 75 e0 jne 8010551a <memmove+0x35> const char *s; char *d; s = src; d = dst; if(s < d && s + n > d){ 8010553a: eb 26 jmp 80105562 <memmove+0x7d> s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 8010553c: eb 17 jmp 80105555 <memmove+0x70> *d++ = *s++; 8010553e: 8b 45 f8 mov -0x8(%ebp),%eax 80105541: 8d 50 01 lea 0x1(%eax),%edx 80105544: 89 55 f8 mov %edx,-0x8(%ebp) 80105547: 8b 55 fc mov -0x4(%ebp),%edx 8010554a: 8d 4a 01 lea 0x1(%edx),%ecx 8010554d: 89 4d fc mov %ecx,-0x4(%ebp) 80105550: 0f b6 12 movzbl (%edx),%edx 80105553: 88 10 mov %dl,(%eax) s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 80105555: 8b 45 10 mov 0x10(%ebp),%eax 80105558: 8d 50 ff lea -0x1(%eax),%edx 8010555b: 89 55 10 mov %edx,0x10(%ebp) 8010555e: 85 c0 test %eax,%eax 80105560: 75 dc jne 8010553e <memmove+0x59> *d++ = *s++; return dst; 80105562: 8b 45 08 mov 0x8(%ebp),%eax } 80105565: c9 leave 80105566: c3 ret 80105567 <memcpy>: // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { 80105567: 55 push %ebp 80105568: 89 e5 mov %esp,%ebp 8010556a: 83 ec 0c sub $0xc,%esp return memmove(dst, src, n); 8010556d: 8b 45 10 mov 0x10(%ebp),%eax 80105570: 89 44 24 08 mov %eax,0x8(%esp) 80105574: 8b 45 0c mov 0xc(%ebp),%eax 80105577: 89 44 24 04 mov %eax,0x4(%esp) 8010557b: 8b 45 08 mov 0x8(%ebp),%eax 8010557e: 89 04 24 mov %eax,(%esp) 80105581: e8 5f ff ff ff call 801054e5 <memmove> } 80105586: c9 leave 80105587: c3 ret 80105588 <strncmp>: int strncmp(const char *p, const char *q, uint n) { 80105588: 55 push %ebp 80105589: 89 e5 mov %esp,%ebp while(n > 0 && *p && *p == *q) 8010558b: eb 0c jmp 80105599 <strncmp+0x11> n--, p++, q++; 8010558d: 83 6d 10 01 subl $0x1,0x10(%ebp) 80105591: 83 45 08 01 addl $0x1,0x8(%ebp) 80105595: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 80105599: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 8010559d: 74 1a je 801055b9 <strncmp+0x31> 8010559f: 8b 45 08 mov 0x8(%ebp),%eax 801055a2: 0f b6 00 movzbl (%eax),%eax 801055a5: 84 c0 test %al,%al 801055a7: 74 10 je 801055b9 <strncmp+0x31> 801055a9: 8b 45 08 mov 0x8(%ebp),%eax 801055ac: 0f b6 10 movzbl (%eax),%edx 801055af: 8b 45 0c mov 0xc(%ebp),%eax 801055b2: 0f b6 00 movzbl (%eax),%eax 801055b5: 38 c2 cmp %al,%dl 801055b7: 74 d4 je 8010558d <strncmp+0x5> n--, p++, q++; if(n == 0) 801055b9: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 801055bd: 75 07 jne 801055c6 <strncmp+0x3e> return 0; 801055bf: b8 00 00 00 00 mov $0x0,%eax 801055c4: eb 16 jmp 801055dc <strncmp+0x54> return (uchar)*p - (uchar)*q; 801055c6: 8b 45 08 mov 0x8(%ebp),%eax 801055c9: 0f b6 00 movzbl (%eax),%eax 801055cc: 0f b6 d0 movzbl %al,%edx 801055cf: 8b 45 0c mov 0xc(%ebp),%eax 801055d2: 0f b6 00 movzbl (%eax),%eax 801055d5: 0f b6 c0 movzbl %al,%eax 801055d8: 29 c2 sub %eax,%edx 801055da: 89 d0 mov %edx,%eax } 801055dc: 5d pop %ebp 801055dd: c3 ret 801055de <strncpy>: char* strncpy(char *s, const char *t, int n) { 801055de: 55 push %ebp 801055df: 89 e5 mov %esp,%ebp 801055e1: 83 ec 10 sub $0x10,%esp char *os; os = s; 801055e4: 8b 45 08 mov 0x8(%ebp),%eax 801055e7: 89 45 fc mov %eax,-0x4(%ebp) while(n-- > 0 && (*s++ = *t++) != 0) 801055ea: 90 nop 801055eb: 8b 45 10 mov 0x10(%ebp),%eax 801055ee: 8d 50 ff lea -0x1(%eax),%edx 801055f1: 89 55 10 mov %edx,0x10(%ebp) 801055f4: 85 c0 test %eax,%eax 801055f6: 7e 1e jle 80105616 <strncpy+0x38> 801055f8: 8b 45 08 mov 0x8(%ebp),%eax 801055fb: 8d 50 01 lea 0x1(%eax),%edx 801055fe: 89 55 08 mov %edx,0x8(%ebp) 80105601: 8b 55 0c mov 0xc(%ebp),%edx 80105604: 8d 4a 01 lea 0x1(%edx),%ecx 80105607: 89 4d 0c mov %ecx,0xc(%ebp) 8010560a: 0f b6 12 movzbl (%edx),%edx 8010560d: 88 10 mov %dl,(%eax) 8010560f: 0f b6 00 movzbl (%eax),%eax 80105612: 84 c0 test %al,%al 80105614: 75 d5 jne 801055eb <strncpy+0xd> ; while(n-- > 0) 80105616: eb 0c jmp 80105624 <strncpy+0x46> *s++ = 0; 80105618: 8b 45 08 mov 0x8(%ebp),%eax 8010561b: 8d 50 01 lea 0x1(%eax),%edx 8010561e: 89 55 08 mov %edx,0x8(%ebp) 80105621: c6 00 00 movb $0x0,(%eax) char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) ; while(n-- > 0) 80105624: 8b 45 10 mov 0x10(%ebp),%eax 80105627: 8d 50 ff lea -0x1(%eax),%edx 8010562a: 89 55 10 mov %edx,0x10(%ebp) 8010562d: 85 c0 test %eax,%eax 8010562f: 7f e7 jg 80105618 <strncpy+0x3a> *s++ = 0; return os; 80105631: 8b 45 fc mov -0x4(%ebp),%eax } 80105634: c9 leave 80105635: c3 ret 80105636 <safestrcpy>: // Like strncpy but guaranteed to NUL-terminate. char* safestrcpy(char *s, const char *t, int n) { 80105636: 55 push %ebp 80105637: 89 e5 mov %esp,%ebp 80105639: 83 ec 10 sub $0x10,%esp char *os; os = s; 8010563c: 8b 45 08 mov 0x8(%ebp),%eax 8010563f: 89 45 fc mov %eax,-0x4(%ebp) if(n <= 0) 80105642: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 80105646: 7f 05 jg 8010564d <safestrcpy+0x17> return os; 80105648: 8b 45 fc mov -0x4(%ebp),%eax 8010564b: eb 31 jmp 8010567e <safestrcpy+0x48> while(--n > 0 && (*s++ = *t++) != 0) 8010564d: 83 6d 10 01 subl $0x1,0x10(%ebp) 80105651: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 80105655: 7e 1e jle 80105675 <safestrcpy+0x3f> 80105657: 8b 45 08 mov 0x8(%ebp),%eax 8010565a: 8d 50 01 lea 0x1(%eax),%edx 8010565d: 89 55 08 mov %edx,0x8(%ebp) 80105660: 8b 55 0c mov 0xc(%ebp),%edx 80105663: 8d 4a 01 lea 0x1(%edx),%ecx 80105666: 89 4d 0c mov %ecx,0xc(%ebp) 80105669: 0f b6 12 movzbl (%edx),%edx 8010566c: 88 10 mov %dl,(%eax) 8010566e: 0f b6 00 movzbl (%eax),%eax 80105671: 84 c0 test %al,%al 80105673: 75 d8 jne 8010564d <safestrcpy+0x17> ; *s = 0; 80105675: 8b 45 08 mov 0x8(%ebp),%eax 80105678: c6 00 00 movb $0x0,(%eax) return os; 8010567b: 8b 45 fc mov -0x4(%ebp),%eax } 8010567e: c9 leave 8010567f: c3 ret 80105680 <strlen>: int strlen(const char *s) { 80105680: 55 push %ebp 80105681: 89 e5 mov %esp,%ebp 80105683: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 80105686: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 8010568d: eb 04 jmp 80105693 <strlen+0x13> 8010568f: 83 45 fc 01 addl $0x1,-0x4(%ebp) 80105693: 8b 55 fc mov -0x4(%ebp),%edx 80105696: 8b 45 08 mov 0x8(%ebp),%eax 80105699: 01 d0 add %edx,%eax 8010569b: 0f b6 00 movzbl (%eax),%eax 8010569e: 84 c0 test %al,%al 801056a0: 75 ed jne 8010568f <strlen+0xf> ; return n; 801056a2: 8b 45 fc mov -0x4(%ebp),%eax } 801056a5: c9 leave 801056a6: c3 ret 801056a7: 90 nop 801056a8 <swtch>: # Save current register context in old # and then load register context from new. .globl swtch swtch: movl 4(%esp), %eax 801056a8: 8b 44 24 04 mov 0x4(%esp),%eax movl 8(%esp), %edx 801056ac: 8b 54 24 08 mov 0x8(%esp),%edx # Save old callee-save registers pushl %ebp 801056b0: 55 push %ebp pushl %ebx 801056b1: 53 push %ebx pushl %esi 801056b2: 56 push %esi pushl %edi 801056b3: 57 push %edi # Switch stacks movl %esp, (%eax) 801056b4: 89 20 mov %esp,(%eax) movl %edx, %esp 801056b6: 89 d4 mov %edx,%esp # Load new callee-save registers popl %edi 801056b8: 5f pop %edi popl %esi 801056b9: 5e pop %esi popl %ebx 801056ba: 5b pop %ebx popl %ebp 801056bb: 5d pop %ebp ret 801056bc: c3 ret 801056bd: 66 90 xchg %ax,%ax 801056bf: 90 nop 801056c0 <fetchint>: // to a saved program counter, and then the first argument. // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { 801056c0: 55 push %ebp 801056c1: 89 e5 mov %esp,%ebp if(addr >= proc->sz || addr+4 > proc->sz) 801056c3: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801056c9: 8b 00 mov (%eax),%eax 801056cb: 3b 45 08 cmp 0x8(%ebp),%eax 801056ce: 76 12 jbe 801056e2 <fetchint+0x22> 801056d0: 8b 45 08 mov 0x8(%ebp),%eax 801056d3: 8d 50 04 lea 0x4(%eax),%edx 801056d6: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801056dc: 8b 00 mov (%eax),%eax 801056de: 39 c2 cmp %eax,%edx 801056e0: 76 07 jbe 801056e9 <fetchint+0x29> return -1; 801056e2: b8 ff ff ff ff mov $0xffffffff,%eax 801056e7: eb 0f jmp 801056f8 <fetchint+0x38> *ip = *(int*)(addr); 801056e9: 8b 45 08 mov 0x8(%ebp),%eax 801056ec: 8b 10 mov (%eax),%edx 801056ee: 8b 45 0c mov 0xc(%ebp),%eax 801056f1: 89 10 mov %edx,(%eax) return 0; 801056f3: b8 00 00 00 00 mov $0x0,%eax } 801056f8: 5d pop %ebp 801056f9: c3 ret 801056fa <fetchstr>: // Fetch the nul-terminated string at addr from the current process. // Doesn't actually copy the string - just sets *pp to point at it. // Returns length of string, not including nul. int fetchstr(uint addr, char **pp) { 801056fa: 55 push %ebp 801056fb: 89 e5 mov %esp,%ebp 801056fd: 83 ec 10 sub $0x10,%esp char *s, *ep; if(addr >= proc->sz) 80105700: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105706: 8b 00 mov (%eax),%eax 80105708: 3b 45 08 cmp 0x8(%ebp),%eax 8010570b: 77 07 ja 80105714 <fetchstr+0x1a> return -1; 8010570d: b8 ff ff ff ff mov $0xffffffff,%eax 80105712: eb 46 jmp 8010575a <fetchstr+0x60> *pp = (char*)addr; 80105714: 8b 55 08 mov 0x8(%ebp),%edx 80105717: 8b 45 0c mov 0xc(%ebp),%eax 8010571a: 89 10 mov %edx,(%eax) ep = (char*)proc->sz; 8010571c: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105722: 8b 00 mov (%eax),%eax 80105724: 89 45 f8 mov %eax,-0x8(%ebp) for(s = *pp; s < ep; s++) 80105727: 8b 45 0c mov 0xc(%ebp),%eax 8010572a: 8b 00 mov (%eax),%eax 8010572c: 89 45 fc mov %eax,-0x4(%ebp) 8010572f: eb 1c jmp 8010574d <fetchstr+0x53> if(*s == 0) 80105731: 8b 45 fc mov -0x4(%ebp),%eax 80105734: 0f b6 00 movzbl (%eax),%eax 80105737: 84 c0 test %al,%al 80105739: 75 0e jne 80105749 <fetchstr+0x4f> return s - *pp; 8010573b: 8b 55 fc mov -0x4(%ebp),%edx 8010573e: 8b 45 0c mov 0xc(%ebp),%eax 80105741: 8b 00 mov (%eax),%eax 80105743: 29 c2 sub %eax,%edx 80105745: 89 d0 mov %edx,%eax 80105747: eb 11 jmp 8010575a <fetchstr+0x60> if(addr >= proc->sz) return -1; *pp = (char*)addr; ep = (char*)proc->sz; for(s = *pp; s < ep; s++) 80105749: 83 45 fc 01 addl $0x1,-0x4(%ebp) 8010574d: 8b 45 fc mov -0x4(%ebp),%eax 80105750: 3b 45 f8 cmp -0x8(%ebp),%eax 80105753: 72 dc jb 80105731 <fetchstr+0x37> if(*s == 0) return s - *pp; return -1; 80105755: b8 ff ff ff ff mov $0xffffffff,%eax } 8010575a: c9 leave 8010575b: c3 ret 8010575c <argint>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { 8010575c: 55 push %ebp 8010575d: 89 e5 mov %esp,%ebp 8010575f: 83 ec 08 sub $0x8,%esp return fetchint(proc->tf->esp + 4 + 4*n, ip); 80105762: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105768: 8b 40 18 mov 0x18(%eax),%eax 8010576b: 8b 50 44 mov 0x44(%eax),%edx 8010576e: 8b 45 08 mov 0x8(%ebp),%eax 80105771: c1 e0 02 shl $0x2,%eax 80105774: 01 d0 add %edx,%eax 80105776: 8d 50 04 lea 0x4(%eax),%edx 80105779: 8b 45 0c mov 0xc(%ebp),%eax 8010577c: 89 44 24 04 mov %eax,0x4(%esp) 80105780: 89 14 24 mov %edx,(%esp) 80105783: e8 38 ff ff ff call 801056c0 <fetchint> } 80105788: c9 leave 80105789: c3 ret 8010578a <argptr>: // Fetch the nth word-sized system call argument as a pointer // to a block of memory of size n bytes. Check that the pointer // lies within the process address space. int argptr(int n, char **pp, int size) { 8010578a: 55 push %ebp 8010578b: 89 e5 mov %esp,%ebp 8010578d: 83 ec 18 sub $0x18,%esp int i; if(argint(n, &i) < 0) 80105790: 8d 45 fc lea -0x4(%ebp),%eax 80105793: 89 44 24 04 mov %eax,0x4(%esp) 80105797: 8b 45 08 mov 0x8(%ebp),%eax 8010579a: 89 04 24 mov %eax,(%esp) 8010579d: e8 ba ff ff ff call 8010575c <argint> 801057a2: 85 c0 test %eax,%eax 801057a4: 79 07 jns 801057ad <argptr+0x23> return -1; 801057a6: b8 ff ff ff ff mov $0xffffffff,%eax 801057ab: eb 3d jmp 801057ea <argptr+0x60> if((uint)i >= proc->sz || (uint)i+size > proc->sz) 801057ad: 8b 45 fc mov -0x4(%ebp),%eax 801057b0: 89 c2 mov %eax,%edx 801057b2: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801057b8: 8b 00 mov (%eax),%eax 801057ba: 39 c2 cmp %eax,%edx 801057bc: 73 16 jae 801057d4 <argptr+0x4a> 801057be: 8b 45 fc mov -0x4(%ebp),%eax 801057c1: 89 c2 mov %eax,%edx 801057c3: 8b 45 10 mov 0x10(%ebp),%eax 801057c6: 01 c2 add %eax,%edx 801057c8: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801057ce: 8b 00 mov (%eax),%eax 801057d0: 39 c2 cmp %eax,%edx 801057d2: 76 07 jbe 801057db <argptr+0x51> return -1; 801057d4: b8 ff ff ff ff mov $0xffffffff,%eax 801057d9: eb 0f jmp 801057ea <argptr+0x60> *pp = (char*)i; 801057db: 8b 45 fc mov -0x4(%ebp),%eax 801057de: 89 c2 mov %eax,%edx 801057e0: 8b 45 0c mov 0xc(%ebp),%eax 801057e3: 89 10 mov %edx,(%eax) return 0; 801057e5: b8 00 00 00 00 mov $0x0,%eax } 801057ea: c9 leave 801057eb: c3 ret 801057ec <argstr>: // Check that the pointer is valid and the string is nul-terminated. // (There is no shared writable memory, so the string can't change // between this check and being used by the kernel.) int argstr(int n, char **pp) { 801057ec: 55 push %ebp 801057ed: 89 e5 mov %esp,%ebp 801057ef: 83 ec 18 sub $0x18,%esp int addr; if(argint(n, &addr) < 0) 801057f2: 8d 45 fc lea -0x4(%ebp),%eax 801057f5: 89 44 24 04 mov %eax,0x4(%esp) 801057f9: 8b 45 08 mov 0x8(%ebp),%eax 801057fc: 89 04 24 mov %eax,(%esp) 801057ff: e8 58 ff ff ff call 8010575c <argint> 80105804: 85 c0 test %eax,%eax 80105806: 79 07 jns 8010580f <argstr+0x23> return -1; 80105808: b8 ff ff ff ff mov $0xffffffff,%eax 8010580d: eb 12 jmp 80105821 <argstr+0x35> return fetchstr(addr, pp); 8010580f: 8b 45 fc mov -0x4(%ebp),%eax 80105812: 8b 55 0c mov 0xc(%ebp),%edx 80105815: 89 54 24 04 mov %edx,0x4(%esp) 80105819: 89 04 24 mov %eax,(%esp) 8010581c: e8 d9 fe ff ff call 801056fa <fetchstr> } 80105821: c9 leave 80105822: c3 ret 80105823 <syscall>: [SYS_join] sys_join, }; void syscall(void) { 80105823: 55 push %ebp 80105824: 89 e5 mov %esp,%ebp 80105826: 53 push %ebx 80105827: 83 ec 24 sub $0x24,%esp int num; num = proc->tf->eax; 8010582a: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105830: 8b 40 18 mov 0x18(%eax),%eax 80105833: 8b 40 1c mov 0x1c(%eax),%eax 80105836: 89 45 f4 mov %eax,-0xc(%ebp) if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 80105839: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 8010583d: 7e 30 jle 8010586f <syscall+0x4c> 8010583f: 8b 45 f4 mov -0xc(%ebp),%eax 80105842: 83 f8 17 cmp $0x17,%eax 80105845: 77 28 ja 8010586f <syscall+0x4c> 80105847: 8b 45 f4 mov -0xc(%ebp),%eax 8010584a: 8b 04 85 40 b0 10 80 mov -0x7fef4fc0(,%eax,4),%eax 80105851: 85 c0 test %eax,%eax 80105853: 74 1a je 8010586f <syscall+0x4c> proc->tf->eax = syscalls[num](); 80105855: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010585b: 8b 58 18 mov 0x18(%eax),%ebx 8010585e: 8b 45 f4 mov -0xc(%ebp),%eax 80105861: 8b 04 85 40 b0 10 80 mov -0x7fef4fc0(,%eax,4),%eax 80105868: ff d0 call *%eax 8010586a: 89 43 1c mov %eax,0x1c(%ebx) 8010586d: eb 3d jmp 801058ac <syscall+0x89> } else { cprintf("%d %s: unknown sys call %d\n", proc->pid, proc->name, num); 8010586f: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105875: 8d 48 6c lea 0x6c(%eax),%ecx 80105878: 65 a1 04 00 00 00 mov %gs:0x4,%eax num = proc->tf->eax; if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { proc->tf->eax = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", 8010587e: 8b 40 10 mov 0x10(%eax),%eax 80105881: 8b 55 f4 mov -0xc(%ebp),%edx 80105884: 89 54 24 0c mov %edx,0xc(%esp) 80105888: 89 4c 24 08 mov %ecx,0x8(%esp) 8010588c: 89 44 24 04 mov %eax,0x4(%esp) 80105890: c7 04 24 af 8c 10 80 movl $0x80108caf,(%esp) 80105897: e8 04 ab ff ff call 801003a0 <cprintf> proc->pid, proc->name, num); proc->tf->eax = -1; 8010589c: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801058a2: 8b 40 18 mov 0x18(%eax),%eax 801058a5: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) } } 801058ac: 83 c4 24 add $0x24,%esp 801058af: 5b pop %ebx 801058b0: 5d pop %ebp 801058b1: c3 ret 801058b2: 66 90 xchg %ax,%ax 801058b4 <argfd>: // Fetch the nth word-sized system call argument as a file descriptor // and return both the descriptor and the corresponding struct file. static int argfd(int n, int *pfd, struct file **pf) { 801058b4: 55 push %ebp 801058b5: 89 e5 mov %esp,%ebp 801058b7: 83 ec 28 sub $0x28,%esp int fd; struct file *f; if(argint(n, &fd) < 0) 801058ba: 8d 45 f0 lea -0x10(%ebp),%eax 801058bd: 89 44 24 04 mov %eax,0x4(%esp) 801058c1: 8b 45 08 mov 0x8(%ebp),%eax 801058c4: 89 04 24 mov %eax,(%esp) 801058c7: e8 90 fe ff ff call 8010575c <argint> 801058cc: 85 c0 test %eax,%eax 801058ce: 79 07 jns 801058d7 <argfd+0x23> return -1; 801058d0: b8 ff ff ff ff mov $0xffffffff,%eax 801058d5: eb 50 jmp 80105927 <argfd+0x73> if(fd < 0 || fd >= NOFILE || (f=proc->ofile[fd]) == 0) 801058d7: 8b 45 f0 mov -0x10(%ebp),%eax 801058da: 85 c0 test %eax,%eax 801058dc: 78 21 js 801058ff <argfd+0x4b> 801058de: 8b 45 f0 mov -0x10(%ebp),%eax 801058e1: 83 f8 0f cmp $0xf,%eax 801058e4: 7f 19 jg 801058ff <argfd+0x4b> 801058e6: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801058ec: 8b 55 f0 mov -0x10(%ebp),%edx 801058ef: 83 c2 08 add $0x8,%edx 801058f2: 8b 44 90 08 mov 0x8(%eax,%edx,4),%eax 801058f6: 89 45 f4 mov %eax,-0xc(%ebp) 801058f9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801058fd: 75 07 jne 80105906 <argfd+0x52> return -1; 801058ff: b8 ff ff ff ff mov $0xffffffff,%eax 80105904: eb 21 jmp 80105927 <argfd+0x73> if(pfd) 80105906: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 8010590a: 74 08 je 80105914 <argfd+0x60> *pfd = fd; 8010590c: 8b 55 f0 mov -0x10(%ebp),%edx 8010590f: 8b 45 0c mov 0xc(%ebp),%eax 80105912: 89 10 mov %edx,(%eax) if(pf) 80105914: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 80105918: 74 08 je 80105922 <argfd+0x6e> *pf = f; 8010591a: 8b 45 10 mov 0x10(%ebp),%eax 8010591d: 8b 55 f4 mov -0xc(%ebp),%edx 80105920: 89 10 mov %edx,(%eax) return 0; 80105922: b8 00 00 00 00 mov $0x0,%eax } 80105927: c9 leave 80105928: c3 ret 80105929 <fdalloc>: // Allocate a file descriptor for the given file. // Takes over file reference from caller on success. static int fdalloc(struct file *f) { 80105929: 55 push %ebp 8010592a: 89 e5 mov %esp,%ebp 8010592c: 83 ec 10 sub $0x10,%esp int fd; for(fd = 0; fd < NOFILE; fd++){ 8010592f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 80105936: eb 30 jmp 80105968 <fdalloc+0x3f> if(proc->ofile[fd] == 0){ 80105938: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010593e: 8b 55 fc mov -0x4(%ebp),%edx 80105941: 83 c2 08 add $0x8,%edx 80105944: 8b 44 90 08 mov 0x8(%eax,%edx,4),%eax 80105948: 85 c0 test %eax,%eax 8010594a: 75 18 jne 80105964 <fdalloc+0x3b> proc->ofile[fd] = f; 8010594c: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105952: 8b 55 fc mov -0x4(%ebp),%edx 80105955: 8d 4a 08 lea 0x8(%edx),%ecx 80105958: 8b 55 08 mov 0x8(%ebp),%edx 8010595b: 89 54 88 08 mov %edx,0x8(%eax,%ecx,4) return fd; 8010595f: 8b 45 fc mov -0x4(%ebp),%eax 80105962: eb 0f jmp 80105973 <fdalloc+0x4a> static int fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ 80105964: 83 45 fc 01 addl $0x1,-0x4(%ebp) 80105968: 83 7d fc 0f cmpl $0xf,-0x4(%ebp) 8010596c: 7e ca jle 80105938 <fdalloc+0xf> if(proc->ofile[fd] == 0){ proc->ofile[fd] = f; return fd; } } return -1; 8010596e: b8 ff ff ff ff mov $0xffffffff,%eax } 80105973: c9 leave 80105974: c3 ret 80105975 <sys_dup>: int sys_dup(void) { 80105975: 55 push %ebp 80105976: 89 e5 mov %esp,%ebp 80105978: 83 ec 28 sub $0x28,%esp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 8010597b: 8d 45 f0 lea -0x10(%ebp),%eax 8010597e: 89 44 24 08 mov %eax,0x8(%esp) 80105982: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105989: 00 8010598a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105991: e8 1e ff ff ff call 801058b4 <argfd> 80105996: 85 c0 test %eax,%eax 80105998: 79 07 jns 801059a1 <sys_dup+0x2c> return -1; 8010599a: b8 ff ff ff ff mov $0xffffffff,%eax 8010599f: eb 29 jmp 801059ca <sys_dup+0x55> if((fd=fdalloc(f)) < 0) 801059a1: 8b 45 f0 mov -0x10(%ebp),%eax 801059a4: 89 04 24 mov %eax,(%esp) 801059a7: e8 7d ff ff ff call 80105929 <fdalloc> 801059ac: 89 45 f4 mov %eax,-0xc(%ebp) 801059af: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801059b3: 79 07 jns 801059bc <sys_dup+0x47> return -1; 801059b5: b8 ff ff ff ff mov $0xffffffff,%eax 801059ba: eb 0e jmp 801059ca <sys_dup+0x55> filedup(f); 801059bc: 8b 45 f0 mov -0x10(%ebp),%eax 801059bf: 89 04 24 mov %eax,(%esp) 801059c2: e8 dd b5 ff ff call 80100fa4 <filedup> return fd; 801059c7: 8b 45 f4 mov -0xc(%ebp),%eax } 801059ca: c9 leave 801059cb: c3 ret 801059cc <sys_read>: int sys_read(void) { 801059cc: 55 push %ebp 801059cd: 89 e5 mov %esp,%ebp 801059cf: 83 ec 28 sub $0x28,%esp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 801059d2: 8d 45 f4 lea -0xc(%ebp),%eax 801059d5: 89 44 24 08 mov %eax,0x8(%esp) 801059d9: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801059e0: 00 801059e1: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801059e8: e8 c7 fe ff ff call 801058b4 <argfd> 801059ed: 85 c0 test %eax,%eax 801059ef: 78 35 js 80105a26 <sys_read+0x5a> 801059f1: 8d 45 f0 lea -0x10(%ebp),%eax 801059f4: 89 44 24 04 mov %eax,0x4(%esp) 801059f8: c7 04 24 02 00 00 00 movl $0x2,(%esp) 801059ff: e8 58 fd ff ff call 8010575c <argint> 80105a04: 85 c0 test %eax,%eax 80105a06: 78 1e js 80105a26 <sys_read+0x5a> 80105a08: 8b 45 f0 mov -0x10(%ebp),%eax 80105a0b: 89 44 24 08 mov %eax,0x8(%esp) 80105a0f: 8d 45 ec lea -0x14(%ebp),%eax 80105a12: 89 44 24 04 mov %eax,0x4(%esp) 80105a16: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105a1d: e8 68 fd ff ff call 8010578a <argptr> 80105a22: 85 c0 test %eax,%eax 80105a24: 79 07 jns 80105a2d <sys_read+0x61> return -1; 80105a26: b8 ff ff ff ff mov $0xffffffff,%eax 80105a2b: eb 19 jmp 80105a46 <sys_read+0x7a> return fileread(f, p, n); 80105a2d: 8b 4d f0 mov -0x10(%ebp),%ecx 80105a30: 8b 55 ec mov -0x14(%ebp),%edx 80105a33: 8b 45 f4 mov -0xc(%ebp),%eax 80105a36: 89 4c 24 08 mov %ecx,0x8(%esp) 80105a3a: 89 54 24 04 mov %edx,0x4(%esp) 80105a3e: 89 04 24 mov %eax,(%esp) 80105a41: e8 cb b6 ff ff call 80101111 <fileread> } 80105a46: c9 leave 80105a47: c3 ret 80105a48 <sys_write>: int sys_write(void) { 80105a48: 55 push %ebp 80105a49: 89 e5 mov %esp,%ebp 80105a4b: 83 ec 28 sub $0x28,%esp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80105a4e: 8d 45 f4 lea -0xc(%ebp),%eax 80105a51: 89 44 24 08 mov %eax,0x8(%esp) 80105a55: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105a5c: 00 80105a5d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105a64: e8 4b fe ff ff call 801058b4 <argfd> 80105a69: 85 c0 test %eax,%eax 80105a6b: 78 35 js 80105aa2 <sys_write+0x5a> 80105a6d: 8d 45 f0 lea -0x10(%ebp),%eax 80105a70: 89 44 24 04 mov %eax,0x4(%esp) 80105a74: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80105a7b: e8 dc fc ff ff call 8010575c <argint> 80105a80: 85 c0 test %eax,%eax 80105a82: 78 1e js 80105aa2 <sys_write+0x5a> 80105a84: 8b 45 f0 mov -0x10(%ebp),%eax 80105a87: 89 44 24 08 mov %eax,0x8(%esp) 80105a8b: 8d 45 ec lea -0x14(%ebp),%eax 80105a8e: 89 44 24 04 mov %eax,0x4(%esp) 80105a92: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105a99: e8 ec fc ff ff call 8010578a <argptr> 80105a9e: 85 c0 test %eax,%eax 80105aa0: 79 07 jns 80105aa9 <sys_write+0x61> return -1; 80105aa2: b8 ff ff ff ff mov $0xffffffff,%eax 80105aa7: eb 19 jmp 80105ac2 <sys_write+0x7a> return filewrite(f, p, n); 80105aa9: 8b 4d f0 mov -0x10(%ebp),%ecx 80105aac: 8b 55 ec mov -0x14(%ebp),%edx 80105aaf: 8b 45 f4 mov -0xc(%ebp),%eax 80105ab2: 89 4c 24 08 mov %ecx,0x8(%esp) 80105ab6: 89 54 24 04 mov %edx,0x4(%esp) 80105aba: 89 04 24 mov %eax,(%esp) 80105abd: e8 0b b7 ff ff call 801011cd <filewrite> } 80105ac2: c9 leave 80105ac3: c3 ret 80105ac4 <sys_close>: int sys_close(void) { 80105ac4: 55 push %ebp 80105ac5: 89 e5 mov %esp,%ebp 80105ac7: 83 ec 28 sub $0x28,%esp int fd; struct file *f; if(argfd(0, &fd, &f) < 0) 80105aca: 8d 45 f0 lea -0x10(%ebp),%eax 80105acd: 89 44 24 08 mov %eax,0x8(%esp) 80105ad1: 8d 45 f4 lea -0xc(%ebp),%eax 80105ad4: 89 44 24 04 mov %eax,0x4(%esp) 80105ad8: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105adf: e8 d0 fd ff ff call 801058b4 <argfd> 80105ae4: 85 c0 test %eax,%eax 80105ae6: 79 07 jns 80105aef <sys_close+0x2b> return -1; 80105ae8: b8 ff ff ff ff mov $0xffffffff,%eax 80105aed: eb 24 jmp 80105b13 <sys_close+0x4f> proc->ofile[fd] = 0; 80105aef: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105af5: 8b 55 f4 mov -0xc(%ebp),%edx 80105af8: 83 c2 08 add $0x8,%edx 80105afb: c7 44 90 08 00 00 00 movl $0x0,0x8(%eax,%edx,4) 80105b02: 00 fileclose(f); 80105b03: 8b 45 f0 mov -0x10(%ebp),%eax 80105b06: 89 04 24 mov %eax,(%esp) 80105b09: e8 de b4 ff ff call 80100fec <fileclose> return 0; 80105b0e: b8 00 00 00 00 mov $0x0,%eax } 80105b13: c9 leave 80105b14: c3 ret 80105b15 <sys_fstat>: int sys_fstat(void) { 80105b15: 55 push %ebp 80105b16: 89 e5 mov %esp,%ebp 80105b18: 83 ec 28 sub $0x28,%esp struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80105b1b: 8d 45 f4 lea -0xc(%ebp),%eax 80105b1e: 89 44 24 08 mov %eax,0x8(%esp) 80105b22: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105b29: 00 80105b2a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105b31: e8 7e fd ff ff call 801058b4 <argfd> 80105b36: 85 c0 test %eax,%eax 80105b38: 78 1f js 80105b59 <sys_fstat+0x44> 80105b3a: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 80105b41: 00 80105b42: 8d 45 f0 lea -0x10(%ebp),%eax 80105b45: 89 44 24 04 mov %eax,0x4(%esp) 80105b49: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105b50: e8 35 fc ff ff call 8010578a <argptr> 80105b55: 85 c0 test %eax,%eax 80105b57: 79 07 jns 80105b60 <sys_fstat+0x4b> return -1; 80105b59: b8 ff ff ff ff mov $0xffffffff,%eax 80105b5e: eb 12 jmp 80105b72 <sys_fstat+0x5d> return filestat(f, st); 80105b60: 8b 55 f0 mov -0x10(%ebp),%edx 80105b63: 8b 45 f4 mov -0xc(%ebp),%eax 80105b66: 89 54 24 04 mov %edx,0x4(%esp) 80105b6a: 89 04 24 mov %eax,(%esp) 80105b6d: e8 50 b5 ff ff call 801010c2 <filestat> } 80105b72: c9 leave 80105b73: c3 ret 80105b74 <sys_link>: // Create the path new as a link to the same inode as old. int sys_link(void) { 80105b74: 55 push %ebp 80105b75: 89 e5 mov %esp,%ebp 80105b77: 83 ec 38 sub $0x38,%esp char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80105b7a: 8d 45 d8 lea -0x28(%ebp),%eax 80105b7d: 89 44 24 04 mov %eax,0x4(%esp) 80105b81: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105b88: e8 5f fc ff ff call 801057ec <argstr> 80105b8d: 85 c0 test %eax,%eax 80105b8f: 78 17 js 80105ba8 <sys_link+0x34> 80105b91: 8d 45 dc lea -0x24(%ebp),%eax 80105b94: 89 44 24 04 mov %eax,0x4(%esp) 80105b98: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105b9f: e8 48 fc ff ff call 801057ec <argstr> 80105ba4: 85 c0 test %eax,%eax 80105ba6: 79 0a jns 80105bb2 <sys_link+0x3e> return -1; 80105ba8: b8 ff ff ff ff mov $0xffffffff,%eax 80105bad: e9 42 01 00 00 jmp 80105cf4 <sys_link+0x180> begin_op(); 80105bb2: e8 11 d9 ff ff call 801034c8 <begin_op> if((ip = namei(old)) == 0){ 80105bb7: 8b 45 d8 mov -0x28(%ebp),%eax 80105bba: 89 04 24 mov %eax,(%esp) 80105bbd: e8 c7 c8 ff ff call 80102489 <namei> 80105bc2: 89 45 f4 mov %eax,-0xc(%ebp) 80105bc5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80105bc9: 75 0f jne 80105bda <sys_link+0x66> end_op(); 80105bcb: e8 7c d9 ff ff call 8010354c <end_op> return -1; 80105bd0: b8 ff ff ff ff mov $0xffffffff,%eax 80105bd5: e9 1a 01 00 00 jmp 80105cf4 <sys_link+0x180> } ilock(ip); 80105bda: 8b 45 f4 mov -0xc(%ebp),%eax 80105bdd: 89 04 24 mov %eax,(%esp) 80105be0: e8 f3 bc ff ff call 801018d8 <ilock> if(ip->type == T_DIR){ 80105be5: 8b 45 f4 mov -0xc(%ebp),%eax 80105be8: 0f b7 40 10 movzwl 0x10(%eax),%eax 80105bec: 66 83 f8 01 cmp $0x1,%ax 80105bf0: 75 1a jne 80105c0c <sys_link+0x98> iunlockput(ip); 80105bf2: 8b 45 f4 mov -0xc(%ebp),%eax 80105bf5: 89 04 24 mov %eax,(%esp) 80105bf8: e8 65 bf ff ff call 80101b62 <iunlockput> end_op(); 80105bfd: e8 4a d9 ff ff call 8010354c <end_op> return -1; 80105c02: b8 ff ff ff ff mov $0xffffffff,%eax 80105c07: e9 e8 00 00 00 jmp 80105cf4 <sys_link+0x180> } ip->nlink++; 80105c0c: 8b 45 f4 mov -0xc(%ebp),%eax 80105c0f: 0f b7 40 16 movzwl 0x16(%eax),%eax 80105c13: 8d 50 01 lea 0x1(%eax),%edx 80105c16: 8b 45 f4 mov -0xc(%ebp),%eax 80105c19: 66 89 50 16 mov %dx,0x16(%eax) iupdate(ip); 80105c1d: 8b 45 f4 mov -0xc(%ebp),%eax 80105c20: 89 04 24 mov %eax,(%esp) 80105c23: e8 ee ba ff ff call 80101716 <iupdate> iunlock(ip); 80105c28: 8b 45 f4 mov -0xc(%ebp),%eax 80105c2b: 89 04 24 mov %eax,(%esp) 80105c2e: e8 f9 bd ff ff call 80101a2c <iunlock> if((dp = nameiparent(new, name)) == 0) 80105c33: 8b 45 dc mov -0x24(%ebp),%eax 80105c36: 8d 55 e2 lea -0x1e(%ebp),%edx 80105c39: 89 54 24 04 mov %edx,0x4(%esp) 80105c3d: 89 04 24 mov %eax,(%esp) 80105c40: e8 66 c8 ff ff call 801024ab <nameiparent> 80105c45: 89 45 f0 mov %eax,-0x10(%ebp) 80105c48: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80105c4c: 75 02 jne 80105c50 <sys_link+0xdc> goto bad; 80105c4e: eb 68 jmp 80105cb8 <sys_link+0x144> ilock(dp); 80105c50: 8b 45 f0 mov -0x10(%ebp),%eax 80105c53: 89 04 24 mov %eax,(%esp) 80105c56: e8 7d bc ff ff call 801018d8 <ilock> if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ 80105c5b: 8b 45 f0 mov -0x10(%ebp),%eax 80105c5e: 8b 10 mov (%eax),%edx 80105c60: 8b 45 f4 mov -0xc(%ebp),%eax 80105c63: 8b 00 mov (%eax),%eax 80105c65: 39 c2 cmp %eax,%edx 80105c67: 75 20 jne 80105c89 <sys_link+0x115> 80105c69: 8b 45 f4 mov -0xc(%ebp),%eax 80105c6c: 8b 40 04 mov 0x4(%eax),%eax 80105c6f: 89 44 24 08 mov %eax,0x8(%esp) 80105c73: 8d 45 e2 lea -0x1e(%ebp),%eax 80105c76: 89 44 24 04 mov %eax,0x4(%esp) 80105c7a: 8b 45 f0 mov -0x10(%ebp),%eax 80105c7d: 89 04 24 mov %eax,(%esp) 80105c80: e8 44 c5 ff ff call 801021c9 <dirlink> 80105c85: 85 c0 test %eax,%eax 80105c87: 79 0d jns 80105c96 <sys_link+0x122> iunlockput(dp); 80105c89: 8b 45 f0 mov -0x10(%ebp),%eax 80105c8c: 89 04 24 mov %eax,(%esp) 80105c8f: e8 ce be ff ff call 80101b62 <iunlockput> goto bad; 80105c94: eb 22 jmp 80105cb8 <sys_link+0x144> } iunlockput(dp); 80105c96: 8b 45 f0 mov -0x10(%ebp),%eax 80105c99: 89 04 24 mov %eax,(%esp) 80105c9c: e8 c1 be ff ff call 80101b62 <iunlockput> iput(ip); 80105ca1: 8b 45 f4 mov -0xc(%ebp),%eax 80105ca4: 89 04 24 mov %eax,(%esp) 80105ca7: e8 e5 bd ff ff call 80101a91 <iput> end_op(); 80105cac: e8 9b d8 ff ff call 8010354c <end_op> return 0; 80105cb1: b8 00 00 00 00 mov $0x0,%eax 80105cb6: eb 3c jmp 80105cf4 <sys_link+0x180> bad: ilock(ip); 80105cb8: 8b 45 f4 mov -0xc(%ebp),%eax 80105cbb: 89 04 24 mov %eax,(%esp) 80105cbe: e8 15 bc ff ff call 801018d8 <ilock> ip->nlink--; 80105cc3: 8b 45 f4 mov -0xc(%ebp),%eax 80105cc6: 0f b7 40 16 movzwl 0x16(%eax),%eax 80105cca: 8d 50 ff lea -0x1(%eax),%edx 80105ccd: 8b 45 f4 mov -0xc(%ebp),%eax 80105cd0: 66 89 50 16 mov %dx,0x16(%eax) iupdate(ip); 80105cd4: 8b 45 f4 mov -0xc(%ebp),%eax 80105cd7: 89 04 24 mov %eax,(%esp) 80105cda: e8 37 ba ff ff call 80101716 <iupdate> iunlockput(ip); 80105cdf: 8b 45 f4 mov -0xc(%ebp),%eax 80105ce2: 89 04 24 mov %eax,(%esp) 80105ce5: e8 78 be ff ff call 80101b62 <iunlockput> end_op(); 80105cea: e8 5d d8 ff ff call 8010354c <end_op> return -1; 80105cef: b8 ff ff ff ff mov $0xffffffff,%eax } 80105cf4: c9 leave 80105cf5: c3 ret 80105cf6 <isdirempty>: // Is the directory dp empty except for "." and ".." ? static int isdirempty(struct inode *dp) { 80105cf6: 55 push %ebp 80105cf7: 89 e5 mov %esp,%ebp 80105cf9: 83 ec 38 sub $0x38,%esp int off; struct dirent de; for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ 80105cfc: c7 45 f4 20 00 00 00 movl $0x20,-0xc(%ebp) 80105d03: eb 4b jmp 80105d50 <isdirempty+0x5a> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80105d05: 8b 45 f4 mov -0xc(%ebp),%eax 80105d08: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80105d0f: 00 80105d10: 89 44 24 08 mov %eax,0x8(%esp) 80105d14: 8d 45 e4 lea -0x1c(%ebp),%eax 80105d17: 89 44 24 04 mov %eax,0x4(%esp) 80105d1b: 8b 45 08 mov 0x8(%ebp),%eax 80105d1e: 89 04 24 mov %eax,(%esp) 80105d21: e8 c5 c0 ff ff call 80101deb <readi> 80105d26: 83 f8 10 cmp $0x10,%eax 80105d29: 74 0c je 80105d37 <isdirempty+0x41> panic("isdirempty: readi"); 80105d2b: c7 04 24 cb 8c 10 80 movl $0x80108ccb,(%esp) 80105d32: e8 03 a8 ff ff call 8010053a <panic> if(de.inum != 0) 80105d37: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax 80105d3b: 66 85 c0 test %ax,%ax 80105d3e: 74 07 je 80105d47 <isdirempty+0x51> return 0; 80105d40: b8 00 00 00 00 mov $0x0,%eax 80105d45: eb 1b jmp 80105d62 <isdirempty+0x6c> isdirempty(struct inode *dp) { int off; struct dirent de; for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ 80105d47: 8b 45 f4 mov -0xc(%ebp),%eax 80105d4a: 83 c0 10 add $0x10,%eax 80105d4d: 89 45 f4 mov %eax,-0xc(%ebp) 80105d50: 8b 55 f4 mov -0xc(%ebp),%edx 80105d53: 8b 45 08 mov 0x8(%ebp),%eax 80105d56: 8b 40 18 mov 0x18(%eax),%eax 80105d59: 39 c2 cmp %eax,%edx 80105d5b: 72 a8 jb 80105d05 <isdirempty+0xf> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("isdirempty: readi"); if(de.inum != 0) return 0; } return 1; 80105d5d: b8 01 00 00 00 mov $0x1,%eax } 80105d62: c9 leave 80105d63: c3 ret 80105d64 <sys_unlink>: //PAGEBREAK! int sys_unlink(void) { 80105d64: 55 push %ebp 80105d65: 89 e5 mov %esp,%ebp 80105d67: 83 ec 48 sub $0x48,%esp struct inode *ip, *dp; struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) 80105d6a: 8d 45 cc lea -0x34(%ebp),%eax 80105d6d: 89 44 24 04 mov %eax,0x4(%esp) 80105d71: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105d78: e8 6f fa ff ff call 801057ec <argstr> 80105d7d: 85 c0 test %eax,%eax 80105d7f: 79 0a jns 80105d8b <sys_unlink+0x27> return -1; 80105d81: b8 ff ff ff ff mov $0xffffffff,%eax 80105d86: e9 af 01 00 00 jmp 80105f3a <sys_unlink+0x1d6> begin_op(); 80105d8b: e8 38 d7 ff ff call 801034c8 <begin_op> if((dp = nameiparent(path, name)) == 0){ 80105d90: 8b 45 cc mov -0x34(%ebp),%eax 80105d93: 8d 55 d2 lea -0x2e(%ebp),%edx 80105d96: 89 54 24 04 mov %edx,0x4(%esp) 80105d9a: 89 04 24 mov %eax,(%esp) 80105d9d: e8 09 c7 ff ff call 801024ab <nameiparent> 80105da2: 89 45 f4 mov %eax,-0xc(%ebp) 80105da5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80105da9: 75 0f jne 80105dba <sys_unlink+0x56> end_op(); 80105dab: e8 9c d7 ff ff call 8010354c <end_op> return -1; 80105db0: b8 ff ff ff ff mov $0xffffffff,%eax 80105db5: e9 80 01 00 00 jmp 80105f3a <sys_unlink+0x1d6> } ilock(dp); 80105dba: 8b 45 f4 mov -0xc(%ebp),%eax 80105dbd: 89 04 24 mov %eax,(%esp) 80105dc0: e8 13 bb ff ff call 801018d8 <ilock> // Cannot unlink "." or "..". if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) 80105dc5: c7 44 24 04 dd 8c 10 movl $0x80108cdd,0x4(%esp) 80105dcc: 80 80105dcd: 8d 45 d2 lea -0x2e(%ebp),%eax 80105dd0: 89 04 24 mov %eax,(%esp) 80105dd3: e8 06 c3 ff ff call 801020de <namecmp> 80105dd8: 85 c0 test %eax,%eax 80105dda: 0f 84 45 01 00 00 je 80105f25 <sys_unlink+0x1c1> 80105de0: c7 44 24 04 df 8c 10 movl $0x80108cdf,0x4(%esp) 80105de7: 80 80105de8: 8d 45 d2 lea -0x2e(%ebp),%eax 80105deb: 89 04 24 mov %eax,(%esp) 80105dee: e8 eb c2 ff ff call 801020de <namecmp> 80105df3: 85 c0 test %eax,%eax 80105df5: 0f 84 2a 01 00 00 je 80105f25 <sys_unlink+0x1c1> goto bad; if((ip = dirlookup(dp, name, &off)) == 0) 80105dfb: 8d 45 c8 lea -0x38(%ebp),%eax 80105dfe: 89 44 24 08 mov %eax,0x8(%esp) 80105e02: 8d 45 d2 lea -0x2e(%ebp),%eax 80105e05: 89 44 24 04 mov %eax,0x4(%esp) 80105e09: 8b 45 f4 mov -0xc(%ebp),%eax 80105e0c: 89 04 24 mov %eax,(%esp) 80105e0f: e8 ec c2 ff ff call 80102100 <dirlookup> 80105e14: 89 45 f0 mov %eax,-0x10(%ebp) 80105e17: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80105e1b: 75 05 jne 80105e22 <sys_unlink+0xbe> goto bad; 80105e1d: e9 03 01 00 00 jmp 80105f25 <sys_unlink+0x1c1> ilock(ip); 80105e22: 8b 45 f0 mov -0x10(%ebp),%eax 80105e25: 89 04 24 mov %eax,(%esp) 80105e28: e8 ab ba ff ff call 801018d8 <ilock> if(ip->nlink < 1) 80105e2d: 8b 45 f0 mov -0x10(%ebp),%eax 80105e30: 0f b7 40 16 movzwl 0x16(%eax),%eax 80105e34: 66 85 c0 test %ax,%ax 80105e37: 7f 0c jg 80105e45 <sys_unlink+0xe1> panic("unlink: nlink < 1"); 80105e39: c7 04 24 e2 8c 10 80 movl $0x80108ce2,(%esp) 80105e40: e8 f5 a6 ff ff call 8010053a <panic> if(ip->type == T_DIR && !isdirempty(ip)){ 80105e45: 8b 45 f0 mov -0x10(%ebp),%eax 80105e48: 0f b7 40 10 movzwl 0x10(%eax),%eax 80105e4c: 66 83 f8 01 cmp $0x1,%ax 80105e50: 75 1f jne 80105e71 <sys_unlink+0x10d> 80105e52: 8b 45 f0 mov -0x10(%ebp),%eax 80105e55: 89 04 24 mov %eax,(%esp) 80105e58: e8 99 fe ff ff call 80105cf6 <isdirempty> 80105e5d: 85 c0 test %eax,%eax 80105e5f: 75 10 jne 80105e71 <sys_unlink+0x10d> iunlockput(ip); 80105e61: 8b 45 f0 mov -0x10(%ebp),%eax 80105e64: 89 04 24 mov %eax,(%esp) 80105e67: e8 f6 bc ff ff call 80101b62 <iunlockput> goto bad; 80105e6c: e9 b4 00 00 00 jmp 80105f25 <sys_unlink+0x1c1> } memset(&de, 0, sizeof(de)); 80105e71: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80105e78: 00 80105e79: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105e80: 00 80105e81: 8d 45 e0 lea -0x20(%ebp),%eax 80105e84: 89 04 24 mov %eax,(%esp) 80105e87: e8 8a f5 ff ff call 80105416 <memset> if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80105e8c: 8b 45 c8 mov -0x38(%ebp),%eax 80105e8f: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80105e96: 00 80105e97: 89 44 24 08 mov %eax,0x8(%esp) 80105e9b: 8d 45 e0 lea -0x20(%ebp),%eax 80105e9e: 89 44 24 04 mov %eax,0x4(%esp) 80105ea2: 8b 45 f4 mov -0xc(%ebp),%eax 80105ea5: 89 04 24 mov %eax,(%esp) 80105ea8: e8 a2 c0 ff ff call 80101f4f <writei> 80105ead: 83 f8 10 cmp $0x10,%eax 80105eb0: 74 0c je 80105ebe <sys_unlink+0x15a> panic("unlink: writei"); 80105eb2: c7 04 24 f4 8c 10 80 movl $0x80108cf4,(%esp) 80105eb9: e8 7c a6 ff ff call 8010053a <panic> if(ip->type == T_DIR){ 80105ebe: 8b 45 f0 mov -0x10(%ebp),%eax 80105ec1: 0f b7 40 10 movzwl 0x10(%eax),%eax 80105ec5: 66 83 f8 01 cmp $0x1,%ax 80105ec9: 75 1c jne 80105ee7 <sys_unlink+0x183> dp->nlink--; 80105ecb: 8b 45 f4 mov -0xc(%ebp),%eax 80105ece: 0f b7 40 16 movzwl 0x16(%eax),%eax 80105ed2: 8d 50 ff lea -0x1(%eax),%edx 80105ed5: 8b 45 f4 mov -0xc(%ebp),%eax 80105ed8: 66 89 50 16 mov %dx,0x16(%eax) iupdate(dp); 80105edc: 8b 45 f4 mov -0xc(%ebp),%eax 80105edf: 89 04 24 mov %eax,(%esp) 80105ee2: e8 2f b8 ff ff call 80101716 <iupdate> } iunlockput(dp); 80105ee7: 8b 45 f4 mov -0xc(%ebp),%eax 80105eea: 89 04 24 mov %eax,(%esp) 80105eed: e8 70 bc ff ff call 80101b62 <iunlockput> ip->nlink--; 80105ef2: 8b 45 f0 mov -0x10(%ebp),%eax 80105ef5: 0f b7 40 16 movzwl 0x16(%eax),%eax 80105ef9: 8d 50 ff lea -0x1(%eax),%edx 80105efc: 8b 45 f0 mov -0x10(%ebp),%eax 80105eff: 66 89 50 16 mov %dx,0x16(%eax) iupdate(ip); 80105f03: 8b 45 f0 mov -0x10(%ebp),%eax 80105f06: 89 04 24 mov %eax,(%esp) 80105f09: e8 08 b8 ff ff call 80101716 <iupdate> iunlockput(ip); 80105f0e: 8b 45 f0 mov -0x10(%ebp),%eax 80105f11: 89 04 24 mov %eax,(%esp) 80105f14: e8 49 bc ff ff call 80101b62 <iunlockput> end_op(); 80105f19: e8 2e d6 ff ff call 8010354c <end_op> return 0; 80105f1e: b8 00 00 00 00 mov $0x0,%eax 80105f23: eb 15 jmp 80105f3a <sys_unlink+0x1d6> bad: iunlockput(dp); 80105f25: 8b 45 f4 mov -0xc(%ebp),%eax 80105f28: 89 04 24 mov %eax,(%esp) 80105f2b: e8 32 bc ff ff call 80101b62 <iunlockput> end_op(); 80105f30: e8 17 d6 ff ff call 8010354c <end_op> return -1; 80105f35: b8 ff ff ff ff mov $0xffffffff,%eax } 80105f3a: c9 leave 80105f3b: c3 ret 80105f3c <create>: static struct inode* create(char *path, short type, short major, short minor) { 80105f3c: 55 push %ebp 80105f3d: 89 e5 mov %esp,%ebp 80105f3f: 83 ec 48 sub $0x48,%esp 80105f42: 8b 4d 0c mov 0xc(%ebp),%ecx 80105f45: 8b 55 10 mov 0x10(%ebp),%edx 80105f48: 8b 45 14 mov 0x14(%ebp),%eax 80105f4b: 66 89 4d d4 mov %cx,-0x2c(%ebp) 80105f4f: 66 89 55 d0 mov %dx,-0x30(%ebp) 80105f53: 66 89 45 cc mov %ax,-0x34(%ebp) uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 80105f57: 8d 45 de lea -0x22(%ebp),%eax 80105f5a: 89 44 24 04 mov %eax,0x4(%esp) 80105f5e: 8b 45 08 mov 0x8(%ebp),%eax 80105f61: 89 04 24 mov %eax,(%esp) 80105f64: e8 42 c5 ff ff call 801024ab <nameiparent> 80105f69: 89 45 f4 mov %eax,-0xc(%ebp) 80105f6c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80105f70: 75 0a jne 80105f7c <create+0x40> return 0; 80105f72: b8 00 00 00 00 mov $0x0,%eax 80105f77: e9 7e 01 00 00 jmp 801060fa <create+0x1be> ilock(dp); 80105f7c: 8b 45 f4 mov -0xc(%ebp),%eax 80105f7f: 89 04 24 mov %eax,(%esp) 80105f82: e8 51 b9 ff ff call 801018d8 <ilock> if((ip = dirlookup(dp, name, &off)) != 0){ 80105f87: 8d 45 ec lea -0x14(%ebp),%eax 80105f8a: 89 44 24 08 mov %eax,0x8(%esp) 80105f8e: 8d 45 de lea -0x22(%ebp),%eax 80105f91: 89 44 24 04 mov %eax,0x4(%esp) 80105f95: 8b 45 f4 mov -0xc(%ebp),%eax 80105f98: 89 04 24 mov %eax,(%esp) 80105f9b: e8 60 c1 ff ff call 80102100 <dirlookup> 80105fa0: 89 45 f0 mov %eax,-0x10(%ebp) 80105fa3: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80105fa7: 74 47 je 80105ff0 <create+0xb4> iunlockput(dp); 80105fa9: 8b 45 f4 mov -0xc(%ebp),%eax 80105fac: 89 04 24 mov %eax,(%esp) 80105faf: e8 ae bb ff ff call 80101b62 <iunlockput> ilock(ip); 80105fb4: 8b 45 f0 mov -0x10(%ebp),%eax 80105fb7: 89 04 24 mov %eax,(%esp) 80105fba: e8 19 b9 ff ff call 801018d8 <ilock> if(type == T_FILE && ip->type == T_FILE) 80105fbf: 66 83 7d d4 02 cmpw $0x2,-0x2c(%ebp) 80105fc4: 75 15 jne 80105fdb <create+0x9f> 80105fc6: 8b 45 f0 mov -0x10(%ebp),%eax 80105fc9: 0f b7 40 10 movzwl 0x10(%eax),%eax 80105fcd: 66 83 f8 02 cmp $0x2,%ax 80105fd1: 75 08 jne 80105fdb <create+0x9f> return ip; 80105fd3: 8b 45 f0 mov -0x10(%ebp),%eax 80105fd6: e9 1f 01 00 00 jmp 801060fa <create+0x1be> iunlockput(ip); 80105fdb: 8b 45 f0 mov -0x10(%ebp),%eax 80105fde: 89 04 24 mov %eax,(%esp) 80105fe1: e8 7c bb ff ff call 80101b62 <iunlockput> return 0; 80105fe6: b8 00 00 00 00 mov $0x0,%eax 80105feb: e9 0a 01 00 00 jmp 801060fa <create+0x1be> } if((ip = ialloc(dp->dev, type)) == 0) 80105ff0: 0f bf 55 d4 movswl -0x2c(%ebp),%edx 80105ff4: 8b 45 f4 mov -0xc(%ebp),%eax 80105ff7: 8b 00 mov (%eax),%eax 80105ff9: 89 54 24 04 mov %edx,0x4(%esp) 80105ffd: 89 04 24 mov %eax,(%esp) 80106000: e8 3c b6 ff ff call 80101641 <ialloc> 80106005: 89 45 f0 mov %eax,-0x10(%ebp) 80106008: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8010600c: 75 0c jne 8010601a <create+0xde> panic("create: ialloc"); 8010600e: c7 04 24 03 8d 10 80 movl $0x80108d03,(%esp) 80106015: e8 20 a5 ff ff call 8010053a <panic> ilock(ip); 8010601a: 8b 45 f0 mov -0x10(%ebp),%eax 8010601d: 89 04 24 mov %eax,(%esp) 80106020: e8 b3 b8 ff ff call 801018d8 <ilock> ip->major = major; 80106025: 8b 45 f0 mov -0x10(%ebp),%eax 80106028: 0f b7 55 d0 movzwl -0x30(%ebp),%edx 8010602c: 66 89 50 12 mov %dx,0x12(%eax) ip->minor = minor; 80106030: 8b 45 f0 mov -0x10(%ebp),%eax 80106033: 0f b7 55 cc movzwl -0x34(%ebp),%edx 80106037: 66 89 50 14 mov %dx,0x14(%eax) ip->nlink = 1; 8010603b: 8b 45 f0 mov -0x10(%ebp),%eax 8010603e: 66 c7 40 16 01 00 movw $0x1,0x16(%eax) iupdate(ip); 80106044: 8b 45 f0 mov -0x10(%ebp),%eax 80106047: 89 04 24 mov %eax,(%esp) 8010604a: e8 c7 b6 ff ff call 80101716 <iupdate> if(type == T_DIR){ // Create . and .. entries. 8010604f: 66 83 7d d4 01 cmpw $0x1,-0x2c(%ebp) 80106054: 75 6a jne 801060c0 <create+0x184> dp->nlink++; // for ".." 80106056: 8b 45 f4 mov -0xc(%ebp),%eax 80106059: 0f b7 40 16 movzwl 0x16(%eax),%eax 8010605d: 8d 50 01 lea 0x1(%eax),%edx 80106060: 8b 45 f4 mov -0xc(%ebp),%eax 80106063: 66 89 50 16 mov %dx,0x16(%eax) iupdate(dp); 80106067: 8b 45 f4 mov -0xc(%ebp),%eax 8010606a: 89 04 24 mov %eax,(%esp) 8010606d: e8 a4 b6 ff ff call 80101716 <iupdate> // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) 80106072: 8b 45 f0 mov -0x10(%ebp),%eax 80106075: 8b 40 04 mov 0x4(%eax),%eax 80106078: 89 44 24 08 mov %eax,0x8(%esp) 8010607c: c7 44 24 04 dd 8c 10 movl $0x80108cdd,0x4(%esp) 80106083: 80 80106084: 8b 45 f0 mov -0x10(%ebp),%eax 80106087: 89 04 24 mov %eax,(%esp) 8010608a: e8 3a c1 ff ff call 801021c9 <dirlink> 8010608f: 85 c0 test %eax,%eax 80106091: 78 21 js 801060b4 <create+0x178> 80106093: 8b 45 f4 mov -0xc(%ebp),%eax 80106096: 8b 40 04 mov 0x4(%eax),%eax 80106099: 89 44 24 08 mov %eax,0x8(%esp) 8010609d: c7 44 24 04 df 8c 10 movl $0x80108cdf,0x4(%esp) 801060a4: 80 801060a5: 8b 45 f0 mov -0x10(%ebp),%eax 801060a8: 89 04 24 mov %eax,(%esp) 801060ab: e8 19 c1 ff ff call 801021c9 <dirlink> 801060b0: 85 c0 test %eax,%eax 801060b2: 79 0c jns 801060c0 <create+0x184> panic("create dots"); 801060b4: c7 04 24 12 8d 10 80 movl $0x80108d12,(%esp) 801060bb: e8 7a a4 ff ff call 8010053a <panic> } if(dirlink(dp, name, ip->inum) < 0) 801060c0: 8b 45 f0 mov -0x10(%ebp),%eax 801060c3: 8b 40 04 mov 0x4(%eax),%eax 801060c6: 89 44 24 08 mov %eax,0x8(%esp) 801060ca: 8d 45 de lea -0x22(%ebp),%eax 801060cd: 89 44 24 04 mov %eax,0x4(%esp) 801060d1: 8b 45 f4 mov -0xc(%ebp),%eax 801060d4: 89 04 24 mov %eax,(%esp) 801060d7: e8 ed c0 ff ff call 801021c9 <dirlink> 801060dc: 85 c0 test %eax,%eax 801060de: 79 0c jns 801060ec <create+0x1b0> panic("create: dirlink"); 801060e0: c7 04 24 1e 8d 10 80 movl $0x80108d1e,(%esp) 801060e7: e8 4e a4 ff ff call 8010053a <panic> iunlockput(dp); 801060ec: 8b 45 f4 mov -0xc(%ebp),%eax 801060ef: 89 04 24 mov %eax,(%esp) 801060f2: e8 6b ba ff ff call 80101b62 <iunlockput> return ip; 801060f7: 8b 45 f0 mov -0x10(%ebp),%eax } 801060fa: c9 leave 801060fb: c3 ret 801060fc <sys_open>: int sys_open(void) { 801060fc: 55 push %ebp 801060fd: 89 e5 mov %esp,%ebp 801060ff: 83 ec 38 sub $0x38,%esp char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 80106102: 8d 45 e8 lea -0x18(%ebp),%eax 80106105: 89 44 24 04 mov %eax,0x4(%esp) 80106109: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80106110: e8 d7 f6 ff ff call 801057ec <argstr> 80106115: 85 c0 test %eax,%eax 80106117: 78 17 js 80106130 <sys_open+0x34> 80106119: 8d 45 e4 lea -0x1c(%ebp),%eax 8010611c: 89 44 24 04 mov %eax,0x4(%esp) 80106120: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80106127: e8 30 f6 ff ff call 8010575c <argint> 8010612c: 85 c0 test %eax,%eax 8010612e: 79 0a jns 8010613a <sys_open+0x3e> return -1; 80106130: b8 ff ff ff ff mov $0xffffffff,%eax 80106135: e9 5c 01 00 00 jmp 80106296 <sys_open+0x19a> begin_op(); 8010613a: e8 89 d3 ff ff call 801034c8 <begin_op> if(omode & O_CREATE){ 8010613f: 8b 45 e4 mov -0x1c(%ebp),%eax 80106142: 25 00 02 00 00 and $0x200,%eax 80106147: 85 c0 test %eax,%eax 80106149: 74 3b je 80106186 <sys_open+0x8a> ip = create(path, T_FILE, 0, 0); 8010614b: 8b 45 e8 mov -0x18(%ebp),%eax 8010614e: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 80106155: 00 80106156: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 8010615d: 00 8010615e: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 80106165: 00 80106166: 89 04 24 mov %eax,(%esp) 80106169: e8 ce fd ff ff call 80105f3c <create> 8010616e: 89 45 f4 mov %eax,-0xc(%ebp) if(ip == 0){ 80106171: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80106175: 75 6b jne 801061e2 <sys_open+0xe6> end_op(); 80106177: e8 d0 d3 ff ff call 8010354c <end_op> return -1; 8010617c: b8 ff ff ff ff mov $0xffffffff,%eax 80106181: e9 10 01 00 00 jmp 80106296 <sys_open+0x19a> } } else { if((ip = namei(path)) == 0){ 80106186: 8b 45 e8 mov -0x18(%ebp),%eax 80106189: 89 04 24 mov %eax,(%esp) 8010618c: e8 f8 c2 ff ff call 80102489 <namei> 80106191: 89 45 f4 mov %eax,-0xc(%ebp) 80106194: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80106198: 75 0f jne 801061a9 <sys_open+0xad> end_op(); 8010619a: e8 ad d3 ff ff call 8010354c <end_op> return -1; 8010619f: b8 ff ff ff ff mov $0xffffffff,%eax 801061a4: e9 ed 00 00 00 jmp 80106296 <sys_open+0x19a> } ilock(ip); 801061a9: 8b 45 f4 mov -0xc(%ebp),%eax 801061ac: 89 04 24 mov %eax,(%esp) 801061af: e8 24 b7 ff ff call 801018d8 <ilock> if(ip->type == T_DIR && omode != O_RDONLY){ 801061b4: 8b 45 f4 mov -0xc(%ebp),%eax 801061b7: 0f b7 40 10 movzwl 0x10(%eax),%eax 801061bb: 66 83 f8 01 cmp $0x1,%ax 801061bf: 75 21 jne 801061e2 <sys_open+0xe6> 801061c1: 8b 45 e4 mov -0x1c(%ebp),%eax 801061c4: 85 c0 test %eax,%eax 801061c6: 74 1a je 801061e2 <sys_open+0xe6> iunlockput(ip); 801061c8: 8b 45 f4 mov -0xc(%ebp),%eax 801061cb: 89 04 24 mov %eax,(%esp) 801061ce: e8 8f b9 ff ff call 80101b62 <iunlockput> end_op(); 801061d3: e8 74 d3 ff ff call 8010354c <end_op> return -1; 801061d8: b8 ff ff ff ff mov $0xffffffff,%eax 801061dd: e9 b4 00 00 00 jmp 80106296 <sys_open+0x19a> } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ 801061e2: e8 5d ad ff ff call 80100f44 <filealloc> 801061e7: 89 45 f0 mov %eax,-0x10(%ebp) 801061ea: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 801061ee: 74 14 je 80106204 <sys_open+0x108> 801061f0: 8b 45 f0 mov -0x10(%ebp),%eax 801061f3: 89 04 24 mov %eax,(%esp) 801061f6: e8 2e f7 ff ff call 80105929 <fdalloc> 801061fb: 89 45 ec mov %eax,-0x14(%ebp) 801061fe: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 80106202: 79 28 jns 8010622c <sys_open+0x130> if(f) 80106204: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80106208: 74 0b je 80106215 <sys_open+0x119> fileclose(f); 8010620a: 8b 45 f0 mov -0x10(%ebp),%eax 8010620d: 89 04 24 mov %eax,(%esp) 80106210: e8 d7 ad ff ff call 80100fec <fileclose> iunlockput(ip); 80106215: 8b 45 f4 mov -0xc(%ebp),%eax 80106218: 89 04 24 mov %eax,(%esp) 8010621b: e8 42 b9 ff ff call 80101b62 <iunlockput> end_op(); 80106220: e8 27 d3 ff ff call 8010354c <end_op> return -1; 80106225: b8 ff ff ff ff mov $0xffffffff,%eax 8010622a: eb 6a jmp 80106296 <sys_open+0x19a> } iunlock(ip); 8010622c: 8b 45 f4 mov -0xc(%ebp),%eax 8010622f: 89 04 24 mov %eax,(%esp) 80106232: e8 f5 b7 ff ff call 80101a2c <iunlock> end_op(); 80106237: e8 10 d3 ff ff call 8010354c <end_op> f->type = FD_INODE; 8010623c: 8b 45 f0 mov -0x10(%ebp),%eax 8010623f: c7 00 02 00 00 00 movl $0x2,(%eax) f->ip = ip; 80106245: 8b 45 f0 mov -0x10(%ebp),%eax 80106248: 8b 55 f4 mov -0xc(%ebp),%edx 8010624b: 89 50 10 mov %edx,0x10(%eax) f->off = 0; 8010624e: 8b 45 f0 mov -0x10(%ebp),%eax 80106251: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax) f->readable = !(omode & O_WRONLY); 80106258: 8b 45 e4 mov -0x1c(%ebp),%eax 8010625b: 83 e0 01 and $0x1,%eax 8010625e: 85 c0 test %eax,%eax 80106260: 0f 94 c0 sete %al 80106263: 89 c2 mov %eax,%edx 80106265: 8b 45 f0 mov -0x10(%ebp),%eax 80106268: 88 50 08 mov %dl,0x8(%eax) f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 8010626b: 8b 45 e4 mov -0x1c(%ebp),%eax 8010626e: 83 e0 01 and $0x1,%eax 80106271: 85 c0 test %eax,%eax 80106273: 75 0a jne 8010627f <sys_open+0x183> 80106275: 8b 45 e4 mov -0x1c(%ebp),%eax 80106278: 83 e0 02 and $0x2,%eax 8010627b: 85 c0 test %eax,%eax 8010627d: 74 07 je 80106286 <sys_open+0x18a> 8010627f: b8 01 00 00 00 mov $0x1,%eax 80106284: eb 05 jmp 8010628b <sys_open+0x18f> 80106286: b8 00 00 00 00 mov $0x0,%eax 8010628b: 89 c2 mov %eax,%edx 8010628d: 8b 45 f0 mov -0x10(%ebp),%eax 80106290: 88 50 09 mov %dl,0x9(%eax) return fd; 80106293: 8b 45 ec mov -0x14(%ebp),%eax } 80106296: c9 leave 80106297: c3 ret 80106298 <sys_mkdir>: int sys_mkdir(void) { 80106298: 55 push %ebp 80106299: 89 e5 mov %esp,%ebp 8010629b: 83 ec 28 sub $0x28,%esp char *path; struct inode *ip; begin_op(); 8010629e: e8 25 d2 ff ff call 801034c8 <begin_op> if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ 801062a3: 8d 45 f0 lea -0x10(%ebp),%eax 801062a6: 89 44 24 04 mov %eax,0x4(%esp) 801062aa: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801062b1: e8 36 f5 ff ff call 801057ec <argstr> 801062b6: 85 c0 test %eax,%eax 801062b8: 78 2c js 801062e6 <sys_mkdir+0x4e> 801062ba: 8b 45 f0 mov -0x10(%ebp),%eax 801062bd: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 801062c4: 00 801062c5: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 801062cc: 00 801062cd: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 801062d4: 00 801062d5: 89 04 24 mov %eax,(%esp) 801062d8: e8 5f fc ff ff call 80105f3c <create> 801062dd: 89 45 f4 mov %eax,-0xc(%ebp) 801062e0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801062e4: 75 0c jne 801062f2 <sys_mkdir+0x5a> end_op(); 801062e6: e8 61 d2 ff ff call 8010354c <end_op> return -1; 801062eb: b8 ff ff ff ff mov $0xffffffff,%eax 801062f0: eb 15 jmp 80106307 <sys_mkdir+0x6f> } iunlockput(ip); 801062f2: 8b 45 f4 mov -0xc(%ebp),%eax 801062f5: 89 04 24 mov %eax,(%esp) 801062f8: e8 65 b8 ff ff call 80101b62 <iunlockput> end_op(); 801062fd: e8 4a d2 ff ff call 8010354c <end_op> return 0; 80106302: b8 00 00 00 00 mov $0x0,%eax } 80106307: c9 leave 80106308: c3 ret 80106309 <sys_mknod>: int sys_mknod(void) { 80106309: 55 push %ebp 8010630a: 89 e5 mov %esp,%ebp 8010630c: 83 ec 38 sub $0x38,%esp struct inode *ip; char *path; int len; int major, minor; begin_op(); 8010630f: e8 b4 d1 ff ff call 801034c8 <begin_op> if((len=argstr(0, &path)) < 0 || 80106314: 8d 45 ec lea -0x14(%ebp),%eax 80106317: 89 44 24 04 mov %eax,0x4(%esp) 8010631b: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80106322: e8 c5 f4 ff ff call 801057ec <argstr> 80106327: 89 45 f4 mov %eax,-0xc(%ebp) 8010632a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 8010632e: 78 5e js 8010638e <sys_mknod+0x85> argint(1, &major) < 0 || 80106330: 8d 45 e8 lea -0x18(%ebp),%eax 80106333: 89 44 24 04 mov %eax,0x4(%esp) 80106337: c7 04 24 01 00 00 00 movl $0x1,(%esp) 8010633e: e8 19 f4 ff ff call 8010575c <argint> char *path; int len; int major, minor; begin_op(); if((len=argstr(0, &path)) < 0 || 80106343: 85 c0 test %eax,%eax 80106345: 78 47 js 8010638e <sys_mknod+0x85> argint(1, &major) < 0 || argint(2, &minor) < 0 || 80106347: 8d 45 e4 lea -0x1c(%ebp),%eax 8010634a: 89 44 24 04 mov %eax,0x4(%esp) 8010634e: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80106355: e8 02 f4 ff ff call 8010575c <argint> int len; int major, minor; begin_op(); if((len=argstr(0, &path)) < 0 || argint(1, &major) < 0 || 8010635a: 85 c0 test %eax,%eax 8010635c: 78 30 js 8010638e <sys_mknod+0x85> argint(2, &minor) < 0 || (ip = create(path, T_DEV, major, minor)) == 0){ 8010635e: 8b 45 e4 mov -0x1c(%ebp),%eax 80106361: 0f bf c8 movswl %ax,%ecx 80106364: 8b 45 e8 mov -0x18(%ebp),%eax 80106367: 0f bf d0 movswl %ax,%edx 8010636a: 8b 45 ec mov -0x14(%ebp),%eax int major, minor; begin_op(); if((len=argstr(0, &path)) < 0 || argint(1, &major) < 0 || argint(2, &minor) < 0 || 8010636d: 89 4c 24 0c mov %ecx,0xc(%esp) 80106371: 89 54 24 08 mov %edx,0x8(%esp) 80106375: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp) 8010637c: 00 8010637d: 89 04 24 mov %eax,(%esp) 80106380: e8 b7 fb ff ff call 80105f3c <create> 80106385: 89 45 f0 mov %eax,-0x10(%ebp) 80106388: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8010638c: 75 0c jne 8010639a <sys_mknod+0x91> (ip = create(path, T_DEV, major, minor)) == 0){ end_op(); 8010638e: e8 b9 d1 ff ff call 8010354c <end_op> return -1; 80106393: b8 ff ff ff ff mov $0xffffffff,%eax 80106398: eb 15 jmp 801063af <sys_mknod+0xa6> } iunlockput(ip); 8010639a: 8b 45 f0 mov -0x10(%ebp),%eax 8010639d: 89 04 24 mov %eax,(%esp) 801063a0: e8 bd b7 ff ff call 80101b62 <iunlockput> end_op(); 801063a5: e8 a2 d1 ff ff call 8010354c <end_op> return 0; 801063aa: b8 00 00 00 00 mov $0x0,%eax } 801063af: c9 leave 801063b0: c3 ret 801063b1 <sys_chdir>: int sys_chdir(void) { 801063b1: 55 push %ebp 801063b2: 89 e5 mov %esp,%ebp 801063b4: 83 ec 28 sub $0x28,%esp char *path; struct inode *ip; begin_op(); 801063b7: e8 0c d1 ff ff call 801034c8 <begin_op> if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ 801063bc: 8d 45 f0 lea -0x10(%ebp),%eax 801063bf: 89 44 24 04 mov %eax,0x4(%esp) 801063c3: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801063ca: e8 1d f4 ff ff call 801057ec <argstr> 801063cf: 85 c0 test %eax,%eax 801063d1: 78 14 js 801063e7 <sys_chdir+0x36> 801063d3: 8b 45 f0 mov -0x10(%ebp),%eax 801063d6: 89 04 24 mov %eax,(%esp) 801063d9: e8 ab c0 ff ff call 80102489 <namei> 801063de: 89 45 f4 mov %eax,-0xc(%ebp) 801063e1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801063e5: 75 0c jne 801063f3 <sys_chdir+0x42> end_op(); 801063e7: e8 60 d1 ff ff call 8010354c <end_op> return -1; 801063ec: b8 ff ff ff ff mov $0xffffffff,%eax 801063f1: eb 61 jmp 80106454 <sys_chdir+0xa3> } ilock(ip); 801063f3: 8b 45 f4 mov -0xc(%ebp),%eax 801063f6: 89 04 24 mov %eax,(%esp) 801063f9: e8 da b4 ff ff call 801018d8 <ilock> if(ip->type != T_DIR){ 801063fe: 8b 45 f4 mov -0xc(%ebp),%eax 80106401: 0f b7 40 10 movzwl 0x10(%eax),%eax 80106405: 66 83 f8 01 cmp $0x1,%ax 80106409: 74 17 je 80106422 <sys_chdir+0x71> iunlockput(ip); 8010640b: 8b 45 f4 mov -0xc(%ebp),%eax 8010640e: 89 04 24 mov %eax,(%esp) 80106411: e8 4c b7 ff ff call 80101b62 <iunlockput> end_op(); 80106416: e8 31 d1 ff ff call 8010354c <end_op> return -1; 8010641b: b8 ff ff ff ff mov $0xffffffff,%eax 80106420: eb 32 jmp 80106454 <sys_chdir+0xa3> } iunlock(ip); 80106422: 8b 45 f4 mov -0xc(%ebp),%eax 80106425: 89 04 24 mov %eax,(%esp) 80106428: e8 ff b5 ff ff call 80101a2c <iunlock> iput(proc->cwd); 8010642d: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106433: 8b 40 68 mov 0x68(%eax),%eax 80106436: 89 04 24 mov %eax,(%esp) 80106439: e8 53 b6 ff ff call 80101a91 <iput> end_op(); 8010643e: e8 09 d1 ff ff call 8010354c <end_op> proc->cwd = ip; 80106443: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106449: 8b 55 f4 mov -0xc(%ebp),%edx 8010644c: 89 50 68 mov %edx,0x68(%eax) return 0; 8010644f: b8 00 00 00 00 mov $0x0,%eax } 80106454: c9 leave 80106455: c3 ret 80106456 <sys_exec>: int sys_exec(void) { 80106456: 55 push %ebp 80106457: 89 e5 mov %esp,%ebp 80106459: 81 ec a8 00 00 00 sub $0xa8,%esp char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 8010645f: 8d 45 f0 lea -0x10(%ebp),%eax 80106462: 89 44 24 04 mov %eax,0x4(%esp) 80106466: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010646d: e8 7a f3 ff ff call 801057ec <argstr> 80106472: 85 c0 test %eax,%eax 80106474: 78 1a js 80106490 <sys_exec+0x3a> 80106476: 8d 85 6c ff ff ff lea -0x94(%ebp),%eax 8010647c: 89 44 24 04 mov %eax,0x4(%esp) 80106480: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80106487: e8 d0 f2 ff ff call 8010575c <argint> 8010648c: 85 c0 test %eax,%eax 8010648e: 79 0a jns 8010649a <sys_exec+0x44> return -1; 80106490: b8 ff ff ff ff mov $0xffffffff,%eax 80106495: e9 c8 00 00 00 jmp 80106562 <sys_exec+0x10c> } memset(argv, 0, sizeof(argv)); 8010649a: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) 801064a1: 00 801064a2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801064a9: 00 801064aa: 8d 85 70 ff ff ff lea -0x90(%ebp),%eax 801064b0: 89 04 24 mov %eax,(%esp) 801064b3: e8 5e ef ff ff call 80105416 <memset> for(i=0;; i++){ 801064b8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) if(i >= NELEM(argv)) 801064bf: 8b 45 f4 mov -0xc(%ebp),%eax 801064c2: 83 f8 1f cmp $0x1f,%eax 801064c5: 76 0a jbe 801064d1 <sys_exec+0x7b> return -1; 801064c7: b8 ff ff ff ff mov $0xffffffff,%eax 801064cc: e9 91 00 00 00 jmp 80106562 <sys_exec+0x10c> if(fetchint(uargv+4*i, (int*)&uarg) < 0) 801064d1: 8b 45 f4 mov -0xc(%ebp),%eax 801064d4: c1 e0 02 shl $0x2,%eax 801064d7: 89 c2 mov %eax,%edx 801064d9: 8b 85 6c ff ff ff mov -0x94(%ebp),%eax 801064df: 01 c2 add %eax,%edx 801064e1: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax 801064e7: 89 44 24 04 mov %eax,0x4(%esp) 801064eb: 89 14 24 mov %edx,(%esp) 801064ee: e8 cd f1 ff ff call 801056c0 <fetchint> 801064f3: 85 c0 test %eax,%eax 801064f5: 79 07 jns 801064fe <sys_exec+0xa8> return -1; 801064f7: b8 ff ff ff ff mov $0xffffffff,%eax 801064fc: eb 64 jmp 80106562 <sys_exec+0x10c> if(uarg == 0){ 801064fe: 8b 85 68 ff ff ff mov -0x98(%ebp),%eax 80106504: 85 c0 test %eax,%eax 80106506: 75 26 jne 8010652e <sys_exec+0xd8> argv[i] = 0; 80106508: 8b 45 f4 mov -0xc(%ebp),%eax 8010650b: c7 84 85 70 ff ff ff movl $0x0,-0x90(%ebp,%eax,4) 80106512: 00 00 00 00 break; 80106516: 90 nop } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 80106517: 8b 45 f0 mov -0x10(%ebp),%eax 8010651a: 8d 95 70 ff ff ff lea -0x90(%ebp),%edx 80106520: 89 54 24 04 mov %edx,0x4(%esp) 80106524: 89 04 24 mov %eax,(%esp) 80106527: e8 e0 a5 ff ff call 80100b0c <exec> 8010652c: eb 34 jmp 80106562 <sys_exec+0x10c> return -1; if(uarg == 0){ argv[i] = 0; break; } if(fetchstr(uarg, &argv[i]) < 0) 8010652e: 8d 85 70 ff ff ff lea -0x90(%ebp),%eax 80106534: 8b 55 f4 mov -0xc(%ebp),%edx 80106537: c1 e2 02 shl $0x2,%edx 8010653a: 01 c2 add %eax,%edx 8010653c: 8b 85 68 ff ff ff mov -0x98(%ebp),%eax 80106542: 89 54 24 04 mov %edx,0x4(%esp) 80106546: 89 04 24 mov %eax,(%esp) 80106549: e8 ac f1 ff ff call 801056fa <fetchstr> 8010654e: 85 c0 test %eax,%eax 80106550: 79 07 jns 80106559 <sys_exec+0x103> return -1; 80106552: b8 ff ff ff ff mov $0xffffffff,%eax 80106557: eb 09 jmp 80106562 <sys_exec+0x10c> if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; } memset(argv, 0, sizeof(argv)); for(i=0;; i++){ 80106559: 83 45 f4 01 addl $0x1,-0xc(%ebp) argv[i] = 0; break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } 8010655d: e9 5d ff ff ff jmp 801064bf <sys_exec+0x69> return exec(path, argv); } 80106562: c9 leave 80106563: c3 ret 80106564 <sys_pipe>: int sys_pipe(void) { 80106564: 55 push %ebp 80106565: 89 e5 mov %esp,%ebp 80106567: 83 ec 38 sub $0x38,%esp int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 8010656a: c7 44 24 08 08 00 00 movl $0x8,0x8(%esp) 80106571: 00 80106572: 8d 45 ec lea -0x14(%ebp),%eax 80106575: 89 44 24 04 mov %eax,0x4(%esp) 80106579: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80106580: e8 05 f2 ff ff call 8010578a <argptr> 80106585: 85 c0 test %eax,%eax 80106587: 79 0a jns 80106593 <sys_pipe+0x2f> return -1; 80106589: b8 ff ff ff ff mov $0xffffffff,%eax 8010658e: e9 9b 00 00 00 jmp 8010662e <sys_pipe+0xca> if(pipealloc(&rf, &wf) < 0) 80106593: 8d 45 e4 lea -0x1c(%ebp),%eax 80106596: 89 44 24 04 mov %eax,0x4(%esp) 8010659a: 8d 45 e8 lea -0x18(%ebp),%eax 8010659d: 89 04 24 mov %eax,(%esp) 801065a0: e8 37 da ff ff call 80103fdc <pipealloc> 801065a5: 85 c0 test %eax,%eax 801065a7: 79 07 jns 801065b0 <sys_pipe+0x4c> return -1; 801065a9: b8 ff ff ff ff mov $0xffffffff,%eax 801065ae: eb 7e jmp 8010662e <sys_pipe+0xca> fd0 = -1; 801065b0: c7 45 f4 ff ff ff ff movl $0xffffffff,-0xc(%ebp) if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ 801065b7: 8b 45 e8 mov -0x18(%ebp),%eax 801065ba: 89 04 24 mov %eax,(%esp) 801065bd: e8 67 f3 ff ff call 80105929 <fdalloc> 801065c2: 89 45 f4 mov %eax,-0xc(%ebp) 801065c5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801065c9: 78 14 js 801065df <sys_pipe+0x7b> 801065cb: 8b 45 e4 mov -0x1c(%ebp),%eax 801065ce: 89 04 24 mov %eax,(%esp) 801065d1: e8 53 f3 ff ff call 80105929 <fdalloc> 801065d6: 89 45 f0 mov %eax,-0x10(%ebp) 801065d9: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 801065dd: 79 37 jns 80106616 <sys_pipe+0xb2> if(fd0 >= 0) 801065df: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 801065e3: 78 14 js 801065f9 <sys_pipe+0x95> proc->ofile[fd0] = 0; 801065e5: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801065eb: 8b 55 f4 mov -0xc(%ebp),%edx 801065ee: 83 c2 08 add $0x8,%edx 801065f1: c7 44 90 08 00 00 00 movl $0x0,0x8(%eax,%edx,4) 801065f8: 00 fileclose(rf); 801065f9: 8b 45 e8 mov -0x18(%ebp),%eax 801065fc: 89 04 24 mov %eax,(%esp) 801065ff: e8 e8 a9 ff ff call 80100fec <fileclose> fileclose(wf); 80106604: 8b 45 e4 mov -0x1c(%ebp),%eax 80106607: 89 04 24 mov %eax,(%esp) 8010660a: e8 dd a9 ff ff call 80100fec <fileclose> return -1; 8010660f: b8 ff ff ff ff mov $0xffffffff,%eax 80106614: eb 18 jmp 8010662e <sys_pipe+0xca> } fd[0] = fd0; 80106616: 8b 45 ec mov -0x14(%ebp),%eax 80106619: 8b 55 f4 mov -0xc(%ebp),%edx 8010661c: 89 10 mov %edx,(%eax) fd[1] = fd1; 8010661e: 8b 45 ec mov -0x14(%ebp),%eax 80106621: 8d 50 04 lea 0x4(%eax),%edx 80106624: 8b 45 f0 mov -0x10(%ebp),%eax 80106627: 89 02 mov %eax,(%edx) return 0; 80106629: b8 00 00 00 00 mov $0x0,%eax } 8010662e: c9 leave 8010662f: c3 ret 80106630 <sys_fork>: #include "mmu.h" #include "proc.h" int sys_fork(void) { 80106630: 55 push %ebp 80106631: 89 e5 mov %esp,%ebp 80106633: 83 ec 08 sub $0x8,%esp return fork(); 80106636: e8 4f e0 ff ff call 8010468a <fork> } 8010663b: c9 leave 8010663c: c3 ret 8010663d <sys_exit>: int sys_exit(void) { 8010663d: 55 push %ebp 8010663e: 89 e5 mov %esp,%ebp 80106640: 83 ec 08 sub $0x8,%esp exit(); 80106643: e8 bd e1 ff ff call 80104805 <exit> return 0; // not reached 80106648: b8 00 00 00 00 mov $0x0,%eax } 8010664d: c9 leave 8010664e: c3 ret 8010664f <sys_wait>: int sys_wait(void) { 8010664f: 55 push %ebp 80106650: 89 e5 mov %esp,%ebp 80106652: 83 ec 08 sub $0x8,%esp return wait(); 80106655: e8 cd e2 ff ff call 80104927 <wait> } 8010665a: c9 leave 8010665b: c3 ret 8010665c <sys_kill>: int sys_kill(void) { 8010665c: 55 push %ebp 8010665d: 89 e5 mov %esp,%ebp 8010665f: 83 ec 28 sub $0x28,%esp int pid; if(argint(0, &pid) < 0) 80106662: 8d 45 f4 lea -0xc(%ebp),%eax 80106665: 89 44 24 04 mov %eax,0x4(%esp) 80106669: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80106670: e8 e7 f0 ff ff call 8010575c <argint> 80106675: 85 c0 test %eax,%eax 80106677: 79 07 jns 80106680 <sys_kill+0x24> return -1; 80106679: b8 ff ff ff ff mov $0xffffffff,%eax 8010667e: eb 0b jmp 8010668b <sys_kill+0x2f> return kill(pid); 80106680: 8b 45 f4 mov -0xc(%ebp),%eax 80106683: 89 04 24 mov %eax,(%esp) 80106686: e8 b2 e7 ff ff call 80104e3d <kill> } 8010668b: c9 leave 8010668c: c3 ret 8010668d <sys_getpid>: int sys_getpid(void) { 8010668d: 55 push %ebp 8010668e: 89 e5 mov %esp,%ebp return proc->pid; 80106690: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106696: 8b 40 10 mov 0x10(%eax),%eax } 80106699: 5d pop %ebp 8010669a: c3 ret 8010669b <sys_sbrk>: int sys_sbrk(void) { 8010669b: 55 push %ebp 8010669c: 89 e5 mov %esp,%ebp 8010669e: 83 ec 28 sub $0x28,%esp int addr; int n; if(argint(0, &n) < 0) 801066a1: 8d 45 f0 lea -0x10(%ebp),%eax 801066a4: 89 44 24 04 mov %eax,0x4(%esp) 801066a8: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801066af: e8 a8 f0 ff ff call 8010575c <argint> 801066b4: 85 c0 test %eax,%eax 801066b6: 79 07 jns 801066bf <sys_sbrk+0x24> return -1; 801066b8: b8 ff ff ff ff mov $0xffffffff,%eax 801066bd: eb 24 jmp 801066e3 <sys_sbrk+0x48> addr = proc->sz; 801066bf: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801066c5: 8b 00 mov (%eax),%eax 801066c7: 89 45 f4 mov %eax,-0xc(%ebp) if(growproc(n) < 0) 801066ca: 8b 45 f0 mov -0x10(%ebp),%eax 801066cd: 89 04 24 mov %eax,(%esp) 801066d0: e8 10 df ff ff call 801045e5 <growproc> 801066d5: 85 c0 test %eax,%eax 801066d7: 79 07 jns 801066e0 <sys_sbrk+0x45> return -1; 801066d9: b8 ff ff ff ff mov $0xffffffff,%eax 801066de: eb 03 jmp 801066e3 <sys_sbrk+0x48> return addr; 801066e0: 8b 45 f4 mov -0xc(%ebp),%eax } 801066e3: c9 leave 801066e4: c3 ret 801066e5 <sys_sleep>: int sys_sleep(void) { 801066e5: 55 push %ebp 801066e6: 89 e5 mov %esp,%ebp 801066e8: 83 ec 28 sub $0x28,%esp int n; uint ticks0; if(argint(0, &n) < 0) 801066eb: 8d 45 f0 lea -0x10(%ebp),%eax 801066ee: 89 44 24 04 mov %eax,0x4(%esp) 801066f2: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801066f9: e8 5e f0 ff ff call 8010575c <argint> 801066fe: 85 c0 test %eax,%eax 80106700: 79 07 jns 80106709 <sys_sleep+0x24> return -1; 80106702: b8 ff ff ff ff mov $0xffffffff,%eax 80106707: eb 6c jmp 80106775 <sys_sleep+0x90> acquire(&tickslock); 80106709: c7 04 24 a0 48 11 80 movl $0x801148a0,(%esp) 80106710: e8 aa ea ff ff call 801051bf <acquire> ticks0 = ticks; 80106715: a1 e0 50 11 80 mov 0x801150e0,%eax 8010671a: 89 45 f4 mov %eax,-0xc(%ebp) while(ticks - ticks0 < n){ 8010671d: eb 34 jmp 80106753 <sys_sleep+0x6e> if(proc->killed){ 8010671f: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106725: 8b 40 24 mov 0x24(%eax),%eax 80106728: 85 c0 test %eax,%eax 8010672a: 74 13 je 8010673f <sys_sleep+0x5a> release(&tickslock); 8010672c: c7 04 24 a0 48 11 80 movl $0x801148a0,(%esp) 80106733: e8 e9 ea ff ff call 80105221 <release> return -1; 80106738: b8 ff ff ff ff mov $0xffffffff,%eax 8010673d: eb 36 jmp 80106775 <sys_sleep+0x90> } sleep(&ticks, &tickslock); 8010673f: c7 44 24 04 a0 48 11 movl $0x801148a0,0x4(%esp) 80106746: 80 80106747: c7 04 24 e0 50 11 80 movl $0x801150e0,(%esp) 8010674e: e8 9e e4 ff ff call 80104bf1 <sleep> if(argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; while(ticks - ticks0 < n){ 80106753: a1 e0 50 11 80 mov 0x801150e0,%eax 80106758: 2b 45 f4 sub -0xc(%ebp),%eax 8010675b: 89 c2 mov %eax,%edx 8010675d: 8b 45 f0 mov -0x10(%ebp),%eax 80106760: 39 c2 cmp %eax,%edx 80106762: 72 bb jb 8010671f <sys_sleep+0x3a> release(&tickslock); return -1; } sleep(&ticks, &tickslock); } release(&tickslock); 80106764: c7 04 24 a0 48 11 80 movl $0x801148a0,(%esp) 8010676b: e8 b1 ea ff ff call 80105221 <release> return 0; 80106770: b8 00 00 00 00 mov $0x0,%eax } 80106775: c9 leave 80106776: c3 ret 80106777 <sys_join>: int sys_join(void) { 80106777: 55 push %ebp 80106778: 89 e5 mov %esp,%ebp 8010677a: 83 ec 28 sub $0x28,%esp void **stack; int stackArg; stackArg = argint(0, &stackArg); 8010677d: 8d 45 f0 lea -0x10(%ebp),%eax 80106780: 89 44 24 04 mov %eax,0x4(%esp) 80106784: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010678b: e8 cc ef ff ff call 8010575c <argint> 80106790: 89 45 f0 mov %eax,-0x10(%ebp) stack = (void**) stackArg; 80106793: 8b 45 f0 mov -0x10(%ebp),%eax 80106796: 89 45 f4 mov %eax,-0xc(%ebp) return join(stack); 80106799: 8b 45 f4 mov -0xc(%ebp),%eax 8010679c: 89 04 24 mov %eax,(%esp) 8010679f: e8 51 e5 ff ff call 80104cf5 <join> } 801067a4: c9 leave 801067a5: c3 ret 801067a6 <sys_uptime>: // return how many clock tick interrupts have occurred // since start. int sys_uptime(void) { 801067a6: 55 push %ebp 801067a7: 89 e5 mov %esp,%ebp 801067a9: 83 ec 28 sub $0x28,%esp uint xticks; acquire(&tickslock); 801067ac: c7 04 24 a0 48 11 80 movl $0x801148a0,(%esp) 801067b3: e8 07 ea ff ff call 801051bf <acquire> xticks = ticks; 801067b8: a1 e0 50 11 80 mov 0x801150e0,%eax 801067bd: 89 45 f4 mov %eax,-0xc(%ebp) release(&tickslock); 801067c0: c7 04 24 a0 48 11 80 movl $0x801148a0,(%esp) 801067c7: e8 55 ea ff ff call 80105221 <release> return xticks; 801067cc: 8b 45 f4 mov -0xc(%ebp),%eax } 801067cf: c9 leave 801067d0: c3 ret 801067d1 <sys_clone>: int sys_clone(void) { 801067d1: 55 push %ebp 801067d2: 89 e5 mov %esp,%ebp 801067d4: 83 ec 28 sub $0x28,%esp void * fcn,* arg,* stack; if(argptr(0, (void *)&fcn, sizeof(void *)) < 0) 801067d7: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 801067de: 00 801067df: 8d 45 f4 lea -0xc(%ebp),%eax 801067e2: 89 44 24 04 mov %eax,0x4(%esp) 801067e6: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801067ed: e8 98 ef ff ff call 8010578a <argptr> 801067f2: 85 c0 test %eax,%eax 801067f4: 79 07 jns 801067fd <sys_clone+0x2c> return -1; 801067f6: b8 ff ff ff ff mov $0xffffffff,%eax 801067fb: eb 65 jmp 80106862 <sys_clone+0x91> if(argptr(1, (void *)&arg, sizeof(void *)) < 0) 801067fd: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 80106804: 00 80106805: 8d 45 f0 lea -0x10(%ebp),%eax 80106808: 89 44 24 04 mov %eax,0x4(%esp) 8010680c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80106813: e8 72 ef ff ff call 8010578a <argptr> 80106818: 85 c0 test %eax,%eax 8010681a: 79 07 jns 80106823 <sys_clone+0x52> return -1; 8010681c: b8 ff ff ff ff mov $0xffffffff,%eax 80106821: eb 3f jmp 80106862 <sys_clone+0x91> if(argptr(2, (void *)&stack, sizeof(void *)) < 0) 80106823: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 8010682a: 00 8010682b: 8d 45 ec lea -0x14(%ebp),%eax 8010682e: 89 44 24 04 mov %eax,0x4(%esp) 80106832: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80106839: e8 4c ef ff ff call 8010578a <argptr> 8010683e: 85 c0 test %eax,%eax 80106840: 79 07 jns 80106849 <sys_clone+0x78> return -1; 80106842: b8 ff ff ff ff mov $0xffffffff,%eax 80106847: eb 19 jmp 80106862 <sys_clone+0x91> return clone(fcn, arg, stack); 80106849: 8b 4d ec mov -0x14(%ebp),%ecx 8010684c: 8b 55 f0 mov -0x10(%ebp),%edx 8010684f: 8b 45 f4 mov -0xc(%ebp),%eax 80106852: 89 4c 24 08 mov %ecx,0x8(%esp) 80106856: 89 54 24 04 mov %edx,0x4(%esp) 8010685a: 89 04 24 mov %eax,(%esp) 8010685d: e8 4a e7 ff ff call 80104fac <clone> 80106862: c9 leave 80106863: c3 ret 80106864 <outb>: "memory", "cc"); } static inline void outb(ushort port, uchar data) { 80106864: 55 push %ebp 80106865: 89 e5 mov %esp,%ebp 80106867: 83 ec 08 sub $0x8,%esp 8010686a: 8b 55 08 mov 0x8(%ebp),%edx 8010686d: 8b 45 0c mov 0xc(%ebp),%eax 80106870: 66 89 55 fc mov %dx,-0x4(%ebp) 80106874: 88 45 f8 mov %al,-0x8(%ebp) asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80106877: 0f b6 45 f8 movzbl -0x8(%ebp),%eax 8010687b: 0f b7 55 fc movzwl -0x4(%ebp),%edx 8010687f: ee out %al,(%dx) } 80106880: c9 leave 80106881: c3 ret 80106882 <timerinit>: #define TIMER_RATEGEN 0x04 // mode 2, rate generator #define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first void timerinit(void) { 80106882: 55 push %ebp 80106883: 89 e5 mov %esp,%ebp 80106885: 83 ec 18 sub $0x18,%esp // Interrupt 100 times/sec. outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); 80106888: c7 44 24 04 34 00 00 movl $0x34,0x4(%esp) 8010688f: 00 80106890: c7 04 24 43 00 00 00 movl $0x43,(%esp) 80106897: e8 c8 ff ff ff call 80106864 <outb> outb(IO_TIMER1, TIMER_DIV(100) % 256); 8010689c: c7 44 24 04 9c 00 00 movl $0x9c,0x4(%esp) 801068a3: 00 801068a4: c7 04 24 40 00 00 00 movl $0x40,(%esp) 801068ab: e8 b4 ff ff ff call 80106864 <outb> outb(IO_TIMER1, TIMER_DIV(100) / 256); 801068b0: c7 44 24 04 2e 00 00 movl $0x2e,0x4(%esp) 801068b7: 00 801068b8: c7 04 24 40 00 00 00 movl $0x40,(%esp) 801068bf: e8 a0 ff ff ff call 80106864 <outb> picenable(IRQ_TIMER); 801068c4: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801068cb: e8 9d d5 ff ff call 80103e6d <picenable> } 801068d0: c9 leave 801068d1: c3 ret 801068d2: 66 90 xchg %ax,%ax 801068d4 <alltraps>: # vectors.S sends all traps here. .globl alltraps alltraps: # Build trap frame. pushl %ds 801068d4: 1e push %ds pushl %es 801068d5: 06 push %es pushl %fs 801068d6: 0f a0 push %fs pushl %gs 801068d8: 0f a8 push %gs pushal 801068da: 60 pusha # Set up data and per-cpu segments. movw $(SEG_KDATA<<3), %ax 801068db: 66 b8 10 00 mov $0x10,%ax movw %ax, %ds 801068df: 8e d8 mov %eax,%ds movw %ax, %es 801068e1: 8e c0 mov %eax,%es movw $(SEG_KCPU<<3), %ax 801068e3: 66 b8 18 00 mov $0x18,%ax movw %ax, %fs 801068e7: 8e e0 mov %eax,%fs movw %ax, %gs 801068e9: 8e e8 mov %eax,%gs # Call trap(tf), where tf=%esp pushl %esp 801068eb: 54 push %esp call trap 801068ec: e8 d9 01 00 00 call 80106aca <trap> addl $4, %esp 801068f1: 83 c4 04 add $0x4,%esp 801068f4 <trapret>: # Return falls through to trapret... .globl trapret trapret: popal 801068f4: 61 popa popl %gs 801068f5: 0f a9 pop %gs popl %fs 801068f7: 0f a1 pop %fs popl %es 801068f9: 07 pop %es popl %ds 801068fa: 1f pop %ds addl $0x8, %esp # trapno and errcode 801068fb: 83 c4 08 add $0x8,%esp iret 801068fe: cf iret 801068ff: 90 nop 80106900 <lidt>: struct gatedesc; static inline void lidt(struct gatedesc *p, int size) { 80106900: 55 push %ebp 80106901: 89 e5 mov %esp,%ebp 80106903: 83 ec 10 sub $0x10,%esp volatile ushort pd[3]; pd[0] = size-1; 80106906: 8b 45 0c mov 0xc(%ebp),%eax 80106909: 83 e8 01 sub $0x1,%eax 8010690c: 66 89 45 fa mov %ax,-0x6(%ebp) pd[1] = (uint)p; 80106910: 8b 45 08 mov 0x8(%ebp),%eax 80106913: 66 89 45 fc mov %ax,-0x4(%ebp) pd[2] = (uint)p >> 16; 80106917: 8b 45 08 mov 0x8(%ebp),%eax 8010691a: c1 e8 10 shr $0x10,%eax 8010691d: 66 89 45 fe mov %ax,-0x2(%ebp) asm volatile("lidt (%0)" : : "r" (pd)); 80106921: 8d 45 fa lea -0x6(%ebp),%eax 80106924: 0f 01 18 lidtl (%eax) } 80106927: c9 leave 80106928: c3 ret 80106929 <rcr2>: return result; } static inline uint rcr2(void) { 80106929: 55 push %ebp 8010692a: 89 e5 mov %esp,%ebp 8010692c: 83 ec 10 sub $0x10,%esp uint val; asm volatile("movl %%cr2,%0" : "=r" (val)); 8010692f: 0f 20 d0 mov %cr2,%eax 80106932: 89 45 fc mov %eax,-0x4(%ebp) return val; 80106935: 8b 45 fc mov -0x4(%ebp),%eax } 80106938: c9 leave 80106939: c3 ret 8010693a <tvinit>: struct spinlock tickslock; uint ticks; void tvinit(void) { 8010693a: 55 push %ebp 8010693b: 89 e5 mov %esp,%ebp 8010693d: 83 ec 28 sub $0x28,%esp int i; for(i = 0; i < 256; i++) 80106940: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80106947: e9 c3 00 00 00 jmp 80106a0f <tvinit+0xd5> SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); 8010694c: 8b 45 f4 mov -0xc(%ebp),%eax 8010694f: 8b 04 85 a0 b0 10 80 mov -0x7fef4f60(,%eax,4),%eax 80106956: 89 c2 mov %eax,%edx 80106958: 8b 45 f4 mov -0xc(%ebp),%eax 8010695b: 66 89 14 c5 e0 48 11 mov %dx,-0x7feeb720(,%eax,8) 80106962: 80 80106963: 8b 45 f4 mov -0xc(%ebp),%eax 80106966: 66 c7 04 c5 e2 48 11 movw $0x8,-0x7feeb71e(,%eax,8) 8010696d: 80 08 00 80106970: 8b 45 f4 mov -0xc(%ebp),%eax 80106973: 0f b6 14 c5 e4 48 11 movzbl -0x7feeb71c(,%eax,8),%edx 8010697a: 80 8010697b: 83 e2 e0 and $0xffffffe0,%edx 8010697e: 88 14 c5 e4 48 11 80 mov %dl,-0x7feeb71c(,%eax,8) 80106985: 8b 45 f4 mov -0xc(%ebp),%eax 80106988: 0f b6 14 c5 e4 48 11 movzbl -0x7feeb71c(,%eax,8),%edx 8010698f: 80 80106990: 83 e2 1f and $0x1f,%edx 80106993: 88 14 c5 e4 48 11 80 mov %dl,-0x7feeb71c(,%eax,8) 8010699a: 8b 45 f4 mov -0xc(%ebp),%eax 8010699d: 0f b6 14 c5 e5 48 11 movzbl -0x7feeb71b(,%eax,8),%edx 801069a4: 80 801069a5: 83 e2 f0 and $0xfffffff0,%edx 801069a8: 83 ca 0e or $0xe,%edx 801069ab: 88 14 c5 e5 48 11 80 mov %dl,-0x7feeb71b(,%eax,8) 801069b2: 8b 45 f4 mov -0xc(%ebp),%eax 801069b5: 0f b6 14 c5 e5 48 11 movzbl -0x7feeb71b(,%eax,8),%edx 801069bc: 80 801069bd: 83 e2 ef and $0xffffffef,%edx 801069c0: 88 14 c5 e5 48 11 80 mov %dl,-0x7feeb71b(,%eax,8) 801069c7: 8b 45 f4 mov -0xc(%ebp),%eax 801069ca: 0f b6 14 c5 e5 48 11 movzbl -0x7feeb71b(,%eax,8),%edx 801069d1: 80 801069d2: 83 e2 9f and $0xffffff9f,%edx 801069d5: 88 14 c5 e5 48 11 80 mov %dl,-0x7feeb71b(,%eax,8) 801069dc: 8b 45 f4 mov -0xc(%ebp),%eax 801069df: 0f b6 14 c5 e5 48 11 movzbl -0x7feeb71b(,%eax,8),%edx 801069e6: 80 801069e7: 83 ca 80 or $0xffffff80,%edx 801069ea: 88 14 c5 e5 48 11 80 mov %dl,-0x7feeb71b(,%eax,8) 801069f1: 8b 45 f4 mov -0xc(%ebp),%eax 801069f4: 8b 04 85 a0 b0 10 80 mov -0x7fef4f60(,%eax,4),%eax 801069fb: c1 e8 10 shr $0x10,%eax 801069fe: 89 c2 mov %eax,%edx 80106a00: 8b 45 f4 mov -0xc(%ebp),%eax 80106a03: 66 89 14 c5 e6 48 11 mov %dx,-0x7feeb71a(,%eax,8) 80106a0a: 80 void tvinit(void) { int i; for(i = 0; i < 256; i++) 80106a0b: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80106a0f: 81 7d f4 ff 00 00 00 cmpl $0xff,-0xc(%ebp) 80106a16: 0f 8e 30 ff ff ff jle 8010694c <tvinit+0x12> SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 80106a1c: a1 a0 b1 10 80 mov 0x8010b1a0,%eax 80106a21: 66 a3 e0 4a 11 80 mov %ax,0x80114ae0 80106a27: 66 c7 05 e2 4a 11 80 movw $0x8,0x80114ae2 80106a2e: 08 00 80106a30: 0f b6 05 e4 4a 11 80 movzbl 0x80114ae4,%eax 80106a37: 83 e0 e0 and $0xffffffe0,%eax 80106a3a: a2 e4 4a 11 80 mov %al,0x80114ae4 80106a3f: 0f b6 05 e4 4a 11 80 movzbl 0x80114ae4,%eax 80106a46: 83 e0 1f and $0x1f,%eax 80106a49: a2 e4 4a 11 80 mov %al,0x80114ae4 80106a4e: 0f b6 05 e5 4a 11 80 movzbl 0x80114ae5,%eax 80106a55: 83 c8 0f or $0xf,%eax 80106a58: a2 e5 4a 11 80 mov %al,0x80114ae5 80106a5d: 0f b6 05 e5 4a 11 80 movzbl 0x80114ae5,%eax 80106a64: 83 e0 ef and $0xffffffef,%eax 80106a67: a2 e5 4a 11 80 mov %al,0x80114ae5 80106a6c: 0f b6 05 e5 4a 11 80 movzbl 0x80114ae5,%eax 80106a73: 83 c8 60 or $0x60,%eax 80106a76: a2 e5 4a 11 80 mov %al,0x80114ae5 80106a7b: 0f b6 05 e5 4a 11 80 movzbl 0x80114ae5,%eax 80106a82: 83 c8 80 or $0xffffff80,%eax 80106a85: a2 e5 4a 11 80 mov %al,0x80114ae5 80106a8a: a1 a0 b1 10 80 mov 0x8010b1a0,%eax 80106a8f: c1 e8 10 shr $0x10,%eax 80106a92: 66 a3 e6 4a 11 80 mov %ax,0x80114ae6 initlock(&tickslock, "time"); 80106a98: c7 44 24 04 30 8d 10 movl $0x80108d30,0x4(%esp) 80106a9f: 80 80106aa0: c7 04 24 a0 48 11 80 movl $0x801148a0,(%esp) 80106aa7: e8 f2 e6 ff ff call 8010519e <initlock> } 80106aac: c9 leave 80106aad: c3 ret 80106aae <idtinit>: void idtinit(void) { 80106aae: 55 push %ebp 80106aaf: 89 e5 mov %esp,%ebp 80106ab1: 83 ec 08 sub $0x8,%esp lidt(idt, sizeof(idt)); 80106ab4: c7 44 24 04 00 08 00 movl $0x800,0x4(%esp) 80106abb: 00 80106abc: c7 04 24 e0 48 11 80 movl $0x801148e0,(%esp) 80106ac3: e8 38 fe ff ff call 80106900 <lidt> } 80106ac8: c9 leave 80106ac9: c3 ret 80106aca <trap>: //PAGEBREAK: 41 void trap(struct trapframe *tf) { 80106aca: 55 push %ebp 80106acb: 89 e5 mov %esp,%ebp 80106acd: 57 push %edi 80106ace: 56 push %esi 80106acf: 53 push %ebx 80106ad0: 83 ec 3c sub $0x3c,%esp if(tf->trapno == T_SYSCALL){ 80106ad3: 8b 45 08 mov 0x8(%ebp),%eax 80106ad6: 8b 40 30 mov 0x30(%eax),%eax 80106ad9: 83 f8 40 cmp $0x40,%eax 80106adc: 75 3f jne 80106b1d <trap+0x53> if(proc->killed) 80106ade: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106ae4: 8b 40 24 mov 0x24(%eax),%eax 80106ae7: 85 c0 test %eax,%eax 80106ae9: 74 05 je 80106af0 <trap+0x26> exit(); 80106aeb: e8 15 dd ff ff call 80104805 <exit> proc->tf = tf; 80106af0: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106af6: 8b 55 08 mov 0x8(%ebp),%edx 80106af9: 89 50 18 mov %edx,0x18(%eax) syscall(); 80106afc: e8 22 ed ff ff call 80105823 <syscall> if(proc->killed) 80106b01: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106b07: 8b 40 24 mov 0x24(%eax),%eax 80106b0a: 85 c0 test %eax,%eax 80106b0c: 74 0a je 80106b18 <trap+0x4e> exit(); 80106b0e: e8 f2 dc ff ff call 80104805 <exit> return; 80106b13: e9 2d 02 00 00 jmp 80106d45 <trap+0x27b> 80106b18: e9 28 02 00 00 jmp 80106d45 <trap+0x27b> } switch(tf->trapno){ 80106b1d: 8b 45 08 mov 0x8(%ebp),%eax 80106b20: 8b 40 30 mov 0x30(%eax),%eax 80106b23: 83 e8 20 sub $0x20,%eax 80106b26: 83 f8 1f cmp $0x1f,%eax 80106b29: 0f 87 bc 00 00 00 ja 80106beb <trap+0x121> 80106b2f: 8b 04 85 d8 8d 10 80 mov -0x7fef7228(,%eax,4),%eax 80106b36: ff e0 jmp *%eax case T_IRQ0 + IRQ_TIMER: if(cpu->id == 0){ 80106b38: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80106b3e: 0f b6 00 movzbl (%eax),%eax 80106b41: 84 c0 test %al,%al 80106b43: 75 31 jne 80106b76 <trap+0xac> acquire(&tickslock); 80106b45: c7 04 24 a0 48 11 80 movl $0x801148a0,(%esp) 80106b4c: e8 6e e6 ff ff call 801051bf <acquire> ticks++; 80106b51: a1 e0 50 11 80 mov 0x801150e0,%eax 80106b56: 83 c0 01 add $0x1,%eax 80106b59: a3 e0 50 11 80 mov %eax,0x801150e0 wakeup(&ticks); 80106b5e: c7 04 24 e0 50 11 80 movl $0x801150e0,(%esp) 80106b65: e8 60 e1 ff ff call 80104cca <wakeup> release(&tickslock); 80106b6a: c7 04 24 a0 48 11 80 movl $0x801148a0,(%esp) 80106b71: e8 ab e6 ff ff call 80105221 <release> } lapiceoi(); 80106b76: e8 16 c4 ff ff call 80102f91 <lapiceoi> break; 80106b7b: e9 41 01 00 00 jmp 80106cc1 <trap+0x1f7> case T_IRQ0 + IRQ_IDE: ideintr(); 80106b80: e8 16 bc ff ff call 8010279b <ideintr> lapiceoi(); 80106b85: e8 07 c4 ff ff call 80102f91 <lapiceoi> break; 80106b8a: e9 32 01 00 00 jmp 80106cc1 <trap+0x1f7> case T_IRQ0 + IRQ_IDE+1: // Bochs generates spurious IDE1 interrupts. break; case T_IRQ0 + IRQ_KBD: kbdintr(); 80106b8f: e8 cc c1 ff ff call 80102d60 <kbdintr> lapiceoi(); 80106b94: e8 f8 c3 ff ff call 80102f91 <lapiceoi> break; 80106b99: e9 23 01 00 00 jmp 80106cc1 <trap+0x1f7> case T_IRQ0 + IRQ_COM1: uartintr(); 80106b9e: e8 9a 03 00 00 call 80106f3d <uartintr> lapiceoi(); 80106ba3: e8 e9 c3 ff ff call 80102f91 <lapiceoi> break; 80106ba8: e9 14 01 00 00 jmp 80106cc1 <trap+0x1f7> case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x\n", 80106bad: 8b 45 08 mov 0x8(%ebp),%eax 80106bb0: 8b 48 38 mov 0x38(%eax),%ecx cpu->id, tf->cs, tf->eip); 80106bb3: 8b 45 08 mov 0x8(%ebp),%eax 80106bb6: 0f b7 40 3c movzwl 0x3c(%eax),%eax uartintr(); lapiceoi(); break; case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x\n", 80106bba: 0f b7 d0 movzwl %ax,%edx cpu->id, tf->cs, tf->eip); 80106bbd: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80106bc3: 0f b6 00 movzbl (%eax),%eax uartintr(); lapiceoi(); break; case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x\n", 80106bc6: 0f b6 c0 movzbl %al,%eax 80106bc9: 89 4c 24 0c mov %ecx,0xc(%esp) 80106bcd: 89 54 24 08 mov %edx,0x8(%esp) 80106bd1: 89 44 24 04 mov %eax,0x4(%esp) 80106bd5: c7 04 24 38 8d 10 80 movl $0x80108d38,(%esp) 80106bdc: e8 bf 97 ff ff call 801003a0 <cprintf> cpu->id, tf->cs, tf->eip); lapiceoi(); 80106be1: e8 ab c3 ff ff call 80102f91 <lapiceoi> break; 80106be6: e9 d6 00 00 00 jmp 80106cc1 <trap+0x1f7> //PAGEBREAK: 13 default: if(proc == 0 || (tf->cs&3) == 0){ 80106beb: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106bf1: 85 c0 test %eax,%eax 80106bf3: 74 11 je 80106c06 <trap+0x13c> 80106bf5: 8b 45 08 mov 0x8(%ebp),%eax 80106bf8: 0f b7 40 3c movzwl 0x3c(%eax),%eax 80106bfc: 0f b7 c0 movzwl %ax,%eax 80106bff: 83 e0 03 and $0x3,%eax 80106c02: 85 c0 test %eax,%eax 80106c04: 75 46 jne 80106c4c <trap+0x182> // In kernel, it must be our mistake. cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", 80106c06: e8 1e fd ff ff call 80106929 <rcr2> 80106c0b: 8b 55 08 mov 0x8(%ebp),%edx 80106c0e: 8b 5a 38 mov 0x38(%edx),%ebx tf->trapno, cpu->id, tf->eip, rcr2()); 80106c11: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 80106c18: 0f b6 12 movzbl (%edx),%edx //PAGEBREAK: 13 default: if(proc == 0 || (tf->cs&3) == 0){ // In kernel, it must be our mistake. cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", 80106c1b: 0f b6 ca movzbl %dl,%ecx 80106c1e: 8b 55 08 mov 0x8(%ebp),%edx 80106c21: 8b 52 30 mov 0x30(%edx),%edx 80106c24: 89 44 24 10 mov %eax,0x10(%esp) 80106c28: 89 5c 24 0c mov %ebx,0xc(%esp) 80106c2c: 89 4c 24 08 mov %ecx,0x8(%esp) 80106c30: 89 54 24 04 mov %edx,0x4(%esp) 80106c34: c7 04 24 5c 8d 10 80 movl $0x80108d5c,(%esp) 80106c3b: e8 60 97 ff ff call 801003a0 <cprintf> tf->trapno, cpu->id, tf->eip, rcr2()); panic("trap"); 80106c40: c7 04 24 8e 8d 10 80 movl $0x80108d8e,(%esp) 80106c47: e8 ee 98 ff ff call 8010053a <panic> } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80106c4c: e8 d8 fc ff ff call 80106929 <rcr2> 80106c51: 89 c2 mov %eax,%edx 80106c53: 8b 45 08 mov 0x8(%ebp),%eax 80106c56: 8b 78 38 mov 0x38(%eax),%edi "eip 0x%x addr 0x%x--kill proc\n", proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip, 80106c59: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80106c5f: 0f b6 00 movzbl (%eax),%eax cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpu->id, tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80106c62: 0f b6 f0 movzbl %al,%esi 80106c65: 8b 45 08 mov 0x8(%ebp),%eax 80106c68: 8b 58 34 mov 0x34(%eax),%ebx 80106c6b: 8b 45 08 mov 0x8(%ebp),%eax 80106c6e: 8b 48 30 mov 0x30(%eax),%ecx "eip 0x%x addr 0x%x--kill proc\n", proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip, 80106c71: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106c77: 83 c0 6c add $0x6c,%eax 80106c7a: 89 45 e4 mov %eax,-0x1c(%ebp) 80106c7d: 65 a1 04 00 00 00 mov %gs:0x4,%eax cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpu->id, tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80106c83: 8b 40 10 mov 0x10(%eax),%eax 80106c86: 89 54 24 1c mov %edx,0x1c(%esp) 80106c8a: 89 7c 24 18 mov %edi,0x18(%esp) 80106c8e: 89 74 24 14 mov %esi,0x14(%esp) 80106c92: 89 5c 24 10 mov %ebx,0x10(%esp) 80106c96: 89 4c 24 0c mov %ecx,0xc(%esp) 80106c9a: 8b 75 e4 mov -0x1c(%ebp),%esi 80106c9d: 89 74 24 08 mov %esi,0x8(%esp) 80106ca1: 89 44 24 04 mov %eax,0x4(%esp) 80106ca5: c7 04 24 94 8d 10 80 movl $0x80108d94,(%esp) 80106cac: e8 ef 96 ff ff call 801003a0 <cprintf> "eip 0x%x addr 0x%x--kill proc\n", proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip, rcr2()); proc->killed = 1; 80106cb1: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106cb7: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) 80106cbe: eb 01 jmp 80106cc1 <trap+0x1f7> ideintr(); lapiceoi(); break; case T_IRQ0 + IRQ_IDE+1: // Bochs generates spurious IDE1 interrupts. break; 80106cc0: 90 nop } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(proc && proc->killed && (tf->cs&3) == DPL_USER) 80106cc1: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106cc7: 85 c0 test %eax,%eax 80106cc9: 74 24 je 80106cef <trap+0x225> 80106ccb: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106cd1: 8b 40 24 mov 0x24(%eax),%eax 80106cd4: 85 c0 test %eax,%eax 80106cd6: 74 17 je 80106cef <trap+0x225> 80106cd8: 8b 45 08 mov 0x8(%ebp),%eax 80106cdb: 0f b7 40 3c movzwl 0x3c(%eax),%eax 80106cdf: 0f b7 c0 movzwl %ax,%eax 80106ce2: 83 e0 03 and $0x3,%eax 80106ce5: 83 f8 03 cmp $0x3,%eax 80106ce8: 75 05 jne 80106cef <trap+0x225> exit(); 80106cea: e8 16 db ff ff call 80104805 <exit> // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) 80106cef: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106cf5: 85 c0 test %eax,%eax 80106cf7: 74 1e je 80106d17 <trap+0x24d> 80106cf9: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106cff: 8b 40 0c mov 0xc(%eax),%eax 80106d02: 83 f8 04 cmp $0x4,%eax 80106d05: 75 10 jne 80106d17 <trap+0x24d> 80106d07: 8b 45 08 mov 0x8(%ebp),%eax 80106d0a: 8b 40 30 mov 0x30(%eax),%eax 80106d0d: 83 f8 20 cmp $0x20,%eax 80106d10: 75 05 jne 80106d17 <trap+0x24d> yield(); 80106d12: e8 69 de ff ff call 80104b80 <yield> // Check if the process has been killed since we yielded if(proc && proc->killed && (tf->cs&3) == DPL_USER) 80106d17: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106d1d: 85 c0 test %eax,%eax 80106d1f: 74 24 je 80106d45 <trap+0x27b> 80106d21: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80106d27: 8b 40 24 mov 0x24(%eax),%eax 80106d2a: 85 c0 test %eax,%eax 80106d2c: 74 17 je 80106d45 <trap+0x27b> 80106d2e: 8b 45 08 mov 0x8(%ebp),%eax 80106d31: 0f b7 40 3c movzwl 0x3c(%eax),%eax 80106d35: 0f b7 c0 movzwl %ax,%eax 80106d38: 83 e0 03 and $0x3,%eax 80106d3b: 83 f8 03 cmp $0x3,%eax 80106d3e: 75 05 jne 80106d45 <trap+0x27b> exit(); 80106d40: e8 c0 da ff ff call 80104805 <exit> } 80106d45: 83 c4 3c add $0x3c,%esp 80106d48: 5b pop %ebx 80106d49: 5e pop %esi 80106d4a: 5f pop %edi 80106d4b: 5d pop %ebp 80106d4c: c3 ret 80106d4d: 66 90 xchg %ax,%ax 80106d4f: 90 nop 80106d50 <inb>: // Routines to let C code use special x86 instructions. static inline uchar inb(ushort port) { 80106d50: 55 push %ebp 80106d51: 89 e5 mov %esp,%ebp 80106d53: 83 ec 14 sub $0x14,%esp 80106d56: 8b 45 08 mov 0x8(%ebp),%eax 80106d59: 66 89 45 ec mov %ax,-0x14(%ebp) uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80106d5d: 0f b7 45 ec movzwl -0x14(%ebp),%eax 80106d61: 89 c2 mov %eax,%edx 80106d63: ec in (%dx),%al 80106d64: 88 45 ff mov %al,-0x1(%ebp) return data; 80106d67: 0f b6 45 ff movzbl -0x1(%ebp),%eax } 80106d6b: c9 leave 80106d6c: c3 ret 80106d6d <outb>: "memory", "cc"); } static inline void outb(ushort port, uchar data) { 80106d6d: 55 push %ebp 80106d6e: 89 e5 mov %esp,%ebp 80106d70: 83 ec 08 sub $0x8,%esp 80106d73: 8b 55 08 mov 0x8(%ebp),%edx 80106d76: 8b 45 0c mov 0xc(%ebp),%eax 80106d79: 66 89 55 fc mov %dx,-0x4(%ebp) 80106d7d: 88 45 f8 mov %al,-0x8(%ebp) asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80106d80: 0f b6 45 f8 movzbl -0x8(%ebp),%eax 80106d84: 0f b7 55 fc movzwl -0x4(%ebp),%edx 80106d88: ee out %al,(%dx) } 80106d89: c9 leave 80106d8a: c3 ret 80106d8b <uartinit>: static int uart; // is there a uart? void uartinit(void) { 80106d8b: 55 push %ebp 80106d8c: 89 e5 mov %esp,%ebp 80106d8e: 83 ec 28 sub $0x28,%esp char *p; // Turn off the FIFO outb(COM1+2, 0); 80106d91: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106d98: 00 80106d99: c7 04 24 fa 03 00 00 movl $0x3fa,(%esp) 80106da0: e8 c8 ff ff ff call 80106d6d <outb> // 9600 baud, 8 data bits, 1 stop bit, parity off. outb(COM1+3, 0x80); // Unlock divisor 80106da5: c7 44 24 04 80 00 00 movl $0x80,0x4(%esp) 80106dac: 00 80106dad: c7 04 24 fb 03 00 00 movl $0x3fb,(%esp) 80106db4: e8 b4 ff ff ff call 80106d6d <outb> outb(COM1+0, 115200/9600); 80106db9: c7 44 24 04 0c 00 00 movl $0xc,0x4(%esp) 80106dc0: 00 80106dc1: c7 04 24 f8 03 00 00 movl $0x3f8,(%esp) 80106dc8: e8 a0 ff ff ff call 80106d6d <outb> outb(COM1+1, 0); 80106dcd: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106dd4: 00 80106dd5: c7 04 24 f9 03 00 00 movl $0x3f9,(%esp) 80106ddc: e8 8c ff ff ff call 80106d6d <outb> outb(COM1+3, 0x03); // Lock divisor, 8 data bits. 80106de1: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp) 80106de8: 00 80106de9: c7 04 24 fb 03 00 00 movl $0x3fb,(%esp) 80106df0: e8 78 ff ff ff call 80106d6d <outb> outb(COM1+4, 0); 80106df5: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106dfc: 00 80106dfd: c7 04 24 fc 03 00 00 movl $0x3fc,(%esp) 80106e04: e8 64 ff ff ff call 80106d6d <outb> outb(COM1+1, 0x01); // Enable receive interrupts. 80106e09: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80106e10: 00 80106e11: c7 04 24 f9 03 00 00 movl $0x3f9,(%esp) 80106e18: e8 50 ff ff ff call 80106d6d <outb> // If status is 0xFF, no serial port. if(inb(COM1+5) == 0xFF) 80106e1d: c7 04 24 fd 03 00 00 movl $0x3fd,(%esp) 80106e24: e8 27 ff ff ff call 80106d50 <inb> 80106e29: 3c ff cmp $0xff,%al 80106e2b: 75 02 jne 80106e2f <uartinit+0xa4> return; 80106e2d: eb 6a jmp 80106e99 <uartinit+0x10e> uart = 1; 80106e2f: c7 05 4c b6 10 80 01 movl $0x1,0x8010b64c 80106e36: 00 00 00 // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); 80106e39: c7 04 24 fa 03 00 00 movl $0x3fa,(%esp) 80106e40: e8 0b ff ff ff call 80106d50 <inb> inb(COM1+0); 80106e45: c7 04 24 f8 03 00 00 movl $0x3f8,(%esp) 80106e4c: e8 ff fe ff ff call 80106d50 <inb> picenable(IRQ_COM1); 80106e51: c7 04 24 04 00 00 00 movl $0x4,(%esp) 80106e58: e8 10 d0 ff ff call 80103e6d <picenable> ioapicenable(IRQ_COM1, 0); 80106e5d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106e64: 00 80106e65: c7 04 24 04 00 00 00 movl $0x4,(%esp) 80106e6c: e8 ab bb ff ff call 80102a1c <ioapicenable> // Announce that we're here. for(p="xv6...\n"; *p; p++) 80106e71: c7 45 f4 58 8e 10 80 movl $0x80108e58,-0xc(%ebp) 80106e78: eb 15 jmp 80106e8f <uartinit+0x104> uartputc(*p); 80106e7a: 8b 45 f4 mov -0xc(%ebp),%eax 80106e7d: 0f b6 00 movzbl (%eax),%eax 80106e80: 0f be c0 movsbl %al,%eax 80106e83: 89 04 24 mov %eax,(%esp) 80106e86: e8 10 00 00 00 call 80106e9b <uartputc> inb(COM1+0); picenable(IRQ_COM1); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) 80106e8b: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80106e8f: 8b 45 f4 mov -0xc(%ebp),%eax 80106e92: 0f b6 00 movzbl (%eax),%eax 80106e95: 84 c0 test %al,%al 80106e97: 75 e1 jne 80106e7a <uartinit+0xef> uartputc(*p); } 80106e99: c9 leave 80106e9a: c3 ret 80106e9b <uartputc>: void uartputc(int c) { 80106e9b: 55 push %ebp 80106e9c: 89 e5 mov %esp,%ebp 80106e9e: 83 ec 28 sub $0x28,%esp int i; if(!uart) 80106ea1: a1 4c b6 10 80 mov 0x8010b64c,%eax 80106ea6: 85 c0 test %eax,%eax 80106ea8: 75 02 jne 80106eac <uartputc+0x11> return; 80106eaa: eb 4b jmp 80106ef7 <uartputc+0x5c> for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 80106eac: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 80106eb3: eb 10 jmp 80106ec5 <uartputc+0x2a> microdelay(10); 80106eb5: c7 04 24 0a 00 00 00 movl $0xa,(%esp) 80106ebc: e8 f5 c0 ff ff call 80102fb6 <microdelay> { int i; if(!uart) return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 80106ec1: 83 45 f4 01 addl $0x1,-0xc(%ebp) 80106ec5: 83 7d f4 7f cmpl $0x7f,-0xc(%ebp) 80106ec9: 7f 16 jg 80106ee1 <uartputc+0x46> 80106ecb: c7 04 24 fd 03 00 00 movl $0x3fd,(%esp) 80106ed2: e8 79 fe ff ff call 80106d50 <inb> 80106ed7: 0f b6 c0 movzbl %al,%eax 80106eda: 83 e0 20 and $0x20,%eax 80106edd: 85 c0 test %eax,%eax 80106edf: 74 d4 je 80106eb5 <uartputc+0x1a> microdelay(10); outb(COM1+0, c); 80106ee1: 8b 45 08 mov 0x8(%ebp),%eax 80106ee4: 0f b6 c0 movzbl %al,%eax 80106ee7: 89 44 24 04 mov %eax,0x4(%esp) 80106eeb: c7 04 24 f8 03 00 00 movl $0x3f8,(%esp) 80106ef2: e8 76 fe ff ff call 80106d6d <outb> } 80106ef7: c9 leave 80106ef8: c3 ret 80106ef9 <uartgetc>: static int uartgetc(void) { 80106ef9: 55 push %ebp 80106efa: 89 e5 mov %esp,%ebp 80106efc: 83 ec 04 sub $0x4,%esp if(!uart) 80106eff: a1 4c b6 10 80 mov 0x8010b64c,%eax 80106f04: 85 c0 test %eax,%eax 80106f06: 75 07 jne 80106f0f <uartgetc+0x16> return -1; 80106f08: b8 ff ff ff ff mov $0xffffffff,%eax 80106f0d: eb 2c jmp 80106f3b <uartgetc+0x42> if(!(inb(COM1+5) & 0x01)) 80106f0f: c7 04 24 fd 03 00 00 movl $0x3fd,(%esp) 80106f16: e8 35 fe ff ff call 80106d50 <inb> 80106f1b: 0f b6 c0 movzbl %al,%eax 80106f1e: 83 e0 01 and $0x1,%eax 80106f21: 85 c0 test %eax,%eax 80106f23: 75 07 jne 80106f2c <uartgetc+0x33> return -1; 80106f25: b8 ff ff ff ff mov $0xffffffff,%eax 80106f2a: eb 0f jmp 80106f3b <uartgetc+0x42> return inb(COM1+0); 80106f2c: c7 04 24 f8 03 00 00 movl $0x3f8,(%esp) 80106f33: e8 18 fe ff ff call 80106d50 <inb> 80106f38: 0f b6 c0 movzbl %al,%eax } 80106f3b: c9 leave 80106f3c: c3 ret 80106f3d <uartintr>: void uartintr(void) { 80106f3d: 55 push %ebp 80106f3e: 89 e5 mov %esp,%ebp 80106f40: 83 ec 18 sub $0x18,%esp consoleintr(uartgetc); 80106f43: c7 04 24 f9 6e 10 80 movl $0x80106ef9,(%esp) 80106f4a: e8 79 98 ff ff call 801007c8 <consoleintr> } 80106f4f: c9 leave 80106f50: c3 ret 80106f51: 66 90 xchg %ax,%ax 80106f53: 90 nop 80106f54 <vector0>: # generated by vectors.pl - do not edit # handlers .globl alltraps .globl vector0 vector0: pushl $0 80106f54: 6a 00 push $0x0 pushl $0 80106f56: 6a 00 push $0x0 jmp alltraps 80106f58: e9 77 f9 ff ff jmp 801068d4 <alltraps> 80106f5d <vector1>: .globl vector1 vector1: pushl $0 80106f5d: 6a 00 push $0x0 pushl $1 80106f5f: 6a 01 push $0x1 jmp alltraps 80106f61: e9 6e f9 ff ff jmp 801068d4 <alltraps> 80106f66 <vector2>: .globl vector2 vector2: pushl $0 80106f66: 6a 00 push $0x0 pushl $2 80106f68: 6a 02 push $0x2 jmp alltraps 80106f6a: e9 65 f9 ff ff jmp 801068d4 <alltraps> 80106f6f <vector3>: .globl vector3 vector3: pushl $0 80106f6f: 6a 00 push $0x0 pushl $3 80106f71: 6a 03 push $0x3 jmp alltraps 80106f73: e9 5c f9 ff ff jmp 801068d4 <alltraps> 80106f78 <vector4>: .globl vector4 vector4: pushl $0 80106f78: 6a 00 push $0x0 pushl $4 80106f7a: 6a 04 push $0x4 jmp alltraps 80106f7c: e9 53 f9 ff ff jmp 801068d4 <alltraps> 80106f81 <vector5>: .globl vector5 vector5: pushl $0 80106f81: 6a 00 push $0x0 pushl $5 80106f83: 6a 05 push $0x5 jmp alltraps 80106f85: e9 4a f9 ff ff jmp 801068d4 <alltraps> 80106f8a <vector6>: .globl vector6 vector6: pushl $0 80106f8a: 6a 00 push $0x0 pushl $6 80106f8c: 6a 06 push $0x6 jmp alltraps 80106f8e: e9 41 f9 ff ff jmp 801068d4 <alltraps> 80106f93 <vector7>: .globl vector7 vector7: pushl $0 80106f93: 6a 00 push $0x0 pushl $7 80106f95: 6a 07 push $0x7 jmp alltraps 80106f97: e9 38 f9 ff ff jmp 801068d4 <alltraps> 80106f9c <vector8>: .globl vector8 vector8: pushl $8 80106f9c: 6a 08 push $0x8 jmp alltraps 80106f9e: e9 31 f9 ff ff jmp 801068d4 <alltraps> 80106fa3 <vector9>: .globl vector9 vector9: pushl $0 80106fa3: 6a 00 push $0x0 pushl $9 80106fa5: 6a 09 push $0x9 jmp alltraps 80106fa7: e9 28 f9 ff ff jmp 801068d4 <alltraps> 80106fac <vector10>: .globl vector10 vector10: pushl $10 80106fac: 6a 0a push $0xa jmp alltraps 80106fae: e9 21 f9 ff ff jmp 801068d4 <alltraps> 80106fb3 <vector11>: .globl vector11 vector11: pushl $11 80106fb3: 6a 0b push $0xb jmp alltraps 80106fb5: e9 1a f9 ff ff jmp 801068d4 <alltraps> 80106fba <vector12>: .globl vector12 vector12: pushl $12 80106fba: 6a 0c push $0xc jmp alltraps 80106fbc: e9 13 f9 ff ff jmp 801068d4 <alltraps> 80106fc1 <vector13>: .globl vector13 vector13: pushl $13 80106fc1: 6a 0d push $0xd jmp alltraps 80106fc3: e9 0c f9 ff ff jmp 801068d4 <alltraps> 80106fc8 <vector14>: .globl vector14 vector14: pushl $14 80106fc8: 6a 0e push $0xe jmp alltraps 80106fca: e9 05 f9 ff ff jmp 801068d4 <alltraps> 80106fcf <vector15>: .globl vector15 vector15: pushl $0 80106fcf: 6a 00 push $0x0 pushl $15 80106fd1: 6a 0f push $0xf jmp alltraps 80106fd3: e9 fc f8 ff ff jmp 801068d4 <alltraps> 80106fd8 <vector16>: .globl vector16 vector16: pushl $0 80106fd8: 6a 00 push $0x0 pushl $16 80106fda: 6a 10 push $0x10 jmp alltraps 80106fdc: e9 f3 f8 ff ff jmp 801068d4 <alltraps> 80106fe1 <vector17>: .globl vector17 vector17: pushl $17 80106fe1: 6a 11 push $0x11 jmp alltraps 80106fe3: e9 ec f8 ff ff jmp 801068d4 <alltraps> 80106fe8 <vector18>: .globl vector18 vector18: pushl $0 80106fe8: 6a 00 push $0x0 pushl $18 80106fea: 6a 12 push $0x12 jmp alltraps 80106fec: e9 e3 f8 ff ff jmp 801068d4 <alltraps> 80106ff1 <vector19>: .globl vector19 vector19: pushl $0 80106ff1: 6a 00 push $0x0 pushl $19 80106ff3: 6a 13 push $0x13 jmp alltraps 80106ff5: e9 da f8 ff ff jmp 801068d4 <alltraps> 80106ffa <vector20>: .globl vector20 vector20: pushl $0 80106ffa: 6a 00 push $0x0 pushl $20 80106ffc: 6a 14 push $0x14 jmp alltraps 80106ffe: e9 d1 f8 ff ff jmp 801068d4 <alltraps> 80107003 <vector21>: .globl vector21 vector21: pushl $0 80107003: 6a 00 push $0x0 pushl $21 80107005: 6a 15 push $0x15 jmp alltraps 80107007: e9 c8 f8 ff ff jmp 801068d4 <alltraps> 8010700c <vector22>: .globl vector22 vector22: pushl $0 8010700c: 6a 00 push $0x0 pushl $22 8010700e: 6a 16 push $0x16 jmp alltraps 80107010: e9 bf f8 ff ff jmp 801068d4 <alltraps> 80107015 <vector23>: .globl vector23 vector23: pushl $0 80107015: 6a 00 push $0x0 pushl $23 80107017: 6a 17 push $0x17 jmp alltraps 80107019: e9 b6 f8 ff ff jmp 801068d4 <alltraps> 8010701e <vector24>: .globl vector24 vector24: pushl $0 8010701e: 6a 00 push $0x0 pushl $24 80107020: 6a 18 push $0x18 jmp alltraps 80107022: e9 ad f8 ff ff jmp 801068d4 <alltraps> 80107027 <vector25>: .globl vector25 vector25: pushl $0 80107027: 6a 00 push $0x0 pushl $25 80107029: 6a 19 push $0x19 jmp alltraps 8010702b: e9 a4 f8 ff ff jmp 801068d4 <alltraps> 80107030 <vector26>: .globl vector26 vector26: pushl $0 80107030: 6a 00 push $0x0 pushl $26 80107032: 6a 1a push $0x1a jmp alltraps 80107034: e9 9b f8 ff ff jmp 801068d4 <alltraps> 80107039 <vector27>: .globl vector27 vector27: pushl $0 80107039: 6a 00 push $0x0 pushl $27 8010703b: 6a 1b push $0x1b jmp alltraps 8010703d: e9 92 f8 ff ff jmp 801068d4 <alltraps> 80107042 <vector28>: .globl vector28 vector28: pushl $0 80107042: 6a 00 push $0x0 pushl $28 80107044: 6a 1c push $0x1c jmp alltraps 80107046: e9 89 f8 ff ff jmp 801068d4 <alltraps> 8010704b <vector29>: .globl vector29 vector29: pushl $0 8010704b: 6a 00 push $0x0 pushl $29 8010704d: 6a 1d push $0x1d jmp alltraps 8010704f: e9 80 f8 ff ff jmp 801068d4 <alltraps> 80107054 <vector30>: .globl vector30 vector30: pushl $0 80107054: 6a 00 push $0x0 pushl $30 80107056: 6a 1e push $0x1e jmp alltraps 80107058: e9 77 f8 ff ff jmp 801068d4 <alltraps> 8010705d <vector31>: .globl vector31 vector31: pushl $0 8010705d: 6a 00 push $0x0 pushl $31 8010705f: 6a 1f push $0x1f jmp alltraps 80107061: e9 6e f8 ff ff jmp 801068d4 <alltraps> 80107066 <vector32>: .globl vector32 vector32: pushl $0 80107066: 6a 00 push $0x0 pushl $32 80107068: 6a 20 push $0x20 jmp alltraps 8010706a: e9 65 f8 ff ff jmp 801068d4 <alltraps> 8010706f <vector33>: .globl vector33 vector33: pushl $0 8010706f: 6a 00 push $0x0 pushl $33 80107071: 6a 21 push $0x21 jmp alltraps 80107073: e9 5c f8 ff ff jmp 801068d4 <alltraps> 80107078 <vector34>: .globl vector34 vector34: pushl $0 80107078: 6a 00 push $0x0 pushl $34 8010707a: 6a 22 push $0x22 jmp alltraps 8010707c: e9 53 f8 ff ff jmp 801068d4 <alltraps> 80107081 <vector35>: .globl vector35 vector35: pushl $0 80107081: 6a 00 push $0x0 pushl $35 80107083: 6a 23 push $0x23 jmp alltraps 80107085: e9 4a f8 ff ff jmp 801068d4 <alltraps> 8010708a <vector36>: .globl vector36 vector36: pushl $0 8010708a: 6a 00 push $0x0 pushl $36 8010708c: 6a 24 push $0x24 jmp alltraps 8010708e: e9 41 f8 ff ff jmp 801068d4 <alltraps> 80107093 <vector37>: .globl vector37 vector37: pushl $0 80107093: 6a 00 push $0x0 pushl $37 80107095: 6a 25 push $0x25 jmp alltraps 80107097: e9 38 f8 ff ff jmp 801068d4 <alltraps> 8010709c <vector38>: .globl vector38 vector38: pushl $0 8010709c: 6a 00 push $0x0 pushl $38 8010709e: 6a 26 push $0x26 jmp alltraps 801070a0: e9 2f f8 ff ff jmp 801068d4 <alltraps> 801070a5 <vector39>: .globl vector39 vector39: pushl $0 801070a5: 6a 00 push $0x0 pushl $39 801070a7: 6a 27 push $0x27 jmp alltraps 801070a9: e9 26 f8 ff ff jmp 801068d4 <alltraps> 801070ae <vector40>: .globl vector40 vector40: pushl $0 801070ae: 6a 00 push $0x0 pushl $40 801070b0: 6a 28 push $0x28 jmp alltraps 801070b2: e9 1d f8 ff ff jmp 801068d4 <alltraps> 801070b7 <vector41>: .globl vector41 vector41: pushl $0 801070b7: 6a 00 push $0x0 pushl $41 801070b9: 6a 29 push $0x29 jmp alltraps 801070bb: e9 14 f8 ff ff jmp 801068d4 <alltraps> 801070c0 <vector42>: .globl vector42 vector42: pushl $0 801070c0: 6a 00 push $0x0 pushl $42 801070c2: 6a 2a push $0x2a jmp alltraps 801070c4: e9 0b f8 ff ff jmp 801068d4 <alltraps> 801070c9 <vector43>: .globl vector43 vector43: pushl $0 801070c9: 6a 00 push $0x0 pushl $43 801070cb: 6a 2b push $0x2b jmp alltraps 801070cd: e9 02 f8 ff ff jmp 801068d4 <alltraps> 801070d2 <vector44>: .globl vector44 vector44: pushl $0 801070d2: 6a 00 push $0x0 pushl $44 801070d4: 6a 2c push $0x2c jmp alltraps 801070d6: e9 f9 f7 ff ff jmp 801068d4 <alltraps> 801070db <vector45>: .globl vector45 vector45: pushl $0 801070db: 6a 00 push $0x0 pushl $45 801070dd: 6a 2d push $0x2d jmp alltraps 801070df: e9 f0 f7 ff ff jmp 801068d4 <alltraps> 801070e4 <vector46>: .globl vector46 vector46: pushl $0 801070e4: 6a 00 push $0x0 pushl $46 801070e6: 6a 2e push $0x2e jmp alltraps 801070e8: e9 e7 f7 ff ff jmp 801068d4 <alltraps> 801070ed <vector47>: .globl vector47 vector47: pushl $0 801070ed: 6a 00 push $0x0 pushl $47 801070ef: 6a 2f push $0x2f jmp alltraps 801070f1: e9 de f7 ff ff jmp 801068d4 <alltraps> 801070f6 <vector48>: .globl vector48 vector48: pushl $0 801070f6: 6a 00 push $0x0 pushl $48 801070f8: 6a 30 push $0x30 jmp alltraps 801070fa: e9 d5 f7 ff ff jmp 801068d4 <alltraps> 801070ff <vector49>: .globl vector49 vector49: pushl $0 801070ff: 6a 00 push $0x0 pushl $49 80107101: 6a 31 push $0x31 jmp alltraps 80107103: e9 cc f7 ff ff jmp 801068d4 <alltraps> 80107108 <vector50>: .globl vector50 vector50: pushl $0 80107108: 6a 00 push $0x0 pushl $50 8010710a: 6a 32 push $0x32 jmp alltraps 8010710c: e9 c3 f7 ff ff jmp 801068d4 <alltraps> 80107111 <vector51>: .globl vector51 vector51: pushl $0 80107111: 6a 00 push $0x0 pushl $51 80107113: 6a 33 push $0x33 jmp alltraps 80107115: e9 ba f7 ff ff jmp 801068d4 <alltraps> 8010711a <vector52>: .globl vector52 vector52: pushl $0 8010711a: 6a 00 push $0x0 pushl $52 8010711c: 6a 34 push $0x34 jmp alltraps 8010711e: e9 b1 f7 ff ff jmp 801068d4 <alltraps> 80107123 <vector53>: .globl vector53 vector53: pushl $0 80107123: 6a 00 push $0x0 pushl $53 80107125: 6a 35 push $0x35 jmp alltraps 80107127: e9 a8 f7 ff ff jmp 801068d4 <alltraps> 8010712c <vector54>: .globl vector54 vector54: pushl $0 8010712c: 6a 00 push $0x0 pushl $54 8010712e: 6a 36 push $0x36 jmp alltraps 80107130: e9 9f f7 ff ff jmp 801068d4 <alltraps> 80107135 <vector55>: .globl vector55 vector55: pushl $0 80107135: 6a 00 push $0x0 pushl $55 80107137: 6a 37 push $0x37 jmp alltraps 80107139: e9 96 f7 ff ff jmp 801068d4 <alltraps> 8010713e <vector56>: .globl vector56 vector56: pushl $0 8010713e: 6a 00 push $0x0 pushl $56 80107140: 6a 38 push $0x38 jmp alltraps 80107142: e9 8d f7 ff ff jmp 801068d4 <alltraps> 80107147 <vector57>: .globl vector57 vector57: pushl $0 80107147: 6a 00 push $0x0 pushl $57 80107149: 6a 39 push $0x39 jmp alltraps 8010714b: e9 84 f7 ff ff jmp 801068d4 <alltraps> 80107150 <vector58>: .globl vector58 vector58: pushl $0 80107150: 6a 00 push $0x0 pushl $58 80107152: 6a 3a push $0x3a jmp alltraps 80107154: e9 7b f7 ff ff jmp 801068d4 <alltraps> 80107159 <vector59>: .globl vector59 vector59: pushl $0 80107159: 6a 00 push $0x0 pushl $59 8010715b: 6a 3b push $0x3b jmp alltraps 8010715d: e9 72 f7 ff ff jmp 801068d4 <alltraps> 80107162 <vector60>: .globl vector60 vector60: pushl $0 80107162: 6a 00 push $0x0 pushl $60 80107164: 6a 3c push $0x3c jmp alltraps 80107166: e9 69 f7 ff ff jmp 801068d4 <alltraps> 8010716b <vector61>: .globl vector61 vector61: pushl $0 8010716b: 6a 00 push $0x0 pushl $61 8010716d: 6a 3d push $0x3d jmp alltraps 8010716f: e9 60 f7 ff ff jmp 801068d4 <alltraps> 80107174 <vector62>: .globl vector62 vector62: pushl $0 80107174: 6a 00 push $0x0 pushl $62 80107176: 6a 3e push $0x3e jmp alltraps 80107178: e9 57 f7 ff ff jmp 801068d4 <alltraps> 8010717d <vector63>: .globl vector63 vector63: pushl $0 8010717d: 6a 00 push $0x0 pushl $63 8010717f: 6a 3f push $0x3f jmp alltraps 80107181: e9 4e f7 ff ff jmp 801068d4 <alltraps> 80107186 <vector64>: .globl vector64 vector64: pushl $0 80107186: 6a 00 push $0x0 pushl $64 80107188: 6a 40 push $0x40 jmp alltraps 8010718a: e9 45 f7 ff ff jmp 801068d4 <alltraps> 8010718f <vector65>: .globl vector65 vector65: pushl $0 8010718f: 6a 00 push $0x0 pushl $65 80107191: 6a 41 push $0x41 jmp alltraps 80107193: e9 3c f7 ff ff jmp 801068d4 <alltraps> 80107198 <vector66>: .globl vector66 vector66: pushl $0 80107198: 6a 00 push $0x0 pushl $66 8010719a: 6a 42 push $0x42 jmp alltraps 8010719c: e9 33 f7 ff ff jmp 801068d4 <alltraps> 801071a1 <vector67>: .globl vector67 vector67: pushl $0 801071a1: 6a 00 push $0x0 pushl $67 801071a3: 6a 43 push $0x43 jmp alltraps 801071a5: e9 2a f7 ff ff jmp 801068d4 <alltraps> 801071aa <vector68>: .globl vector68 vector68: pushl $0 801071aa: 6a 00 push $0x0 pushl $68 801071ac: 6a 44 push $0x44 jmp alltraps 801071ae: e9 21 f7 ff ff jmp 801068d4 <alltraps> 801071b3 <vector69>: .globl vector69 vector69: pushl $0 801071b3: 6a 00 push $0x0 pushl $69 801071b5: 6a 45 push $0x45 jmp alltraps 801071b7: e9 18 f7 ff ff jmp 801068d4 <alltraps> 801071bc <vector70>: .globl vector70 vector70: pushl $0 801071bc: 6a 00 push $0x0 pushl $70 801071be: 6a 46 push $0x46 jmp alltraps 801071c0: e9 0f f7 ff ff jmp 801068d4 <alltraps> 801071c5 <vector71>: .globl vector71 vector71: pushl $0 801071c5: 6a 00 push $0x0 pushl $71 801071c7: 6a 47 push $0x47 jmp alltraps 801071c9: e9 06 f7 ff ff jmp 801068d4 <alltraps> 801071ce <vector72>: .globl vector72 vector72: pushl $0 801071ce: 6a 00 push $0x0 pushl $72 801071d0: 6a 48 push $0x48 jmp alltraps 801071d2: e9 fd f6 ff ff jmp 801068d4 <alltraps> 801071d7 <vector73>: .globl vector73 vector73: pushl $0 801071d7: 6a 00 push $0x0 pushl $73 801071d9: 6a 49 push $0x49 jmp alltraps 801071db: e9 f4 f6 ff ff jmp 801068d4 <alltraps> 801071e0 <vector74>: .globl vector74 vector74: pushl $0 801071e0: 6a 00 push $0x0 pushl $74 801071e2: 6a 4a push $0x4a jmp alltraps 801071e4: e9 eb f6 ff ff jmp 801068d4 <alltraps> 801071e9 <vector75>: .globl vector75 vector75: pushl $0 801071e9: 6a 00 push $0x0 pushl $75 801071eb: 6a 4b push $0x4b jmp alltraps 801071ed: e9 e2 f6 ff ff jmp 801068d4 <alltraps> 801071f2 <vector76>: .globl vector76 vector76: pushl $0 801071f2: 6a 00 push $0x0 pushl $76 801071f4: 6a 4c push $0x4c jmp alltraps 801071f6: e9 d9 f6 ff ff jmp 801068d4 <alltraps> 801071fb <vector77>: .globl vector77 vector77: pushl $0 801071fb: 6a 00 push $0x0 pushl $77 801071fd: 6a 4d push $0x4d jmp alltraps 801071ff: e9 d0 f6 ff ff jmp 801068d4 <alltraps> 80107204 <vector78>: .globl vector78 vector78: pushl $0 80107204: 6a 00 push $0x0 pushl $78 80107206: 6a 4e push $0x4e jmp alltraps 80107208: e9 c7 f6 ff ff jmp 801068d4 <alltraps> 8010720d <vector79>: .globl vector79 vector79: pushl $0 8010720d: 6a 00 push $0x0 pushl $79 8010720f: 6a 4f push $0x4f jmp alltraps 80107211: e9 be f6 ff ff jmp 801068d4 <alltraps> 80107216 <vector80>: .globl vector80 vector80: pushl $0 80107216: 6a 00 push $0x0 pushl $80 80107218: 6a 50 push $0x50 jmp alltraps 8010721a: e9 b5 f6 ff ff jmp 801068d4 <alltraps> 8010721f <vector81>: .globl vector81 vector81: pushl $0 8010721f: 6a 00 push $0x0 pushl $81 80107221: 6a 51 push $0x51 jmp alltraps 80107223: e9 ac f6 ff ff jmp 801068d4 <alltraps> 80107228 <vector82>: .globl vector82 vector82: pushl $0 80107228: 6a 00 push $0x0 pushl $82 8010722a: 6a 52 push $0x52 jmp alltraps 8010722c: e9 a3 f6 ff ff jmp 801068d4 <alltraps> 80107231 <vector83>: .globl vector83 vector83: pushl $0 80107231: 6a 00 push $0x0 pushl $83 80107233: 6a 53 push $0x53 jmp alltraps 80107235: e9 9a f6 ff ff jmp 801068d4 <alltraps> 8010723a <vector84>: .globl vector84 vector84: pushl $0 8010723a: 6a 00 push $0x0 pushl $84 8010723c: 6a 54 push $0x54 jmp alltraps 8010723e: e9 91 f6 ff ff jmp 801068d4 <alltraps> 80107243 <vector85>: .globl vector85 vector85: pushl $0 80107243: 6a 00 push $0x0 pushl $85 80107245: 6a 55 push $0x55 jmp alltraps 80107247: e9 88 f6 ff ff jmp 801068d4 <alltraps> 8010724c <vector86>: .globl vector86 vector86: pushl $0 8010724c: 6a 00 push $0x0 pushl $86 8010724e: 6a 56 push $0x56 jmp alltraps 80107250: e9 7f f6 ff ff jmp 801068d4 <alltraps> 80107255 <vector87>: .globl vector87 vector87: pushl $0 80107255: 6a 00 push $0x0 pushl $87 80107257: 6a 57 push $0x57 jmp alltraps 80107259: e9 76 f6 ff ff jmp 801068d4 <alltraps> 8010725e <vector88>: .globl vector88 vector88: pushl $0 8010725e: 6a 00 push $0x0 pushl $88 80107260: 6a 58 push $0x58 jmp alltraps 80107262: e9 6d f6 ff ff jmp 801068d4 <alltraps> 80107267 <vector89>: .globl vector89 vector89: pushl $0 80107267: 6a 00 push $0x0 pushl $89 80107269: 6a 59 push $0x59 jmp alltraps 8010726b: e9 64 f6 ff ff jmp 801068d4 <alltraps> 80107270 <vector90>: .globl vector90 vector90: pushl $0 80107270: 6a 00 push $0x0 pushl $90 80107272: 6a 5a push $0x5a jmp alltraps 80107274: e9 5b f6 ff ff jmp 801068d4 <alltraps> 80107279 <vector91>: .globl vector91 vector91: pushl $0 80107279: 6a 00 push $0x0 pushl $91 8010727b: 6a 5b push $0x5b jmp alltraps 8010727d: e9 52 f6 ff ff jmp 801068d4 <alltraps> 80107282 <vector92>: .globl vector92 vector92: pushl $0 80107282: 6a 00 push $0x0 pushl $92 80107284: 6a 5c push $0x5c jmp alltraps 80107286: e9 49 f6 ff ff jmp 801068d4 <alltraps> 8010728b <vector93>: .globl vector93 vector93: pushl $0 8010728b: 6a 00 push $0x0 pushl $93 8010728d: 6a 5d push $0x5d jmp alltraps 8010728f: e9 40 f6 ff ff jmp 801068d4 <alltraps> 80107294 <vector94>: .globl vector94 vector94: pushl $0 80107294: 6a 00 push $0x0 pushl $94 80107296: 6a 5e push $0x5e jmp alltraps 80107298: e9 37 f6 ff ff jmp 801068d4 <alltraps> 8010729d <vector95>: .globl vector95 vector95: pushl $0 8010729d: 6a 00 push $0x0 pushl $95 8010729f: 6a 5f push $0x5f jmp alltraps 801072a1: e9 2e f6 ff ff jmp 801068d4 <alltraps> 801072a6 <vector96>: .globl vector96 vector96: pushl $0 801072a6: 6a 00 push $0x0 pushl $96 801072a8: 6a 60 push $0x60 jmp alltraps 801072aa: e9 25 f6 ff ff jmp 801068d4 <alltraps> 801072af <vector97>: .globl vector97 vector97: pushl $0 801072af: 6a 00 push $0x0 pushl $97 801072b1: 6a 61 push $0x61 jmp alltraps 801072b3: e9 1c f6 ff ff jmp 801068d4 <alltraps> 801072b8 <vector98>: .globl vector98 vector98: pushl $0 801072b8: 6a 00 push $0x0 pushl $98 801072ba: 6a 62 push $0x62 jmp alltraps 801072bc: e9 13 f6 ff ff jmp 801068d4 <alltraps> 801072c1 <vector99>: .globl vector99 vector99: pushl $0 801072c1: 6a 00 push $0x0 pushl $99 801072c3: 6a 63 push $0x63 jmp alltraps 801072c5: e9 0a f6 ff ff jmp 801068d4 <alltraps> 801072ca <vector100>: .globl vector100 vector100: pushl $0 801072ca: 6a 00 push $0x0 pushl $100 801072cc: 6a 64 push $0x64 jmp alltraps 801072ce: e9 01 f6 ff ff jmp 801068d4 <alltraps> 801072d3 <vector101>: .globl vector101 vector101: pushl $0 801072d3: 6a 00 push $0x0 pushl $101 801072d5: 6a 65 push $0x65 jmp alltraps 801072d7: e9 f8 f5 ff ff jmp 801068d4 <alltraps> 801072dc <vector102>: .globl vector102 vector102: pushl $0 801072dc: 6a 00 push $0x0 pushl $102 801072de: 6a 66 push $0x66 jmp alltraps 801072e0: e9 ef f5 ff ff jmp 801068d4 <alltraps> 801072e5 <vector103>: .globl vector103 vector103: pushl $0 801072e5: 6a 00 push $0x0 pushl $103 801072e7: 6a 67 push $0x67 jmp alltraps 801072e9: e9 e6 f5 ff ff jmp 801068d4 <alltraps> 801072ee <vector104>: .globl vector104 vector104: pushl $0 801072ee: 6a 00 push $0x0 pushl $104 801072f0: 6a 68 push $0x68 jmp alltraps 801072f2: e9 dd f5 ff ff jmp 801068d4 <alltraps> 801072f7 <vector105>: .globl vector105 vector105: pushl $0 801072f7: 6a 00 push $0x0 pushl $105 801072f9: 6a 69 push $0x69 jmp alltraps 801072fb: e9 d4 f5 ff ff jmp 801068d4 <alltraps> 80107300 <vector106>: .globl vector106 vector106: pushl $0 80107300: 6a 00 push $0x0 pushl $106 80107302: 6a 6a push $0x6a jmp alltraps 80107304: e9 cb f5 ff ff jmp 801068d4 <alltraps> 80107309 <vector107>: .globl vector107 vector107: pushl $0 80107309: 6a 00 push $0x0 pushl $107 8010730b: 6a 6b push $0x6b jmp alltraps 8010730d: e9 c2 f5 ff ff jmp 801068d4 <alltraps> 80107312 <vector108>: .globl vector108 vector108: pushl $0 80107312: 6a 00 push $0x0 pushl $108 80107314: 6a 6c push $0x6c jmp alltraps 80107316: e9 b9 f5 ff ff jmp 801068d4 <alltraps> 8010731b <vector109>: .globl vector109 vector109: pushl $0 8010731b: 6a 00 push $0x0 pushl $109 8010731d: 6a 6d push $0x6d jmp alltraps 8010731f: e9 b0 f5 ff ff jmp 801068d4 <alltraps> 80107324 <vector110>: .globl vector110 vector110: pushl $0 80107324: 6a 00 push $0x0 pushl $110 80107326: 6a 6e push $0x6e jmp alltraps 80107328: e9 a7 f5 ff ff jmp 801068d4 <alltraps> 8010732d <vector111>: .globl vector111 vector111: pushl $0 8010732d: 6a 00 push $0x0 pushl $111 8010732f: 6a 6f push $0x6f jmp alltraps 80107331: e9 9e f5 ff ff jmp 801068d4 <alltraps> 80107336 <vector112>: .globl vector112 vector112: pushl $0 80107336: 6a 00 push $0x0 pushl $112 80107338: 6a 70 push $0x70 jmp alltraps 8010733a: e9 95 f5 ff ff jmp 801068d4 <alltraps> 8010733f <vector113>: .globl vector113 vector113: pushl $0 8010733f: 6a 00 push $0x0 pushl $113 80107341: 6a 71 push $0x71 jmp alltraps 80107343: e9 8c f5 ff ff jmp 801068d4 <alltraps> 80107348 <vector114>: .globl vector114 vector114: pushl $0 80107348: 6a 00 push $0x0 pushl $114 8010734a: 6a 72 push $0x72 jmp alltraps 8010734c: e9 83 f5 ff ff jmp 801068d4 <alltraps> 80107351 <vector115>: .globl vector115 vector115: pushl $0 80107351: 6a 00 push $0x0 pushl $115 80107353: 6a 73 push $0x73 jmp alltraps 80107355: e9 7a f5 ff ff jmp 801068d4 <alltraps> 8010735a <vector116>: .globl vector116 vector116: pushl $0 8010735a: 6a 00 push $0x0 pushl $116 8010735c: 6a 74 push $0x74 jmp alltraps 8010735e: e9 71 f5 ff ff jmp 801068d4 <alltraps> 80107363 <vector117>: .globl vector117 vector117: pushl $0 80107363: 6a 00 push $0x0 pushl $117 80107365: 6a 75 push $0x75 jmp alltraps 80107367: e9 68 f5 ff ff jmp 801068d4 <alltraps> 8010736c <vector118>: .globl vector118 vector118: pushl $0 8010736c: 6a 00 push $0x0 pushl $118 8010736e: 6a 76 push $0x76 jmp alltraps 80107370: e9 5f f5 ff ff jmp 801068d4 <alltraps> 80107375 <vector119>: .globl vector119 vector119: pushl $0 80107375: 6a 00 push $0x0 pushl $119 80107377: 6a 77 push $0x77 jmp alltraps 80107379: e9 56 f5 ff ff jmp 801068d4 <alltraps> 8010737e <vector120>: .globl vector120 vector120: pushl $0 8010737e: 6a 00 push $0x0 pushl $120 80107380: 6a 78 push $0x78 jmp alltraps 80107382: e9 4d f5 ff ff jmp 801068d4 <alltraps> 80107387 <vector121>: .globl vector121 vector121: pushl $0 80107387: 6a 00 push $0x0 pushl $121 80107389: 6a 79 push $0x79 jmp alltraps 8010738b: e9 44 f5 ff ff jmp 801068d4 <alltraps> 80107390 <vector122>: .globl vector122 vector122: pushl $0 80107390: 6a 00 push $0x0 pushl $122 80107392: 6a 7a push $0x7a jmp alltraps 80107394: e9 3b f5 ff ff jmp 801068d4 <alltraps> 80107399 <vector123>: .globl vector123 vector123: pushl $0 80107399: 6a 00 push $0x0 pushl $123 8010739b: 6a 7b push $0x7b jmp alltraps 8010739d: e9 32 f5 ff ff jmp 801068d4 <alltraps> 801073a2 <vector124>: .globl vector124 vector124: pushl $0 801073a2: 6a 00 push $0x0 pushl $124 801073a4: 6a 7c push $0x7c jmp alltraps 801073a6: e9 29 f5 ff ff jmp 801068d4 <alltraps> 801073ab <vector125>: .globl vector125 vector125: pushl $0 801073ab: 6a 00 push $0x0 pushl $125 801073ad: 6a 7d push $0x7d jmp alltraps 801073af: e9 20 f5 ff ff jmp 801068d4 <alltraps> 801073b4 <vector126>: .globl vector126 vector126: pushl $0 801073b4: 6a 00 push $0x0 pushl $126 801073b6: 6a 7e push $0x7e jmp alltraps 801073b8: e9 17 f5 ff ff jmp 801068d4 <alltraps> 801073bd <vector127>: .globl vector127 vector127: pushl $0 801073bd: 6a 00 push $0x0 pushl $127 801073bf: 6a 7f push $0x7f jmp alltraps 801073c1: e9 0e f5 ff ff jmp 801068d4 <alltraps> 801073c6 <vector128>: .globl vector128 vector128: pushl $0 801073c6: 6a 00 push $0x0 pushl $128 801073c8: 68 80 00 00 00 push $0x80 jmp alltraps 801073cd: e9 02 f5 ff ff jmp 801068d4 <alltraps> 801073d2 <vector129>: .globl vector129 vector129: pushl $0 801073d2: 6a 00 push $0x0 pushl $129 801073d4: 68 81 00 00 00 push $0x81 jmp alltraps 801073d9: e9 f6 f4 ff ff jmp 801068d4 <alltraps> 801073de <vector130>: .globl vector130 vector130: pushl $0 801073de: 6a 00 push $0x0 pushl $130 801073e0: 68 82 00 00 00 push $0x82 jmp alltraps 801073e5: e9 ea f4 ff ff jmp 801068d4 <alltraps> 801073ea <vector131>: .globl vector131 vector131: pushl $0 801073ea: 6a 00 push $0x0 pushl $131 801073ec: 68 83 00 00 00 push $0x83 jmp alltraps 801073f1: e9 de f4 ff ff jmp 801068d4 <alltraps> 801073f6 <vector132>: .globl vector132 vector132: pushl $0 801073f6: 6a 00 push $0x0 pushl $132 801073f8: 68 84 00 00 00 push $0x84 jmp alltraps 801073fd: e9 d2 f4 ff ff jmp 801068d4 <alltraps> 80107402 <vector133>: .globl vector133 vector133: pushl $0 80107402: 6a 00 push $0x0 pushl $133 80107404: 68 85 00 00 00 push $0x85 jmp alltraps 80107409: e9 c6 f4 ff ff jmp 801068d4 <alltraps> 8010740e <vector134>: .globl vector134 vector134: pushl $0 8010740e: 6a 00 push $0x0 pushl $134 80107410: 68 86 00 00 00 push $0x86 jmp alltraps 80107415: e9 ba f4 ff ff jmp 801068d4 <alltraps> 8010741a <vector135>: .globl vector135 vector135: pushl $0 8010741a: 6a 00 push $0x0 pushl $135 8010741c: 68 87 00 00 00 push $0x87 jmp alltraps 80107421: e9 ae f4 ff ff jmp 801068d4 <alltraps> 80107426 <vector136>: .globl vector136 vector136: pushl $0 80107426: 6a 00 push $0x0 pushl $136 80107428: 68 88 00 00 00 push $0x88 jmp alltraps 8010742d: e9 a2 f4 ff ff jmp 801068d4 <alltraps> 80107432 <vector137>: .globl vector137 vector137: pushl $0 80107432: 6a 00 push $0x0 pushl $137 80107434: 68 89 00 00 00 push $0x89 jmp alltraps 80107439: e9 96 f4 ff ff jmp 801068d4 <alltraps> 8010743e <vector138>: .globl vector138 vector138: pushl $0 8010743e: 6a 00 push $0x0 pushl $138 80107440: 68 8a 00 00 00 push $0x8a jmp alltraps 80107445: e9 8a f4 ff ff jmp 801068d4 <alltraps> 8010744a <vector139>: .globl vector139 vector139: pushl $0 8010744a: 6a 00 push $0x0 pushl $139 8010744c: 68 8b 00 00 00 push $0x8b jmp alltraps 80107451: e9 7e f4 ff ff jmp 801068d4 <alltraps> 80107456 <vector140>: .globl vector140 vector140: pushl $0 80107456: 6a 00 push $0x0 pushl $140 80107458: 68 8c 00 00 00 push $0x8c jmp alltraps 8010745d: e9 72 f4 ff ff jmp 801068d4 <alltraps> 80107462 <vector141>: .globl vector141 vector141: pushl $0 80107462: 6a 00 push $0x0 pushl $141 80107464: 68 8d 00 00 00 push $0x8d jmp alltraps 80107469: e9 66 f4 ff ff jmp 801068d4 <alltraps> 8010746e <vector142>: .globl vector142 vector142: pushl $0 8010746e: 6a 00 push $0x0 pushl $142 80107470: 68 8e 00 00 00 push $0x8e jmp alltraps 80107475: e9 5a f4 ff ff jmp 801068d4 <alltraps> 8010747a <vector143>: .globl vector143 vector143: pushl $0 8010747a: 6a 00 push $0x0 pushl $143 8010747c: 68 8f 00 00 00 push $0x8f jmp alltraps 80107481: e9 4e f4 ff ff jmp 801068d4 <alltraps> 80107486 <vector144>: .globl vector144 vector144: pushl $0 80107486: 6a 00 push $0x0 pushl $144 80107488: 68 90 00 00 00 push $0x90 jmp alltraps 8010748d: e9 42 f4 ff ff jmp 801068d4 <alltraps> 80107492 <vector145>: .globl vector145 vector145: pushl $0 80107492: 6a 00 push $0x0 pushl $145 80107494: 68 91 00 00 00 push $0x91 jmp alltraps 80107499: e9 36 f4 ff ff jmp 801068d4 <alltraps> 8010749e <vector146>: .globl vector146 vector146: pushl $0 8010749e: 6a 00 push $0x0 pushl $146 801074a0: 68 92 00 00 00 push $0x92 jmp alltraps 801074a5: e9 2a f4 ff ff jmp 801068d4 <alltraps> 801074aa <vector147>: .globl vector147 vector147: pushl $0 801074aa: 6a 00 push $0x0 pushl $147 801074ac: 68 93 00 00 00 push $0x93 jmp alltraps 801074b1: e9 1e f4 ff ff jmp 801068d4 <alltraps> 801074b6 <vector148>: .globl vector148 vector148: pushl $0 801074b6: 6a 00 push $0x0 pushl $148 801074b8: 68 94 00 00 00 push $0x94 jmp alltraps 801074bd: e9 12 f4 ff ff jmp 801068d4 <alltraps> 801074c2 <vector149>: .globl vector149 vector149: pushl $0 801074c2: 6a 00 push $0x0 pushl $149 801074c4: 68 95 00 00 00 push $0x95 jmp alltraps 801074c9: e9 06 f4 ff ff jmp 801068d4 <alltraps> 801074ce <vector150>: .globl vector150 vector150: pushl $0 801074ce: 6a 00 push $0x0 pushl $150 801074d0: 68 96 00 00 00 push $0x96 jmp alltraps 801074d5: e9 fa f3 ff ff jmp 801068d4 <alltraps> 801074da <vector151>: .globl vector151 vector151: pushl $0 801074da: 6a 00 push $0x0 pushl $151 801074dc: 68 97 00 00 00 push $0x97 jmp alltraps 801074e1: e9 ee f3 ff ff jmp 801068d4 <alltraps> 801074e6 <vector152>: .globl vector152 vector152: pushl $0 801074e6: 6a 00 push $0x0 pushl $152 801074e8: 68 98 00 00 00 push $0x98 jmp alltraps 801074ed: e9 e2 f3 ff ff jmp 801068d4 <alltraps> 801074f2 <vector153>: .globl vector153 vector153: pushl $0 801074f2: 6a 00 push $0x0 pushl $153 801074f4: 68 99 00 00 00 push $0x99 jmp alltraps 801074f9: e9 d6 f3 ff ff jmp 801068d4 <alltraps> 801074fe <vector154>: .globl vector154 vector154: pushl $0 801074fe: 6a 00 push $0x0 pushl $154 80107500: 68 9a 00 00 00 push $0x9a jmp alltraps 80107505: e9 ca f3 ff ff jmp 801068d4 <alltraps> 8010750a <vector155>: .globl vector155 vector155: pushl $0 8010750a: 6a 00 push $0x0 pushl $155 8010750c: 68 9b 00 00 00 push $0x9b jmp alltraps 80107511: e9 be f3 ff ff jmp 801068d4 <alltraps> 80107516 <vector156>: .globl vector156 vector156: pushl $0 80107516: 6a 00 push $0x0 pushl $156 80107518: 68 9c 00 00 00 push $0x9c jmp alltraps 8010751d: e9 b2 f3 ff ff jmp 801068d4 <alltraps> 80107522 <vector157>: .globl vector157 vector157: pushl $0 80107522: 6a 00 push $0x0 pushl $157 80107524: 68 9d 00 00 00 push $0x9d jmp alltraps 80107529: e9 a6 f3 ff ff jmp 801068d4 <alltraps> 8010752e <vector158>: .globl vector158 vector158: pushl $0 8010752e: 6a 00 push $0x0 pushl $158 80107530: 68 9e 00 00 00 push $0x9e jmp alltraps 80107535: e9 9a f3 ff ff jmp 801068d4 <alltraps> 8010753a <vector159>: .globl vector159 vector159: pushl $0 8010753a: 6a 00 push $0x0 pushl $159 8010753c: 68 9f 00 00 00 push $0x9f jmp alltraps 80107541: e9 8e f3 ff ff jmp 801068d4 <alltraps> 80107546 <vector160>: .globl vector160 vector160: pushl $0 80107546: 6a 00 push $0x0 pushl $160 80107548: 68 a0 00 00 00 push $0xa0 jmp alltraps 8010754d: e9 82 f3 ff ff jmp 801068d4 <alltraps> 80107552 <vector161>: .globl vector161 vector161: pushl $0 80107552: 6a 00 push $0x0 pushl $161 80107554: 68 a1 00 00 00 push $0xa1 jmp alltraps 80107559: e9 76 f3 ff ff jmp 801068d4 <alltraps> 8010755e <vector162>: .globl vector162 vector162: pushl $0 8010755e: 6a 00 push $0x0 pushl $162 80107560: 68 a2 00 00 00 push $0xa2 jmp alltraps 80107565: e9 6a f3 ff ff jmp 801068d4 <alltraps> 8010756a <vector163>: .globl vector163 vector163: pushl $0 8010756a: 6a 00 push $0x0 pushl $163 8010756c: 68 a3 00 00 00 push $0xa3 jmp alltraps 80107571: e9 5e f3 ff ff jmp 801068d4 <alltraps> 80107576 <vector164>: .globl vector164 vector164: pushl $0 80107576: 6a 00 push $0x0 pushl $164 80107578: 68 a4 00 00 00 push $0xa4 jmp alltraps 8010757d: e9 52 f3 ff ff jmp 801068d4 <alltraps> 80107582 <vector165>: .globl vector165 vector165: pushl $0 80107582: 6a 00 push $0x0 pushl $165 80107584: 68 a5 00 00 00 push $0xa5 jmp alltraps 80107589: e9 46 f3 ff ff jmp 801068d4 <alltraps> 8010758e <vector166>: .globl vector166 vector166: pushl $0 8010758e: 6a 00 push $0x0 pushl $166 80107590: 68 a6 00 00 00 push $0xa6 jmp alltraps 80107595: e9 3a f3 ff ff jmp 801068d4 <alltraps> 8010759a <vector167>: .globl vector167 vector167: pushl $0 8010759a: 6a 00 push $0x0 pushl $167 8010759c: 68 a7 00 00 00 push $0xa7 jmp alltraps 801075a1: e9 2e f3 ff ff jmp 801068d4 <alltraps> 801075a6 <vector168>: .globl vector168 vector168: pushl $0 801075a6: 6a 00 push $0x0 pushl $168 801075a8: 68 a8 00 00 00 push $0xa8 jmp alltraps 801075ad: e9 22 f3 ff ff jmp 801068d4 <alltraps> 801075b2 <vector169>: .globl vector169 vector169: pushl $0 801075b2: 6a 00 push $0x0 pushl $169 801075b4: 68 a9 00 00 00 push $0xa9 jmp alltraps 801075b9: e9 16 f3 ff ff jmp 801068d4 <alltraps> 801075be <vector170>: .globl vector170 vector170: pushl $0 801075be: 6a 00 push $0x0 pushl $170 801075c0: 68 aa 00 00 00 push $0xaa jmp alltraps 801075c5: e9 0a f3 ff ff jmp 801068d4 <alltraps> 801075ca <vector171>: .globl vector171 vector171: pushl $0 801075ca: 6a 00 push $0x0 pushl $171 801075cc: 68 ab 00 00 00 push $0xab jmp alltraps 801075d1: e9 fe f2 ff ff jmp 801068d4 <alltraps> 801075d6 <vector172>: .globl vector172 vector172: pushl $0 801075d6: 6a 00 push $0x0 pushl $172 801075d8: 68 ac 00 00 00 push $0xac jmp alltraps 801075dd: e9 f2 f2 ff ff jmp 801068d4 <alltraps> 801075e2 <vector173>: .globl vector173 vector173: pushl $0 801075e2: 6a 00 push $0x0 pushl $173 801075e4: 68 ad 00 00 00 push $0xad jmp alltraps 801075e9: e9 e6 f2 ff ff jmp 801068d4 <alltraps> 801075ee <vector174>: .globl vector174 vector174: pushl $0 801075ee: 6a 00 push $0x0 pushl $174 801075f0: 68 ae 00 00 00 push $0xae jmp alltraps 801075f5: e9 da f2 ff ff jmp 801068d4 <alltraps> 801075fa <vector175>: .globl vector175 vector175: pushl $0 801075fa: 6a 00 push $0x0 pushl $175 801075fc: 68 af 00 00 00 push $0xaf jmp alltraps 80107601: e9 ce f2 ff ff jmp 801068d4 <alltraps> 80107606 <vector176>: .globl vector176 vector176: pushl $0 80107606: 6a 00 push $0x0 pushl $176 80107608: 68 b0 00 00 00 push $0xb0 jmp alltraps 8010760d: e9 c2 f2 ff ff jmp 801068d4 <alltraps> 80107612 <vector177>: .globl vector177 vector177: pushl $0 80107612: 6a 00 push $0x0 pushl $177 80107614: 68 b1 00 00 00 push $0xb1 jmp alltraps 80107619: e9 b6 f2 ff ff jmp 801068d4 <alltraps> 8010761e <vector178>: .globl vector178 vector178: pushl $0 8010761e: 6a 00 push $0x0 pushl $178 80107620: 68 b2 00 00 00 push $0xb2 jmp alltraps 80107625: e9 aa f2 ff ff jmp 801068d4 <alltraps> 8010762a <vector179>: .globl vector179 vector179: pushl $0 8010762a: 6a 00 push $0x0 pushl $179 8010762c: 68 b3 00 00 00 push $0xb3 jmp alltraps 80107631: e9 9e f2 ff ff jmp 801068d4 <alltraps> 80107636 <vector180>: .globl vector180 vector180: pushl $0 80107636: 6a 00 push $0x0 pushl $180 80107638: 68 b4 00 00 00 push $0xb4 jmp alltraps 8010763d: e9 92 f2 ff ff jmp 801068d4 <alltraps> 80107642 <vector181>: .globl vector181 vector181: pushl $0 80107642: 6a 00 push $0x0 pushl $181 80107644: 68 b5 00 00 00 push $0xb5 jmp alltraps 80107649: e9 86 f2 ff ff jmp 801068d4 <alltraps> 8010764e <vector182>: .globl vector182 vector182: pushl $0 8010764e: 6a 00 push $0x0 pushl $182 80107650: 68 b6 00 00 00 push $0xb6 jmp alltraps 80107655: e9 7a f2 ff ff jmp 801068d4 <alltraps> 8010765a <vector183>: .globl vector183 vector183: pushl $0 8010765a: 6a 00 push $0x0 pushl $183 8010765c: 68 b7 00 00 00 push $0xb7 jmp alltraps 80107661: e9 6e f2 ff ff jmp 801068d4 <alltraps> 80107666 <vector184>: .globl vector184 vector184: pushl $0 80107666: 6a 00 push $0x0 pushl $184 80107668: 68 b8 00 00 00 push $0xb8 jmp alltraps 8010766d: e9 62 f2 ff ff jmp 801068d4 <alltraps> 80107672 <vector185>: .globl vector185 vector185: pushl $0 80107672: 6a 00 push $0x0 pushl $185 80107674: 68 b9 00 00 00 push $0xb9 jmp alltraps 80107679: e9 56 f2 ff ff jmp 801068d4 <alltraps> 8010767e <vector186>: .globl vector186 vector186: pushl $0 8010767e: 6a 00 push $0x0 pushl $186 80107680: 68 ba 00 00 00 push $0xba jmp alltraps 80107685: e9 4a f2 ff ff jmp 801068d4 <alltraps> 8010768a <vector187>: .globl vector187 vector187: pushl $0 8010768a: 6a 00 push $0x0 pushl $187 8010768c: 68 bb 00 00 00 push $0xbb jmp alltraps 80107691: e9 3e f2 ff ff jmp 801068d4 <alltraps> 80107696 <vector188>: .globl vector188 vector188: pushl $0 80107696: 6a 00 push $0x0 pushl $188 80107698: 68 bc 00 00 00 push $0xbc jmp alltraps 8010769d: e9 32 f2 ff ff jmp 801068d4 <alltraps> 801076a2 <vector189>: .globl vector189 vector189: pushl $0 801076a2: 6a 00 push $0x0 pushl $189 801076a4: 68 bd 00 00 00 push $0xbd jmp alltraps 801076a9: e9 26 f2 ff ff jmp 801068d4 <alltraps> 801076ae <vector190>: .globl vector190 vector190: pushl $0 801076ae: 6a 00 push $0x0 pushl $190 801076b0: 68 be 00 00 00 push $0xbe jmp alltraps 801076b5: e9 1a f2 ff ff jmp 801068d4 <alltraps> 801076ba <vector191>: .globl vector191 vector191: pushl $0 801076ba: 6a 00 push $0x0 pushl $191 801076bc: 68 bf 00 00 00 push $0xbf jmp alltraps 801076c1: e9 0e f2 ff ff jmp 801068d4 <alltraps> 801076c6 <vector192>: .globl vector192 vector192: pushl $0 801076c6: 6a 00 push $0x0 pushl $192 801076c8: 68 c0 00 00 00 push $0xc0 jmp alltraps 801076cd: e9 02 f2 ff ff jmp 801068d4 <alltraps> 801076d2 <vector193>: .globl vector193 vector193: pushl $0 801076d2: 6a 00 push $0x0 pushl $193 801076d4: 68 c1 00 00 00 push $0xc1 jmp alltraps 801076d9: e9 f6 f1 ff ff jmp 801068d4 <alltraps> 801076de <vector194>: .globl vector194 vector194: pushl $0 801076de: 6a 00 push $0x0 pushl $194 801076e0: 68 c2 00 00 00 push $0xc2 jmp alltraps 801076e5: e9 ea f1 ff ff jmp 801068d4 <alltraps> 801076ea <vector195>: .globl vector195 vector195: pushl $0 801076ea: 6a 00 push $0x0 pushl $195 801076ec: 68 c3 00 00 00 push $0xc3 jmp alltraps 801076f1: e9 de f1 ff ff jmp 801068d4 <alltraps> 801076f6 <vector196>: .globl vector196 vector196: pushl $0 801076f6: 6a 00 push $0x0 pushl $196 801076f8: 68 c4 00 00 00 push $0xc4 jmp alltraps 801076fd: e9 d2 f1 ff ff jmp 801068d4 <alltraps> 80107702 <vector197>: .globl vector197 vector197: pushl $0 80107702: 6a 00 push $0x0 pushl $197 80107704: 68 c5 00 00 00 push $0xc5 jmp alltraps 80107709: e9 c6 f1 ff ff jmp 801068d4 <alltraps> 8010770e <vector198>: .globl vector198 vector198: pushl $0 8010770e: 6a 00 push $0x0 pushl $198 80107710: 68 c6 00 00 00 push $0xc6 jmp alltraps 80107715: e9 ba f1 ff ff jmp 801068d4 <alltraps> 8010771a <vector199>: .globl vector199 vector199: pushl $0 8010771a: 6a 00 push $0x0 pushl $199 8010771c: 68 c7 00 00 00 push $0xc7 jmp alltraps 80107721: e9 ae f1 ff ff jmp 801068d4 <alltraps> 80107726 <vector200>: .globl vector200 vector200: pushl $0 80107726: 6a 00 push $0x0 pushl $200 80107728: 68 c8 00 00 00 push $0xc8 jmp alltraps 8010772d: e9 a2 f1 ff ff jmp 801068d4 <alltraps> 80107732 <vector201>: .globl vector201 vector201: pushl $0 80107732: 6a 00 push $0x0 pushl $201 80107734: 68 c9 00 00 00 push $0xc9 jmp alltraps 80107739: e9 96 f1 ff ff jmp 801068d4 <alltraps> 8010773e <vector202>: .globl vector202 vector202: pushl $0 8010773e: 6a 00 push $0x0 pushl $202 80107740: 68 ca 00 00 00 push $0xca jmp alltraps 80107745: e9 8a f1 ff ff jmp 801068d4 <alltraps> 8010774a <vector203>: .globl vector203 vector203: pushl $0 8010774a: 6a 00 push $0x0 pushl $203 8010774c: 68 cb 00 00 00 push $0xcb jmp alltraps 80107751: e9 7e f1 ff ff jmp 801068d4 <alltraps> 80107756 <vector204>: .globl vector204 vector204: pushl $0 80107756: 6a 00 push $0x0 pushl $204 80107758: 68 cc 00 00 00 push $0xcc jmp alltraps 8010775d: e9 72 f1 ff ff jmp 801068d4 <alltraps> 80107762 <vector205>: .globl vector205 vector205: pushl $0 80107762: 6a 00 push $0x0 pushl $205 80107764: 68 cd 00 00 00 push $0xcd jmp alltraps 80107769: e9 66 f1 ff ff jmp 801068d4 <alltraps> 8010776e <vector206>: .globl vector206 vector206: pushl $0 8010776e: 6a 00 push $0x0 pushl $206 80107770: 68 ce 00 00 00 push $0xce jmp alltraps 80107775: e9 5a f1 ff ff jmp 801068d4 <alltraps> 8010777a <vector207>: .globl vector207 vector207: pushl $0 8010777a: 6a 00 push $0x0 pushl $207 8010777c: 68 cf 00 00 00 push $0xcf jmp alltraps 80107781: e9 4e f1 ff ff jmp 801068d4 <alltraps> 80107786 <vector208>: .globl vector208 vector208: pushl $0 80107786: 6a 00 push $0x0 pushl $208 80107788: 68 d0 00 00 00 push $0xd0 jmp alltraps 8010778d: e9 42 f1 ff ff jmp 801068d4 <alltraps> 80107792 <vector209>: .globl vector209 vector209: pushl $0 80107792: 6a 00 push $0x0 pushl $209 80107794: 68 d1 00 00 00 push $0xd1 jmp alltraps 80107799: e9 36 f1 ff ff jmp 801068d4 <alltraps> 8010779e <vector210>: .globl vector210 vector210: pushl $0 8010779e: 6a 00 push $0x0 pushl $210 801077a0: 68 d2 00 00 00 push $0xd2 jmp alltraps 801077a5: e9 2a f1 ff ff jmp 801068d4 <alltraps> 801077aa <vector211>: .globl vector211 vector211: pushl $0 801077aa: 6a 00 push $0x0 pushl $211 801077ac: 68 d3 00 00 00 push $0xd3 jmp alltraps 801077b1: e9 1e f1 ff ff jmp 801068d4 <alltraps> 801077b6 <vector212>: .globl vector212 vector212: pushl $0 801077b6: 6a 00 push $0x0 pushl $212 801077b8: 68 d4 00 00 00 push $0xd4 jmp alltraps 801077bd: e9 12 f1 ff ff jmp 801068d4 <alltraps> 801077c2 <vector213>: .globl vector213 vector213: pushl $0 801077c2: 6a 00 push $0x0 pushl $213 801077c4: 68 d5 00 00 00 push $0xd5 jmp alltraps 801077c9: e9 06 f1 ff ff jmp 801068d4 <alltraps> 801077ce <vector214>: .globl vector214 vector214: pushl $0 801077ce: 6a 00 push $0x0 pushl $214 801077d0: 68 d6 00 00 00 push $0xd6 jmp alltraps 801077d5: e9 fa f0 ff ff jmp 801068d4 <alltraps> 801077da <vector215>: .globl vector215 vector215: pushl $0 801077da: 6a 00 push $0x0 pushl $215 801077dc: 68 d7 00 00 00 push $0xd7 jmp alltraps 801077e1: e9 ee f0 ff ff jmp 801068d4 <alltraps> 801077e6 <vector216>: .globl vector216 vector216: pushl $0 801077e6: 6a 00 push $0x0 pushl $216 801077e8: 68 d8 00 00 00 push $0xd8 jmp alltraps 801077ed: e9 e2 f0 ff ff jmp 801068d4 <alltraps> 801077f2 <vector217>: .globl vector217 vector217: pushl $0 801077f2: 6a 00 push $0x0 pushl $217 801077f4: 68 d9 00 00 00 push $0xd9 jmp alltraps 801077f9: e9 d6 f0 ff ff jmp 801068d4 <alltraps> 801077fe <vector218>: .globl vector218 vector218: pushl $0 801077fe: 6a 00 push $0x0 pushl $218 80107800: 68 da 00 00 00 push $0xda jmp alltraps 80107805: e9 ca f0 ff ff jmp 801068d4 <alltraps> 8010780a <vector219>: .globl vector219 vector219: pushl $0 8010780a: 6a 00 push $0x0 pushl $219 8010780c: 68 db 00 00 00 push $0xdb jmp alltraps 80107811: e9 be f0 ff ff jmp 801068d4 <alltraps> 80107816 <vector220>: .globl vector220 vector220: pushl $0 80107816: 6a 00 push $0x0 pushl $220 80107818: 68 dc 00 00 00 push $0xdc jmp alltraps 8010781d: e9 b2 f0 ff ff jmp 801068d4 <alltraps> 80107822 <vector221>: .globl vector221 vector221: pushl $0 80107822: 6a 00 push $0x0 pushl $221 80107824: 68 dd 00 00 00 push $0xdd jmp alltraps 80107829: e9 a6 f0 ff ff jmp 801068d4 <alltraps> 8010782e <vector222>: .globl vector222 vector222: pushl $0 8010782e: 6a 00 push $0x0 pushl $222 80107830: 68 de 00 00 00 push $0xde jmp alltraps 80107835: e9 9a f0 ff ff jmp 801068d4 <alltraps> 8010783a <vector223>: .globl vector223 vector223: pushl $0 8010783a: 6a 00 push $0x0 pushl $223 8010783c: 68 df 00 00 00 push $0xdf jmp alltraps 80107841: e9 8e f0 ff ff jmp 801068d4 <alltraps> 80107846 <vector224>: .globl vector224 vector224: pushl $0 80107846: 6a 00 push $0x0 pushl $224 80107848: 68 e0 00 00 00 push $0xe0 jmp alltraps 8010784d: e9 82 f0 ff ff jmp 801068d4 <alltraps> 80107852 <vector225>: .globl vector225 vector225: pushl $0 80107852: 6a 00 push $0x0 pushl $225 80107854: 68 e1 00 00 00 push $0xe1 jmp alltraps 80107859: e9 76 f0 ff ff jmp 801068d4 <alltraps> 8010785e <vector226>: .globl vector226 vector226: pushl $0 8010785e: 6a 00 push $0x0 pushl $226 80107860: 68 e2 00 00 00 push $0xe2 jmp alltraps 80107865: e9 6a f0 ff ff jmp 801068d4 <alltraps> 8010786a <vector227>: .globl vector227 vector227: pushl $0 8010786a: 6a 00 push $0x0 pushl $227 8010786c: 68 e3 00 00 00 push $0xe3 jmp alltraps 80107871: e9 5e f0 ff ff jmp 801068d4 <alltraps> 80107876 <vector228>: .globl vector228 vector228: pushl $0 80107876: 6a 00 push $0x0 pushl $228 80107878: 68 e4 00 00 00 push $0xe4 jmp alltraps 8010787d: e9 52 f0 ff ff jmp 801068d4 <alltraps> 80107882 <vector229>: .globl vector229 vector229: pushl $0 80107882: 6a 00 push $0x0 pushl $229 80107884: 68 e5 00 00 00 push $0xe5 jmp alltraps 80107889: e9 46 f0 ff ff jmp 801068d4 <alltraps> 8010788e <vector230>: .globl vector230 vector230: pushl $0 8010788e: 6a 00 push $0x0 pushl $230 80107890: 68 e6 00 00 00 push $0xe6 jmp alltraps 80107895: e9 3a f0 ff ff jmp 801068d4 <alltraps> 8010789a <vector231>: .globl vector231 vector231: pushl $0 8010789a: 6a 00 push $0x0 pushl $231 8010789c: 68 e7 00 00 00 push $0xe7 jmp alltraps 801078a1: e9 2e f0 ff ff jmp 801068d4 <alltraps> 801078a6 <vector232>: .globl vector232 vector232: pushl $0 801078a6: 6a 00 push $0x0 pushl $232 801078a8: 68 e8 00 00 00 push $0xe8 jmp alltraps 801078ad: e9 22 f0 ff ff jmp 801068d4 <alltraps> 801078b2 <vector233>: .globl vector233 vector233: pushl $0 801078b2: 6a 00 push $0x0 pushl $233 801078b4: 68 e9 00 00 00 push $0xe9 jmp alltraps 801078b9: e9 16 f0 ff ff jmp 801068d4 <alltraps> 801078be <vector234>: .globl vector234 vector234: pushl $0 801078be: 6a 00 push $0x0 pushl $234 801078c0: 68 ea 00 00 00 push $0xea jmp alltraps 801078c5: e9 0a f0 ff ff jmp 801068d4 <alltraps> 801078ca <vector235>: .globl vector235 vector235: pushl $0 801078ca: 6a 00 push $0x0 pushl $235 801078cc: 68 eb 00 00 00 push $0xeb jmp alltraps 801078d1: e9 fe ef ff ff jmp 801068d4 <alltraps> 801078d6 <vector236>: .globl vector236 vector236: pushl $0 801078d6: 6a 00 push $0x0 pushl $236 801078d8: 68 ec 00 00 00 push $0xec jmp alltraps 801078dd: e9 f2 ef ff ff jmp 801068d4 <alltraps> 801078e2 <vector237>: .globl vector237 vector237: pushl $0 801078e2: 6a 00 push $0x0 pushl $237 801078e4: 68 ed 00 00 00 push $0xed jmp alltraps 801078e9: e9 e6 ef ff ff jmp 801068d4 <alltraps> 801078ee <vector238>: .globl vector238 vector238: pushl $0 801078ee: 6a 00 push $0x0 pushl $238 801078f0: 68 ee 00 00 00 push $0xee jmp alltraps 801078f5: e9 da ef ff ff jmp 801068d4 <alltraps> 801078fa <vector239>: .globl vector239 vector239: pushl $0 801078fa: 6a 00 push $0x0 pushl $239 801078fc: 68 ef 00 00 00 push $0xef jmp alltraps 80107901: e9 ce ef ff ff jmp 801068d4 <alltraps> 80107906 <vector240>: .globl vector240 vector240: pushl $0 80107906: 6a 00 push $0x0 pushl $240 80107908: 68 f0 00 00 00 push $0xf0 jmp alltraps 8010790d: e9 c2 ef ff ff jmp 801068d4 <alltraps> 80107912 <vector241>: .globl vector241 vector241: pushl $0 80107912: 6a 00 push $0x0 pushl $241 80107914: 68 f1 00 00 00 push $0xf1 jmp alltraps 80107919: e9 b6 ef ff ff jmp 801068d4 <alltraps> 8010791e <vector242>: .globl vector242 vector242: pushl $0 8010791e: 6a 00 push $0x0 pushl $242 80107920: 68 f2 00 00 00 push $0xf2 jmp alltraps 80107925: e9 aa ef ff ff jmp 801068d4 <alltraps> 8010792a <vector243>: .globl vector243 vector243: pushl $0 8010792a: 6a 00 push $0x0 pushl $243 8010792c: 68 f3 00 00 00 push $0xf3 jmp alltraps 80107931: e9 9e ef ff ff jmp 801068d4 <alltraps> 80107936 <vector244>: .globl vector244 vector244: pushl $0 80107936: 6a 00 push $0x0 pushl $244 80107938: 68 f4 00 00 00 push $0xf4 jmp alltraps 8010793d: e9 92 ef ff ff jmp 801068d4 <alltraps> 80107942 <vector245>: .globl vector245 vector245: pushl $0 80107942: 6a 00 push $0x0 pushl $245 80107944: 68 f5 00 00 00 push $0xf5 jmp alltraps 80107949: e9 86 ef ff ff jmp 801068d4 <alltraps> 8010794e <vector246>: .globl vector246 vector246: pushl $0 8010794e: 6a 00 push $0x0 pushl $246 80107950: 68 f6 00 00 00 push $0xf6 jmp alltraps 80107955: e9 7a ef ff ff jmp 801068d4 <alltraps> 8010795a <vector247>: .globl vector247 vector247: pushl $0 8010795a: 6a 00 push $0x0 pushl $247 8010795c: 68 f7 00 00 00 push $0xf7 jmp alltraps 80107961: e9 6e ef ff ff jmp 801068d4 <alltraps> 80107966 <vector248>: .globl vector248 vector248: pushl $0 80107966: 6a 00 push $0x0 pushl $248 80107968: 68 f8 00 00 00 push $0xf8 jmp alltraps 8010796d: e9 62 ef ff ff jmp 801068d4 <alltraps> 80107972 <vector249>: .globl vector249 vector249: pushl $0 80107972: 6a 00 push $0x0 pushl $249 80107974: 68 f9 00 00 00 push $0xf9 jmp alltraps 80107979: e9 56 ef ff ff jmp 801068d4 <alltraps> 8010797e <vector250>: .globl vector250 vector250: pushl $0 8010797e: 6a 00 push $0x0 pushl $250 80107980: 68 fa 00 00 00 push $0xfa jmp alltraps 80107985: e9 4a ef ff ff jmp 801068d4 <alltraps> 8010798a <vector251>: .globl vector251 vector251: pushl $0 8010798a: 6a 00 push $0x0 pushl $251 8010798c: 68 fb 00 00 00 push $0xfb jmp alltraps 80107991: e9 3e ef ff ff jmp 801068d4 <alltraps> 80107996 <vector252>: .globl vector252 vector252: pushl $0 80107996: 6a 00 push $0x0 pushl $252 80107998: 68 fc 00 00 00 push $0xfc jmp alltraps 8010799d: e9 32 ef ff ff jmp 801068d4 <alltraps> 801079a2 <vector253>: .globl vector253 vector253: pushl $0 801079a2: 6a 00 push $0x0 pushl $253 801079a4: 68 fd 00 00 00 push $0xfd jmp alltraps 801079a9: e9 26 ef ff ff jmp 801068d4 <alltraps> 801079ae <vector254>: .globl vector254 vector254: pushl $0 801079ae: 6a 00 push $0x0 pushl $254 801079b0: 68 fe 00 00 00 push $0xfe jmp alltraps 801079b5: e9 1a ef ff ff jmp 801068d4 <alltraps> 801079ba <vector255>: .globl vector255 vector255: pushl $0 801079ba: 6a 00 push $0x0 pushl $255 801079bc: 68 ff 00 00 00 push $0xff jmp alltraps 801079c1: e9 0e ef ff ff jmp 801068d4 <alltraps> 801079c6: 66 90 xchg %ax,%ax 801079c8 <lgdt>: struct segdesc; static inline void lgdt(struct segdesc *p, int size) { 801079c8: 55 push %ebp 801079c9: 89 e5 mov %esp,%ebp 801079cb: 83 ec 10 sub $0x10,%esp volatile ushort pd[3]; pd[0] = size-1; 801079ce: 8b 45 0c mov 0xc(%ebp),%eax 801079d1: 83 e8 01 sub $0x1,%eax 801079d4: 66 89 45 fa mov %ax,-0x6(%ebp) pd[1] = (uint)p; 801079d8: 8b 45 08 mov 0x8(%ebp),%eax 801079db: 66 89 45 fc mov %ax,-0x4(%ebp) pd[2] = (uint)p >> 16; 801079df: 8b 45 08 mov 0x8(%ebp),%eax 801079e2: c1 e8 10 shr $0x10,%eax 801079e5: 66 89 45 fe mov %ax,-0x2(%ebp) asm volatile("lgdt (%0)" : : "r" (pd)); 801079e9: 8d 45 fa lea -0x6(%ebp),%eax 801079ec: 0f 01 10 lgdtl (%eax) } 801079ef: c9 leave 801079f0: c3 ret 801079f1 <ltr>: asm volatile("lidt (%0)" : : "r" (pd)); } static inline void ltr(ushort sel) { 801079f1: 55 push %ebp 801079f2: 89 e5 mov %esp,%ebp 801079f4: 83 ec 04 sub $0x4,%esp 801079f7: 8b 45 08 mov 0x8(%ebp),%eax 801079fa: 66 89 45 fc mov %ax,-0x4(%ebp) asm volatile("ltr %0" : : "r" (sel)); 801079fe: 0f b7 45 fc movzwl -0x4(%ebp),%eax 80107a02: 0f 00 d8 ltr %ax } 80107a05: c9 leave 80107a06: c3 ret 80107a07 <loadgs>: return eflags; } static inline void loadgs(ushort v) { 80107a07: 55 push %ebp 80107a08: 89 e5 mov %esp,%ebp 80107a0a: 83 ec 04 sub $0x4,%esp 80107a0d: 8b 45 08 mov 0x8(%ebp),%eax 80107a10: 66 89 45 fc mov %ax,-0x4(%ebp) asm volatile("movw %0, %%gs" : : "r" (v)); 80107a14: 0f b7 45 fc movzwl -0x4(%ebp),%eax 80107a18: 8e e8 mov %eax,%gs } 80107a1a: c9 leave 80107a1b: c3 ret 80107a1c <lcr3>: return val; } static inline void lcr3(uint val) { 80107a1c: 55 push %ebp 80107a1d: 89 e5 mov %esp,%ebp asm volatile("movl %0,%%cr3" : : "r" (val)); 80107a1f: 8b 45 08 mov 0x8(%ebp),%eax 80107a22: 0f 22 d8 mov %eax,%cr3 } 80107a25: 5d pop %ebp 80107a26: c3 ret 80107a27 <v2p>: #define KERNBASE 0x80000000 // First kernel virtual address #define KERNLINK (KERNBASE+EXTMEM) // Address where kernel is linked #ifndef __ASSEMBLER__ static inline uint v2p(void *a) { return ((uint) (a)) - KERNBASE; } 80107a27: 55 push %ebp 80107a28: 89 e5 mov %esp,%ebp 80107a2a: 8b 45 08 mov 0x8(%ebp),%eax 80107a2d: 05 00 00 00 80 add $0x80000000,%eax 80107a32: 5d pop %ebp 80107a33: c3 ret 80107a34 <p2v>: static inline void *p2v(uint a) { return (void *) ((a) + KERNBASE); } 80107a34: 55 push %ebp 80107a35: 89 e5 mov %esp,%ebp 80107a37: 8b 45 08 mov 0x8(%ebp),%eax 80107a3a: 05 00 00 00 80 add $0x80000000,%eax 80107a3f: 5d pop %ebp 80107a40: c3 ret 80107a41 <seginit>: // Set up CPU's kernel segment descriptors. // Run once on entry on each CPU. void seginit(void) { 80107a41: 55 push %ebp 80107a42: 89 e5 mov %esp,%ebp 80107a44: 53 push %ebx 80107a45: 83 ec 24 sub $0x24,%esp // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpunum()]; 80107a48: e8 ec b4 ff ff call 80102f39 <cpunum> 80107a4d: 69 c0 bc 00 00 00 imul $0xbc,%eax,%eax 80107a53: 05 60 23 11 80 add $0x80112360,%eax 80107a58: 89 45 f4 mov %eax,-0xc(%ebp) c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 80107a5b: 8b 45 f4 mov -0xc(%ebp),%eax 80107a5e: 66 c7 40 78 ff ff movw $0xffff,0x78(%eax) 80107a64: 8b 45 f4 mov -0xc(%ebp),%eax 80107a67: 66 c7 40 7a 00 00 movw $0x0,0x7a(%eax) 80107a6d: 8b 45 f4 mov -0xc(%ebp),%eax 80107a70: c6 40 7c 00 movb $0x0,0x7c(%eax) 80107a74: 8b 45 f4 mov -0xc(%ebp),%eax 80107a77: 0f b6 50 7d movzbl 0x7d(%eax),%edx 80107a7b: 83 e2 f0 and $0xfffffff0,%edx 80107a7e: 83 ca 0a or $0xa,%edx 80107a81: 88 50 7d mov %dl,0x7d(%eax) 80107a84: 8b 45 f4 mov -0xc(%ebp),%eax 80107a87: 0f b6 50 7d movzbl 0x7d(%eax),%edx 80107a8b: 83 ca 10 or $0x10,%edx 80107a8e: 88 50 7d mov %dl,0x7d(%eax) 80107a91: 8b 45 f4 mov -0xc(%ebp),%eax 80107a94: 0f b6 50 7d movzbl 0x7d(%eax),%edx 80107a98: 83 e2 9f and $0xffffff9f,%edx 80107a9b: 88 50 7d mov %dl,0x7d(%eax) 80107a9e: 8b 45 f4 mov -0xc(%ebp),%eax 80107aa1: 0f b6 50 7d movzbl 0x7d(%eax),%edx 80107aa5: 83 ca 80 or $0xffffff80,%edx 80107aa8: 88 50 7d mov %dl,0x7d(%eax) 80107aab: 8b 45 f4 mov -0xc(%ebp),%eax 80107aae: 0f b6 50 7e movzbl 0x7e(%eax),%edx 80107ab2: 83 ca 0f or $0xf,%edx 80107ab5: 88 50 7e mov %dl,0x7e(%eax) 80107ab8: 8b 45 f4 mov -0xc(%ebp),%eax 80107abb: 0f b6 50 7e movzbl 0x7e(%eax),%edx 80107abf: 83 e2 ef and $0xffffffef,%edx 80107ac2: 88 50 7e mov %dl,0x7e(%eax) 80107ac5: 8b 45 f4 mov -0xc(%ebp),%eax 80107ac8: 0f b6 50 7e movzbl 0x7e(%eax),%edx 80107acc: 83 e2 df and $0xffffffdf,%edx 80107acf: 88 50 7e mov %dl,0x7e(%eax) 80107ad2: 8b 45 f4 mov -0xc(%ebp),%eax 80107ad5: 0f b6 50 7e movzbl 0x7e(%eax),%edx 80107ad9: 83 ca 40 or $0x40,%edx 80107adc: 88 50 7e mov %dl,0x7e(%eax) 80107adf: 8b 45 f4 mov -0xc(%ebp),%eax 80107ae2: 0f b6 50 7e movzbl 0x7e(%eax),%edx 80107ae6: 83 ca 80 or $0xffffff80,%edx 80107ae9: 88 50 7e mov %dl,0x7e(%eax) 80107aec: 8b 45 f4 mov -0xc(%ebp),%eax 80107aef: c6 40 7f 00 movb $0x0,0x7f(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 80107af3: 8b 45 f4 mov -0xc(%ebp),%eax 80107af6: 66 c7 80 80 00 00 00 movw $0xffff,0x80(%eax) 80107afd: ff ff 80107aff: 8b 45 f4 mov -0xc(%ebp),%eax 80107b02: 66 c7 80 82 00 00 00 movw $0x0,0x82(%eax) 80107b09: 00 00 80107b0b: 8b 45 f4 mov -0xc(%ebp),%eax 80107b0e: c6 80 84 00 00 00 00 movb $0x0,0x84(%eax) 80107b15: 8b 45 f4 mov -0xc(%ebp),%eax 80107b18: 0f b6 90 85 00 00 00 movzbl 0x85(%eax),%edx 80107b1f: 83 e2 f0 and $0xfffffff0,%edx 80107b22: 83 ca 02 or $0x2,%edx 80107b25: 88 90 85 00 00 00 mov %dl,0x85(%eax) 80107b2b: 8b 45 f4 mov -0xc(%ebp),%eax 80107b2e: 0f b6 90 85 00 00 00 movzbl 0x85(%eax),%edx 80107b35: 83 ca 10 or $0x10,%edx 80107b38: 88 90 85 00 00 00 mov %dl,0x85(%eax) 80107b3e: 8b 45 f4 mov -0xc(%ebp),%eax 80107b41: 0f b6 90 85 00 00 00 movzbl 0x85(%eax),%edx 80107b48: 83 e2 9f and $0xffffff9f,%edx 80107b4b: 88 90 85 00 00 00 mov %dl,0x85(%eax) 80107b51: 8b 45 f4 mov -0xc(%ebp),%eax 80107b54: 0f b6 90 85 00 00 00 movzbl 0x85(%eax),%edx 80107b5b: 83 ca 80 or $0xffffff80,%edx 80107b5e: 88 90 85 00 00 00 mov %dl,0x85(%eax) 80107b64: 8b 45 f4 mov -0xc(%ebp),%eax 80107b67: 0f b6 90 86 00 00 00 movzbl 0x86(%eax),%edx 80107b6e: 83 ca 0f or $0xf,%edx 80107b71: 88 90 86 00 00 00 mov %dl,0x86(%eax) 80107b77: 8b 45 f4 mov -0xc(%ebp),%eax 80107b7a: 0f b6 90 86 00 00 00 movzbl 0x86(%eax),%edx 80107b81: 83 e2 ef and $0xffffffef,%edx 80107b84: 88 90 86 00 00 00 mov %dl,0x86(%eax) 80107b8a: 8b 45 f4 mov -0xc(%ebp),%eax 80107b8d: 0f b6 90 86 00 00 00 movzbl 0x86(%eax),%edx 80107b94: 83 e2 df and $0xffffffdf,%edx 80107b97: 88 90 86 00 00 00 mov %dl,0x86(%eax) 80107b9d: 8b 45 f4 mov -0xc(%ebp),%eax 80107ba0: 0f b6 90 86 00 00 00 movzbl 0x86(%eax),%edx 80107ba7: 83 ca 40 or $0x40,%edx 80107baa: 88 90 86 00 00 00 mov %dl,0x86(%eax) 80107bb0: 8b 45 f4 mov -0xc(%ebp),%eax 80107bb3: 0f b6 90 86 00 00 00 movzbl 0x86(%eax),%edx 80107bba: 83 ca 80 or $0xffffff80,%edx 80107bbd: 88 90 86 00 00 00 mov %dl,0x86(%eax) 80107bc3: 8b 45 f4 mov -0xc(%ebp),%eax 80107bc6: c6 80 87 00 00 00 00 movb $0x0,0x87(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 80107bcd: 8b 45 f4 mov -0xc(%ebp),%eax 80107bd0: 66 c7 80 90 00 00 00 movw $0xffff,0x90(%eax) 80107bd7: ff ff 80107bd9: 8b 45 f4 mov -0xc(%ebp),%eax 80107bdc: 66 c7 80 92 00 00 00 movw $0x0,0x92(%eax) 80107be3: 00 00 80107be5: 8b 45 f4 mov -0xc(%ebp),%eax 80107be8: c6 80 94 00 00 00 00 movb $0x0,0x94(%eax) 80107bef: 8b 45 f4 mov -0xc(%ebp),%eax 80107bf2: 0f b6 90 95 00 00 00 movzbl 0x95(%eax),%edx 80107bf9: 83 e2 f0 and $0xfffffff0,%edx 80107bfc: 83 ca 0a or $0xa,%edx 80107bff: 88 90 95 00 00 00 mov %dl,0x95(%eax) 80107c05: 8b 45 f4 mov -0xc(%ebp),%eax 80107c08: 0f b6 90 95 00 00 00 movzbl 0x95(%eax),%edx 80107c0f: 83 ca 10 or $0x10,%edx 80107c12: 88 90 95 00 00 00 mov %dl,0x95(%eax) 80107c18: 8b 45 f4 mov -0xc(%ebp),%eax 80107c1b: 0f b6 90 95 00 00 00 movzbl 0x95(%eax),%edx 80107c22: 83 ca 60 or $0x60,%edx 80107c25: 88 90 95 00 00 00 mov %dl,0x95(%eax) 80107c2b: 8b 45 f4 mov -0xc(%ebp),%eax 80107c2e: 0f b6 90 95 00 00 00 movzbl 0x95(%eax),%edx 80107c35: 83 ca 80 or $0xffffff80,%edx 80107c38: 88 90 95 00 00 00 mov %dl,0x95(%eax) 80107c3e: 8b 45 f4 mov -0xc(%ebp),%eax 80107c41: 0f b6 90 96 00 00 00 movzbl 0x96(%eax),%edx 80107c48: 83 ca 0f or $0xf,%edx 80107c4b: 88 90 96 00 00 00 mov %dl,0x96(%eax) 80107c51: 8b 45 f4 mov -0xc(%ebp),%eax 80107c54: 0f b6 90 96 00 00 00 movzbl 0x96(%eax),%edx 80107c5b: 83 e2 ef and $0xffffffef,%edx 80107c5e: 88 90 96 00 00 00 mov %dl,0x96(%eax) 80107c64: 8b 45 f4 mov -0xc(%ebp),%eax 80107c67: 0f b6 90 96 00 00 00 movzbl 0x96(%eax),%edx 80107c6e: 83 e2 df and $0xffffffdf,%edx 80107c71: 88 90 96 00 00 00 mov %dl,0x96(%eax) 80107c77: 8b 45 f4 mov -0xc(%ebp),%eax 80107c7a: 0f b6 90 96 00 00 00 movzbl 0x96(%eax),%edx 80107c81: 83 ca 40 or $0x40,%edx 80107c84: 88 90 96 00 00 00 mov %dl,0x96(%eax) 80107c8a: 8b 45 f4 mov -0xc(%ebp),%eax 80107c8d: 0f b6 90 96 00 00 00 movzbl 0x96(%eax),%edx 80107c94: 83 ca 80 or $0xffffff80,%edx 80107c97: 88 90 96 00 00 00 mov %dl,0x96(%eax) 80107c9d: 8b 45 f4 mov -0xc(%ebp),%eax 80107ca0: c6 80 97 00 00 00 00 movb $0x0,0x97(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 80107ca7: 8b 45 f4 mov -0xc(%ebp),%eax 80107caa: 66 c7 80 98 00 00 00 movw $0xffff,0x98(%eax) 80107cb1: ff ff 80107cb3: 8b 45 f4 mov -0xc(%ebp),%eax 80107cb6: 66 c7 80 9a 00 00 00 movw $0x0,0x9a(%eax) 80107cbd: 00 00 80107cbf: 8b 45 f4 mov -0xc(%ebp),%eax 80107cc2: c6 80 9c 00 00 00 00 movb $0x0,0x9c(%eax) 80107cc9: 8b 45 f4 mov -0xc(%ebp),%eax 80107ccc: 0f b6 90 9d 00 00 00 movzbl 0x9d(%eax),%edx 80107cd3: 83 e2 f0 and $0xfffffff0,%edx 80107cd6: 83 ca 02 or $0x2,%edx 80107cd9: 88 90 9d 00 00 00 mov %dl,0x9d(%eax) 80107cdf: 8b 45 f4 mov -0xc(%ebp),%eax 80107ce2: 0f b6 90 9d 00 00 00 movzbl 0x9d(%eax),%edx 80107ce9: 83 ca 10 or $0x10,%edx 80107cec: 88 90 9d 00 00 00 mov %dl,0x9d(%eax) 80107cf2: 8b 45 f4 mov -0xc(%ebp),%eax 80107cf5: 0f b6 90 9d 00 00 00 movzbl 0x9d(%eax),%edx 80107cfc: 83 ca 60 or $0x60,%edx 80107cff: 88 90 9d 00 00 00 mov %dl,0x9d(%eax) 80107d05: 8b 45 f4 mov -0xc(%ebp),%eax 80107d08: 0f b6 90 9d 00 00 00 movzbl 0x9d(%eax),%edx 80107d0f: 83 ca 80 or $0xffffff80,%edx 80107d12: 88 90 9d 00 00 00 mov %dl,0x9d(%eax) 80107d18: 8b 45 f4 mov -0xc(%ebp),%eax 80107d1b: 0f b6 90 9e 00 00 00 movzbl 0x9e(%eax),%edx 80107d22: 83 ca 0f or $0xf,%edx 80107d25: 88 90 9e 00 00 00 mov %dl,0x9e(%eax) 80107d2b: 8b 45 f4 mov -0xc(%ebp),%eax 80107d2e: 0f b6 90 9e 00 00 00 movzbl 0x9e(%eax),%edx 80107d35: 83 e2 ef and $0xffffffef,%edx 80107d38: 88 90 9e 00 00 00 mov %dl,0x9e(%eax) 80107d3e: 8b 45 f4 mov -0xc(%ebp),%eax 80107d41: 0f b6 90 9e 00 00 00 movzbl 0x9e(%eax),%edx 80107d48: 83 e2 df and $0xffffffdf,%edx 80107d4b: 88 90 9e 00 00 00 mov %dl,0x9e(%eax) 80107d51: 8b 45 f4 mov -0xc(%ebp),%eax 80107d54: 0f b6 90 9e 00 00 00 movzbl 0x9e(%eax),%edx 80107d5b: 83 ca 40 or $0x40,%edx 80107d5e: 88 90 9e 00 00 00 mov %dl,0x9e(%eax) 80107d64: 8b 45 f4 mov -0xc(%ebp),%eax 80107d67: 0f b6 90 9e 00 00 00 movzbl 0x9e(%eax),%edx 80107d6e: 83 ca 80 or $0xffffff80,%edx 80107d71: 88 90 9e 00 00 00 mov %dl,0x9e(%eax) 80107d77: 8b 45 f4 mov -0xc(%ebp),%eax 80107d7a: c6 80 9f 00 00 00 00 movb $0x0,0x9f(%eax) // Map cpu, and curproc c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0); 80107d81: 8b 45 f4 mov -0xc(%ebp),%eax 80107d84: 05 b4 00 00 00 add $0xb4,%eax 80107d89: 89 c3 mov %eax,%ebx 80107d8b: 8b 45 f4 mov -0xc(%ebp),%eax 80107d8e: 05 b4 00 00 00 add $0xb4,%eax 80107d93: c1 e8 10 shr $0x10,%eax 80107d96: 89 c1 mov %eax,%ecx 80107d98: 8b 45 f4 mov -0xc(%ebp),%eax 80107d9b: 05 b4 00 00 00 add $0xb4,%eax 80107da0: c1 e8 18 shr $0x18,%eax 80107da3: 89 c2 mov %eax,%edx 80107da5: 8b 45 f4 mov -0xc(%ebp),%eax 80107da8: 66 c7 80 88 00 00 00 movw $0x0,0x88(%eax) 80107daf: 00 00 80107db1: 8b 45 f4 mov -0xc(%ebp),%eax 80107db4: 66 89 98 8a 00 00 00 mov %bx,0x8a(%eax) 80107dbb: 8b 45 f4 mov -0xc(%ebp),%eax 80107dbe: 88 88 8c 00 00 00 mov %cl,0x8c(%eax) 80107dc4: 8b 45 f4 mov -0xc(%ebp),%eax 80107dc7: 0f b6 88 8d 00 00 00 movzbl 0x8d(%eax),%ecx 80107dce: 83 e1 f0 and $0xfffffff0,%ecx 80107dd1: 83 c9 02 or $0x2,%ecx 80107dd4: 88 88 8d 00 00 00 mov %cl,0x8d(%eax) 80107dda: 8b 45 f4 mov -0xc(%ebp),%eax 80107ddd: 0f b6 88 8d 00 00 00 movzbl 0x8d(%eax),%ecx 80107de4: 83 c9 10 or $0x10,%ecx 80107de7: 88 88 8d 00 00 00 mov %cl,0x8d(%eax) 80107ded: 8b 45 f4 mov -0xc(%ebp),%eax 80107df0: 0f b6 88 8d 00 00 00 movzbl 0x8d(%eax),%ecx 80107df7: 83 e1 9f and $0xffffff9f,%ecx 80107dfa: 88 88 8d 00 00 00 mov %cl,0x8d(%eax) 80107e00: 8b 45 f4 mov -0xc(%ebp),%eax 80107e03: 0f b6 88 8d 00 00 00 movzbl 0x8d(%eax),%ecx 80107e0a: 83 c9 80 or $0xffffff80,%ecx 80107e0d: 88 88 8d 00 00 00 mov %cl,0x8d(%eax) 80107e13: 8b 45 f4 mov -0xc(%ebp),%eax 80107e16: 0f b6 88 8e 00 00 00 movzbl 0x8e(%eax),%ecx 80107e1d: 83 e1 f0 and $0xfffffff0,%ecx 80107e20: 88 88 8e 00 00 00 mov %cl,0x8e(%eax) 80107e26: 8b 45 f4 mov -0xc(%ebp),%eax 80107e29: 0f b6 88 8e 00 00 00 movzbl 0x8e(%eax),%ecx 80107e30: 83 e1 ef and $0xffffffef,%ecx 80107e33: 88 88 8e 00 00 00 mov %cl,0x8e(%eax) 80107e39: 8b 45 f4 mov -0xc(%ebp),%eax 80107e3c: 0f b6 88 8e 00 00 00 movzbl 0x8e(%eax),%ecx 80107e43: 83 e1 df and $0xffffffdf,%ecx 80107e46: 88 88 8e 00 00 00 mov %cl,0x8e(%eax) 80107e4c: 8b 45 f4 mov -0xc(%ebp),%eax 80107e4f: 0f b6 88 8e 00 00 00 movzbl 0x8e(%eax),%ecx 80107e56: 83 c9 40 or $0x40,%ecx 80107e59: 88 88 8e 00 00 00 mov %cl,0x8e(%eax) 80107e5f: 8b 45 f4 mov -0xc(%ebp),%eax 80107e62: 0f b6 88 8e 00 00 00 movzbl 0x8e(%eax),%ecx 80107e69: 83 c9 80 or $0xffffff80,%ecx 80107e6c: 88 88 8e 00 00 00 mov %cl,0x8e(%eax) 80107e72: 8b 45 f4 mov -0xc(%ebp),%eax 80107e75: 88 90 8f 00 00 00 mov %dl,0x8f(%eax) lgdt(c->gdt, sizeof(c->gdt)); 80107e7b: 8b 45 f4 mov -0xc(%ebp),%eax 80107e7e: 83 c0 70 add $0x70,%eax 80107e81: c7 44 24 04 38 00 00 movl $0x38,0x4(%esp) 80107e88: 00 80107e89: 89 04 24 mov %eax,(%esp) 80107e8c: e8 37 fb ff ff call 801079c8 <lgdt> loadgs(SEG_KCPU << 3); 80107e91: c7 04 24 18 00 00 00 movl $0x18,(%esp) 80107e98: e8 6a fb ff ff call 80107a07 <loadgs> // Initialize cpu-local storage. cpu = c; 80107e9d: 8b 45 f4 mov -0xc(%ebp),%eax 80107ea0: 65 a3 00 00 00 00 mov %eax,%gs:0x0 proc = 0; 80107ea6: 65 c7 05 04 00 00 00 movl $0x0,%gs:0x4 80107ead: 00 00 00 00 } 80107eb1: 83 c4 24 add $0x24,%esp 80107eb4: 5b pop %ebx 80107eb5: 5d pop %ebp 80107eb6: c3 ret 80107eb7 <walkpgdir>: // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 80107eb7: 55 push %ebp 80107eb8: 89 e5 mov %esp,%ebp 80107eba: 83 ec 28 sub $0x28,%esp pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; 80107ebd: 8b 45 0c mov 0xc(%ebp),%eax 80107ec0: c1 e8 16 shr $0x16,%eax 80107ec3: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80107eca: 8b 45 08 mov 0x8(%ebp),%eax 80107ecd: 01 d0 add %edx,%eax 80107ecf: 89 45 f0 mov %eax,-0x10(%ebp) if(*pde & PTE_P){ 80107ed2: 8b 45 f0 mov -0x10(%ebp),%eax 80107ed5: 8b 00 mov (%eax),%eax 80107ed7: 83 e0 01 and $0x1,%eax 80107eda: 85 c0 test %eax,%eax 80107edc: 74 17 je 80107ef5 <walkpgdir+0x3e> pgtab = (pte_t*)p2v(PTE_ADDR(*pde)); 80107ede: 8b 45 f0 mov -0x10(%ebp),%eax 80107ee1: 8b 00 mov (%eax),%eax 80107ee3: 25 00 f0 ff ff and $0xfffff000,%eax 80107ee8: 89 04 24 mov %eax,(%esp) 80107eeb: e8 44 fb ff ff call 80107a34 <p2v> 80107ef0: 89 45 f4 mov %eax,-0xc(%ebp) 80107ef3: eb 4b jmp 80107f40 <walkpgdir+0x89> } else { if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) 80107ef5: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 80107ef9: 74 0e je 80107f09 <walkpgdir+0x52> 80107efb: e8 a3 ac ff ff call 80102ba3 <kalloc> 80107f00: 89 45 f4 mov %eax,-0xc(%ebp) 80107f03: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80107f07: 75 07 jne 80107f10 <walkpgdir+0x59> return 0; 80107f09: b8 00 00 00 00 mov $0x0,%eax 80107f0e: eb 47 jmp 80107f57 <walkpgdir+0xa0> // Make sure all those PTE_P bits are zero. memset(pgtab, 0, PGSIZE); 80107f10: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80107f17: 00 80107f18: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80107f1f: 00 80107f20: 8b 45 f4 mov -0xc(%ebp),%eax 80107f23: 89 04 24 mov %eax,(%esp) 80107f26: e8 eb d4 ff ff call 80105416 <memset> // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = v2p(pgtab) | PTE_P | PTE_W | PTE_U; 80107f2b: 8b 45 f4 mov -0xc(%ebp),%eax 80107f2e: 89 04 24 mov %eax,(%esp) 80107f31: e8 f1 fa ff ff call 80107a27 <v2p> 80107f36: 83 c8 07 or $0x7,%eax 80107f39: 89 c2 mov %eax,%edx 80107f3b: 8b 45 f0 mov -0x10(%ebp),%eax 80107f3e: 89 10 mov %edx,(%eax) } return &pgtab[PTX(va)]; 80107f40: 8b 45 0c mov 0xc(%ebp),%eax 80107f43: c1 e8 0c shr $0xc,%eax 80107f46: 25 ff 03 00 00 and $0x3ff,%eax 80107f4b: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80107f52: 8b 45 f4 mov -0xc(%ebp),%eax 80107f55: 01 d0 add %edx,%eax } 80107f57: c9 leave 80107f58: c3 ret 80107f59 <mappages>: // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 80107f59: 55 push %ebp 80107f5a: 89 e5 mov %esp,%ebp 80107f5c: 83 ec 28 sub $0x28,%esp char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); 80107f5f: 8b 45 0c mov 0xc(%ebp),%eax 80107f62: 25 00 f0 ff ff and $0xfffff000,%eax 80107f67: 89 45 f4 mov %eax,-0xc(%ebp) last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 80107f6a: 8b 55 0c mov 0xc(%ebp),%edx 80107f6d: 8b 45 10 mov 0x10(%ebp),%eax 80107f70: 01 d0 add %edx,%eax 80107f72: 83 e8 01 sub $0x1,%eax 80107f75: 25 00 f0 ff ff and $0xfffff000,%eax 80107f7a: 89 45 f0 mov %eax,-0x10(%ebp) for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) 80107f7d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 80107f84: 00 80107f85: 8b 45 f4 mov -0xc(%ebp),%eax 80107f88: 89 44 24 04 mov %eax,0x4(%esp) 80107f8c: 8b 45 08 mov 0x8(%ebp),%eax 80107f8f: 89 04 24 mov %eax,(%esp) 80107f92: e8 20 ff ff ff call 80107eb7 <walkpgdir> 80107f97: 89 45 ec mov %eax,-0x14(%ebp) 80107f9a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 80107f9e: 75 07 jne 80107fa7 <mappages+0x4e> return -1; 80107fa0: b8 ff ff ff ff mov $0xffffffff,%eax 80107fa5: eb 48 jmp 80107fef <mappages+0x96> if(*pte & PTE_P) 80107fa7: 8b 45 ec mov -0x14(%ebp),%eax 80107faa: 8b 00 mov (%eax),%eax 80107fac: 83 e0 01 and $0x1,%eax 80107faf: 85 c0 test %eax,%eax 80107fb1: 74 0c je 80107fbf <mappages+0x66> panic("remap"); 80107fb3: c7 04 24 60 8e 10 80 movl $0x80108e60,(%esp) 80107fba: e8 7b 85 ff ff call 8010053a <panic> *pte = pa | perm | PTE_P; 80107fbf: 8b 45 18 mov 0x18(%ebp),%eax 80107fc2: 0b 45 14 or 0x14(%ebp),%eax 80107fc5: 83 c8 01 or $0x1,%eax 80107fc8: 89 c2 mov %eax,%edx 80107fca: 8b 45 ec mov -0x14(%ebp),%eax 80107fcd: 89 10 mov %edx,(%eax) if(a == last) 80107fcf: 8b 45 f4 mov -0xc(%ebp),%eax 80107fd2: 3b 45 f0 cmp -0x10(%ebp),%eax 80107fd5: 75 08 jne 80107fdf <mappages+0x86> break; 80107fd7: 90 nop a += PGSIZE; pa += PGSIZE; } return 0; 80107fd8: b8 00 00 00 00 mov $0x0,%eax 80107fdd: eb 10 jmp 80107fef <mappages+0x96> if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; if(a == last) break; a += PGSIZE; 80107fdf: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) pa += PGSIZE; 80107fe6: 81 45 14 00 10 00 00 addl $0x1000,0x14(%ebp) } 80107fed: eb 8e jmp 80107f7d <mappages+0x24> return 0; } 80107fef: c9 leave 80107ff0: c3 ret 80107ff1 <setupkvm>: }; // Set up kernel part of a page table. pde_t* setupkvm(void) { 80107ff1: 55 push %ebp 80107ff2: 89 e5 mov %esp,%ebp 80107ff4: 53 push %ebx 80107ff5: 83 ec 34 sub $0x34,%esp pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) 80107ff8: e8 a6 ab ff ff call 80102ba3 <kalloc> 80107ffd: 89 45 f0 mov %eax,-0x10(%ebp) 80108000: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80108004: 75 0a jne 80108010 <setupkvm+0x1f> return 0; 80108006: b8 00 00 00 00 mov $0x0,%eax 8010800b: e9 98 00 00 00 jmp 801080a8 <setupkvm+0xb7> memset(pgdir, 0, PGSIZE); 80108010: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80108017: 00 80108018: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 8010801f: 00 80108020: 8b 45 f0 mov -0x10(%ebp),%eax 80108023: 89 04 24 mov %eax,(%esp) 80108026: e8 eb d3 ff ff call 80105416 <memset> if (p2v(PHYSTOP) > (void*)DEVSPACE) 8010802b: c7 04 24 00 00 00 0e movl $0xe000000,(%esp) 80108032: e8 fd f9 ff ff call 80107a34 <p2v> 80108037: 3d 00 00 00 fe cmp $0xfe000000,%eax 8010803c: 76 0c jbe 8010804a <setupkvm+0x59> panic("PHYSTOP too high"); 8010803e: c7 04 24 66 8e 10 80 movl $0x80108e66,(%esp) 80108045: e8 f0 84 ff ff call 8010053a <panic> for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 8010804a: c7 45 f4 a0 b4 10 80 movl $0x8010b4a0,-0xc(%ebp) 80108051: eb 49 jmp 8010809c <setupkvm+0xab> if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, 80108053: 8b 45 f4 mov -0xc(%ebp),%eax 80108056: 8b 48 0c mov 0xc(%eax),%ecx 80108059: 8b 45 f4 mov -0xc(%ebp),%eax 8010805c: 8b 50 04 mov 0x4(%eax),%edx 8010805f: 8b 45 f4 mov -0xc(%ebp),%eax 80108062: 8b 58 08 mov 0x8(%eax),%ebx 80108065: 8b 45 f4 mov -0xc(%ebp),%eax 80108068: 8b 40 04 mov 0x4(%eax),%eax 8010806b: 29 c3 sub %eax,%ebx 8010806d: 8b 45 f4 mov -0xc(%ebp),%eax 80108070: 8b 00 mov (%eax),%eax 80108072: 89 4c 24 10 mov %ecx,0x10(%esp) 80108076: 89 54 24 0c mov %edx,0xc(%esp) 8010807a: 89 5c 24 08 mov %ebx,0x8(%esp) 8010807e: 89 44 24 04 mov %eax,0x4(%esp) 80108082: 8b 45 f0 mov -0x10(%ebp),%eax 80108085: 89 04 24 mov %eax,(%esp) 80108088: e8 cc fe ff ff call 80107f59 <mappages> 8010808d: 85 c0 test %eax,%eax 8010808f: 79 07 jns 80108098 <setupkvm+0xa7> (uint)k->phys_start, k->perm) < 0) return 0; 80108091: b8 00 00 00 00 mov $0x0,%eax 80108096: eb 10 jmp 801080a8 <setupkvm+0xb7> if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); if (p2v(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80108098: 83 45 f4 10 addl $0x10,-0xc(%ebp) 8010809c: 81 7d f4 e0 b4 10 80 cmpl $0x8010b4e0,-0xc(%ebp) 801080a3: 72 ae jb 80108053 <setupkvm+0x62> if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, k->perm) < 0) return 0; return pgdir; 801080a5: 8b 45 f0 mov -0x10(%ebp),%eax } 801080a8: 83 c4 34 add $0x34,%esp 801080ab: 5b pop %ebx 801080ac: 5d pop %ebp 801080ad: c3 ret 801080ae <kvmalloc>: // Allocate one page table for the machine for the kernel address // space for scheduler processes. void kvmalloc(void) { 801080ae: 55 push %ebp 801080af: 89 e5 mov %esp,%ebp 801080b1: 83 ec 08 sub $0x8,%esp kpgdir = setupkvm(); 801080b4: e8 38 ff ff ff call 80107ff1 <setupkvm> 801080b9: a3 38 51 11 80 mov %eax,0x80115138 switchkvm(); 801080be: e8 02 00 00 00 call 801080c5 <switchkvm> } 801080c3: c9 leave 801080c4: c3 ret 801080c5 <switchkvm>: // Switch h/w page table register to the kernel-only page table, // for when no process is running. void switchkvm(void) { 801080c5: 55 push %ebp 801080c6: 89 e5 mov %esp,%ebp 801080c8: 83 ec 04 sub $0x4,%esp lcr3(v2p(kpgdir)); // switch to the kernel page table 801080cb: a1 38 51 11 80 mov 0x80115138,%eax 801080d0: 89 04 24 mov %eax,(%esp) 801080d3: e8 4f f9 ff ff call 80107a27 <v2p> 801080d8: 89 04 24 mov %eax,(%esp) 801080db: e8 3c f9 ff ff call 80107a1c <lcr3> } 801080e0: c9 leave 801080e1: c3 ret 801080e2 <switchuvm>: // Switch TSS and h/w page table to correspond to process p. void switchuvm(struct proc *p) { 801080e2: 55 push %ebp 801080e3: 89 e5 mov %esp,%ebp 801080e5: 53 push %ebx 801080e6: 83 ec 14 sub $0x14,%esp pushcli(); 801080e9: e8 25 d2 ff ff call 80105313 <pushcli> cpu->gdt[SEG_TSS] = SEG16(STS_T32A, &cpu->ts, sizeof(cpu->ts)-1, 0); 801080ee: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801080f4: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 801080fb: 83 c2 08 add $0x8,%edx 801080fe: 89 d3 mov %edx,%ebx 80108100: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 80108107: 83 c2 08 add $0x8,%edx 8010810a: c1 ea 10 shr $0x10,%edx 8010810d: 89 d1 mov %edx,%ecx 8010810f: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 80108116: 83 c2 08 add $0x8,%edx 80108119: c1 ea 18 shr $0x18,%edx 8010811c: 66 c7 80 a0 00 00 00 movw $0x67,0xa0(%eax) 80108123: 67 00 80108125: 66 89 98 a2 00 00 00 mov %bx,0xa2(%eax) 8010812c: 88 88 a4 00 00 00 mov %cl,0xa4(%eax) 80108132: 0f b6 88 a5 00 00 00 movzbl 0xa5(%eax),%ecx 80108139: 83 e1 f0 and $0xfffffff0,%ecx 8010813c: 83 c9 09 or $0x9,%ecx 8010813f: 88 88 a5 00 00 00 mov %cl,0xa5(%eax) 80108145: 0f b6 88 a5 00 00 00 movzbl 0xa5(%eax),%ecx 8010814c: 83 c9 10 or $0x10,%ecx 8010814f: 88 88 a5 00 00 00 mov %cl,0xa5(%eax) 80108155: 0f b6 88 a5 00 00 00 movzbl 0xa5(%eax),%ecx 8010815c: 83 e1 9f and $0xffffff9f,%ecx 8010815f: 88 88 a5 00 00 00 mov %cl,0xa5(%eax) 80108165: 0f b6 88 a5 00 00 00 movzbl 0xa5(%eax),%ecx 8010816c: 83 c9 80 or $0xffffff80,%ecx 8010816f: 88 88 a5 00 00 00 mov %cl,0xa5(%eax) 80108175: 0f b6 88 a6 00 00 00 movzbl 0xa6(%eax),%ecx 8010817c: 83 e1 f0 and $0xfffffff0,%ecx 8010817f: 88 88 a6 00 00 00 mov %cl,0xa6(%eax) 80108185: 0f b6 88 a6 00 00 00 movzbl 0xa6(%eax),%ecx 8010818c: 83 e1 ef and $0xffffffef,%ecx 8010818f: 88 88 a6 00 00 00 mov %cl,0xa6(%eax) 80108195: 0f b6 88 a6 00 00 00 movzbl 0xa6(%eax),%ecx 8010819c: 83 e1 df and $0xffffffdf,%ecx 8010819f: 88 88 a6 00 00 00 mov %cl,0xa6(%eax) 801081a5: 0f b6 88 a6 00 00 00 movzbl 0xa6(%eax),%ecx 801081ac: 83 c9 40 or $0x40,%ecx 801081af: 88 88 a6 00 00 00 mov %cl,0xa6(%eax) 801081b5: 0f b6 88 a6 00 00 00 movzbl 0xa6(%eax),%ecx 801081bc: 83 e1 7f and $0x7f,%ecx 801081bf: 88 88 a6 00 00 00 mov %cl,0xa6(%eax) 801081c5: 88 90 a7 00 00 00 mov %dl,0xa7(%eax) cpu->gdt[SEG_TSS].s = 0; 801081cb: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801081d1: 0f b6 90 a5 00 00 00 movzbl 0xa5(%eax),%edx 801081d8: 83 e2 ef and $0xffffffef,%edx 801081db: 88 90 a5 00 00 00 mov %dl,0xa5(%eax) cpu->ts.ss0 = SEG_KDATA << 3; 801081e1: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801081e7: 66 c7 40 10 10 00 movw $0x10,0x10(%eax) cpu->ts.esp0 = (uint)proc->kstack + KSTACKSIZE; 801081ed: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801081f3: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 801081fa: 8b 52 08 mov 0x8(%edx),%edx 801081fd: 81 c2 00 10 00 00 add $0x1000,%edx 80108203: 89 50 0c mov %edx,0xc(%eax) ltr(SEG_TSS << 3); 80108206: c7 04 24 30 00 00 00 movl $0x30,(%esp) 8010820d: e8 df f7 ff ff call 801079f1 <ltr> if(p->pgdir == 0) 80108212: 8b 45 08 mov 0x8(%ebp),%eax 80108215: 8b 40 04 mov 0x4(%eax),%eax 80108218: 85 c0 test %eax,%eax 8010821a: 75 0c jne 80108228 <switchuvm+0x146> panic("switchuvm: no pgdir"); 8010821c: c7 04 24 77 8e 10 80 movl $0x80108e77,(%esp) 80108223: e8 12 83 ff ff call 8010053a <panic> lcr3(v2p(p->pgdir)); // switch to new address space 80108228: 8b 45 08 mov 0x8(%ebp),%eax 8010822b: 8b 40 04 mov 0x4(%eax),%eax 8010822e: 89 04 24 mov %eax,(%esp) 80108231: e8 f1 f7 ff ff call 80107a27 <v2p> 80108236: 89 04 24 mov %eax,(%esp) 80108239: e8 de f7 ff ff call 80107a1c <lcr3> popcli(); 8010823e: e8 14 d1 ff ff call 80105357 <popcli> } 80108243: 83 c4 14 add $0x14,%esp 80108246: 5b pop %ebx 80108247: 5d pop %ebp 80108248: c3 ret 80108249 <inituvm>: // Load the initcode into address 0 of pgdir. // sz must be less than a page. void inituvm(pde_t *pgdir, char *init, uint sz) { 80108249: 55 push %ebp 8010824a: 89 e5 mov %esp,%ebp 8010824c: 83 ec 38 sub $0x38,%esp char *mem; if(sz >= PGSIZE) 8010824f: 81 7d 10 ff 0f 00 00 cmpl $0xfff,0x10(%ebp) 80108256: 76 0c jbe 80108264 <inituvm+0x1b> panic("inituvm: more than a page"); 80108258: c7 04 24 8b 8e 10 80 movl $0x80108e8b,(%esp) 8010825f: e8 d6 82 ff ff call 8010053a <panic> mem = kalloc(); 80108264: e8 3a a9 ff ff call 80102ba3 <kalloc> 80108269: 89 45 f4 mov %eax,-0xc(%ebp) memset(mem, 0, PGSIZE); 8010826c: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80108273: 00 80108274: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 8010827b: 00 8010827c: 8b 45 f4 mov -0xc(%ebp),%eax 8010827f: 89 04 24 mov %eax,(%esp) 80108282: e8 8f d1 ff ff call 80105416 <memset> mappages(pgdir, 0, PGSIZE, v2p(mem), PTE_W|PTE_U); 80108287: 8b 45 f4 mov -0xc(%ebp),%eax 8010828a: 89 04 24 mov %eax,(%esp) 8010828d: e8 95 f7 ff ff call 80107a27 <v2p> 80108292: c7 44 24 10 06 00 00 movl $0x6,0x10(%esp) 80108299: 00 8010829a: 89 44 24 0c mov %eax,0xc(%esp) 8010829e: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 801082a5: 00 801082a6: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801082ad: 00 801082ae: 8b 45 08 mov 0x8(%ebp),%eax 801082b1: 89 04 24 mov %eax,(%esp) 801082b4: e8 a0 fc ff ff call 80107f59 <mappages> memmove(mem, init, sz); 801082b9: 8b 45 10 mov 0x10(%ebp),%eax 801082bc: 89 44 24 08 mov %eax,0x8(%esp) 801082c0: 8b 45 0c mov 0xc(%ebp),%eax 801082c3: 89 44 24 04 mov %eax,0x4(%esp) 801082c7: 8b 45 f4 mov -0xc(%ebp),%eax 801082ca: 89 04 24 mov %eax,(%esp) 801082cd: e8 13 d2 ff ff call 801054e5 <memmove> } 801082d2: c9 leave 801082d3: c3 ret 801082d4 <loaduvm>: // Load a program segment into pgdir. addr must be page-aligned // and the pages from addr to addr+sz must already be mapped. int loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz) { 801082d4: 55 push %ebp 801082d5: 89 e5 mov %esp,%ebp 801082d7: 53 push %ebx 801082d8: 83 ec 24 sub $0x24,%esp uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) 801082db: 8b 45 0c mov 0xc(%ebp),%eax 801082de: 25 ff 0f 00 00 and $0xfff,%eax 801082e3: 85 c0 test %eax,%eax 801082e5: 74 0c je 801082f3 <loaduvm+0x1f> panic("loaduvm: addr must be page aligned"); 801082e7: c7 04 24 a8 8e 10 80 movl $0x80108ea8,(%esp) 801082ee: e8 47 82 ff ff call 8010053a <panic> for(i = 0; i < sz; i += PGSIZE){ 801082f3: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 801082fa: e9 a9 00 00 00 jmp 801083a8 <loaduvm+0xd4> if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) 801082ff: 8b 45 f4 mov -0xc(%ebp),%eax 80108302: 8b 55 0c mov 0xc(%ebp),%edx 80108305: 01 d0 add %edx,%eax 80108307: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 8010830e: 00 8010830f: 89 44 24 04 mov %eax,0x4(%esp) 80108313: 8b 45 08 mov 0x8(%ebp),%eax 80108316: 89 04 24 mov %eax,(%esp) 80108319: e8 99 fb ff ff call 80107eb7 <walkpgdir> 8010831e: 89 45 ec mov %eax,-0x14(%ebp) 80108321: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 80108325: 75 0c jne 80108333 <loaduvm+0x5f> panic("loaduvm: address should exist"); 80108327: c7 04 24 cb 8e 10 80 movl $0x80108ecb,(%esp) 8010832e: e8 07 82 ff ff call 8010053a <panic> pa = PTE_ADDR(*pte); 80108333: 8b 45 ec mov -0x14(%ebp),%eax 80108336: 8b 00 mov (%eax),%eax 80108338: 25 00 f0 ff ff and $0xfffff000,%eax 8010833d: 89 45 e8 mov %eax,-0x18(%ebp) if(sz - i < PGSIZE) 80108340: 8b 45 f4 mov -0xc(%ebp),%eax 80108343: 8b 55 18 mov 0x18(%ebp),%edx 80108346: 29 c2 sub %eax,%edx 80108348: 89 d0 mov %edx,%eax 8010834a: 3d ff 0f 00 00 cmp $0xfff,%eax 8010834f: 77 0f ja 80108360 <loaduvm+0x8c> n = sz - i; 80108351: 8b 45 f4 mov -0xc(%ebp),%eax 80108354: 8b 55 18 mov 0x18(%ebp),%edx 80108357: 29 c2 sub %eax,%edx 80108359: 89 d0 mov %edx,%eax 8010835b: 89 45 f0 mov %eax,-0x10(%ebp) 8010835e: eb 07 jmp 80108367 <loaduvm+0x93> else n = PGSIZE; 80108360: c7 45 f0 00 10 00 00 movl $0x1000,-0x10(%ebp) if(readi(ip, p2v(pa), offset+i, n) != n) 80108367: 8b 45 f4 mov -0xc(%ebp),%eax 8010836a: 8b 55 14 mov 0x14(%ebp),%edx 8010836d: 8d 1c 02 lea (%edx,%eax,1),%ebx 80108370: 8b 45 e8 mov -0x18(%ebp),%eax 80108373: 89 04 24 mov %eax,(%esp) 80108376: e8 b9 f6 ff ff call 80107a34 <p2v> 8010837b: 8b 55 f0 mov -0x10(%ebp),%edx 8010837e: 89 54 24 0c mov %edx,0xc(%esp) 80108382: 89 5c 24 08 mov %ebx,0x8(%esp) 80108386: 89 44 24 04 mov %eax,0x4(%esp) 8010838a: 8b 45 10 mov 0x10(%ebp),%eax 8010838d: 89 04 24 mov %eax,(%esp) 80108390: e8 56 9a ff ff call 80101deb <readi> 80108395: 3b 45 f0 cmp -0x10(%ebp),%eax 80108398: 74 07 je 801083a1 <loaduvm+0xcd> return -1; 8010839a: b8 ff ff ff ff mov $0xffffffff,%eax 8010839f: eb 18 jmp 801083b9 <loaduvm+0xe5> uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ 801083a1: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) 801083a8: 8b 45 f4 mov -0xc(%ebp),%eax 801083ab: 3b 45 18 cmp 0x18(%ebp),%eax 801083ae: 0f 82 4b ff ff ff jb 801082ff <loaduvm+0x2b> else n = PGSIZE; if(readi(ip, p2v(pa), offset+i, n) != n) return -1; } return 0; 801083b4: b8 00 00 00 00 mov $0x0,%eax } 801083b9: 83 c4 24 add $0x24,%esp 801083bc: 5b pop %ebx 801083bd: 5d pop %ebp 801083be: c3 ret 801083bf <allocuvm>: // Allocate page tables and physical memory to grow process from oldsz to // newsz, which need not be page aligned. Returns new size or 0 on error. int allocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 801083bf: 55 push %ebp 801083c0: 89 e5 mov %esp,%ebp 801083c2: 83 ec 38 sub $0x38,%esp char *mem; uint a; if(newsz >= KERNBASE) 801083c5: 8b 45 10 mov 0x10(%ebp),%eax 801083c8: 85 c0 test %eax,%eax 801083ca: 79 0a jns 801083d6 <allocuvm+0x17> return 0; 801083cc: b8 00 00 00 00 mov $0x0,%eax 801083d1: e9 c1 00 00 00 jmp 80108497 <allocuvm+0xd8> if(newsz < oldsz) 801083d6: 8b 45 10 mov 0x10(%ebp),%eax 801083d9: 3b 45 0c cmp 0xc(%ebp),%eax 801083dc: 73 08 jae 801083e6 <allocuvm+0x27> return oldsz; 801083de: 8b 45 0c mov 0xc(%ebp),%eax 801083e1: e9 b1 00 00 00 jmp 80108497 <allocuvm+0xd8> a = PGROUNDUP(oldsz); 801083e6: 8b 45 0c mov 0xc(%ebp),%eax 801083e9: 05 ff 0f 00 00 add $0xfff,%eax 801083ee: 25 00 f0 ff ff and $0xfffff000,%eax 801083f3: 89 45 f4 mov %eax,-0xc(%ebp) for(; a < newsz; a += PGSIZE){ 801083f6: e9 8d 00 00 00 jmp 80108488 <allocuvm+0xc9> mem = kalloc(); 801083fb: e8 a3 a7 ff ff call 80102ba3 <kalloc> 80108400: 89 45 f0 mov %eax,-0x10(%ebp) if(mem == 0){ 80108403: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80108407: 75 2c jne 80108435 <allocuvm+0x76> cprintf("allocuvm out of memory\n"); 80108409: c7 04 24 e9 8e 10 80 movl $0x80108ee9,(%esp) 80108410: e8 8b 7f ff ff call 801003a0 <cprintf> deallocuvm(pgdir, newsz, oldsz); 80108415: 8b 45 0c mov 0xc(%ebp),%eax 80108418: 89 44 24 08 mov %eax,0x8(%esp) 8010841c: 8b 45 10 mov 0x10(%ebp),%eax 8010841f: 89 44 24 04 mov %eax,0x4(%esp) 80108423: 8b 45 08 mov 0x8(%ebp),%eax 80108426: 89 04 24 mov %eax,(%esp) 80108429: e8 6b 00 00 00 call 80108499 <deallocuvm> return 0; 8010842e: b8 00 00 00 00 mov $0x0,%eax 80108433: eb 62 jmp 80108497 <allocuvm+0xd8> } memset(mem, 0, PGSIZE); 80108435: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 8010843c: 00 8010843d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80108444: 00 80108445: 8b 45 f0 mov -0x10(%ebp),%eax 80108448: 89 04 24 mov %eax,(%esp) 8010844b: e8 c6 cf ff ff call 80105416 <memset> mappages(pgdir, (char*)a, PGSIZE, v2p(mem), PTE_W|PTE_U); 80108450: 8b 45 f0 mov -0x10(%ebp),%eax 80108453: 89 04 24 mov %eax,(%esp) 80108456: e8 cc f5 ff ff call 80107a27 <v2p> 8010845b: 8b 55 f4 mov -0xc(%ebp),%edx 8010845e: c7 44 24 10 06 00 00 movl $0x6,0x10(%esp) 80108465: 00 80108466: 89 44 24 0c mov %eax,0xc(%esp) 8010846a: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80108471: 00 80108472: 89 54 24 04 mov %edx,0x4(%esp) 80108476: 8b 45 08 mov 0x8(%ebp),%eax 80108479: 89 04 24 mov %eax,(%esp) 8010847c: e8 d8 fa ff ff call 80107f59 <mappages> return 0; if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ 80108481: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) 80108488: 8b 45 f4 mov -0xc(%ebp),%eax 8010848b: 3b 45 10 cmp 0x10(%ebp),%eax 8010848e: 0f 82 67 ff ff ff jb 801083fb <allocuvm+0x3c> return 0; } memset(mem, 0, PGSIZE); mappages(pgdir, (char*)a, PGSIZE, v2p(mem), PTE_W|PTE_U); } return newsz; 80108494: 8b 45 10 mov 0x10(%ebp),%eax } 80108497: c9 leave 80108498: c3 ret 80108499 <deallocuvm>: // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 80108499: 55 push %ebp 8010849a: 89 e5 mov %esp,%ebp 8010849c: 83 ec 28 sub $0x28,%esp pte_t *pte; uint a, pa; if(newsz >= oldsz) 8010849f: 8b 45 10 mov 0x10(%ebp),%eax 801084a2: 3b 45 0c cmp 0xc(%ebp),%eax 801084a5: 72 08 jb 801084af <deallocuvm+0x16> return oldsz; 801084a7: 8b 45 0c mov 0xc(%ebp),%eax 801084aa: e9 a4 00 00 00 jmp 80108553 <deallocuvm+0xba> a = PGROUNDUP(newsz); 801084af: 8b 45 10 mov 0x10(%ebp),%eax 801084b2: 05 ff 0f 00 00 add $0xfff,%eax 801084b7: 25 00 f0 ff ff and $0xfffff000,%eax 801084bc: 89 45 f4 mov %eax,-0xc(%ebp) for(; a < oldsz; a += PGSIZE){ 801084bf: e9 80 00 00 00 jmp 80108544 <deallocuvm+0xab> pte = walkpgdir(pgdir, (char*)a, 0); 801084c4: 8b 45 f4 mov -0xc(%ebp),%eax 801084c7: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 801084ce: 00 801084cf: 89 44 24 04 mov %eax,0x4(%esp) 801084d3: 8b 45 08 mov 0x8(%ebp),%eax 801084d6: 89 04 24 mov %eax,(%esp) 801084d9: e8 d9 f9 ff ff call 80107eb7 <walkpgdir> 801084de: 89 45 f0 mov %eax,-0x10(%ebp) if(!pte) 801084e1: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 801084e5: 75 09 jne 801084f0 <deallocuvm+0x57> a += (NPTENTRIES - 1) * PGSIZE; 801084e7: 81 45 f4 00 f0 3f 00 addl $0x3ff000,-0xc(%ebp) 801084ee: eb 4d jmp 8010853d <deallocuvm+0xa4> else if((*pte & PTE_P) != 0){ 801084f0: 8b 45 f0 mov -0x10(%ebp),%eax 801084f3: 8b 00 mov (%eax),%eax 801084f5: 83 e0 01 and $0x1,%eax 801084f8: 85 c0 test %eax,%eax 801084fa: 74 41 je 8010853d <deallocuvm+0xa4> pa = PTE_ADDR(*pte); 801084fc: 8b 45 f0 mov -0x10(%ebp),%eax 801084ff: 8b 00 mov (%eax),%eax 80108501: 25 00 f0 ff ff and $0xfffff000,%eax 80108506: 89 45 ec mov %eax,-0x14(%ebp) if(pa == 0) 80108509: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 8010850d: 75 0c jne 8010851b <deallocuvm+0x82> panic("kfree"); 8010850f: c7 04 24 01 8f 10 80 movl $0x80108f01,(%esp) 80108516: e8 1f 80 ff ff call 8010053a <panic> char *v = p2v(pa); 8010851b: 8b 45 ec mov -0x14(%ebp),%eax 8010851e: 89 04 24 mov %eax,(%esp) 80108521: e8 0e f5 ff ff call 80107a34 <p2v> 80108526: 89 45 e8 mov %eax,-0x18(%ebp) kfree(v); 80108529: 8b 45 e8 mov -0x18(%ebp),%eax 8010852c: 89 04 24 mov %eax,(%esp) 8010852f: e8 d6 a5 ff ff call 80102b0a <kfree> *pte = 0; 80108534: 8b 45 f0 mov -0x10(%ebp),%eax 80108537: c7 00 00 00 00 00 movl $0x0,(%eax) if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 8010853d: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) 80108544: 8b 45 f4 mov -0xc(%ebp),%eax 80108547: 3b 45 0c cmp 0xc(%ebp),%eax 8010854a: 0f 82 74 ff ff ff jb 801084c4 <deallocuvm+0x2b> char *v = p2v(pa); kfree(v); *pte = 0; } } return newsz; 80108550: 8b 45 10 mov 0x10(%ebp),%eax } 80108553: c9 leave 80108554: c3 ret 80108555 <freevm>: // Free a page table and all the physical memory pages // in the user part. void freevm(pde_t *pgdir) { 80108555: 55 push %ebp 80108556: 89 e5 mov %esp,%ebp 80108558: 83 ec 28 sub $0x28,%esp uint i; if(pgdir == 0) 8010855b: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 8010855f: 75 0c jne 8010856d <freevm+0x18> panic("freevm: no pgdir"); 80108561: c7 04 24 07 8f 10 80 movl $0x80108f07,(%esp) 80108568: e8 cd 7f ff ff call 8010053a <panic> deallocuvm(pgdir, KERNBASE, 0); 8010856d: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80108574: 00 80108575: c7 44 24 04 00 00 00 movl $0x80000000,0x4(%esp) 8010857c: 80 8010857d: 8b 45 08 mov 0x8(%ebp),%eax 80108580: 89 04 24 mov %eax,(%esp) 80108583: e8 11 ff ff ff call 80108499 <deallocuvm> for(i = 0; i < NPDENTRIES; i++){ 80108588: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 8010858f: eb 48 jmp 801085d9 <freevm+0x84> if(pgdir[i] & PTE_P){ 80108591: 8b 45 f4 mov -0xc(%ebp),%eax 80108594: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 8010859b: 8b 45 08 mov 0x8(%ebp),%eax 8010859e: 01 d0 add %edx,%eax 801085a0: 8b 00 mov (%eax),%eax 801085a2: 83 e0 01 and $0x1,%eax 801085a5: 85 c0 test %eax,%eax 801085a7: 74 2c je 801085d5 <freevm+0x80> char * v = p2v(PTE_ADDR(pgdir[i])); 801085a9: 8b 45 f4 mov -0xc(%ebp),%eax 801085ac: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 801085b3: 8b 45 08 mov 0x8(%ebp),%eax 801085b6: 01 d0 add %edx,%eax 801085b8: 8b 00 mov (%eax),%eax 801085ba: 25 00 f0 ff ff and $0xfffff000,%eax 801085bf: 89 04 24 mov %eax,(%esp) 801085c2: e8 6d f4 ff ff call 80107a34 <p2v> 801085c7: 89 45 f0 mov %eax,-0x10(%ebp) kfree(v); 801085ca: 8b 45 f0 mov -0x10(%ebp),%eax 801085cd: 89 04 24 mov %eax,(%esp) 801085d0: e8 35 a5 ff ff call 80102b0a <kfree> uint i; if(pgdir == 0) panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 801085d5: 83 45 f4 01 addl $0x1,-0xc(%ebp) 801085d9: 81 7d f4 ff 03 00 00 cmpl $0x3ff,-0xc(%ebp) 801085e0: 76 af jbe 80108591 <freevm+0x3c> if(pgdir[i] & PTE_P){ char * v = p2v(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 801085e2: 8b 45 08 mov 0x8(%ebp),%eax 801085e5: 89 04 24 mov %eax,(%esp) 801085e8: e8 1d a5 ff ff call 80102b0a <kfree> } 801085ed: c9 leave 801085ee: c3 ret 801085ef <clearpteu>: // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 801085ef: 55 push %ebp 801085f0: 89 e5 mov %esp,%ebp 801085f2: 83 ec 28 sub $0x28,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 801085f5: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 801085fc: 00 801085fd: 8b 45 0c mov 0xc(%ebp),%eax 80108600: 89 44 24 04 mov %eax,0x4(%esp) 80108604: 8b 45 08 mov 0x8(%ebp),%eax 80108607: 89 04 24 mov %eax,(%esp) 8010860a: e8 a8 f8 ff ff call 80107eb7 <walkpgdir> 8010860f: 89 45 f4 mov %eax,-0xc(%ebp) if(pte == 0) 80108612: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 80108616: 75 0c jne 80108624 <clearpteu+0x35> panic("clearpteu"); 80108618: c7 04 24 18 8f 10 80 movl $0x80108f18,(%esp) 8010861f: e8 16 7f ff ff call 8010053a <panic> *pte &= ~PTE_U; 80108624: 8b 45 f4 mov -0xc(%ebp),%eax 80108627: 8b 00 mov (%eax),%eax 80108629: 83 e0 fb and $0xfffffffb,%eax 8010862c: 89 c2 mov %eax,%edx 8010862e: 8b 45 f4 mov -0xc(%ebp),%eax 80108631: 89 10 mov %edx,(%eax) } 80108633: c9 leave 80108634: c3 ret 80108635 <copyuvm>: // Given a parent process's page table, create a copy // of it for a child. pde_t* copyuvm(pde_t *pgdir, uint sz) { 80108635: 55 push %ebp 80108636: 89 e5 mov %esp,%ebp 80108638: 53 push %ebx 80108639: 83 ec 44 sub $0x44,%esp pde_t *d; pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) 8010863c: e8 b0 f9 ff ff call 80107ff1 <setupkvm> 80108641: 89 45 f0 mov %eax,-0x10(%ebp) 80108644: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 80108648: 75 0a jne 80108654 <copyuvm+0x1f> return 0; 8010864a: b8 00 00 00 00 mov $0x0,%eax 8010864f: e9 fd 00 00 00 jmp 80108751 <copyuvm+0x11c> for(i = 0; i < sz; i += PGSIZE){ 80108654: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 8010865b: e9 d0 00 00 00 jmp 80108730 <copyuvm+0xfb> if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) 80108660: 8b 45 f4 mov -0xc(%ebp),%eax 80108663: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 8010866a: 00 8010866b: 89 44 24 04 mov %eax,0x4(%esp) 8010866f: 8b 45 08 mov 0x8(%ebp),%eax 80108672: 89 04 24 mov %eax,(%esp) 80108675: e8 3d f8 ff ff call 80107eb7 <walkpgdir> 8010867a: 89 45 ec mov %eax,-0x14(%ebp) 8010867d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 80108681: 75 0c jne 8010868f <copyuvm+0x5a> panic("copyuvm: pte should exist"); 80108683: c7 04 24 22 8f 10 80 movl $0x80108f22,(%esp) 8010868a: e8 ab 7e ff ff call 8010053a <panic> if(!(*pte & PTE_P)) 8010868f: 8b 45 ec mov -0x14(%ebp),%eax 80108692: 8b 00 mov (%eax),%eax 80108694: 83 e0 01 and $0x1,%eax 80108697: 85 c0 test %eax,%eax 80108699: 75 0c jne 801086a7 <copyuvm+0x72> panic("copyuvm: page not present"); 8010869b: c7 04 24 3c 8f 10 80 movl $0x80108f3c,(%esp) 801086a2: e8 93 7e ff ff call 8010053a <panic> pa = PTE_ADDR(*pte); 801086a7: 8b 45 ec mov -0x14(%ebp),%eax 801086aa: 8b 00 mov (%eax),%eax 801086ac: 25 00 f0 ff ff and $0xfffff000,%eax 801086b1: 89 45 e8 mov %eax,-0x18(%ebp) flags = PTE_FLAGS(*pte); 801086b4: 8b 45 ec mov -0x14(%ebp),%eax 801086b7: 8b 00 mov (%eax),%eax 801086b9: 25 ff 0f 00 00 and $0xfff,%eax 801086be: 89 45 e4 mov %eax,-0x1c(%ebp) if((mem = kalloc()) == 0) 801086c1: e8 dd a4 ff ff call 80102ba3 <kalloc> 801086c6: 89 45 e0 mov %eax,-0x20(%ebp) 801086c9: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 801086cd: 75 02 jne 801086d1 <copyuvm+0x9c> goto bad; 801086cf: eb 70 jmp 80108741 <copyuvm+0x10c> memmove(mem, (char*)p2v(pa), PGSIZE); 801086d1: 8b 45 e8 mov -0x18(%ebp),%eax 801086d4: 89 04 24 mov %eax,(%esp) 801086d7: e8 58 f3 ff ff call 80107a34 <p2v> 801086dc: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 801086e3: 00 801086e4: 89 44 24 04 mov %eax,0x4(%esp) 801086e8: 8b 45 e0 mov -0x20(%ebp),%eax 801086eb: 89 04 24 mov %eax,(%esp) 801086ee: e8 f2 cd ff ff call 801054e5 <memmove> if(mappages(d, (void*)i, PGSIZE, v2p(mem), flags) < 0) 801086f3: 8b 5d e4 mov -0x1c(%ebp),%ebx 801086f6: 8b 45 e0 mov -0x20(%ebp),%eax 801086f9: 89 04 24 mov %eax,(%esp) 801086fc: e8 26 f3 ff ff call 80107a27 <v2p> 80108701: 8b 55 f4 mov -0xc(%ebp),%edx 80108704: 89 5c 24 10 mov %ebx,0x10(%esp) 80108708: 89 44 24 0c mov %eax,0xc(%esp) 8010870c: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80108713: 00 80108714: 89 54 24 04 mov %edx,0x4(%esp) 80108718: 8b 45 f0 mov -0x10(%ebp),%eax 8010871b: 89 04 24 mov %eax,(%esp) 8010871e: e8 36 f8 ff ff call 80107f59 <mappages> 80108723: 85 c0 test %eax,%eax 80108725: 79 02 jns 80108729 <copyuvm+0xf4> goto bad; 80108727: eb 18 jmp 80108741 <copyuvm+0x10c> uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ 80108729: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) 80108730: 8b 45 f4 mov -0xc(%ebp),%eax 80108733: 3b 45 0c cmp 0xc(%ebp),%eax 80108736: 0f 82 24 ff ff ff jb 80108660 <copyuvm+0x2b> goto bad; memmove(mem, (char*)p2v(pa), PGSIZE); if(mappages(d, (void*)i, PGSIZE, v2p(mem), flags) < 0) goto bad; } return d; 8010873c: 8b 45 f0 mov -0x10(%ebp),%eax 8010873f: eb 10 jmp 80108751 <copyuvm+0x11c> bad: freevm(d); 80108741: 8b 45 f0 mov -0x10(%ebp),%eax 80108744: 89 04 24 mov %eax,(%esp) 80108747: e8 09 fe ff ff call 80108555 <freevm> return 0; 8010874c: b8 00 00 00 00 mov $0x0,%eax } 80108751: 83 c4 44 add $0x44,%esp 80108754: 5b pop %ebx 80108755: 5d pop %ebp 80108756: c3 ret 80108757 <uva2ka>: //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80108757: 55 push %ebp 80108758: 89 e5 mov %esp,%ebp 8010875a: 83 ec 28 sub $0x28,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 8010875d: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80108764: 00 80108765: 8b 45 0c mov 0xc(%ebp),%eax 80108768: 89 44 24 04 mov %eax,0x4(%esp) 8010876c: 8b 45 08 mov 0x8(%ebp),%eax 8010876f: 89 04 24 mov %eax,(%esp) 80108772: e8 40 f7 ff ff call 80107eb7 <walkpgdir> 80108777: 89 45 f4 mov %eax,-0xc(%ebp) if((*pte & PTE_P) == 0) 8010877a: 8b 45 f4 mov -0xc(%ebp),%eax 8010877d: 8b 00 mov (%eax),%eax 8010877f: 83 e0 01 and $0x1,%eax 80108782: 85 c0 test %eax,%eax 80108784: 75 07 jne 8010878d <uva2ka+0x36> return 0; 80108786: b8 00 00 00 00 mov $0x0,%eax 8010878b: eb 25 jmp 801087b2 <uva2ka+0x5b> if((*pte & PTE_U) == 0) 8010878d: 8b 45 f4 mov -0xc(%ebp),%eax 80108790: 8b 00 mov (%eax),%eax 80108792: 83 e0 04 and $0x4,%eax 80108795: 85 c0 test %eax,%eax 80108797: 75 07 jne 801087a0 <uva2ka+0x49> return 0; 80108799: b8 00 00 00 00 mov $0x0,%eax 8010879e: eb 12 jmp 801087b2 <uva2ka+0x5b> return (char*)p2v(PTE_ADDR(*pte)); 801087a0: 8b 45 f4 mov -0xc(%ebp),%eax 801087a3: 8b 00 mov (%eax),%eax 801087a5: 25 00 f0 ff ff and $0xfffff000,%eax 801087aa: 89 04 24 mov %eax,(%esp) 801087ad: e8 82 f2 ff ff call 80107a34 <p2v> } 801087b2: c9 leave 801087b3: c3 ret 801087b4 <copyout>: // Copy len bytes from p to user address va in page table pgdir. // Most useful when pgdir is not the current page table. // uva2ka ensures this only works for PTE_U pages. int copyout(pde_t *pgdir, uint va, void *p, uint len) { 801087b4: 55 push %ebp 801087b5: 89 e5 mov %esp,%ebp 801087b7: 83 ec 28 sub $0x28,%esp char *buf, *pa0; uint n, va0; buf = (char*)p; 801087ba: 8b 45 10 mov 0x10(%ebp),%eax 801087bd: 89 45 f4 mov %eax,-0xc(%ebp) while(len > 0){ 801087c0: e9 87 00 00 00 jmp 8010884c <copyout+0x98> va0 = (uint)PGROUNDDOWN(va); 801087c5: 8b 45 0c mov 0xc(%ebp),%eax 801087c8: 25 00 f0 ff ff and $0xfffff000,%eax 801087cd: 89 45 ec mov %eax,-0x14(%ebp) pa0 = uva2ka(pgdir, (char*)va0); 801087d0: 8b 45 ec mov -0x14(%ebp),%eax 801087d3: 89 44 24 04 mov %eax,0x4(%esp) 801087d7: 8b 45 08 mov 0x8(%ebp),%eax 801087da: 89 04 24 mov %eax,(%esp) 801087dd: e8 75 ff ff ff call 80108757 <uva2ka> 801087e2: 89 45 e8 mov %eax,-0x18(%ebp) if(pa0 == 0) 801087e5: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 801087e9: 75 07 jne 801087f2 <copyout+0x3e> return -1; 801087eb: b8 ff ff ff ff mov $0xffffffff,%eax 801087f0: eb 69 jmp 8010885b <copyout+0xa7> n = PGSIZE - (va - va0); 801087f2: 8b 45 0c mov 0xc(%ebp),%eax 801087f5: 8b 55 ec mov -0x14(%ebp),%edx 801087f8: 29 c2 sub %eax,%edx 801087fa: 89 d0 mov %edx,%eax 801087fc: 05 00 10 00 00 add $0x1000,%eax 80108801: 89 45 f0 mov %eax,-0x10(%ebp) if(n > len) 80108804: 8b 45 f0 mov -0x10(%ebp),%eax 80108807: 3b 45 14 cmp 0x14(%ebp),%eax 8010880a: 76 06 jbe 80108812 <copyout+0x5e> n = len; 8010880c: 8b 45 14 mov 0x14(%ebp),%eax 8010880f: 89 45 f0 mov %eax,-0x10(%ebp) memmove(pa0 + (va - va0), buf, n); 80108812: 8b 45 ec mov -0x14(%ebp),%eax 80108815: 8b 55 0c mov 0xc(%ebp),%edx 80108818: 29 c2 sub %eax,%edx 8010881a: 8b 45 e8 mov -0x18(%ebp),%eax 8010881d: 01 c2 add %eax,%edx 8010881f: 8b 45 f0 mov -0x10(%ebp),%eax 80108822: 89 44 24 08 mov %eax,0x8(%esp) 80108826: 8b 45 f4 mov -0xc(%ebp),%eax 80108829: 89 44 24 04 mov %eax,0x4(%esp) 8010882d: 89 14 24 mov %edx,(%esp) 80108830: e8 b0 cc ff ff call 801054e5 <memmove> len -= n; 80108835: 8b 45 f0 mov -0x10(%ebp),%eax 80108838: 29 45 14 sub %eax,0x14(%ebp) buf += n; 8010883b: 8b 45 f0 mov -0x10(%ebp),%eax 8010883e: 01 45 f4 add %eax,-0xc(%ebp) va = va0 + PGSIZE; 80108841: 8b 45 ec mov -0x14(%ebp),%eax 80108844: 05 00 10 00 00 add $0x1000,%eax 80108849: 89 45 0c mov %eax,0xc(%ebp) { char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 8010884c: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 80108850: 0f 85 6f ff ff ff jne 801087c5 <copyout+0x11> memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; va = va0 + PGSIZE; } return 0; 80108856: b8 00 00 00 00 mov $0x0,%eax } 8010885b: c9 leave 8010885c: c3 ret
; A274047: Diameter of Generalized Petersen Graph G(n, 2). ; 2,4,3,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28 lpb $0 mov $2,$0 mov $0,2 add $2,4 lpe add $1,1 sub $2,$0 trn $2,2 add $2,2 lpb $2 add $1,1 trn $2,$0 mov $0,4 lpe add $1,1 mov $0,$1
; ; This file is automatically generated ; ; Do not edit!!! ; ; djm 12/2/2000 ; ; ZSock Lib function: device_online PUBLIC deviceonline EXTERN no_zsock INCLUDE "packages.def" INCLUDE "zsock.def" .deviceonline call_pkg(tcp_online) ret nc ; We failed..are we installed? cp rc_pnf scf ;signal error ret nz ;Internal error call_pkg(tcp_ayt) jr nc,deviceonline jp no_zsock
; 殆どの機能を削った CRT0 ; ; - スタックを設定して main() にジャンプするだけ ; - main() は引数無し, リターンしない(すると暴走する) ; - bss セクションのクリアをしないので, 静的変数は各自初期化してください ; ; @author Snail Barbarian Macho (NWK) ; @date 2012.06.23 defc crt0 = 1 INCLUDE "zcc_opt.def" EXTERN _main ; main() のシンボル PUBLIC l_dcal ; 関数ポインタの飛び先 PUBLIC _funcPtr ; ↑と同じ(Cから使う) IF !DEFINED_CRT_ORG_CODE defc CRT_ORG_CODE = $2000 ENDIF org CRT_ORG_CODE ; -------- コード開始 start: di call crt0_init_bss ; -------- サウンドのため, 8255 の初期化 ; (e008) = 0x00 ※音を鳴らすなら 0x01 ; (e007) = チャンネル0 下位バイト→上位バイトR/W モード3 ld hl, $e008 xor a ld (hl), a dec l ld (hl), $36 ; -------- モニタ ROM, VRAM を切り離して オール RAM 構成にします ld c, $e0 out (c), a ; モニタ ROM を RAM に. 値は何でもいい inc c out (c), a ; VRAM を RAM に. 値は何でもいい ; -------- スタックを設定してジャンプ(no return) ld sp, $0000 jp _main ; -------- 関数ポインタの飛び先 _funcPtr: l_dcal: jp (hl) ; -------- これが無いと DATA 領域が空っぽ INCLUDE "crt/classic/crt_section.asm"
// Create a n x m rectangle by manipulating the screen register // PSEUDO CODE: // addr = SCREEN // n = RAM[0] // i = 0 // LOOP: // if i > n goto END // RAM[addr] = -1 (set pixels to black) // addr = addr + 31 // i = i + 1 // goto LOOP // END: // goto END @SCREEN D=A @addr M=D // addr = 16384 register @R0 D=M @n M=D // n = RAM[0] @i M=0 (LOOP) @i D=M @n D=D-M @END D;JGT // if i > n goto END @addr A=M M=-1 // sets RAM[addr] = 1111111111111111 @i M=M+1 // i = i + 1 @32 D=A @addr M=D+M // addr = addr + 32 @LOOP 0;JMP (END) @END 0;JMP
.text main: li $t0, 0x1234abcd li $t1, 12 # Should be 0x4abcd123 rolv $a0, $t0, $t1 li $v0, 34 syscall li $a0, ' ' li $v0, 11 syscall # Should be 0xbcd1234a rorv $a0, $t0, $t1 li $v0, 34 syscall
; A045991: a(n) = n^3 - n^2. ; 0,0,4,18,48,100,180,294,448,648,900,1210,1584,2028,2548,3150,3840,4624,5508,6498,7600,8820,10164,11638,13248,15000,16900,18954,21168,23548,26100,28830,31744,34848,38148,41650,45360,49284,53428,57798,62400,67240,72324,77658,83248,89100,95220,101614,108288,115248,122500,130050,137904,146068,154548,163350,172480,181944,191748,201898,212400,223260,234484,246078,258048,270400,283140,296274,309808,323748,338100,352870,368064,383688,399748,416250,433200,450604,468468,486798,505600,524880,544644,564898,585648,606900,628660,650934,673728,697048,720900,745290,770224,795708,821748,848350,875520,903264,931588,960498,990000,1020100,1050804,1082118,1114048,1146600,1179780,1213594,1248048,1283148,1318900,1355310,1392384,1430128,1468548,1507650,1547440,1587924,1629108,1670998,1713600,1756920,1800964,1845738,1891248,1937500,1984500,2032254,2080768,2130048,2180100,2230930,2282544,2334948,2388148,2442150,2496960,2552584,2609028,2666298,2724400,2783340,2843124,2903758,2965248,3027600,3090820,3154914,3219888,3285748,3352500,3420150,3488704,3558168,3628548,3699850,3772080,3845244,3919348,3994398,4070400,4147360,4225284,4304178,4384048,4464900,4546740,4629574,4713408,4798248,4884100,4970970,5058864,5147788,5237748,5328750,5420800,5513904,5608068,5703298,5799600,5896980,5995444,6094998,6195648,6297400,6400260,6504234,6609328,6715548,6822900,6931390,7041024,7151808,7263748,7376850,7491120,7606564,7723188,7840998,7960000,8080200,8201604,8324218,8448048,8573100,8699380,8826894,8955648,9085648,9216900,9349410,9483184,9618228,9754548,9892150,10031040,10171224,10312708,10455498,10599600,10745020,10891764,11039838,11189248,11340000,11492100,11645554,11800368,11956548,12114100,12273030,12433344,12595048,12758148,12922650,13088560,13255884,13424628,13594798,13766400,13939440,14113924,14289858,14467248,14646100,14826420,15008214,15191488,15376248 mov $1,$0 pow $0,2 mul $1,$0 sub $1,$0
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: Albert Bartok (Cambridge University) Aidan Thompson (Sandia, athomps@sandia.gov) ------------------------------------------------------------------------- */ #include <mpi.h> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include "pair_quip.h" #include "atom.h" #include "update.h" #include "force.h" #include "comm.h" #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" #include "memory.h" #include "error.h" #include "domain.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ PairQUIP::PairQUIP(LAMMPS *lmp) : Pair(lmp) { single_enable = 0; restartinfo = 0; one_coeff = 1; no_virial_fdotr_compute = 1; manybody_flag = 1; map = NULL; quip_potential = NULL; quip_file = NULL; quip_string = NULL; } PairQUIP::~PairQUIP() { if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); delete [] map; } delete [] quip_potential; delete [] quip_file; delete [] quip_string; } void PairQUIP::compute(int eflag, int vflag) { int inum, jnum, sum_num_neigh, ii, jj, i, iquip; int *ilist; int *jlist; int *numneigh, **firstneigh; int *quip_num_neigh, *quip_neigh, *atomic_numbers; int nlocal = atom->nlocal; int nghost = atom->nghost; int ntotal = nlocal + nghost; int *type = atom->type; tagint *tag = atom->tag; double **x = atom->x; double **f = atom->f; double *quip_local_e, *quip_force, *quip_local_virial, *quip_virial, quip_energy, *lattice; ev_init(eflag,vflag); inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; sum_num_neigh = 0; quip_num_neigh = new int [inum]; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; quip_num_neigh[ii] = numneigh[i]; sum_num_neigh += numneigh[i]; } quip_neigh = new int [sum_num_neigh]; iquip = 0; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; jlist = firstneigh[i]; jnum = numneigh[i]; for (jj = 0; jj < jnum; jj++) { quip_neigh[iquip] = (jlist[jj] & NEIGHMASK) + 1; iquip++; } } atomic_numbers = new int[ntotal]; for (ii = 0; ii < ntotal; ii++) atomic_numbers[ii] = map[type[ii]]; quip_local_e = new double [ntotal]; quip_force = new double [ntotal*3]; quip_local_virial = new double [ntotal*9]; quip_virial = new double [9]; lattice = new double [9]; lattice[0] = domain->xprd; lattice[1] = 0.0; lattice[2] = 0.0; lattice[3] = domain->xy; lattice[4] = domain->yprd; lattice[5] = 0.0; lattice[6] = domain->xz; lattice[7] = domain->yz; lattice[8] = domain->zprd; #if defined(LAMMPS_BIGBIG) int *tmptag = new int[ntotal]; int tmplarge = 0, toolarge = 0; for (ii = 0; ii < ntotal; ++ii) { tmptag[ii] = tag[ii]; if (tag[ii] > MAXSMALLINT) tmplarge=1; } MPI_Allreduce(&tmplarge,&toolarge,1,MPI_INT,MPI_MAX,world); if (toolarge > 0) error->all(FLERR,"Pair style quip does not support 64-bit atom IDs"); quip_lammps_wrapper(&nlocal,&nghost,atomic_numbers,tmptag, &inum,&sum_num_neigh,ilist, quip_num_neigh,quip_neigh,lattice, quip_potential,&n_quip_potential,&x[0][0], &quip_energy,quip_local_e,quip_virial, quip_local_virial,quip_force); delete[] tmptag; #else quip_lammps_wrapper(&nlocal,&nghost,atomic_numbers,tag, &inum,&sum_num_neigh,ilist, quip_num_neigh,quip_neigh,lattice, quip_potential,&n_quip_potential,&x[0][0], &quip_energy,quip_local_e,quip_virial, quip_local_virial,quip_force); #endif iquip = 0; for (ii = 0; ii < ntotal; ii++) { for( jj = 0; jj < 3; jj++ ) { f[ii][jj] += quip_force[iquip]; iquip++; } } if(eflag_global) { eng_vdwl = quip_energy; } if(eflag_atom) { for (ii = 0; ii < ntotal; ii++) { eatom[ii] = quip_local_e[ii]; } } if (vflag_global) { virial[0] = quip_virial[0]; virial[1] = quip_virial[4]; virial[2] = quip_virial[8]; virial[3] = (quip_virial[3] + quip_virial[1])*0.5; virial[4] = (quip_virial[2] + quip_virial[6])*0.5; virial[5] = (quip_virial[5] + quip_virial[7])*0.5; } if(vflag_atom) { int iatom = 0; for(ii = 0; ii < ntotal; ii++) { vatom[ii][0] += quip_local_virial[iatom+0]; vatom[ii][1] += quip_local_virial[iatom+4]; vatom[ii][2] += quip_local_virial[iatom+8]; vatom[ii][3] += (quip_local_virial[iatom+3] + quip_local_virial[iatom+1])*0.5; vatom[ii][4] += (quip_local_virial[iatom+2] + quip_local_virial[iatom+6])*0.5; vatom[ii][5] += (quip_local_virial[iatom+5] + quip_local_virial[iatom+7])*0.5; iatom += 9; } } delete [] atomic_numbers; delete [] quip_num_neigh; delete [] quip_neigh; delete [] quip_local_e; delete [] quip_force; delete [] quip_virial; delete [] quip_local_virial; delete [] lattice; } /* ---------------------------------------------------------------------- global settings ------------------------------------------------------------------------- */ void PairQUIP::settings(int narg, char ** /* arg */) { if (narg != 0) error->all(FLERR,"Illegal pair_style command"); // check if linked to the correct QUIP library API version // as of 2017-07-19 this is API_VERSION 1 if (quip_lammps_api_version() != 1) error->all(FLERR,"QUIP LAMMPS wrapper API version is not compatible " "with this version of LAMMPS"); // QUIP potentials are parameterized in metal units if (strcmp("metal",update->unit_style) != 0) error->all(FLERR,"QUIP potentials require 'metal' units"); } /* ---------------------------------------------------------------------- set coeffs for one or more type pairs ------------------------------------------------------------------------- */ void PairQUIP::allocate() { allocated = 1; int n = atom->ntypes; setflag = memory->create(setflag,n+1,n+1,"pair:setflag"); cutsq = memory->create(cutsq,n+1,n+1,"pair:cutsq"); map = new int[n+1]; } void PairQUIP::coeff(int narg, char **arg) { if (!allocated) allocate(); int n = atom->ntypes; if (narg != (4+n)) { char str[1024]; sprintf(str,"Number of arguments %d is not correct, it should be %d", narg, 4+n); error->all(FLERR,str); } // ensure I,J args are * * if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) error->all(FLERR,"Incorrect args for pair coefficients"); n_quip_file = strlen(arg[2]); quip_file = new char[n_quip_file+1]; strcpy(quip_file,arg[2]); n_quip_string = strlen(arg[3]); quip_string = new char[n_quip_string+1]; strcpy(quip_string,arg[3]); for (int i = 4; i < narg; i++) { if (strcmp(arg[i],"NULL") == 0) map[i-3] = -1; else map[i-3] = force->inumeric(FLERR,arg[i]); } // clear setflag since coeff() called once with I,J = * * n = atom->ntypes; for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) setflag[i][j] = 0; // set setflag i,j for type pairs where both are mapped to elements int count = 0; for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; count++; } if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); // Initialise potential // First call initialises potential via the fortran code in memory, and returns the necessary size // of quip_potential. This behaviour is invoked by setting n_potential_quip to 0. n_quip_potential = 0; quip_potential = new int[0]; quip_lammps_potential_initialise(quip_potential,&n_quip_potential,&cutoff,quip_file,&n_quip_file,quip_string,&n_quip_string); delete [] quip_potential; // Allocate quip_potential integer array. This initialise call will transfer the location of the // previously initialised potential to the quip_potential variable, and we will use it as a handle // when calling the actual calculation routine. We return the cutoff as well. quip_potential = new int[n_quip_potential]; quip_lammps_potential_initialise(quip_potential,&n_quip_potential,&cutoff,quip_file,&n_quip_file,quip_string,&n_quip_string); } /* ---------------------------------------------------------------------- init specific to this pair style ------------------------------------------------------------------------- */ void PairQUIP::init_style() { // Require newton pair on if (force->newton_pair != 1) error->all(FLERR,"Pair style quip requires newton pair on"); // Initialise neighbor list int irequest_full = neighbor->request(this); neighbor->requests[irequest_full]->id = 1; neighbor->requests[irequest_full]->half = 0; neighbor->requests[irequest_full]->full = 1; } /* ---------------------------------------------------------------------- init for one type pair i,j and corresponding j,i ------------------------------------------------------------------------- */ double PairQUIP::init_one(int /*i*/, int /*j*/) { return cutoff; }
BITS 16 ORG 0xA000 %include "src/boot/structures.asm" stage2: ; Retrieve memory information from BIOS call get_mem_info ; Locate KERNEL.ELF mov si, ROOT_DIR mov di, KERNEL_STR call fat32_findfile cmp edi, 0 je no_kernel ; Put starting cluster in EAX ; DI contains starting cluster mov eax, edi mov bx, 0x1000 mov es, bx .load_loop: ; Load file starting at 0x10000 ; The file will be loaded in 64k chunks ; Once a 64k chunk is read, copy it to 0x100000 (1 MB) xor di, di call fat32_readfile ; Copy to higher memory pushad push ds ; Some BIOS interrupts may overwrite DS thereby destroying ; the cached limit value. This is why it's called per ; loop. call enable_unreal mov esi, 0x10000 - 4 mov edi, [DST] sub edi, 4 mov ebx, 0x10000 / 4 ; MODIFIED ECX -> EBX .loop: mov edx, ds:[esi + ebx*4] mov ds:[edi + ebx*4], edx dec ebx jnz .loop .break: pop ds popad cmp eax, 0x0FFFFFF8 jge .done add dword [DST], 0x10000 jmp .load_loop .done: ; Kernel is loaded at 1 MB now ; Time to swtich to long mode jmp mode_long enable_unreal: push ds lgdt [GDT32.Pointer] mov eax, cr0 or al, 1 mov cr0, eax jmp $+2 mov bx, GDT32.Data mov ds, bx and al, 0xFE mov cr0, eax pop ds ret mode_long: ; -- Switch to long mode -- ; Zero PML4 mov edi, PML4 xor eax, eax mov es, ax mov ecx, 0x400 cld rep stosd ; Zero PDP push edi mov edi, PDP xor eax, eax mov ecx, 0x400 rep stosd pop edi mov edi, PML4 mov cr3, edi mov edi, cr3 ; Populate entries for 1 GB identity map mov word [edi], PDP + 3 add edi, 0x1000 mov word [edi], (1 << 7) | 3 ; Enable PAE mov eax, cr4 or eax, 1 << 5 mov cr4, eax ; Set long mode bit mov ecx, 0xC0000080 rdmsr or eax, 1 << 8 wrmsr ; Enable paging mov eax, cr0 or eax, 1 << 31 | 1 << 0 mov cr0, eax ; Switch :) lgdt [GDT64.Pointer] jmp GDT64.Code:long_mode hlt ; ------------------ ; -- get_mem_info -- ; ------------------ ; ; See https://wiki.osdev.org/Detecting_Memory_(x86)#BIOS_Function:_INT_0x15.2C_EAX_.3D_0xE820 ; get_mem_info: pushad xor bp, bp xor ax, ax mov es, ax mov di, MEM_INFO xor ebx, ebx mov edx, 0x534D4150 ; Some magic number .loop mov eax, 0xE820 ; Interrupt # mov ecx, 24 ; Bytes to read int 0x15 jc .done cmp ebx, 0 je .done cmp eax, 0x534D4150 jne .done inc bp add di, 24 jmp .loop .done mov [MEM_INFO_AMT], bp popad ret no_kernel: hlt hlt hlt BITS 64 long_mode: cli mov ax, GDT64.Data mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; Now the ELF needs to be loaded ; This should be easy since the CPU is in long mode load_elf: xor rdx, rdx mov rbp, ELF_BASE mov bx, [rbp+ELFe_phnum] ; # of segments in program header mov dx, [rbp+ELFe_phentsize] ; Size of segment entry mov r15, [rbp+ELFe_entry] ; Entry point add rbp, [rbp+ELFe_phoff] ; # Offset of program header .load_segment: cmp bx, 0 jz .done ; Check type mov eax, [rbp+ELFp_type] cmp eax, 1 jne .next ; Load segment mov rdi, [rbp+ELFp_vaddr] mov rsi, [rbp+ELFp_offset] add rsi, ELF_BASE mov rcx, [rbp+ELFp_filesz] rep movsb .next: add rbp, rdx dec bx jmp .load_segment .done: ; Pass in MEM_INFO mov rdi, MEM_INFO xor rsi, rsi mov si, [MEM_INFO_AMT] mov rsp, 0xA000 call r15 hlt GDT32: .Null: equ $ - GDT32 dq 0 .Data: equ $ - GDT32 dw 0xFFFF ; Limit 0:15 dw 0x0000 ; Base 0:15 db 0x00 ; Base 16:23 db 0b10010010 ; Access Byte db 0b01001111 ; Flags & Limit 16:19 db 0x00 ; Base 24:31 .Pointer: dw $ - GDT32 - 1 dd GDT32 GDT64: ; Global Descriptor Table (64-bit). .Null: equ $ - GDT64 ; The null descriptor. dw 0xFFFF ; Limit (low). dw 0 ; Base (low). db 0 ; Base (middle) db 0 ; Access. db 1 ; Granularity. db 0 ; Base (high). .Code: equ $ - GDT64 ; The code descriptor. dw 0 ; Limit (low). dw 0 ; Base (low). db 0 ; Base (middle) db 10011010b ; Access (exec/read). db 10101111b ; Granularity, 64 bits flag, limit19:16. db 0 ; Base (high). .Data: equ $ - GDT64 ; The data descriptor. dw 0 ; Limit (low). dw 0 ; Base (low). db 0 ; Base (middle) db 10010010b ; Access (read/write). db 00000000b ; Granularity. db 0 ; Base (high). .Pointer: ; The GDT-pointer. dw $ - GDT64 - 1 ; Limit. dq GDT64 ; Base. SRC: dd 0x10000 DST: dd 0x100000 KERNEL_STR: db "KERNEL ELF" %include "src/boot/disk.asm"
;******************************************************************************************************** ; uC/OS-II ; The Real-Time Kernel ; ; Copyright 1992-2021 Silicon Laboratories Inc. www.silabs.com ; ; SPDX-License-Identifier: APACHE-2.0 ; ; This software is subject to an open source license and is distributed by ; Silicon Laboratories Inc. pursuant to the terms of the Apache License, ; Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. ; ;******************************************************************************************************** ;******************************************************************************************************** ; ; 80x86/80x88 Specific code ; LARGE MEMORY MODEL ; ; Borland C/C++ V4.51 ; (IBM/PC Compatible Target) ; ; Filename : os_cpu_a.asm ; Version : V2.93.01 ;******************************************************************************************************** ;******************************************************************************************************** ; PUBLIC and EXTERNAL REFERENCES ;******************************************************************************************************** PUBLIC _OSTickISR PUBLIC _OSStartHighRdy PUBLIC _OSCtxSw PUBLIC _OSIntCtxSw EXTRN _OSIntExit:FAR EXTRN _OSTimeTick:FAR EXTRN _OSTaskSwHook:FAR EXTRN _OSIntNesting:BYTE EXTRN _OSTickDOSCtr:BYTE EXTRN _OSTickDOSCtrReload:BYTE EXTRN _OSPrioHighRdy:BYTE EXTRN _OSPrioCur:BYTE EXTRN _OSRunning:BYTE EXTRN _OSTCBCur:DWORD EXTRN _OSTCBHighRdy:DWORD .MODEL LARGE .CODE .186 PAGE ;********************************************************************************************************* ; START MULTITASKING ; void OSStartHighRdy(void) ; ; The stack frame is assumed to look as follows: ; ; OSTCBHighRdy->OSTCBStkPtr --> DS (Low memory) ; ES ; DI ; SI ; BP ; SP ; BX ; DX ; CX ; AX ; OFFSET of task code address ; SEGMENT of task code address ; Flags to load in PSW ; OFFSET of task code address ; SEGMENT of task code address ; OFFSET of 'p_arg' ; SEGMENT of 'p_arg' (High memory) ; ; Note : OSStartHighRdy() MUST: ; a) Call OSTaskSwHook() then, ; b) Set OSRunning to TRUE, ; c) Switch to the highest priority task. ;********************************************************************************************************* _OSStartHighRdy PROC FAR MOV AX, SEG _OSTCBHighRdy ; Reload DS MOV DS, AX ; ; CALL FAR PTR _OSTaskSwHook ; Call user defined task switch hook ; MOV AL, 1 ; OSRunning = TRUE; MOV BYTE PTR DS:_OSRunning, AL ; (Indicates that multitasking has started) ; LES BX, DWORD PTR DS:_OSTCBHighRdy ; SS:SP = OSTCBHighRdy->OSTCBStkPtr MOV SS, ES:[BX+2] ; MOV SP, ES:[BX+0] ; ; POP DS ; Load task's context POP ES ; POPA ; ; IRET ; Run task _OSStartHighRdy ENDP PAGE ;********************************************************************************************************* ; PERFORM A CONTEXT SWITCH (From task level) ; void OSCtxSw(void) ; ; Note(s): 1) Upon entry, ; OSTCBCur points to the OS_TCB of the task to suspend ; OSTCBHighRdy points to the OS_TCB of the task to resume ; ; 2) The stack frame of the task to suspend looks as follows: ; ; SP -> OFFSET of task to suspend (Low memory) ; SEGMENT of task to suspend ; PSW of task to suspend (High memory) ; ; 3) The stack frame of the task to resume looks as follows: ; ; OSTCBHighRdy->OSTCBStkPtr --> DS (Low memory) ; ES ; DI ; SI ; BP ; SP ; BX ; DX ; CX ; AX ; OFFSET of task code address ; SEGMENT of task code address ; Flags to load in PSW (High memory) ;********************************************************************************************************* _OSCtxSw PROC FAR ; PUSHA ; Save current task's context PUSH ES ; PUSH DS ; ; MOV AX, SEG _OSTCBCur ; Reload DS in case it was altered MOV DS, AX ; ; LES BX, DWORD PTR DS:_OSTCBCur ; OSTCBCur->OSTCBStkPtr = SS:SP MOV ES:[BX+2], SS ; MOV ES:[BX+0], SP ; ; CALL FAR PTR _OSTaskSwHook ; Call user defined task switch hook ; MOV AX, WORD PTR DS:_OSTCBHighRdy+2 ; OSTCBCur = OSTCBHighRdy MOV DX, WORD PTR DS:_OSTCBHighRdy ; MOV WORD PTR DS:_OSTCBCur+2, AX ; MOV WORD PTR DS:_OSTCBCur, DX ; ; MOV AL, BYTE PTR DS:_OSPrioHighRdy ; OSPrioCur = OSPrioHighRdy MOV BYTE PTR DS:_OSPrioCur, AL ; ; LES BX, DWORD PTR DS:_OSTCBHighRdy ; SS:SP = OSTCBHighRdy->OSTCBStkPtr MOV SS, ES:[BX+2] ; MOV SP, ES:[BX] ; ; POP DS ; Load new task's context POP ES ; POPA ; ; IRET ; Return to new task ; _OSCtxSw ENDP PAGE ;********************************************************************************************************* ; PERFORM A CONTEXT SWITCH (From an ISR) ; void OSIntCtxSw(void) ; ; Note(s): 1) Upon entry, ; OSTCBCur points to the OS_TCB of the task to suspend ; OSTCBHighRdy points to the OS_TCB of the task to resume ; ; 2) The stack frame of the task to suspend looks as follows: ; ; OSTCBCur->OSTCBStkPtr ------> DS (Low memory) ; ES ; DI ; SI ; BP ; SP ; BX ; DX ; CX ; AX ; OFFSET of task code address ; SEGMENT of task code address ; Flags to load in PSW (High memory) ; ; ; 3) The stack frame of the task to resume looks as follows: ; ; OSTCBHighRdy->OSTCBStkPtr --> DS (Low memory) ; ES ; DI ; SI ; BP ; SP ; BX ; DX ; CX ; AX ; OFFSET of task code address ; SEGMENT of task code address ; Flags to load in PSW (High memory) ;********************************************************************************************************* _OSIntCtxSw PROC FAR ; CALL FAR PTR _OSTaskSwHook ; Call user defined task switch hook ; MOV AX, SEG _OSTCBCur ; Reload DS in case it was altered MOV DS, AX ; ; MOV AX, WORD PTR DS:_OSTCBHighRdy+2 ; OSTCBCur = OSTCBHighRdy MOV DX, WORD PTR DS:_OSTCBHighRdy ; MOV WORD PTR DS:_OSTCBCur+2, AX ; MOV WORD PTR DS:_OSTCBCur, DX ; ; MOV AL, BYTE PTR DS:_OSPrioHighRdy ; OSPrioCur = OSPrioHighRdy MOV BYTE PTR DS:_OSPrioCur, AL ; LES BX, DWORD PTR DS:_OSTCBHighRdy ; SS:SP = OSTCBHighRdy->OSTCBStkPtr MOV SS, ES:[BX+2] ; MOV SP, ES:[BX] ; ; POP DS ; Load new task's context POP ES ; POPA ; ; IRET ; Return to new task ; _OSIntCtxSw ENDP PAGE ;********************************************************************************************************* ; HANDLE TICK ISR ; ; Description: This function is called 199.99 times per second or, 11 times faster than the normal DOS ; tick rate of 18.20648 Hz. Thus every 11th time, the normal DOS tick handler is called. ; This is called chaining. 10 times out of 11, however, the interrupt controller on the PC ; must be cleared to allow for the next interrupt. ; ; Arguments : none ; ; Returns : none ; ; Note(s) : The following C-like pseudo-code describe the operation being performed in the code below. ; ; Save all registers on the current task's stack; ; OSIntNesting++; ; if (OSIntNesting == 1) { ; OSTCBCur->OSTCBStkPtr = SS:SP ; } ; OSTickDOSCtr--; ; if (OSTickDOSCtr == 0) { ; OSTickDOSCtr = OSTickDOSCtrReload; ; INT 81H; Chain into DOS every 54.925 mS ; (Interrupt will be cleared by DOS) ; } else { ; Send EOI to PIC; Clear tick interrupt by sending an End-Of-Interrupt to the 8259 ; PIC (Priority Interrupt Controller) ; } ; OSTimeTick(); Notify uC/OS-II that a tick has occured ; OSIntExit(); Notify uC/OS-II about end of ISR ; Restore all registers that were save on the current task's stack; ; Return from Interrupt; ;********************************************************************************************************* ; _OSTickISR PROC FAR ; PUSHA ; Save interrupted task's context PUSH ES PUSH DS ; MOV AX, SEG(_OSIntNesting) ; Reload DS MOV DS, AX INC BYTE PTR DS:_OSIntNesting ; Notify uC/OS-II of ISR ; CMP BYTE PTR DS:_OSIntNesting, 1 ; if (OSIntNesting == 1) JNE SHORT _OSTickISR1 MOV AX, SEG(_OSTCBCur) ; Reload DS MOV DS, AX LES BX, DWORD PTR DS:_OSTCBCur ; OSTCBCur->OSTCBStkPtr = SS:SP MOV ES:[BX+2], SS ; MOV ES:[BX+0], SP ; ; _OSTickISR1: MOV AX, SEG(_OSTickDOSCtr) ; Reload DS MOV DS, AX DEC BYTE PTR DS:_OSTickDOSCtr CMP BYTE PTR DS:_OSTickDOSCtr, 0 JNE SHORT _OSTickISR2 ; Every 11 ticks (~199.99 Hz), chain into DOS ; MOV AL, BYTE PTR DS:_OSTickDOSCtrReload MOV BYTE PTR DS:_OSTickDOSCtr, AL INT 081H ; Chain into DOS's tick ISR JMP SHORT _OSTickISR3 _OSTickISR2: MOV AL, 20H ; Move EOI code into AL. MOV DX, 20H ; Address of 8259 PIC in DX. OUT DX, AL ; Send EOI to PIC if not processing DOS timer. ; _OSTickISR3: CALL FAR PTR _OSTimeTick ; Process system tick ; CALL FAR PTR _OSIntExit ; Notify uC/OS-II of end of ISR ; POP DS ; Restore interrupted task's context POP ES POPA ; IRET ; Return to interrupted task ; _OSTickISR ENDP ; END
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb Copyright (C) 2005 StatPro Italia srl This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ QuantLib is free software: you can redistribute it and/or modify it under the terms of the QuantLib license. You should have received a copy of the license along with this program; if not, please email <quantlib-dev@lists.sf.net>. The license is also available online at <http://quantlib.org/license.shtml>. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /*! \file trinomialtree.hpp \brief Trinomial tree class */ #ifndef quantlib_trinomial_tree_hpp #define quantlib_trinomial_tree_hpp #include <ql/methods/lattices/tree.hpp> #include <ql/timegrid.hpp> namespace QuantLib { class StochasticProcess1D; //! Recombining trinomial tree class /*! This class defines a recombining trinomial tree approximating a 1-D stochastic process. \warning The diffusion term of the SDE must be independent of the underlying process. \ingroup lattices */ class TrinomialTree : public Tree<TrinomialTree> { class Branching; public: enum Branches { branches = 3 }; TrinomialTree(const boost::shared_ptr<StochasticProcess1D>& process, const TimeGrid& timeGrid, bool isPositive = false); Real dx(Size i) const { return dx_[i]; } const TimeGrid& timeGrid() const { return timeGrid_; } Size size(Size i) const; Real underlying(Size i, Size index) const; Size descendant(Size i, Size index, Size branch) const; Real probability(Size i, Size index, Size branch) const; protected: std::vector<Branching> branchings_; Real x0_; std::vector<Real> dx_; TimeGrid timeGrid_; private: /* Branching scheme for a trinomial node. Each node has three descendants, with the middle branch linked to the node which is closest to the expectation of the variable. */ class Branching { public: Branching(); Size descendant(Size index, Size branch) const; Real probability(Size index, Size branch) const; Size size() const; Integer jMin() const; Integer jMax() const; void add(Integer k, Real p1, Real p2, Real p3); private: std::vector<Integer> k_; std::vector<std::vector<Real> > probs_; Integer kMin_, jMin_, kMax_, jMax_; }; }; // inline definitions inline Size TrinomialTree::size(Size i) const { return i==0 ? 1 : branchings_[i-1].size(); } inline Real TrinomialTree::underlying(Size i, Size index) const { if (i==0) return x0_; else return x0_ + (branchings_[i-1].jMin() + static_cast<Real>(index))*dx(i); } inline Size TrinomialTree::descendant(Size i, Size index, Size branch) const { return branchings_[i].descendant(index, branch); } inline Real TrinomialTree::probability(Size i, Size j, Size b) const { return branchings_[i].probability(j, b); } inline TrinomialTree::Branching::Branching() : probs_(3), kMin_(QL_MAX_INTEGER), jMin_(QL_MAX_INTEGER), kMax_(QL_MIN_INTEGER), jMax_(QL_MIN_INTEGER) {} inline Size TrinomialTree::Branching::descendant(Size index, Size branch) const { return k_[index] - jMin_ - 1 + branch; } inline Real TrinomialTree::Branching::probability(Size index, Size branch) const { return probs_[branch][index]; } inline Size TrinomialTree::Branching::size() const { return jMax_ - jMin_ + 1; } inline Integer TrinomialTree::Branching::jMin() const { return jMin_; } inline Integer TrinomialTree::Branching::jMax() const { return jMax_; } inline void TrinomialTree::Branching::add(Integer k, Real p1, Real p2, Real p3) { // store k_.push_back(k); probs_[0].push_back(p1); probs_[1].push_back(p2); probs_[2].push_back(p3); // maintain invariants kMin_ = std::min(kMin_, k); jMin_ = kMin_ - 1; kMax_ = std::max(kMax_, k); jMax_ = kMax_ + 1; } } #endif
// basic starter BasicUpstart2(main) * = $080d // assembler start address main: ldy #$0 // y will be the offset into the lengths and offsets byte array ldx #0 loop: tya pha // calc y as offset for start printing * lda #11 clc sbc lengths,y tay // calc length of asteriks txa asl // lengths only stores half of the length excluding the middle *, so multiply by 2 tax inx // add middle * to length // the asteriks itself lda #$2a sta1: // print as many * as given in lengths sta $0400+19-11+5*40,y iny // continue writing on the right dex bne sta1 // write all * pla tay // increase index in to bytes iny lda lengths,y // load offset for this line into accumulator beq out // 0 terminated byte sequence tax // go to next line lda #40 clc adc sta1+1 sta sta1+1 lda #0 adc sta1+2 sta sta1+2 jmp loop out: rts lengths: .byte 0,1,2,3, 1,3,5,7, 2,4,7,10, 1,1, 0
; ; ; Z88 Maths Routines ; ; C Interface for Small C+ Compiler ; ; 7/12/98 djm ;double ceil(double) ;Number in FA.. ; ;This is implemented as -(floor(-x)) SECTION code_fp INCLUDE "target/z88/def/fpp.def" PUBLIC ceil EXTERN fsetup EXTERN stkequ2 .ceil call fsetup fpp(FP_NEG) fpp(FP_INT) ;floor it (round down!) fpp(FP_NEG) jp stkequ2
.size 8000 .text@48 inc a ldff(45), a jp lstatint .text@100 jp lbegin .data@143 80 .text@150 lbegin: ld a, ff ldff(45), a ld b, 03 call lwaitly_b ld a, 40 ldff(41), a ld a, 02 ldff(ff), a ei ld a, b inc a inc a ldff(45), a ld c, 0f .text@1000 lstatint: xor a, a ldff(41), a .text@105a xor a, a ldff(c), a ld a, 40 ldff(41), a nop nop nop nop nop nop ldff a, (c) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
; A249407: Numbers not in A249406. ; 2,3,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,57,58,59,60,61,62,63,64,65,66,67,68,69,70 mov $2,$0 add $0,5 add $2,2 mov $1,$2 add $2,4 lpb $0 sub $0,1 sub $2,$0 sub $0,$2 add $0,2 trn $0,2 add $1,1 add $2,$1 lpe sub $1,2
; A134429: Array read by rows: row n lists 4 terms: k, m, k, m where k = 8n+3 and m = -8n -5. ; 3,-5,3,-5,11,-13,11,-13,19,-21,19,-21,27,-29,27,-29,35,-37,35,-37,43,-45,43,-45,51,-53,51,-53,59,-61,59,-61,67,-69,67,-69,75,-77,75,-77,83,-85,83,-85,91,-93,91,-93,99,-101,99,-101,107,-109,107,-109,115,-117,115,-117,123,-125,123,-125,131,-133,131,-133,139,-141,139,-141,147,-149,147,-149,155,-157,155,-157,163,-165,163,-165,171,-173,171,-173,179,-181,179,-181,187,-189,187,-189,195,-197,195,-197,203,-205,203,-205,211,-213,211,-213,219,-221,219,-221,227,-229,227,-229,235,-237,235,-237,243,-245,243,-245,251,-253,251,-253,259,-261,259,-261,267,-269,267,-269,275,-277,275,-277,283,-285,283,-285,291,-293,291,-293,299,-301,299,-301,307,-309,307,-309,315,-317,315,-317,323,-325,323,-325,331,-333,331,-333,339,-341,339,-341,347,-349,347,-349,355,-357,355,-357,363,-365,363,-365,371,-373,371,-373,379,-381,379,-381,387,-389,387,-389,395,-397,395,-397,403,-405,403,-405,411,-413,411,-413,419,-421,419,-421,427,-429,427,-429,435,-437,435,-437,443,-445,443,-445,451,-453,451,-453,459,-461,459,-461,467,-469,467,-469,475,-477,475,-477,483,-485,483,-485,491,-493,491,-493,499,-501 mov $1,$0 sub $1,$0 lpb $0 add $1,$0 sub $0,1 add $1,2 mov $2,$1 mov $1,1 sub $1,$2 lpe div $1,2 mul $1,8 add $1,3
; Scroll Spectrum/TS2068 up ; ; Relies on ROM routines to perform the scroll ; ; Toggle on __zx_screenmode to determine whether to scroll ; the second display ; MODULE __zx_scrollup SECTION code_driver PUBLIC __zx_scrollup EXTERN call_rom3 EXTERN __zx_screenmode EXTERN __zx_console_attr EXTERN zx_rowtab EXTERN generic_console_zxn_tile_scrollup IF FORsam defc NOROMCALLS = 1 EXTERN SCREEN_BASE EXTERN __sam_graphics_pagein EXTERN __sam_graphics_pageout ENDIF __zx_scrollup: IF FORzxn ld a,(__zx_screenmode) bit 6,a jp nz,generic_console_zxn_tile_scrollup ENDIF push de push bc IF NOROMCALLS ; TODO: Do this better without the big table ; Code to be used when the original ROM is missing or not available IF FORsam call __sam_graphics_pagein ENDIF push ix ld ix,zx_rowtab ld a,8 .outer_loop push af push ix ld a,23 .inner_loop ex af,af ld l,(ix+16) IF FORsam ld a,(ix+17) sub 64 -(SCREEN_BASE / 256) ld h,a ELSE ld h,(ix+17) ENDIF ld e,(ix+0) IF FORsam ld a,(ix+1) sub 64 -(SCREEN_BASE / 256) ld d,a ELSE ld d,(ix+1) ENDIF ld bc,32 ldir ld bc,16 add ix,bc ex af,af dec a jr nz,inner_loop pop ix pop af inc ix inc ix dec a jr nz,outer_loop ; clear ld ix,zx_rowtab + (192 - 8) * 2 ld a,8 .clear_loop ex af,af ld e,(ix+0) IF FORsam ld a,(ix+1) sub 64 -(SCREEN_BASE / 256) ld d,a ELSE ld d,(ix+1) ENDIF ld h,d ld l,e ld (hl),0 inc de ld bc,31 ldir inc ix inc ix ex af,af dec a jr nz,clear_loop IF FORsam ld hl,SCREEN_BASE + 6144 + 32 ld de,SCREEN_BASE + 6144 ELSE ld hl,22528 + 32 ld de,22528 ENDIF ld bc,768-32 ldir ex de,hl ld d,h ld e,l inc de ld a,(__zx_console_attr) ld (hl),a ld bc,31 ldir pop ix IF FORsam call __sam_graphics_pageout ENDIF pop bc pop de ret ELSE IF FORts2068 | FORzxn ld a,(__zx_screenmode) cp 6 ;Hires jr z,hrgscroll cp 2 ;High colour jr z,hrgscroll cp 1 ;Screen 1 jr z,hrgscroll ENDIF ld a,($dff) cp $17 jr nz,ts2068_rom call call_rom3 defw 3582 ;scrollup pop bc pop de ret .ts2068_rom call call_rom3 defw $939 ; TS2068 scrollup pop bc pop de ret ENDIF IF FORts2068 | FORzxn .hrgscroll push ix ld ix,zx_rowtab ld a,8 .outer_loophr push af push ix ld a,(__zx_screenmode) ld b,23 .inner_loophr push bc ld e,(ix+16) ld d,(ix+17) ex de,hl ld e,(ix+0) ld d,(ix+1) cp 1 jr z,just_screen_1 push de push hl ld bc,32 ldir pop hl pop de just_screen_1: set 5,d set 5,h ld bc,32 ldir ld bc,16 add ix,bc pop bc djnz inner_loophr pop ix pop af inc ix inc ix dec a jr nz,outer_loophr ; clear ld ix,zx_rowtab + (192 - 8) * 2 ld a,(__zx_screenmode) ld b,8 .clear_loophr push bc push ix ld e,(ix+0) ld d,(ix+1) ld h,d ld l,e inc de push de push hl cp 1 jr z,clear_screen1_only ld (hl),0 ld bc,31 ldir ; second display clear_screen1_only: pop hl pop de set 5,d set 5,h cp 4 ex af,af ld a,(__zx_console_attr) ld c,a ex af,af jr z,clear_hires2 ld c,0 clear_hires2: ld (hl),c ld bc,31 ldir pop ix inc ix inc ix pop bc djnz clear_loophr pop ix pop bc pop de ret ENDIF
; ; Copyright (c) 2010 The Webm project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; EXPORT |idct_dequant_full_2x_neon| ARM REQUIRE8 PRESERVE8 AREA ||.text||, CODE, READONLY, ALIGN=2 ;void idct_dequant_full_2x_neon(short *q, short *dq, ; unsigned char *dst, int stride); ; r0 *q, ; r1 *dq, ; r2 *dst ; r3 stride |idct_dequant_full_2x_neon| PROC vld1.16 {q0, q1}, [r1] ; dq (same l/r) vld1.16 {q2, q3}, [r0] ; l q add r0, r0, #32 vld1.16 {q4, q5}, [r0] ; r q add r12, r2, #4 ; interleave the predictors vld1.32 {d28[0]}, [r2], r3 ; l pre vld1.32 {d28[1]}, [r12], r3 ; r pre vld1.32 {d29[0]}, [r2], r3 vld1.32 {d29[1]}, [r12], r3 vld1.32 {d30[0]}, [r2], r3 vld1.32 {d30[1]}, [r12], r3 vld1.32 {d31[0]}, [r2], r3 vld1.32 {d31[1]}, [r12] adr r1, cospi8sqrt2minus1 ; pointer to the first constant ; dequant: q[i] = q[i] * dq[i] vmul.i16 q2, q2, q0 vmul.i16 q3, q3, q1 vmul.i16 q4, q4, q0 vmul.i16 q5, q5, q1 vld1.16 {d0}, [r1] ; q2: l0r0 q3: l8r8 ; q4: l4r4 q5: l12r12 vswp d5, d8 vswp d7, d10 ; _CONSTANTS_ * 4,12 >> 16 ; q6: 4 * sinpi : c1/temp1 ; q7: 12 * sinpi : d1/temp2 ; q8: 4 * cospi ; q9: 12 * cospi vqdmulh.s16 q6, q4, d0[2] ; sinpi8sqrt2 vqdmulh.s16 q7, q5, d0[2] vqdmulh.s16 q8, q4, d0[0] ; cospi8sqrt2minus1 vqdmulh.s16 q9, q5, d0[0] vqadd.s16 q10, q2, q3 ; a1 = 0 + 8 vqsub.s16 q11, q2, q3 ; b1 = 0 - 8 ; vqdmulh only accepts signed values. this was a problem because ; our constant had the high bit set, and was treated as a negative value. ; vqdmulh also doubles the value before it shifts by 16. we need to ; compensate for this. in the case of sinpi8sqrt2, the lowest bit is 0, ; so we can shift the constant without losing precision. this avoids ; shift again afterward, but also avoids the sign issue. win win! ; for cospi8sqrt2minus1 the lowest bit is 1, so we lose precision if we ; pre-shift it vshr.s16 q8, q8, #1 vshr.s16 q9, q9, #1 ; q4: 4 + 4 * cospi : d1/temp1 ; q5: 12 + 12 * cospi : c1/temp2 vqadd.s16 q4, q4, q8 vqadd.s16 q5, q5, q9 ; c1 = temp1 - temp2 ; d1 = temp1 + temp2 vqsub.s16 q2, q6, q5 vqadd.s16 q3, q4, q7 ; [0]: a1+d1 ; [1]: b1+c1 ; [2]: b1-c1 ; [3]: a1-d1 vqadd.s16 q4, q10, q3 vqadd.s16 q5, q11, q2 vqsub.s16 q6, q11, q2 vqsub.s16 q7, q10, q3 ; rotate vtrn.32 q4, q6 vtrn.32 q5, q7 vtrn.16 q4, q5 vtrn.16 q6, q7 ; idct loop 2 ; q4: l 0, 4, 8,12 r 0, 4, 8,12 ; q5: l 1, 5, 9,13 r 1, 5, 9,13 ; q6: l 2, 6,10,14 r 2, 6,10,14 ; q7: l 3, 7,11,15 r 3, 7,11,15 ; q8: 1 * sinpi : c1/temp1 ; q9: 3 * sinpi : d1/temp2 ; q10: 1 * cospi ; q11: 3 * cospi vqdmulh.s16 q8, q5, d0[2] ; sinpi8sqrt2 vqdmulh.s16 q9, q7, d0[2] vqdmulh.s16 q10, q5, d0[0] ; cospi8sqrt2minus1 vqdmulh.s16 q11, q7, d0[0] vqadd.s16 q2, q4, q6 ; a1 = 0 + 2 vqsub.s16 q3, q4, q6 ; b1 = 0 - 2 ; see note on shifting above vshr.s16 q10, q10, #1 vshr.s16 q11, q11, #1 ; q10: 1 + 1 * cospi : d1/temp1 ; q11: 3 + 3 * cospi : c1/temp2 vqadd.s16 q10, q5, q10 vqadd.s16 q11, q7, q11 ; q8: c1 = temp1 - temp2 ; q9: d1 = temp1 + temp2 vqsub.s16 q8, q8, q11 vqadd.s16 q9, q10, q9 ; a1+d1 ; b1+c1 ; b1-c1 ; a1-d1 vqadd.s16 q4, q2, q9 vqadd.s16 q5, q3, q8 vqsub.s16 q6, q3, q8 vqsub.s16 q7, q2, q9 ; +4 >> 3 (rounding) vrshr.s16 q4, q4, #3 ; lo vrshr.s16 q5, q5, #3 vrshr.s16 q6, q6, #3 ; hi vrshr.s16 q7, q7, #3 vtrn.32 q4, q6 vtrn.32 q5, q7 vtrn.16 q4, q5 vtrn.16 q6, q7 ; adding pre ; input is still packed. pre was read interleaved vaddw.u8 q4, q4, d28 vaddw.u8 q5, q5, d29 vaddw.u8 q6, q6, d30 vaddw.u8 q7, q7, d31 vmov.i16 q14, #0 vmov q15, q14 vst1.16 {q14, q15}, [r0] ; write over high input sub r0, r0, #32 vst1.16 {q14, q15}, [r0] ; write over low input sub r2, r2, r3, lsl #2 ; dst - 4*stride add r1, r2, #4 ; hi ;saturate and narrow vqmovun.s16 d0, q4 ; lo vqmovun.s16 d1, q5 vqmovun.s16 d2, q6 ; hi vqmovun.s16 d3, q7 vst1.32 {d0[0]}, [r2], r3 ; lo vst1.32 {d0[1]}, [r1], r3 ; hi vst1.32 {d1[0]}, [r2], r3 vst1.32 {d1[1]}, [r1], r3 vst1.32 {d2[0]}, [r2], r3 vst1.32 {d2[1]}, [r1], r3 vst1.32 {d3[0]}, [r2] vst1.32 {d3[1]}, [r1] bx lr ENDP ; |idct_dequant_full_2x_neon| ; Constant Pool cospi8sqrt2minus1 DCD 0x4e7b ; because the lowest bit in 0x8a8c is 0, we can pre-shift this sinpi8sqrt2 DCD 0x4546 END
; A164001: Spiral of triangles around a hexagon. ; 1,2,3,4,5,7,9,12,16,21,28,37,49,65,86,114,151,200,265,351,465,616,816,1081,1432,1897,2513,3329,4410,5842,7739,10252,13581,17991,23833,31572,41824,55405,73396,97229,128801,170625,226030,299426,396655,525456,696081,922111,1221537,1618192,2143648,2839729,3761840,4983377,6601569,8745217,11584946,15346786,20330163,26931732,35676949,47261895,62608681,82938844,109870576,145547525,192809420,255418101,338356945,448227521,593775046,786584466,1042002567,1380359512,1828587033,2422362079,3208946545,4250949112,5631308624,7459895657,9882257736,13091204281,17342153393,22973462017,30433357674,40315615410,53406819691,70748973084,93722435101,124155792775,164471408185,217878227876,288627200960,382349636061,506505428836,670976837021,888855064897,1177482265857,1559831901918,2066337330754,2737314167775,3626169232672,4803651498529,6363483400447,8429820731201,11167134898976,14793304131648,19596955630177,25960439030624,34390259761825,45557394660801,60350698792449,79947654422626,105908093453250,140298353215075,185855747875876,246206446668325,326154101090951,432062194544201,572360547759276,758216295635152,1004422742303477,1330576843394428,1762639037938629,2334999585697905,3093215881333057,4097638623636534,5428215467030962,7190854504969591 mov $5,$0 mov $7,2 lpb $7 clr $0,5 mov $0,$5 sub $7,1 add $0,$7 sub $0,1 add $3,$0 add $3,8 cal $3,134816 ; Padovan's spiral numbers. mov $1,$3 sub $1,6 mov $8,$7 lpb $8 mov $6,$1 sub $8,1 lpe lpe lpb $5 mov $5,0 sub $6,$1 lpe mov $1,$6
#include "qrcodedialog.h" #include "ui_qrcodedialog.h" #include "bitcoinunits.h" #include "guiconstants.h" #include "guiutil.h" #include "optionsmodel.h" #include <QPixmap> #include <QUrl> #include <qrencode.h> QRCodeDialog::QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent) : QDialog(parent), ui(new Ui::QRCodeDialog), model(0), address(addr) { ui->setupUi(this); setWindowTitle(QString("%1").arg(address)); ui->chkReqPayment->setVisible(enableReq); ui->lblAmount->setVisible(enableReq); ui->lnReqAmount->setVisible(enableReq); ui->lnLabel->setText(label); ui->btnSaveAs->setEnabled(false); genCode(); } QRCodeDialog::~QRCodeDialog() { delete ui; } void QRCodeDialog::setModel(OptionsModel *model) { this->model = model; if (model) connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); // update the display unit, to not use the default ("BTC") updateDisplayUnit(); } void QRCodeDialog::genCode() { QString uri = getURI(); if (uri != "") { ui->lblQRCode->setText(""); QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1); if (!code) { ui->lblQRCode->setText(tr("Error encoding URI into QR Code.")); return; } myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); myImage.fill(0xffffff); unsigned char *p = code->data; for (int y = 0; y < code->width; y++) { for (int x = 0; x < code->width; x++) { myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff)); p++; } } QRcode_free(code); ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300)); ui->outUri->setPlainText(uri); } } QString QRCodeDialog::getURI() { QString ret = QString("daricoin:%1").arg(address); int paramCount = 0; ui->outUri->clear(); if (ui->chkReqPayment->isChecked()) { if (ui->lnReqAmount->validate()) { // even if we allow a non BTC unit input in lnReqAmount, we generate the URI with BTC as unit (as defined in BIP21) ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::BTC, ui->lnReqAmount->value())); paramCount++; } else { ui->btnSaveAs->setEnabled(false); ui->lblQRCode->setText(tr("The entered amount is invalid, please check.")); return QString(""); } } if (!ui->lnLabel->text().isEmpty()) { QString lbl(QUrl::toPercentEncoding(ui->lnLabel->text())); ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl); paramCount++; } if (!ui->lnMessage->text().isEmpty()) { QString msg(QUrl::toPercentEncoding(ui->lnMessage->text())); ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg); paramCount++; } // limit URI length to prevent a DoS against the QR-Code dialog if (ret.length() > MAX_URI_LENGTH) { ui->btnSaveAs->setEnabled(false); ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce the text for label / message.")); return QString(""); } ui->btnSaveAs->setEnabled(true); return ret; } void QRCodeDialog::on_lnReqAmount_textChanged() { genCode(); } void QRCodeDialog::on_lnLabel_textChanged() { genCode(); } void QRCodeDialog::on_lnMessage_textChanged() { genCode(); } void QRCodeDialog::on_btnSaveAs_clicked() { QString fn = GUIUtil::getSaveFileName(this, tr("Save QR Code"), QString(), tr("PNG Images (*.png)")); if (!fn.isEmpty()) myImage.scaled(EXPORT_IMAGE_SIZE, EXPORT_IMAGE_SIZE).save(fn); } void QRCodeDialog::on_chkReqPayment_toggled(bool fChecked) { if (!fChecked) // if chkReqPayment is not active, don't display lnReqAmount as invalid ui->lnReqAmount->setValid(true); genCode(); } void QRCodeDialog::updateDisplayUnit() { if (model) { // Update lnReqAmount with the current unit ui->lnReqAmount->setDisplayUnit(model->getDisplayUnit()); } }
/* //@HEADER // ************************************************************************ // // KokkosKernels 0.9: Linear Algebra and Graph Kernels // Copyright 2017 Sandia Corporation // // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Questions? Contact Siva Rajamanickam (srajama@sandia.gov) // // ************************************************************************ //@HEADER */ #define KOKKOSKERNELS_IMPL_COMPILE_LIBRARY true #include "KokkosKernels_config.h" #if defined (KOKKOSKERNELS_INST_KOKKOS_COMPLEX_FLOAT_) \ && defined (KOKKOSKERNELS_INST_LAYOUTLEFT) \ && defined (KOKKOSKERNELS_INST_EXECSPACE_CUDA) \ && defined (KOKKOSKERNELS_INST_MEMSPACE_CUDASPACE) \ && defined (KOKKOSKERNELS_INST_MEMSPACE_CUDASPACE) \ && defined (KOKKOSKERNELS_INST_ORDINAL_INT64_T) \ && defined (KOKKOSKERNELS_INST_OFFSET_SIZE_T) #include "KokkosSparse_gauss_seidel_spec.hpp" namespace KokkosSparse { namespace Impl { KOKKOSSPARSE_GAUSS_SEIDEL_SYMBOLIC_ETI_SPEC_INST(Kokkos::complex<float>, int64_t, size_t, Kokkos::LayoutLeft, Kokkos::Cuda, Kokkos::CudaSpace, Kokkos::CudaSpace) } // Impl } // KokkosSparse #endif
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r15 push %r9 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x15bbe, %r14 nop nop nop cmp %rbx, %rbx movb $0x61, (%r14) nop nop cmp $32700, %rdx lea addresses_WT_ht+0x12a9c, %r9 nop and %rdi, %rdi mov $0x6162636465666768, %r14 movq %r14, %xmm7 movups %xmm7, (%r9) nop xor $64792, %rbx lea addresses_A_ht+0x1da9c, %rbx nop nop nop nop add $51242, %r10 mov $0x6162636465666768, %r14 movq %r14, (%rbx) add $37210, %r9 lea addresses_D_ht+0x18e9c, %r10 nop nop nop nop and $20199, %r9 movw $0x6162, (%r10) cmp %rdi, %rdi lea addresses_WC_ht+0x15900, %rsi lea addresses_WC_ht+0x1ca9c, %rdi clflush (%rdi) and $32563, %r9 mov $73, %rcx rep movsl nop nop nop nop nop and %rbx, %rbx lea addresses_normal_ht+0x10268, %r10 clflush (%r10) nop nop nop add $4861, %r14 vmovups (%r10), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %rsi nop nop nop nop nop add %rbx, %rbx lea addresses_D_ht+0x1869c, %r14 sub $26419, %r9 movl $0x61626364, (%r14) nop nop nop nop nop xor %rdx, %rdx lea addresses_A_ht+0x1e9c, %rdx and $7629, %r9 movl $0x61626364, (%rdx) add %rbx, %rbx lea addresses_A_ht+0x1a9dc, %rdx clflush (%rdx) nop nop xor %rbx, %rbx movl $0x61626364, (%rdx) nop nop nop dec %r10 lea addresses_WT_ht+0x12e9c, %r10 nop nop nop nop nop xor %rcx, %rcx mov $0x6162636465666768, %rdi movq %rdi, %xmm1 movups %xmm1, (%r10) nop nop sub $63488, %r9 lea addresses_D_ht+0x13c00, %rsi lea addresses_UC_ht+0x18adc, %rdi nop nop xor %r9, %r9 mov $42, %rcx rep movsq nop nop cmp $45757, %rdx lea addresses_normal_ht+0x15b64, %rsi lea addresses_UC_ht+0xa49c, %rdi nop nop nop cmp $6098, %r14 mov $48, %rcx rep movsb nop nop cmp %r9, %r9 lea addresses_WT_ht+0x52ec, %r9 nop nop nop nop nop inc %rdi mov $0x6162636465666768, %rsi movq %rsi, %xmm4 and $0xffffffffffffffc0, %r9 vmovaps %ymm4, (%r9) nop nop nop nop dec %rdx lea addresses_A_ht+0xe09c, %rdx nop nop sub $12189, %rdi mov (%rdx), %esi nop and %rdx, %rdx lea addresses_D_ht+0x1ca5c, %rsi lea addresses_D_ht+0xce9c, %rdi nop nop nop xor $45908, %r14 mov $16, %rcx rep movsw sub %r15, %r15 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r9 pop %r15 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %r15 push %rax push %rcx push %rsi // Load lea addresses_WC+0x1d39c, %rax nop nop nop nop inc %r11 vmovups (%rax), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $0, %xmm2, %r14 nop nop nop nop xor $61096, %rax // Store lea addresses_US+0x1c59c, %rcx nop nop nop nop cmp $63869, %r10 movb $0x51, (%rcx) nop nop nop nop xor $42843, %rcx // Store lea addresses_WT+0xee1c, %rax nop add %r14, %r14 mov $0x5152535455565758, %r11 movq %r11, %xmm7 movntdq %xmm7, (%rax) nop nop dec %r11 // Load lea addresses_D+0x8594, %rax clflush (%rax) nop nop nop nop cmp $48560, %rsi movntdqa (%rax), %xmm6 vpextrq $1, %xmm6, %rcx nop nop nop cmp $11212, %r10 // Store mov $0xcbc, %rsi nop nop add $45732, %r11 movb $0x51, (%rsi) add $9588, %r15 // Faulty Load lea addresses_A+0xe69c, %rcx nop nop xor $50149, %rax vmovups (%rcx), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %rsi lea oracles, %rax and $0xff, %rsi shlq $12, %rsi mov (%rax,%rsi,1), %rsi pop %rsi pop %rcx pop %rax pop %r15 pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_US', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}} {'00': 2008} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Compute the line coordinates and put into a vector ; Basic concept by Rafael de Oliveira Jannone (calculate_side) ; ; Stefano Bodrato - 13/3/2009 ; ; ; $Id: w_stencil_add_circle.asm,v 1.3 2016/04/23 20:37:40 dom Exp $ ; ;; void stencil_add_circle(int x1, int y1, int x2, int y2, unsigned char *stencil) SECTION code_clib PUBLIC stencil_add_circle PUBLIC _stencil_add_circle EXTERN w_draw_circle EXTERN stencil_add_pixel EXTERN swapgfxbk EXTERN swapgfxbk1 EXTERN stencil_ptr EXTERN __graphics_end .stencil_add_circle ._stencil_add_circle push ix ld ix,2 add ix,sp ld l,(ix+2) ;pointer to stencil ld h,(ix+3) ld (stencil_ptr),hl ;ld l,(ix+4) ;pointer to leftmost vector ;ld h,(ix+5) ;ld (gfx_area),hl ld a,(ix+4) ;skip ld c,(ix+6) ;radius ld b,(ix+7) ld l,(ix+8) ;y ld h,(ix+9) ld e,(ix+10) ;x ld d,(ix+11) call swapgfxbk ld ix,stencil_add_pixel call w_draw_circle jp __graphics_end
#include "reflection.h" Reflection::Reflection(short width, short height) :ShadowRays(width, height) { } Reflection::~Reflection() { } Payload Reflection::Hit(const Ray& ray, const IntersectableData& data, const MaterialTriangle* triangle, const unsigned int raytrace_depth) const { if (raytrace_depth <= 0) { return Miss(ray); } if (triangle == nullptr) { return Miss(ray); } Payload payload; payload.color = triangle->emissive_color; float3 X = ray.position + ray.direction * data.t; float3 n = triangle->GetNormal(data.baricentric); if (triangle->reflectiveness) { float3 reflection_direction = ray.direction - 2.0f * dot(n, ray.direction) * n; Ray reflection_ray(X, reflection_direction); return TraceRay(reflection_ray, raytrace_depth - 1); } for (auto light : lights) { Ray to_light(X, light->position - X); float to_light_distance = length(light->position - X); float t = TraceShadowRay(to_light, to_light_distance); if (fabs(t - to_light_distance) > 0.001f) { //payload.color /= 3; continue; } payload.color += light->color * triangle->diffuse_color * std::max(0.0f, dot(n, to_light.direction)); float3 reflection_direction = 2.0f * dot(n, to_light.direction) * n - to_light.direction; payload.color += light->color * triangle->specular_color * powf(std::max(0.0f, dot(ray.direction, reflection_direction)), triangle->specular_exponent); } return payload; }
// -*- C++ -*- // // Package: TauTagValidation // Class: TauTagValidation // /**\class TauTagValidation TauTagValidation.cc Description: <one line class summary> Class used to do the Validation of the TauTag Implementation: <Notes on implementation> */ // // Original Author: Ricardo Vasquez Sierra // Created: October 8, 2008 // //Modified by: Atanu Modak to include extra plots // user include files #include "Validation/RecoTau/interface/TauTagValidation.h" #include "FWCore/Version/interface/GetReleaseVersion.h" #include <DataFormats/VertexReco/interface/Vertex.h> #include <DataFormats/VertexReco/interface/VertexFwd.h> #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "PhysicsTools/JetMCUtils/interface/JetMCTag.h" #include "DataFormats/JetReco/interface/GenJet.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "CommonTools/Utils/interface/StringCutObjectSelector.h" #include "RecoTauTag/RecoTau/interface/PFTauDecayModeTools.h" using namespace edm; using namespace std; using namespace reco; TauTagValidation::TauTagValidation(const edm::ParameterSet& iConfig): moduleLabel_(iConfig.getParameter<std::string>("@module_label")), // What do we want to use as source Leptons or Jets (the only difference is the matching criteria) dataType_( iConfig.getParameter<string>("DataType") ), // We need different matching criteria if we talk about leptons or jets matchDeltaR_Leptons_( iConfig.getParameter<double>("MatchDeltaR_Leptons")), matchDeltaR_Jets_( iConfig.getParameter<double>("MatchDeltaR_Jets")), TauPtCut_( iConfig.getParameter<double>("TauPtCut")), //flexible cut interface to filter reco and gen collection. use an empty string to select all. recoCuts_( iConfig.getParameter<std::string>( "recoCuts" )), genCuts_( iConfig.getParameter<std::string>( "genCuts" )), // The output histograms can be stored or not saveoutputhistograms_( iConfig.getParameter<bool>("SaveOutputHistograms")), // Here it can be pretty much anything either a lepton or a jet refCollectionInputTag_( iConfig.getParameter<InputTag>("RefCollection")), // The extension name has information about the Reference collection used extensionName_( iConfig.getParameter<string>("ExtensionName")), // Here is the reconstructed product of interest. TauProducerInputTag_( iConfig.getParameter<InputTag>("TauProducer")), // Get the discriminators and their cuts discriminators_( iConfig.getParameter< std::vector<edm::ParameterSet> >( "discriminators" )) { turnOnTrigger_ = iConfig.exists("turnOnTrigger") && iConfig.getParameter<bool>("turnOnTrigger"); genericTriggerEventFlag_ = (iConfig.exists("GenericTriggerSelection") && turnOnTrigger_) ? new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("GenericTriggerSelection"), consumesCollector(), *this) : NULL; if(genericTriggerEventFlag_ != NULL) LogDebug(moduleLabel_) <<"--> GenericTriggerSelection parameters found in "<<moduleLabel_<<"."<<std::endl;//move to LogDebug else LogDebug(moduleLabel_) <<"--> GenericTriggerSelection not found in "<<moduleLabel_<<"."<<std::endl;//move to LogDebug to keep track of modules that fail and pass //InputTag to strings refCollection_ = refCollectionInputTag_.label(); TauProducer_ = TauProducerInputTag_.label(); histoSettings_= (iConfig.exists("histoSettings")) ? iConfig.getParameter<edm::ParameterSet>("histoSettings") : edm::ParameterSet(); edm::InputTag PrimaryVertexCollection_ = (iConfig.exists("PrimaryVertexCollection")) ? iConfig.getParameter<InputTag>("PrimaryVertexCollection") : edm::InputTag("offlinePrimaryVertices"); //TO-DO refCollectionInputTagToken_ = consumes<edm::View<reco::Candidate> >(iConfig.getParameter<InputTag>("RefCollection")); primaryVertexCollectionToken_ = consumes<VertexCollection>(PrimaryVertexCollection_); //TO-DO tauProducerInputTagToken_ = consumes<reco::PFTauCollection>(iConfig.getParameter<InputTag>("TauProducer")); int j = 0; for ( std::vector<edm::ParameterSet>::iterator it = discriminators_.begin(); it != discriminators_.end(); ++j, ++it ) { currentDiscriminatorToken_.push_back( consumes<reco::PFTauDiscriminator>(edm::InputTag(it->getParameter<string>("discriminator"))) ); } tversion = edm::getReleaseVersion(); if (!saveoutputhistograms_) { LogInfo("OutputInfo") << " TauVisible histograms will NOT be saved"; } else { outPutFile_ = TauProducer_; outPutFile_.append("_"); tversion.erase(0,1); tversion.erase(tversion.size()-1,1); outPutFile_.append(tversion); outPutFile_.append("_"+ refCollection_); if ( ! extensionName_.empty()){ outPutFile_.append("_"+ extensionName_); } outPutFile_.append(".root"); LogInfo("OutputInfo") << " TauVisiblehistograms will be saved to file:" << outPutFile_; } //---- book-keeping information --- numEvents_ = 0 ; // Check if we want to "chain" the discriminator requirements (i.e. all // prveious discriminators must pass) chainCuts_ = iConfig.exists("chainCuts") ? iConfig.getParameter<bool>("chainCuts") : true; } TauTagValidation::~TauTagValidation() { if (genericTriggerEventFlag_) delete genericTriggerEventFlag_; } void TauTagValidation::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & iRun, edm::EventSetup const & /* iSetup */) { MonitorElement * ptTemp,* etaTemp,* phiTemp, *pileupTemp, *tmpME; ibooker.setCurrentFolder("RecoTauV/" + TauProducer_ + extensionName_ + "_ReferenceCollection" ); //Histograms settings hinfo ptHinfo = (histoSettings_.exists("pt")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("pt")) : hinfo(500, 0., 1000.); hinfo etaHinfo = (histoSettings_.exists("eta")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("eta")) : hinfo(60, -3.0, 3.0); hinfo phiHinfo = (histoSettings_.exists("phi")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("phi")) : hinfo(40, -200., 200.); hinfo pileupHinfo = (histoSettings_.exists("pileup")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("pileup")) : hinfo(100, 0., 100.); //hinfo dRHinfo = (histoSettings_.exists("deltaR")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("deltaR")) : hinfo(10, 0., 0.5); // What kind of Taus do we originally have! ptTemp = ibooker.book1D("nRef_Taus_vs_ptTauVisible", "nRef_Taus_vs_ptTauVisible", ptHinfo.nbins, ptHinfo.min, ptHinfo.max); etaTemp = ibooker.book1D("nRef_Taus_vs_etaTauVisible", "nRef_Taus_vs_etaTauVisible", etaHinfo.nbins, etaHinfo.min, etaHinfo.max ); phiTemp = ibooker.book1D("nRef_Taus_vs_phiTauVisible", "nRef_Taus_vs_phiTauVisible", phiHinfo.nbins, phiHinfo.min, phiHinfo.max); pileupTemp = ibooker.book1D("nRef_Taus_vs_pileupTauVisible", "nRef_Taus_vs_pileupTauVisible", pileupHinfo.nbins, pileupHinfo.min, pileupHinfo.max); ptTauVisibleMap.insert( std::make_pair( refCollection_,ptTemp)); etaTauVisibleMap.insert( std::make_pair(refCollection_,etaTemp)); phiTauVisibleMap.insert( std::make_pair(refCollection_,phiTemp)); pileupTauVisibleMap.insert( std::make_pair(refCollection_,pileupTemp)); // Number of Tau Candidates matched to MC Taus ibooker.setCurrentFolder("RecoTauV/"+ TauProducer_ + extensionName_ + "_Matched"); ptTemp = ibooker.book1D(TauProducer_ +"Matched_vs_ptTauVisible", TauProducer_ +"Matched_vs_ptTauVisible", ptHinfo.nbins, ptHinfo.min, ptHinfo.max); etaTemp = ibooker.book1D(TauProducer_ +"Matched_vs_etaTauVisible", TauProducer_ +"Matched_vs_etaTauVisible", etaHinfo.nbins, etaHinfo.min, etaHinfo.max ); phiTemp = ibooker.book1D(TauProducer_ +"Matched_vs_phiTauVisible", TauProducer_ +"Matched_vs_phiTauVisible", phiHinfo.nbins, phiHinfo.min, phiHinfo.max ); pileupTemp = ibooker.book1D(TauProducer_ +"Matched_vs_pileupTauVisible", TauProducer_ +"Matched_vs_pileupTauVisible", pileupHinfo.nbins, pileupHinfo.min, pileupHinfo.max); ptTauVisibleMap.insert( std::make_pair( TauProducer_+"Matched" ,ptTemp)); etaTauVisibleMap.insert( std::make_pair(TauProducer_+"Matched" ,etaTemp)); phiTauVisibleMap.insert( std::make_pair(TauProducer_+"Matched" ,phiTemp)); pileupTauVisibleMap.insert( std::make_pair(TauProducer_+"Matched" ,pileupTemp)); for ( std::vector< edm::ParameterSet >::iterator it = discriminators_.begin(); it!= discriminators_.end(); it++) { string DiscriminatorLabel = it->getParameter<string>("discriminator"); std::string histogramName; stripDiscriminatorLabel(DiscriminatorLabel, histogramName); ibooker.setCurrentFolder("RecoTauV/" + TauProducer_ + extensionName_ + "_" + DiscriminatorLabel ); ptTemp = ibooker.book1D(DiscriminatorLabel + "_vs_ptTauVisible", histogramName +"_vs_ptTauVisible", ptHinfo.nbins, ptHinfo.min, ptHinfo.max); etaTemp = ibooker.book1D(DiscriminatorLabel + "_vs_etaTauVisible", histogramName + "_vs_etaTauVisible", etaHinfo.nbins, etaHinfo.min, etaHinfo.max ); phiTemp = ibooker.book1D(DiscriminatorLabel + "_vs_phiTauVisible", histogramName + "_vs_phiTauVisible", phiHinfo.nbins, phiHinfo.min, phiHinfo.max); pileupTemp = ibooker.book1D(DiscriminatorLabel + "_vs_pileupTauVisible", histogramName + "_vs_pileupTauVisible", pileupHinfo.nbins, pileupHinfo.min, pileupHinfo.max); ptTauVisibleMap.insert( std::make_pair(DiscriminatorLabel,ptTemp)); etaTauVisibleMap.insert( std::make_pair(DiscriminatorLabel,etaTemp)); phiTauVisibleMap.insert( std::make_pair(DiscriminatorLabel,phiTemp)); pileupTauVisibleMap.insert( std::make_pair(DiscriminatorLabel,pileupTemp)); tmpME = ibooker.book1D(DiscriminatorLabel + "_TauCandMass", histogramName + "_TauCandMass" + ";Cand Mass" + ";Frequency", 30, 0., 2.0); plotMap_.insert( std::make_pair( DiscriminatorLabel + "_TauCandMass", tmpME ) ); // momentum resolution for several decay modes std::string plotType = "_pTRatio_";//use underscores (this allows to parse plot type in later stages) std::string xaxisLabel = ";p_{T}^{reco}/p_{T}^{gen}"; std::string yaxislabel = ";Frequency"; std::string plotName = plotType + "allHadronic"; int bins = 40; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "oneProng0Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "oneProng1Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "oneProng2Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "twoProng0Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "twoProng1Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "twoProng2Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "threeProng0Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "threeProng1Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); // Tau Multiplicity for several decay modes plotType = "_nTaus_";//use underscores (this allows to parse plot type in later stages) xaxisLabel = ";Tau Multiplicity"; yaxislabel = ";Frequency"; plotName = plotType + "allHadronic"; bins = 50; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "oneProng0Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "oneProng1Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "oneProng2Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "twoProng0Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "twoProng1Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "twoProng2Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "threeProng0Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "threeProng1Pi0"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); //size and sumPt within tau isolation plotType = "_Size_"; xaxisLabel = ";size"; yaxislabel = ";Frequency"; bins = 20; plotName = plotType + "signalPFCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "signalPFChargedHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "signalPFNeutrHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "isolationPFCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "isolationPFChargedHadrCands"; bins = 10; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "isolationPFNeutrHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "isolationPFGammaCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotType = "_SumPt_"; xaxisLabel = ";p_{T}^{sum}/ GeV"; yaxislabel = ";Frequency"; bins = 20; plotName = plotType + "signalPFCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "signalPFChargedHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "signalPFNeutrHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "isolationPFCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "isolationPFChargedHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 10.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "isolationPFNeutrHadrCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 30.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); plotName = plotType + "isolationPFGammaCands"; tmpME = ibooker.book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 20.); plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) ); //deprecated! if ( DiscriminatorLabel.find("LeadingTrackPtCut") != string::npos){ if ( TauProducer_.find("PFTau") != string::npos) { nPFJet_LeadingChargedHadron_ChargedHadronsSignal_ =ibooker.book1D(DiscriminatorLabel + "_ChargedHadronsSignal",DiscriminatorLabel + "_ChargedHadronsSignal", 21, -0.5, 20.5); nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_ =ibooker.book1D(DiscriminatorLabel + "_ChargedHadronsIsolAnnulus",DiscriminatorLabel + "_ChargedHadronsIsolAnnulus", 21, -0.5, 20.5); nPFJet_LeadingChargedHadron_GammasSignal_ =ibooker.book1D(DiscriminatorLabel + "_GammasSignal",DiscriminatorLabel + "_GammasSignal",21, -0.5, 20.5); nPFJet_LeadingChargedHadron_GammasIsolAnnulus_ =ibooker.book1D(DiscriminatorLabel + "_GammasIsolAnnulus",DiscriminatorLabel + "_GammasIsolAnnulus",21, -0.5, 20.5); nPFJet_LeadingChargedHadron_NeutralHadronsSignal_ =ibooker.book1D(DiscriminatorLabel + "_NeutralHadronsSignal",DiscriminatorLabel + "_NeutralHadronsSignal",21, -0.5, 20.5); nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_ =ibooker.book1D(DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",21, -0.5, 20.5); } } if ( DiscriminatorLabel.find("ByIsolationLater") != string::npos ){ if ( TauProducer_.find("PFTau") != string::npos) { nIsolated_NoChargedHadrons_ChargedHadronsSignal_ =ibooker.book1D(DiscriminatorLabel + "_ChargedHadronsSignal",DiscriminatorLabel + "_ChargedHadronsSignal", 21, -0.5, 20.5); nIsolated_NoChargedHadrons_GammasSignal_ =ibooker.book1D(DiscriminatorLabel + "_GammasSignal",DiscriminatorLabel + "_GammasSignal",21, -0.5, 20.5); nIsolated_NoChargedHadrons_GammasIsolAnnulus_ =ibooker.book1D(DiscriminatorLabel + "_GammasIsolAnnulus",DiscriminatorLabel + "_GammasIsolAnnulus",21, -0.5, 20.5); nIsolated_NoChargedHadrons_NeutralHadronsSignal_ =ibooker.book1D(DiscriminatorLabel + "_NeutralHadronsSignal",DiscriminatorLabel + "_NeutralHadronsSignal",21, -0.5, 20.5); nIsolated_NoChargedHadrons_NeutralHadronsIsolAnnulus_ =ibooker.book1D(DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",21, -0.5, 20.5); } } if ( DiscriminatorLabel.find("ByIsolation") != string::npos ){ if ( TauProducer_.find("PFTau") != string::npos) { nIsolated_NoChargedNoGammas_ChargedHadronsSignal_ =ibooker.book1D(DiscriminatorLabel + "_ChargedHadronsSignal",DiscriminatorLabel + "_ChargedHadronsSignal", 21, -0.5, 20.5); nIsolated_NoChargedNoGammas_GammasSignal_ =ibooker.book1D(DiscriminatorLabel + "_GammasSignal",DiscriminatorLabel + "_GammasSignal",21, -0.5, 20.5); nIsolated_NoChargedNoGammas_NeutralHadronsSignal_ =ibooker.book1D(DiscriminatorLabel + "_NeutralHadronsSignal",DiscriminatorLabel + "_NeutralHadronsSignal",21, -0.5, 20.5); nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_ =ibooker.book1D(DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",21, -0.5, 20.5); } } } } void TauTagValidation::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) { if (genericTriggerEventFlag_) { if (genericTriggerEventFlag_->on()) { genericTriggerEventFlag_->initRun(iRun, iSetup); } } } void TauTagValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { if (genericTriggerEventFlag_) { if (!genericTriggerEventFlag_->on()) std::cout<<"TauTagValidation::analyze: No working genericTriggerEventFlag. Did you specify a valid globaltag?"<<std::endl;//move to LogDebug? } numEvents_++; double matching_criteria = -1.0; //Initialize the Tau Multiplicity Counter for ( std::vector< edm::ParameterSet >::iterator it = discriminators_.begin(); it!= discriminators_.end(); it++) { string DiscriminatorLabel = it->getParameter<string>("discriminator"); tauDeacyCountMap_.insert(std::make_pair("allHadronic" + DiscriminatorLabel, 0.)); tauDeacyCountMap_.insert(std::make_pair("oneProng0Pi0" + DiscriminatorLabel, 0.)); tauDeacyCountMap_.insert(std::make_pair("oneProng1Pi0" + DiscriminatorLabel, 0.)); tauDeacyCountMap_.insert(std::make_pair("oneProng2Pi0" + DiscriminatorLabel, 0.)); tauDeacyCountMap_.insert(std::make_pair("twoProng0Pi0" + DiscriminatorLabel, 0.)); tauDeacyCountMap_.insert(std::make_pair("twoProng1Pi0" + DiscriminatorLabel, 0.)); tauDeacyCountMap_.insert(std::make_pair("twoProng2Pi0" + DiscriminatorLabel, 0.)); tauDeacyCountMap_.insert(std::make_pair("threeProng0Pi0" + DiscriminatorLabel, 0.)); tauDeacyCountMap_.insert(std::make_pair("threeProng1Pi0" + DiscriminatorLabel, 0.)); } typedef edm::View<reco::Candidate> genCandidateCollection; // ----------------------- Reference product ----------------------------------------------------------------------- Handle<genCandidateCollection> ReferenceCollection; bool isGen = iEvent.getByToken( refCollectionInputTagToken_, ReferenceCollection ); Handle<VertexCollection> pvHandle; iEvent.getByToken( primaryVertexCollectionToken_, pvHandle ); //TO-DO if (!isGen) { std::cerr << " Reference collection: " << refCollection_ << " not found while running TauTagValidation.cc " << std::endl; return; } if(dataType_ == "Leptons"){ matching_criteria = matchDeltaR_Leptons_; } else { matching_criteria = matchDeltaR_Jets_; } // ------------------------------ PFTauCollection Matched and other discriminators --------------------------------------------------------- if ( TauProducer_.find("PFTau") != string::npos || TauProducer_.find("hpsTancTaus") != string::npos ) { Handle<PFTauCollection> thePFTauHandle; iEvent.getByToken( tauProducerInputTagToken_, thePFTauHandle ); const PFTauCollection *pfTauProduct; pfTauProduct = thePFTauHandle.product(); PFTauCollection::size_type thePFTauClosest; std::map<std::string, MonitorElement *>::const_iterator element = plotMap_.end(); //Run the Reference Collection for (genCandidateCollection::const_iterator RefJet= ReferenceCollection->begin() ; RefJet != ReferenceCollection->end(); RefJet++ ){ ptTauVisibleMap.find(refCollection_)->second->Fill(RefJet->pt()); etaTauVisibleMap.find(refCollection_)->second->Fill(RefJet->eta()); phiTauVisibleMap.find(refCollection_)->second->Fill(RefJet->phi()*180.0/TMath::Pi()); pileupTauVisibleMap.find(refCollection_)->second->Fill(pvHandle->size()); const reco::Candidate *gen_particle = &(*RefJet); double delta=TMath::Pi(); thePFTauClosest = pfTauProduct->size(); for (PFTauCollection::size_type iPFTau=0 ; iPFTau < pfTauProduct->size() ; iPFTau++) { if (algo_->deltaR(gen_particle, & pfTauProduct->at(iPFTau)) < delta){ delta = algo_->deltaR(gen_particle, & pfTauProduct->at(iPFTau)); thePFTauClosest = iPFTau; } } // Skip if there is no reconstructed Tau matching the Reference if (thePFTauClosest == pfTauProduct->size()) continue; double deltaR = algo_->deltaR(gen_particle, & pfTauProduct->at(thePFTauClosest)); // Skip if the delta R difference is larger than the required criteria if (deltaR > matching_criteria && matching_criteria != -1.0) continue; ptTauVisibleMap.find( TauProducer_+"Matched")->second->Fill(RefJet->pt()); etaTauVisibleMap.find( TauProducer_+"Matched" )->second->Fill(RefJet->eta()); phiTauVisibleMap.find( TauProducer_+"Matched" )->second->Fill(RefJet->phi()*180.0/TMath::Pi()); pileupTauVisibleMap.find( TauProducer_+"Matched")->second->Fill(pvHandle->size()); PFTauRef thePFTau(thePFTauHandle, thePFTauClosest); Handle<PFTauDiscriminator> currentDiscriminator; //filter the candidates if(thePFTau->pt() < TauPtCut_ ) continue;//almost deprecated, since recoCuts_ provides more flexibility //reco StringCutObjectSelector<PFTauRef> selectReco(recoCuts_); bool pass = selectReco( thePFTau ); if( !pass ) continue; //gen StringCutObjectSelector<reco::Candidate> selectGen(genCuts_); pass = selectGen( *gen_particle ); if( !pass ) continue; int j = 0; for ( std::vector< edm::ParameterSet >::iterator it = discriminators_.begin(); it!= discriminators_.end(); it++, j++) { string currentDiscriminatorLabel = it->getParameter<string>("discriminator"); iEvent.getByToken( currentDiscriminatorToken_[j], currentDiscriminator ); if ((*currentDiscriminator)[thePFTau] >= it->getParameter<double>("selectionCut")){ ptTauVisibleMap.find( currentDiscriminatorLabel )->second->Fill(RefJet->pt()); etaTauVisibleMap.find( currentDiscriminatorLabel )->second->Fill(RefJet->eta()); phiTauVisibleMap.find( currentDiscriminatorLabel )->second->Fill(RefJet->phi()*180.0/TMath::Pi()); pileupTauVisibleMap.find( currentDiscriminatorLabel )->second->Fill(pvHandle->size()); //fill the momentum resolution plots double tauPtRes = thePFTau->pt()/gen_particle->pt();//WARNING: use only the visible parts! plotMap_.find( currentDiscriminatorLabel + "_pTRatio_allHadronic" )->second->Fill(tauPtRes); //Fill Tau Cand Mass TLorentzVector TAU; TAU.SetPtEtaPhiE(thePFTau->pt(), thePFTau->eta(), thePFTau->phi(), thePFTau->energy()); plotMap_.find( currentDiscriminatorLabel + "_TauCandMass" )->second->Fill(TAU.M()); //Tau Counter, allHadronic mode tauDeacyCountMap_.find( "allHadronic" + currentDiscriminatorLabel)->second++; /* //is there a better way than casting the candidate? const reco::GenJet *tauGenJet = dynamic_cast<const reco::GenJet*>(gen_particle); if(tauGenJet){ std::string genTauDecayMode = JetMCTagUtils::genTauDecayMode(*tauGenJet); // gen_particle is the tauGenJet matched to the reconstructed tau element = plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + genTauDecayMode ); if( element != plotMap_.end() ) element->second->Fill(tauPtRes); tauDeacyCountMap_.find( genTauDecayMode + currentDiscriminatorLabel)->second++; }else{ LogInfo("TauTagValidation") << " Failed to cast the MC candidate."; }*/ if (thePFTau->decayMode() == reco::PFTau::kOneProng0PiZero){ tauDeacyCountMap_.find("oneProng0Pi0" + currentDiscriminatorLabel)->second++; plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + "oneProng0Pi0")->second->Fill(tauPtRes); } else if (thePFTau->decayMode() == reco::PFTau::kOneProng1PiZero){ tauDeacyCountMap_.find("oneProng1Pi0" + currentDiscriminatorLabel)->second++; plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + "oneProng1Pi0")->second->Fill(tauPtRes); } else if (thePFTau->decayMode() == reco::PFTau::kOneProng2PiZero){ tauDeacyCountMap_.find("oneProng2Pi0" + currentDiscriminatorLabel)->second++; plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + "oneProng2Pi0")->second->Fill(tauPtRes); } else if (thePFTau->decayMode() == reco::PFTau::kTwoProng0PiZero){ tauDeacyCountMap_.find("twoProng0Pi0" + currentDiscriminatorLabel)->second++; plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + "twoProng0Pi0")->second->Fill(tauPtRes); } else if (thePFTau->decayMode() == reco::PFTau::kTwoProng1PiZero){ tauDeacyCountMap_.find("twoProng1Pi0" + currentDiscriminatorLabel)->second++; plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + "twoProng1Pi0")->second->Fill(tauPtRes); } else if (thePFTau->decayMode() == reco::PFTau::kTwoProng2PiZero){ tauDeacyCountMap_.find("twoProng2Pi0" + currentDiscriminatorLabel)->second++; plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + "twoProng2Pi0")->second->Fill(tauPtRes); } else if (thePFTau->decayMode() == reco::PFTau::kThreeProng0PiZero){ tauDeacyCountMap_.find("threeProng0Pi0" + currentDiscriminatorLabel)->second++; plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + "threeProng0Pi0")->second->Fill(tauPtRes); } else if (thePFTau->decayMode() == reco::PFTau::kThreeProng1PiZero){ tauDeacyCountMap_.find("threeProng1Pi0" + currentDiscriminatorLabel)->second++; plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + "threeProng1Pi0")->second->Fill(tauPtRes); } //fill: size and sumPt within tau isolation std::string plotType = "_Size_"; element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFCands" ); if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFCands().size() ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFChargedHadrCands" ); if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFChargedHadrCands().size() ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFNeutrHadrCands" ); if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFNeutrHadrCands().size() ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFCands" ); if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFCands().size() ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFChargedHadrCands" ); if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFChargedHadrCands().size() ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFNeutrHadrCands" ); if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFNeutrHadrCands().size() ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFGammaCands" ); if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFGammaCands().size() ); plotType = "_SumPt_"; element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFCands" ); if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFCands() ) ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFChargedHadrCands" ); if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFChargedHadrCands() ) ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFNeutrHadrCands" ); if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFNeutrHadrCands() ) ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFCands" ); if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFCands() ) ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFChargedHadrCands" ); if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFChargedHadrCands() ) ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFNeutrHadrCands" ); if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFNeutrHadrCands() ) ); element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFGammaCands" ); if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFGammaCands() ) ); //deprecated if( TauProducer_.find("PFTau") != string::npos ){ if ( currentDiscriminatorLabel.find("LeadingTrackPtCut") != string::npos){ nPFJet_LeadingChargedHadron_ChargedHadronsSignal_->Fill((*thePFTau).signalPFChargedHadrCands().size()); nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFChargedHadrCands().size()); nPFJet_LeadingChargedHadron_GammasSignal_->Fill((*thePFTau).signalPFGammaCands().size()); nPFJet_LeadingChargedHadron_GammasIsolAnnulus_->Fill((*thePFTau).isolationPFGammaCands().size()); nPFJet_LeadingChargedHadron_NeutralHadronsSignal_->Fill((*thePFTau).signalPFNeutrHadrCands().size()); nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFNeutrHadrCands().size()); } else if ( currentDiscriminatorLabel.find("ByIsolation") != string::npos ){ nIsolated_NoChargedNoGammas_ChargedHadronsSignal_->Fill((*thePFTau).signalPFChargedHadrCands().size()); nIsolated_NoChargedNoGammas_GammasSignal_->Fill((*thePFTau).signalPFGammaCands().size()); nIsolated_NoChargedNoGammas_NeutralHadronsSignal_->Fill((*thePFTau).signalPFNeutrHadrCands().size()); nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFNeutrHadrCands().size()); } } } else { if (chainCuts_) break; } } }//End of Reference Collection Loop //Fill the Tau Multiplicity Histograms for ( std::vector< edm::ParameterSet >::iterator it = discriminators_.begin(); it!= discriminators_.end(); it++){ string currentDiscriminatorLabel = it->getParameter<string>("discriminator"); plotMap_.find(currentDiscriminatorLabel + "_nTaus_allHadronic")->second->Fill(tauDeacyCountMap_.find( "allHadronic" + currentDiscriminatorLabel)->second); plotMap_.find(currentDiscriminatorLabel + "_nTaus_oneProng0Pi0")->second->Fill(tauDeacyCountMap_.find( "oneProng0Pi0" + currentDiscriminatorLabel)->second); plotMap_.find(currentDiscriminatorLabel + "_nTaus_oneProng1Pi0")->second->Fill(tauDeacyCountMap_.find( "oneProng1Pi0" + currentDiscriminatorLabel)->second); plotMap_.find(currentDiscriminatorLabel + "_nTaus_oneProng2Pi0")->second->Fill(tauDeacyCountMap_.find( "oneProng2Pi0" + currentDiscriminatorLabel)->second); plotMap_.find(currentDiscriminatorLabel + "_nTaus_twoProng0Pi0")->second->Fill(tauDeacyCountMap_.find( "twoProng0Pi0" + currentDiscriminatorLabel)->second); plotMap_.find(currentDiscriminatorLabel + "_nTaus_twoProng1Pi0")->second->Fill(tauDeacyCountMap_.find( "twoProng1Pi0" + currentDiscriminatorLabel)->second); plotMap_.find(currentDiscriminatorLabel + "_nTaus_twoProng2Pi0")->second->Fill(tauDeacyCountMap_.find( "twoProng2Pi0" + currentDiscriminatorLabel)->second); plotMap_.find(currentDiscriminatorLabel + "_nTaus_threeProng0Pi0")->second->Fill(tauDeacyCountMap_.find( "threeProng0Pi0" + currentDiscriminatorLabel)->second); plotMap_.find(currentDiscriminatorLabel + "_nTaus_threeProng1Pi0")->second->Fill(tauDeacyCountMap_.find( "threeProng1Pi0" + currentDiscriminatorLabel)->second); } }//End of PFTau Collection If Loop } double TauTagValidation::getSumPt(const std::vector<edm::Ptr<reco::PFCandidate> > & candidates ){ double sumPt = 0.; for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator candidate = candidates.begin(); candidate!=candidates.end(); ++candidate) { sumPt += (*candidate)->pt(); } return sumPt; } bool TauTagValidation::stripDiscriminatorLabel(const std::string& discriminatorLabel, std::string & newLabel) { std::string separatorString = "DiscriminationBy"; std::string::size_type separator = discriminatorLabel.find(separatorString); if(separator==std::string::npos){ separatorString = "Discrimination";//DiscriminationAgainst, keep the 'against' here separator = discriminatorLabel.find(separatorString); if(separator==std::string::npos){ return false; } } std::string prefix = discriminatorLabel.substr(0,separator); std::string postfix = discriminatorLabel.substr(separator+separatorString.size()); newLabel = prefix+postfix; return true; }
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/views/constrained_window_views.h" #include "components/web_modal/web_contents_modal_dialog_manager.h" #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "google_apis/gaia/gaia_auth_util.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/range/range.h" #include "ui/gfx/font.h" #include "ui/gfx/native_widget_types.h" #include "ui/views/background.h" #include "ui/views/controls/label.h" #include "ui/views/controls/link.h" #include "ui/views/controls/styled_label.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/grid_layout.h" #include "ui/views/layout/layout_constants.h" #include "ui/views/widget/widget.h" namespace { // Wrap a view in a fixed-width container. views::View* MakeFixedWidth(views::View* view, int width) { views::View* container = new views::View; views::GridLayout* layout = views::GridLayout::CreatePanel(container); container->SetLayoutManager(layout); layout->AddColumnSet(0)->AddColumn( views::GridLayout::LEADING, views::GridLayout::CENTER, 0, views::GridLayout::FIXED, width, false); layout->StartRow(0, 0); layout->AddView(view, 1, 1, views::GridLayout::FILL, views::GridLayout::FILL); return container; } } // namespace namespace chrome { // Declared in browser_dialogs.h void ShowProfileSigninConfirmationDialog( Browser* browser, content::WebContents* web_contents, Profile* profile, const std::string& username, ui::ProfileSigninConfirmationDelegate* delegate) { ProfileSigninConfirmationDialogViews::ShowDialog(browser, profile, username, delegate); } } // namespace chrome ProfileSigninConfirmationDialogViews::ProfileSigninConfirmationDialogViews( Browser* browser, Profile* profile, const std::string& username, ui::ProfileSigninConfirmationDelegate* delegate) : browser_(browser), profile_(profile), username_(username), delegate_(delegate), prompt_for_new_profile_(true), link_(NULL) { } ProfileSigninConfirmationDialogViews::~ProfileSigninConfirmationDialogViews() {} // static void ProfileSigninConfirmationDialogViews::ShowDialog( Browser* browser, Profile* profile, const std::string& username, ui::ProfileSigninConfirmationDelegate* delegate) { ProfileSigninConfirmationDialogViews* dialog = new ProfileSigninConfirmationDialogViews( browser, profile, username, delegate); ui::CheckShouldPromptForNewProfile( profile, // This callback is guaranteed to be invoked, and once it is, the dialog // owns itself. base::Bind(&ProfileSigninConfirmationDialogViews::Show, base::Unretained(dialog))); } void ProfileSigninConfirmationDialogViews::Show(bool prompt_for_new_profile) { prompt_for_new_profile_ = prompt_for_new_profile; CreateBrowserModalDialogViews( this, browser_->window()->GetNativeWindow())->Show(); } string16 ProfileSigninConfirmationDialogViews::GetWindowTitle() const { return l10n_util::GetStringUTF16( IDS_ENTERPRISE_SIGNIN_TITLE_NEW_STYLE); } string16 ProfileSigninConfirmationDialogViews::GetDialogButtonLabel( ui::DialogButton button) const { return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ? IDS_ENTERPRISE_SIGNIN_CONTINUE_NEW_STYLE : IDS_ENTERPRISE_SIGNIN_CANCEL); } int ProfileSigninConfirmationDialogViews::GetDefaultDialogButton() const { return ui::DIALOG_BUTTON_NONE; } views::View* ProfileSigninConfirmationDialogViews::CreateExtraView() { if (prompt_for_new_profile_) { const string16 create_profile_text = l10n_util::GetStringUTF16( IDS_ENTERPRISE_SIGNIN_CREATE_NEW_PROFILE_NEW_STYLE); link_ = new views::Link(create_profile_text); link_->SetUnderline(false); link_->set_listener(this); link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); } return link_; } bool ProfileSigninConfirmationDialogViews::Accept() { if (delegate_) { delegate_->OnContinueSignin(); delegate_ = NULL; } return true; } bool ProfileSigninConfirmationDialogViews::Cancel() { if (delegate_) { delegate_->OnCancelSignin(); delegate_ = NULL; } return true; } void ProfileSigninConfirmationDialogViews::OnClose() { Cancel(); } ui::ModalType ProfileSigninConfirmationDialogViews::GetModalType() const { return ui::MODAL_TYPE_WINDOW; } void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged( const ViewHierarchyChangedDetails& details) { if (!details.is_add || details.child != this) return; // Layout the labels in a single fixed-width column. SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); // Create the prompt label. std::vector<size_t> offsets; const string16 domain = ASCIIToUTF16(gaia::ExtractDomainName(username_)); const string16 username = ASCIIToUTF16(username_); const string16 prompt_text = l10n_util::GetStringFUTF16( IDS_ENTERPRISE_SIGNIN_ALERT_NEW_STYLE, username, domain, &offsets); views::StyledLabel* prompt_label = new views::StyledLabel(prompt_text, this); views::StyledLabel::RangeStyleInfo bold_style; bold_style.font_style = gfx::Font::BOLD; prompt_label->AddStyleRange( ui::Range(offsets[1], offsets[1] + domain.size()), bold_style); // Add the prompt label with a darker background and border. const int kDialogWidth = 440; views::View* prompt_container = MakeFixedWidth(prompt_label, kDialogWidth); prompt_container->set_border( views::Border::CreateSolidSidedBorder( 1, 0, 1, 0, ui::GetSigninConfirmationPromptBarColor( ui::kSigninConfirmationPromptBarBorderAlpha))); prompt_container->set_background( views::Background::CreateSolidBackground( ui::GetSigninConfirmationPromptBarColor( ui::kSigninConfirmationPromptBarBackgroundAlpha))); AddChildView(prompt_container); // Create and add the explanation label. offsets.clear(); const string16 learn_more_text = l10n_util::GetStringUTF16( IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_LEARN_MORE); const string16 signin_explanation_text = l10n_util::GetStringFUTF16(prompt_for_new_profile_ ? IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITH_PROFILE_CREATION_NEW_STYLE : IDS_ENTERPRISE_SIGNIN_EXPLANATION_WITHOUT_PROFILE_CREATION_NEW_STYLE, username, learn_more_text, &offsets); explanation_label_ = new views::StyledLabel(signin_explanation_text, this); views::StyledLabel::RangeStyleInfo link_style = views::StyledLabel::RangeStyleInfo::CreateForLink(); link_style.font_style = gfx::Font::NORMAL; explanation_label_->AddStyleRange( ui::Range(offsets[1], offsets[1] + learn_more_text.size()), link_style); // TODO(dconnelly): set the background color on the label (crbug.com/244630) AddChildView(MakeFixedWidth(explanation_label_, kDialogWidth)); } void ProfileSigninConfirmationDialogViews::LinkClicked(views::Link* source, int event_flags) { if (delegate_) { delegate_->OnSigninWithNewProfile(); delegate_ = NULL; } GetWidget()->Close(); } void ProfileSigninConfirmationDialogViews::StyledLabelLinkClicked( const ui::Range& range, int event_flags) { chrome::NavigateParams params( browser_, GURL("http://support.google.com/chromeos/bin/answer.py?answer=1331549"), content::PAGE_TRANSITION_LINK); params.disposition = NEW_POPUP; params.window_action = chrome::NavigateParams::SHOW_WINDOW; chrome::Navigate(&params); }
; A110132: a(n) = floor(n/2)^ceiling(n/2). ; 1,0,1,1,4,8,27,81,256,1024,3125,15625,46656,279936,823543,5764801,16777216,134217728,387420489,3486784401,10000000000,100000000000,285311670611,3138428376721,8916100448256,106993205379072,302875106592253,3937376385699289 mov $1,$0 div $1,2 sub $0,$1 pow $1,$0
copyright zengfr site:http://github.com/zengfr/romhack 038FBA add.w D3, D3 [enemy+95] copyright zengfr site:http://github.com/zengfr/romhack
global WinMain extern ExitProcess ; external functions in system libraries extern MessageBoxA section .data title: db 'Win64', 0 msg: db 'Hello world!', 0 section .text WinMain: sub rsp, 28h mov rcx, 0 ; hWnd = HWND_DESKTOP lea rdx,[msg] ; LPCSTR lpText lea r8,[title] ; LPCSTR lpCaption mov r9d, 0 ; uType = MB_OK call MessageBoxA add rsp, 28h mov ecx,eax call ExitProcess hlt ; never here
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r8 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x13fb8, %rsi lea addresses_normal_ht+0x19338, %rdi clflush (%rsi) cmp %rax, %rax mov $108, %rcx rep movsw nop nop nop nop sub %r10, %r10 lea addresses_A_ht+0x2d00, %rbx xor $35299, %rcx movb (%rbx), %r10b nop xor %rdi, %rdi lea addresses_normal_ht+0x1db38, %rsi nop nop nop nop nop cmp $47589, %r8 movl $0x61626364, (%rsi) nop nop nop and $185, %r8 lea addresses_UC_ht+0x1238, %r10 nop nop nop nop nop xor $26836, %rdi mov (%r10), %r8d add %rdi, %rdi lea addresses_WT_ht+0xed38, %rsi lea addresses_WC_ht+0x1a011, %rdi nop nop nop nop and $26795, %r14 mov $28, %rcx rep movsw nop cmp %rdi, %rdi lea addresses_normal_ht+0x53d2, %rcx nop nop nop cmp %rdi, %rdi mov $0x6162636465666768, %r10 movq %r10, %xmm2 and $0xffffffffffffffc0, %rcx vmovntdq %ymm2, (%rcx) dec %rax lea addresses_UC_ht+0x2ab8, %rdi nop cmp $2095, %rsi movl $0x61626364, (%rdi) nop nop nop nop nop sub $50282, %rdi lea addresses_normal_ht+0xf38, %rdi nop nop dec %r8 mov $0x6162636465666768, %r10 movq %r10, %xmm4 movups %xmm4, (%rdi) nop nop nop sub $6638, %rax lea addresses_WC_ht+0x4518, %rbx nop nop and $25995, %r8 movb $0x61, (%rbx) nop sub $3904, %rcx lea addresses_UC_ht+0xc738, %rcx nop nop nop nop nop dec %rdi movups (%rcx), %xmm5 vpextrq $1, %xmm5, %rbx nop nop sub $11579, %r10 lea addresses_D_ht+0x13398, %rax nop nop nop nop cmp $7519, %rsi mov $0x6162636465666768, %r10 movq %r10, (%rax) nop sub $62888, %r10 pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %rbp push %rdi push %rdx // Store lea addresses_D+0xa138, %r11 sub %rdx, %rdx movl $0x51525354, (%r11) nop nop dec %r13 // Faulty Load lea addresses_RW+0x7f38, %r11 and $26656, %rdx movups (%r11), %xmm4 vpextrq $1, %xmm4, %rdi lea oracles, %r11 and $0xff, %rdi shlq $12, %rdi mov (%r11,%rdi,1), %rdi pop %rdx pop %rdi pop %rbp pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_RW', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D', 'congruent': 8}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': True, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_A_ht', 'congruent': 1}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 8}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 7}} {'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_normal_ht', 'congruent': 1}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 6}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 11}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 0}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 10}} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 4}, 'OP': 'STOR'} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
; A245425: Number of nonnegative integers with the property that their base 9/4 expansion (see A024652) has n digits. ; 9,18,36,81,180,405,918,2061,4635,10431,23472,52812,118827,267363,601560,1353510,3045402,6852150,15417342,34689015,78050286,175613148,395129583,889041555,2000343501,4500772875,10126738971,22785162687,51266616048,115349886108 mov $20,$0 mov $22,$0 add $22,1 lpb $22 clr $0,20 mov $0,$20 sub $22,1 sub $0,$22 mov $17,$0 mov $19,$0 add $19,1 lpb $19 mov $0,$17 sub $19,1 sub $0,$19 mov $13,$0 mov $15,2 lpb $15 mov $0,$13 sub $15,1 add $0,$15 sub $0,1 mov $9,$0 mov $11,2 lpb $11 mov $0,$9 sub $11,1 add $0,$11 sub $0,1 mov $5,$0 mov $7,2 lpb $7 mov $0,$5 sub $7,1 add $0,$7 sub $0,1 mov $2,1 lpb $0 sub $0,1 mul $2,9 sub $2,1 div $2,4 add $2,1 lpe mov $3,1 mul $3,$2 mov $1,$3 mov $8,$7 lpb $8 mov $6,$1 sub $8,1 lpe lpe lpb $5 mov $5,0 sub $6,$1 lpe mov $1,$6 mov $12,$11 lpb $12 mov $10,$1 sub $12,1 lpe lpe lpb $9 mov $9,0 sub $10,$1 lpe mov $1,$10 mov $16,$15 lpb $16 mov $14,$1 sub $16,1 lpe lpe lpb $13 mov $13,0 sub $14,$1 lpe mov $1,$14 mul $1,9 add $18,$1 lpe add $21,$18 lpe mov $1,$21
/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "src/tracing/test/mock_producer.h" #include "perfetto/ext/tracing/core/trace_writer.h" #include "perfetto/ext/tracing/core/tracing_service.h" #include "perfetto/protozero/scattered_heap_buffer.h" #include "perfetto/tracing/core/data_source_config.h" #include "perfetto/tracing/core/data_source_descriptor.h" #include "protos/perfetto/common/track_event_descriptor.pbzero.h" #include "src/base/test/test_task_runner.h" using ::testing::_; using ::testing::Eq; using ::testing::Invoke; using ::testing::InvokeWithoutArgs; using ::testing::Property; namespace perfetto { namespace { static DataSourceDescriptor CreateDataSourceDescriptor( const std::initializer_list<std::string>& categories, uint32_t id) { DataSourceDescriptor ds_desc; ds_desc.set_name("track_event"); ds_desc.set_id(id); protozero::HeapBuffered<protos::pbzero::TrackEventDescriptor> ted; for (auto c : categories) { auto cat = ted->add_available_categories(); cat->set_name(c); } ds_desc.set_track_event_descriptor_raw(ted.SerializeAsString()); return ds_desc; } } // anonymous namespace MockProducer::MockProducer(base::TestTaskRunner* task_runner) : task_runner_(task_runner) {} MockProducer::~MockProducer() { if (!service_endpoint_) return; static int i = 0; auto checkpoint_name = "on_producer_disconnect_" + std::to_string(i++); auto on_disconnect = task_runner_->CreateCheckpoint(checkpoint_name); EXPECT_CALL(*this, OnDisconnect()).WillOnce(Invoke(on_disconnect)); service_endpoint_.reset(); task_runner_->RunUntilCheckpoint(checkpoint_name); } void MockProducer::Connect(TracingService* svc, const std::string& producer_name, uid_t uid, pid_t pid, size_t shared_memory_size_hint_bytes, size_t shared_memory_page_size_hint_bytes, std::unique_ptr<SharedMemory> shm) { producer_name_ = producer_name; service_endpoint_ = svc->ConnectProducer( this, uid, pid, producer_name, shared_memory_size_hint_bytes, /*in_process=*/true, TracingService::ProducerSMBScrapingMode::kDefault, shared_memory_page_size_hint_bytes, std::move(shm)); auto checkpoint_name = "on_producer_connect_" + producer_name; auto on_connect = task_runner_->CreateCheckpoint(checkpoint_name); EXPECT_CALL(*this, OnConnect()).WillOnce(Invoke(on_connect)); task_runner_->RunUntilCheckpoint(checkpoint_name); } void MockProducer::RegisterDataSource(const std::string& name, bool ack_stop, bool ack_start, bool handle_incremental_state_clear) { DataSourceDescriptor ds_desc; ds_desc.set_name(name); ds_desc.set_will_notify_on_stop(ack_stop); ds_desc.set_will_notify_on_start(ack_start); ds_desc.set_handles_incremental_state_clear(handle_incremental_state_clear); service_endpoint_->RegisterDataSource(ds_desc); } void MockProducer::UnregisterDataSource(const std::string& name) { service_endpoint_->UnregisterDataSource(name); } void MockProducer::RegisterTrackEventDataSource( const std::initializer_list<std::string>& categories, uint32_t id) { service_endpoint_->RegisterDataSource( CreateDataSourceDescriptor(categories, id)); } void MockProducer::UpdateTrackEventDataSource( const std::initializer_list<std::string>& categories, uint32_t id) { service_endpoint_->UpdateDataSource( CreateDataSourceDescriptor(categories, id)); } void MockProducer::RegisterTraceWriter(uint32_t writer_id, uint32_t target_buffer) { service_endpoint_->RegisterTraceWriter(writer_id, target_buffer); } void MockProducer::UnregisterTraceWriter(uint32_t writer_id) { service_endpoint_->UnregisterTraceWriter(writer_id); } void MockProducer::WaitForTracingSetup() { static int i = 0; auto checkpoint_name = "on_shmem_initialized_" + producer_name_ + "_" + std::to_string(i++); auto on_tracing_enabled = task_runner_->CreateCheckpoint(checkpoint_name); EXPECT_CALL(*this, OnTracingSetup()).WillOnce(Invoke(on_tracing_enabled)); task_runner_->RunUntilCheckpoint(checkpoint_name); } void MockProducer::WaitForDataSourceSetup(const std::string& name) { static int i = 0; auto checkpoint_name = "on_ds_setup_" + name + "_" + std::to_string(i++); auto on_ds_start = task_runner_->CreateCheckpoint(checkpoint_name); EXPECT_CALL(*this, SetupDataSource(_, Property(&DataSourceConfig::name, Eq(name)))) .WillOnce(Invoke([on_ds_start, this](DataSourceInstanceID ds_id, const DataSourceConfig& cfg) { EXPECT_FALSE(data_source_instances_.count(cfg.name())); auto target_buffer = static_cast<BufferID>(cfg.target_buffer()); auto session_id = static_cast<TracingSessionID>(cfg.tracing_session_id()); data_source_instances_.emplace( cfg.name(), EnabledDataSource{ds_id, target_buffer, session_id}); on_ds_start(); })); task_runner_->RunUntilCheckpoint(checkpoint_name); } void MockProducer::WaitForDataSourceStart(const std::string& name) { static int i = 0; auto checkpoint_name = "on_ds_start_" + name + "_" + std::to_string(i++); auto on_ds_start = task_runner_->CreateCheckpoint(checkpoint_name); EXPECT_CALL(*this, StartDataSource(_, Property(&DataSourceConfig::name, Eq(name)))) .WillOnce(Invoke([on_ds_start, this](DataSourceInstanceID ds_id, const DataSourceConfig& cfg) { // The data source might have been seen already through // WaitForDataSourceSetup(). if (data_source_instances_.count(cfg.name()) == 0) { auto target_buffer = static_cast<BufferID>(cfg.target_buffer()); auto session_id = static_cast<TracingSessionID>(cfg.tracing_session_id()); data_source_instances_.emplace( cfg.name(), EnabledDataSource{ds_id, target_buffer, session_id}); } on_ds_start(); })); task_runner_->RunUntilCheckpoint(checkpoint_name); } void MockProducer::WaitForDataSourceStop(const std::string& name) { static int i = 0; auto checkpoint_name = "on_ds_stop_" + name + "_" + std::to_string(i++); auto on_ds_stop = task_runner_->CreateCheckpoint(checkpoint_name); ASSERT_EQ(1u, data_source_instances_.count(name)); DataSourceInstanceID ds_id = data_source_instances_[name].id; EXPECT_CALL(*this, StopDataSource(ds_id)) .WillOnce(InvokeWithoutArgs(on_ds_stop)); task_runner_->RunUntilCheckpoint(checkpoint_name); data_source_instances_.erase(name); } std::unique_ptr<TraceWriter> MockProducer::CreateTraceWriter( const std::string& data_source_name) { PERFETTO_DCHECK(data_source_instances_.count(data_source_name)); BufferID buf_id = data_source_instances_[data_source_name].target_buffer; return service_endpoint_->CreateTraceWriter(buf_id); } void MockProducer::WaitForFlush(TraceWriter* writer_to_flush, bool reply) { std::vector<TraceWriter*> writers; if (writer_to_flush) writers.push_back(writer_to_flush); WaitForFlush(writers, reply); } void MockProducer::WaitForFlush(std::vector<TraceWriter*> writers_to_flush, bool reply) { auto& expected_call = EXPECT_CALL(*this, Flush(_, _, _)); expected_call.WillOnce(Invoke( [this, writers_to_flush, reply](FlushRequestID flush_req_id, const DataSourceInstanceID*, size_t) { for (auto* writer : writers_to_flush) writer->Flush(); if (reply) service_endpoint_->NotifyFlushComplete(flush_req_id); })); } DataSourceInstanceID MockProducer::GetDataSourceInstanceId( const std::string& name) { auto it = data_source_instances_.find(name); return it == data_source_instances_.end() ? 0 : it->second.id; } const MockProducer::EnabledDataSource* MockProducer::GetDataSourceInstance( const std::string& name) { auto it = data_source_instances_.find(name); return it == data_source_instances_.end() ? nullptr : &it->second; } } // namespace perfetto
; A142180: Primes congruent to 35 mod 39. ; Submitted by Jon Maiga ; 113,191,269,347,503,659,971,1049,1283,1361,1439,1907,2063,2141,2297,2531,2609,2687,2843,2999,3389,3467,3623,3701,3779,4013,4091,4481,4637,4793,4871,5261,5417,5573,5651,5807,6197,6353,6899,6977,7211,7523,7757,8069,8147,8537,8693,8849,9161,9239,9473,9551,9629,9941,10253,10331,10487,10799,11423,11579,11657,11813,11969,12203,12281,12437,12671,12983,13217,13451,13763,13841,13997,14153,14387,14543,14621,14699,15401,15791,16103,16493,16649,16883,17117,17351,18131,18287,18443,18521,18911,19301,19379 mov $1,19 mov $2,$0 add $2,2 pow $2,2 lpb $2 sub $1,2 sub $2,2 mov $3,$1 mul $3,2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,41 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mul $1,2 mov $0,$1 sub $0,81
# Test program ASSIGN @value 5 :start_loop PRINT "Counting " @value SUB @value 1 NOT_EQUAL @is_equal @value 0 IF @is_equal :start_loop PRINT "Loop done!"