hexsha stringlengths 40 40 | size int64 6 1.05M | ext stringclasses 3 values | lang stringclasses 1 value | max_stars_repo_path stringlengths 4 232 | max_stars_repo_name stringlengths 7 106 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 7 | max_stars_count int64 1 33.5k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 232 | max_issues_repo_name stringlengths 7 106 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 7 | max_issues_count int64 1 37.5k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 232 | max_forks_repo_name stringlengths 7 106 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 7 | max_forks_count int64 1 12.6k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 6 1.05M | avg_line_length float64 1.16 19.7k | max_line_length int64 2 938k | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5ddcf6e7d0a0f6a2967de5f1dcfc477a1c53651d | 2,579 | asm | Assembly | source/video.asm | wilsonpilon/msx-menu | 21110eb2e93ed033ed95d80f282b869c09f3714b | [
"Apache-2.0"
] | null | null | null | source/video.asm | wilsonpilon/msx-menu | 21110eb2e93ed033ed95d80f282b869c09f3714b | [
"Apache-2.0"
] | null | null | null | source/video.asm | wilsonpilon/msx-menu | 21110eb2e93ed033ed95d80f282b869c09f3714b | [
"Apache-2.0"
] | null | null | null | ;***** Imprime uma string armazenada em RAM (STR) na SCREEN IV ***************
; POSY e passada via BASIC representa a linha da impressao
; POSX tambem passada via BASIC representa a coluna
; WIDT e calculada em outras rotinas que usam NPRIN e tem o tamanho da string
PTSTR:
call CALCXY ;Posiciona VRAM
ex de,hl ;Swap de registradores
ld a,[WIDT]
ld b,0
ld c,a
ld hl,STR
call LDIRVM
ret
;***** Calcula o endereco da VRAM a partir de POSX e POSY ********************
CALCXY:
ld a,[POSY] ;Linha inicial
ld h,a
ld e,32 ;WIDTH do programa (SCREENIV)
call MULHXE
ld a,[POSX] ;Coluna inicial
ld e,a
ld d,0
add hl,de
ld de,1800h ;Tabela de nomes (SCREEN IV)
add hl,de
ret
;***** SVSCR *****************************************************************
; Salva a tela corrente na RAM para auxiliar no tracado de pseudo janelas
SVSCR:
ld bc,768 ;Tamanho da SCREEN IV
ld de,SCRN ;Destino na RAM
ld hl,1800h ;Inicio tabela de nomes
call LDIRMV ;Transfere
ret
;***** LDSCR *****************************************************************
; Carrega tela da RAM na corrente para auxiliar no tracado de pseudo janelas
LDSRC:
ld bc,768 ;Tamanho da SCREEN IV
ld de,1800h ;Inicio tabela de nomes
ld hl,SCRN ;Origem na RAM
call LDIRVM ;Transfere
ret
;***** Rotina para impressao de String na Screen IV **************************
NPRIN:
call LDSTR ;Carrega a string de USR em STR
call PTSTR ;Chama rotina de impressao
ret
;***** Inverte uma String e a imprime na Screen IV ***************************
IPRIN:
call LDSTR ;Carrega a string de USR em STR
ld a,[SLEN] ;Tamanho da STRING
ld b,a ;Laco para inverter STRING
ld hl,STR ;Endereco da STRING
.loop:
ld a,[hl] ;Aponta para o caractere
add a,96 ;Desloca para o invertido
ld [hl],a ;Troca o original
inc hl ;proximo caracter
djnz .loop ;laco
call PTSTR ;Chama rotina de impressao
ret
| 38.492537 | 79 | 0.459868 |
e8e21cb5b850d0caf30d375015132e66c32c693c | 407 | asm | Assembly | programs/oeis/194/A194050.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/194/A194050.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/194/A194050.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | ; A194050: Natural fractal sequence of A014739.
; 1,1,2,3,1,2,3,4,1,2,3,4,5,6,7,1,2,3,4,5,6,7,8,9,10,11,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,1,2,3,4,5,6,7,8,9,10
mov $3,$0
add $0,1
mov $2,$3
lpb $0,1
mov $1,$0
add $0,$2
sub $0,$3
trn $0,1
mov $2,$1
sub $2,3
sub $3,1
add $3,$1
add $3,1
sub $3,$1
lpe
| 21.421053 | 199 | 0.555283 |
fe95ee854d377f502f50a27f95dbbccfd4023192 | 749 | asm | Assembly | learn-assembly/asm101/asm101-16.asm | hailehong95/Practice-Coding | 729acdd596f15657b717975bfa54da1e39114f8a | [
"MIT"
] | null | null | null | learn-assembly/asm101/asm101-16.asm | hailehong95/Practice-Coding | 729acdd596f15657b717975bfa54da1e39114f8a | [
"MIT"
] | null | null | null | learn-assembly/asm101/asm101-16.asm | hailehong95/Practice-Coding | 729acdd596f15657b717975bfa54da1e39114f8a | [
"MIT"
] | null | null | null | ; asm101-16: Chuoi nghich dao
.model small
.stack 100h
.data
str1 db 'Nhap chuoi: $'
str2 db 13,10,'Chuoi nghich dao: $'
.code
main proc
mov ax, @data
mov ds, ax
mov ah, 09h
lea dx, str1
int 21h
mov cx,0
input:
mov ah, 1
int 21h
cmp al,13 ; 13 = enter
je stop
push ax ; Day vao ngan xep
inc cx ; cx = cx+1
jmp input ; nhay khong dieu kien
stop:
cmp cx,0
je input
mov ah,9
lea dx, str2
int 21h
mov ah,2
display:
pop dx ; Lay ra tu ngan xep
int 21h
loop display ; So lan lap bang gia tri trong thanh ghi cx
; end
mov ah, 4ch
int 21h
main endp
end main
| 15.604167 | 64 | 0.512684 |
a4bbcf1e6f723390ac8d601f636d0faab7d6fcc5 | 4,994 | asm | Assembly | MASM/12date.asm | iamvk1437k/mpmc | 3640b29f29b3ffa78747b13b2ca8ac77c49695eb | [
"MIT"
] | 1 | 2022-01-01T11:27:43.000Z | 2022-01-01T11:27:43.000Z | MASM/12date.asm | iamvk1437k/mpmc | 3640b29f29b3ffa78747b13b2ca8ac77c49695eb | [
"MIT"
] | null | null | null | MASM/12date.asm | iamvk1437k/mpmc | 3640b29f29b3ffa78747b13b2ca8ac77c49695eb | [
"MIT"
] | null | null | null | ASSUME CS:CODE, DS:DATA ; code and data segment initialization
DATA SEGMENT
YY DW ?
MM DB ?
D DB ?
TDAY DW SUN,MON,TUE,WED,THU,FRI,SAT ; define the days of the week
SUN DB'SUNDAY,$'
MON DB'MONDAY,$'
TUE DB'TUESDAY,$'
WED DB'WEDNESDAY,$'
THU DB'THURSDAY,$'
FRI DB'FRIDAY,$'
SAT DB'SATURDAY,$'
TMON DW JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC ; define the months of the year
JAN DB'JANUARY,$'
FEB DB'FEBRUARY,$'
MAR DB'MARCH,$'
APR DB'APRIL,$'
MAY DB 'MAY,$'
JUN DB 'JUNE,$'
JUL DB 'JULY,$'
AUG DB 'AUGUST,$'
SEP DB 'SEPTEMBER,$'
OCT DB 'OCTOBER,$'
NOV DB 'NOVEMBER,$'
DCMB DB 'DECEMBER,$'
DATA ENDS ; end of data segment
CODE SEGMENT
DISCHAR MACRO CHAR
PUSH AX ; save AX
PUSH DX ;save DX
MOV DL,CHAR ;display the character
MOV AH,02H ;move 02 to AH
INT 21H
POP DX ;restore DX
POP AX ;restore AX
ENDM ;end of main
START: MOV AX,DATA ; initialize data segment
MOV DS,AX
CALL FAR PTR PDATE ; display code
MOV AH,4CH ;exit to dos
INT 21H
PDATE PROC FAR ; move 2a to AH
MOV AH,2AH
INT 21H
MOV [YY],CX ; save year
MOV [MM],DH ; save month
MOV [D],DL ; save day
MOV AH,0 ;get a day of the week
ROL AX,1 ; rotate right accumulator
MOV SI,OFFSET TDAY ;address day table
ADD SI,AX ;add SI and AX
MOV DX, [SI] ;address day of week
MOV AH,09H ; display day of week
INT 21H
MOV AL,[D] ; get day of month
MOV AH,00H ; clear the contents of AH
AAM
OR AH,AH ; convert to BCD
JZ DIGIT0 ; if tens is 0
ADD AH,30H ; convert tens
DISCHAR AH ; display tens
DIGIT0: ADD AL,30H ; convert units
DISCHAR AL ; display units
DISCHAR ' ' ; leave space
MOV AL,[MM] ; get month
SUB AL,1 ; sub the contents of al with 1
MOV AH,0 ; move 0 to AH
ROL AX,1 ; rotate accumulator
MOV SI,OFFSET TMON ; address month table
ADD SI,AX ;add SI and AX contents
MOV DX, [SI] ; address month
MOV AH,09H ;display month
INT 21H
MOV AX,[YY] ; read year
CMP AX,07D0H ; check for year 2000
JB DIS19 ; if below year 2000
SUB AX,07D0H ; scale for 00-99
DISCHAR '2' ; display 2
DISCHAR '0' ; display 0
JMP SKIP
DIS19: SUB AX,076CH ; scale 1900-1999
DISCHAR '1' ; display 1
DISCHAR '9' ; display 9
SKIP: AAM ; convert to BCD
ADD AX,3030H ; convert to ASCII
DISCHAR AH ; display tens
DISCHAR AL ; display units
RET ; return
PDATE ENDP
CODE ENDS
END START ; end of program
| 53.698925 | 99 | 0.31678 |
ac5acb39521ff6b6fb96ff3397d744b4a4d4337a | 15,486 | asm | Assembly | base/ntos/ke/amd64/intsup.asm | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | base/ntos/ke/amd64/intsup.asm | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | base/ntos/ke/amd64/intsup.asm | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | TITLE "Interrupt Object Support Routines"
;++
;
; Copyright (c) 2000 Microsoft Corporation
;
; Module Name:
;
; intsup.asm
;
; Abstract:
;
; This module implements the platform specific code to support interrupt
; objects. It contains the interrupt dispatch code and the code template
; that gets copied into an interrupt object.
;
; Author:
;
; David N. Cutler (davec) 19-Jun-2000
;
; Environment:
;
; Kernel mode only.
;
;--
include ksamd64.inc
extern KeBugCheck:proc
extern KiInitiateUserApc:proc
extern __imp_HalEndSystemInterrupt:qword
subttl "Synchronize Execution"
;++
;
; BOOLEAN
; KeSynchronizeExecution (
; IN PKINTERRUPT Interrupt,
; IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine,
; IN PVOID SynchronizeContext
; )
;
; Routine Description:
;
; This function synchronizes the execution of the specified routine with
; the execution of the service routine associated with the specified
; interrupt object.
;
; Arguments:
;
; Interrupt (rcx) - Supplies a pointer to an interrupt object.
;
; SynchronizeRoutine (rdx) - Supplies a pointer to the function whose
; execution is to be synchronized with the execution of the service
; routine associated with the specified interrupt object.
;
; SynchronizeContext (r8) - Supplies a context pointer which is to be
; passed to the synchronization function as a parameter.
;
; Return Value:
;
; The value returned by the synchronization routine is returned as the
; function value.
;
;--
SyFrame struct
P1Home dq ? ; parameter home address
OldIrql dd ? ; saved IRQL
Fill dd ? ; fill
syFrame ends
NESTED_ENTRY KeSynchronizeExecution, _TEXT$00
push_reg rsi ; save nonvolatile register
alloc_stack (sizeof SyFrame) ; allocate stack frame
END_PROLOGUE
mov rsi, rcx ; save interrupt object address
movzx ecx, byte ptr InSynchronizeIrql[rsi] ; get synchronization IRQL
RaiseIrql ; raise IRQL to synchronization level
mov SyFrame.OldIrql[rsp], eax ; save previous IRQL
AcquireSpinLock InActualLock[rsi] ; acquire interrupt spin lock
mov rcx, r8 ; set synchronization context
call rdx ; call synchronization routine
ReleaseSpinlock InActualLock[rsi] ; release interrutp spin lock
mov ecx, SyFrame.OldIrql[rsp] ; get previous IRQL
LowerIrql ; lower IRQL to previous level
add rsp, sizeof SyFrame ; deallocate stack frame
pop rsi ; restore nonvolatile register
ret ;
NESTED_END KeSynchronizeExecution, _TEXT$00
subttl "Interrupt Exception Handler"
;++
;
; EXCEPTION_DISPOSITION
; KiInterruptHandler (
; IN PEXCEPTION_RECORD ExceptionRecord,
; IN PVOID EstablisherFrame,
; IN OUT PCONTEXT ContextRecord,
; IN OUT PDISPATCHER_CONTEXT DispatcherContext
; )
;
; Routine Description:
;
; This routine is the exception handler for the interrupt dispatcher. The
; dispatching or unwinding of an exception across an interrupt causes a
; bug check.
;
; Arguments:
;
; ExceptionRecord (rcx) - Supplies a pointer to an exception record.
;
; EstablisherFrame (rdx) - Supplies the frame pointer of the establisher
; of this exception handler.
;
; ContextRecord (r8) - Supplies a pointer to a context record.
;
; DispatcherContext (r9) - Supplies a pointer to the dispatcher context
; record.
;
; Return Value:
;
; There is no return from this routine.
;
;--
IhFrame struct
P1Home dq ? ; parameter home address
IhFrame ends
NESTED_ENTRY KiInterruptHandler, _TEXT$00
alloc_stack (sizeof IhFrame) ; allocate stack frame
END_PROLOGUE
test dword ptr ErExceptionFlags[rcx], EXCEPTION_UNWIND ; test for unwind
mov ecx, INTERRUPT_UNWIND_ATTEMPTED ; set bug check code
jnz short KiIH10 ; if nz, unwind in progress
mov ecx, INTERRUPT_EXCEPTION_NOT_HANDLED ; set bug check code
KiIH10: call KeBugCheck ; bug check - no return
nop ; fill - do not remove
NESTED_END KiInterruptHandler, _TEXT$00
subttl "Chained Dispatch"
;++
;
; VOID
; KiChainedDispatch (
; VOID
; );
;
; Routine Description:
;
; This routine is entered as the result of an interrupt being generated
; via a vector that is connected to more than one interrupt object.
;
; Arguments:
;
; rbp - Supplies a pointer to the interrupt object.
;
; Return Value:
;
; None.
;
;--
NESTED_ENTRY KiChainedDispatch, _TEXT$00, KiInterruptHandler
.pushframe code ; mark machine frame
.pushreg rbp ; mark mark nonvolatile register push
GENERATE_INTERRUPT_FRAME ; generate interrupt frame
movzx ecx, byte ptr InIrql[rsi] ; set interrupt IRQL
ENTER_INTERRUPT <NoEOI> ; raise IRQL and enable interrupts
call KiScanInterruptObjectList ; scan interrupt object list
EXIT_INTERRUPT ; do EOI, lower IRQL, and restore state
NESTED_END KiChainedDispatch, _TEXT$00
subttl "Scan Interrupt Object List"
;++
;
; Routine Description:
;
; This routine scans the list of interrupt objects for chained interrupt
; dispatch. If the mode of the interrupt is latched, then a complete scan
; of the list must be performed. Otherwise, the scan can be cut short as
; soon as an interrupt routine returns
;
; Arguments:
;
; rsi - Supplies a pointer to the interrupt object.
;
; Return Value:
;
; None.
;
;--
SiFrame struct
P1Home dq ? ; interrupt object parameter
P2Home dq ? ; service context parameter
Return db ? ; service routine return value
Fill db 15 dup (?) ; fill
SavedRbx dq ? ; saved register RBX
SavedRdi dq ? ; saved register RDI
SavedR12 dq ? ; saved register RSI
SiFrame ends
NESTED_ENTRY KiScanInterruptObjectList, _TEXT$00
push_reg r12 ; save nonvolatile registers
push_reg rdi ;
push_reg rbx ;
alloc_stack (sizeof SiFrame - (3 * 8)) ; allocate stack frame
END_PROLOGUE
lea rbx, InInterruptListEntry[rsi] ; get list head address
mov r12, rbx ; set address of first list entry
;
; Scan the list of connected interrupt objects and call the service routine.
;
Si05: xor edi, edi ; clear interrupt handled flag
Si10: sub r12, InInterruptListEntry ; compute interrupt object address
movzx ecx, byte ptr InSynchronizeIrql[r12] ; get synchronization IRQL
cmp cl, InIrql[rsi] ; check if equal interrupt IRQL
je short Si20 ; if e, IRQL levels equal
SetIrql ; set IRQL to synchronization level
Si20: AcquireSpinLock InActualLock[r12] ; acquire interrupt spin lock
mov rcx, r12 ; set interrupt object parameter
mov rdx, InServiceContext[r12] ; set context parameter
call qword ptr InServiceRoutine[r12] ; call interrupt service routine
mov SiFrame.Return[rsp], al ; save return value
ReleaseSpinLock InActualLock[r12] ; release interrupt spin lock
movzx ecx, byte ptr InIrql[rsi] ; get interrupt IRQL
cmp cl, InSynchronizeIrql[r12] ; check if equal synchronization IRQL
je short Si30 ; if e, IRQL levels equal
SetIrql ; set IRQL to interrupt level
Si30: test byte ptr SiFrame.Return[rsp], 0ffh ; test if interrupt handled
jz short Si40 ; if z, interrupt not handled
cmp word ptr InMode[r12], InLatched ; check if latched interrupt
jne short Si50 ; if ne, not latched interrupt
inc edi ; indicate latched interrupt handled
Si40: mov r12, InInterruptListEntry[r12] ; get next interrupt list entry
cmp r12, rbx ; check if end of list
jne Si10 ; if ne, not end of list
;
; The complete interrupt object list has been scanned. This can only happen
; if the interrupt is a level sensitive interrupt and no interrupt was handled
; or the interrupt is a latched interrupt. Therefore, if any interrupt was
; handled it was a latched interrupt and the list needs to be scanned again
; to ensure that no interrupts are lost.
;
test edi, edi ; test if any interrupts handled
jnz Si05 ; if nz, latched interrupt handled
Si50: add rsp, sizeof SiFrame - (3 * 8) ; deallocate stack frame
pop rbx ; restore nonvolatile register
pop rdi ;
pop r12 ;
ret ;
NESTED_END KiscanInterruptObjectList, _TEXT$00
subttl "Interrupt Dispatch"
;++
;
; Routine Description:
;
; This routine is entered as the result of an interrupt being generated
; via a vector that is connected to an interrupt object. Its function is
; to directly call the specified interrupt service routine.
;
; This routine is identical to KiInterruptDispatchNoLock except that
; the interrupt spinlock is taken.
;
; N.B. On entry rbp and rsi have been saved on the stack.
;
; Arguments:
;
; rbp - Supplies a pointer to the interrupt object.
;
; Return Value:
;
; None.
;
;--
NESTED_ENTRY KiInterruptDispatch, _TEXT$00, KiInterruptHandler
.pushframe code ; mark machine frame
.pushreg rbp ; mark mark nonvolatile register push
GENERATE_INTERRUPT_FRAME ; generate interrupt frame
;
; N.B. It is possible for a interrupt to occur at an IRQL that is lower
; than the current IRQL. This happens when the IRQL raised and at
; the same time an interrupt request is granted.
;
movzx ecx, byte ptr InIrql[rsi] ; set interrupt IRQL
ENTER_INTERRUPT <NoEOI> ; raise IRQL and enable interrupts
lea rax, (-128)[rbp] ; set trap frame address
mov InTrapFrame[rsi], rax ;
AcquireSpinLock InActualLock[rsi] ; acquire interrupt spin lock
mov rcx, rsi ; set address of interrupt object
mov rdx, InServiceContext[rsi] ; set service context
call qword ptr InServiceRoutine[rsi] ; call interrupt service routine
ReleaseSpinLock InActualLock[rsi] ; release interrupt spin lock
EXIT_INTERRUPT ; do EOI, lower IRQL, and restore state
NESTED_END KiInterruptDispatch, _TEXT$00
subttl "Interrupt Dispatch, No Lock"
;++
;
; Routine Description:
;
; This routine is entered as the result of an interrupt being generated
; via a vector that is connected to an interrupt object. Its function is
; to directly call the specified interrupt service routine.
;
; This routine is identical to KiInterruptDispatch except that no spinlock
; is taken.
;
; N.B. On entry rbp and rsi have been saved on the stack.
;
; Arguments:
;
; rbp - Supplies a pointer to the interrupt object.
;
; Return Value:
;
; None.
;
;--
NESTED_ENTRY KiInterruptDispatchNoLock, _TEXT$00, KiInterruptHandler
.pushframe code ; mark machine frame
.pushreg rbp ; mark mark nonvolatile register push
GENERATE_INTERRUPT_FRAME ; generate interrupt frame
;
; N.B. It is possible for a interrupt to occur at an IRQL that is lower
; than the current IRQL. This happens when the IRQL raised and at
; the same time an interrupt request is granted.
;
movzx ecx, byte ptr InIrql[rsi] ; set interrupt IRQL
ENTER_INTERRUPT <NoEOI> ; raise IRQL and enable interrupts
lea rax, (-128)[rbp] ; set trap frame address
mov InTrapFrame[rsi], rax ;
mov rcx, rsi ; set address of interrupt object
mov rdx, InServiceContext[rsi] ; set service context
call qword ptr InServiceRoutine[rsi] ; call interrupt service routine
EXIT_INTERRUPT ; do EOI, lower IRQL, and restore state
NESTED_END KiInterruptDispatchNoLock, _TEXT$00
subttl "Disable Processor Interrupts"
;++
;
; BOOLEAN
; KeDisableInterrupts(
; VOID
; )
;
; Routine Description:
;
; This function saves the state of the interrupt enable flag, clear the
; state of the interrupt flag (disables interrupts), and return the old
; inerrrupt enable flag state.
;
; Arguments:
;
; None.
;
; Return Value:
;
; If interrupts were previously enabled, then 1 is returned as the function
; value. Otherwise, 0 is returned.
;
;--
DiFrame struct
Flags dd ? ; processor flags
Fill dd ? ; fill
DiFrame ends
NESTED_ENTRY KeDisableInterrupts, _TEXT$00
push_eflags ; push processor flags
END_PROLOGUE
mov eax, DiFrame.Flags[rsp] ; isolate interrupt enable bit
shr eax, EFLAGS_IF_SHIFT ;
and al, 1 ;
cli ; disable interrupts
add rsp, sizeof DiFrame ; deallocate stack frame
ret ; return
NESTED_END KeDisableInterrupts, _TEXT$00
subttl "Interrupt Template"
;++
;
; Routine Description:
;
; This routine is a template that is copied into each interrupt object.
; Its function is to save volatile machine state, compute the interrupt
; object address, and transfer control to the appropriate interrupt
; dispatcher.
;
; N.B. Interrupts are disabled on entry to this routine.
;
; Arguments:
;
; None.
;
; Return Value:
;
; N.B. Control does not return to this routine. The respective interrupt
; dispatcher dismisses the interrupt directly.
;
;--
LEAF_ENTRY KiInterruptTemplate, _TEXT$00
push rax ; push dummy vector number
push rbp ; save nonvolatile register
lea rbp, KiInterruptTemplate - InDispatchCode ; get interrupt object address
jmp qword ptr InDispatchAddress[rbp] ; finish in common code
LEAF_END KiInterruptTemplate, _TEXT$00
end
| 32.195426 | 89 | 0.603577 |
4abd1b7c9bd476de59ba89440a8a434a23573247 | 10,876 | asm | Assembly | Test/ZXSP/template_z80.asm | sparks-c16/zasm | c03a31c6d7ec2c2aecb1d6dc6b4ced73b7cf00c4 | [
"BSD-2-Clause"
] | 43 | 2019-12-06T23:46:40.000Z | 2022-03-31T15:34:44.000Z | Test/ZXSP/template_z80.asm | sparks-c16/zasm | c03a31c6d7ec2c2aecb1d6dc6b4ced73b7cf00c4 | [
"BSD-2-Clause"
] | 21 | 2019-12-27T01:49:08.000Z | 2022-03-31T15:38:42.000Z | Test/ZXSP/template_z80.asm | sparks-c16/zasm | c03a31c6d7ec2c2aecb1d6dc6b4ced73b7cf00c4 | [
"BSD-2-Clause"
] | 13 | 2019-12-27T00:38:46.000Z | 2022-03-15T08:34:51.000Z | #!/usr/local/bin/zasm -o original/
; ================================================================
; Example file for target 'z80'
; Emulator snapshot format for Sinclair computers
; Copyright (c) Günter Woigk 1994 - 2015
; mailto:kio@little-bat.de
; ================================================================
; space is filled with 0x00
;
; The first code segment must contain the z80 header data and must be properly set up.
; Header size may be 30 (v1, deprecated), 55 (v2.01) or 86 to 88 (v3 recommended).
; Ram segments have an additional argument: the pageID. see pageID description.
; Segment size must be 16k except for b&w models. see pageID description.
; All ram pages must be saved.
; Roms may be included if a non-standard rom is used.
#target z80
; ---------------------------------------------------
; .z80 header: saved machine state
; ---------------------------------------------------
; header length:
z80v1len equ 30
z80v2len equ 55
z80v3len equ 86
z80maxlen equ z80v3len+3
; first segment must be the header segment:
;
#code HEADER, 0, z80v3len
dw 0 ; af
dw 0 ; bc
dw 0 ; hl
dw 0 ; pc_in_z80v1 0x0000 => header z80v2 or higher
dw stack_end ; sp
db $3f,0 ; i, r
db 0 ; data Bit 0 : Bit 7 of the R-register
; Bit 1-3 : Border colour
; Bit 4 : 1 = Basic SamRom switched in
; Bit 5 : 1 = Block of data is compressed
; Bit 6-7 : unused
dw 0 ; de
dw 0 ; bc'
dw 0 ; de'
dw 0 ; hl'
dw 0 ; af'
dw 0 ; iy
dw 0 ; ix
db 0,0 ; iff1,iff2
db 1 ; im Bit 0-1 : Interrupt mode (0, 1 or 2)
; Bit 2 : 1 = Issue 2 emulation / 60 Hz model
; Bit 3 : 1 = Double interrupt frequency
; Bit 4-5 : 1 = High video synchronisation
; 3 = Low video synchronisation
; 0,2 = Normal
; Bit 6-7 : 0 = Cursor/Protek/AGF joystick
; 1 = Kempston joystick
; 2 = Sinclair 2 left joystick (or user defined, for z80v3)
; 3 = Sinclair 2 right joystick
; Z80 version 2.01:
dw z80v3len-z80v1len-2 ; h2len = size of header extension: 23 for z80v2
dw code_start ; pc
db 0 ; model 0 = ZX Spectrum 48k
;
; Value Meaning in v2.01 Meaning in v3.0 ldiremu.bit7 im.bit2
; 0 48k 48k 16k issue2
; 1 48k + If.1 48k + If.1 16k issue2
; 2 SamRam SamRam 16k issue2
; 3 128k 48k + M.G.T. 16k issue2
; 4 128k + If.1 128k +2 .
; 5 - 128k + If.1 +2 .
; 6 - 128k + M.G.T. +2 .
; 7,8 - +3 +2A .
; 9 - Pentagon 128k . .
; 10 - Scorpion 256k . .
; 11 - Didaktik-Kompakt . .
; 12 - +2 . .
; 13 - +2A . .
; 14 - TC2048 . .
; 15 - TC2068 . .
; *zxsp* 76 - TK85 . .
; *zxsp* 77 - TS1000 . 60 Hz
; *zxsp* 78 - TS1500 . 60 Hz
; *zxsp* 80 - ZX80 . 60 Hz
; *zxsp* 81 - ZX81 . 60 Hz
; *zxsp* 83 - Jupiter ACE . 60 Hz
; *zxsp* 84 - Inves 48k . .
; *zxsp* 85 - +128 Span. . .
; *zxsp* 86 - Sam Coupé . .
; *zxsp* 87 - +2 Spanish . .
; *zxsp* 88 - +2 French . .
; *zxsp* 89 - +3 Spanish . .
; *zxsp* 90 - +2A Spanish . .
; *zxsp* 91 - tk90x . .
; *zxsp* 92 - tk95 . .
; 128 - TS2068 . .
db 0 ; port_7ffd or port_f4
; If in SamRam mode, bitwise state of 74ls259.
; For example, bit 6=1 after an OUT 31,13 (=2*6+1)
; If in 128 mode, contains last OUT to 7ffd (paging control)
; if timex ts2068: last out to port 244
db 0 ; if1paged or port_ff
; !=0 means: interface1 rom is paged in
; if timex ts2068: last out to port 255
db 7 ; rldiremu Bit 0: 1 if R register emulation on
; Bit 1: 1 if LDIR emulation on
; Bit 2: AY sound in use, even on 48K machines
; *zxsp* Bit 3: SPECTRA interface present, can only add to 48k models
; *zxsp* Bit 5: if zxsp, then present a ZX Spectrum Plus
; Bit 6: (if bit 2 set) Fuller Audio Box emulation
; Bit 7: Modify hardware (see below)
db 0 ; port_fffd Last OUT to fffd (soundchip register number)
ds 16 ; soundreg[16] Contents of the sound chip registers
; Z80 version 3.0:
db 0,0,0 ; t_l,t_m,t_h T state counter
; The hi T state counter counts up modulo 4. Just after the ULA generates its
; 50 Hz interrupt, it is 3, and is increased by one every 5 emulated milliseconds.
; In these 1/200s intervals, the low T state counter counts down from 17471 to 0 (17726 in 128K modes),
; which make a total of 69888 (70908) T states per frame.
db 0 ; spectator Flag byte used by Spectator QL Specci emulator.
; *zxsp* ram size (in kB) for b&w models ID 76 to 83. 0 = default ram size (no memory expansion).
db 0 ; mgt_paged 0xFF if MGT Rom paged
db 0 ; multiface_paged 0xFF if Multiface Rom paged. Should always be 0.
db 0,0 ; ram0,ram1 0xFF if 0-8191 / 8192-16383 is ROM
ds 10 ; joy[10] 5* ascii word: keys for user defined joystick
ds 10 ; stick[10] 5* keyboard mappings corresponding to keys above
db 0 ; mgt_type MGT type: 0=Disciple+Epson,1=Disciple+HP,16=Plus D
db 0 ; disciple_inhibit_button_status 0=out, 0xFF=in
db 0 ; disciple_inhibit_flag 0=rom pageable, 0xFF=not
; warajewo/xzx extension if PC=0 & h2len≥55:
; db 0 ; port_1ffd last out to $1ffd (bank switching on +3)
; zxsp extension if PC=0 & h2len≥57:
; db 0 ; spectra_bits if SPECTRA present:
; *zxsp* Bit 0: new colour modes enabled
; *zxsp* Bit 1: RS232 enabled
; *zxsp* Bit 2: Joystick enabled
; *zxsp* Bit 3: IF1 rom hooks enabled
; *zxsp* Bit 4: rom paged in
; *zxsp* Bit 5: port 239: Comms out bit
; *zxsp* Bit 6: port 239: CTS out bit
; *zxsp* Bit 7: port 247: Data out bit
; db 0 ; spectra_port_7fdf if SPECTRA present:
; *zxsp* last out to port 7FDF (colour mode register)
; ---------------------------------------------------
; saved ram (and rom) pages
; ---------------------------------------------------
; The pages are numbered, depending on the hardware mode, in the following way:
;
; PageID 48 mode 128 mode SamRam mode varying_pagesize
; 0 48K rom rom (basic) 48K rom -
; 1 Interface I, Disciple or Plus D rom, according to setting -
; 2 rom (reset) samram rom (basic) -
; 3 - page 0 samram rom (monitor) 1k
; 4 8000-bfff page 1 Normal 8000-bfff 2k
; 5 c000-ffff page 2 Normal c000-ffff 4k
; 6 - page 3 Shadow 8000-bfff 8k
; 7 - page 4 Shadow c000-ffff 16k
; 8 4000-7fff page 5 4000-7fff 32k
; 9 - page 6 - 64k
; 10 - page 7 - 128k
; 11 Multiface rom Multiface rom - -
;*zxsp* 12 SPECTRA rom SPECTRA rom SPECTRA rom -
;*zxsp* 13 SPECTRA ram[0] SPECTRA ram[0] SPECTRA ram[0] -
;*zxsp* 14 SPECTRA ram[1] SPECTRA ram[1] SPECTRA ram[1] -
;
; In 16k mode, only page 8 is saved.
; In 48k mode, pages 4, 5 and 8 are saved.
; In SamRam mode, pages 4 to 8 must be saved.
; In 128 mode, all pages from 3 to 10 are saved.
;
; The 128 has a memory map like: Rom [switchable]; Ram 5; Ram 2; Ram [switchable, reset=0]
;
; Some models (Russian) have more than 128k of ram. They can have ram page IDs from 3+0 up to 3+31 (up to 512k ram).
;
; b&w models ID 76 to 83 (TK85, TS1000, TS1500, ZX80, ZX81, Jupiter ACE) have a 'varying ram size'.
; their ram is saved in one block of 1k, 2k, 4k, 8k, 16k, 32k, 64k and 128k each as required to sum up to the actual ram size.
; maximum ram size which can be saved this way is 255k: 1+2+4+8+16+32+64+128=255. (actually they have 64k at most.)
; these ram pages may occur in any order. They are concatenated in sequence of occurance when loaded,
; so e.g. for a 48k ram you have the choice to save the 16k or the 32k chunk first, whichever fits your memory layout better.
; page IDs:
; misc. roms visible at 0x0000:
; note: listed for completeness. roms are almost never saved in a snapshot!
pageID_48k_rom equ 0
pageID_128k_basic_rom equ 0
pageID_128k_boot_rom equ 2
pageID_if1_rom equ 1
pageID_disciple_rom equ 1
pageID_plusD_rom equ 1
pageID_multiface_rom equ 11
pageID_spectra_rom equ 12 ; *zxsp*
pageID_spectra_ram0 equ 13 ; *zxsp*
pageID_spectra_ram1 equ 14 ; *zxsp*
pageID_samram_basic_rom equ 2
pageID_samram_monitor_rom equ 3
pageID_samram_shadow_ram_0x8000 equ 6
pageID_samram_shadow_ram_0xC000 equ 7
; 48k model (not pageable) ram:
pageID_48k_ram_0x4000 equ 8
pageID_48k_ram_0x8000 equ 4
pageID_48k_ram_0xC000 equ 5
; 128k models with pageable ram:
pageID_128k_ram_page0 equ 3
pageID_128k_ram_page1 equ 4
pageID_128k_ram_page2 equ 5
pageID_128k_ram_page3 equ 6
pageID_128k_ram_page4 equ 7
pageID_128k_ram_page5 equ 8
pageID_128k_ram_page6 equ 9
pageID_128k_ram_page7 equ 10
pageID_128k_ram_0x4000 equ pageID_128k_ram_page5
pageID_128k_ram_0x8000 equ pageID_128k_ram_page2
; b&w models with varying ram size:
pageID_var_ram_1k equ 3
pageID_var_ram_2k equ 4
pageID_var_ram_4k equ 5
pageID_var_ram_8k equ 6
pageID_var_ram_16k equ 7
pageID_var_ram_32k equ 8
pageID_var_ram_64k equ 9
pageID_var_ram_128k equ 10
; ---------------------------------------------------
; contended ram: video ram & rarely used code
; pageID for 48k Specci (set in header.model above)
; ---------------------------------------------------
#code SLOW_RAM, 0x4000, 0x4000, pageID_48k_ram_0x4000
pixels_start: defs 0x1800
attr_start: defs 0x300
code_start:
; define some rarely used machine code here
; e.g. initialization code
; ---------------------------------------------------
; fast ram: frequently used code,
; variables and machine stack
; must be segmented into 16k chunks for .z80 file
; pageIDs for 48k Specci (set in header.model above)
; ---------------------------------------------------
#code RAM_0x8000, 0x8000, 0x4000, pageID_48k_ram_0x8000
stack_bot: defs 0x100
stack_end: equ $
; define some variables here
; define some machine code here
#code RAM_0xC000, 0xC000, 0x4000, pageID_48k_ram_0xC000
; define some variables here
; define some machine code here
| 35.083871 | 127 | 0.574476 |
5e6847166d666d42cae513f0413cdccbd3098ea8 | 591 | asm | Assembly | programs/oeis/131/A131579.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/131/A131579.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/131/A131579.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | ; A131579: Period 10: repeat 0, 3, 6, 9, 2, 5, 8, 1, 4, 7.
; 0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5,8,1,4,7
mov $1,$0
mul $1,3
mod $1,10
| 84.428571 | 501 | 0.502538 |
3f8d100331e7d7f270ca71aafaeaa819bb8f9021 | 1,028 | asm | Assembly | programs/oeis/091/A091818.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/091/A091818.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/091/A091818.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | ; A091818: Sum of even proper divisors of 2n. Sum of the even divisors of 2n that are less than 2n.
; 0,2,2,6,2,12,2,14,8,16,2,32,2,20,18,30,2,42,2,44,22,28,2,72,12,32,26,56,2,84,2,62,30,40,26,110,2,44,34,100,2,108,2,80,66,52,2,152,16,86,42,92,2,132,34,128,46,64,2,216,2,68,82,126,38,156,2,116,54,148,2,246,2,80,98,128,38,180,2,212,80,88,2,280,46,92,66,184,2,288,42,152,70,100,50,312,2,146,114,234,2,228,2,212,174,112,2,344,2,212,82,272,2,252,58,188,130,124,50,480,24,128,90,200,62,372,2,254,94,244,2,408,54,140,210,268,2,300,2,392,102,148,50,518,70,152,162,236,2,444,2,296,162,268,74,472,2,164,114,436,62,402,2,260,246,172,2,624,28,308,178,272,2,372,146,392,126,184,2,732,2,308,130,352,86,396,58,296,262,340,2,632,2,200,282,406,2,540,2,530,142,208,74,600,94,212,210,452,62,732,2,332,150,220,98,768,78,224,154,568,62,468,2,560,356,232,2,664,2,404,306,436,2,624,106,368,166,388,2,1008,2,314,242,380,194,516,66,464,174,436
cal $0,62967 ; a(n) = 2*(sigma(n)-n-1)+1, where sigma = A000203, sum of divisors of n.
add $0,1
mov $1,$0
| 146.857143 | 820 | 0.688716 |
ed1ce5d75de22be9c34fe4c3fba95f42fb0fd35a | 372 | asm | Assembly | programs/oeis/188/A188861.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/188/A188861.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | programs/oeis/188/A188861.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | ; A188861: Number of n X 4 binary arrays without the pattern 0 1 diagonally, vertically or antidiagonally.
; 16,41,68,95,122,149,176,203,230,257,284,311,338,365,392,419,446,473,500,527,554,581,608,635,662,689,716,743,770,797,824,851,878,905,932,959,986,1013,1040,1067,1094,1121,1148,1175,1202,1229,1256,1283,1310,1337,1364
mov $1,81
mul $1,$0
trn $1,6
div $1,3
add $1,16
| 41.333333 | 215 | 0.739247 |
5bf5b4092a9ab4ee61972c1bbe2801989bbe0794 | 491 | asm | Assembly | programs/oeis/008/A008344.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/008/A008344.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/008/A008344.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A008344: a(1)=0; thereafter a(n+1) = a(n) - n if a(n) >= n otherwise a(n+1) = a(n) + n.
; 0,1,3,0,4,9,3,10,2,11,1,12,0,13,27,12,28,11,29,10,30,9,31,8,32,7,33,6,34,5,35,4,36,3,37,2,38,1,39,0,40,81,39,82,38,83,37,84,36,85,35,86,34,87,33,88,32,89,31,90,30,91,29,92,28,93,27,94,26,95,25,96,24,97,23,98,22,99,21,100,20,101,19,102,18,103,17,104,16,105,15,106,14,107,13,108,12,109,11,110
lpb $0
sub $0,1
add $3,71724
mov $2,$3
div $2,2
add $1,$2
mod $1,$3
lpe
div $1,35862
mov $0,$1
| 35.071429 | 292 | 0.594705 |
03d1cc1737eaf20f11926e4f751172348bce0b5e | 6,636 | asm | Assembly | Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_21829_1154.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 9 | 2020-08-13T19:41:58.000Z | 2022-03-30T12:22:51.000Z | Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_21829_1154.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 1 | 2021-04-29T06:29:35.000Z | 2021-05-13T21:02:30.000Z | Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_21829_1154.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 3 | 2020-07-14T17:07:07.000Z | 2022-03-21T01:12:22.000Z | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x1ad26, %r9
dec %r8
mov $0x6162636465666768, %rcx
movq %rcx, %xmm4
and $0xffffffffffffffc0, %r9
movntdq %xmm4, (%r9)
nop
nop
nop
nop
nop
xor %r10, %r10
lea addresses_D_ht+0x49c6, %rsi
lea addresses_WC_ht+0x12996, %rdi
nop
xor $53342, %rbp
mov $9, %rcx
rep movsl
nop
cmp $50296, %rbp
lea addresses_WT_ht+0xa847, %rbp
nop
nop
nop
nop
sub $57505, %r10
movb $0x61, (%rbp)
nop
nop
nop
nop
nop
inc %rbp
lea addresses_WC_ht+0x136de, %rsi
lea addresses_WT_ht+0x1e326, %rdi
nop
cmp %r10, %r10
mov $102, %rcx
rep movsw
nop
nop
nop
cmp $57765, %rsi
lea addresses_WC_ht+0x11b26, %r9
nop
nop
nop
nop
nop
dec %rdi
and $0xffffffffffffffc0, %r9
movntdqa (%r9), %xmm2
vpextrq $1, %xmm2, %rsi
nop
inc %rcx
lea addresses_WT_ht+0x17666, %r10
sub %r9, %r9
mov $0x6162636465666768, %rdi
movq %rdi, (%r10)
sub %rcx, %rcx
lea addresses_WT_ht+0xc326, %rsi
lea addresses_normal_ht+0xc326, %rdi
clflush (%rdi)
add %rdx, %rdx
mov $126, %rcx
rep movsl
nop
nop
sub $63012, %rsi
lea addresses_normal_ht+0xa326, %rsi
lea addresses_D_ht+0x3526, %rdi
nop
nop
nop
xor $25359, %r9
mov $93, %rcx
rep movsq
lfence
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
// REPMOV
lea addresses_normal+0x811e, %rsi
lea addresses_A+0xa126, %rdi
nop
add %rbx, %rbx
mov $96, %rcx
rep movsb
nop
nop
nop
nop
sub %r8, %r8
// Store
lea addresses_normal+0xd326, %rbx
nop
add %r13, %r13
movl $0x51525354, (%rbx)
nop
nop
nop
nop
nop
dec %rdi
// Faulty Load
lea addresses_normal+0x1ab26, %rdi
nop
nop
inc %rcx
movups (%rdi), %xmm3
vpextrq $1, %xmm3, %r13
lea oracles, %rdi
and $0xff, %r13
shlq $12, %r13
mov (%rdi,%r13,1), %r13
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A', 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
| 38.137931 | 2,999 | 0.662749 |
21607cc0f49b4392884bfa7c3737bea8b183b5ea | 2,341 | asm | Assembly | scripts/silvercave.asm | adhi-thirumala/EvoYellow | 6fb1b1d6a1fa84b02e2d982f270887f6c63cdf4c | [
"Unlicense"
] | null | null | null | scripts/silvercave.asm | adhi-thirumala/EvoYellow | 6fb1b1d6a1fa84b02e2d982f270887f6c63cdf4c | [
"Unlicense"
] | null | null | null | scripts/silvercave.asm | adhi-thirumala/EvoYellow | 6fb1b1d6a1fa84b02e2d982f270887f6c63cdf4c | [
"Unlicense"
] | null | null | null | SilverCaveScript:
call EnableAutoTextBoxDrawing
ld hl, SilverCaveTrainerHeaders
ld de, SilverCaveScriptPointers
ld a, [wRoute4CurScript]
call ExecuteCurMapScriptInTable
ld [wRoute4CurScript], a
ret
;this is all pretty much just terrible junk coding. >_> however, I did eventually get it to work.
SilverCaveScriptPointers:
dw CheckFightingMapTrainers
dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilverCaveTextPointers:
dw SilverCaveText1
dw SilverCaveText2
SilverCaveTrainerHeaders:
SilverCaveTrainerHeader1:
dbEventFlagBit EVENT_BEAT_ROUTE_4_TRAINER_1 ;actually this one already exists elsewhere >_> don't feel like risking having it not work due to being on the 'wrong' spote or whatevs though, annoying thing. not that it worked well...
db ($2 << 4) ; trainer's view range, 4 << 4 for instance.
dwEventFlagAddress EVENT_BEAT_ROUTE_4_TRAINER_1
dw SilverCaveBattleText1 ; TextBeforeBattle
dw SilverCaveAfterBattleText1 ; TextAfterBattle
dw SilverCaveEndBattleText1 ; TextEndBattle
dw SilverCaveEndBattleText1 ; TextEndBattle
SilverCaveTrainerHeader2:
dbEventFlagBit EVENT_BEAT_ROUTE_4_TRAINER_0
db ($0 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROUTE_4_TRAINER_0
dw SilverCaveBattleText2 ; TextBeforeBattle
dw SilverCaveAfterBattleText2 ; TextAfterBattle
dw SilverCaveEndBattleText2 ; TextEndBattle
dw SilverCaveEndBattleText2 ; TextEndBattle
db $ff
SilverCaveText1:
TX_ASM
ld hl, SilverCaveTrainerHeader1
jr SilverCaveTalkToTrainer2
SilverCaveText2:
TX_ASM
ld hl, SilverCaveTrainerHeader2
SilverCaveTalkToTrainer:
call TalkToTrainer
SetEvent EVENT_BEAT_ROUTE_4_TRAINER_0
jp TextScriptEnd
SilverCaveTalkToTrainer2:
call TalkToTrainer
SetEvent EVENT_BEAT_ROUTE_4_TRAINER_1
jp TextScriptEnd
SilverCaveBattleText1:
TX_FAR _SilverCaveBattleText1
db "@"
SilverCaveEndBattleText1:
;SetEvent EVENT_BEAT_ROUTE_4_TRAINER_0
TX_FAR _SilverCaveEndBattleText1
db "@"
SilverCaveAfterBattleText1:
;SetEvent EVENT_BEAT_ROUTE_4_TRAINER_0
TX_FAR _SilverCaveAfterBattleText1
db "@"
SilverCaveBattleText2:
TX_FAR _SilverCaveBattleText2
db "@"
SilverCaveEndBattleText2:
; SetEvent EVENT_BEAT_ROUTE_4_TRAINER_1
TX_FAR _SilverCaveEndBattleText2
db "@"
SilverCaveAfterBattleText2:
; SetEvent EVENT_BEAT_ROUTE_4_TRAINER_1
TX_FAR _SilverCaveAfterBattleText2
db "@"
| 27.541176 | 231 | 0.840666 |
85d78b01b0645008c3374c7a58f832737233cfe0 | 489 | asm | Assembly | libsrc/msx/gen_get_vdp_reg.asm | andydansby/z88dk-mk2 | 51c15f1387293809c496f5eaf7b196f8a0e9b66b | [
"ClArtistic"
] | 1 | 2020-09-15T08:35:49.000Z | 2020-09-15T08:35:49.000Z | libsrc/msx/gen_get_vdp_reg.asm | andydansby/z88dk-MK2 | 51c15f1387293809c496f5eaf7b196f8a0e9b66b | [
"ClArtistic"
] | null | null | null | libsrc/msx/gen_get_vdp_reg.asm | andydansby/z88dk-MK2 | 51c15f1387293809c496f5eaf7b196f8a0e9b66b | [
"ClArtistic"
] | null | null | null | ;
; z88dk library: Generic VDP support code
;
; void get_vdp_reg(int reg)
;
;==============================================================
; Gets the value of a VDP register
;==============================================================
;
; $Id: gen_get_vdp_reg.asm,v 1.1 2010/06/30 13:21:38 stefano Exp $
;
XLIB get_vdp_reg
XREF RG0SAV
get_vdp_reg:
;;return *(u_char*)(RG0SAV + reg);
; (FASTCALL) -> HL = address
ld de,RG0SAV
add hl,de
ld a,(hl)
ld h,0
ld l,a
ret
| 15.774194 | 66 | 0.478528 |
a65e95db573502510d7c5f38da77ea7270d018f2 | 676 | asm | Assembly | ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibV7Support.asm | nicklela/edk2 | dfafa8e45382939fb5dc78e9d37b97b500a43613 | [
"Python-2.0",
"Zlib",
"BSD-2-Clause",
"MIT",
"BSD-2-Clause-Patent",
"BSD-3-Clause"
] | 3,012 | 2015-01-01T19:58:18.000Z | 2022-03-31T22:07:14.000Z | ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibV7Support.asm | nicklela/edk2 | dfafa8e45382939fb5dc78e9d37b97b500a43613 | [
"Python-2.0",
"Zlib",
"BSD-2-Clause",
"MIT",
"BSD-2-Clause-Patent",
"BSD-3-Clause"
] | 1,199 | 2015-01-12T08:00:01.000Z | 2022-03-29T18:14:42.000Z | ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibV7Support.asm | nicklela/edk2 | dfafa8e45382939fb5dc78e9d37b97b500a43613 | [
"Python-2.0",
"Zlib",
"BSD-2-Clause",
"MIT",
"BSD-2-Clause-Patent",
"BSD-3-Clause"
] | 1,850 | 2015-01-01T11:28:12.000Z | 2022-03-31T18:10:59.000Z | //------------------------------------------------------------------------------
//
// Copyright (c) 2016, Linaro Limited. All rights reserved.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
//------------------------------------------------------------------------------
INCLUDE AsmMacroExport.inc
//------------------------------------------------------------------------------
RVCT_ASM_EXPORT ArmHasMpExtensions
mrc p15,0,R0,c0,c0,5
// Get Multiprocessing extension (bit31)
lsr R0, R0, #31
bx LR
RVCT_ASM_EXPORT ArmReadIdMmfr0
mrc p15, 0, r0, c0, c1, 4 ; Read ID_MMFR0 Register
bx lr
END
| 25.037037 | 81 | 0.39497 |
03aa245ba0c12d94871a875329d6734604815696 | 1,404 | asm | Assembly | 5e05/5e05.asm | sqph/td-micl | fbd130a6a741a38945c80bd8a1c2cfa7105754bd | [
"Unlicense"
] | null | null | null | 5e05/5e05.asm | sqph/td-micl | fbd130a6a741a38945c80bd8a1c2cfa7105754bd | [
"Unlicense"
] | null | null | null | 5e05/5e05.asm | sqph/td-micl | fbd130a6a741a38945c80bd8a1c2cfa7105754bd | [
"Unlicense"
] | null | null | null | ; 5e05.asm
global main
section .rodata
fichier DB `brol`, 0 ; nom du fichier
section .bss
descr RESD 1 ; descripteur de fichier
section .text
main:
mov eax, 5 ; numéro de service: 5 (open)
mov ebx, fichier ; adresse du nom du fichier
mov ecx, 0q ; RDONLY
int 0x80
bt eax, 31
jnc _ok
jmp _erreur
_ok:
mov dword [descr], eax ;sauvegarde eax (descripteur fichier)
mov eax, 19 ; lseek(?)
mov ebx, [descr] ; descripteur fichier
mov ecx, 0 ; offset
mov edx, 2 ; SEEK_END
int 0x80
bt eax, 31
jnc _fermer_ok
jmp _fermer_erreur
_fermer_ok:
mov ecx, eax ; taille du fichier dans ecx (énoncé)
mov eax, 6 ; numéro de service: 6 (close)
mov ebx, [descr] ; descripteur de fichier
int 0x80
bt eax, 31
jnc _fin
jmp _erreur
_fermer_erreur:
mov eax, 6 ; numéro de service: 6 (close)
mov ebx, [descr] ; descripteur de fichier
int 0x80
jmp _erreur
_fin:
mov eax, 1 ; numéro de service: 1 (exit)
mov ebx, 0 ; retourner ok (0)
int 0x80
_erreur:
mov eax, 1 ; numéro de service: 1 (exit)
mov ebx, 1 ; retourner erreur (1)
int 0x80
| 22.645161 | 69 | 0.518519 |
de64296619d77f89fc7f1cba4887ddbb0410436f | 363 | asm | Assembly | programs/oeis/025/A025683.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/025/A025683.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/025/A025683.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A025683: Exponent of 9 (value of i) in n-th number of form 9^i*10^j.
; 0,1,0,2,1,0,3,2,1,0,4,3,2,1,0,5,4,3,2,1,0,6,5,4,3,2,1,0,7,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,9,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,2,1,0,11,10,9,8,7,6,5,4,3,2,1,0,12,11,10,9,8,7,6,5,4,3,2,1,0,13,12,11,10,9,8,7,6,5
lpb $0
sub $0,1
add $2,1
mov $1,$2
sub $1,$0
trn $0,$2
lpe
mov $0,$1
| 30.25 | 211 | 0.53719 |
7243eaf453c50a2eca14ef3fb81bf929e0c5dfee | 782 | asm | Assembly | data/pokemon/base_stats/vulpix.asm | AtmaBuster/pokeplat-gen2 | fa83b2e75575949b8f72cb2c48f7a1042e97f70f | [
"blessing"
] | 6 | 2021-06-19T06:41:19.000Z | 2022-02-15T17:12:33.000Z | data/pokemon/base_stats/vulpix.asm | AtmaBuster/pokeplat-gen2-old | 01e42c55db5408d72d89133dc84a46c699d849ad | [
"blessing"
] | null | null | null | data/pokemon/base_stats/vulpix.asm | AtmaBuster/pokeplat-gen2-old | 01e42c55db5408d72d89133dc84a46c699d849ad | [
"blessing"
] | 2 | 2021-08-11T19:47:07.000Z | 2022-01-01T07:07:56.000Z | db 0 ; species ID placeholder
db 38, 41, 40, 65, 50, 65
; hp atk def spd sat sdf
db FIRE, FIRE ; type
db 190 ; catch rate
db 63 ; base exp
db BURNT_BERRY, BURNT_BERRY ; items
db GENDER_F75 ; gender ratio
db 20 ; step cycles to hatch
INCBIN "gfx/pokemon/vulpix/front.dimensions"
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_GROUND, EGG_GROUND ; egg groups
db 70 ; happiness
; tm/hm learnset
tmhm ROAR, TOXIC, HIDDEN_POWER, SUNNY_DAY, PROTECT, SAFEGUARD, FRUSTRATION, IRON_TAIL, RETURN, DIG, DOUBLE_TEAM, FLAMETHROWER, FIRE_BLAST, FACADE, SECRET_POWER, REST, ATTRACT, OVERHEAT, ENDURE, WILL_O_WISP, PAYBACK, PSYCH_UP, CAPTIVATE, DARK_PULSE, SLEEP_TALK, NATURAL_GIFT, SWAGGER, SUBSTITUTE, HEAT_WAVE, OMINOUS_WIND, SNORE, SPITE, SWIFT, ZEN_HEADBUTT
; end
| 39.1 | 356 | 0.740409 |
ecea0f59fdd56aa20bd3dc7e58dbf149527865a9 | 5,700 | asm | Assembly | Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_44.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 9 | 2020-08-13T19:41:58.000Z | 2022-03-30T12:22:51.000Z | Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_44.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 1 | 2021-04-29T06:29:35.000Z | 2021-05-13T21:02:30.000Z | Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_44.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 3 | 2020-07-14T17:07:07.000Z | 2022-03-21T01:12:22.000Z | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %r15
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x5f2e, %rcx
nop
nop
nop
nop
nop
xor $15291, %r12
mov $0x6162636465666768, %r10
movq %r10, (%rcx)
nop
nop
nop
nop
cmp %r15, %r15
lea addresses_D_ht+0x8a2e, %rax
nop
nop
nop
nop
xor %rbp, %rbp
and $0xffffffffffffffc0, %rax
vmovaps (%rax), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %r13
nop
nop
nop
nop
nop
cmp $32281, %r15
lea addresses_A_ht+0x13af8, %rax
nop
nop
nop
nop
nop
and $50473, %r12
movl $0x61626364, (%rax)
xor $26459, %r12
lea addresses_WT_ht+0x3f3e, %rcx
nop
nop
inc %r12
movups (%rcx), %xmm5
vpextrq $1, %xmm5, %r13
and $32394, %r12
lea addresses_A_ht+0x17d3a, %r12
nop
dec %rax
movb (%r12), %r10b
nop
nop
nop
nop
cmp %rax, %rax
lea addresses_A_ht+0x32e, %rsi
lea addresses_normal_ht+0x732e, %rdi
nop
nop
nop
nop
nop
and $22638, %r13
mov $55, %rcx
rep movsb
nop
nop
nop
nop
sub $42944, %r13
lea addresses_WT_ht+0x532e, %r15
nop
nop
nop
nop
xor %r13, %r13
movb $0x61, (%r15)
nop
nop
sub %r12, %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r15
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r8
push %rbp
push %rbx
push %rsi
// Faulty Load
lea addresses_WT+0x952e, %r14
xor %rbp, %rbp
movups (%r14), %xmm4
vpextrq $0, %xmm4, %r8
lea oracles, %rsi
and $0xff, %r8
shlq $12, %r8
mov (%rsi,%r8,1), %r8
pop %rsi
pop %rbx
pop %rbp
pop %r8
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WT', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_WT', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 8, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
| 39.583333 | 2,999 | 0.659298 |
a4371a235b8e5cb7b1e330e4b6f711b95558717f | 399 | asm | Assembly | solutions/67 - Decimal Doubler/size-20_speed-219.asm | michaelgundlach/7billionhumans | 02c6f3963364362c95cb516cbc6ef1efc073bb2e | [
"MIT"
] | 45 | 2018-09-05T04:56:59.000Z | 2021-11-22T08:57:26.000Z | solutions/67 - Decimal Doubler/size-20_speed-219.asm | michaelgundlach/7billionhumans | 02c6f3963364362c95cb516cbc6ef1efc073bb2e | [
"MIT"
] | 36 | 2018-09-01T11:34:26.000Z | 2021-05-19T23:20:49.000Z | solutions/67 - Decimal Doubler/size-20_speed-219.asm | michaelgundlach/7billionhumans | 02c6f3963364362c95cb516cbc6ef1efc073bb2e | [
"MIT"
] | 36 | 2018-09-01T07:44:19.000Z | 2021-09-10T19:07:35.000Z | -- 7 Billion Humans (2053) --
-- 67: Decimal Doubler --
-- Author: Tiza59
-- Size: 20
-- Speed: 219
step s
if s != button:
pickup c
mem3 = set myitem
step s
a:
drop
step se
step nw
mem3 = calc mem3 x 2
if e >= 5:
mem3 = calc mem3 + 1
else:
mem3 = calc mem3 + 0
endif
if mem3 >= 10:
mem3 = calc mem3 - 10
else:
mem1 = calc 0 + 0
endif
pickup c
write mem3
jump a
endif
| 10.783784 | 29 | 0.591479 |
944fb081a66ff0f62dc78e4dd6766e453d86d894 | 969 | asm | Assembly | programs/oeis/060/A060548.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/060/A060548.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/060/A060548.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A060548: a(n) is the number of D3-symmetric patterns that may be formed with a top-down equilateral triangular arrangement of closely packed black and white cells satisfying the local matching rule of Pascal's triangle modulo 2, where n is the number of cells in each edge of the arrangement. The matching rule is such that any elementary top-down triangle of three neighboring cells in the arrangement contains either one or three white cells.
; 2,1,2,2,2,2,4,2,4,4,4,4,8,4,8,8,8,8,16,8,16,16,16,16,32,16,32,32,32,32,64,32,64,64,64,64,128,64,128,128,128,128,256,128,256,256,256,256,512,256,512,512,512,512,1024,512,1024,1024,1024,1024,2048,1024,2048,2048,2048,2048,4096,2048,4096,4096,4096,4096,8192,4096,8192,8192,8192,8192,16384,8192,16384,16384,16384,16384,32768,16384,32768,32768,32768,32768,65536,32768,65536,65536,65536,65536,131072,65536,131072,131072
add $0,5
mov $1,5
lpb $0
mul $1,2
mov $2,2
gcd $2,$0
mul $2,3
trn $0,$2
lpe
div $1,10
mov $0,$1
| 64.6 | 446 | 0.752322 |
d363cf5ecb143a054f750539a15fe9c16f66706a | 5,810 | asm | Assembly | micro_kernel/interrupts.asm | bursaiskender/BaseLevelComputerKernel | fa76bafe48ea8780f5dec6165d0454ef13892d50 | [
"MIT"
] | 1 | 2020-07-17T12:37:54.000Z | 2020-07-17T12:37:54.000Z | micro_kernel/interrupts.asm | bursaiskender/BaseLevelComputerKernel | fa76bafe48ea8780f5dec6165d0454ef13892d50 | [
"MIT"
] | null | null | null | micro_kernel/interrupts.asm | bursaiskender/BaseLevelComputerKernel | fa76bafe48ea8780f5dec6165d0454ef13892d50 | [
"MIT"
] | 1 | 2019-02-13T10:39:32.000Z | 2019-02-13T10:39:32.000Z | STRING isr0_msg, "Divide by Zero exception "
STRING isr1_msg, "Debug Exception "
STRING isr2_msg, "Non Maskale Interrupt Exception "
STRING isr3_msg, "Breakpoint Exception "
STRING isr4_msg, "Into Detected Overflow Exception "
STRING isr5_msg, "Out Of Bounds Exception "
STRING isr6_msg, "Invalid Opcode Exception "
STRING isr7_msg, "No Coprocessor Exception "
STRING isr8_msg, "Double Fault Exception "
STRING isr9_msg, "Coprocessor Segment Overrun Exception "
STRING isr10_msg, "Bad TSS Exception "
STRING isr11_msg, "Segment Not Present Exception "
STRING isr12_msg, "Stack Fault Exception "
STRING isr13_msg, "General Protection Fault Exception "
STRING isr14_msg, "Page Fault Exception "
STRING isr15_msg, "Unknown Interrupt Exception "
STRING isr16_msg, "Coprocessor Fault Exception "
STRING isr17_msg, "Alignment Check Exception "
STRING isr18_msg, "Machine Check Exception "
STRING isr19_msg, "19: Reserved Exception "
STRING isr20_msg, "20: Reserved Exception "
STRING isr21_msg, "21: Reserved Exception "
STRING isr22_msg, "22: Reserved Exception "
STRING isr23_msg, "23: Reserved Exception "
STRING isr24_msg, "24: Reserved Exception "
STRING isr25_msg, "25: Reserved Exception "
STRING isr26_msg, "26: Reserved Exception "
STRING isr27_msg, "27: Reserved Exception "
STRING isr28_msg, "28: Reserved Exception "
STRING isr29_msg, "29: Reserved Exception "
STRING isr30_msg, "30: Reserved Exception "
STRING isr31_msg, "31: Reserved Exception "
%macro CREATE_ISR 1
_isr%1:
cli
push r8
push r9
mov r8, isr%1_msg
mov r9, isr%1_msg_length
call print_normal
hlt
pop r9
pop r8
iretq
%endmacro
%macro CREATE_IRQ 1
_irq%1:
cli
mov rax, [irq_handlers + 8 *%1]
test rax, rax
je .eoi
call rax
.eoi:
mov rax, %1
test rax, rax
jl .master
mov al, 0x20
out 0xA0, al
.master:
mov al, 0x20
out 0x20, al
iretq
%endmacro
%macro IDT_SET_GATE 4
lea rdi, [IDT64 + %1 * 16]
mov rax, %2
mov word [rdi], ax
mov word [rdi+2], %3
mov byte [rdi+4], 0
mov byte [rdi+5], %4
shr rax, 16
mov word [rdi+6], ax
shr rax, 16
mov dword [rdi+8], eax
mov dword [rdi+12], 0
%endmacro
%assign i 0
%rep 32
CREATE_ISR i
%assign i i+1
%endrep
%assign i 0
%rep 16
CREATE_IRQ i
%assign i i+1
%endrep
install_idt:
lidt [IDTR64]
ret
install_isrs:
IDT_SET_GATE 0, _isr0, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 1, _isr1, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 2, _isr2, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 3, _isr3, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 4, _isr4, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 5, _isr5, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 6, _isr6, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 7, _isr7, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 8, _isr8, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 9, _isr9, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 10, _isr10, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 11, _isr11, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 12, _isr12, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 13, _isr13, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 14, _isr14, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 15, _isr15, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 16, _isr16, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 17, _isr17, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 18, _isr18, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 19, _isr19, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 20, _isr20, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 21, _isr21, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 22, _isr22, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 23, _isr23, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 24, _isr24, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 25, _isr25, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 26, _isr26, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 27, _isr27, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 28, _isr28, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 29, _isr29, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 30, _isr30, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 31, _isr31, LONG_SELECTOR-GDT64, 0x8E
ret
remap_irqs:
mov al, 0x11
out 0x20, al
out 0xA1, al
mov al, 0x20
out 0x21, al
mov al, 0x28
out 0xA1, al
mov al, 0x04
out 0x21, al
mov al, 0x02
out 0xA1, al
mov al, 0x01
out 0x21, al
out 0xA1, al
mov al, 0x00
out 0x21, al
out 0xA1, al
ret
install_irqs:
IDT_SET_GATE 32, _irq0, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 33, _irq1, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 34, _irq2, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 35, _irq3, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 36, _irq4, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 37, _irq5, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 38, _irq6, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 39, _irq7, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 40, _irq8, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 41, _irq9, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 42, _irq10, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 43, _irq11, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 44, _irq12, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 45, _irq13, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 46, _irq14, LONG_SELECTOR-GDT64, 0x8E
IDT_SET_GATE 47, _irq15, LONG_SELECTOR-GDT64, 0x8E
ret
install_syscalls:
IDT_SET_GATE 60, syscall_reboot, LONG_SELECTOR-GDT64, 0x8E
ret
register_irq_handler:
mov [irq_handlers + r8 * 8], r9
ret
syscall_reboot:
cli
push rax
mov al, 0x64
or al, 0xFE
out 0x64, al
mov al, 0xFE
out 0x64, al
pop rax
iretq
IDT64:
times 256 dq 0,0
IDTR64:
dw (256 * 16) - 1 ; Limit
dq IDT64 ; Base
irq_handlers:
times 16 dq 0
| 25.26087 | 62 | 0.706713 |
19c01600dba0f8ec9f1a509f7fd2aadd5183629c | 605 | asm | Assembly | programs/oeis/069/A069306.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/069/A069306.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | programs/oeis/069/A069306.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | ; A069306: Number of 2 X n binary arrays with a path of adjacent 1's from upper left corner to anywhere in right hand column.
; 5,12,29,70,169,408,985,2378,5741,13860,33461,80782,195025,470832,1136689,2744210,6625109,15994428,38613965,93222358,225058681,543339720,1311738121,3166815962,7645370045,18457556052,44560482149,107578520350,259717522849,627013566048,1513744654945,3654502875938,8822750406821,21300003689580,51422757785981,124145519261542,299713796309065,723573111879672,1746860020068409,4217293152016490
add $0,3
lpb $0
sub $0,1
add $3,1
mov $1,$3
add $2,$3
mov $3,$2
add $2,$1
lpe
| 46.538462 | 387 | 0.801653 |
26ca51fd7e179b8ed4bdbf76e5f1dfba7753cc74 | 494 | asm | Assembly | oeis/344/A344006.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/344/A344006.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/344/A344006.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A344006: a(n) = m*(m+1)/n, where A344005(n) is the smallest number m such that n divides m*(m+1).
; Submitted by Jon Maiga
; 2,1,2,3,4,1,6,7,8,2,10,1,12,3,2,15,16,4,18,1,2,5,22,3,24,6,26,2,28,1,30,31,4,8,6,2,36,9,4,6,40,1,42,3,2,11,46,5,48,12,6,3,52,13,2,1,6,14,58,4,60,15,12,63,10,2,66,4,8,3,70,1,72,18,8,5,6,2,78,3,80,20,82,5,14,21,10,12,88,1,2,6,10,23,4,11,96,24,20,6
mov $1,$0
seq $0,345988 ; Smallest oblong number m*(m+1) that is divisible by n.
add $1,1
mov $2,$0
div $2,$1
mov $0,$2
| 44.909091 | 247 | 0.619433 |
6562be72146c292c8bce40111de5c5ea1f7f527d | 1,175 | asm | Assembly | src/coreclr/vm/arm/thunktemplates.asm | berkansasmaz/runtime | 7626c5d8be527d6735eddcdc7c97423211d8f9e9 | [
"MIT"
] | 8 | 2022-02-19T15:57:07.000Z | 2022-03-10T06:00:02.000Z | src/coreclr/vm/arm/thunktemplates.asm | berkansasmaz/runtime | 7626c5d8be527d6735eddcdc7c97423211d8f9e9 | [
"MIT"
] | 6 | 2020-03-20T18:33:48.000Z | 2022-01-13T13:20:05.000Z | src/coreclr/vm/arm/thunktemplates.asm | berkansasmaz/runtime | 7626c5d8be527d6735eddcdc7c97423211d8f9e9 | [
"MIT"
] | 2 | 2022-02-24T06:39:57.000Z | 2022-03-18T16:03:11.000Z | ; Licensed to the .NET Foundation under one or more agreements.
; The .NET Foundation licenses this file to you under the MIT license.
#include "ksarm.h"
#include "asmconstants.h"
#include "asmmacros.h"
TEXTAREA
ALIGN 4
#define DATA_SLOT(stub, field) stub##Code + PAGE_SIZE + stub##Data__##field
LEAF_ENTRY StubPrecodeCode
ldr r12, DATA_SLOT(StubPrecode, MethodDesc)
ldr pc, DATA_SLOT(StubPrecode, Target)
LEAF_END_MARKED StubPrecodeCode
ALIGN 4
LEAF_ENTRY FixupPrecodeCode
ldr pc, DATA_SLOT(FixupPrecode, Target)
ldr r12, DATA_SLOT(FixupPrecode, MethodDesc)
ldr pc, DATA_SLOT(FixupPrecode, PrecodeFixupThunk)
LEAF_END_MARKED FixupPrecodeCode
ALIGN 4
LEAF_ENTRY CallCountingStubCode
push {r0}
ldr r12, DATA_SLOT(CallCountingStub, RemainingCallCountCell)
ldrh r0, [r12]
subs r0, r0, #1
strh r0, [r12]
pop {r0}
beq CountReachedZero
ldr pc, DATA_SLOT(CallCountingStub, TargetForMethod)
CountReachedZero
ldr pc, DATA_SLOT(CallCountingStub, TargetForThresholdReached)
LEAF_END_MARKED CallCountingStubCode
END
| 26.704545 | 79 | 0.699574 |
6841a311df93bb67eb72f3d88cf8b1441b58dbbf | 27,852 | asm | Assembly | Snake.asm | Zoomelectrico/Snake | 3f654abe3aeb6381240d80b0fcd185d805a26722 | [
"MIT"
] | null | null | null | Snake.asm | Zoomelectrico/Snake | 3f654abe3aeb6381240d80b0fcd185d805a26722 | [
"MIT"
] | null | null | null | Snake.asm | Zoomelectrico/Snake | 3f654abe3aeb6381240d80b0fcd185d805a26722 | [
"MIT"
] | 2 | 2018-06-29T12:42:21.000Z | 2020-08-10T07:22:34.000Z | #################################################
# 1er Proyecto de Organización del Computador #
# Snake Version 2.0 #
# Germano Rojas & José Quevedo #
# Teclas para usar: #
# w (Arriba/up) #
# s (Abajo/down) #
# a (Derecha/right) #
# d (Izquierda/left) #
# p (Pausar/pause) #
# r (Reiniciar/restar) #
#################################################
#########################################################
# Uso de los Registros #
# 1. $t0 Indice para recorrer el tablero / Auxiliar #
# 2. $t1 Guarda los colores para rellenar el tablero #
# 3. $t2 Contador de cuadritos para el snake #
# 4. $t3 Indice para el movimiento #
# 5. $t4 Indice para borrar #
# 6. $t5 Contiene la Direrección del movimiento #
# 7. $t6 Para manejar la velocidad #
# 8. $t7 Auxiliar para las colisiones #
# 9. $t8 Auxiliar #
# 10. $t9 Para el Manejo del tiempo #
# 11. $s0 Acumulador del puntaje #
# 12. $s1 Lleva el conteo de las vidas #
# 13. $s3 Lleva el tamaño del snake #
# #
# Indices #
# #
# $t0 para recorrer el tablero #
# $t3 para el movimiento #
# $t4 para borrar el movimiento #
# "4" para el movimiento horizontal #
# "256" para el movimiento vertical #
#########################################################
principio:
.data
# Espacio de Memoria del tablero
tablero: .space 1048576
# Colores del Juego
Cborde: .word 0x00006400 # Bordes del Tablero
Cfondo: .word 0x0000FF00 # Fondo del Tablero
Cvidas: .word 0x00FF4500 # Rojo
Csnake: .word 0x00808000 # Oliva
Cpatilla: .word 0x00FF0000 # Rojo 2
Ccambur: .word 0x00FFFF00 # Amarillo
Cnaranja: .word 0x00FFA500 # Naraja
Cmora: .word 0x004400FF # Azul
Cpopo: .word 0x00794900 # Marrón
Cpiedras: .word 0x00808080 # Gris
TiempoI: .word 0
velocidad: .word 0
auxiliar: .word 0
movimiento: .word 0
# Mensaje de puntaje
Puntaje: .asciiz "El puntaje es: "
salto: .asciiz "\n"
# Mensaje de Reinicio
reinicio: .asciiz "Desea reiniciar el juego?"
mensajePausa: .asciiz "El juego esta pausado\nDele clic en <ok> para continuar "
Inicio: .asciiz "BIENVENIDO AL JUEGO CULEBRITA ISIS!\nElaborado por: Jose Quevedo y Germano Rojas\n Dele clic en <ok> para continuar"
.text
macros:
# Instrucción para "pintar" los bordes del tablero #
.macro bordes
li $t0, 0 # Registro auxiliar para indice de inicio del tablero
# Pintar todo el tablero como si fuese el fondo "
fondo:
lw $t1, Cfondo # Obtiene el color del fondo
sw $t1, tablero($t0) # Guarda en el tablero dicho color
addi $t0, $t0, 4 # Se posiciona en la siguiente posición a "pintar"
blt $t0, 16384, fondo # Condición para que solamente utilice el espacio necesario para el tablero
li $t0, 0 # Registro auxiliar para indice de inicio del tablero
# "Pinta" el borde del tablero #
horizontal:
lw $t1, Cborde # Obtiene el color del borde
sw $t1, tablero($t0) # Guarda en el tablero dicho color
addi $t0, $t0, 4 # Se posiciona en la siguiente posición a "pintar"
blt $t0, 1024, horizontal # Condición que permite pintar solamente la parte superior del tablero
beq $t0, 16384, finalbordes # Último recuadro del borde a pintar
bge $t0, 16128, horizontal # Condición para pintar el borde inferior del tablero
vertical:
# Borde lateral izquierdo #
lw $t1, Cborde # Obtiene el color del borde
sw $t1, tablero($t0) # Guarda en el tablero dicho color
add $t0, $t0, 252 # Se posiciona en la siguiente posición a "pintar"
# Borde lateral derecho #
lw $t1, Cborde # Obtiene el color del borde
sw $t1, tablero($t0) # Guarda en el tablero dicho color
add $t0, $t0, 4 # Se posiciona en la siguiente posición a "pintar"
blt $t0, 16128, vertical # En caso de no llegar al primer recuadro del borde inferior, continúa con los laterales
b horizontal # En caso de llegar al primer recuadro del borde inferior, salta a "horizontal"
finalbordes:
.end_macro
# Suma al puntaje general de acuerdo a los siguiente criterios:
# 1. Se suman puntos cada vez que el snake va creciendo
# 2. 3 pts por cada naranja comida
# 3. 4 pts por cada cambur comida
# 4. 5 pts por cada patilla comida
# 5. 10 pts por cada mora comida
.macro SumarPuntaje ($arg)
add $s0, $s0, $arg # Al registro de puntaje le suma los puntos especificados por $arg
.end_macro
# Esta macro arma el snake dado el tamaño deseado, puede mandar el tamaño como un ope inmediato o como un registro #
.macro Armar(%arg)
li $t3, 8064 # Punto de comienzo del snake
armar:
li $t8, 1 # Referencia 1 (hacia la derecha) --- ver Macro Mover
sb $t8, movimiento # Se guarda el byte en "Movimiento"
lw $t8, movimiento # Se obtiene el byte
sll $t8, $t8, 24 # Se corren 24 bits para poder guardar el color del Snake junto con la referencia a movimiento
lw $t1, Csnake # Se obtiene el color del Snake
add $t1, $t1, $t8 # Se le añade al byte corrido para guardarlo en el tablero
sw $t1, tablero($t3) # Se guarda en el tablero
addi $t3, $t3, 4 # $t3 funciona como indice para construir el snake, se aumente en 4 para ir con el oro cuadro
addi $t2, $t2, 1 # $t2 funciona como contador para saber cuantos cuadros falta por llenar
blt $t2, %arg, armar # Condición para seguir "pintando" cuadros en el tablero
subi $t3, $t3, 4 # Posiciona el indice de la cabeza del snake en la posición del último cuadro "pintado" (la cabeza)
li $t8, 64 # Proporciona un numero en ascii neutral para empezar a hacer el movimiento hacia la derecha desde el inicio
sw $t8, 0xFFFF0004 # Guarda dicho número
.end_macro
# Esta Macro pinta la cantidad de Vidas en el Tablero #
.macro Vidas
lw $t1, Cvidas
# "Pinta" de rojo los recuadros que indican la primera vida #
Vida1:
sw $t1, tablero+268
sw $t1, tablero+272
sw $t1, tablero+524
sw $t1, tablero+528
# "Pinta" de rojo los recuadros que indican la primera vida #
Vida2:
sw $t1, tablero+280
sw $t1, tablero+284
sw $t1, tablero+536
sw $t1, tablero+540
# "Pinta" de rojo los recuadros que indican la primera vida #
Vida3:
sw $t1, tablero+292
sw $t1, tablero+296
sw $t1, tablero+548
sw $t1, tablero+552
.end_macro
# Divide el tiempo de espera entre 5 y eso permite aumentar la veloidad del movimiento #
.macro aumentarVelocidad
# Si la velocidad es divible entre 5, la reduce, sino llegó al máximo
bgtz $t6, aumentar # Comprueba que la velocidad actual sea mayor a 0
b terminarMacro
aumentar:
li $t8, 0
# Comprueba que la velocidad sea divisible entre 5 #
rem $t8, $t6, 5
bgtz $t8, terminarMacro
div $t8, $t6, 5 # Realiza la división
sub $t6, $t6, $t8 # Sustrae el resultado de la división a la velocidad actual
terminarMacro:
.end_macro
# Genera las Frutas y las coloca aleatoriamente en el Tablero #
# Falta verificar que no haya nada en la posición generada :|
.macro frutasRandom
li $t8, 0 # Registro auxiliar a usarse luego
loopCantidadFRandom:
# Genera la cantidad de las frutas de forma aleatoria
li $a0, 1
li $a1, 10
li $v0, 42
syscall
move $t9, $a0
blt $t9, 2, loopCantidadFRandom # Condición para obtener más de dos frutas como mínimo
li $s5, 0 # Registro utilizado para contar cuántas frutas se han colocado en el tablero
loopCantidadF:
# Instrucciones para obtener la posición donde se colocarán las frutas #
loopRandom:
# Se obtiene la posición aleatoria #
li $a0, 1
li $a1, 4031
li $v0, 42
syscall
move $t7, $a0
mul $t7, $t7, 4 # El número de la posición debe ser múltiplo de 4
blt $t7, 1024, loopRandom # La posición debe estar debajo del borde superior, es decir en el tablero
# Evalua si en la posición establecida hay algún otro objeto #
lw $t1, Cfondo
lw $t8, tablero($t7)
bne $t8, $t1, loopRandom
# Determinación aleatoria de cuál furta colocar #
fruticasRandom:
especiales:
rem $t8, $s3, 3 # Como es una fruta especial, la condicion especial es que si el tamaño del Snake es múltiplo de 3, se pueden colocar moras
beqz $t8, mora # En caso que si sea múltiplo de 3, se coloca la mora
rem $t8, $s3, 5 # Como es un objeto especial, la condicion especial es que si el tamaño del Snake es múltiplo de 5, se pueden colocar popos
beqz $t8, popo # En caso que si sea múltiplo de 5, se coloca el popo que restará 5 pts. al puntaje
normales:
# Las frutas normales se manejan con un número aleatorio del 0 al 3"
li $a0, 1
li $a1, 4
li $v0, 42
syscall
move $t8, $a0
beqz $t8, finMacroFrutasR # En caso de arrojar 0, no se coloca fruta
beq $t8, 1, patilla # En caso de arrojar 1, se coloca un patilla
beq $t8, 2, cambur # En caso de arrojar 2, se coloca un cambur
beq $t8, 3, naraja # En caso de arrojar 3, se coloca una naranja
# Instrucciones para colocar las frutas en el tablero #
patilla:
lw $t1, Cpatilla
sw $t1, tablero($t7)
b finMacroFrutasR
cambur:
lw $t1, Ccambur($zero)
sw $t1, tablero($t7)
b finMacroFrutasR
naraja:
lw $t1, Cnaranja
sw $t1, tablero($t7)
b finMacroFrutasR
mora:
lw $t1, Cmora
sw $t1, tablero($t7)
b normales
popo:
lw $t1, Cpopo
sw $t1, tablero($t7)
b normales
finMacroFrutasR:
addi $s5, $s5, 1 # Contador para saber cuántas frutas se han colocado
blt $s5, $t9, loopCantidadF # Condición para colocar todas las frutas
.end_macro
# Genera Obstaculos y los coloca aleatoriamente en el Tablero #
.macro obstaculosRandom
loopcantidadRandom:
li $t8, 0
li $t0, 0
# Genera la cantidad de los obtaculos de forma aleatoria
li $a0, 1
move $a1, $s3
li $v0, 42
syscall
move $t9, $a0
beqz $t9, loopcantidadRandom
bgt $t9, 10, loopcantidadRandom
li $s5, 0 # Registro auxiliar para saber cuantos obstáculos se han colocado
loopCantidadO:
looptamanioRandom:
li $t8, 0
li $t0, 0
# Genera el tamaño de los obstaculos de forma aleatoria
li $a0, 1
li $a1, 8 # El tamaño está limitado por 8 cuadros
li $v0, 42
syscall
move $t0, $a0
beqz $t0, looptamanioRandom # El tamaño no puede ser igual a 0
# Genera la posicion aleatoria
loopRandomO:
li $a0, 1
li $a1, 4031
li $v0, 42
syscall
move $t7, $a0
mul $t7, $t7, 4 # La posición debe ser múltiplo de 4
blt $t7, 1024, loopcantidadRandom # En caso de arrojar una posición en el borde superior, buscar otra posición
sw $t7, auxiliar # Guarda la posición en memoria para usarla después
li $t2, 0 # Contador de piezas colocadas
# Comprueba si hay algún objeto que interfiera en el espacio del obstáculo #
comprobar:
lw $t1, Cfondo # Obtiene el color del fondo
lw $t8, tablero($t7) # Obtiene el color del tablero en la posición a poner el obstáculo
bne $t8, $t1, loopcantidadRandom # Compara para saber si hay algun objeto en el lugar
addi $t2, $t2, 1 # Contador para saber cuántas piezas del obstáculo se han evaluado
addi $t7, $t7, 4 # Mueve el indice de posicionamiento para evaluar la siguiente pieza
ble $t2, $t0, comprobar # Conidición para saber si faltan piezas por evaluar
li $t8, 0 # Contador para saber cuantás piezas faltan por colocar
lw $t7, auxiliar # Obtiene la posición inicial del obstáculo
# Una vez que se comprueba que el espacio total para poner el obstáculo está libre, se coloca el obstáculo #
loopTamanioO:
lw $t1, Cpiedras # Obtiene el color del obstáculo
sw $t1, tablero($t7) # Guarda el color en el tablero
addi $t7, $t7, 4 # Aumenta el indice de posicionamiento
addi $t8, $t8, 1 # Aumenta el contador
blt $t8, $t0, loopTamanioO # Loop para saber si ya las piezas se colocaron en su totalidad
# Averigua si faltan obstáculos por colocar #
addi $s5, $s5, 1 # Aumenta el contador de obstáculo por colocar en total
ble $s5, $t9, loopCantidadO # Loop para saber si ya los obstáculos se colocaron en su totalidad
.end_macro
# Macro para realizar movimientos #
.macro mover($arg)
inicioM:
colision($arg) # Intrucciones de colisiones
li $t8, 0 # Registro auxiliar, se usará luego
beq $arg, 4, der # En caso de quereserse mover a la derecha ($arg = 4), saltar a der
beq $arg, -4, izq # En caso de quereserse mover a la derecha ($arg = -4), saltar a izq
beq $arg, 256, aba # En caso de quereserse mover a la derecha ($arg = 256), saltar a aba
beq $arg, -256, arr # En caso de quereserse mover a la derecha ($arg = -256), saltar a arr
# Movimiento hacia la derecha #
der:
li $t8, 1 # Se carga un numeor de referencia (1) para guardarlo junto con el color del Snake en el tablero
sb $t8, movimiento # Se carga el byte al espacio en memoria "movimiento"
b moveS # Salta
# Movimiento hacia la izquierda #
izq:
li $t8, 2 # Se carga un numeor de referencia (2) para guardarlo junto con el color del Snake en el tablero
sb $t8, movimiento # Se carga el byte al espacio en memoria "movimiento"
b moveS # Salta
# Movimiento hacia la abajo #
aba:
li $t8, 3 # Se carga un numeor de referencia (3) para guardarlo junto con el color del Snake en el tablero
sb $t8, movimiento # Se carga el byte al espacio en memoria "movimiento"
b moveS # Salta
# Movimiento hacia la arriba #
arr:
li $t8, 4 # Se carga un numeor de referencia (4) para guardarlo junto con el color del Snake en el tablero
sb $t8, movimiento # Se carga el byte al espacio en memoria "movimiento"
b moveS # Salta
li $t8, 0 # Registro auxiliar, se lleva a 0
# Instrucciones para guardar el movimiento junto con el color del Snake #
moveS:
lw $t1, movimiento # Se obtiene la palabra de "movimiento" en este caso el numero de referencia
sll $t1, $t1, 24 # Dicha palabra se corre 24 bits para colocar el byte de referencia más hacia la izquierda (*)
lw $t7, Csnake
# (*) Se hace esto debido a que para "pintar" el tablero, el sistema lee los ultimos 3 bytes de izquierda a derecha, los byte del color #
add $t1, $t1, $t7 # Se añade el color al numero de referencia corrido
sw $t1, tablero($t3) # Se guarda el movimiento y el color en el tablero
add $t3, $t3, $arg # Se le suma al indice de la cabeza del snake el numero dependiendo de cuál es el movimiento que se quiere, de tal forma lo realiza
sw $t1, tablero($t3) # Se guarda el color del Snake en el recuadro del tablero dependiendo de $t3
beqz $t0, tiempo # En caso que no sea necesario aumentar el tamaño del Snake, se salta a "tiempo"
# En caso de aumentar el tamaño del snake se realiza lo siguiente #
addi $t8, $t8, 1 # $t8 funciona como contador
ble $t8, $t0, moveS # Hasta que el contador no alcance el tamaño de la serpiente, esta no accederá a las instrucciones de borrado por lo que "aumentará" de tamaño
# Determina su movimiento en relación al tiempo (velocidad) #
tiempo:
# Sleep que determina esta velocidad
li $v0, 32
la $a0, ($t6) # $t6 establece los milisegundos que se "dormirá" el proceso
syscall
# Inicio de las instrucciones de borrado #
lw $t1, Csnake # Obtiene el color del Snake para compararlo posteriormente
li $t8, 0
lw $t8, tablero($t4) # Obtiene lo que está contenido en el tablero en la posición establecida por el indice de borrado o cola ($t4)
# Condición para realizar el borrado #
derecha:
li $t7, 4 # Numero a sumarse para ir a la derecha
beq $t8, 25198592, borrar # Si el numero guardado en la posición del tablero dada por el índice es igual al mostrado, borrar hacia la derecha
izquierda:
li $t7, -4 # Numero a sumarse para ir a la izquierda
beq $t8, 41975808, borrar # Si el numero guardado en la posición del tablero dada por el índice es igual al mostrado, borrar hacia la izquierda
abajo:
li $t7, 256 # Numero a sumarse para ir a la abajo
beq $t8, 58753024, borrar # Si el numero guardado en la posición del tablero dada por el índice es igual al mostrado, borrar hacia la abajo
arriba:
li $t7, -256 # Numero a sumarse para ir a la arriba
beq $t8, 75530240, borrar # Si el numero guardado en la posición del tablero dada por el índice es igual al mostrado, borrar hacia la arriba
# Instrucción de borrado, de tal forma se da ilusión de movimiento dle snake #
borrar:
lw $t1, Cfondo # Obtiene el color del fondo del tablero
sw $t1, tablero($t4) # Guarda dicho color en la posición que se desea borrar
add $t4, $t4, $t7 # Cambia el índice de borrado o cola para la proxima posición a evaluar
.end_macro
# Verifica si el snake choco contra un borde o un obstaculo #
.macro colision($arg)
# Carga el color que esta proximo a la cabeza del snake #
add $t3, $t3, $arg # Obtiene el espacio próximo, según el movimiento, para saber si hay algo
lw $t1, tablero($t3) # Obtiene el color de ese espacio
sub $t3, $t3, $arg # Devuelve a la posición de antes
lw $t7, Cborde # Carga el color del borde
beq $t7, $t1, pierdeVida # Descuenta una Vida y reinicia al snake
lw $t7, Cpiedras # Carga el color de las piedras
beq $t7, $t1, pierdeVida # Descuenta una Vida y reinicia al snake
lw $t7, Csnake # Carga el color del snake
beq $t1, $t7, pierdeVida # Descuenta una Vida y reinicia al snake
li $t0, 0 # Se usa $t0 como registro auxiliar que permita determinar que tanto se aumenta el tamaño del snake #
lw $t7, Cfondo # Carga el color del fondo
beq $t1, $t7, finalMacro # Termina la macro si no choco
# En caso de "colisionar" o comer una fruta #
lw $t7, Cpatilla # Obtiene el color de la fruta
li $t0, 5 # Numero de cuadros extras en el Snake
addi $s3, $s3, 5 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
lw $t7, Ccambur # Obtiene el color de la fruta
li $t0, 4 # Numero de cuadros extras en el Snake
addi $s3, $s3, 4 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
lw $t7, Cnaranja # Obtiene el color de la fruta
li $t0, 3 # Numero de cuadros extras en el Snake
addi $s3, $s3, 3 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
lw $t7, Cmora # Obtiene el color de la fruta
li $t0, 10 # Numero de cuadros extras en el Snake
addi $s3, $s3, 10 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
lw $t7, Cpopo # Obtiene el color del objeto
li $t0, 1 # Numero de cuadros extras en el Snake
subi $s0, $s0, 5 # Resta 5 puntos
addi $s3, $s3, 1 # Conserva el numero de cuadros que forman el snake, útil para obtener un puntaje mayor dependiendo del tamaño del snake
beq $t1, $t7, finalMacro # Salta las demas condiciones, en caso que esta esté acertada
# Intrucciones en caso que haya una colisión #
pierdeVida:
subi $s1, $s1, 1 # Resta una vida
una:
bordes # Vuelve a poner el trablero como el inicio
Vidas # Pinta las vidas
li $t7, 0
# Resta el primer recuadro de las vidas #
sw $t7, tablero+268
sw $t7, tablero+272
sw $t7, tablero+524
sw $t7, tablero+528
ble $s1, 1, dos # En caso que sea la segunda vida perdida, salta a "dos"
b loopVidas # Continúa
dos:
li $t7, 0
# Resta el segundo recuadro de las vidas #
sw $t7, tablero+280
sw $t7, tablero+284
sw $t7, tablero+536
sw $t7, tablero+540
beq $s1, 0, tres # En caso que sea la tercera vida perdida, salta a "tres"
b loopVidas # Continúa
tres:
li $t7, 0
# Resta el segundo recuadro de las vidas #
sw $t7, tablero+292
sw $t7, tablero+296
sw $t7, tablero+548
sw $t7, tablero+552
b reiniciar # En este caso ya no quedan más vidas asi que salta a la pregunta de reiniciar o no
finalMacro:
SumarPuntaje ($t0) # En caso de obtener puntaje, lo suma
.end_macro
# Macro para reestablecer las condiciones del tablero sin obstáculos o frutas #
.macro reestablecer
li $t8, 1024
lw $t1, Cfondo # Color de fondo #
inicioRes:
lw $t0, tablero($t8) # Obtiene el contenido del recuadro en el tablero #
beq $t0, $t1, saltar
# Cuadros que no deben ser "borrados" del tablero #
li $t7, 25198592 # Numero resultante de la suma del numero decimal más el numero usado para referenciarse al respectivo movimiento (ver Macro de movimiento)
beq $t0, $t7, saltar
li $t7, 41975808 # Numero resultante de la suma del numero decimal más el numero usado para referenciarse al respectivo movimiento (ver Macro de movimiento)
beq $t0, $t7, saltar
li $t7, 58753024 # Numero resultante de la suma del numero decimal más el numero usado para referenciarse al respectivo movimiento (ver Macro de movimiento)
beq $t0, $t7, saltar
li $t7, 75530240 # Numero resultante de la suma del numero decimal más el numero usado para referenciarse al respectivo movimiento (ver Macro de movimiento)
beq $t0, $t7, saltar
lw $t7, Cborde # Color del borde #
beq $t0, $t7, saltar
# Pinta el fondo del tablero #
pintar:
sw $t1, tablero($t8)
# En caso de presentarse algún objeto que se debe conservar en el tablero, se salta al siguiente recuadro #
saltar:
addi $t8, $t8, 4
blt $t8, 16124, inicioRes
.end_macro
# Este es el comienzo del juego, al principio se inicializan las vidas y el puntaje #
inicio1:
la $a0, Inicio
li $a1, 2
li $v0, 55
syscall
bordes
main:
li $s0, 0 # Cantidad de Puntos acumulados
li $s1, 3 # Vidas del snake
li $s3, 5 # Cantidad de cuadritos del snake
Vidas
loopVidas:
li $t6, 1000 # Tiempo predeterminado para comenzar
li $s3, 5
star: # Inicio del Juego
li $t2, 0 # Contador de cuadritos para el snake
li $t3, 8064 # Indice para Avanzar (Primera Posicion)
li $t4, 8064 # Indice para Borrar
Armar(5) # Macro para armar al snake (Cantidad de cuadros)
pausa1:
lw $t9, 0xffff0000
beq $t9, 0, pausa1
beq $t9, 1, loopJuego
# Ciclo del juego, se lee hacia donde se quiere ir para luego realizar las instrucciones respectivas #
loopJuego:
#contar tiempo
li $t8, 0
li $v0, 30
syscall
move $t8, $a0
sw $t8, TiempoI
mientras: #loop para hacer un movimiento
lw $t9, 0xFFFF0004
move $t8, $t9
preguntar:
# Condiciones para moverse
beq $t9, 72, principio # Lleva al inicio del juego
beq $t9, 70, final # Finaliza el juego
beq $t9, 112, pausa # Pausa el juego, es necesario volver a apretar esta tecla para continuar
beq $t9, 119, arriba # Movimiento hacia arriba
beq $t9, 115, abajo # Movimiento hacia abajo
beq $t9, 64, inicio # Movimiento hacia la derecha
beq $t9, 100, derecha # Movimiento hacia la derecha 2
beq $t9, 97, izquierda # Movimiento hacia la izquierda
## En caso que se teclee alguna tecla errónea el juego continuará sin alteraciones ##
bne $t9, 72, siga2
bne $t9, 70, siga2
bne $t9, 112, siga2
bne $t9, 119, siga2
bne $t9, 115, siga2
bne $t9, 64, siga2
bne $t9, 100, siga2
bne $t9, 97, siga2
# Mensaje de pausa por consola #
pausa:
la $a0, mensajePausa
li $a1, 2
li $v0, 55 # Imprime mensaje de pausa
syscall
b pausa1 # Condicion para que el pueda seguir el juego
# Instrucciones de movimiento
arriba:
beq $s4, 256, siga2 # Condición para que no vaya en sentido contrario
li $s4, -256 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2 # Continúa
abajo:
beq $s4, -256, siga2 # Condición para que no vaya en sentido contrario
li $s4, 256 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2 # Continúa
derecha:
beq $s4, -4, siga2 # Condición para que no vaya en sentido contrario
li $s4, 4 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2 # Continúa
izquierda:
beq $s4, 4, siga2 # Condición para que no vaya en sentido contrario
li $s4, -4 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2
inicio:
li $s4, 4 # Se resta 256 a la posición actual para que suba el cuadrito
b siga2 # Continúa
siga2: # Loop para saltar cuando se sepa qué movimiento hacer
mover($s4) # Macro de movimiento, están las instrucciones que permiten el movimiento del Snake
bnez $t0, aparicion # En caso que se coma una fruta "aparición" salta al label para limpiar el tablero
# 2da toma de tiempo
li $v0, 30
syscall
move $t0, $a0
lw $t8, TiempoI
sub $t8, $t0, $t8 # Resta para saber si han pasado 10 segundos
blt $t8, 10000, mientras # Condicion de los 10 segundos
SumarPuntaje ($s3) #suma un punto por cada 10 segundos transcurridos dependiendo de la dificultad
aparicion: # Pasados 10 segundos o comida una fruta, pone en blanco el tablero para volver a poner las otras frutas/obstaculos
reestablecer # Pone en blanco el tablero y conserva la posicion del snake
obstaculosRandom # Coloca nuevos obstaculos
frutasRandom # Coloca nuevas frutas
# Imprime el puntaje por consola #
la $a0, salto # Salto para que se vea mas ordenado
li $v0, 4
syscall
la $a0, Puntaje
li $v0, 4
syscall
move $a0, $s0
li $v0, 1
syscall
la $a0, salto # Salto para que se vea mas ordenado
li $v0, 4
syscall
sw $zero, TiempoI # Retorna a 0 la posicion de memoria donde se guarda el tiempo para que se cuente a partir de ahí 10 segundos
blt $t6, 200, siga # Condicion para que la velocidad no disminuya menor a 0.20 segundos
aumentarVelocidad # Aumenta la velocidad
siga:
b loopJuego # Retorna para seguir jugando
# Condiciones del loop de vidas #
beqz $s1, reiniciar # Si llego a 0 vida pregunto para reiniciar
ble $s1, 3, loopVidas # Sino vuelvo a iniciar todo el proceso del juego
# Para reiniciar el Juego #
reiniciar:
la $a0, reinicio # Pregunto por otra partida
li $v0, 50
syscall
beqz $a0, otraPartida
# Para salir del juego #
final:
li $v0, 10
syscall
# Permite otra partida #
otraPartida:
b principio
| 38.310867 | 166 | 0.650259 |
59a7cc85dfa5102ac47852c8b5ae7acb50fc6105 | 144 | asm | Assembly | other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/mak.lzh/mak/maped3.asm | prismotizm/gigaleak | d082854866186a05fec4e2fdf1def0199e7f3098 | [
"MIT"
] | null | null | null | other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/mak.lzh/mak/maped3.asm | prismotizm/gigaleak | d082854866186a05fec4e2fdf1def0199e7f3098 | [
"MIT"
] | null | null | null | other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/mak.lzh/mak/maped3.asm | prismotizm/gigaleak | d082854866186a05fec4e2fdf1def0199e7f3098 | [
"MIT"
] | null | null | null | Name: maped3.asm
Type: file
Size: 46302
Last-Modified: '1992-02-13T07:48:24Z'
SHA-1: E711F6B7A5B3C9083B37828E025254FBF1DF6600
Description: null
| 20.571429 | 47 | 0.8125 |
62b1f10c8c4e80d3bce7dfa740ff7b98dae7939c | 619 | asm | Assembly | programs/oeis/194/A194391.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/194/A194391.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | programs/oeis/194/A194391.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | ; A194391: Numbers m such that Sum_{k=1..m} (<1/2 + k*r> - <k*r>) > 0, where r=sqrt(12) and < > denotes fractional part.
; 1,3,5,7,9,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,29,31,33,35,37,39,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,57,59,61,63,65,67,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,87,89,91,93
mov $2,$0
add $2,1
lpb $2
mov $0,$6
sub $2,1
sub $0,$2
mov $3,8
mov $4,2
mov $8,2
lpb $0
add $3,8
div $3,2
mod $5,$4
mov $7,$0
mov $0,0
sub $3,2
add $5,5
div $7,7
mul $8,$7
gcd $8,$3
mul $8,$5
lpe
div $8,28
add $8,1
add $1,$8
lpe
| 20.633333 | 200 | 0.531502 |
14a9d70a398d490163f22c5d4a0b2af26f224be0 | 643 | asm | Assembly | oeis/325/A325805.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/325/A325805.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/325/A325805.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A325805: "Sloping octal numbers": write numbers in octal under each other (right-justified), read diagonals in upward direction, convert to decimal.
; Submitted by Jamie Morken(w4)
; 0,1,2,3,4,5,6,15,8,9,10,11,12,13,14,23,16,17,18,19,20,21,22,31,24,25,26,27,28,29,30,39,32,33,34,35,36,37,38,47,40,41,42,43,44,45,46,55,48,49,50,51,52,53,54,63,56,57,58,59,60,61,126,71,64,65,66,67,68,69,70,79,72,73,74,75,76,77,78,87,80,81,82,83,84,85,86,95,88,89,90,91,92,93,94,103,96,97,98,99
mov $2,$0
add $0,1
mov $4,1
lpb $2
mul $4,8
mov $3,$4
mov $5,$0
add $0,1
mod $5,$4
cmp $5,0
mul $3,$5
add $1,$3
add $1,1
sub $2,1
lpe
mov $0,$1
| 30.619048 | 294 | 0.642302 |
202a4e37a284603c262e36b160791bc51863205e | 1,181 | asm | Assembly | _build/dispatcher/jmp_ippsGFpECInitStd192r1_ffc1d72c.asm | zyktrcn/ippcp | b0bbe9bbb750a7cf4af5914dd8e6776a8d544466 | [
"Apache-2.0"
] | 1 | 2021-10-04T10:21:54.000Z | 2021-10-04T10:21:54.000Z | _build/dispatcher/jmp_ippsGFpECInitStd192r1_ffc1d72c.asm | zyktrcn/ippcp | b0bbe9bbb750a7cf4af5914dd8e6776a8d544466 | [
"Apache-2.0"
] | null | null | null | _build/dispatcher/jmp_ippsGFpECInitStd192r1_ffc1d72c.asm | zyktrcn/ippcp | b0bbe9bbb750a7cf4af5914dd8e6776a8d544466 | [
"Apache-2.0"
] | null | null | null | extern m7_ippsGFpECInitStd192r1:function
extern n8_ippsGFpECInitStd192r1:function
extern y8_ippsGFpECInitStd192r1:function
extern e9_ippsGFpECInitStd192r1:function
extern l9_ippsGFpECInitStd192r1:function
extern n0_ippsGFpECInitStd192r1:function
extern k0_ippsGFpECInitStd192r1:function
extern ippcpJumpIndexForMergedLibs
extern ippcpSafeInit:function
segment .data
align 8
dq .Lin_ippsGFpECInitStd192r1
.Larraddr_ippsGFpECInitStd192r1:
dq m7_ippsGFpECInitStd192r1
dq n8_ippsGFpECInitStd192r1
dq y8_ippsGFpECInitStd192r1
dq e9_ippsGFpECInitStd192r1
dq l9_ippsGFpECInitStd192r1
dq n0_ippsGFpECInitStd192r1
dq k0_ippsGFpECInitStd192r1
segment .text
global ippsGFpECInitStd192r1:function (ippsGFpECInitStd192r1.LEndippsGFpECInitStd192r1 - ippsGFpECInitStd192r1)
.Lin_ippsGFpECInitStd192r1:
db 0xf3, 0x0f, 0x1e, 0xfa
call ippcpSafeInit wrt ..plt
align 16
ippsGFpECInitStd192r1:
db 0xf3, 0x0f, 0x1e, 0xfa
mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc]
movsxd rax, dword [rax]
lea r11, [rel .Larraddr_ippsGFpECInitStd192r1]
mov r11, qword [r11+rax*8]
jmp r11
.LEndippsGFpECInitStd192r1:
| 30.282051 | 111 | 0.813717 |
b7e61d914d74979459be8b965bd2fa7929b1044b | 500 | asm | Assembly | oeis/274/A274657.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/274/A274657.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/274/A274657.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A274657: Numerators of the coefficients of z^n/n! for the expansion of hypergeometric([1/2,1/2],[1];z).
; Submitted by Christian Krause
; 1,1,9,75,3675,59535,2401245,57972915,13043905875,418854310875,30241281245175,1212400457192925,213786613951685775,10278202593831046875,1070401384414690453125,60013837619516978071875,57673297952355815927071875,3694483615889146090857721875
seq $0,92563 ; Coefficients in asymptotic expansion of I_0(x)sqrt(2*Pi*x)/e^x in powers of 1/(16x).
lpb $0
dif $0,2
lpe
| 55.555556 | 238 | 0.81 |
185402c4f5994e5fc69c77f7ebce768dbbf6bdcf | 291 | asm | Assembly | programs/oeis/040/A040551.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/040/A040551.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/040/A040551.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | ; A040551: Continued fraction for sqrt(575).
; 23,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46
mov $1,23
lpb $0,1
mod $0,2
mul $1,2
lpe
gcd $1,$0
| 29.1 | 189 | 0.604811 |
5aaf72982834469b863c68547ff5bf0eb00ae431 | 4,261 | asm | Assembly | Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0x48.log_21829_1887.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 9 | 2020-08-13T19:41:58.000Z | 2022-03-30T12:22:51.000Z | Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0x48.log_21829_1887.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 1 | 2021-04-29T06:29:35.000Z | 2021-05-13T21:02:30.000Z | Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0x48.log_21829_1887.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 3 | 2020-07-14T17:07:07.000Z | 2022-03-21T01:12:22.000Z | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %rax
push %rbx
push %rsi
lea addresses_WT_ht+0xf0d2, %rax
xor $38173, %rsi
mov (%rax), %r12d
nop
nop
nop
nop
dec %rbx
pop %rsi
pop %rbx
pop %rax
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r15
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_US+0xa936, %rsi
nop
cmp %rax, %rax
mov $0x5152535455565758, %rdi
movq %rdi, (%rsi)
nop
cmp $58890, %rsi
// Faulty Load
lea addresses_WC+0x33d2, %rdi
nop
nop
nop
nop
sub %r15, %r15
mov (%rdi), %r11
lea oracles, %rdi
and $0xff, %r11
shlq $12, %r11
mov (%rdi,%r11,1), %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': True, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 8, 'size': 4, 'same': False, 'NT': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
| 58.369863 | 2,999 | 0.660643 |
c59771dcc8470f2cd9c78ea615a72bd0a8214760 | 381 | asm | Assembly | programs/oeis/117/A117673.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/117/A117673.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/117/A117673.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A117673: a(n) is the least k such that k*2*prime(n) + 1 is prime.
; 1,1,1,2,1,2,3,5,1,1,5,2,1,2,3,1,6,3,2,4,2,2,1,1,2,3,3,3,5,1,2,1,3,2,4,3,5,2,7,1,1,3,1,2,9,2,5,6,12,6,1,1,3,1,3,3,4,3,2,1,3,1,2,3,3,13,3,5,3,5,7,1,3,2,6,6,12,3,4,2,1,5,1,2,5,1,4,15,3,6,3,4,2,1,2,3,1,16,5,9
seq $0,6093 ; a(n) = prime(n) - 1.
seq $0,34693 ; Smallest k such that k*n+1 is prime.
add $0,1
div $0,2
| 47.625 | 206 | 0.55643 |
f48062175cbfd2ea2a261554ccbff11970fe4c5e | 796 | asm | Assembly | krakensvm/ia32e/segment_intrins.asm | fengjixuchui/krakensvm-mg | 91652779af063bbc50b895796d4071dcccdca235 | [
"MIT"
] | 45 | 2022-03-13T07:17:19.000Z | 2022-03-30T02:01:46.000Z | krakensvm/ia32e/segment_intrins.asm | fengjixuchui/krakensvm-mg | 91652779af063bbc50b895796d4071dcccdca235 | [
"MIT"
] | null | null | null | krakensvm/ia32e/segment_intrins.asm | fengjixuchui/krakensvm-mg | 91652779af063bbc50b895796d4071dcccdca235 | [
"MIT"
] | 11 | 2022-03-13T07:27:16.000Z | 2022-03-16T00:55:21.000Z | ; got this Semantics idea from Daax & XEROXZ
; XEROXZ - (https://githacks.org/_xeroxz/bluepill/-/blob/master/segment_intrin.asm)
; Daax - 7 Days virtualization
.code
__reades proc
mov rax, es
ret
__reades endp
__readcs proc
mov rax, cs
ret
__readcs endp
__readss proc
mov rax, ss
ret
__readss endp
__readds proc
mov rax, ds
ret
__readds endp
__readfs proc
mov rax, fs
ret
__readfs endp
__readgs proc
mov rax, gs
ret
__readgs endp
__readtr proc
str ax
ret
__readtr endp
__readldt proc
sldt ax
ret
__readldt endp
__readrsp proc
mov rax, rsp
add rax, 8
ret
__readrsp endp
__readrip proc
mov rax, [rsp]
ret
__readrip endp
__readrflags proc
pushfq
pop rax
popfq
ret
__readrflags endp
END
| 12.246154 | 83 | 0.678392 |
f4d84b2b7c70ad871fc17c94217d60055093eb26 | 2,235 | asm | Assembly | recitations/DetailedStack.asm | lauras5/cs270_comporg | f00048e66a8ba52de3887200e73fb8a10b72227e | [
"MIT"
] | null | null | null | recitations/DetailedStack.asm | lauras5/cs270_comporg | f00048e66a8ba52de3887200e73fb8a10b72227e | [
"MIT"
] | null | null | null | recitations/DetailedStack.asm | lauras5/cs270_comporg | f00048e66a8ba52de3887200e73fb8a10b72227e | [
"MIT"
] | null | null | null | ; STEPS:
; 1. CALLER: push arguments (last to first)
; 2. CALLER: invoke subroutine (JSR)
; 3. CALLEE: allocate return address, push R7 & R5
; 4. CALLEE: set up new R5, allocate space for local var
; 5. CALLEE: execute function code
; 6. CALLEE: store result into return value slot
; 7. CALLEE: pop local vars, pop R5 & R7
; 8. CALLEE: return RET/JMP R7
; 9. CALLER: loads return value and pops args
; 10: CALLER: resumes computation
.ORIG x3000
; caller
MAIN LD R6, STACK ; init stack pointer, load location of stack
LD R0, B ; load second operand --> STEP 1
PUSH R0 ; PUSH second operand
LD R1, A ; load first operand
PUSH R1 ; PUSH first operand
JSR FOO ; call function --> STEP 2
LDR R0, R6, #0 ; POP return value
ADD R6, R6, #3 ; unwind stack
ST R0, C ; store result
HALT ; end program
; callee
FOO
ADD R6, R6, #1 ; allocate return value --> STEP 3
PUSH R7 ; PUSH return address
PUSH R5 ; PUSH frame pointer (top)
ADD R5, R6, #-1 ; FP = SP - 1 --> STEP 4.1
ADD R6, R6, #-1 ; alloc local var --> STEP 4.2
LDR R2, R5, #4 ; load first operand into R2
LDR R3, R5, #5 ; load second operand into R3
ADD R4, R3, R2 ; add operands --> STEP 5
STR R4, R5, #0 ; store local variable into R5 (pointer)
; stack exit code
STR R4, R5, #3 ; store return value --> STEP 6
ADD R6, R5, #1 ; SP = FP + 1
POP R5 ; pop frame pointer
POP R7 ; pop return address
RET ; return
A .FILL #5 ; first operand
B .FILL #20 ; second operand
C .BLKW 1 ; result
STACK .FILL x4000 ; stack address | 45.612245 | 80 | 0.447427 |
08d75240d133897916455c26d661fd93a8a47cb2 | 494 | asm | Assembly | oeis/028/A028026.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/028/A028026.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/028/A028026.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A028026: Expansion of 1/((1-3x)(1-4x)(1-5x)(1-7x)).
; Submitted by Christian Krause
; 1,19,230,2270,19971,163569,1278040,9670540,71557541,521211119,3754036650,26822296410,190541788711,1347984742669,9507913700060,66919750327880,470277075161481,3301201972518219,23154999755212270,162319024049252950,1137407684744763851
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,16801 ; Expansion of 1/((1-3x)(1-4x)(1-7x)).
sub $0,$1
mul $1,6
add $1,$0
lpe
mov $0,$1
| 27.444444 | 232 | 0.716599 |
33a092280b523a80b75d050a3ec55e94173fdc54 | 792 | asm | Assembly | programs/oeis/221/A221543.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/221/A221543.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | programs/oeis/221/A221543.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | ; A221543: Number of 0..n arrays of length 5 with each element differing from at least one neighbor by something other than 1, starting with 0.
; 3,22,103,303,716,1455,2658,4487,7128,10791,15710,22143,30372,40703,53466,69015,87728,110007,136278,166991,202620,243663,290642,344103,404616,472775,549198,634527,729428,834591,950730,1078583,1218912
mov $1,$0
trn $1,3
add $1,3
mov $5,$0
lpb $0
mul $0,2
sub $0,2
mov $1,$3
lpe
mov $2,10
mov $6,$5
lpb $2
add $1,$6
sub $2,1
lpe
mov $4,$5
lpb $4
sub $4,1
add $7,$6
lpe
mov $2,6
mov $6,$7
lpb $2
add $1,$6
sub $2,1
lpe
mov $4,$5
mov $7,0
lpb $4
sub $4,1
add $7,$6
lpe
mov $2,5
mov $6,$7
lpb $2
add $1,$6
sub $2,1
lpe
mov $4,$5
mov $7,0
lpb $4
sub $4,1
add $7,$6
lpe
mov $2,1
mov $6,$7
lpb $2
add $1,$6
sub $2,1
lpe
| 14.666667 | 200 | 0.637626 |
acfd76fe6b44c1d1452f90450710f3ecd2d03fac | 269 | asm | Assembly | kernal/src/kernal_loader.asm | arpitchakladar/bazl | bd871d06b440b03bf05b153a3705ca3321b081f3 | [
"MIT"
] | null | null | null | kernal/src/kernal_loader.asm | arpitchakladar/bazl | bd871d06b440b03bf05b153a3705ca3321b081f3 | [
"MIT"
] | null | null | null | kernal/src/kernal_loader.asm | arpitchakladar/bazl | bd871d06b440b03bf05b153a3705ca3321b081f3 | [
"MIT"
] | null | null | null | bits 16
extern BOOT_DRIVE_NUMBER
extern main
extern sys_call
section .text
global _start
_start:
mov [BOOT_DRIVE_NUMBER], dl
; initialize system calls
cli
mov bx, sys_call
mov [0x0088], bx
mov [0x008a], cs
sti
; start
call main
jmp $
| 11.695652 | 29 | 0.67658 |
e4f5eb5ab6d64737c69002ba00f1531e078e9494 | 638 | asm | Assembly | programs/oeis/238/A238535.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/238/A238535.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/238/A238535.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A238535: Sum of divisors d of n where d > sqrt(n).
; 0,2,3,4,5,9,7,12,9,15,11,22,13,21,20,24,17,33,19,35,28,33,23,50,25,39,36,49,29,61,31,56,44,51,42,75,37,57,52,78,41,84,43,77,69,69,47,108,49,85,68,91,53,108,66,106,76,87,59,147,61,93,93,112,78,132,67,119,92,129,71,171,73,111,115,133,88,156,79,166,108,123,83,201,102,129,116,165,89,208,104,161,124,141,114,228,97,161,143,195
add $0,1
mov $2,$0
lpb $0
mov $3,$2
lpb $2,2
add $5,1
mov $26,$0
cmp $26,0
add $0,$26
dif $3,$0
lpb $3
cmp $3,$2
add $2,5
cmp $3,0
mul $3,$0
sub $3,1
lpe
lpe
sub $0,1
add $9,$5
lpe
mov $0,$9
| 24.538462 | 324 | 0.568966 |
b101748024d27fa03157b69cd4d2b1bf83bfce7b | 236 | asm | Assembly | Assignment-1/Assignment1/supporting_files/program_templates/descending_template.asm | abhiisshheekk/CS311-COA-Lab | c5effdc22bd7c1c35ba44fe3a6f8998c8189554e | [
"MIT"
] | 1 | 2021-05-16T14:13:12.000Z | 2021-05-16T14:13:12.000Z | Assignment-1/Assignment1/supporting_files/program_templates/descending_template.asm | abhiisshheekk/CS311-COA-Lab | c5effdc22bd7c1c35ba44fe3a6f8998c8189554e | [
"MIT"
] | null | null | null | Assignment-1/Assignment1/supporting_files/program_templates/descending_template.asm | abhiisshheekk/CS311-COA-Lab | c5effdc22bd7c1c35ba44fe3a6f8998c8189554e | [
"MIT"
] | 1 | 2022-03-19T14:56:20.000Z | 2022-03-19T14:56:20.000Z | .data
a:
70
80
40
20
10
30
50
60
n:
8
.text
// your code here
// you may change the numbers in the array, and the size of the array; but allow the name of the array to remain as 'a', and size as 'n'
// remove these comments!
| 13.882353 | 136 | 0.661017 |
c630b12c7a367698a227185b21205f3970e718ae | 350 | asm | Assembly | programs/oeis/080/A080846.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/080/A080846.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/080/A080846.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A080846: Fixed point of the morphism 0->010, 1->011, starting from a(1) = 0.
; 0,1,0,0,1,1,0,1,0,0,1,0,0,1,1,0,1,1,0,1,0,0,1,1,0,1,0,0,1,0,0,1,1,0,1,0,0,1,0,0,1,1,0,1,1,0,1,0,0,1,1,0,1,1,0,1,0,0,1,1,0,1,0,0,1,0,0,1,1,0,1,1,0,1,0,0,1,1,0,1,0,0,1,0,0,1,1,0,1,0,0,1,0,0,1,1,0,1,1,0
add $0,1
lpb $0
lpb $0
dif $0,3
lpe
mod $0,3
lpe
div $0,2
| 29.166667 | 201 | 0.534286 |
39d3bc8f1857343597aafedd54f221ba2c9a0104 | 12,329 | asm | Assembly | Appl/Calendar/Misc/miscPrint.asm | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 504 | 2018-11-18T03:35:53.000Z | 2022-03-29T01:02:51.000Z | Appl/Calendar/Misc/miscPrint.asm | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 96 | 2018-11-19T21:06:50.000Z | 2022-03-06T10:26:48.000Z | Appl/Calendar/Misc/miscPrint.asm | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 73 | 2018-11-19T20:46:53.000Z | 2022-03-29T00:59:26.000Z | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1989 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Calendar/Misc - Printing Mechanisms
FILE: miscPrint.asm
AUTHOR: Don Reeves, February 25, 1990
ROUTINES:
Name Description
---- -----------
GLB MyPrintSetOutputType MSG_MY_PRINT_SET_OUTPUT_TYPE handler
GLB MyPrintSetIncludeEvents MSG_MY_PRINT_SET_INCLUDE_EVENTS handler
GLB MyPrintGetPrintInfo MSG_MY_PRINT_GET_INFO handler
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/25/90 Initial revision
DESCRIPTION:
Contains all the code dealing with print UI.
$Id: miscPrint.asm,v 1.1 97/04/04 14:48:43 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
idata segment
MyPrintClass
idata ends
PrintCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MyPrintUpdateDisplayData
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update the data displayed in the print options DB
CALLED BY: GLOBAL (MSG_MY_PRINT_UPDATE_DISPLAY_DATA)
PASS: *DS:SI = MyPrintClass object
DS:DI = MyPrintClassInstance
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MyPrintUpdateDisplayData method dynamic MyPrintClass,
MSG_MY_PRINT_UPDATE_DISPLAY_DATA
.enter
; If we've already initialized the year/month, don't
; do it again. Actually, I don't see a good reason for
; doing this, and there is a good reason not to do
; this - so that whenever we print the current month
; and year will be displayed. So, I've commented it out.
; -Don 4/29/00
;
;;; test ds:[di].MPI_attrs, mask MPA_INITIALIZED
;;; jnz eventTitle
;;; or ds:[di].MPI_attrs, mask MPA_INITIALIZED
; Get the current month & day. We previously
; would retrieve the selection range and use
; the start month/year, but it seems that we can
; do better and show the contents of the YearView.
;
mov ax, MSG_YEAR_GET_MONTH_AND_YEAR
GetResourceHandleNS YearObject, bx
mov si, offset YearObject
call ObjMessage_print_call
; Update the month & day spinners
;
push dx
mov cl, ch
clr ch
mov si, offset DataMonth
call PrintSetRangeValue
pop cx
mov si, offset DataYear
call PrintSetRangeValue
; Update the event text
eventTitle::
mov ax, MSG_DP_SET_TITLE
GetResourceHandleNS DayPlanObject, bx
mov si, offset DayPlanObject
mov cx, ds:[LMBH_handle]
mov dx, offset DataEvents
call ObjMessage_print_send
.leave
ret
MyPrintUpdateDisplayData endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MyPrintSetOutputType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the type of print output the user desires.
CALLED BY: UI (MSG_MY_PRINT_SET_OUTPUT_TYPE)
PASS: ES = DGroup
DS:DI = MyPrintClass specific instance data
CL = MyPrintOutputType
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
Sets things enabled/disabled as necessary
Set the output of printing correctly
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 2/26/90 Initial version
Don 5/11/90 Removed delayed stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MyPrintSetOutputType method dynamic MyPrintClass,
MSG_MY_PRINT_SET_OUTPUT_TYPE
.enter
; Store the new output type
;
and ds:[di].MPI_attrs, not (mask MPA_OUTPUT_TYPE)
or ds:[di].MPI_attrs, cl ; set the new output type
mov bl, cl ; MyPrintOutputType => BL
; Enable or disable the Include Events checkbox
;
mov ax, MSG_GEN_SET_ENABLED
cmp bl, MPOT_GR_MONTH
je setStatus
mov ax, MSG_GEN_SET_NOT_ENABLED
setStatus:
mov si, offset IncludeEventsEntry
call ObjCallInstanceNoLock_VUM
; Now determine which data controls are displayed
;
mov ax, MSG_GEN_SET_USABLE
mov bp, MSG_GEN_SET_NOT_USABLE
cmp bl, MPOT_EVENTS
je setDataEvents
xchg ax, bp
setDataEvents:
push bp
mov si, offset DataEvents
call ObjCallInstanceNoLock_VUM
pop ax
mov si, offset DataMonthYear
call ObjCallInstanceNoLock_VUM
mov ax, MSG_GEN_SET_USABLE
cmp bl, MPOT_GR_MONTH
je setDataMonth
mov ax, MSG_GEN_SET_NOT_USABLE
setDataMonth:
mov si, offset DataMonth
call ObjCallInstanceNoLock_VUM
.leave
ret
MyPrintSetOutputType endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MyPrintSetIncludeEvents
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the collate mode on/off
CALLED BY: UI (MSG_MY_PRINT_SET_INCLUDE_EVENTS)
PASS: DS:DI = MyPrintClass specific instance data
CL = mask MPA_INCLUDE_EVENTS or 0
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 6/25/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MyPrintSetIncludeEvents method dynamic MyPrintClass,
MSG_MY_PRINT_SET_INCLUDE_EVENTS
; Set or clear the flag
;
and ds:[di].MPI_attrs, not (mask MPA_INCLUDE_EVENTS)
or ds:[di].MPI_attrs, cl
ret
MyPrintSetIncludeEvents endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MyPrintStartPrinting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Start printing, please
CALLED BY: GLOBAL (MSG_PRINT_START_PRINTING)
PASS: *DS:SI = MyPrintClass object
DS:DI = MyPrintClassInstance
CX:DX = OD of PrintControl object
BP = GState to print to
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP
PSEUDO CODE/STRATEGY:
We want, if at all possible, for the document to fit.
So try doing things with the margins oriented in
either direction.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 10/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MyPrintStartPrinting method dynamic MyPrintClass, MSG_PRINT_START_PRINTING
.enter
; Set the number of pages to 1 (the default)
;
push cx, dx, bp ; save message data
push si ; save my chunk handle
mov ax, MSG_PRINT_CONTROL_SET_TOTAL_PAGE_RANGE
movdw bxsi, cxdx
mov cx, 1
mov dx, cx
call ObjMessage_print_send
; First set the document size
;
sub sp, size PageSizeReport
mov bp, sp
push bx, si ; save OD of PrintControl
mov dx, ss ; PageSizeReport => DX:BP
mov ax, MSG_PZC_GET_PAGE_SIZE
GetResourceHandleNS CalendarPageSetup, bx
mov si, offset CalendarPageSetup
call ObjMessage_print_call
mov ax, ss:[bp].PSR_width.low
mov es:[printWidth], ax
mov ax, ss:[bp].PSR_height.low
mov es:[printHeight], ax
; Get the printer's margins
;
mov ax, MSG_PRINT_CONTROL_GET_PRINTER_MARGINS
pop bx, si ; PrintControl OD => BX:SI
mov dx, FALSE ; no reason to set the margins
call ObjMessage_print_call ; margins => AX, CX, DX, BP
mov di, bp
mov bp, sp
mov ss:[bp].PSR_margins.PCMP_left, cx
mov ss:[bp].PSR_margins.PCMP_top, ax
mov ss:[bp].PSR_margins.PCMP_right, di
mov ss:[bp].PSR_margins.PCMP_bottom, dx
; Set the document info, and see if it will fit. If it
; doesn't then assume the other way.
;
push ax, cx, dx, di
call MyPrintSetSizeCheckFit
tst ax
pop ax, cx, dx, di
jnz thingsFitWell
mov ss:[bp].PSR_margins.PCMP_left, ax
mov ss:[bp].PSR_margins.PCMP_top, cx
mov ss:[bp].PSR_margins.PCMP_right, dx
mov ss:[bp].PSR_margins.PCMP_bottom, di
call MyPrintSetSizeCheckFit
; Now store the printable area & top/left margins
thingsFitWell:
mov ax, ss:[bp].PSR_margins.PCMP_left
mov cx, ss:[bp].PSR_margins.PCMP_top
mov dx, ss:[bp].PSR_margins.PCMP_right
mov bp, ss:[bp].PSR_margins.PCMP_bottom
add sp, size PageSizeReport
mov es:[printMarginLeft], ax
mov es:[printMarginTop], cx
add ax, dx ; horizontal margins => AX
add bp, cx ; vertical margins => BP
sub es:[printWidth], ax
sub es:[printHeight], bp
dec es:[printHeight] ; month can be one pixel too
; long, so add in margin here
; Finally, send the print message off to the proper object
;
pop si
mov di, ds:[si]
add di, ds:[di].MyPrint_offset
GetResourceHandleNS YearObject, bx
mov si, offset YearObject
test ds:[di].MPI_attrs, MPOT_EVENTS
jz startPrinting
GetResourceHandleNS DayPlanObject, bx
mov si, offset DayPlanObject
startPrinting:
mov ax, MSG_PRINT_START_PRINTING
pop cx, dx, bp
call ObjMessage_print_send
.leave
ret
MyPrintStartPrinting endm
MyPrintSetSizeCheckFit proc near
uses bp
.enter
; First set the size
;
mov dx, ss
mov ax, MSG_PRINT_CONTROL_SET_DOC_SIZE_INFO
call ObjMessage_print_call
; Now see if things fit
;
mov ax, MSG_PRINT_CONTROL_CHECK_IF_DOC_WILL_FIT
clr cx ; don't display warning
call ObjMessage_print_call
.leave
ret
MyPrintSetSizeCheckFit endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MyPrintGetInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns all of the current print data
CALLED BY: GLOBAL (MSG_MY_PRINT_GET_INFO)
PASS: DS:DI = MyPrintClass specific instance data
RETURN: CX = FontID to use for printing
DL = MyPrintAttrs
DH = Month
BP = Year
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/13/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MyPrintGetInfo method dynamic MyPrintClass, MSG_MY_PRINT_GET_INFO
.enter
; Return the crucial information
;
mov bl, ds:[di].MPI_attrs
mov di, ds:[di].MPI_fontID
call GetOverrideFontID
; Grab the month & the year
;
mov si, offset DataYear
call PrintGetRangeValue
push dx ; save the year
mov si, offset DataMonth
call PrintGetRangeValue
mov dh, dl ; month => DH
mov dl, bl ; MyPrintAttrs => DL
mov cx, di ; FontID => CX
pop bp ; year => BP
.leave
ret
MyPrintGetInfo endp
GetOverrideFontID proc near
uses ax, cx, dx, si, ds
.enter
; Look in the .INI file for a font override
;
segmov ds, cs, cx
mov si, offset fontIDOverrideCategory
mov dx, offset fontIDOverrideKey
mov_tr ax, di ; default => AX
call InitFileReadInteger
mov_tr di, ax ; new fontID (maybe) => DI
.leave
ret
GetOverrideFontID endp
fontIDOverrideCategory char "GeoPlanner", 0
fontIDOverrideKey char "printFontID", 0
PrintSetRangeValue proc near
mov ax, MSG_GEN_VALUE_SET_INTEGER_VALUE
clr bp ; determinate
GOTO ObjCallInstanceNoLock_print
PrintSetRangeValue endp
PrintGetRangeValue proc near
mov ax, MSG_GEN_VALUE_GET_VALUE
GOTO ObjCallInstanceNoLock_print
PrintGetRangeValue endp
ObjCallInstanceNoLock_VUM proc near
mov dl, VUM_DELAYED_VIA_UI_QUEUE
FALL_THRU ObjCallInstanceNoLock_print
ObjCallInstanceNoLock_VUM endp
ObjCallInstanceNoLock_print proc near
call ObjCallInstanceNoLock
ret
ObjCallInstanceNoLock_print endp
ObjMessage_print_send proc near
mov di, mask MF_FIXUP_DS
GOTO ObjMessage_print
ObjMessage_print_send endp
ObjMessage_print_call proc near
mov di, mask MF_CALL or mask MF_FIXUP_DS or mask MF_FIXUP_ES
FALL_THRU ObjMessage_print
ObjMessage_print_call endp
ObjMessage_print proc near
call ObjMessage
ret
ObjMessage_print endp
PrintCode ends
| 25.420619 | 79 | 0.632087 |
955806cd74852c6ddb29306f534545b693cb2dff | 4,563 | asm | Assembly | Transynther/x86/_processed/US/_zr_/i7-8650U_0xd2_notsx.log_1649_878.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 9 | 2020-08-13T19:41:58.000Z | 2022-03-30T12:22:51.000Z | Transynther/x86/_processed/US/_zr_/i7-8650U_0xd2_notsx.log_1649_878.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 1 | 2021-04-29T06:29:35.000Z | 2021-05-13T21:02:30.000Z | Transynther/x86/_processed/US/_zr_/i7-8650U_0xd2_notsx.log_1649_878.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 3 | 2020-07-14T17:07:07.000Z | 2022-03-21T01:12:22.000Z | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x12424, %rsi
lea addresses_A_ht+0x950c, %rdi
nop
nop
nop
nop
nop
and %rbp, %rbp
mov $110, %rcx
rep movsl
nop
nop
add $33257, %r11
lea addresses_WT_ht+0x110dc, %r14
nop
nop
nop
nop
nop
and %rbp, %rbp
mov (%r14), %cx
nop
and $54493, %r14
lea addresses_D_ht+0xdeb4, %rdi
nop
nop
nop
nop
cmp %rsi, %rsi
mov (%rdi), %r14
cmp %rbp, %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r15
push %rax
push %rbx
push %rsi
// Faulty Load
lea addresses_US+0x1e3f4, %r15
clflush (%r15)
nop
nop
nop
inc %r11
movb (%r15), %bl
lea oracles, %r14
and $0xff, %rbx
shlq $12, %rbx
mov (%r14,%rbx,1), %rbx
pop %rsi
pop %rbx
pop %rax
pop %r15
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 6, 'same': False}}
{'00': 1649}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
| 50.7 | 2,999 | 0.66053 |
3f8be49d134b62898c1b39f7c1681629a338adaf | 944 | asm | Assembly | programs/oeis/156/A156865.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/156/A156865.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/156/A156865.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A156865: 729000n - 612180.
; 116820,845820,1574820,2303820,3032820,3761820,4490820,5219820,5948820,6677820,7406820,8135820,8864820,9593820,10322820,11051820,11780820,12509820,13238820,13967820,14696820,15425820,16154820,16883820,17612820,18341820,19070820,19799820,20528820,21257820,21986820,22715820,23444820,24173820,24902820,25631820,26360820,27089820,27818820,28547820,29276820,30005820,30734820,31463820,32192820,32921820,33650820,34379820,35108820,35837820,36566820,37295820,38024820,38753820,39482820,40211820,40940820,41669820,42398820,43127820,43856820,44585820,45314820,46043820,46772820,47501820,48230820,48959820,49688820,50417820,51146820,51875820,52604820,53333820,54062820,54791820,55520820,56249820,56978820,57707820,58436820,59165820,59894820,60623820,61352820,62081820,62810820,63539820,64268820,64997820,65726820,66455820,67184820,67913820,68642820,69371820,70100820,70829820,71558820,72287820
mul $0,729000
add $0,116820
| 157.333333 | 885 | 0.872881 |
143f83a544c278f58f5ac076f846d319b48d382a | 310 | asm | Assembly | libsrc/_DEVELOPMENT/adt/p_forward_list/c/sccz80/p_forward_list_remove.asm | teknoplop/z88dk | bb03fbfd6b2ab0f397a1358559089f9cd3706485 | [
"ClArtistic"
] | 8 | 2017-01-18T12:02:17.000Z | 2021-06-12T09:40:28.000Z | libsrc/_DEVELOPMENT/adt/p_forward_list/c/sccz80/p_forward_list_remove.asm | teknoplop/z88dk | bb03fbfd6b2ab0f397a1358559089f9cd3706485 | [
"ClArtistic"
] | 1 | 2017-03-06T07:41:56.000Z | 2017-03-06T07:41:56.000Z | libsrc/_DEVELOPMENT/adt/p_forward_list/c/sccz80/p_forward_list_remove.asm | teknoplop/z88dk | bb03fbfd6b2ab0f397a1358559089f9cd3706485 | [
"ClArtistic"
] | 3 | 2017-03-07T03:19:40.000Z | 2021-09-15T17:59:19.000Z |
; void *p_forward_list_remove(p_forward_list_t *list, void *item)
SECTION code_clib
SECTION code_adt_p_forward_list
PUBLIC p_forward_list_remove
EXTERN asm_p_forward_list_remove
p_forward_list_remove:
pop af
pop bc
pop hl
push hl
push bc
push af
jp asm_p_forward_list_remove
| 14.090909 | 65 | 0.767742 |
936ed1deb86d315e88fbde247ac5c6fae4c56fe9 | 3,730 | asm | Assembly | main/swos1617.asm | zlatkok/swospp | 27a2d2061af2f46c59f2470b138c7170c45fe03b | [
"MIT"
] | 12 | 2016-02-18T12:53:52.000Z | 2022-02-09T11:07:23.000Z | main/swos1617.asm | zlatkok/swospp | 27a2d2061af2f46c59f2470b138c7170c45fe03b | [
"MIT"
] | null | null | null | main/swos1617.asm | zlatkok/swospp | 27a2d2061af2f46c59f2470b138c7170c45fe03b | [
"MIT"
] | null | null | null | ; Implement SWOS 96/97 specific entry in main menu
[list -]
%include "swos.inc"
%include "swsmenu.inc"
[list +]
section .data
; special entry for SWOS 96/97
swosAnniversaryEntry:
dw 92 ; x
dw 165 ; y
dw 120 ; width
dw 16 ; height
dw 2 ; type 2 - positions
db -1 ; left - nothing
db -1 ; right - nothing
db 12 ; up - "LOAD OLD COMPETITION"
db -1 ; down - nothing
dw 4 ; type 4 - background color
dw 13
dw 8 ; type 8 - string
dw 16 ; string flags
declareStr "16/17 CREDITS"
dw 13 ; type 13 - on select function
dd ShowSWOSAnniversaryMenu
dw 0 ; type 0 - end of menu entry
swosAnniversaryEntrySize equ $ - swosAnniversaryEntry
newMainMenuSize equ SWOS_MAIN_MENU_SIZE + swosAnniversaryEntrySize
section .bss
; reserve space for new SWOS main menu (size of the menu + one entry)
global newMainMenu
declareStatic newMainMenu, newMainMenuSize
section .text
; SetupSWOSAnniversaryMenu
;
; Copy SWOS main menu to new location and edit it, in order to show new SWOS 16/17 menu entry.
; Note that all patches for SWOS++ entry are done by now.
;
global SetupSWOSAnniversaryMenu
SetupSWOSAnniversaryMenu:
mov eax, newMainMenu
mov ecx, (SWOS_MAIN_MENU_SIZE - 8) / 4
mov esi, SWOS_MainMenu
mov edi, eax
rep movsd
mov ecx, swosAnniversaryEntrySize
mov esi, swosAnniversaryEntry
rep movsb
mov dword [edi], 0x0000fc1a
mov dword [edi + 4], 0xfc190000
; fix down entry for "LOAD OLD COMPETITION"
mov byte [eax + 0x1c3], 13
; now that everything is ready, replace SWOS menu references, rest is in our code
mov dword [ExitEuropeanChampionshipMenu + 6], newMainMenu
mov eax, ShowSWOSAnniversaryEntry
mov ebx, CommonMenuExit + 0x98 + 5
sub eax, ebx
mov [CommonMenuExit + 0x99], eax
mov eax, HideSWOSAnniversaryEntry
mov ebx, CommonMenuExit + 0x175 + 5
sub eax, ebx
mov [CommonMenuExit + 0x176], eax
retn
; ShowOrHideAnniversaryEntry
;
; in:
; edi - boolean, show or hide the entry
;
; Show or hide SWOS 16/17 entry in main menu as needed. Called from patched SWOS code,
; so must call CalcMenuEntryAddress before returning.
;
ShowOrHideAnniversaryEntry:
mov esi, CalcMenuEntryAddress
call esi
mov ecx, [A0]
mov word [D0], 13
call esi
mov eax, [A0]
mov [eax + MenuEntry.isInvisible], di
mov [A0], ecx
retn
; ShowSWOSAnniversaryEntry
;
; Show SWOS 16/17 entry when we are not showing prompt to save career.
;
ShowSWOSAnniversaryEntry:
xor edi, edi
jmp ShowOrHideAnniversaryEntry
; HideSWOSAnniversaryEntry
;
; Hide SWOS 16/17 entry or it will be drawn all across the bottom prompt to save career.
;
HideSWOSAnniversaryEntry:
or edi, 1
jmp ShowOrHideAnniversaryEntry
ShowSWOSAnniversaryMenu:
mov dword [A6], swosAnniversaryMenu
calla ShowMenu
jmpa CommonMenuExit
section .data
global swosUnitedLogo
swosUnitedLogo:
incbin "../bitmap/swos_united_logo.bp"
extern SWOSAnniversaryMenuOnDraw, SWOSAnniversaryMenuInit
;
; SWOS 96/97 menu
;
StartMenu swosAnniversaryMenu, SWOSAnniversaryMenuInit, 0, SWOSAnniversaryMenuOnDraw, 1
; title
StartEntry 92, 2, 120, 11
EntryColor 0x17
EntryString 0, "16/17 CREDITS"
EndEntry
; exit
StartEntry 250, 188, 60, 11
EntryColor 10
EntryString 0, aExit
OnSelect SetExitMenuFlag
EndEntry
EndMenu
| 25.033557 | 94 | 0.645576 |
f7cc48886113025733931a7d6bfaa2fbb4089756 | 11,101 | asm | Assembly | code/6502/tests/inp/kbtest.asm | visrealm/hbc-56 | 9c082946e247e79edc12867299b5b0fda3b6c873 | [
"MIT"
] | 65 | 2021-07-22T10:32:02.000Z | 2022-03-30T04:42:45.000Z | code/6502/tests/inp/kbtest.asm | visrealm/hbc-56 | 9c082946e247e79edc12867299b5b0fda3b6c873 | [
"MIT"
] | 5 | 2022-03-29T20:23:57.000Z | 2022-03-30T23:12:42.000Z | code/6502/tests/inp/kbtest.asm | visrealm/hbc-56 | 9c082946e247e79edc12867299b5b0fda3b6c873 | [
"MIT"
] | 4 | 2021-12-30T17:13:23.000Z | 2022-03-05T09:07:22.000Z | ; Troy's HBC-56 - Input test
;
; Copyright (c) 2021 Troy Schrapel
;
; This code is licensed under the MIT license
;
; https://github.com/visrealm/hbc-56
;
!src "hbc56kernel.inc"
Y_OFFSET = 4
PRESSED_KEY_COUNT = HBC56_USER_ZP_START
pressedTable = $1000
extPressedTable = $1100
hbc56Meta:
+setHbcMetaTitle "KEYBOARD TEST"
rts
hbc56Main:
jsr tmsModeGraphicsI
; set up sprite mode (16x16, unmagnified)
lda #TMS_R1_SPRITE_MAG2
jsr tmsReg1ClearFields
lda #TMS_R1_SPRITE_16
jsr tmsReg1SetFields
; set up color table
+tmsSetAddrColorTable
+tmsSendData colorTab, 32
; clear the name table
+tmsSetAddrNameTable
lda #$f9
jsr _tmsSendPage
jsr _tmsSendPage
jsr _tmsSendPage
; load the keyboard glyph data
+tmsSetAddrPattTable
+tmsSendData keyboardPatt, 256*8
; output the keyboard tiles
+tmsSetPosWrite 0, Y_OFFSET
+tmsSendData keyboardInd, 512
; set up the overlay sprites
+tmsSetAddrSpritePattTable
+tmsSendData sprites, 4*8
+tmsCreateSprite 0, 0, 0, $d0, TMS_DK_GREEN
+tmsCreateSprite 1, 0, 0, $d0, TMS_DK_GREEN
+tmsCreateSprite 2, 0, 0, $d0, TMS_DK_GREEN
+tmsCreateSprite 3, 0, 0, $d0, TMS_DK_GREEN
+tmsCreateSprite 4, 0, 0, $d0, TMS_DK_GREEN
+tmsCreateSprite 5, 0, 0, $d0, TMS_DK_GREEN
+tmsCreateSprite 6, 0, 0, $d0, TMS_DK_GREEN
+tmsCreateSprite 7, 0, 0, $d0, TMS_DK_GREEN
; clear the key pressed tables
+memset pressedTable, 0, 256
+memset extPressedTable, 0, 256
+tmsEnableOutput
+hbc56SetVsyncCallback outputLoop
cli
+tmsEnableInterrupts
; -----------------------------------------------------------------------------
; Input loop runs continuously and sets the key tables
; -----------------------------------------------------------------------------
inputLoop:
jsr kbReadByte ; load scancode into X
cpx #0
beq inputLoop
cpx #KB_RELEASE ; is it a release code?
beq keyReleased
cpx #KB_EXT_KEY ; is it an extended key code?
beq extendedKey
cpx #$e1 ; is it the pause/break key?
beq pauseBreakLoop
jmp keyPressed ; just a regular key (pressed)
; -----------------------------------------------------------------------------
; Pause/break handler (presss/release only sent on key release)
; -----------------------------------------------------------------------------
pauseBreakLoop:
jsr kbReadByte
cpx #0
beq pauseBreakLoop ; get next scancode (either $14 or $f0)
cpx #$14 ; if it's $14, then it's a press
beq pausePressed
jsr kbWaitForScancode ; eat the next two scancodes
jsr kbWaitForScancode
lda #0 ; mark as released
sta pressedTable + 2
jmp keyPressed
pausePressed:
jsr kbWaitForScancode ; eat the next two scancodes
jsr kbWaitForScancode
lda #1 ; mark as pressed
sta pressedTable + 2
jmp keyPressed
; -----------------------------------------------------------------------------
; A standard key was pressed (scancode in X)
; -----------------------------------------------------------------------------
keyPressed:
lda #1 ; mark as pressed
sta pressedTable,x
jmp inputLoop
; -----------------------------------------------------------------------------
; A standard key was released ($f0 in X)
; -----------------------------------------------------------------------------
keyReleased:
jsr kbReadByte ; get the released key scancode
cpx #0
beq keyReleased
lda #0 ; mark as released
sta pressedTable,x
jmp inputLoop
; -----------------------------------------------------------------------------
; An extended key was pressed ($e0 in X)
; -----------------------------------------------------------------------------
extendedKey:
jsr kbReadByte
cpx #0
beq extendedKey ; get the scancode
cpx #KB_RELEASE ; is it the release code?
beq extKeyReleased
jmp extKeyPressed ; extended key pressed
; -----------------------------------------------------------------------------
; An extended key was pressed (scancode in X)
; -----------------------------------------------------------------------------
extKeyPressed:
lda #1 ; mark as pressed
sta extPressedTable,x
jmp inputLoop
; -----------------------------------------------------------------------------
; An extended key was released ($f0 in X)
; -----------------------------------------------------------------------------
extKeyReleased:
jsr kbReadByte
cpx #0
beq extKeyReleased ; get the scancode
lda #0
sta extPressedTable,x ; mark as released
jmp inputLoop
; -----------------------------------------------------------------------------
; Output a sprite overlay at the key position
; -----------------------------------------------------------------------------
doShowKey:
lda PRESSED_KEY_COUNT ; set up sprite attribute address for writing
jsr tmsSetSpriteTmpAddress
jsr tmsSetAddressWrite
tya ; set Y location
clc
adc #(Y_OFFSET*8-1) ; add keyboard vertical offset
+tmsPut
txa ; set X location
+tmsPut
inc PRESSED_KEY_COUNT
rts
; -----------------------------------------------------------------------------
; Show a standard key
; -----------------------------------------------------------------------------
showKey:
txa
pha
ldy keyPosY,x ; find key position
lda keyPosX,x
beq @noShow ; 0? not a supported key
tax ; add an overlay for the key
jsr doShowKey
@noShow
pla
tax
jmp doneShowKey
; -----------------------------------------------------------------------------
; Show an extended key
; -----------------------------------------------------------------------------
showExtKey:
txa
pha
ldy extKeyPosY,x ; find key position
lda extKeyPosX,x
beq @noShowExt ; 0? not a supported key
tax
jsr doShowKey ; add an overlay for the key
@noShowExt
pla
tax
jmp doneShowExtKey
; -----------------------------------------------------------------------------
; Output loop (runs once for each VSYNC)
; -----------------------------------------------------------------------------
outputLoop:
stx HBC56_TMP_X ; keep X/Y
sty HBC56_TMP_Y
; +tmsSetColorFgBg TMS_WHITE, TMS_LT_GREEN ; keep track of vsync processing time
lda #0 ; clear pressed count
sta PRESSED_KEY_COUNT
ldx #131 ; max normal key index
- ; iterate over the scancode table
lda pressedTable,x ; if a key is pressed, show the overlay
bne showKey
doneShowKey:
dex
bne -
ldx #125 ; max ext key index
- ; iterate over the extended scancode table
lda extPressedTable,x ; if a key is pressed, show the overlay
bne showExtKey
doneShowExtKey:
dex
bne -
lda PRESSED_KEY_COUNT ; set the next sprite Y location to $d0 (last sprite)
jsr tmsSetSpriteTmpAddress
jsr tmsSetAddressWrite
lda #$d0
+tmsPut
ldx HBC56_TMP_X ; restore X/Y
ldy HBC56_TMP_Y
lda #1 ; set sprite visibility based on frame count
bit HBC56_TICKS
beq evenFrame
jmp oddFrame
rts
; -----------------------------------------------------------------------------
; Even frames hide overlay sprites
; -----------------------------------------------------------------------------
evenFrame:
!for i,0,8 {
+tmsSpriteColor i, TMS_TRANSPARENT
}
+tmsSetColorFgBg TMS_WHITE, TMS_DK_BLUE ; end vsync processing time
rts
; -----------------------------------------------------------------------------
; Odd frames show overlay sprites
; -----------------------------------------------------------------------------
oddFrame:
!for i,0,8 {
+tmsSpriteColor i, TMS_DK_GREEN
}
+tmsSetColorFgBg TMS_WHITE, TMS_DK_BLUE ; end vsync processing time
rts
; -----------------------------------------------------------------------------
; Key position tables (scancode to X/Y pixel)
; -----------------------------------------------------------------------------
keyPosX:
!byte 0,135,219,79,51,23,37,177,0,149,121,93,65,13, 9,0,0, 54,19,0, 9,32,24,0,0,0,45,52,37,47,39,0,0,75,60,67,62,69,54,0,0, 97,90,82,92,77,84,0,0,120,105,112,97,107,99,0,0,0,135,127,122,114,129,0,0,150,142,137,152,159,144,0,0,165,180,157,172,167,174,0,0,0,187,0,182,189,0,0,16,199,210,197,0,215,0,0,0,0,0,0,0,0,211,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 9,0,163,0,0,0,0,0,205,0,0,0,0,107
keyPosY:
!byte 0, 25, 25,25,25,25,25, 25,0, 25, 25,25,25,56,40,0,0,104,88,0,104,56,40,0,0,0,88,72,72,56,40,0,0,88,88,72,56,40,40,0,0,104,88,72,56,56,40,0,0, 88, 88, 72,72, 56,40,0,0,0, 88, 72, 56, 40, 40,0,0, 88, 72, 56, 56, 40, 40,0,0, 88, 88, 72, 72, 56, 40,0,0,0, 72,0, 56, 40,0,0,72, 88, 72, 56,0, 56,0,0,0,0,0,0,0,0, 40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,0, 25,0,0,0,0,0, 25,0,0,0,0, 25
extKeyPosX:
!byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,143,191,0,173,0,0,0,0,0,0,0,0,0,0, 24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,158,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,233,0,203,233,0,0,0,188,233,218,0,233,218,0,0,0,0,233,0,0,233
extKeyPosY:
!byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104, 25,0,104,0,0,0,0,0,0,0,0,0,0,104,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104,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, 88,0,104, 40,0,0,0,104, 25,104,0,104, 88,0,0,0,0, 72,0,0, 56
; -----------------------------------------------------------------------------
; Graphics data
; -----------------------------------------------------------------------------
colorTab:
!byte $1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f
!byte $1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$1f,$4f
keyboardInd:
!bin "keyboard.ind"
keyboardIndEnd:
keyboardPatt:
!bin "keyboard.patt"
keyboardPattEnd:
sprites:
!byte $07,$1F,$3F,$7F,$7F,$FF,$FF,$FF
!byte $FF,$FF,$7F,$7F,$3F,$1F,$07,$00
!byte $80,$E0,$F0,$F8,$F8,$FC,$FC,$FC
!byte $FC,$FC,$F8,$F8,$F0,$E0,$80,$00
| 33.639394 | 380 | 0.452482 |
15ed5c8078ee425e2bb880460aa85ca154f108ff | 201 | asm | Assembly | libsrc/_DEVELOPMENT/arch/zx/misc/c/sdcc_iy/zx_cls_attr.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 640 | 2017-01-14T23:33:45.000Z | 2022-03-30T11:28:42.000Z | libsrc/_DEVELOPMENT/arch/zx/misc/c/sdcc_iy/zx_cls_attr.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 1,600 | 2017-01-15T16:12:02.000Z | 2022-03-31T12:11:12.000Z | libsrc/_DEVELOPMENT/arch/zx/misc/c/sdcc_iy/zx_cls_attr.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 215 | 2017-01-17T10:43:03.000Z | 2022-03-23T17:25:02.000Z | ; void zx_cls_attr(uchar attr)
SECTION code_clib
SECTION code_arch
PUBLIC _zx_cls_attr
EXTERN asm_zx_cls_attr
_zx_cls_attr:
pop af
pop hl
push hl
push af
jp asm_zx_cls_attr
| 10.578947 | 30 | 0.726368 |
30818e00b2e61b3957148696ebc7b4d3f372f06c | 11,520 | asm | Assembly | libsrc/target/gb/gbdk/font.asm | Frodevan/z88dk | f27af9fe840ff995c63c80a73673ba7ee33fffac | [
"ClArtistic"
] | 38 | 2021-06-18T12:56:15.000Z | 2022-03-12T20:38:40.000Z | libsrc/target/gb/gbdk/font.asm | Frodevan/z88dk | f27af9fe840ff995c63c80a73673ba7ee33fffac | [
"ClArtistic"
] | 2 | 2021-06-20T16:28:12.000Z | 2021-11-17T21:33:56.000Z | libsrc/target/gb/gbdk/font.asm | Frodevan/z88dk | f27af9fe840ff995c63c80a73673ba7ee33fffac | [
"ClArtistic"
] | 6 | 2021-06-18T18:18:36.000Z | 2021-12-22T08:01:32.000Z | ; font.ms
;
; Michael Hope, 1999
; michaelh@earthling.net
; Distrubuted under the Artistic License - see www.opensource.org
;
INCLUDE "target/gb/def/gb_globals.def"
PUBLIC tmode_out
PUBLIC tmode
PUBLIC asm_setchar
PUBLIC asm_font_load
PUBLIC asm_font_set
PUBLIC asm_load_z88dk_font
PUBLIC asm_load_z88dk_udg
GLOBAL display_off
GLOBAL __console_y, __console_x
EXTERN asm_cls
EXTERN asm_adv_curs
EXTERN __mode
EXTERN generic_console_font32
; Structure offsets
defc sfont_handle_sizeof = 3
defc sfont_handle_font = 1
defc sfont_handle_first_tile = 0
; Other bits
defc FONT_BCOMPRESSED = 2
defc CR = 0x0A ; Unix
defc SPACE = 0x00
; Maximum number of fonts
defc MAX_FONTS = 6
; Globals from drawing.s
; FIXME: Hmmm... check the linkage of these
GLOBAL __fgcolour
GLOBAL __bgcolour
SECTION bss_driver
; The current font
font_current:
defs sfont_handle_sizeof
; +0 =
; +1 = font address low
; +2 = font address high
; Cached copy of the first free tile
font_first_free_tile:
defs 1
; Table containing descriptors for all of the fonts
font_table:
defs sfont_handle_sizeof*MAX_FONTS
SECTION code_driver
; Copy uncompressed 16 byte tiles from (BC) to (HL), length = DE*2
; Note: HL must be aligned on a UWORD boundry
font_copy_uncompressed:
ld a,d
or e
ret z
ld a,h
cp 0x98
jr c,fc_4
sub 0x98-0x88
ld h,a
fc_4:
xor a
cp e ; Special for when e=0 you will get another loop
jr nz,fc_1
dec d
fc_1:
ldh a,(STAT)
bit 1,a
jr nz,fc_1
ld a,(bc)
ld (hl+),a
inc bc
stat_1:
ldh a,(STAT)
bit 1,a
jr nz,stat_1
ld a,(bc)
ld (hl),a
inc bc
inc l
jr nz,fc_2
inc h
ld a,h ; Special wrap-around
cp 0x98
jr nz,fc_2
ld h,0x88
fc_2:
dec e
jr nz,fc_1
dec d
bit 7,d ; -1?
jr z,fc_1
ret
; Copy a set of compressed (8 bytes/cell) tiles to VRAM
; Sets the foreground and background colours based on the current
; font colours
; Entry:
; From (BC) to (HL), length (DE) where DE = #cells * 8
; Uses the current __fgcolour and __bgcolour fiedefs
font_copy_compressed:
ld a,d
or e
ret z ; Do nothing
ld a,h
cp 0x98 ; Take care of the 97FF -> 8800 wrap around
jr c,font_copy_compressed_loop
sub 0x98-0x88
ld h,a
font_copy_compressed_loop:
push de
ld a,(bc)
ld e,a
inc bc
push bc
ld bc,0
; Do the background colour first
ld a,(__bgcolour)
bit 0,a
jr z,font_copy_compressed_bg_grey1
ld b,0xFF
font_copy_compressed_bg_grey1:
bit 1,a
jr z,font_copy_compressed_bg_grey2
ld c,0xFF
font_copy_compressed_bg_grey2:
; BC contains the background colour
; Compute what xoring we need to do to get the correct fg colour
ld d,a
ld a,(__fgcolour)
xor d
ld d,a
bit 0,d
jr z,font_copy_compressed_grey1
ld a,e
xor b
ld b,a
font_copy_compressed_grey1:
bit 1,d
jr z,font_copy_compressed_grey2
ld a,e
xor c
ld c,a
font_copy_compressed_grey2:
ldh a,(STAT)
bit 1,a
jr nz,font_copy_compressed_grey2
ld (hl),b
inc hl
stat_2:
ldh a,(STAT)
bit 1,a
jr nz,stat_2
ld (hl),c
inc hl
ld a,h ; Take care of the 97FFF -> 8800 wrap around
cp 0x98
jr nz,fcc_1
ld h,0x88
fcc_1:
pop bc
pop de
dec de
ld a,d
or e
jr nz,font_copy_compressed_loop
ret
; Load the font HL
asm_font_load:
call display_off
push hl
; Find the first free font entry
ld hl,font_table+sfont_handle_font
ld b,MAX_FONTS
font_load_find_slot:
ld a,(hl) ; Check to see if this entry is free
inc hl ; Free is 0000 for the font pointer
or (hl)
jr z,font_load_found
inc hl
inc hl
dec b
jr nz,font_load_find_slot
pop hl
ld hl,0
jr font_load_exit ; Couldn't find a free space
font_load_found:
; HL points to the end of the free font table entry
pop de
ld (hl),d ; Copy across the font struct pointer
dec hl
ld (hl),e
ld a,(font_first_free_tile)
dec hl
ld (hl),a
push hl
call asm_font_set ; Set this new font to be the default
; Only copy the tiles in if were in text mode
ld a,(__mode)
and T_MODE
call nz,font_copy_current
; Increase the 'first free tile' counter
ld hl,font_current+sfont_handle_font
ld a,(hl+)
ld h,(hl)
ld l,a
inc hl ; Number of tiles used
ld a,(font_first_free_tile)
add a,(hl)
ld (font_first_free_tile),a
pop hl ; Return font setup in HL
font_load_exit:
;; Turn the screen on
LDH A,(LCDC)
OR @10000001 ; LCD = On
; BG = On
AND @11100111 ; BG Chr = 0x8800
; BG Bank = 0x9800
LDH (LCDC),A
RET
; Copy the tiles from the current font into VRAM
font_copy_current:
; Find the current font data
ld hl,font_current+sfont_handle_font
ld a,(hl+)
ld h,(hl)
ld l,a ;hl = font address
inc hl ; Points to the 'tiles required' entry
ld e,(hl)
ld d,0
rl e ; Multiple DE by 8
rl d
rl e
rl d
rl e
rl d ; DE has the length of the tile data
dec hl
ld a,(hl) ; Get the flags
push af
and 3 ; Only lower 2 bits set encoding table size
ld bc,128
cp FONT_128ENCODING ; 0 for 256 char encoding table, 1 for 128 char
jr z,font_copy_current_copy
ld bc,0
cp FONT_NOENCODING
jr z,font_copy_current_copy
ld bc,256 ; Must be 256 element encoding
font_copy_current_copy:
inc hl
inc hl ; Points to the start of the encoding table
add hl,bc
ld c,l
ld b,h ; BC points to the start of the tile data
; Find the offset in VRAM for this font
ld a,(font_current+sfont_handle_first_tile) ; First tile used for this font
ld l,a
ld h,0
add hl,hl
add hl,hl
add hl,hl
add hl,hl
ld a,0x90 ; Tile 0 is at 9000h
add a,h
ld h,a
; Is this font compressed?
pop af ; Recover flags
bit FONT_BCOMPRESSED,a
; Do the jump in a mildly different way
jp z,font_copy_uncompressed
jp font_copy_compressed
; Set the current font to HL
asm_font_set:
ld a,(hl+)
ld (font_current),a
ld a,(hl+)
ld (font_current+1),a
ld a,(hl+)
ld (font_current+2),a
ret
;; Print a character without interpretation
out_char:
call asm_setchar
call asm_adv_curs
ret
;; Print the character in A
; C =x, B=y
asm_setchar:
push af
ld a,(font_current+2)
; Must be non-zero if the font system is setup (cant have a font in page zero)
or a
jr nz,asm_setchar_3
push bc
; Font system is not yet setup - init it and copy in the default font
; Kind of a compatibility mode
call _font_init
; Need all of the tiles
xor a
ld (font_first_free_tile),a
ld hl,generic_console_font32
ld a,(hl+)
ld h,(hl)
ld l,a
call asm_font_load
pop bc
asm_setchar_3:
pop af
push de
push hl
push bc ;Save coordinates
; Compute which tile maps to this character
ld e,a
ld hl,font_current+sfont_handle_font
ld a,(hl+)
ld h,(hl)
ld l,a ;hl = address of font
ld a,(hl+) ;font encoding
and 3
cp FONT_NOENCODING
jr z,asm_setchar_no_encoding
inc hl
; Now at the base of the encoding table
; E is set above
ld d,0
add hl,de
ld e,(hl) ; That's the tile!
asm_setchar_no_encoding:
ld a,(font_current+0) ;first tile
add a,e
ld e,a ;e = tile to use
pop bc ;c = x, b = y
push bc
LD L,B
LD H,0x00
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
LD B,0x00 ;Add on x coordinate now
ADD HL,BC
LD BC,0x9800
ADD HL,BC
stat_4:
ldh a,(STAT)
bit 1,a
jr nz,stat_4
LD (HL),E
POP BC
POP HL
POP DE
RET
_font_init:
push bc
call tmode
xor a ; We use the first tile as a space _always_
ld (font_first_free_tile),a
; Clear the font table
ld hl,font_table
ld b,sfont_handle_sizeof*MAX_FONTS
init_1:
ld (hl+),a
dec b
jr nz,init_1
ld (__bgcolour),a ;a = 0
ld a,3
ld (__fgcolour),a
call asm_cls
pop bc
ret
SECTION code_driver
GLOBAL vbl
GLOBAL lcd
GLOBAL int_0x40
GLOBAL int_0x48
GLOBAL remove_int
;; Enter text mode
tmode:
DI ; Disable interrupts
;; Turn the screen off
LDH A,(LCDC)
BIT 7,A
JR Z,tmode_1
;; Turn the screen off
CALL display_off
;; Remove any interrupts setup by the drawing routine
; LD BC,vbl
; LD HL,int_0x40
; CALL remove_int
; LD BC,lcd
; LD HL,int_0x48
; CALL remove_int
tmode_1:
CALL tmode_out
;; Turn the screen on
LDH A,(LCDC)
OR @10000001 ; LCD = On
; BG = On
AND @11100111 ; BG Chr = 0x8800
; BG Bank = 0x9800
LDH (LCDC),A
EI ; Enable interrupts
RET
;; Text mode (out only)
tmode_out:
XOR A
LD (__console_x),A
LD (__console_y),A
;; Clear screen
CALL asm_cls
LD A,T_MODE
LD (__mode),A
RET
; Entry: bc = address of font (with gb header)
asm_load_z88dk_font:
push bc
ld a,(font_current+2)
; Must be non-zero if the font system is setup (cant have a font in page zero)
and a
call z,_font_init
xor a
ld (font_first_free_tile),a
ld c,l
ld b,h
call asm_font_load
pop bc
ret
; Entry: bc = address of UDG bitmaps
asm_load_z88dk_udg:
ld a,(font_current+2)
; Must be non-zero if the font system is setup (cant have a font in page zero)
and a
jr z,set_udgs
push bc
ld hl,generic_console_font32
ld c,(hl)
inc hl
ld h,(hl)
call asm_load_z88dk_font
pop bc
set_udgs:
call z,_font_init
ld hl,$8800 ;Tile 128 is the first UDG
ld de,128 * 8
call font_copy_compressed
ret
| 22.412451 | 84 | 0.544271 |
e5f0339f79d6f06c7330ea3d5a68e042cf6c3ec1 | 9,640 | asm | Assembly | Driver/IFS/DOS/Common/msSFT.asm | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 504 | 2018-11-18T03:35:53.000Z | 2022-03-29T01:02:51.000Z | Driver/IFS/DOS/Common/msSFT.asm | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 96 | 2018-11-19T21:06:50.000Z | 2022-03-06T10:26:48.000Z | Driver/IFS/DOS/Common/msSFT.asm | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 73 | 2018-11-19T20:46:53.000Z | 2022-03-29T00:59:26.000Z | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: msSFT.asm
AUTHOR: Adam de Boor, Mar 16, 1992
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Adam 3/16/92 Initial revision
DESCRIPTION:
Code common to all MS DOS IFS drivers to manipulate the linked-list
SFT used by MS DOS.
$Id: msSFT.asm,v 1.1 97/04/10 11:55:05 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Resident segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DOSPointToSFTEntry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Locate the numbered SFT entry (must be resident so
FSHandleInfo can work)
CALLED BY: EXTERNAL
PASS: al = SFN of entry to find
RETURN: carry clear if ok:
es:di = SFTEntry for the thing
carry set if SFN invalid
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/ 8/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DOSPointToSFTEntry proc far uses ax
.enter
segmov es, dgroup, di
les di, es:[sftStart]
clr ah
;
; Loop until we find the right block.
;
blockLoop:
cmp es:[di].SFTBH_numEntries, ax
ja haveBlock
;
; Reduce ax by number in this block and advance to next.
;
sub ax, es:[di].SFTBH_numEntries
les di, es:[di].SFTBH_next
cmp di, NIL
stc
jz done
jmp blockLoop
haveBlock:
;
; ES:DI = SFTBlockHeader of containing block. Add offset into
; block of desired entry (cx * size SFTEntry + offset SFTBH_entries)
;
add di, offset SFTBH_entries
tst ax
jz done ; Don't multiply if ax is 0...
push dx
if _MS3
; sft entry varies in size between versions of 3.x (q.v.
; MSLocateFileTable)
push ds
segmov ds, dgroup, dx
mov dx, ds:[sftEntrySize]
pop ds
else
mov dx, size SFTEntry
endif
mul dx
add di, ax
pop dx
clc
done:
.leave
ret
DOSPointToSFTEntry endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DOSCompareSFTEntries
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Compare two entries in the file table.
CALLED BY: DOSCompareFiles
PASS: ds:si = SFTEntry 1
es:di = SFTEntry 2
RETURN: ZF set if ds:si and es:di refer to the same disk file
DESTROYED: ax
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 3/19/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DOSCompareSFTEntries proc near
.enter
if not _MS2
;
; Make sure both entries are either devices or files and either
; both local or both remote.
;
mov ax, es:[di].SFTE_flags.SFTF_file
xor ax, ds:[si].SFTE_flags.SFTF_file
test ax, (mask SFTFF_ISDEV or mask SFTFF_REMOTE)
jnz done
mov ax, es:[di].SFTE_flags.SFTF_file
; XXX: if the file is remote, we've no way (yet) to uniquely
; identify the beast, so just say they're not equal if
; the thing be remote.
test ax, mask SFTFF_REMOTE
jnz done
;
; If the thing is a file, see if the directory index, directory
; LBN and initial clusters match. Can't do such checks for a
; device b/c a device has no file space.
;
test ax, mask SFTFF_ISDEV
jnz checkDev
; For a file that was recently created and has just been cached (never
; committed to disk), if DOS opens it again, the initial cluster for the
; new instance will be 0, not the cluster allocated for the thing. This
; may only happen if you open the thing read-only (since you won't be
; able to modify the file, why go to the trouble of searching for
; an already-open instance and get the initCluster from there?). Anyway,
; I think the directory's LBN and the index in that directory should
; be sufficient, along with the drive number, to identify the file
; uniquely -- ardeb 6/15/90
;
; mov ax, es:[di].SFTE_initCluster
; cmp ax, ds:[si].SFTE_initCluster
; jne done
mov al, es:[di].SFTE_dirIndex
cmp al, ds:[si].SFTE_dirIndex
jne done
if _MS3
mov ax, es:[di].SFTE_dirLBN
cmp ax, ds:[si].SFTE_dirLBN
else
cmpdw es:[di].SFTE_dirLBN, ds:[si].SFTE_dirLBN, ax
endif ; _MS3
jne done
mov al, {byte}ds:[si].SFTE_flags
xor al, {byte}es:[di].SFTE_flags
andnf al, mask SFTFF_DRIVE
jnz done
checkDev:
;
; See if the DCB field points to the same place. No need to
; check anything *in* the DCB, I don't think -- if the files are
; on the same device, they should have the same DCB...unless the
; user has created disk aliases. In that case one could
; conceivably compare the deviceHeader and unit fields of the
; DCB (except for a device...) but it doesn't seem worth it.
; This way the device and file code can share this here code...
;
mov ax, es:[di].SFTE_DCB.low
cmp ax, ds:[si].SFTE_DCB.low
jne done
mov ax, es:[di].SFTE_DCB.high
cmp ax, ds:[si].SFTE_DCB.high
;
; XXX: Compare names too? Probably not worth it.
;
endif
done:
.leave
ret
DOSCompareSFTEntries endp
;Moved into Resident resource 4/21/93 by EDS. See DOSUtilOpen.
;Resident ends
;PathOps segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MSExtendSFT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Extend the SFT by a reasonable amount to allow us to
open more files, now the current SFT is full.
CALLED BY: DOSAllocOpOpen, DOSAllocOpCreate, DOSUtilOpen
PASS: ax = ERROR_TOO_MANY_OPEN_FILES
RETURN: carry set if couldn't extend
carry clear if caller should try again.
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/ 7/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MSExtendSFT proc far
uses ds, di, es, ax, cx, bx
.enter
;
; Make sure all entries are actually used up. There are certain
; things (e.g. TOPS) that are fascist and will hose us big time,
; telling us there's no room when we know damn well there is.
; Rather than constantly extending the SFT until we run out of
; memory, we'd like to catch this...
;
call LoadVarSegDS
les di, ds:[sftStart]
nextBlock:
;
; See if hit the last block (ptr is -1)
;
cmp di, NIL
je doExtend
;
; Fetch number of entries in the block and advance di to the
; first of them.
;
mov cx, es:[di].SFTBH_numEntries
push di
add di, size SFTBlockHeader
nextEntry:
;
; A reference count of 0 means the entry is unused. We just
; fetch the thing into ax before advancing to the next entry to
; make the loop as nice as possible.
;
if size SFTE_refCount eq word
mov ax, es:[di].SFTE_refCount
if _MS3
add di, ds:[sftEntrySize]
else
add di, size SFTEntry
endif
tst ax
else ; _MS2
mov al, es:[di].SFTE_refCount
add di, size SFTEntry
tst al
endif
loopne nextEntry
;
; Point es:di at next block in case we went through the entire
; block.
;
pop di
les di, es:[di].SFTBH_next
jne nextBlock ; If didn't stop b/c of an unused slot,
; check the next block
stc ; Signal error -- DO NOT TRY TO EXTEND
jmp done
doExtend:
les di, ds:[sftEnd] ;point es:di at last SFT block
;
; allocate a block for new SFT entries and make it owned by us.
;
mov bx, handle 0
mov ax, SFT_EXTEND_NUM_ENTRIES * size SFTEntry + \
size SFTBlockHeader
if _MS3
tst ds:[isPC3_0]
jz doAlloc
mov ax, SFT3_EXTEND_NUM_ENTRIES * size SFT30Entry + \
size SFTBlockHeader
doAlloc:
endif ; _MS3
mov cx, ALLOC_FIXED or (mask HAF_ZERO_INIT shl 8)
call MemAllocSetOwner
jc done
;
; Point former tail block at the new block.
;
mov es:[di].SFTBH_next.offset, 0
mov es:[di].SFTBH_next.segment, ax
;
; Record new block as tail
;
mov ds:[sftEnd].offset, 0
mov ds:[sftEnd].segment, ax
;
; Initialize new block header (rest of block initialized to zero
; by MemAlloc)
;
mov es, ax
clr di
mov es:[di].SFTBH_next.offset, NIL
mov es:[di].SFTBH_numEntries, SFT_EXTEND_NUM_ENTRIES
; carry cleared by 'clr di'
done:
.leave
ret
MSExtendSFT endp
;PathOps ends
Resident ends
| 27.386364 | 81 | 0.55332 |
522f2694d45ae1c9975ed61ad5cac7f1eb52279a | 432 | asm | Assembly | programs/oeis/086/A086483.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/086/A086483.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | programs/oeis/086/A086483.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | ; A086483: Bit that is two places to left of least significant bit in binary expansion of n.
; 0,0,0,0,0,1,0,1,0,0,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,0,1,0,1,1,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,1,1,1,0,0,0,0,1,1,0,1,1,0,1,0,1,1,1,1,0,0,0,0,0,1,0,1,0,0,1,0,0,1,1,1,1,0,0,0,1,1,0,1,0,0,1,0,1,1,1,1,0,0,0,0,0,1,0,1,1
sub $0,1
mul $0,2
lpb $0
mov $2,$0
sub $0,$0
add $2,1
cal $2,99549 ; Odd part of n modulo 8.
add $1,$2
lpe
div $1,4
| 30.857143 | 211 | 0.56713 |
4b6b5b66cbfa3118785d07023ce90154dd67c9c9 | 1,740 | asm | Assembly | libsrc/_DEVELOPMENT/math/float/math16/c/sdcc/cm16_sdcc_read.asm | Frodevan/z88dk | f27af9fe840ff995c63c80a73673ba7ee33fffac | [
"ClArtistic"
] | 640 | 2017-01-14T23:33:45.000Z | 2022-03-30T11:28:42.000Z | libsrc/_DEVELOPMENT/math/float/math16/c/sdcc/cm16_sdcc_read.asm | Frodevan/z88dk | f27af9fe840ff995c63c80a73673ba7ee33fffac | [
"ClArtistic"
] | 1,600 | 2017-01-15T16:12:02.000Z | 2022-03-31T12:11:12.000Z | libsrc/_DEVELOPMENT/math/float/math16/c/sdcc/cm16_sdcc_read.asm | Frodevan/z88dk | f27af9fe840ff995c63c80a73673ba7ee33fffac | [
"ClArtistic"
] | 215 | 2017-01-17T10:43:03.000Z | 2022-03-23T17:25:02.000Z |
SECTION code_fp_math16
PUBLIC cm16_sdcc_readr
PUBLIC cm16_sdcc_read1
PUBLIC cm32_sdcc_read1
.cm16_sdcc_readr
; sdcc half_t primitive
; Read right sdcc half_t from the stack
;
; Convert from sdcc_half calling to f16 half_t.
;
; enter : stack = sdcc_half right, sdcc_half left, ret1, ret0
;
; exit : stack = sdcc_half right, sdcc_half left, ret1
; DEHL = sdcc_half right
;
; uses : f, de, hl
ld hl,6 ; stack sdcc_half right
add hl,sp
ld e,(hl)
inc hl
ld d,(hl) ; DE = sdcc_float
ex de,hl
ret ; HL = sdcc_float ; return HL = sdcc_half right
.cm16_sdcc_read1
; sdcc half_t primitive
; Read left / single sdcc half_t from the stack
;
; Convert from sdcc_half calling to f16 half_t.
;
; enter : stack = sdcc_half, ret1, ret0
;
; exit : stack = sdcc_half, ret1
; DEHL = sdcc_half
;
; uses : f, de, hl
ld hl,4 ; stack sdcc_half
add hl,sp
ld e,(hl)
inc hl
ld d,(hl) ; DE = sdcc_float
ex de,hl
ret ; HL = sdcc_float
.cm32_sdcc_read1
; sdcc float primitive
; Read left / single sdcc float from the stack
;
; enter : stack = sdcc_float, ret1, ret0
;
; exit : stack = sdcc_float, ret1
; DEHL = sdcc_float
;
; uses : f, bc, de, hl
ld hl,4 ; stack sdcc_float
add hl,sp
ld c,(hl)
inc hl
ld b,(hl)
inc hl
ld e,(hl)
inc hl
ld d,(hl) ; DEBC = sdcc_float
ld l,c
ld h,b
ret ; DEHL = sdcc_float
| 21.219512 | 79 | 0.516092 |
9c0446d254184cf31745a278904e0b9c6946bb79 | 7,626 | asm | Assembly | basic/src/evaluate/string.asm | paulscottrobson/eris | cf102530334ed86360deb20f0e41af1e10f5d584 | [
"MIT"
] | 13 | 2020-03-31T08:21:22.000Z | 2021-07-28T20:03:29.000Z | basic/src/evaluate/string.asm | paulscottrobson/eris | cf102530334ed86360deb20f0e41af1e10f5d584 | [
"MIT"
] | 37 | 2020-03-31T06:35:37.000Z | 2020-09-17T08:56:48.000Z | basic/src/evaluate/string.asm | paulscottrobson/eris | cf102530334ed86360deb20f0e41af1e10f5d584 | [
"MIT"
] | 5 | 2020-05-10T10:23:06.000Z | 2022-01-14T02:21:02.000Z | ; *****************************************************************************
; *****************************************************************************
;
; Name: string.asm
; Purpose: String concatenation / splitting functions
; Created: 5th March 2020
; Reviewed: 17th March 2020
; Author: Paul Robson (paul@robsons.org.uk)
;
; *****************************************************************************
; *****************************************************************************
; *****************************************************************************
;
; Concatenate 1st/2nd string entry (already checked)
;
; *****************************************************************************
.StringConcat
jsr #DereferenceBinary ; dereference.
ldm r0,r10,#esValue1 ; work out memory requirements by reading the lengths
ldm r1,r0,#0
ldm r0,r10,#esValue2
ldm r0,r0,#0
add r0,r1,#0 ; add them together
mov r1,r0,#0 ; check if >= max string size
sub r1,#maxStringSize+1
sklt
jmp #StrlenError
ror r0,#1 ; divide by 2 + 2 to give a word size
and r0,#$7FFF
add r0,#2 ; add a little extra space.
jsr #SFAllocate ; and lazy writing.
;
ldm r3,r10,#esValue1 ; output the 1st string
stm r1,r10,#esValue1 ; write this address as the result string address
jsr #_SCOutput
ldm r3,r10,#esValue2 ; output the 2nd string
jsr #_SCOutput
pop link
ret
;
; Write string at R3.
;
._SCOutput
push link
mov r0,r3,#0 ; how many bytes to copy ?
jsr #OSWordLength
mov r4,r0,#0 ; into R4
._SCOutLoop
inc r3 ; next character
sknz r4 ; exit if finished.
jmp #_SCOutExit
dec r4
ldm r0,r3,#0 ; output low
jsr #SFAddCharacter
ldm r0,r3,#0 ; output high
ror r0,#8
jsr #SFAddCharacter
jmp #_SCOutLoop
._SCOutExit
pop link
ret
; *****************************************************************************
;
; Allocate R0 words of string memory and set up R1 (base) and R2 (offset)
;
; *****************************************************************************
.SFAllocate
push link
jsr #AllocateTempMemory ; allocate words for new string
mov r1,r0,#0 ; R1 is the next string to write
clr r2 ; R2 is the rotation for that word, 0->8->0
stm r14,r1,#0 ; clear the length and first word
stm r14,r1,#1
pop link
ret
; *****************************************************************************
;
; Write R0 to R1/R2 pair creating a string
;
; *****************************************************************************
.SFAddCharacter
and r0,#$00FF ; convert to byte as its a character
sknz r0 ; do not output $00
ret
push r3,r4
mov r4,r2,#0 ; R4 = R2 rotated right
ror r4,#1
skp r4 ; if R2 bit 0 was set rotate R0 8
ror r0,#8
and r4,#$7FFF ; R4 now is the offset
add r4,r1,#1 ; now the address of the character
ldm r3,r4,#0 ; get character
add r3,r0,#0 ; add new one in
stm r3,r4,#0 ; write back
stm r14,r4,#1 ; clear next word
inc r2 ; increment offset/length
stm r2,r1,#0 ; save in string header
pop r3,r4
ret
; *****************************************************************************
;
; Mid$( - left$( and right$( also use this code
;
; *****************************************************************************
.Unary_Mid ;; [mid$(]
push link
jsr #EvaluateString ; get string into R3
mov r3,r0,#0
jsr #CheckComma
jsr #EvaluateInteger ; get start into R4
mov r4,r0,#0
mov r5,#maxStringSize ; this is the default for the third parameter
ldm r0,r11,#0 ; is the next character a )
xor r0,#TOK_RPAREN
sknz r0
jmp #UnaryStringSliceCommon ; if so, it's mid$(a$,x)
jsr #CheckComma
jsr #EvaluateInteger ; get end into R5
mov r5,r0,#0
;
; String slicing Common code for left$, mid$ and right$
;
; At this point, R3 points to the string, R4 to the start pos, R5 to the end pos
; note these positions start at 1.
;
.UnaryStringSliceCommon
jsr #CheckRightBracket ; check there's a right bracket
dec r4 ; convert position to offset (so 1 => start)
;
skp r4 ; check both are +ve
jmp #BadNumberError
skp r5
jmp #BadNumberError
sknz r5 ; if length is 0 then return empty string
jmp #_USSCNull
;
;
; Check start offset < length. If >= then it is an empty string.
;
ldm r0,r3,#0 ; get string length in R0.
mov r1,r4,#0
sub r1,r0,#0
sklt
jmp #_USSCNull
;
; Allocate memory for the string
;
mov r0,r5,#0 ; divide by 2, add 2 to get text size.
ror r0,#1
and r0,#$7FFF
add r0,#2
jsr #SFAllocate ; allocate string, setup r1 and r2
stm r0,r10,#esValue1 ; save it so it is returned.
clr r6 ; 0 = LSB 8 = MSB
;
; Source String in R3. Start Offset in R4. Final Length in R5.
; (remember these are packed word). R6 contains the next byte half to use 0/8 rotate
;
; R1 and R2 are set up so that we can write the string out.
;
; -------------------------------------------------------------------------------------
;
; Output characters until either (i) you reach a $00 or (ii) all chars have
; been copied
;
inc r3 ; advance R3 over length byte
._USSCCopyLoop
dec r4 ; decrement the start offset. if this is still +ve
skm r4 ; then we do not start copying, yet.
jmp #_USSCNextCharacter
;
ldm r0,r3,#0 ; get the next character out.
ror r0,r6,#0 ; rotate it into position
and r0,#$00FF ; convert to a byte
sknz r0 ; if it is zero then exit, end of source
jmp #_USSCExit
jsr #SFAddCharacter ; write that to the new string
dec r5 ; decrement the final length
sknz r5
jmp #_USSCExit ; exit if that is zero, e.g. we've done them all.
._USSCNextCharacter
xor r6,#8 ; flip byte half
sknz r6 ; if that was 8->0
inc r3 ; look at the next word
jmp #_USSCCopyLoop
._USSCNull
mov r0,#1 ; allocate 1 character it is cleared
jsr #SFAllocate
stm r0,r10,#esValue1 ; make return value
._USSCExit
stm r14,r10,#esReference1 ; constant
stm r15,r10,#esType1 ; string
pop link
ret
; *****************************************************************************
;
; left$(a$,n) == mid$(a$,1,n)
;
; *****************************************************************************
.Unary_Left ;; [left$(]
push link
jsr #EvaluateString ; get string into R3
mov r3,r0,#0
jsr #CheckComma
mov r4,#1 ; start = 1
jsr #EvaluateInteger ; get length into R5
mov r5,r0,#0
jmp #UnaryStringSliceCommon
; *****************************************************************************
;
; right$(a$,n) == mid$(a$,len(a$)-n+1,...)
;
; *****************************************************************************
.Unary_Right ;; [right$(]
push link
jsr #EvaluateString ; get string into R3
mov r3,r0,#0
ldm r4,r3,#0 ; get string length into R4
inc r4 ; add 1. if right$("abc",3) you start at 3-3+1
jsr #CheckComma
jsr #EvaluateInteger ; get right count
sub r4,r0,#0 ; calculate start position
skp r4 ; if <= 0 make start position 1
mov r4,#1
sknz r4
mov r4,#1
mov r5,#maxStringSize ; to the end of the string.
jmp #UnaryStringSliceCommon
| 31.254098 | 89 | 0.498426 |
39a32704eee4c2b3698eb1d0ea377927a93bb3c9 | 829 | asm | Assembly | oeis/142/A142678.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/142/A142678.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/142/A142678.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A142678: Primes congruent to 22 mod 57.
; Submitted by Jon Maiga
; 79,193,307,421,877,991,1447,1789,2017,2131,2473,3271,3499,3613,3727,4297,4639,5209,5323,5437,5779,6007,6121,6577,6691,7489,7603,7717,8059,8287,8629,8971,9199,9769,9883,10111,10453,10567,10909,11251,11593,11821,12049,12163,12277,12391,12619,13417,13759,13873,14557,15013,15241,15583,16267,16381,17293,17749,17863,17977,18433,18661,19231,19687,19801,20029,20143,20599,21169,21283,21397,21739,22651,22993,23563,23677,24019,24133,24247,26641,27211,28123,28351,28579,28807,28921,29833,29947,30403,30517
mov $1,39
mov $2,$0
add $2,2
pow $2,2
lpb $2
sub $2,1
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,57
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
mul $0,2
sub $0,113
| 34.541667 | 499 | 0.728589 |
510fb0c8ee2dc673286463a151ee34b228c41f3c | 39,400 | asm | Assembly | money-run/money-run.asm | avik-das/gbdev | 663f2675aab85953ce02c88bf16582b4fd85f81e | [
"BSD-3-Clause"
] | 6 | 2016-03-30T04:40:26.000Z | 2020-04-11T13:50:15.000Z | money-run/money-run.asm | avik-das/gbdev | 663f2675aab85953ce02c88bf16582b4fd85f81e | [
"BSD-3-Clause"
] | null | null | null | money-run/money-run.asm | avik-das/gbdev | 663f2675aab85953ce02c88bf16582b4fd85f81e | [
"BSD-3-Clause"
] | null | null | null | ; money-run.asm - Avik Das
;
; A simple side-scroller, in which the character is asked to go from
; left to right, navigating over a series procedurally generated
; columns.
;
; The name is refers to the gameplay mechanic in which the player will
; be trying to collect money while avoiding getting stuck amongst the
; columns.
; = DATA/VARIABLES ==================================================
; Here we set up some locations in memory to store data that will be
; used in the program. Typically, we will store data in the internal
; RAM, which gives us 8KB to work with.
SECTION "RAM",WRAM0[$c000]
; The buttons that are joypad pressed on the joypad. The fields are
; as follows:
; bit 7: down
; bit 6: up
; bit 5: left
; bit 4: right
; bit 3: start
; bit 2: select
; bit 1: B
; bit 0: A
; When a bit is set, the corresponding button is pressed. This
; structure is updated by read_joypad.
PAD : DB
OLDPAD: DB
; The background is 256 pixels wide, with each column taking up 16
; pixels, giving us 16 separate heights to work with.
;
; We can exploit the fact that not all eight bits in one byte are
; used to store a height, but storing multiple heights in one byte
; results in much more awkward code. This is a space-time trade-off.
HEIGHTS: DS 16
RANDHEIGHT: DB ; a random number used for generating the heights
BGSCRL: DB ; amount to scroll the background by
; The player struct, which defines the state of the player.
;
; The Y-coordinate and downward velocity are are stored as two bytes
; each, in a 8.8 fixed point format. This means that the first byte
; is the integer portion of the number, and the second byte contains
; the fractional portion. The Y-coordinate is the actual pixel
; coordinate on screen, as opposed to being offset by 16 pixels as is
; the case in the OAM structure.
;
; The X-coordinate does not need to be stored in fixed point format,
; since no forces are applied horizontally, so no numeric integration
; needs to be done on the X-coordinate. The X-coordinate is the
; actual position on screen, plus 16. This allows the player to go
; partally off screen without the position wrapping around.
;
PLAYER_STATE:
DB ; the x position
DS 2 ; the y position
DS 2 ; the downward velocity
SCROLLFLAG: DB ; whether or not to scroll the world
VBFLAG: DB ; whether or not we are in V-Blank
; Instead of directly manipulating values in the OAM during V-Blank,
; we store a copy of the OAM. Then, we can alter this copy at any
; time, not just during V-Blank, and when the OAM is indeed
; available, we initiate a DMA transfer from the copy to the OAM.
OAMBUF EQU $df00 ; allocate the last page in RAM for the copy
PLAYER EQU OAMBUF ; the player starts at the first sprite
; = INTERRUPT HANDLERS ==============================================
; These are simple interrupt handlers that simply call the actual
; procedures responsible for taking any action. The procedures will
; call "reti".
SECTION "vblank",ROM0[$40]
nop
jp vblank
SECTION "timer",ROM0[$50]
nop
jp timer
SECTION "start",ROM0[$100]
nop
jp start
; = CATRIDGE HEADER =================================================
; Nintendo logo. must be exactly as given
DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
DB "MONEYRUN",0,0,0,0,0,0,0 ; title, upper case ASCII, 15 bytes
DB 0 ; not a GBC catridge
DB 0,0 ; new licensee code, high and low nibbles. not important
DB 0 ; not SGB
DB 0 ; catridge type, ROM only
DB 0 ; ROM size, 256Kbit = 32KByte = 2 banks
DB 0 ; RAM size, no RAM
DB 1 ; destination code, non-Japanese
DB $33 ; old licensee code, $33 => check new licensee code
DB 0 ; mask ROM version number, usually 0
DB 0 ; complement check. computed by rgbfix. important.
DW 0 ; checksum. computed by rgbfix. not important.
; = INITIALIZATION ==================================================
start:
nop
di ; disable interrupts
ld sp, $ffff ; put the stack at the top of the RAM
init:
call lcd_off
call init_ram
call copy_dma_routine
call load_bg_tileset
call init_player_obj
call lcd_on
call start_timer
ld a,%00000101 ; enable V-Blank interrupt
; enable timer interrupt
ld [$ffff],a
ei
; = MENU INITIALIZATION + MENU LOOP =================================
switch_to_menu:
di
call lcd_off
call init_ram_for_menu
call load_bg_for_menu
call place_player_in_menu
call lcd_on
ei
.loop:
halt
nop
ld a,[VBFLAG]
or 0
jr z,.loop
ld a,0
ld [VBFLAG],a
ld hl,RANDHEIGHT
inc [hl]
call read_joypad
call react_to_input_in_menu
jr .loop
; = GAMEPLAY INITIALIZATION + GAMEPLAY LOOP =========================
start_game:
di
call lcd_off
call init_ram_for_gameplay
call generate_initial_bg_for_gameplay
call set_player_initial_position_for_gameplay
call lcd_on
ei
.loop:
halt
nop
ld a,[VBFLAG]
or 0
jr z,.loop
ld a,0
ld [VBFLAG],a
call read_joypad
call react_to_input_during_gameplay
call apply_forces
call position_player
call scroll_world_if_needed
call check_for_game_over
jr .loop
; = MENU INITIALIZATION + MENU LOOP =================================
show_game_over_screen:
di
call lcd_off
call init_ram_for_game_over
call load_bg_for_game_over
call hide_player
call lcd_on
ei
.loop:
halt
nop
ld a,[VBFLAG]
or 0
jr z,.loop
ld a,0
ld [VBFLAG],a
call read_joypad
call react_to_input_in_game_over
jr .loop
; = INITIALIZATION FUNCTIONS ========================================
init_ram:
; Initialize the RAM variables, but only the ones used all throughout
; the program. There are other variables only used in one mode of the
; program (e.g. menu vs. gameplay) that are initialized at the
; beginning of that mode.
ld a,0
ld [PAD],a
ld [OLDPAD],a
ld [VBFLAG],a
ld [RANDHEIGHT],a
ret
init_ram_for_menu:
init_ram_for_game_over:
ld a,0
ld [BGSCRL],a
ret
init_ram_for_gameplay:
ld a,0
ld [BGSCRL],a
ret
copy_dma_routine:
; copy the sprite DMA procedure into HRAM
ld hl,sprite_dma
ld de,hram_sprite_dma
ld bc,sprite_dma_end-sprite_dma
call memcpy
ret
load_bg_tileset:
ld a,[bgpal] ; set the background palette
ld [$ff47],a
; load the background tiles into the Tile Data Table
ld hl,bgbox ; source address
ld de,$8800 ; destination address
ld bc,816 ; number of bytes to copy
call memcpy
ret
load_bg_for_menu:
; reset the screen position, both scrolly and scrollx
ld a,0
ld [$ff42],a
ld [$ff43],a
call clear_bg
; Boxes
ld a,$80 ; box top-left tiles
ld [$9908],a
ld [$9948],a
ld [$994a],a
ld [$994c],a
ld [$9986],a
ld [$9988],a
ld [$998a],a
ld [$998c],a
ld a,$81 ; box top-right tiles
ld [$9909],a
ld [$9949],a
ld [$994b],a
ld [$994d],a
ld [$9987],a
ld [$9989],a
ld [$998b],a
ld [$998d],a
ld a,$82 ; box bottom-left tiles
ld [$9928],a
ld [$9968],a
ld [$996a],a
ld [$996c],a
ld [$99a6],a
ld [$99a8],a
ld [$99aa],a
ld [$99ac],a
ld a,$83 ; box bottom-right tiles
ld [$9929],a
ld [$9969],a
ld [$996b],a
ld [$996d],a
ld [$99a7],a
ld [$99a9],a
ld [$99ab],a
ld [$99ad],a
; Game title
ld hl,bgtitlemap ; source address
ld de,$9845 ; destination address
ld bc,10 ; number of bytes to copy
call memcpy
ld hl,bgtitlemap + 10 ; source address
ld de,$9865 ; destination address
ld bc,10 ; number of bytes to copy
call memcpy
ld hl,bgtitlemap + 20 ; source address
ld de,$9887 ; destination address
ld bc,6 ; number of bytes to copy
call memcpy
ld hl,bgtitlemap + 26 ; source address
ld de,$98a7 ; destination address
ld bc,6 ; number of bytes to copy
call memcpy
; Press start text
ld hl,bgpressstartmap ; source address
ld de,$99e4 ; destination address
ld bc,12 ; number of bytes to copy
call memcpy
ret
load_bg_for_game_over:
; reset the screen position, both scrolly and scrollx
ld a,0
ld [$ff42],a
ld [$ff43],a
call clear_bg
; Game over title
ld hl,gameovertitlemap ; source address
ld de,$98c6 ; destination address
ld bc,8 ; number of bytes to copy
call memcpy
ld hl,gameovertitlemap + 8 ; source address
ld de,$98e6 ; destination address
ld bc,8 ; number of bytes to copy
call memcpy
ld hl,gameovertitlemap + 16 ; source address
ld de,$9926 ; destination address
ld bc,8 ; number of bytes to copy
call memcpy
ld hl,gameovertitlemap + 24 ; source address
ld de,$9946 ; destination address
ld bc,8 ; number of bytes to copy
call memcpy
ret
generate_initial_bg_for_gameplay:
; reset the screen position
ld a,0
ld [$ff42],a ; scrolly will always be 0
ld [$ff43],a ; scrollx starts at 0
call generate_initial_heights
call load_all_columns_into_bg_tile_map
ret
generate_initial_heights:
ld hl,HEIGHTS ; the base address of the height map
ld a,$0
.loop:
push af ; preserve A
call next_rand_height
ld [hl],a ; generate two random heights and place it into the
; height map
inc hl ; go to the next byte in the height map
pop af ; restore A
inc a ; only generate data for 16 bytes
cp $16
jr nz, .loop
ret
load_all_columns_into_bg_tile_map:
ld a,$0
.loop:
push af
call load_column_into_bg_tile_map
pop af
inc a
cp $10
jr nz, .loop
ret
load_column_into_bg_tile_map:
; parameters:
; a = the index of the column to load
ld d,a ; save a, because we'll need the original value later
ld hl,HEIGHTS ; start with the start address of the height map
ld b,$00 ; bc = $00AA, where AA = index
ld c,a
add hl,bc ; actual address = start of height map + $00AA
ld a,[hl] ; grab the height from the height map.
ld b,a ; save the height in b
sla d ; multiply the column index by 2, since in the tile
; map, each column takes up two tiles
ld h,$98 ; HL = $98DD, where DD = index * 2
ld l,d
jp load_column_into_bg_tile_map_at_address ; tail call
init_player_obj:
; Set up the initial player state, so that it can be placed as
; necessary. This doesn't actually position the player, as the
; starting position differs based on if we're on the menu or not.
; load the object palette 0
ld a,[sppal] ; load the object palette 0 data
ld [$ff48],a ; and store it into the object palette 0 register
; zero out the OAM buffer
ld de,OAMBUF
ld bc,256
call zeromem
; load the sprite tiles into the Sprite Pattern Table
ld hl,ghost ; source address
ld de,$8000 ; destination address
ld bc,256 ; number of bytes to copy
call memcpy
; Display the sprites on the screen by populating the Object
; Attribute Memory (OAM). The X- and Y-coordinates will be filled in
; by "position_player" later.
ld a,0 ; pattern number
ld [PLAYER+2],a
ld a,%00000000 ; priority: on top of background
; no y-flip
; no x-flip
; palette 0
; 4 LSB ignored
ld [PLAYER+3],a
; our player requires two sprites, so initialize the second one
ld a,2 ; pattern number
ld [PLAYER+6],a
ld a,%00000000 ; priority: on top of background
; no y-flip
; no x-flip
; palette 0
; 4 LSB ignored
ld [PLAYER+7],a
ret
place_player_in_menu:
ld a,101
ld [PLAYER_STATE],a ; X-coordinate
ld a,64
ld [PLAYER_STATE+1],a ; Y-coordinate (integer part)
; All other portions of the player state are not set because they are
; not used during the menu.
jp position_player ; tail call
hide_player:
ld a,240
ld [PLAYER_STATE+1],a ; Y-coordinate (integer part)
jp position_player ; tail call
set_player_initial_position_for_gameplay:
ld a,144
ld [PLAYER_STATE],a ; X-coordinate
ld a,0
ld [PLAYER_STATE+1],a ; Y-coordinate (integer part)
ld [PLAYER_STATE+2],a ; Y-coordinate (fractional part)
ld [PLAYER_STATE+3],a ; downward velocity (integer part)
ld [PLAYER_STATE+4],a ; downward velocity (fractional part)
jp position_player ; tail call
start_timer:
; The timer will be incremented 4096 times each second, and each time
; it overflows, it will be reset to 196. This means that the timer
; will overflow every (1/4096) * (256 - 196) = ~0.0156s.
ld a,192 ; the value of rTIMA after it overflows
ld [$ff06],a
ld a,%00000100 ; enable the timer
; increment rTIMA at 4096Hz
ld [$ff07],a
ret
; = INTERRUPT HANDLERS ==============================================
vblank:
push af
push bc
push de
push hl
; Note that the DMA procedure must be initiated from High RAM. The
; mechanism for that is detailed alongside the definition of this
; initiation procedure.
call hram_sprite_dma
call scroll_bg
ld a,1
ld [VBFLAG],a
pop hl
pop de
pop bc
pop af
reti
timer:
push af
ld a,1
ld [SCROLLFLAG],a
pop af
reti
; = MAIN LOOP FUNCTIONS =============================================
read_joypad:
; The state that was current before should now become the old state.
ld a,[PAD]
ld [OLDPAD],a
; First, we will read the direction pad by sending a value to the
; joypad register (P1) that will enable the d-pad (by clearing bit 4)
; and disable the buttons (by setting bit 5).
ld a,%00100000
ld [$ff00],a
; To minimize the effects of key bouncing, in which the contacts of
; the joypad cause oscillations between the high and low states, we
; read from P1 multiple times and only use the last value read.
ld a,[$ff00]
ld a,[$ff00]
ld a,[$ff00]
ld a,[$ff00]
and %00001111 ; pick out only the input lines...
swap a ; ...put the states into the high nibble...
ld b,a ; ...and save it away temporarily
; Now we want to read the buttons, and that means we disable the d-pad
; (by setting bit 4) and enable the buttons (by clearing bit 5).
ld a,%00010000
ld [$ff00],a
ld a,[$ff00]
ld a,[$ff00]
ld a,[$ff00]
ld a,[$ff00]
and %00001111
or b ; B contains the d-pad input in the high nibble, so we
; can we incorporate the button input in the low nibble
; Now, A contains the state of the d-pad and the buttons, but when a
; bit is cleared, that means the button is pressed. So, we take the
; complement, and we have an intuitive mapping of 1->pressed and
; 0->not pressed.
cpl
ld [PAD],a
ret
react_to_input_in_menu:
.start_game:
ld a,[PAD]
bit 3,a
jr z,.done
ld a,[OLDPAD]
bit 3,a
jr nz,.done ; only respond to start if start wasn't pressed before
jp start_game
.done:
ret
react_to_input_in_game_over:
.switch_to_menu:
ld a,[PAD]
bit 3,a
jr z,.done
ld a,[OLDPAD]
bit 3,a
jr nz,.done ; only respond to start if start wasn't pressed before
jp switch_to_menu
.done:
ret
react_to_input_during_gameplay:
; When moving horizontally, the player's height needs to be checked
; against the column the player will move into. For that, we'll need
; the player's x position, which we will manipulate before checking
; the height map.
call load_player_real_x_position
ld c,a
.move_right:
ld a,[PAD]
bit 4,a
jr z,.move_left
; Check if the player is allowed to move right
ld a,c ; reload the x position and get the position the right
add 17 ; side of the player would end up at
call load_height_map_entry_for_x_position
call height_to_num_pixels_above_column
add 1 ; add 1 to the number of pixels above the column
; because being exactly on the ground is okay
call is_player_above_column
jr nz,.move_right_slower ; If we can't move right by 2 pixels, try to
; move right by only 1 pixel.
ld a,[PLAYER_STATE]
sub 176
jr nc,.move_left
add 178
ld [PLAYER_STATE],a
jr .move_left
.move_right_slower:
; Check if the player is allowed to move right
ld a,c ; reload the x position and get the position the right
add 16 ; side of the player would end up at
call load_height_map_entry_for_x_position
call height_to_num_pixels_above_column
add 1 ; add 1 to the number of pixels above the column
; because being exactly on the ground is okay
call is_player_above_column
jr nz,.move_left
ld a,[PLAYER_STATE]
sub 176
jr nc,.move_left
add 177
ld [PLAYER_STATE],a
jr .move_left
.move_left:
ld a,[PAD]
bit 5,a
jr z,.jump
; Check if the player is allowed to move left
ld a,c ; reload the x position and get the position the left
sub 1 ; side of the player would end up at
call load_height_map_entry_for_x_position
call height_to_num_pixels_above_column
add 1 ; add 1 to the number of pixels above the column
; because being exactly on the ground is okay
call is_player_above_column
jr nz,.jump
ld a,[PLAYER_STATE]
sub 1
ld [PLAYER_STATE],a
.jump:
ld a,[PAD]
bit 0,a
jr z,.done
ld a,[OLDPAD]
bit 0,a
jr nz,.done ; only respond to A if A wasn't pressed before
ld a,[PLAYER_STATE+3]
cp 0
jr nz,.done
ld a,[PLAYER_STATE+4]
cp 0
jr nz,.done
ld a,$fc
ld [PLAYER_STATE+3],a
ld a,$70
ld [PLAYER_STATE+4],a
.done:
ret
apply_forces:
; In simple Newtonian mechanics, over time:
;
; 1. The downward speed of an object increases linearly with time,
; proportional to the acceleration due to gravity.
;
; 2. The Y-position increases linearly, proportional to the downward,
; velocity. This means it actually increases quadratically with
; time:
;
; y(t) = g * t^2 + v0 * t + y0
;
; This results in the following updates:
;
; y' = y' + v * t * k
; v' = v' + g * t * k
;
; Where "k" is a constant to account for the fact that we're dealing
; with pixels and frames, not meters and seconds. Because the
; timestep is constant (always one frame), we can set "t * k = 1",
; and set "g" to whatever value makes sense for us.
; y' = y' + v
ld bc,PLAYER_STATE+2
ld de,PLAYER_STATE+4
call add_16bit_numbers_in_memory
call check_is_grounded
jr z,.not_grounded
; Since the player is on or below the ground, reset the player to the
; correct height, and set the downward velocity to "0". Register a
; contains the height to which to reset the player, as an integer.
sub 16 ; subtract 16 because the height refers to the player's feet
ld [PLAYER_STATE+1],a
ld a,0
ld [PLAYER_STATE+2],a
ld [PLAYER_STATE+3],a
ld [PLAYER_STATE+4],a
jr .grounded
.not_grounded:
; v' = v' + g
; register b = g in the above equation. The value can be adjusted
; based on trial and error to get the right feel for the game.
ld hl,PLAYER_STATE+4
ld b,32
call add_fractional_to_16bit_number
.grounded:
ret
check_is_grounded:
; output:
; a = the height where the player should be placed, if the player
; is on or below the ground. The output is "0" if the player is
; above the height of the tallest column under it.
;
; Sets the zero flag based on if "a" is "0" or not.
call load_player_real_x_position
ld c,a ; keep the position around for later
and %00001111 ; if the last four bits are zero, then we're
jr z,.on_column ; cleanly on a column
; At this point, we know at least one of the last three digits is
; non-zero, so we're between columns. That means we have to check
; two adjacent columns.
.between_columns:
ld a,c ; reload the x position
call load_height_map_entry_for_x_position
ld d,a
ld a,c ; reload the x position
add 15 ; get the x position at the right edge of the player
call load_height_map_entry_for_x_position
ld b,d
call max
call height_to_num_pixels_above_column
jr is_player_above_column ; tail call
.on_column:
; The player is exclusively over a column.
ld a,c ; reload the x position
call load_height_map_entry_for_x_position
call height_to_num_pixels_above_column
; drop down into "is_player_above_column" function
is_player_above_column:
; parameters:
; a = number of pixels above the column to check against
;
; Sets the zero flag if the player's feet are above the specified
; number of pixels, and unsets the flag otherwise (i.e. z := "is
; player not grounded").
ld b,a
ld a,[PLAYER_STATE+1] ; load the player's y position and add 16 to
add 16 ; get the position of the player's feet
sub b ; compare it against the ground height as
jr c,.not_grounded ; computed above (number of pixels above the
; the player's feet)
ld a,b ; either we're below the ground or on the
jr .set_z_flag ; ground. Either way, the output is the
; ground position.
.not_grounded:
ld a,0
.set_z_flag:
cp 0
ret
load_height_map_entry_for_x_position:
; parameters:
; a = the real x position of the player in the level, modulo 256.
; This is the x position of the player on the screen, plus the
; offset of the background.
; output:
; a = the height map entry corresponding to the given x position.
; This entry is one byte, and it consists of the heights for
; two adjacent columns.
srl a ; divide the x position by 16 to get the column number
srl a
srl a
srl a
ld hl,HEIGHTS ; load the base address of the height map
add a,l ; add the index into the height map and save it into
ld l,a ; "l" so that "hl" points to the height that we then
ld a,[hl] ; load into "a"
ret
height_to_num_pixels_above_column:
; parameters:
; a = the height of a column, as extracted from the height map
; output:
; a = the number of pixels that make up the sky above the column
ld b,a ; compute (9 - height), as that tells us the number of
ld a,9 ; sky tiles above the column
sub b
sla a ; multiply by 16 to get the number of pixels above the
sla a ; column
sla a
sla a
ret
position_player:
; Note that the actual Y-coordinate on the screen is the value stored
; in the OAM structure minus 16, and the actual X-coordinate is the
; stored value minus 8. Furthermore, the two sprites that comprise
; the player have the same Y-coordinate, but two different
; X-coordinates (one being 8 more than the other).
; Because the coordinates are stored in 8.8 fixed point format, we
; can simply ignore the second byte in each pair, since the entire
; first byte is the integer portion.
; load and write the X-coordinates
ld a,[PLAYER_STATE]
sub a,8
ld [PLAYER+1],a
add a,8
ld [PLAYER+5],a
; load and write the Y-coordinate
ld a,[PLAYER_STATE+1]
add a,16
ld [PLAYER],a
ld [PLAYER+4],a
ret
load_player_real_x_position:
; output:
; a = the real x position of the player's left side, accounting for
; how much the background has scrolled (modulo any wraparound).
ld a,[PLAYER_STATE] ; to get the player's real x position, start
sub 15 ; with the position on screen, and add the
ld hl,BGSCRL ; level scroll offset
add a,[hl]
ret
scroll_world_if_needed:
ld a,[SCROLLFLAG]
cp 0
jr z,.no_scroll
ld a,0
ld [SCROLLFLAG],a
ld hl,BGSCRL
inc [hl]
ld hl,PLAYER_STATE
dec [hl]
.no_scroll:
ret
check_for_game_over:
; The player's x position is stored as the on-screen x position plus
; 16, so that the player can be partially to the left of the screen.
; This means that when the player has fully gone past the left of the
; screen, the position has wrapped around to 255.
; Because the player can't go too far to the right of the screen, we
; can safely assume the player's position is near 255 only when the
; player has gone to the left of the screen. Accounting for a little
; bit of buffer, we can safely check to see if the position is near
; 255, and if so, end the game.
ld a,[PLAYER_STATE]
sub 250
jr c,.done
jp show_game_over_screen
.done:
ret
scroll_bg:
ld a,[BGSCRL]
ld [$ff43],a ; set scrollx
ret
; During the DMA transfer, the CPU can only access the High RAM
; (HRAM), so the transfer must be initiated from inside of HRAM.
; However, we can't directly place this procedure there at assembly
; time, so we'll put it here with the rest of the code, then copy it
; into HRAM at run time.
sprite_dma:
ld a,OAMBUF/$100
ld [$ff46],a
ld a,$28
.wait:
dec a
jr nz,.wait
ret
sprite_dma_end:
; We'll set aside some space in HRAM, but we'll have to store the
; actual data here at run time.
PUSHS
SECTION "HRAM",HRAM
; This is the procedure that will actually be called to initiate the
; DMA transfer.
hram_sprite_dma:
DS sprite_dma_end-sprite_dma
POPS
; = UTILITY FUNCTIONS ===============================================
load_column_into_bg_tile_map_at_address:
; parameters:
; hl = start address of bg tile map
; b = number of rows filled with boxes
ld a,$9 ; compute the number of rows filled with sky
sub b ; b = 9 - b
ld b,a
ld d,$00 ; DE = $001f
ld e,$1f ; the amount to increment HL by each tile row, minus one
; (so two increments are needed for each logical row).
; the minus one is because we'll increment by one in
; order to fill out the left and right sides of the box
; on each of the top and bottom portions of the box.
ld c,$0
.loop:
ld a,c ; if c == b: load a box tile
sub b
jr nc, .box
ld a,$84 ; otherwise, load a sky tile
ld [hl],a ; fill out the top-left
inc hl ; fill out the top-right
ld [hl],a
add hl,de ; fill out the bottom-left
ld [hl],a
inc hl ; fill out the bottom-right
ld [hl],a
add hl,de ; get ready for the next load
jr .done
.box:
ld a,$80 ; load a box tile
ld [hl],a ; fill out the top-left
inc hl ; fill out the top-right
inc a ; with the next tile
ld [hl],a
add hl,de ; fill out the bottom-left
inc a ; with the next tile
ld [hl],a
inc hl ; fill out the bottom-right
inc a ; with the next tile
ld [hl],a
add hl,de ; get ready for the next load
.done:
inc c ; only bother filling out the top 9 rows, as that's all
ld a,c ; that will be visible on screen
cp $9
jr nz, .loop
ret
clear_bg:
; Zero out the background by loading only sky tiles.
ld b,$04 ; we will write $0400 (1024) bytes
ld c,$00
ld hl,$9800 ; we will be writing to the BG tile map
.bg_reset_loop:
ld a,$84 ; we will only be writing sky tiles
ld [hl],a ; store one byte in the destination
inc hl ; prepare to write another byte
; the same caveat applies as in memcpy
dec bc ; decrement the counter
ld a,b
or c
jr z,.bg_reset_loop_done ; return if all bytes written
jr .bg_reset_loop
.bg_reset_loop_done:
ret
memcpy:
; parameters:
; hl = source address
; de = destination address
; bc = number of bytes to copy
; assumes:
; bc > 0
ld a,[hl] ; load a byte from the source
ld [de],a ; store it in the destination
inc hl ; prepare to load another byte...
inc de ; ...and prepare to write it
; Now we'll decrement the counter and check if it's zero.
; Unfortunately, when a 16-bit register is decremented, the zero flag
; is not updated, so we need to check if the counter is zero
; manually. A 16-bit value is zero when its constituent 8-bit
; portions are both zero, that is when (b | c) == 0, where "|" is a
; bitwise OR.
dec bc ; decrement the counter
ld a,b
or c
ret z ; return if all bytes written
jr memcpy
zeromem:
; parameters
; de = destination address
; bc = number of bytes to zero out
; assumes:
; bc > 0
.zeromem_loop:
ld a,0 ; we will only be writing zeros
ld [de],a ; store one byte in the destination
inc de ; prepare to write another byte
; the same caveat applies as in memcpy
dec bc ; decrement the counter
ld a,b
or c
ret z ; return if all bytes written
jr .zeromem_loop
lcd_off:
ld a,[$ff40] ; load the LCD Control register
bit 7,a ; check bit 7, whether the LCD is on
ret z ; if off, return immediately
wait_vblank:
ld a,[$ff44] ; load the vertical line the LCD is at
cp 145
jr nz, wait_vblank
; Technically, at this point, we are not just at VBlank, but exactly
; at the start of VBlank. This is because the previous instruction
; made sure that [LY] is exactly 145, the first value when entering
; VBlank.
ld a,[$ff40] ; load the LCD Control register
res 7,a ; clear bit 7, turning off the LCD
ld [$ff40],a ; write the new value back to the LCD Control register
ret ; and done...
lcd_on:
ld a,%11000111 ; LCD on
; Window Tile Map at $9800-9fff
; window off
; BG & window Tile Data at $8800-$97ff
; BG Tile Map at $9800-$9bff
; sprite size 8x16
; sprites on
; BG on
ld [$ff40],a ; write it to the LCD Control register
rand:
; An 8-bit pseudo-random number generator. Taken from
; http://www.z80.info/pseudo-random.txt
;
; R = an integer in the range [1, 256]
; R -> (33 * R) mod 257
;
; parameters:
; hl = address where to take the seed and store the next seed
; output:
; a = next random number
ld a,[hl]
ld b,a
rrca ; multiply by 32
rrca
rrca
xor $1f
add a,b
sbc a,$ff
ld [hl],a
ret
next_rand_height:
; Generate the next random height to put into the height map. The
; result is in the range of [2, 5] inclusive.
;
; output:
; a = next random height
push hl ; preserve HL
ld hl,RANDHEIGHT ; the PRNG seed is in RANDHEIGHT
call rand ; generate a pseudo-random number in the range
; [1, 256]
and %00000011 ; preserve the two least-significant bits of the
add a,%00000010 ; height. This brings the value down to the range
; of [0, 3]. Then add "2", bringing the value into
; the range [2, 5].
pop hl ; restore HL
ret
add_fractional_to_16bit_number:
; Adds a fractional value to 16-bit number stored in a 8.8 fixed
; point format. This entails adding the given value to the second
; byte (fractional part) of the number, then propagating the carry to
; the first byte (the integer part).
;
; No corresponding function is necessary to add an integer value, as
; that can be accomplished purely by adding to the first byte,
; without dealing with any carry.
;
; Stores the resulting number back at the location from which the
; original value was read.
;
; parameters:
; hl = address of *second* byte of the number to add to
; b = the fractional number to add
; output:
; [hl - 1] = [hl - 1] + b
ld a,[hl] ; load the fractional part
add a,b ; add the fractional part, setting the carry flag
ld [hl],a ; store the fractional part
dec hl ; move the address to the integer part
; this does not set the carry
jr nc,.done ; no need to do anything to the integer part if there was
; no carry from the fractional part
inc [hl] ; but if there was a carry, increment the integer part
.done:
ret
max:
; Given two 8-bit integers, returns the larger of the two.
;
; parameters:
; a = the first integer
; b = the second integer
; output:
; a = max(a, b)
sub b ; carry => a - b < 0 => a < b
jr c,.b_is_larger
.a_is_larger:
add b ; restore a to its original value
ret
.b_is_larger:
ld a,b
ret
add_16bit_numbers_in_memory:
; Adds two 16-bit numbers stored in a 8.8 fixed point format, storing
; the result back into the memory location of the first of the two
; numbers.
;
; parameters:
; bc = address of the *second* byte of the first number
; de = address of the *second* byte of the second number
; output:
; [bc - 1] = [bc - 1] + [de - 1]
ld a,[bc] ; load the fractional part of the first number
ld h,a ; into "h"
ld a,[de] ; load the fractional part of the second number into "a"
add a,h ; a += h. This sets the carry flag.
ld [bc],a ; store the result back into the fractional part of the
; first number
dec bc ; move the the integer part of both numbers
dec de ; this doesn't affect the carry flag
ld a,[bc] ; load the integer part of the first number
ld h,a ; into "h"
ld a,[de] ; load the integer part of the second number into "a"
adc a,h ; a += h + c
ld [bc],a ; store the result back into the integer part of the first
; number
ret
; = DATA ============================================================
bgpal:
DB %11100100 ; white is transparent, lightest to darkest.
sppal:
DB %00011100 ; missing second darkest
bgbox:
; background box, 2x2 tiles
DB $7f,$7f,$9f,$f0,$8f,$f8,$c7,$fc
DB $e3,$be,$f1,$9f,$f8,$8f,$fc,$87
DB $fe,$fe,$f9,$0f,$f1,$1f,$e3,$3f
DB $c5,$7f,$8b,$fd,$97,$f9,$6f,$f1
DB $fe,$87,$f9,$8f,$f1,$9f,$e2,$bf
DB $c5,$fe,$8b,$fc,$97,$f8,$7f,$7f
DB $3f,$e1,$1f,$f1,$8f,$f9,$c7,$7d
DB $e3,$3f,$f1,$1f,$f9,$0f,$fe,$fe
bgsky:
; background sky, 1x1 tile
DB $00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00
bgbigfont:
; backgound menu title, 7 2x2 tites
DB $00,$00,$38,$38,$6c,$6c,$5e,$5e ; M
DB $5f,$5f,$5f,$5f,$5f,$5f,$5f,$5f
DB $00,$00,$1c,$1c,$36,$36,$6e,$6e
DB $de,$de,$de,$de,$fe,$fe,$fe,$fe
DB $5b,$5b,$5b,$5b,$59,$59,$78,$78
DB $78,$78,$78,$78,$38,$38,$00,$00
DB $de,$de,$de,$de,$9e,$9e,$1e,$1e
DB $1e,$1e,$1e,$1e,$1c,$1c,$00,$00
DB $00,$00,$07,$07,$1f,$1f,$36,$36 ; O
DB $2c,$2c,$6c,$6c,$5c,$5c,$5c,$5c
DB $00,$00,$e0,$e0,$f8,$f8,$7c,$7c
DB $3c,$3c,$3e,$3e,$3e,$3e,$3e,$3e
DB $5c,$5c,$7c,$7c,$7c,$7c,$3c,$3c
DB $3e,$3e,$1f,$1f,$07,$07,$00,$00
DB $3e,$3e,$2e,$2e,$2e,$2e,$2c,$2c
DB $6c,$6c,$f8,$f8,$e0,$e0,$00,$00
DB $00,$00,$38,$38,$6e,$6e,$5f,$5f ; N
DB $5f,$5f,$5f,$5f,$5b,$5b,$5b,$5b
DB $00,$00,$1c,$1c,$1e,$1e,$16,$16
DB $16,$16,$16,$16,$96,$96,$96,$96
DB $59,$59,$59,$59,$58,$58,$78,$78
DB $78,$78,$78,$78,$38,$38,$00,$00
DB $d6,$d6,$d6,$d6,$f6,$f6,$fe,$fe
DB $7e,$7e,$7e,$7e,$1c,$1c,$00,$00
DB $00,$00,$3f,$3f,$67,$67,$5e,$5e ; E
DB $58,$58,$70,$70,$70,$70,$3f,$3f
DB $00,$00,$fc,$fc,$fe,$fe,$3e,$3e
DB $0e,$0e,$04,$04,$00,$00,$80,$80
DB $3f,$3f,$78,$78,$50,$50,$58,$58
DB $7e,$7e,$7f,$7f,$3f,$3f,$00,$00
DB $80,$80,$04,$04,$0e,$0e,$1e,$1e
DB $36,$36,$ee,$ee,$fc,$fc,$00,$00
DB $00,$00,$38,$38,$68,$68,$58,$58 ; Y
DB $58,$58,$7c,$7c,$3e,$3e,$3f,$3f
DB $00,$00,$1c,$1c,$1e,$1e,$16,$16
DB $16,$16,$36,$36,$6c,$6c,$dc,$dc
DB $1f,$1f,$0f,$0f,$03,$03,$03,$03
DB $03,$03,$03,$03,$01,$01,$00,$00
DB $f8,$f8,$e0,$e0,$c0,$c0,$c0,$c0
DB $c0,$c0,$c0,$c0,$80,$80,$00,$00
DB $00,$00,$3f,$3f,$6f,$6f,$5c,$5c ; R
DB $58,$58,$58,$58,$5c,$5c,$5f,$5f
DB $00,$00,$e0,$e0,$f8,$f8,$7c,$7c
DB $3c,$3c,$2c,$2c,$68,$68,$d8,$d8
DB $5f,$5f,$5f,$5f,$5b,$5b,$79,$79
DB $78,$78,$78,$78,$38,$38,$00,$00
DB $f0,$f0,$c0,$c0,$e0,$e0,$f0,$f0
DB $f8,$f8,$7c,$7c,$38,$38,$00,$00
DB $00,$00,$38,$38,$68,$68,$58,$58 ; U
DB $58,$58,$58,$58,$58,$58,$58,$58
DB $00,$00,$1c,$1c,$1e,$1e,$1e,$1e
DB $1e,$1e,$1e,$1e,$1e,$1e,$1e,$1e
DB $58,$58,$5c,$5c,$7c,$7c,$3f,$3f
DB $3f,$3f,$1f,$1f,$07,$07,$00,$00
DB $16,$16,$36,$36,$2e,$2e,$ec,$ec
DB $dc,$dc,$f8,$f8,$e0,$e0,$00,$00
DB $00,$00,$07,$07,$1f,$1f,$36,$36 ; G
DB $2c,$2c,$6c,$6c,$5c,$5c,$5c,$5c
DB $00,$00,$f0,$f0,$fc,$fc,$1e,$1e
DB $0e,$0e,$00,$00,$00,$00,$7e,$7e
DB $5c,$5c,$7c,$7c,$7c,$7c,$3c,$3c
DB $3e,$3e,$1f,$1f,$07,$07,$00,$00
DB $76,$76,$1e,$1e,$0e,$0e,$1e,$1e
DB $3e,$3e,$fc,$fc,$f0,$f0,$00,$00
DB $00,$00,$07,$07,$1f,$1f,$37,$37 ; A
DB $2f,$2f,$6c,$6c,$5c,$5c,$58,$58
DB $00,$00,$e0,$e0,$f8,$f8,$fc,$fc
DB $fc,$fc,$3e,$3e,$3e,$3e,$1e,$1e
DB $58,$58,$5f,$5f,$5f,$5f,$78,$78
DB $78,$78,$78,$78,$38,$38,$00,$00
DB $1e,$1e,$fe,$fe,$f6,$f6,$16,$16
DB $16,$16,$16,$16,$1c,$1c,$00,$00
DB $00,$00,$38,$38,$6c,$6c,$6c,$6c ; V
DB $2e,$2e,$36,$36,$17,$17,$1b,$1b
DB $00,$00,$1c,$1c,$3e,$3e,$2e,$2e
DB $6c,$6c,$5c,$5c,$d8,$d8,$f8,$f8
DB $0b,$0b,$0d,$0d,$05,$05,$06,$06
DB $03,$03,$03,$03,$01,$01,$00,$00
DB $f0,$f0,$f0,$f0,$e0,$e0,$e0,$e0
DB $c0,$c0,$c0,$c0,$80,$80,$00,$00
bgsmallfont:
DB $00,$00,$3c,$3c,$42,$42,$42,$42 ; P
DB $7c,$7c,$40,$40,$40,$40,$00,$00
DB $00,$00,$3c,$3c,$42,$42,$42,$42 ; R
DB $7c,$7c,$48,$48,$44,$44,$00,$00
DB $00,$00,$3c,$3c,$42,$42,$42,$42 ; E
DB $7c,$7c,$40,$40,$3e,$3e,$00,$00
DB $00,$00,$3c,$3c,$42,$42,$40,$40 ; S
DB $3c,$3c,$02,$02,$3c,$3c,$00,$00
DB $00,$00,$7e,$7e,$08,$08,$08,$08 ; T
DB $08,$08,$08,$08,$08,$08,$00,$00
DB $00,$00,$18,$18,$24,$24,$42,$42 ; A
DB $7e,$7e,$42,$42,$42,$42,$00,$00
bgtitlemap:
; The tile map for the menu title. This is just the four lines that
; make up the title, and that too only the part of the lines that
; have actual tiles in them. The bytes are copied into the correct
; location in the tile map area of memory.
DB $85,$86,$89,$8a,$8d,$8e,$91,$92,$95,$96 ; Line 0
DB $87,$88,$8b,$8c,$8f,$90,$93,$94,$97,$98 ; Line 1
DB $99,$9a,$9d,$9e,$8d,$8e ; Line 2
DB $9b,$9c,$9f,$a0,$8f,$90 ; Line 3
bgpressstartmap:
; The tile map for "PRESS START" text. This is just the line that
; makes up the text, and that too only part of the line. The bytes
; are copied into the correct location int he tile map area of
; memory.
DB $ad,$ae,$af,$b0,$b0,$84,$84,$b0,$b1,$b2,$ae,$b1
gameovertitlemap:
; The tile map for the game over title. This is just the four lines
; that make up the title, and that too only the part of the lines
; that have actual tiles in them. The bytes are copied into the
; correct location in the tile map area of memory.
DB $a1,$a2,$a5,$a6,$85,$86,$91,$92 ; Line 0
DB $a3,$a4,$a7,$a8,$87,$88,$93,$94 ; Line 1
DB $89,$8a,$a9,$aa,$91,$92,$99,$9a ; Line 2
DB $8b,$8c,$ab,$ac,$93,$94,$9b,$9c ; Line 3
ghost:
; foreground ghost
;
; There are a total of 4 tiles laid out in a 2x2 grid, but because
; the sprites used are 8x16 pixels in dimension, only two sprites are
; required.
DB $03,$00,$0c,$03,$10,$0f,$11,$0f ; sprite 0
DB $23,$1d,$27,$19,$27,$19,$61,$1f
DB $ab,$55,$a5,$5a,$a1,$5f,$61,$1f
DB $21,$1f,$20,$1f,$26,$19,$19,$00
DB $c0,$00,$30,$c0,$f8,$f0,$f8,$f0 ; sprite 1
DB $fc,$d8,$fc,$98,$fc,$98,$fe,$f8
DB $ff,$5a,$ff,$aa,$ff,$fa,$fe,$f8
DB $fc,$f8,$fc,$f8,$7c,$98,$98,$00
; vim: ft=rgbasm:tw=72:cc=72:ts=2:sw=2
| 27.571728 | 72 | 0.627868 |
a47529502f84a4a4caf9974a02f491fa4a01ab73 | 16,422 | asm | Assembly | src/third_party/openh264/src/codec/common/x86/mb_copy.asm | ilya-fedin/tg_owt | d5c3d43b959c7e9e7d8004b9b7fdadd12ce7d589 | [
"BSD-3-Clause"
] | 3,565 | 2015-01-03T21:02:47.000Z | 2022-03-30T13:37:29.000Z | src/third_party/openh264/src/codec/common/x86/mb_copy.asm | ilya-fedin/tg_owt | d5c3d43b959c7e9e7d8004b9b7fdadd12ce7d589 | [
"BSD-3-Clause"
] | 2,103 | 2015-01-02T21:32:34.000Z | 2022-03-31T23:30:13.000Z | src/third_party/openh264/src/codec/common/x86/mb_copy.asm | ilya-fedin/tg_owt | d5c3d43b959c7e9e7d8004b9b7fdadd12ce7d589 | [
"BSD-3-Clause"
] | 1,319 | 2015-01-01T10:02:18.000Z | 2022-03-28T15:31:20.000Z | ;*!
;* \copy
;* Copyright (c) 2009-2013, Cisco Systems
;* All rights reserved.
;*
;* Redistribution and use in source and binary forms, with or without
;* modification, are permitted provided that the following conditions
;* are met:
;*
;* * Redistributions of source code must retain the above copyright
;* notice, this list of conditions and the following disclaimer.
;*
;* * 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.
;*
;* 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.
;*
;*
;* mb_copy.asm
;*
;* Abstract
;* mb_copy and mb_copy1
;*
;* History
;* 15/09/2009 Created
;* 12/28/2009 Modified with larger throughput
;* 12/29/2011 Tuned WelsCopy16x16NotAligned_sse2, added UpdateMbMv_sse2 WelsCopy16x8NotAligned_sse2,
;* WelsCopy16x8_mmx, WelsCopy8x16_mmx etc;
;*
;*
;*********************************************************************************************/
%include "asm_inc.asm"
%ifdef __NASM_VER__
%use smartalign
%endif
;***********************************************************************
; Macros and other preprocessor constants
;***********************************************************************
;***********************************************************************
; Code
;***********************************************************************
SECTION .text
;***********************************************************************
; void WelsCopy16x16_sse2( uint8_t* Dst,
; int32_t iStrideD,
; uint8_t* Src,
; int32_t iStrideS )
;***********************************************************************
WELS_EXTERN WelsCopy16x16_sse2
push r4
push r5
%assign push_num 2
LOAD_4_PARA
PUSH_XMM 8
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
lea r4, [r1+2*r1] ;ebx, [eax+2*eax] ; x3
lea r5, [r3+2*r3] ;edx, [ecx+2*ecx] ; x3
movdqa xmm0, [r2]
movdqa xmm1, [r2+r3]
movdqa xmm2, [r2+2*r3]
movdqa xmm3, [r2+r5]
lea r2, [r2+4*r3]
movdqa xmm4, [r2]
movdqa xmm5, [r2+r3]
movdqa xmm6, [r2+2*r3]
movdqa xmm7, [r2+r5]
lea r2, [r2+4*r3]
movdqa [r0], xmm0
movdqa [r0+r1], xmm1
movdqa [r0+2*r1], xmm2
movdqa [r0+r4], xmm3
lea r0, [r0+4*r1]
movdqa [r0], xmm4
movdqa [r0+r1], xmm5
movdqa [r0+2*r1], xmm6
movdqa [r0+r4], xmm7
lea r0, [r0+4*r1]
movdqa xmm0, [r2]
movdqa xmm1, [r2+r3]
movdqa xmm2, [r2+2*r3]
movdqa xmm3, [r2+r5]
lea r2, [r2+4*r3]
movdqa xmm4, [r2]
movdqa xmm5, [r2+r3]
movdqa xmm6, [r2+2*r3]
movdqa xmm7, [r2+r5]
movdqa [r0], xmm0
movdqa [r0+r1], xmm1
movdqa [r0+2*r1], xmm2
movdqa [r0+r4], xmm3
lea r0, [r0+4*r1]
movdqa [r0], xmm4
movdqa [r0+r1], xmm5
movdqa [r0+2*r1], xmm6
movdqa [r0+r4], xmm7
POP_XMM
LOAD_4_PARA_POP
pop r5
pop r4
ret
;***********************************************************************
; void WelsCopy16x16NotAligned_sse2( uint8_t* Dst,
; int32_t iStrideD,
; uint8_t* Src,
; int32_t iStrideS )
;***********************************************************************
; dst can be align with 16 bytes, but not sure about pSrc, 12/29/2011
WELS_EXTERN WelsCopy16x16NotAligned_sse2
push r4
push r5
%assign push_num 2
LOAD_4_PARA
PUSH_XMM 8
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
lea r4, [r1+2*r1] ;ebx, [eax+2*eax] ; x3
lea r5, [r3+2*r3] ;edx, [ecx+2*ecx] ; x3
movdqu xmm0, [r2]
movdqu xmm1, [r2+r3]
movdqu xmm2, [r2+2*r3]
movdqu xmm3, [r2+r5]
lea r2, [r2+4*r3]
movdqu xmm4, [r2]
movdqu xmm5, [r2+r3]
movdqu xmm6, [r2+2*r3]
movdqu xmm7, [r2+r5]
lea r2, [r2+4*r3]
movdqa [r0], xmm0
movdqa [r0+r1], xmm1
movdqa [r0+2*r1], xmm2
movdqa [r0+r4], xmm3
lea r0, [r0+4*r1]
movdqa [r0], xmm4
movdqa [r0+r1], xmm5
movdqa [r0+2*r1], xmm6
movdqa [r0+r4], xmm7
lea r0, [r0+4*r1]
movdqu xmm0, [r2]
movdqu xmm1, [r2+r3]
movdqu xmm2, [r2+2*r3]
movdqu xmm3, [r2+r5]
lea r2, [r2+4*r3]
movdqu xmm4, [r2]
movdqu xmm5, [r2+r3]
movdqu xmm6, [r2+2*r3]
movdqu xmm7, [r2+r5]
movdqa [r0], xmm0
movdqa [r0+r1], xmm1
movdqa [r0+2*r1], xmm2
movdqa [r0+r4], xmm3
lea r0, [r0+4*r1]
movdqa [r0], xmm4
movdqa [r0+r1], xmm5
movdqa [r0+2*r1], xmm6
movdqa [r0+r4], xmm7
POP_XMM
LOAD_4_PARA_POP
pop r5
pop r4
ret
; , 12/29/2011
;***********************************************************************
; void WelsCopy16x8NotAligned_sse2(uint8_t* Dst,
; int32_t iStrideD,
; uint8_t* Src,
; int32_t iStrideS )
;***********************************************************************
WELS_EXTERN WelsCopy16x8NotAligned_sse2
push r4
push r5
%assign push_num 2
LOAD_4_PARA
PUSH_XMM 8
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
lea r4, [r1+2*r1] ;ebx, [eax+2*eax] ; x3
lea r5, [r3+2*r3] ;edx, [ecx+2*ecx] ; x3
movdqu xmm0, [r2]
movdqu xmm1, [r2+r3]
movdqu xmm2, [r2+2*r3]
movdqu xmm3, [r2+r5]
lea r2, [r2+4*r3]
movdqu xmm4, [r2]
movdqu xmm5, [r2+r3]
movdqu xmm6, [r2+2*r3]
movdqu xmm7, [r2+r5]
movdqa [r0], xmm0
movdqa [r0+r1], xmm1
movdqa [r0+2*r1], xmm2
movdqa [r0+r4], xmm3
lea r0, [r0+4*r1]
movdqa [r0], xmm4
movdqa [r0+r1], xmm5
movdqa [r0+2*r1], xmm6
movdqa [r0+r4], xmm7
POP_XMM
LOAD_4_PARA_POP
pop r5
pop r4
ret
;***********************************************************************
; void WelsCopy8x16_mmx(uint8_t* Dst,
; int32_t iStrideD,
; uint8_t* Src,
; int32_t iStrideS )
;***********************************************************************
WELS_EXTERN WelsCopy8x16_mmx
%assign push_num 0
LOAD_4_PARA
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
movq mm0, [r2]
movq mm1, [r2+r3]
lea r2, [r2+2*r3]
movq mm2, [r2]
movq mm3, [r2+r3]
lea r2, [r2+2*r3]
movq mm4, [r2]
movq mm5, [r2+r3]
lea r2, [r2+2*r3]
movq mm6, [r2]
movq mm7, [r2+r3]
lea r2, [r2+2*r3]
movq [r0], mm0
movq [r0+r1], mm1
lea r0, [r0+2*r1]
movq [r0], mm2
movq [r0+r1], mm3
lea r0, [r0+2*r1]
movq [r0], mm4
movq [r0+r1], mm5
lea r0, [r0+2*r1]
movq [r0], mm6
movq [r0+r1], mm7
lea r0, [r0+2*r1]
movq mm0, [r2]
movq mm1, [r2+r3]
lea r2, [r2+2*r3]
movq mm2, [r2]
movq mm3, [r2+r3]
lea r2, [r2+2*r3]
movq mm4, [r2]
movq mm5, [r2+r3]
lea r2, [r2+2*r3]
movq mm6, [r2]
movq mm7, [r2+r3]
movq [r0], mm0
movq [r0+r1], mm1
lea r0, [r0+2*r1]
movq [r0], mm2
movq [r0+r1], mm3
lea r0, [r0+2*r1]
movq [r0], mm4
movq [r0+r1], mm5
lea r0, [r0+2*r1]
movq [r0], mm6
movq [r0+r1], mm7
WELSEMMS
LOAD_4_PARA_POP
ret
;***********************************************************************
; void WelsCopy8x8_mmx( uint8_t* Dst,
; int32_t iStrideD,
; uint8_t* Src,
; int32_t iStrideS )
;***********************************************************************
WELS_EXTERN WelsCopy8x8_mmx
push r4
%assign push_num 1
LOAD_4_PARA
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
lea r4, [r3+2*r3] ;edx, [ebx+2*ebx]
; to prefetch next loop
prefetchnta [r2+2*r3]
prefetchnta [r2+r4]
movq mm0, [r2]
movq mm1, [r2+r3]
lea r2, [r2+2*r3]
; to prefetch next loop
prefetchnta [r2+2*r3]
prefetchnta [r2+r4]
movq mm2, [r2]
movq mm3, [r2+r3]
lea r2, [r2+2*r3]
; to prefetch next loop
prefetchnta [r2+2*r3]
prefetchnta [r2+r4]
movq mm4, [r2]
movq mm5, [r2+r3]
lea r2, [r2+2*r3]
movq mm6, [r2]
movq mm7, [r2+r3]
movq [r0], mm0
movq [r0+r1], mm1
lea r0, [r0+2*r1]
movq [r0], mm2
movq [r0+r1], mm3
lea r0, [r0+2*r1]
movq [r0], mm4
movq [r0+r1], mm5
lea r0, [r0+2*r1]
movq [r0], mm6
movq [r0+r1], mm7
WELSEMMS
LOAD_4_PARA_POP
pop r4
ret
; (dunhuang@cisco), 12/21/2011
;***********************************************************************
; void UpdateMbMv_sse2( SMVUnitXY *pMvBuffer, const SMVUnitXY sMv )
;***********************************************************************
WELS_EXTERN UpdateMbMv_sse2
%assign push_num 0
LOAD_2_PARA
movd xmm0, r1d ; _mv
pshufd xmm1, xmm0, $00
movdqa [r0 ], xmm1
movdqa [r0+0x10], xmm1
movdqa [r0+0x20], xmm1
movdqa [r0+0x30], xmm1
ret
;*******************************************************************************
; Macros and other preprocessor constants
;*******************************************************************************
;*******************************************************************************
; Code
;*******************************************************************************
SECTION .text
;*******************************************************************************
; void PixelAvgWidthEq4_mmx( uint8_t *pDst, int iDstStride,
; uint8_t *pSrcA, int iSrcAStride,
; uint8_t *pSrcB, int iSrcBStride,
; int iHeight );
;*******************************************************************************
WELS_EXTERN PixelAvgWidthEq4_mmx
%assign push_num 0
LOAD_7_PARA
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
SIGN_EXTENSION r5, r5d
SIGN_EXTENSION r6, r6d
ALIGN 4
.height_loop:
movd mm0, [r4]
pavgb mm0, [r2]
movd [r0], mm0
dec r6
lea r0, [r0+r1]
lea r2, [r2+r3]
lea r4, [r4+r5]
jne .height_loop
WELSEMMS
LOAD_7_PARA_POP
ret
;*******************************************************************************
; void PixelAvgWidthEq8_mmx( uint8_t *pDst, int iDstStride,
; uint8_t *pSrcA, int iSrcAStride,
; uint8_t *pSrcB, int iSrcBStride,
; int iHeight );
;*******************************************************************************
WELS_EXTERN PixelAvgWidthEq8_mmx
%assign push_num 0
LOAD_7_PARA
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
SIGN_EXTENSION r5, r5d
SIGN_EXTENSION r6, r6d
ALIGN 4
.height_loop:
movq mm0, [r2]
pavgb mm0, [r4]
movq [r0], mm0
movq mm0, [r2+r3]
pavgb mm0, [r4+r5]
movq [r0+r1], mm0
lea r2, [r2+2*r3]
lea r4, [r4+2*r5]
lea r0, [r0+2*r1]
sub r6, 2
jnz .height_loop
WELSEMMS
LOAD_7_PARA_POP
ret
;*******************************************************************************
; void PixelAvgWidthEq16_sse2( uint8_t *pDst, int iDstStride,
; uint8_t *pSrcA, int iSrcAStride,
; uint8_t *pSrcB, int iSrcBStride,
; int iHeight );
;*******************************************************************************
WELS_EXTERN PixelAvgWidthEq16_sse2
%assign push_num 0
LOAD_7_PARA
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
SIGN_EXTENSION r5, r5d
SIGN_EXTENSION r6, r6d
ALIGN 4
.height_loop:
movdqu xmm0, [r2]
movdqu xmm1, [r4]
pavgb xmm0, xmm1
;pavgb xmm0, [r4]
movdqu [r0], xmm0
movdqu xmm0, [r2+r3]
movdqu xmm1, [r4+r5]
pavgb xmm0, xmm1
movdqu [r0+r1], xmm0
movdqu xmm0, [r2+2*r3]
movdqu xmm1, [r4+2*r5]
pavgb xmm0, xmm1
movdqu [r0+2*r1], xmm0
lea r2, [r2+2*r3]
lea r4, [r4+2*r5]
lea r0, [r0+2*r1]
movdqu xmm0, [r2+r3]
movdqu xmm1, [r4+r5]
pavgb xmm0, xmm1
movdqu [r0+r1], xmm0
lea r2, [r2+2*r3]
lea r4, [r4+2*r5]
lea r0, [r0+2*r1]
sub r6, 4
jne .height_loop
WELSEMMS
LOAD_7_PARA_POP
ret
; load_instr=%1 store_instr=%2 p_dst=%3 i_dststride=%4 p_src=%5 i_srcstride=%6 cnt=%7 r_tmp=%8,%9 mm_tmp=%10,%11
%macro CopyStrided4N 11
lea %8, [3 * %6]
lea %9, [3 * %4]
ALIGN 32
%%loop:
%1 %10, [%5]
%1 %11, [%5 + %6]
%2 [%3], %10
%2 [%3 + %4], %11
%1 %10, [%5 + 2 * %6]
%1 %11, [%5 + %8]
%2 [%3 + 2 * %4], %10
%2 [%3 + %9], %11
lea %5, [%5 + 4 * %6]
lea %3, [%3 + 4 * %4]
sub %7, 4
jg %%loop
%endmacro
;*******************************************************************************
; void McCopyWidthEq8_mmx( uint8_t *pSrc, int iSrcStride,
; uint8_t *pDst, int iDstStride, int iHeight )
;*******************************************************************************
WELS_EXTERN McCopyWidthEq8_mmx
%assign push_num 0
%ifdef X86_32
push r5
push r6
%assign push_num 2
%endif
LOAD_5_PARA
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
SIGN_EXTENSION r4, r4d
CopyStrided4N movq, movq, r2, r3, r0, r1, r4, r5, r6, mm0, mm1
WELSEMMS
LOAD_5_PARA_POP
%ifdef X86_32
pop r6
pop r5
%endif
ret
;*******************************************************************************
; void McCopyWidthEq16_sse2( uint8_t *pSrc, int iSrcStride, uint8_t *pDst, int iDstStride, int iHeight )
;*******************************************************************************
;read unaligned memory
%macro SSE_READ_UNA 2
movq %1, [%2]
movhps %1, [%2+8]
%endmacro
;write unaligned memory
%macro SSE_WRITE_UNA 2
movq [%1], %2
movhps [%1+8], %2
%endmacro
WELS_EXTERN McCopyWidthEq16_sse2
%assign push_num 0
LOAD_5_PARA
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
SIGN_EXTENSION r4, r4d
ALIGN 4
.height_loop:
SSE_READ_UNA xmm0, r0
SSE_READ_UNA xmm1, r0+r1
SSE_WRITE_UNA r2, xmm0
SSE_WRITE_UNA r2+r3, xmm1
sub r4, 2
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
jnz .height_loop
LOAD_5_PARA_POP
ret
;*******************************************************************************
; void McCopyWidthEq16_sse3( uint8_t *pSrc, int iSrcStride, uint8_t *pDst, int iDstStride, int iHeight )
;*******************************************************************************
WELS_EXTERN McCopyWidthEq16_sse3
%assign push_num 0
%ifdef X86_32
push r5
push r6
%assign push_num 2
%endif
LOAD_5_PARA
SIGN_EXTENSION r1, r1d
SIGN_EXTENSION r3, r3d
SIGN_EXTENSION r4, r4d
CopyStrided4N lddqu, MOVDQ, r2, r3, r0, r1, r4, r5, r6, xmm0, xmm1
LOAD_5_PARA_POP
%ifdef X86_32
pop r6
pop r5
%endif
ret
| 26.659091 | 112 | 0.468335 |
abd6cd1b6147535d4b1e1a5bf0a62fcd4f81f061 | 471 | asm | Assembly | oeis/318/A318456.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/318/A318456.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/318/A318456.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A318456: a(n) = n OR A001065(n), where OR is bitwise-or (A003986) and A001065 = sum of proper divisors.
; Submitted by Simon Strandgaard
; 1,3,3,7,5,6,7,15,13,10,11,28,13,14,15,31,17,23,19,22,31,30,23,60,31,26,31,28,29,62,31,63,47,54,47,55,37,54,55,58
mov $1,$0
seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n).
seq $1,318458 ; a(n) = n AND A001065(n), where AND is bitwise-and (A004198) & A001065 = sum of proper divisors.
sub $0,$1
| 52.333333 | 114 | 0.670913 |
6a3226a60430869fef17ea28951e1b4d858bd38f | 342 | asm | Assembly | programs/oeis/174/A174048.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/174/A174048.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/174/A174048.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A174048: Prime(A173919(n))
; 2,3,5,7,11,13,17,29,31,37,41,53,59,61,67,79,83,107,109,113,127,151,157,173,179,181,191,199,211,239,241,271,277,281,283,317,331,349,353,359,367,397,401,421,431,457,461,503,509,541,547,557,563,577,587,593,599
seq $0,93515 ; Numbers k such that either k or k-1 is a prime.
sub $0,2
seq $0,40 ; The prime numbers.
| 48.857143 | 208 | 0.701754 |
c4d8f21fd869f8f0f05fe755a8c95445eeca5d8f | 789 | asm | Assembly | oeis/227/A227665.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/227/A227665.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/227/A227665.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A227665: Number of lattice paths from {n}^3 to {0}^3 using steps that decrement one component by 1 such that for each point (p_1,p_2,p_3) we have abs(p_{i}-p_{i+1}) <= 1.
; Submitted by Jamie Morken(s4)
; 1,6,44,320,2328,16936,123208,896328,6520712,47437640,345104904,2510609608,18264477064,132872558664,966636864776,7032203170760,51158695924872,372175277815624,2707544336559112,19697160911545032,143295215053933448,1042460827200624200,7583816220512236296,55171635197986902472,401369078826932789896,2919926822184503334216,21242225912945388919304,154535435034986729103560,1124232497070797881563528,8178698349565558629151816,59499353441100506167189768,432852870786834660428632008
mov $1,1
mov $3,3
lpb $0
sub $0,1
mov $2,$3
mul $2,2
mul $3,7
add $3,$1
mov $1,$2
lpe
mov $0,$1
| 49.3125 | 474 | 0.808619 |
b50d1e55dff2bbb2b470d11df245fe9d95fd5fc0 | 3,016 | asm | Assembly | Transynther/x86/_processed/NONE/_zr_/i3-7100_9_0x84_notsx.log_31_2128.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 9 | 2020-08-13T19:41:58.000Z | 2022-03-30T12:22:51.000Z | Transynther/x86/_processed/NONE/_zr_/i3-7100_9_0x84_notsx.log_31_2128.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 1 | 2021-04-29T06:29:35.000Z | 2021-05-13T21:02:30.000Z | Transynther/x86/_processed/NONE/_zr_/i3-7100_9_0x84_notsx.log_31_2128.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 3 | 2020-07-14T17:07:07.000Z | 2022-03-21T01:12:22.000Z | .global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
// Store
mov $0x6df, %rcx
nop
nop
nop
nop
nop
xor %rbx, %rbx
mov $0x5152535455565758, %r15
movq %r15, %xmm7
movups %xmm7, (%rcx)
nop
nop
nop
nop
inc %rcx
// Store
lea addresses_US+0x19e9f, %r14
nop
nop
nop
nop
add $5515, %rbp
movw $0x5152, (%r14)
nop
nop
nop
nop
nop
cmp $9575, %r14
// Store
lea addresses_D+0xd607, %rbx
nop
nop
nop
nop
xor %r13, %r13
mov $0x5152535455565758, %rdi
movq %rdi, (%rbx)
nop
nop
nop
nop
inc %rcx
// Store
lea addresses_A+0x1c2df, %rbx
nop
nop
nop
and $48880, %r13
movb $0x51, (%rbx)
nop
nop
nop
dec %rbp
// Store
lea addresses_WT+0x2781, %rdi
nop
nop
nop
nop
cmp $41480, %rbx
mov $0x5152535455565758, %rcx
movq %rcx, %xmm4
movups %xmm4, (%rdi)
nop
and $36378, %rcx
// Store
lea addresses_A+0x1c2df, %r15
nop
nop
nop
nop
xor %rbx, %rbx
mov $0x5152535455565758, %rcx
movq %rcx, %xmm0
vmovups %ymm0, (%r15)
nop
nop
nop
nop
inc %rcx
// Store
lea addresses_PSE+0xa389, %r15
nop
xor $20704, %rbx
mov $0x5152535455565758, %rbp
movq %rbp, %xmm5
movups %xmm5, (%r15)
nop
nop
nop
nop
sub $61654, %r14
// Store
lea addresses_WT+0x1ebd3, %rbp
nop
nop
nop
cmp %rdi, %rdi
mov $0x5152535455565758, %r15
movq %r15, %xmm0
vmovaps %ymm0, (%rbp)
nop
nop
nop
add %r15, %r15
// Faulty Load
lea addresses_A+0x1c2df, %rdi
add %rcx, %rcx
vmovups (%rdi), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $1, %xmm3, %rbp
lea oracles, %r13
and $0xff, %rbp
shlq $12, %rbp
mov (%r13,%rbp,1), %rbp
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_P', 'same': False, 'size': 16, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_US', 'same': False, 'size': 2, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WT', 'same': False, 'size': 16, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WT', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'00': 31}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
| 18.05988 | 123 | 0.642905 |
b2683d959b368aa868aed37eccb9d2331328ec24 | 648 | asm | Assembly | programs/oeis/057/A057211.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/057/A057211.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/057/A057211.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | ; A057211: n-th run has length n.
; 1,0,0,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
mov $1,1
mov $3,3
lpb $0,1
sub $0,1
add $2,1
trn $0,$2
mov $1,1
trn $1,$3
trn $3,3
add $3,$1
lpe
| 43.2 | 501 | 0.503086 |
0e46d44d3b4045e15345aa414fda582409bf2de2 | 556 | asm | Assembly | programs/oeis/143/A143689.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/143/A143689.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/143/A143689.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A143689: a(n) = (3*n^2 - n + 2)/2.
; 1,2,6,13,23,36,52,71,93,118,146,177,211,248,288,331,377,426,478,533,591,652,716,783,853,926,1002,1081,1163,1248,1336,1427,1521,1618,1718,1821,1927,2036,2148,2263,2381,2502,2626,2753,2883,3016,3152,3291,3433,3578,3726,3877,4031,4188,4348,4511,4677,4846,5018,5193,5371,5552,5736,5923,6113,6306,6502,6701,6903,7108,7316,7527,7741,7958,8178,8401,8627,8856,9088,9323,9561,9802,10046,10293,10543,10796,11052,11311,11573,11838,12106,12377,12651,12928,13208,13491,13777,14066,14358,14653
mul $0,3
bin $0,2
div $0,3
add $0,1
| 69.5 | 481 | 0.746403 |
a5641570cf6f0fab9a7d53ed75fa3cd3087ac49c | 29,342 | asm | Assembly | data/battle_anims/framesets.asm | Dev727/ancientplatinum | 8b212a1728cc32a95743e1538b9eaa0827d013a7 | [
"blessing"
] | 28 | 2019-11-08T07:19:00.000Z | 2021-12-20T10:17:54.000Z | data/battle_anims/framesets.asm | Dev727/ancientplatinum | 8b212a1728cc32a95743e1538b9eaa0827d013a7 | [
"blessing"
] | 13 | 2020-01-11T17:00:40.000Z | 2021-09-14T01:27:38.000Z | data/battle_anims/framesets.asm | Dev727/ancientplatinum | 8b212a1728cc32a95743e1538b9eaa0827d013a7 | [
"blessing"
] | 22 | 2020-05-28T17:31:38.000Z | 2022-03-07T20:49:35.000Z | BattleAnimFrameData:
; entries correspond to BATTLEANIMFRAMESET_* constants
dw .Frameset_00 ; BATTLEANIMFRAMESET_00
dw .Frameset_01 ; BATTLEANIMFRAMESET_01
dw .Frameset_02 ; BATTLEANIMFRAMESET_02
dw .Frameset_03 ; BATTLEANIMFRAMESET_03
dw .Frameset_04 ; BATTLEANIMFRAMESET_04
dw .Frameset_05 ; BATTLEANIMFRAMESET_05
dw .Frameset_06 ; BATTLEANIMFRAMESET_06
dw .Frameset_07 ; BATTLEANIMFRAMESET_07
dw .Frameset_08 ; BATTLEANIMFRAMESET_08
dw .Frameset_09 ; BATTLEANIMFRAMESET_09
dw .Frameset_0a ; BATTLEANIMFRAMESET_0A
dw .Frameset_0b ; BATTLEANIMFRAMESET_0B
dw .Frameset_0c ; BATTLEANIMFRAMESET_0C
dw .Frameset_0d ; BATTLEANIMFRAMESET_0D
dw .Frameset_0e ; BATTLEANIMFRAMESET_0E
dw .Frameset_0f ; BATTLEANIMFRAMESET_0F
dw .Frameset_10 ; BATTLEANIMFRAMESET_10
dw .Frameset_11 ; BATTLEANIMFRAMESET_11
dw .Frameset_12 ; BATTLEANIMFRAMESET_12
dw .Frameset_13 ; BATTLEANIMFRAMESET_13
dw .Frameset_14 ; BATTLEANIMFRAMESET_14
dw .Frameset_15 ; BATTLEANIMFRAMESET_15
dw .Frameset_16 ; BATTLEANIMFRAMESET_16
dw .Frameset_17 ; BATTLEANIMFRAMESET_17
dw .Frameset_18 ; BATTLEANIMFRAMESET_18
dw .Frameset_19 ; BATTLEANIMFRAMESET_19
dw .Frameset_1a ; BATTLEANIMFRAMESET_1A
dw .Frameset_1b ; BATTLEANIMFRAMESET_1B
dw .Frameset_1c ; BATTLEANIMFRAMESET_1C
dw .Frameset_1d ; BATTLEANIMFRAMESET_1D
dw .Frameset_1e ; BATTLEANIMFRAMESET_1E
dw .Frameset_1f ; BATTLEANIMFRAMESET_1F
dw .Frameset_20 ; BATTLEANIMFRAMESET_20
dw .Frameset_21 ; BATTLEANIMFRAMESET_21
dw .Frameset_22 ; BATTLEANIMFRAMESET_22
dw .Frameset_23 ; BATTLEANIMFRAMESET_23
dw .Frameset_24 ; BATTLEANIMFRAMESET_24
dw .Frameset_25 ; BATTLEANIMFRAMESET_25
dw .Frameset_26 ; BATTLEANIMFRAMESET_26
dw .Frameset_27 ; BATTLEANIMFRAMESET_27
dw .Frameset_28 ; BATTLEANIMFRAMESET_28
dw .Frameset_29 ; BATTLEANIMFRAMESET_29
dw .Frameset_2a ; BATTLEANIMFRAMESET_2A
dw .Frameset_2b ; BATTLEANIMFRAMESET_2B
dw .Frameset_2c ; BATTLEANIMFRAMESET_2C
dw .Frameset_2d ; BATTLEANIMFRAMESET_2D
dw .Frameset_2e ; BATTLEANIMFRAMESET_2E
dw .Frameset_2f ; BATTLEANIMFRAMESET_2F
dw .Frameset_30 ; BATTLEANIMFRAMESET_30
dw .Frameset_31 ; BATTLEANIMFRAMESET_31
dw .Frameset_32 ; BATTLEANIMFRAMESET_32
dw .Frameset_33 ; BATTLEANIMFRAMESET_33
dw .Frameset_34 ; BATTLEANIMFRAMESET_34
dw .Frameset_35 ; BATTLEANIMFRAMESET_35
dw .Frameset_36 ; BATTLEANIMFRAMESET_36
dw .Frameset_37 ; BATTLEANIMFRAMESET_37
dw .Frameset_38 ; BATTLEANIMFRAMESET_38
dw .Frameset_39 ; BATTLEANIMFRAMESET_39
dw .Frameset_3a ; BATTLEANIMFRAMESET_3A
dw .Frameset_3b ; BATTLEANIMFRAMESET_3B
dw .Frameset_3c ; BATTLEANIMFRAMESET_3C
dw .Frameset_3d ; BATTLEANIMFRAMESET_3D
dw .Frameset_3e ; BATTLEANIMFRAMESET_3E
dw .Frameset_3f ; BATTLEANIMFRAMESET_3F
dw .Frameset_40 ; BATTLEANIMFRAMESET_40
dw .Frameset_41 ; BATTLEANIMFRAMESET_41
dw .Frameset_42 ; BATTLEANIMFRAMESET_42
dw .Frameset_43 ; BATTLEANIMFRAMESET_43
dw .Frameset_44 ; BATTLEANIMFRAMESET_44
dw .Frameset_45 ; BATTLEANIMFRAMESET_45
dw .Frameset_46 ; BATTLEANIMFRAMESET_46
dw .Frameset_47 ; BATTLEANIMFRAMESET_47
dw .Frameset_48 ; BATTLEANIMFRAMESET_48
dw .Frameset_49 ; BATTLEANIMFRAMESET_49
dw .Frameset_4a ; BATTLEANIMFRAMESET_4A
dw .Frameset_4b ; BATTLEANIMFRAMESET_4B
dw .Frameset_4c ; BATTLEANIMFRAMESET_4C
dw .Frameset_4d ; BATTLEANIMFRAMESET_4D
dw .Frameset_4e ; BATTLEANIMFRAMESET_4E
dw .Frameset_4f ; BATTLEANIMFRAMESET_4F
dw .Frameset_50 ; BATTLEANIMFRAMESET_50
dw .Frameset_51 ; BATTLEANIMFRAMESET_51
dw .Frameset_52 ; BATTLEANIMFRAMESET_52
dw .Frameset_53 ; BATTLEANIMFRAMESET_53
dw .Frameset_54 ; BATTLEANIMFRAMESET_54
dw .Frameset_55 ; BATTLEANIMFRAMESET_55
dw .Frameset_56 ; BATTLEANIMFRAMESET_56
dw .Frameset_57 ; BATTLEANIMFRAMESET_57
dw .Frameset_58 ; BATTLEANIMFRAMESET_58
dw .Frameset_59 ; BATTLEANIMFRAMESET_59
dw .Frameset_5a ; BATTLEANIMFRAMESET_5A
dw .Frameset_5b ; BATTLEANIMFRAMESET_5B
dw .Frameset_5c ; BATTLEANIMFRAMESET_5C
dw .Frameset_5d ; BATTLEANIMFRAMESET_5D
dw .Frameset_5e ; BATTLEANIMFRAMESET_5E
dw .Frameset_5f ; BATTLEANIMFRAMESET_5F
dw .Frameset_60 ; BATTLEANIMFRAMESET_60
dw .Frameset_61 ; BATTLEANIMFRAMESET_61
dw .Frameset_62 ; BATTLEANIMFRAMESET_62
dw .Frameset_63 ; BATTLEANIMFRAMESET_63
dw .Frameset_64 ; BATTLEANIMFRAMESET_64
dw .Frameset_65 ; BATTLEANIMFRAMESET_65
dw .Frameset_66 ; BATTLEANIMFRAMESET_66
dw .Frameset_67 ; BATTLEANIMFRAMESET_67
dw .Frameset_68 ; BATTLEANIMFRAMESET_68
dw .Frameset_69 ; BATTLEANIMFRAMESET_69
dw .Frameset_6a ; BATTLEANIMFRAMESET_6A
dw .Frameset_6b ; BATTLEANIMFRAMESET_6B
dw .Frameset_6c ; BATTLEANIMFRAMESET_6C
dw .Frameset_6d ; BATTLEANIMFRAMESET_6D
dw .Frameset_6e ; BATTLEANIMFRAMESET_6E
dw .Frameset_6f ; BATTLEANIMFRAMESET_6F
dw .Frameset_70 ; BATTLEANIMFRAMESET_70
dw .Frameset_71 ; BATTLEANIMFRAMESET_71
dw .Frameset_72 ; BATTLEANIMFRAMESET_72
dw .Frameset_73 ; BATTLEANIMFRAMESET_73
dw .Frameset_74 ; BATTLEANIMFRAMESET_74
dw .Frameset_75 ; BATTLEANIMFRAMESET_75
dw .Frameset_76 ; BATTLEANIMFRAMESET_76
dw .Frameset_77 ; BATTLEANIMFRAMESET_77
dw .Frameset_78 ; BATTLEANIMFRAMESET_78
dw .Frameset_79 ; BATTLEANIMFRAMESET_79
dw .Frameset_7a ; BATTLEANIMFRAMESET_7A
dw .Frameset_7b ; BATTLEANIMFRAMESET_7B
dw .Frameset_7c ; BATTLEANIMFRAMESET_7C
dw .Frameset_7d ; BATTLEANIMFRAMESET_7D
dw .Frameset_7e ; BATTLEANIMFRAMESET_7E
dw .Frameset_7f ; BATTLEANIMFRAMESET_7F
dw .Frameset_80 ; BATTLEANIMFRAMESET_80
dw .Frameset_81 ; BATTLEANIMFRAMESET_81
dw .Frameset_82 ; BATTLEANIMFRAMESET_82
dw .Frameset_83 ; BATTLEANIMFRAMESET_83
dw .Frameset_84 ; BATTLEANIMFRAMESET_84
dw .Frameset_85 ; BATTLEANIMFRAMESET_85
dw .Frameset_86 ; BATTLEANIMFRAMESET_86
dw .Frameset_87 ; BATTLEANIMFRAMESET_87
dw .Frameset_88 ; BATTLEANIMFRAMESET_88
dw .Frameset_89 ; BATTLEANIMFRAMESET_89
dw .Frameset_8a ; BATTLEANIMFRAMESET_8A
dw .Frameset_8b ; BATTLEANIMFRAMESET_8B
dw .Frameset_8c ; BATTLEANIMFRAMESET_8C
dw .Frameset_8d ; BATTLEANIMFRAMESET_8D
dw .Frameset_8e ; BATTLEANIMFRAMESET_8E
dw .Frameset_8f ; BATTLEANIMFRAMESET_8F
dw .Frameset_90 ; BATTLEANIMFRAMESET_90
dw .Frameset_91 ; BATTLEANIMFRAMESET_91
dw .Frameset_92 ; BATTLEANIMFRAMESET_92
dw .Frameset_93 ; BATTLEANIMFRAMESET_93
dw .Frameset_94 ; BATTLEANIMFRAMESET_94
dw .Frameset_95 ; BATTLEANIMFRAMESET_95
dw .Frameset_96 ; BATTLEANIMFRAMESET_96
dw .Frameset_97 ; BATTLEANIMFRAMESET_97
dw .Frameset_98 ; BATTLEANIMFRAMESET_98
dw .Frameset_99 ; BATTLEANIMFRAMESET_99
dw .Frameset_9a ; BATTLEANIMFRAMESET_9A
dw .Frameset_9b ; BATTLEANIMFRAMESET_9B
dw .Frameset_9c ; BATTLEANIMFRAMESET_9C
dw .Frameset_9d ; BATTLEANIMFRAMESET_9D
dw .Frameset_9e ; BATTLEANIMFRAMESET_9E
dw .Frameset_9f ; BATTLEANIMFRAMESET_9F
dw .Frameset_a0 ; BATTLEANIMFRAMESET_A0
dw .Frameset_a1 ; BATTLEANIMFRAMESET_A1
dw .Frameset_a2 ; BATTLEANIMFRAMESET_A2
dw .Frameset_a3 ; BATTLEANIMFRAMESET_A3
dw .Frameset_a4 ; BATTLEANIMFRAMESET_A4
dw .Frameset_a5 ; BATTLEANIMFRAMESET_A5
dw .Frameset_a6 ; BATTLEANIMFRAMESET_A6
dw .Frameset_a7 ; BATTLEANIMFRAMESET_A7
dw .Frameset_a8 ; BATTLEANIMFRAMESET_A8
dw .Frameset_a9 ; BATTLEANIMFRAMESET_A9
dw .Frameset_aa ; BATTLEANIMFRAMESET_AA
dw .Frameset_ab ; BATTLEANIMFRAMESET_AB
dw .Frameset_ac ; BATTLEANIMFRAMESET_AC
dw .Frameset_ad ; BATTLEANIMFRAMESET_AD
dw .Frameset_ae ; BATTLEANIMFRAMESET_AE
dw .Frameset_af ; BATTLEANIMFRAMESET_AF
dw .Frameset_b0 ; BATTLEANIMFRAMESET_B0
dw .Frameset_b1 ; BATTLEANIMFRAMESET_B1
dw .Frameset_b2 ; BATTLEANIMFRAMESET_B2
dw .Frameset_b3 ; BATTLEANIMFRAMESET_B3
dw .Frameset_b4 ; BATTLEANIMFRAMESET_B4
dw .Frameset_b5 ; BATTLEANIMFRAMESET_B5
dw .Frameset_b6 ; BATTLEANIMFRAMESET_B6
dw .Frameset_b7 ; BATTLEANIMFRAMESET_B7
dw .Frameset_b8 ; BATTLEANIMFRAMESET_B8
.Frameset_00:
frame BATTLEANIMOAMSET_00, 6
delanim
.Frameset_01:
frame BATTLEANIMOAMSET_01, 6
delanim
.Frameset_02:
frame BATTLEANIMOAMSET_02, 6
delanim
.Frameset_03:
frame BATTLEANIMOAMSET_03, 6
delanim
.Frameset_04:
frame BATTLEANIMOAMSET_04, 6
delanim
.Frameset_05:
frame BATTLEANIMOAMSET_05, 6
delanim
.Frameset_06:
frame BATTLEANIMOAMSET_06, 6
delanim
.Frameset_07:
frame BATTLEANIMOAMSET_03, 4
frame BATTLEANIMOAMSET_01, 1
frame BATTLEANIMOAMSET_03, 4
frame BATTLEANIMOAMSET_01, 1
frame BATTLEANIMOAMSET_03, 4
frame BATTLEANIMOAMSET_01, 1
frame BATTLEANIMOAMSET_03, 4
frame BATTLEANIMOAMSET_01, 1
delanim
.Frameset_3e:
frame BATTLEANIMOAMSET_4B, 2
frame BATTLEANIMOAMSET_4C, 2
frame BATTLEANIMOAMSET_4D, 4
frame BATTLEANIMOAMSET_4E, 2
dowait 2
frame BATTLEANIMOAMSET_4E, 2
dowait 2
frame BATTLEANIMOAMSET_4E, 2
dowait 2
frame BATTLEANIMOAMSET_4E, 2
delanim
.Frameset_3f:
frame BATTLEANIMOAMSET_4B, 2, OAM_X_FLIP
frame BATTLEANIMOAMSET_4C, 2, OAM_X_FLIP
frame BATTLEANIMOAMSET_4D, 4, OAM_X_FLIP
frame BATTLEANIMOAMSET_4E, 2, OAM_X_FLIP
dowait 2
frame BATTLEANIMOAMSET_4E, 2, OAM_X_FLIP
dowait 2
frame BATTLEANIMOAMSET_4E, 2, OAM_X_FLIP
dowait 2
frame BATTLEANIMOAMSET_4E, 2, OAM_X_FLIP
delanim
.Frameset_40:
frame BATTLEANIMOAMSET_4B, 2, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_4C, 2, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_4D, 4, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_4E, 2, OAM_X_FLIP, OAM_Y_FLIP
dowait 2
frame BATTLEANIMOAMSET_4E, 2, OAM_X_FLIP, OAM_Y_FLIP
dowait 2
frame BATTLEANIMOAMSET_4E, 2, OAM_X_FLIP, OAM_Y_FLIP
dowait 2
frame BATTLEANIMOAMSET_4E, 2, OAM_X_FLIP, OAM_Y_FLIP
delanim
.Frameset_41:
frame BATTLEANIMOAMSET_4B, 1
frame BATTLEANIMOAMSET_4C, 1
frame BATTLEANIMOAMSET_4D, 1
frame BATTLEANIMOAMSET_4F, 1
frame BATTLEANIMOAMSET_50, 1
frame BATTLEANIMOAMSET_51, 1
frame BATTLEANIMOAMSET_52, 2
dowait 2
frame BATTLEANIMOAMSET_52, 2
dowait 2
frame BATTLEANIMOAMSET_52, 2
dowait 2
frame BATTLEANIMOAMSET_52, 2
delanim
.Frameset_42:
frame BATTLEANIMOAMSET_4B, 1, OAM_X_FLIP
frame BATTLEANIMOAMSET_4C, 1, OAM_X_FLIP
frame BATTLEANIMOAMSET_4D, 1, OAM_X_FLIP
frame BATTLEANIMOAMSET_4F, 1, OAM_X_FLIP
frame BATTLEANIMOAMSET_50, 1, OAM_X_FLIP
frame BATTLEANIMOAMSET_51, 1, OAM_X_FLIP
frame BATTLEANIMOAMSET_52, 2, OAM_X_FLIP
dowait 2
frame BATTLEANIMOAMSET_52, 2, OAM_X_FLIP
dowait 2
frame BATTLEANIMOAMSET_52, 2, OAM_X_FLIP
dowait 2
frame BATTLEANIMOAMSET_52, 2, OAM_X_FLIP
delanim
.Frameset_08:
frame BATTLEANIMOAMSET_00, 3
frame BATTLEANIMOAMSET_07, 3
frame BATTLEANIMOAMSET_08, 3
frame BATTLEANIMOAMSET_09, 3
delanim
.Frameset_09:
frame BATTLEANIMOAMSET_0A, 7
frame BATTLEANIMOAMSET_0B, 7
frame BATTLEANIMOAMSET_0A, 7
frame BATTLEANIMOAMSET_0B, 7, OAM_X_FLIP
dorestart
.Frameset_0a:
frame BATTLEANIMOAMSET_0C, 8
endanim
.Frameset_0b:
frame BATTLEANIMOAMSET_0D, 8
endanim
.Frameset_0c:
frame BATTLEANIMOAMSET_0A, 8
endanim
.Frameset_0d:
frame BATTLEANIMOAMSET_0A, 7
frame BATTLEANIMOAMSET_0B, 7
frame BATTLEANIMOAMSET_0A, 7
frame BATTLEANIMOAMSET_0B, 7, OAM_X_FLIP
frame BATTLEANIMOAMSET_0A, 7
endanim
.Frameset_0e:
frame BATTLEANIMOAMSET_0A, 8
endanim
.Frameset_0f:
frame BATTLEANIMOAMSET_0A, 4
frame BATTLEANIMOAMSET_0E, 4
dorestart
.Frameset_10:
frame BATTLEANIMOAMSET_0F, 4
frame BATTLEANIMOAMSET_10, 4
dorestart
.Frameset_11:
frame BATTLEANIMOAMSET_10, 4
frame BATTLEANIMOAMSET_0F, 4
frame BATTLEANIMOAMSET_0E, 4
frame BATTLEANIMOAMSET_0A, 4
frame BATTLEANIMOAMSET_0E, 4
frame BATTLEANIMOAMSET_0A, 4
frame BATTLEANIMOAMSET_0E, 4
frame BATTLEANIMOAMSET_0A, 4
delanim
.Frameset_12:
frame BATTLEANIMOAMSET_10, 1
frame BATTLEANIMOAMSET_0F, 1
frame BATTLEANIMOAMSET_12, 1
frame BATTLEANIMOAMSET_11, 1
frame BATTLEANIMOAMSET_12, 1
frame BATTLEANIMOAMSET_0F, 1
dorestart
.Frameset_13:
frame BATTLEANIMOAMSET_10, 3
frame BATTLEANIMOAMSET_0F, 3
frame BATTLEANIMOAMSET_12, 1
dowait 1
frame BATTLEANIMOAMSET_12, 1
dowait 1
frame BATTLEANIMOAMSET_12, 1
dowait 1
frame BATTLEANIMOAMSET_12, 1
dowait 1
frame BATTLEANIMOAMSET_12, 3
delanim
.Frameset_14:
frame BATTLEANIMOAMSET_13, 20
delanim
.Frameset_15:
frame BATTLEANIMOAMSET_10, 1
frame BATTLEANIMOAMSET_0F, 1
dorestart
.Frameset_16:
frame BATTLEANIMOAMSET_14, 8
endanim
.Frameset_17:
frame BATTLEANIMOAMSET_17, 4
frame BATTLEANIMOAMSET_16, 8
frame BATTLEANIMOAMSET_15, 8
frame BATTLEANIMOAMSET_16, 8
frame BATTLEANIMOAMSET_17, 4
frame BATTLEANIMOAMSET_17, 4
frame BATTLEANIMOAMSET_16, 8, OAM_X_FLIP
frame BATTLEANIMOAMSET_15, 8, OAM_X_FLIP
frame BATTLEANIMOAMSET_16, 8, OAM_X_FLIP
frame BATTLEANIMOAMSET_17, 4
dorestart
.Frameset_56:
frame BATTLEANIMOAMSET_69, 8
endanim
.Frameset_57:
frame BATTLEANIMOAMSET_69, 32
frame BATTLEANIMOAMSET_6A, 4
frame BATTLEANIMOAMSET_6B, 4
frame BATTLEANIMOAMSET_6D, 4
frame BATTLEANIMOAMSET_6C, 4
endanim
.Frameset_58:
frame BATTLEANIMOAMSET_6C, 8
frame BATTLEANIMOAMSET_6D, 8
dorestart
.Frameset_18:
frame BATTLEANIMOAMSET_18, 4
frame BATTLEANIMOAMSET_19, 4
frame BATTLEANIMOAMSET_1A, 4
delanim
.Frameset_19:
frame BATTLEANIMOAMSET_1B, 8
endanim
.Frameset_1a:
frame BATTLEANIMOAMSET_0F, 8
endanim
.Frameset_1b:
frame BATTLEANIMOAMSET_1C, 8
endanim
.Frameset_1c:
frame BATTLEANIMOAMSET_0A, 8
delanim
.Frameset_1d:
frame BATTLEANIMOAMSET_1D, 8
endanim
.Frameset_1e:
frame BATTLEANIMOAMSET_17, 8
endanim
.Frameset_1f:
frame BATTLEANIMOAMSET_0F, 3
frame BATTLEANIMOAMSET_10, 3
frame BATTLEANIMOAMSET_1E, 3
endanim
.Frameset_20:
frame BATTLEANIMOAMSET_1F, 16
frame BATTLEANIMOAMSET_20, 3
delanim
.Frameset_21:
frame BATTLEANIMOAMSET_20, 8
endanim
.Frameset_22:
frame BATTLEANIMOAMSET_20, 8
frame BATTLEANIMOAMSET_21, 8
frame BATTLEANIMOAMSET_1B, 8
frame BATTLEANIMOAMSET_21, 8
dorestart
.Frameset_23:
frame BATTLEANIMOAMSET_22, 8
endanim
.Frameset_24:
frame BATTLEANIMOAMSET_1B, 8
endanim
.Frameset_25:
frame BATTLEANIMOAMSET_23, 8
endanim
.Frameset_26:
frame BATTLEANIMOAMSET_24, 8
endanim
.Frameset_27:
frame BATTLEANIMOAMSET_25, 8
endanim
.Frameset_28:
frame BATTLEANIMOAMSET_26, 8
frame BATTLEANIMOAMSET_27, 8
endanim
.Frameset_29:
frame BATTLEANIMOAMSET_28, 8
frame BATTLEANIMOAMSET_29, 8
delanim
.Frameset_2a:
frame BATTLEANIMOAMSET_2A, 1
frame BATTLEANIMOAMSET_2B, 1
frame BATTLEANIMOAMSET_2C, 1
frame BATTLEANIMOAMSET_2D, 1
frame BATTLEANIMOAMSET_2E, 1
frame BATTLEANIMOAMSET_2D, 1
frame BATTLEANIMOAMSET_2C, 1
frame BATTLEANIMOAMSET_2B, 1
frame BATTLEANIMOAMSET_2A, 1
delanim
.Frameset_2b:
frame BATTLEANIMOAMSET_14, 1
frame BATTLEANIMOAMSET_15, 1
dorestart
.Frameset_2c:
frame BATTLEANIMOAMSET_2F, 4
frame BATTLEANIMOAMSET_30, 40
delanim
.Frameset_2d:
frame BATTLEANIMOAMSET_31, 8
endanim
.Frameset_2e:
frame BATTLEANIMOAMSET_32, 32
frame BATTLEANIMOAMSET_33, 32
frame BATTLEANIMOAMSET_34, 32
frame BATTLEANIMOAMSET_35, 32 ; fallthrough
.Frameset_2f:
dowait 2
frame BATTLEANIMOAMSET_35, 4
dowait 2
frame BATTLEANIMOAMSET_35, 4
dowait 2
frame BATTLEANIMOAMSET_35, 4
dowait 2
frame BATTLEANIMOAMSET_35, 4
delanim
.Frameset_30:
frame BATTLEANIMOAMSET_14, 4
frame BATTLEANIMOAMSET_15, 4
dorestart
.Frameset_31:
frame BATTLEANIMOAMSET_36, 2
frame BATTLEANIMOAMSET_37, 2
frame BATTLEANIMOAMSET_38, 2
frame BATTLEANIMOAMSET_39, 32
delanim
.Frameset_32:
frame BATTLEANIMOAMSET_3A, 2
frame BATTLEANIMOAMSET_3B, 2
frame BATTLEANIMOAMSET_3C, 2
frame BATTLEANIMOAMSET_3D, 32
delanim
.Frameset_33:
frame BATTLEANIMOAMSET_3A, 2, OAM_X_FLIP
frame BATTLEANIMOAMSET_3B, 2, OAM_X_FLIP
frame BATTLEANIMOAMSET_3C, 2, OAM_X_FLIP
frame BATTLEANIMOAMSET_3D, 32, OAM_X_FLIP
delanim
.Frameset_34:
frame BATTLEANIMOAMSET_3E, 8
frame BATTLEANIMOAMSET_3F, 8
frame BATTLEANIMOAMSET_40, 8
endanim
.Frameset_35:
frame BATTLEANIMOAMSET_40, 2
dowait 2
frame BATTLEANIMOAMSET_40, 2
dowait 2
frame BATTLEANIMOAMSET_41, 2
dowait 2
frame BATTLEANIMOAMSET_41, 2
dowait 2
dorestart
.Frameset_36:
frame BATTLEANIMOAMSET_42, 2
frame BATTLEANIMOAMSET_43, 2
frame BATTLEANIMOAMSET_44, 2
frame BATTLEANIMOAMSET_45, 2
dorestart
.Frameset_37:
frame BATTLEANIMOAMSET_19, 2
dowait 2
dorestart
.Frameset_38:
frame BATTLEANIMOAMSET_46, 4
frame BATTLEANIMOAMSET_47, 4
dorestart
.Frameset_39:
frame BATTLEANIMOAMSET_18, 2
dowait 2
dorestart
.Frameset_3a:
frame BATTLEANIMOAMSET_48, 8
endanim
.Frameset_3b:
frame BATTLEANIMOAMSET_48, 8, OAM_X_FLIP
endanim
.Frameset_3c:
frame BATTLEANIMOAMSET_49, 8
endanim
.Frameset_3d:
frame BATTLEANIMOAMSET_4A, 8
endanim
.Frameset_43:
frame BATTLEANIMOAMSET_20, 16
frame BATTLEANIMOAMSET_1F, 16
frame BATTLEANIMOAMSET_1E, 16
endanim
.Frameset_4c:
frame BATTLEANIMOAMSET_20, 8
frame BATTLEANIMOAMSET_1F, 8
frame BATTLEANIMOAMSET_1E, 8
endanim
.Frameset_44:
dowait 20
frame BATTLEANIMOAMSET_55, 40
frame BATTLEANIMOAMSET_54, 40
frame BATTLEANIMOAMSET_53, 20
dowait 4
frame BATTLEANIMOAMSET_53, 4
dowait 4
frame BATTLEANIMOAMSET_53, 4
dowait 4
frame BATTLEANIMOAMSET_53, 4
delanim
.Frameset_7e:
frame BATTLEANIMOAMSET_1E, 8
frame BATTLEANIMOAMSET_1F, 8
frame BATTLEANIMOAMSET_20, 8
delanim
.Frameset_45:
dowait 0
frame BATTLEANIMOAMSET_14, 0
frame BATTLEANIMOAMSET_15, 0
frame BATTLEANIMOAMSET_14, 0, OAM_X_FLIP
dowait 0
frame BATTLEANIMOAMSET_16, 0, OAM_X_FLIP
frame BATTLEANIMOAMSET_15, 0
frame BATTLEANIMOAMSET_16, 0
dorestart
.Frameset_46:
frame BATTLEANIMOAMSET_56, 2
frame BATTLEANIMOAMSET_57, 4
delanim
.Frameset_47:
frame BATTLEANIMOAMSET_56, 2, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_57, 4, OAM_X_FLIP, OAM_Y_FLIP
delanim
.Frameset_48:
frame BATTLEANIMOAMSET_56, 1
frame BATTLEANIMOAMSET_57, 1
frame BATTLEANIMOAMSET_58, 1
frame BATTLEANIMOAMSET_57, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_58, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_57, 2
delanim
.Frameset_49:
frame BATTLEANIMOAMSET_56, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_57, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_58, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_57, 1
frame BATTLEANIMOAMSET_58, 1
frame BATTLEANIMOAMSET_57, 2, OAM_X_FLIP, OAM_Y_FLIP
delanim
.Frameset_4a:
frame BATTLEANIMOAMSET_57, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_58, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_57, 1
frame BATTLEANIMOAMSET_58, 1
dorestart
.Frameset_4b:
frame BATTLEANIMOAMSET_59, 1
frame BATTLEANIMOAMSET_5A, 1
frame BATTLEANIMOAMSET_5B, 1
frame BATTLEANIMOAMSET_5C, 2
delanim
.Frameset_4d:
frame BATTLEANIMOAMSET_0A, 10
frame BATTLEANIMOAMSET_0B, 3, OAM_X_FLIP
frame BATTLEANIMOAMSET_5D, 3, OAM_X_FLIP
frame BATTLEANIMOAMSET_0B, 3, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_0A, 2, OAM_Y_FLIP
frame BATTLEANIMOAMSET_0B, 1, OAM_Y_FLIP
frame BATTLEANIMOAMSET_5D, 1
frame BATTLEANIMOAMSET_0B, 1
dorestart
.Frameset_4e:
frame BATTLEANIMOAMSET_0A, 3
frame BATTLEANIMOAMSET_0B, 7, OAM_X_FLIP
frame BATTLEANIMOAMSET_0A, 7
frame BATTLEANIMOAMSET_0B, 7
frame BATTLEANIMOAMSET_0A, 3
dorestart
.Frameset_4f:
frame BATTLEANIMOAMSET_5E, 32
frame BATTLEANIMOAMSET_5E, 32
delanim
.Frameset_50:
frame BATTLEANIMOAMSET_5F, 32
frame BATTLEANIMOAMSET_5F, 32
delanim
.Frameset_51:
frame BATTLEANIMOAMSET_60, 8
endanim
.Frameset_52:
frame BATTLEANIMOAMSET_61, 1
frame BATTLEANIMOAMSET_62, 1
frame BATTLEANIMOAMSET_63, 1
endanim
.Frameset_53:
frame BATTLEANIMOAMSET_63, 7
frame BATTLEANIMOAMSET_64, 7
dorestart
.Frameset_54:
frame BATTLEANIMOAMSET_65, 1
frame BATTLEANIMOAMSET_66, 1
frame BATTLEANIMOAMSET_67, 1
endanim
.Frameset_55:
frame BATTLEANIMOAMSET_67, 7
frame BATTLEANIMOAMSET_68, 7
dorestart
.Frameset_59:
frame BATTLEANIMOAMSET_6E, 8
endanim
.Frameset_5a:
frame BATTLEANIMOAMSET_6F, 8
endanim
.Frameset_5b:
frame BATTLEANIMOAMSET_6E, 8, OAM_Y_FLIP
endanim
.Frameset_5c:
frame BATTLEANIMOAMSET_18, 4
frame BATTLEANIMOAMSET_70, 4
frame BATTLEANIMOAMSET_71, 4
frame BATTLEANIMOAMSET_72, 4
frame BATTLEANIMOAMSET_73, 4
delanim
.Frameset_5d:
frame BATTLEANIMOAMSET_74, 4
frame BATTLEANIMOAMSET_75, 4
dorestart
.Frameset_5e:
frame BATTLEANIMOAMSET_14, 8
endanim
.Frameset_7a:
frame BATTLEANIMOAMSET_74, 3
frame BATTLEANIMOAMSET_14, 3
frame BATTLEANIMOAMSET_15, 3
frame BATTLEANIMOAMSET_14, 3
frame BATTLEANIMOAMSET_15, 3
delanim
.Frameset_af:
frame BATTLEANIMOAMSET_14, 0
frame BATTLEANIMOAMSET_15, 0
frame BATTLEANIMOAMSET_14, 0
frame BATTLEANIMOAMSET_15, 0
frame BATTLEANIMOAMSET_74, 12
delanim
.Frameset_5f:
frame BATTLEANIMOAMSET_76, 8
endanim
.Frameset_60:
frame BATTLEANIMOAMSET_77, 1
frame BATTLEANIMOAMSET_78, 1
frame BATTLEANIMOAMSET_79, 1
frame BATTLEANIMOAMSET_7A, 1
frame BATTLEANIMOAMSET_7B, 1
frame BATTLEANIMOAMSET_7C, 1
frame BATTLEANIMOAMSET_7D, 1
frame BATTLEANIMOAMSET_7C, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_7B, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_7A, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_79, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_78, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_77, 1, OAM_X_FLIP, OAM_Y_FLIP
delanim
.Frameset_61:
frame BATTLEANIMOAMSET_1B, 4
frame BATTLEANIMOAMSET_7E, 4
dorestart
.Frameset_62:
frame BATTLEANIMOAMSET_1B, 4, OAM_X_FLIP
frame BATTLEANIMOAMSET_7E, 4, OAM_X_FLIP
dorestart
.Frameset_63:
frame BATTLEANIMOAMSET_7F, 8
endanim
.Frameset_64:
frame BATTLEANIMOAMSET_25, 8
endanim
.Frameset_65:
frame BATTLEANIMOAMSET_80, 8
endanim
.Frameset_66:
frame BATTLEANIMOAMSET_83, 7
frame BATTLEANIMOAMSET_82, 7
frame BATTLEANIMOAMSET_81, 7
frame BATTLEANIMOAMSET_82, 7
frame BATTLEANIMOAMSET_83, 7
frame BATTLEANIMOAMSET_82, 7
frame BATTLEANIMOAMSET_81, 7
delanim
.Frameset_67:
frame BATTLEANIMOAMSET_1B, 16
delanim
.Frameset_68:
dowait 15
frame BATTLEANIMOAMSET_84, 15
frame BATTLEANIMOAMSET_85, 15
frame BATTLEANIMOAMSET_29, 15
frame BATTLEANIMOAMSET_28, 15
frame BATTLEANIMOAMSET_86, 32
delanim
.Frameset_69:
frame BATTLEANIMOAMSET_1B, 3
frame BATTLEANIMOAMSET_87, 3
frame BATTLEANIMOAMSET_88, 3
frame BATTLEANIMOAMSET_89, 3
delanim
.Frameset_6a:
frame BATTLEANIMOAMSET_8A, 2
frame BATTLEANIMOAMSET_8B, 2
frame BATTLEANIMOAMSET_8C, 2
frame BATTLEANIMOAMSET_8D, 2
delanim
.Frameset_6b:
frame BATTLEANIMOAMSET_61, 2
frame BATTLEANIMOAMSET_62, 2
frame BATTLEANIMOAMSET_63, 2
endanim
.Frameset_6c:
frame BATTLEANIMOAMSET_65, 2
frame BATTLEANIMOAMSET_66, 2
frame BATTLEANIMOAMSET_67, 2
endanim
.Frameset_6d:
frame BATTLEANIMOAMSET_8E, 8
endanim
.Frameset_6e:
frame BATTLEANIMOAMSET_8E, 8, OAM_X_FLIP
endanim
.Frameset_6f:
frame BATTLEANIMOAMSET_8F, 16
frame BATTLEANIMOAMSET_90, 16
dorestart
.Frameset_70:
frame BATTLEANIMOAMSET_91, 16
frame BATTLEANIMOAMSET_92, 16
dorestart
.Frameset_71:
frame BATTLEANIMOAMSET_93, 8
endanim
.Frameset_72:
frame BATTLEANIMOAMSET_1E, 8
endanim
.Frameset_73:
frame BATTLEANIMOAMSET_1B, 7
frame BATTLEANIMOAMSET_94, 7
dorestart
.Frameset_74:
frame BATTLEANIMOAMSET_95, 8
endanim
.Frameset_75:
frame BATTLEANIMOAMSET_96, 8
endanim
.Frameset_76:
frame BATTLEANIMOAMSET_95, 8
endanim
.Frameset_77:
frame BATTLEANIMOAMSET_97, 1
frame BATTLEANIMOAMSET_97, 1, OAM_X_FLIP
dorestart
.Frameset_78:
frame BATTLEANIMOAMSET_98, 8
endanim
.Frameset_79:
frame BATTLEANIMOAMSET_99, 32
frame BATTLEANIMOAMSET_99, 32
frame BATTLEANIMOAMSET_99, 32
frame BATTLEANIMOAMSET_99, 32
frame BATTLEANIMOAMSET_99, 32
frame BATTLEANIMOAMSET_9A, 8
endanim
.Frameset_7b:
frame BATTLEANIMOAMSET_9B, 8
endanim
.Frameset_7c:
frame BATTLEANIMOAMSET_9C, 2
frame BATTLEANIMOAMSET_9D, 2
frame BATTLEANIMOAMSET_9E, 8
dowait 2
frame BATTLEANIMOAMSET_9E, 2
dowait 2
frame BATTLEANIMOAMSET_9E, 2
dowait 2
frame BATTLEANIMOAMSET_9E, 2
delanim
.Frameset_7d:
frame BATTLEANIMOAMSET_9F, 8
endanim
.Frameset_7f:
frame BATTLEANIMOAMSET_0F, 8
endanim
.Frameset_80:
frame BATTLEANIMOAMSET_6B, 24
delanim
.Frameset_81:
frame BATTLEANIMOAMSET_A0, 1 ; fallthrough
.Frameset_82:
frame BATTLEANIMOAMSET_A1, 1 ; fallthrough
.Frameset_83:
frame BATTLEANIMOAMSET_A2, 1
delanim
.Frameset_84:
frame BATTLEANIMOAMSET_A3, 8
endanim
.Frameset_85:
frame BATTLEANIMOAMSET_A4, 4
frame BATTLEANIMOAMSET_A5, 4
frame BATTLEANIMOAMSET_A6, 4
frame BATTLEANIMOAMSET_A7, 4
frame BATTLEANIMOAMSET_A6, 4, OAM_X_FLIP
frame BATTLEANIMOAMSET_A5, 4, OAM_X_FLIP
dorestart
.Frameset_86:
frame BATTLEANIMOAMSET_A8, 4
frame BATTLEANIMOAMSET_A9, 4
frame BATTLEANIMOAMSET_AA, 4
frame BATTLEANIMOAMSET_AB, 4
frame BATTLEANIMOAMSET_AA, 4, OAM_X_FLIP
frame BATTLEANIMOAMSET_A9, 4, OAM_X_FLIP
dorestart
.Frameset_87:
frame BATTLEANIMOAMSET_1B, 8
endanim
.Frameset_88:
frame BATTLEANIMOAMSET_AC, 8
endanim
.Frameset_89:
frame BATTLEANIMOAMSET_AD, 8
endanim
.Frameset_8a:
frame BATTLEANIMOAMSET_AE, 8
endanim
.Frameset_8b:
frame BATTLEANIMOAMSET_AF, 8
endanim
.Frameset_8c:
frame BATTLEANIMOAMSET_B0, 32
delanim
.Frameset_8d:
frame BATTLEANIMOAMSET_B1, 7
frame BATTLEANIMOAMSET_B1, 7, OAM_X_FLIP
dorestart
.Frameset_8e:
frame BATTLEANIMOAMSET_B2, 8
endanim
.Frameset_8f:
frame BATTLEANIMOAMSET_B3, 8
endanim
.Frameset_90:
frame BATTLEANIMOAMSET_B3, 8, OAM_X_FLIP
endanim
.Frameset_91:
frame BATTLEANIMOAMSET_B3, 8, OAM_Y_FLIP
endanim
.Frameset_92:
frame BATTLEANIMOAMSET_B3, 8, OAM_X_FLIP, OAM_Y_FLIP
endanim
.Frameset_93:
frame BATTLEANIMOAMSET_B5, 8
endanim
.Frameset_94:
frame BATTLEANIMOAMSET_B5, 8, OAM_X_FLIP
endanim
.Frameset_95:
frame BATTLEANIMOAMSET_B5, 8, OAM_Y_FLIP
endanim
.Frameset_96:
frame BATTLEANIMOAMSET_B5, 8, OAM_X_FLIP, OAM_Y_FLIP
endanim
.Frameset_97:
frame BATTLEANIMOAMSET_B4, 8
endanim
.Frameset_98:
frame BATTLEANIMOAMSET_6B, 8
endanim
.Frameset_99:
frame BATTLEANIMOAMSET_B6, 8
endanim
.Frameset_9a:
frame BATTLEANIMOAMSET_B7, 32
endanim
.Frameset_9b:
frame BATTLEANIMOAMSET_1B, 32
endanim
.Frameset_9c:
frame BATTLEANIMOAMSET_B8, 32
endanim
.Frameset_9d:
frame BATTLEANIMOAMSET_B8, 32, OAM_X_FLIP
endanim
.Frameset_9e:
frame BATTLEANIMOAMSET_B9, 32
endanim
.Frameset_9f:
frame BATTLEANIMOAMSET_BA, 32
endanim
.Frameset_a0:
frame BATTLEANIMOAMSET_BB, 32, OAM_X_FLIP
endanim
.Frameset_a1:
frame BATTLEANIMOAMSET_BB, 32
endanim
.Frameset_a2:
frame BATTLEANIMOAMSET_BC, 32
endanim
.Frameset_a3:
frame BATTLEANIMOAMSET_BD, 11
frame BATTLEANIMOAMSET_BE, 11
frame BATTLEANIMOAMSET_1B, 11
delanim
.Frameset_a4:
frame BATTLEANIMOAMSET_BF, 4
frame BATTLEANIMOAMSET_C0, 4
frame BATTLEANIMOAMSET_C1, 4
delanim
.Frameset_a5:
frame BATTLEANIMOAMSET_C2, 32
frame BATTLEANIMOAMSET_C2, 32
delanim
.Frameset_a6:
frame BATTLEANIMOAMSET_4B, 2
frame BATTLEANIMOAMSET_4C, 2
frame BATTLEANIMOAMSET_4D, 32
frame BATTLEANIMOAMSET_4D, 32
frame BATTLEANIMOAMSET_4D, 32
frame BATTLEANIMOAMSET_4F, 1
frame BATTLEANIMOAMSET_50, 1
frame BATTLEANIMOAMSET_51, 1
frame BATTLEANIMOAMSET_52, 2
dowait 2
frame BATTLEANIMOAMSET_52, 2
dowait 2
frame BATTLEANIMOAMSET_52, 2
dowait 2
frame BATTLEANIMOAMSET_52, 2
delanim
.Frameset_a7:
frame BATTLEANIMOAMSET_4B, 2, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_4C, 2, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_4D, 32, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_4D, 32, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_4D, 32, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_4F, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_50, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_51, 1, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_52, 2, OAM_X_FLIP, OAM_Y_FLIP
dowait 2
frame BATTLEANIMOAMSET_52, 2, OAM_X_FLIP, OAM_Y_FLIP
dowait 2
frame BATTLEANIMOAMSET_52, 2, OAM_X_FLIP, OAM_Y_FLIP
dowait 2
frame BATTLEANIMOAMSET_52, 2, OAM_X_FLIP, OAM_Y_FLIP
delanim
.Frameset_a8:
frame BATTLEANIMOAMSET_C3, 1
frame BATTLEANIMOAMSET_C3, 1, OAM_X_FLIP, OAM_Y_FLIP
dorestart
.Frameset_a9:
frame BATTLEANIMOAMSET_C4, 32
endanim
.Frameset_aa:
frame BATTLEANIMOAMSET_C5, 4
frame BATTLEANIMOAMSET_C6, 4
frame BATTLEANIMOAMSET_C7, 4
delanim
.Frameset_ab:
frame BATTLEANIMOAMSET_C8, 1
frame BATTLEANIMOAMSET_C8, 1, OAM_X_FLIP
dorestart
.Frameset_ac:
frame BATTLEANIMOAMSET_C9, 3
frame BATTLEANIMOAMSET_05, 3
delanim
.Frameset_ad:
frame BATTLEANIMOAMSET_CA, 32
frame BATTLEANIMOAMSET_CB, 3
frame BATTLEANIMOAMSET_CA, 3
frame BATTLEANIMOAMSET_CB, 3
dorestart
.Frameset_ae:
frame BATTLEANIMOAMSET_03, 32, OAM_Y_FLIP
endanim
.Frameset_b0:
frame BATTLEANIMOAMSET_CC, 32
endanim
.Frameset_b1:
frame BATTLEANIMOAMSET_7F, 2
frame BATTLEANIMOAMSET_25, 2
frame BATTLEANIMOAMSET_80, 2
frame BATTLEANIMOAMSET_25, 2
dorestart
.Frameset_b2:
frame BATTLEANIMOAMSET_CD, 4
frame BATTLEANIMOAMSET_CE, 4
frame BATTLEANIMOAMSET_CD, 4, OAM_X_FLIP, OAM_Y_FLIP
frame BATTLEANIMOAMSET_CE, 4, OAM_X_FLIP, OAM_Y_FLIP
dorestart
.Frameset_b3:
frame BATTLEANIMOAMSET_CF, 4
frame BATTLEANIMOAMSET_D0, 4
frame BATTLEANIMOAMSET_D1, 4
frame BATTLEANIMOAMSET_D2, 4
delanim
.Frameset_b4:
frame BATTLEANIMOAMSET_D3, 32
endanim
.Frameset_b5:
frame BATTLEANIMOAMSET_D4, 8
endanim
.Frameset_b6:
frame BATTLEANIMOAMSET_D5, 8
endanim
.Frameset_b7:
frame BATTLEANIMOAMSET_D6, 8
endanim
.Frameset_b8:
frame BATTLEANIMOAMSET_D7, 8
endanim
| 23.122143 | 54 | 0.806591 |
e69713776a121c378afaf6aeec68e7eaf6402dc6 | 522 | asm | Assembly | programs/oeis/178/A178960.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/178/A178960.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | programs/oeis/178/A178960.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | ; A178960: Numbers n such that n! contains every digit at least once.
; 23,27,31,33,34,35,36,37,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101
mov $2,$0
mul $0,3
lpb $0
mov $4,$0
sub $4,18
mov $1,$4
trn $4,15
sub $4,$1
add $4,$0
add $4,2
trn $0,$4
add $3,$0
add $3,34
add $6,2
add $6,$3
div $6,5
add $5,$6
mov $0,$5
lpe
mov $1,$0
add $1,23
add $1,$2
| 20.076923 | 213 | 0.586207 |
f113ba22efbcb311b6266a20c855a34776694a50 | 90 | asm | Assembly | libsrc/_DEVELOPMENT/math/float/math48/lm/c/sccz80/dne.asm | meesokim/z88dk | 5763c7778f19a71d936b3200374059d267066bb2 | [
"ClArtistic"
] | null | null | null | libsrc/_DEVELOPMENT/math/float/math48/lm/c/sccz80/dne.asm | meesokim/z88dk | 5763c7778f19a71d936b3200374059d267066bb2 | [
"ClArtistic"
] | null | null | null | libsrc/_DEVELOPMENT/math/float/math48/lm/c/sccz80/dne.asm | meesokim/z88dk | 5763c7778f19a71d936b3200374059d267066bb2 | [
"ClArtistic"
] | null | null | null |
SECTION code_fp_math48
PUBLIC dne
EXTERN cm48_sccz80p_dne
defc dne = cm48_sccz80p_dne
| 10 | 27 | 0.833333 |
5cbebb8436402e84011fe180c768476edb2ced8a | 1,882 | asm | Assembly | MakeOsMyself/day01/hello_os.asm | tomoyuki-nakabayashi/MyPlayGround | 58719b581d4479511b42dff1516afc3b3af286aa | [
"Apache-2.0"
] | null | null | null | MakeOsMyself/day01/hello_os.asm | tomoyuki-nakabayashi/MyPlayGround | 58719b581d4479511b42dff1516afc3b3af286aa | [
"Apache-2.0"
] | 13 | 2018-05-12T00:53:08.000Z | 2018-11-22T03:00:16.000Z | MakeOsMyself/day01/hello_os.asm | tomoyuki-nakabayashi/MyPlayGround | 58719b581d4479511b42dff1516afc3b3af286aa | [
"Apache-2.0"
] | null | null | null | ; hello-os
; TAB=4
DB 0xeb, 0x4e, 0x90
DB "HELLOIPL" ; ブートセレクタの名前を自由にかいていよい (8Byte)
DW 512 ; 1セクタの大きさ (512にしなければならない)
DB 1 ; クラスタの大きさ (1セクタにしなければならない)
DW 1 ; FATがどこから始まるか (普通は1セクタ目からにする)
DB 2 ; FATの個数 (2にしなければならない)
DW 224 ; ルートディレクトリ領域の大きさ (普通は224エントリにする)
DW 2880 ; このドライブの大きさ (2880セクタにしなければならない)
DB 0xf0 ; メディアタイプ (0xf0にしなければならない)
DW 9 ; FAT領域の長さ (9セクタにしなければならない)
DW 18 ; 1トラックにいくつのセクタがあるか (18にしなければならない)
DW 2 ; ヘッドの数 (2にしなければならない)
DD 0 ; パーティションを使っていないのでここは必ず0
DD 2880 ; このドライブの大きさをもう一度書く
DB 0, 0, 0x29 ; よくわからないけどこの値にしておくといいらしい
DD 0xffffffff ; たぶんボリュームシリアル番号
DB "HELLO-OS " ; ディスクの名前 (11Byte)
DB "FAT12 " ; フォーマットの名前 (8Byte)
RESB 18 ; とりあえず18バイト開けておく`
; Program Main Body
DB 0xb8, 0x00, 0x00, 0x8e, 0xd0, 0xbc, 0x00, 0x7c
DB 0x8e, 0xd8, 0x8e, 0xc0, 0xbe, 0x74, 0x7c, 0x8a
DB 0x04, 0x83, 0xc6, 0x01, 0x3c, 0x00, 0x74, 0x09
db 0xb4, 0x0e, 0xbb, 0x0f, 0x00, 0xcd, 0x10, 0xeb
db 0xee, 0xf4, 0xeb, 0xfd
; Message
db 0x0a, 0x0a
db "hello, world"
db 0x0a
db 0
resb 0x1fe-($-$$)
db 0x55, 0xaa
; ブート以外の記述
db 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
resb 4600
db 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
resb 1469432
| 38.408163 | 83 | 0.435175 |
aa0800026d12f2f4f4c575fee014d18cbcf2ec5b | 198 | asm | Assembly | examples/mix-c-asm/sources/mynum-stm8.asm | JohnHau/cmake-tutorial | 7ba24e39927fd506ba65fe5387e0b847906030cd | [
"MIT"
] | 14 | 2021-11-12T05:30:26.000Z | 2022-03-24T07:03:18.000Z | examples/mix-c-asm/sources/mynum-stm8.asm | JohnHau/cmake-tutorial | 7ba24e39927fd506ba65fe5387e0b847906030cd | [
"MIT"
] | 3 | 2021-10-21T03:13:51.000Z | 2022-02-14T15:45:25.000Z | examples/mix-c-asm/sources/mynum-stm8.asm | JohnHau/cmake-tutorial | 7ba24e39927fd506ba65fe5387e0b847906030cd | [
"MIT"
] | 4 | 2021-11-05T09:40:17.000Z | 2022-03-27T12:11:02.000Z | PUBLIC mynum
SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
CODE
mynum:
LDW X, #0x2a
RET
SECTION VREGS:DATA:REORDER:NOROOT(0)
END
| 15.230769 | 56 | 0.515152 |
fbcc5ea3ea4b62e98bf50dfa0cdb9fa360868c00 | 63,956 | asm | Assembly | prog3.asm | mmend175/xv6_OS | 9f446f254ef3bc85800c5daafbb92fb19011cb31 | [
"MIT-0"
] | null | null | null | prog3.asm | mmend175/xv6_OS | 9f446f254ef3bc85800c5daafbb92fb19011cb31 | [
"MIT-0"
] | null | null | null | prog3.asm | mmend175/xv6_OS | 9f446f254ef3bc85800c5daafbb92fb19011cb31 | [
"MIT-0"
] | null | null | null |
_prog3: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
struct lock_t *lock;
extern struct lock_t *lock;
int main (int argc , char * argv [])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 56 push %esi
e: 53 push %ebx
f: 51 push %ecx
10: 83 ec 18 sub $0x18,%esp
13: 8b 59 04 mov 0x4(%ecx),%ebx
numofthread =atoi(argv[1]);// num of threads is decided by the parameter passed by user
16: ff 73 04 pushl 0x4(%ebx)
19: e8 b2 04 00 00 call 4d0 <atoi>
1e: a3 68 0e 00 00 mov %eax,0xe68
passnum = atoi(argv[2]);
23: 58 pop %eax
24: ff 73 08 pushl 0x8(%ebx)
27: e8 a4 04 00 00 call 4d0 <atoi>
2c: a3 64 0e 00 00 mov %eax,0xe64
printf(1,"PARENT PID:%d\n",getpid());
31: e8 8c 05 00 00 call 5c2 <getpid>
36: 83 c4 0c add $0xc,%esp
39: 50 push %eax
3a: 68 1a 0a 00 00 push $0xa1a
3f: 6a 01 push $0x1
41: e8 5a 06 00 00 call 6a0 <printf>
int i = 0 ;
int pid = 0;
lock_init(lock);
46: a1 7c 0e 00 00 mov 0xe7c,%eax
for(i=0;i<numofthread;i++)
4b: 83 c4 10 add $0x10,%esp
};
//this part is for spin lock
void lock_init(struct lock_t *lk)
{
lk -> locked = 0;//initial situation is unlocked
4e: c7 00 00 00 00 00 movl $0x0,(%eax)
54: a1 68 0e 00 00 mov 0xe68,%eax
59: 85 c0 test %eax,%eax
5b: 0f 8e b1 00 00 00 jle 112 <main+0x112>
61: 31 db xor %ebx,%ebx
63: 90 nop
64: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
{
printf(1,"loop start count:%d with main pid: %d\n\n",i,getpid());
68: e8 55 05 00 00 call 5c2 <getpid>
6d: 50 push %eax
6e: 53 push %ebx
6f: 68 a8 0a 00 00 push $0xaa8
74: 6a 01 push $0x1
76: e8 25 06 00 00 call 6a0 <printf>
pid = thread_create(worker,(void *)i);
7b: 5e pop %esi
7c: 58 pop %eax
7d: 53 push %ebx
7e: 68 30 01 00 00 push $0x130
83: e8 e8 01 00 00 call 270 <thread_create>
88: 89 c6 mov %eax,%esi
printf(1,"out of count:%d, with main pid: %d\n",i,getpid());
8a: e8 33 05 00 00 call 5c2 <getpid>
8f: 50 push %eax
90: 53 push %ebx
passnum = atoi(argv[2]);
printf(1,"PARENT PID:%d\n",getpid());
int i = 0 ;
int pid = 0;
lock_init(lock);
for(i=0;i<numofthread;i++)
91: 83 c3 01 add $0x1,%ebx
{
printf(1,"loop start count:%d with main pid: %d\n\n",i,getpid());
pid = thread_create(worker,(void *)i);
printf(1,"out of count:%d, with main pid: %d\n",i,getpid());
94: 68 d0 0a 00 00 push $0xad0
99: 6a 01 push $0x1
9b: e8 00 06 00 00 call 6a0 <printf>
passnum = atoi(argv[2]);
printf(1,"PARENT PID:%d\n",getpid());
int i = 0 ;
int pid = 0;
lock_init(lock);
for(i=0;i<numofthread;i++)
a0: 83 c4 20 add $0x20,%esp
a3: 39 1d 68 0e 00 00 cmp %ebx,0xe68
a9: 7f bd jg 68 <main+0x68>
{
printf(1,"loop start count:%d with main pid: %d\n\n",i,getpid());
pid = thread_create(worker,(void *)i);
printf(1,"out of count:%d, with main pid: %d\n",i,getpid());
}
if(pid >0)
ab: 83 fe 00 cmp $0x0,%esi
ae: 7e 60 jle 110 <main+0x110>
printf(1,"parent's pid num is %d\n",getpid());
b0: e8 0d 05 00 00 call 5c2 <getpid>
b5: 83 ec 04 sub $0x4,%esp
if(pid ==0)
printf(1,"child's pid num is %d\n",getpid());
if (pid > 0) // pid > 0 -> parent
{
for (i = 0; i <numofthread; i++)
b8: 31 db xor %ebx,%ebx
printf(1,"loop start count:%d with main pid: %d\n\n",i,getpid());
pid = thread_create(worker,(void *)i);
printf(1,"out of count:%d, with main pid: %d\n",i,getpid());
}
if(pid >0)
printf(1,"parent's pid num is %d\n",getpid());
ba: 50 push %eax
bb: 68 29 0a 00 00 push $0xa29
c0: 6a 01 push $0x1
c2: e8 d9 05 00 00 call 6a0 <printf>
if(pid ==0)
printf(1,"child's pid num is %d\n",getpid());
if (pid > 0) // pid > 0 -> parent
{
for (i = 0; i <numofthread; i++)
c7: 8b 0d 68 0e 00 00 mov 0xe68,%ecx
cd: 83 c4 10 add $0x10,%esp
d0: 85 c9 test %ecx,%ecx
d2: 7e 27 jle fb <main+0xfb>
d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
{
wait(); //wait each time for each thread created for parent
d8: e8 6d 04 00 00 call 54a <wait>
printf(1,"end of wait!!PID:%d\n",pid);
dd: 83 ec 04 sub $0x4,%esp
if(pid ==0)
printf(1,"child's pid num is %d\n",getpid());
if (pid > 0) // pid > 0 -> parent
{
for (i = 0; i <numofthread; i++)
e0: 83 c3 01 add $0x1,%ebx
{
wait(); //wait each time for each thread created for parent
printf(1,"end of wait!!PID:%d\n",pid);
e3: 56 push %esi
e4: 68 41 0a 00 00 push $0xa41
e9: 6a 01 push $0x1
eb: e8 b0 05 00 00 call 6a0 <printf>
if(pid ==0)
printf(1,"child's pid num is %d\n",getpid());
if (pid > 0) // pid > 0 -> parent
{
for (i = 0; i <numofthread; i++)
f0: 83 c4 10 add $0x10,%esp
f3: 39 1d 68 0e 00 00 cmp %ebx,0xe68
f9: 7f dd jg d8 <main+0xd8>
wait(); //wait each time for each thread created for parent
printf(1,"end of wait!!PID:%d\n",pid);
}
}
printf(1,"end of program!!!PID:%d\n",pid);
fb: 83 ec 04 sub $0x4,%esp
fe: 56 push %esi
ff: 68 56 0a 00 00 push $0xa56
104: 6a 01 push $0x1
106: e8 95 05 00 00 call 6a0 <printf>
exit();
10b: e8 32 04 00 00 call 542 <exit>
pid = thread_create(worker,(void *)i);
printf(1,"out of count:%d, with main pid: %d\n",i,getpid());
}
if(pid >0)
printf(1,"parent's pid num is %d\n",getpid());
if(pid ==0)
110: 75 e9 jne fb <main+0xfb>
printf(1,"child's pid num is %d\n",getpid());
112: e8 ab 04 00 00 call 5c2 <getpid>
117: 52 push %edx
118: 50 push %eax
119: 31 f6 xor %esi,%esi
11b: 68 c0 09 00 00 push $0x9c0
120: 6a 01 push $0x1
122: e8 79 05 00 00 call 6a0 <printf>
127: 83 c4 10 add $0x10,%esp
12a: eb cf jmp fb <main+0xfb>
12c: 66 90 xchg %ax,%ax
12e: 66 90 xchg %ax,%ax
00000130 <worker>:
* if the thread get the lock does not the thread should work
* it will sleep and release the lock
* */
void* worker(void *arg)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 56 push %esi
134: 53 push %ebx
135: 8b 5d 08 mov 0x8(%ebp),%ebx
int pidnum = (int)arg; // pidnum = thread num
printf(1,"child's pid num is %d\n",pidnum);
138: 83 ec 04 sub $0x4,%esp
13b: 53 push %ebx
13c: 68 c0 09 00 00 push $0x9c0
141: 6a 01 push $0x1
143: e8 58 05 00 00 call 6a0 <printf>
while(output<passnum)//when pass time bigger than it should be passed
148: 83 c4 10 add $0x10,%esp
14b: a1 6c 0e 00 00 mov 0xe6c,%eax
150: 39 05 64 0e 00 00 cmp %eax,0xe64
156: 7e 4e jle 1a6 <worker+0x76>
158: be 01 00 00 00 mov $0x1,%esi
15d: 8d 76 00 lea 0x0(%esi),%esi
160: 8b 15 7c 0e 00 00 mov 0xe7c,%edx
166: 8d 76 00 lea 0x0(%esi),%esi
169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
xchg(volatile uint *addr, uint newval)
{
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
170: 89 f0 mov %esi,%eax
172: f0 87 02 lock xchg %eax,(%edx)
}
void lock_acquire(struct lock_t *lk)
{
while(xchg(&lk->locked,1) != 0);
175: 85 c0 test %eax,%eax
177: 75 f7 jne 170 <worker+0x40>
{
if(output==passnum) //stop we are done
break;
lock_acquire(lock);
if(pidnum==workpid) //workpid == current thread that should get the number the fribee toss to it. I.E if current thread 1 -> workpid(thread 2.)
179: 3b 1d 60 0e 00 00 cmp 0xe60,%ebx
17f: 74 3f je 1c0 <worker+0x90>
sleep(1);
}
else
{
sleep(1); //sleep the other thread that should not be working
181: 83 ec 0c sub $0xc,%esp
184: 6a 01 push $0x1
186: e8 47 04 00 00 call 5d2 <sleep>
18b: 83 c4 10 add $0x10,%esp
}
void lock_release(struct lock_t *lock)
{
xchg(&lock->locked,0);
18e: 8b 15 7c 0e 00 00 mov 0xe7c,%edx
194: 31 c0 xor %eax,%eax
196: f0 87 02 lock xchg %eax,(%edx)
void* worker(void *arg)
{
int pidnum = (int)arg; // pidnum = thread num
printf(1,"child's pid num is %d\n",pidnum);
while(output<passnum)//when pass time bigger than it should be passed
199: a1 64 0e 00 00 mov 0xe64,%eax
19e: 39 05 6c 0e 00 00 cmp %eax,0xe6c
1a4: 7c ba jl 160 <worker+0x30>
}
lock_release(lock);
}
printf(1,"time to end: %d\n",pidnum);
1a6: 83 ec 04 sub $0x4,%esp
1a9: 53 push %ebx
1aa: 68 d7 09 00 00 push $0x9d7
1af: 6a 01 push $0x1
1b1: e8 ea 04 00 00 call 6a0 <printf>
return 0;
}
1b6: 8d 65 f8 lea -0x8(%ebp),%esp
1b9: 31 c0 xor %eax,%eax
1bb: 5b pop %ebx
1bc: 5e pop %esi
1bd: 5d pop %ebp
1be: c3 ret
1bf: 90 nop
if(output==passnum) //stop we are done
break;
lock_acquire(lock);
if(pidnum==workpid) //workpid == current thread that should get the number the fribee toss to it. I.E if current thread 1 -> workpid(thread 2.)
{
output++; //used to count the number of passes currently
1c0: a1 6c 0e 00 00 mov 0xe6c,%eax
printf(1,"pass number no: %d, Thread %d is passing the token to ",output,pidnum);
1c5: 53 push %ebx
if(output==passnum) //stop we are done
break;
lock_acquire(lock);
if(pidnum==workpid) //workpid == current thread that should get the number the fribee toss to it. I.E if current thread 1 -> workpid(thread 2.)
{
output++; //used to count the number of passes currently
1c6: 83 c0 01 add $0x1,%eax
printf(1,"pass number no: %d, Thread %d is passing the token to ",output,pidnum);
1c9: 50 push %eax
1ca: 68 70 0a 00 00 push $0xa70
1cf: 6a 01 push $0x1
if(output==passnum) //stop we are done
break;
lock_acquire(lock);
if(pidnum==workpid) //workpid == current thread that should get the number the fribee toss to it. I.E if current thread 1 -> workpid(thread 2.)
{
output++; //used to count the number of passes currently
1d1: a3 6c 0e 00 00 mov %eax,0xe6c
printf(1,"pass number no: %d, Thread %d is passing the token to ",output,pidnum);
1d6: e8 c5 04 00 00 call 6a0 <printf>
workpid++;
1db: a1 60 0e 00 00 mov 0xe60,%eax
if(workpid == numofthread)// because thread num is start from 0
1e0: 83 c4 10 add $0x10,%esp
lock_acquire(lock);
if(pidnum==workpid) //workpid == current thread that should get the number the fribee toss to it. I.E if current thread 1 -> workpid(thread 2.)
{
output++; //used to count the number of passes currently
printf(1,"pass number no: %d, Thread %d is passing the token to ",output,pidnum);
workpid++;
1e3: 83 c0 01 add $0x1,%eax
if(workpid == numofthread)// because thread num is start from 0
1e6: 3b 05 68 0e 00 00 cmp 0xe68,%eax
lock_acquire(lock);
if(pidnum==workpid) //workpid == current thread that should get the number the fribee toss to it. I.E if current thread 1 -> workpid(thread 2.)
{
output++; //used to count the number of passes currently
printf(1,"pass number no: %d, Thread %d is passing the token to ",output,pidnum);
workpid++;
1ec: a3 60 0e 00 00 mov %eax,0xe60
if(workpid == numofthread)// because thread num is start from 0
1f1: 74 24 je 217 <worker+0xe7>
workpid = 0 ;
printf(1," %d\n",workpid);
1f3: 83 ec 04 sub $0x4,%esp
1f6: 50 push %eax
1f7: 68 e3 09 00 00 push $0x9e3
1fc: 6a 01 push $0x1
1fe: e8 9d 04 00 00 call 6a0 <printf>
sleep(1);
203: c7 04 24 01 00 00 00 movl $0x1,(%esp)
20a: e8 c3 03 00 00 call 5d2 <sleep>
20f: 83 c4 10 add $0x10,%esp
212: e9 77 ff ff ff jmp 18e <worker+0x5e>
{
output++; //used to count the number of passes currently
printf(1,"pass number no: %d, Thread %d is passing the token to ",output,pidnum);
workpid++;
if(workpid == numofthread)// because thread num is start from 0
workpid = 0 ;
217: c7 05 60 0e 00 00 00 movl $0x0,0xe60
21e: 00 00 00
221: 31 c0 xor %eax,%eax
223: eb ce jmp 1f3 <worker+0xc3>
225: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000230 <lock_init>:
uint locked;
};
//this part is for spin lock
void lock_init(struct lock_t *lk)
{
230: 55 push %ebp
231: 89 e5 mov %esp,%ebp
lk -> locked = 0;//initial situation is unlocked
233: 8b 45 08 mov 0x8(%ebp),%eax
236: c7 00 00 00 00 00 movl $0x0,(%eax)
}
23c: 5d pop %ebp
23d: c3 ret
23e: 66 90 xchg %ax,%ax
00000240 <lock_acquire>:
void lock_acquire(struct lock_t *lk)
{
240: 55 push %ebp
241: b9 01 00 00 00 mov $0x1,%ecx
246: 89 e5 mov %esp,%ebp
248: 8b 55 08 mov 0x8(%ebp),%edx
24b: 90 nop
24c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
250: 89 c8 mov %ecx,%eax
252: f0 87 02 lock xchg %eax,(%edx)
while(xchg(&lk->locked,1) != 0);
255: 85 c0 test %eax,%eax
257: 75 f7 jne 250 <lock_acquire+0x10>
}
259: 5d pop %ebp
25a: c3 ret
25b: 90 nop
25c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000260 <lock_release>:
void lock_release(struct lock_t *lock)
{
260: 55 push %ebp
261: 31 c0 xor %eax,%eax
263: 89 e5 mov %esp,%ebp
265: 8b 55 08 mov 0x8(%ebp),%edx
268: f0 87 02 lock xchg %eax,(%edx)
xchg(&lock->locked,0);
}
26b: 5d pop %ebp
26c: c3 ret
26d: 8d 76 00 lea 0x0(%esi),%esi
00000270 <thread_create>:
int thread_create(void*(*start_routine)(void*), void *arg)
{
270: 55 push %ebp
271: 89 e5 mov %esp,%ebp
273: 53 push %ebx
274: 83 ec 10 sub $0x10,%esp
void* newp = malloc(2*PGSIZE); //need twice as much to make sure
277: 68 00 20 00 00 push $0x2000
27c: e8 4f 06 00 00 call 8d0 <malloc>
281: 89 c3 mov %eax,%ebx
int rc;
printf(1,"%s :%d\n",__func__, getpid());
283: e8 3a 03 00 00 call 5c2 <getpid>
288: 50 push %eax
289: 68 f4 0a 00 00 push $0xaf4
28e: 68 e8 09 00 00 push $0x9e8
293: 6a 01 push $0x1
295: e8 06 04 00 00 call 6a0 <printf>
rc = clone(newp,2*PGSIZE);
29a: 83 c4 18 add $0x18,%esp
29d: 68 00 20 00 00 push $0x2000
2a2: 53 push %ebx
2a3: e8 4a 03 00 00 call 5f2 <clone>
//clone returns the PID of the child to the parent,
// and 0 to the newly-created child thread
printf(1,"%s,returns PID :%d\n",__func__,rc);
2a8: 50 push %eax
2a9: 68 f4 0a 00 00 push $0xaf4
int thread_create(void*(*start_routine)(void*), void *arg)
{
void* newp = malloc(2*PGSIZE); //need twice as much to make sure
int rc;
printf(1,"%s :%d\n",__func__, getpid());
rc = clone(newp,2*PGSIZE);
2ae: 89 c3 mov %eax,%ebx
//clone returns the PID of the child to the parent,
// and 0 to the newly-created child thread
printf(1,"%s,returns PID :%d\n",__func__,rc);
2b0: 68 f0 09 00 00 push $0x9f0
2b5: 6a 01 push $0x1
2b7: e8 e4 03 00 00 call 6a0 <printf>
if (rc == 0) //child
2bc: 83 c4 20 add $0x20,%esp
2bf: 83 fb 00 cmp $0x0,%ebx
2c2: 74 22 je 2e6 <thread_create+0x76>
{
(*start_routine)(arg);
exit(); //terminate thread
}
else if(rc > 0) //parent
2c4: 7e 07 jle 2cd <thread_create+0x5d>
2c6: 89 d8 mov %ebx,%eax
else
{
printf(2, " OPPS...\n Error \n ");
return -1;
}
}
2c8: 8b 5d fc mov -0x4(%ebp),%ebx
2cb: c9 leave
2cc: c3 ret
}
else if(rc > 0) //parent
return rc;
else
{
printf(2, " OPPS...\n Error \n ");
2cd: 83 ec 08 sub $0x8,%esp
2d0: 68 04 0a 00 00 push $0xa04
2d5: 6a 02 push $0x2
2d7: e8 c4 03 00 00 call 6a0 <printf>
return -1;
2dc: 83 c4 10 add $0x10,%esp
2df: b8 ff ff ff ff mov $0xffffffff,%eax
2e4: eb e2 jmp 2c8 <thread_create+0x58>
//clone returns the PID of the child to the parent,
// and 0 to the newly-created child thread
printf(1,"%s,returns PID :%d\n",__func__,rc);
if (rc == 0) //child
{
(*start_routine)(arg);
2e6: 83 ec 0c sub $0xc,%esp
2e9: ff 75 0c pushl 0xc(%ebp)
2ec: ff 55 08 call *0x8(%ebp)
exit(); //terminate thread
2ef: e8 4e 02 00 00 call 542 <exit>
2f4: 66 90 xchg %ax,%ax
2f6: 66 90 xchg %ax,%ax
2f8: 66 90 xchg %ax,%ax
2fa: 66 90 xchg %ax,%ax
2fc: 66 90 xchg %ax,%ax
2fe: 66 90 xchg %ax,%ax
00000300 <strcpy>:
//}
char*
strcpy(char *s, const char *t)
{
300: 55 push %ebp
301: 89 e5 mov %esp,%ebp
303: 53 push %ebx
304: 8b 45 08 mov 0x8(%ebp),%eax
307: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
30a: 89 c2 mov %eax,%edx
30c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
310: 83 c1 01 add $0x1,%ecx
313: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
317: 83 c2 01 add $0x1,%edx
31a: 84 db test %bl,%bl
31c: 88 5a ff mov %bl,-0x1(%edx)
31f: 75 ef jne 310 <strcpy+0x10>
;
return os;
}
321: 5b pop %ebx
322: 5d pop %ebp
323: c3 ret
324: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
32a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000330 <strcmp>:
int
strcmp(const char *p, const char *q)
{
330: 55 push %ebp
331: 89 e5 mov %esp,%ebp
333: 56 push %esi
334: 53 push %ebx
335: 8b 55 08 mov 0x8(%ebp),%edx
338: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
33b: 0f b6 02 movzbl (%edx),%eax
33e: 0f b6 19 movzbl (%ecx),%ebx
341: 84 c0 test %al,%al
343: 75 1e jne 363 <strcmp+0x33>
345: eb 29 jmp 370 <strcmp+0x40>
347: 89 f6 mov %esi,%esi
349: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
350: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
353: 0f b6 02 movzbl (%edx),%eax
p++, q++;
356: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
359: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
35d: 84 c0 test %al,%al
35f: 74 0f je 370 <strcmp+0x40>
361: 89 f1 mov %esi,%ecx
363: 38 d8 cmp %bl,%al
365: 74 e9 je 350 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
367: 29 d8 sub %ebx,%eax
}
369: 5b pop %ebx
36a: 5e pop %esi
36b: 5d pop %ebp
36c: c3 ret
36d: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
370: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
372: 29 d8 sub %ebx,%eax
}
374: 5b pop %ebx
375: 5e pop %esi
376: 5d pop %ebp
377: c3 ret
378: 90 nop
379: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000380 <strlen>:
uint
strlen(const char *s)
{
380: 55 push %ebp
381: 89 e5 mov %esp,%ebp
383: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
386: 80 39 00 cmpb $0x0,(%ecx)
389: 74 12 je 39d <strlen+0x1d>
38b: 31 d2 xor %edx,%edx
38d: 8d 76 00 lea 0x0(%esi),%esi
390: 83 c2 01 add $0x1,%edx
393: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
397: 89 d0 mov %edx,%eax
399: 75 f5 jne 390 <strlen+0x10>
;
return n;
}
39b: 5d pop %ebp
39c: c3 ret
uint
strlen(const char *s)
{
int n;
for(n = 0; s[n]; n++)
39d: 31 c0 xor %eax,%eax
;
return n;
}
39f: 5d pop %ebp
3a0: c3 ret
3a1: eb 0d jmp 3b0 <memset>
3a3: 90 nop
3a4: 90 nop
3a5: 90 nop
3a6: 90 nop
3a7: 90 nop
3a8: 90 nop
3a9: 90 nop
3aa: 90 nop
3ab: 90 nop
3ac: 90 nop
3ad: 90 nop
3ae: 90 nop
3af: 90 nop
000003b0 <memset>:
void*
memset(void *dst, int c, uint n)
{
3b0: 55 push %ebp
3b1: 89 e5 mov %esp,%ebp
3b3: 57 push %edi
3b4: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
3b7: 8b 4d 10 mov 0x10(%ebp),%ecx
3ba: 8b 45 0c mov 0xc(%ebp),%eax
3bd: 89 d7 mov %edx,%edi
3bf: fc cld
3c0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
3c2: 89 d0 mov %edx,%eax
3c4: 5f pop %edi
3c5: 5d pop %ebp
3c6: c3 ret
3c7: 89 f6 mov %esi,%esi
3c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000003d0 <strchr>:
char*
strchr(const char *s, char c)
{
3d0: 55 push %ebp
3d1: 89 e5 mov %esp,%ebp
3d3: 53 push %ebx
3d4: 8b 45 08 mov 0x8(%ebp),%eax
3d7: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
3da: 0f b6 10 movzbl (%eax),%edx
3dd: 84 d2 test %dl,%dl
3df: 74 1d je 3fe <strchr+0x2e>
if(*s == c)
3e1: 38 d3 cmp %dl,%bl
3e3: 89 d9 mov %ebx,%ecx
3e5: 75 0d jne 3f4 <strchr+0x24>
3e7: eb 17 jmp 400 <strchr+0x30>
3e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
3f0: 38 ca cmp %cl,%dl
3f2: 74 0c je 400 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
3f4: 83 c0 01 add $0x1,%eax
3f7: 0f b6 10 movzbl (%eax),%edx
3fa: 84 d2 test %dl,%dl
3fc: 75 f2 jne 3f0 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
3fe: 31 c0 xor %eax,%eax
}
400: 5b pop %ebx
401: 5d pop %ebp
402: c3 ret
403: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
409: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000410 <gets>:
char*
gets(char *buf, int max)
{
410: 55 push %ebp
411: 89 e5 mov %esp,%ebp
413: 57 push %edi
414: 56 push %esi
415: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
416: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
418: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
41b: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
41e: eb 29 jmp 449 <gets+0x39>
cc = read(0, &c, 1);
420: 83 ec 04 sub $0x4,%esp
423: 6a 01 push $0x1
425: 57 push %edi
426: 6a 00 push $0x0
428: e8 2d 01 00 00 call 55a <read>
if(cc < 1)
42d: 83 c4 10 add $0x10,%esp
430: 85 c0 test %eax,%eax
432: 7e 1d jle 451 <gets+0x41>
break;
buf[i++] = c;
434: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
438: 8b 55 08 mov 0x8(%ebp),%edx
43b: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
43d: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
43f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
443: 74 1b je 460 <gets+0x50>
445: 3c 0d cmp $0xd,%al
447: 74 17 je 460 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
449: 8d 5e 01 lea 0x1(%esi),%ebx
44c: 3b 5d 0c cmp 0xc(%ebp),%ebx
44f: 7c cf jl 420 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
451: 8b 45 08 mov 0x8(%ebp),%eax
454: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
458: 8d 65 f4 lea -0xc(%ebp),%esp
45b: 5b pop %ebx
45c: 5e pop %esi
45d: 5f pop %edi
45e: 5d pop %ebp
45f: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
460: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
463: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
465: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
469: 8d 65 f4 lea -0xc(%ebp),%esp
46c: 5b pop %ebx
46d: 5e pop %esi
46e: 5f pop %edi
46f: 5d pop %ebp
470: c3 ret
471: eb 0d jmp 480 <stat>
473: 90 nop
474: 90 nop
475: 90 nop
476: 90 nop
477: 90 nop
478: 90 nop
479: 90 nop
47a: 90 nop
47b: 90 nop
47c: 90 nop
47d: 90 nop
47e: 90 nop
47f: 90 nop
00000480 <stat>:
int
stat(const char *n, struct stat *st)
{
480: 55 push %ebp
481: 89 e5 mov %esp,%ebp
483: 56 push %esi
484: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
485: 83 ec 08 sub $0x8,%esp
488: 6a 00 push $0x0
48a: ff 75 08 pushl 0x8(%ebp)
48d: e8 f0 00 00 00 call 582 <open>
if(fd < 0)
492: 83 c4 10 add $0x10,%esp
495: 85 c0 test %eax,%eax
497: 78 27 js 4c0 <stat+0x40>
return -1;
r = fstat(fd, st);
499: 83 ec 08 sub $0x8,%esp
49c: ff 75 0c pushl 0xc(%ebp)
49f: 89 c3 mov %eax,%ebx
4a1: 50 push %eax
4a2: e8 f3 00 00 00 call 59a <fstat>
4a7: 89 c6 mov %eax,%esi
close(fd);
4a9: 89 1c 24 mov %ebx,(%esp)
4ac: e8 b9 00 00 00 call 56a <close>
return r;
4b1: 83 c4 10 add $0x10,%esp
4b4: 89 f0 mov %esi,%eax
}
4b6: 8d 65 f8 lea -0x8(%ebp),%esp
4b9: 5b pop %ebx
4ba: 5e pop %esi
4bb: 5d pop %ebp
4bc: c3 ret
4bd: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
4c0: b8 ff ff ff ff mov $0xffffffff,%eax
4c5: eb ef jmp 4b6 <stat+0x36>
4c7: 89 f6 mov %esi,%esi
4c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000004d0 <atoi>:
return r;
}
int
atoi(const char *s)
{
4d0: 55 push %ebp
4d1: 89 e5 mov %esp,%ebp
4d3: 53 push %ebx
4d4: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
4d7: 0f be 11 movsbl (%ecx),%edx
4da: 8d 42 d0 lea -0x30(%edx),%eax
4dd: 3c 09 cmp $0x9,%al
4df: b8 00 00 00 00 mov $0x0,%eax
4e4: 77 1f ja 505 <atoi+0x35>
4e6: 8d 76 00 lea 0x0(%esi),%esi
4e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
4f0: 8d 04 80 lea (%eax,%eax,4),%eax
4f3: 83 c1 01 add $0x1,%ecx
4f6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
4fa: 0f be 11 movsbl (%ecx),%edx
4fd: 8d 5a d0 lea -0x30(%edx),%ebx
500: 80 fb 09 cmp $0x9,%bl
503: 76 eb jbe 4f0 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
505: 5b pop %ebx
506: 5d pop %ebp
507: c3 ret
508: 90 nop
509: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000510 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
510: 55 push %ebp
511: 89 e5 mov %esp,%ebp
513: 56 push %esi
514: 53 push %ebx
515: 8b 5d 10 mov 0x10(%ebp),%ebx
518: 8b 45 08 mov 0x8(%ebp),%eax
51b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
51e: 85 db test %ebx,%ebx
520: 7e 14 jle 536 <memmove+0x26>
522: 31 d2 xor %edx,%edx
524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
528: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
52c: 88 0c 10 mov %cl,(%eax,%edx,1)
52f: 83 c2 01 add $0x1,%edx
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
532: 39 da cmp %ebx,%edx
534: 75 f2 jne 528 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
536: 5b pop %ebx
537: 5e pop %esi
538: 5d pop %ebp
539: c3 ret
0000053a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
53a: b8 01 00 00 00 mov $0x1,%eax
53f: cd 40 int $0x40
541: c3 ret
00000542 <exit>:
SYSCALL(exit)
542: b8 02 00 00 00 mov $0x2,%eax
547: cd 40 int $0x40
549: c3 ret
0000054a <wait>:
SYSCALL(wait)
54a: b8 03 00 00 00 mov $0x3,%eax
54f: cd 40 int $0x40
551: c3 ret
00000552 <pipe>:
SYSCALL(pipe)
552: b8 04 00 00 00 mov $0x4,%eax
557: cd 40 int $0x40
559: c3 ret
0000055a <read>:
SYSCALL(read)
55a: b8 05 00 00 00 mov $0x5,%eax
55f: cd 40 int $0x40
561: c3 ret
00000562 <write>:
SYSCALL(write)
562: b8 10 00 00 00 mov $0x10,%eax
567: cd 40 int $0x40
569: c3 ret
0000056a <close>:
SYSCALL(close)
56a: b8 15 00 00 00 mov $0x15,%eax
56f: cd 40 int $0x40
571: c3 ret
00000572 <kill>:
SYSCALL(kill)
572: b8 06 00 00 00 mov $0x6,%eax
577: cd 40 int $0x40
579: c3 ret
0000057a <exec>:
SYSCALL(exec)
57a: b8 07 00 00 00 mov $0x7,%eax
57f: cd 40 int $0x40
581: c3 ret
00000582 <open>:
SYSCALL(open)
582: b8 0f 00 00 00 mov $0xf,%eax
587: cd 40 int $0x40
589: c3 ret
0000058a <mknod>:
SYSCALL(mknod)
58a: b8 11 00 00 00 mov $0x11,%eax
58f: cd 40 int $0x40
591: c3 ret
00000592 <unlink>:
SYSCALL(unlink)
592: b8 12 00 00 00 mov $0x12,%eax
597: cd 40 int $0x40
599: c3 ret
0000059a <fstat>:
SYSCALL(fstat)
59a: b8 08 00 00 00 mov $0x8,%eax
59f: cd 40 int $0x40
5a1: c3 ret
000005a2 <link>:
SYSCALL(link)
5a2: b8 13 00 00 00 mov $0x13,%eax
5a7: cd 40 int $0x40
5a9: c3 ret
000005aa <mkdir>:
SYSCALL(mkdir)
5aa: b8 14 00 00 00 mov $0x14,%eax
5af: cd 40 int $0x40
5b1: c3 ret
000005b2 <chdir>:
SYSCALL(chdir)
5b2: b8 09 00 00 00 mov $0x9,%eax
5b7: cd 40 int $0x40
5b9: c3 ret
000005ba <dup>:
SYSCALL(dup)
5ba: b8 0a 00 00 00 mov $0xa,%eax
5bf: cd 40 int $0x40
5c1: c3 ret
000005c2 <getpid>:
SYSCALL(getpid)
5c2: b8 0b 00 00 00 mov $0xb,%eax
5c7: cd 40 int $0x40
5c9: c3 ret
000005ca <sbrk>:
SYSCALL(sbrk)
5ca: b8 0c 00 00 00 mov $0xc,%eax
5cf: cd 40 int $0x40
5d1: c3 ret
000005d2 <sleep>:
SYSCALL(sleep)
5d2: b8 0d 00 00 00 mov $0xd,%eax
5d7: cd 40 int $0x40
5d9: c3 ret
000005da <uptime>:
SYSCALL(uptime)
5da: b8 0e 00 00 00 mov $0xe,%eax
5df: cd 40 int $0x40
5e1: c3 ret
000005e2 <info>:
SYSCALL(info) // LAB-1
5e2: b8 16 00 00 00 mov $0x16,%eax
5e7: cd 40 int $0x40
5e9: c3 ret
000005ea <tickets>:
SYSCALL(tickets) // LAB-2
5ea: b8 17 00 00 00 mov $0x17,%eax
5ef: cd 40 int $0x40
5f1: c3 ret
000005f2 <clone>:
SYSCALL(clone) // LAB-3
5f2: b8 18 00 00 00 mov $0x18,%eax
5f7: cd 40 int $0x40
5f9: c3 ret
5fa: 66 90 xchg %ax,%ax
5fc: 66 90 xchg %ax,%ax
5fe: 66 90 xchg %ax,%ax
00000600 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
600: 55 push %ebp
601: 89 e5 mov %esp,%ebp
603: 57 push %edi
604: 56 push %esi
605: 53 push %ebx
606: 89 c6 mov %eax,%esi
608: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
60b: 8b 5d 08 mov 0x8(%ebp),%ebx
60e: 85 db test %ebx,%ebx
610: 74 7e je 690 <printint+0x90>
612: 89 d0 mov %edx,%eax
614: c1 e8 1f shr $0x1f,%eax
617: 84 c0 test %al,%al
619: 74 75 je 690 <printint+0x90>
neg = 1;
x = -xx;
61b: 89 d0 mov %edx,%eax
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
61d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
x = -xx;
624: f7 d8 neg %eax
626: 89 75 c0 mov %esi,-0x40(%ebp)
} else {
x = xx;
}
i = 0;
629: 31 ff xor %edi,%edi
62b: 8d 5d d7 lea -0x29(%ebp),%ebx
62e: 89 ce mov %ecx,%esi
630: eb 08 jmp 63a <printint+0x3a>
632: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
638: 89 cf mov %ecx,%edi
63a: 31 d2 xor %edx,%edx
63c: 8d 4f 01 lea 0x1(%edi),%ecx
63f: f7 f6 div %esi
641: 0f b6 92 0c 0b 00 00 movzbl 0xb0c(%edx),%edx
}while((x /= base) != 0);
648: 85 c0 test %eax,%eax
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
64a: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
64d: 75 e9 jne 638 <printint+0x38>
if(neg)
64f: 8b 45 c4 mov -0x3c(%ebp),%eax
652: 8b 75 c0 mov -0x40(%ebp),%esi
655: 85 c0 test %eax,%eax
657: 74 08 je 661 <printint+0x61>
buf[i++] = '-';
659: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1)
65e: 8d 4f 02 lea 0x2(%edi),%ecx
661: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi
665: 8d 76 00 lea 0x0(%esi),%esi
668: 0f b6 07 movzbl (%edi),%eax
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
66b: 83 ec 04 sub $0x4,%esp
66e: 83 ef 01 sub $0x1,%edi
671: 6a 01 push $0x1
673: 53 push %ebx
674: 56 push %esi
675: 88 45 d7 mov %al,-0x29(%ebp)
678: e8 e5 fe ff ff call 562 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
67d: 83 c4 10 add $0x10,%esp
680: 39 df cmp %ebx,%edi
682: 75 e4 jne 668 <printint+0x68>
putc(fd, buf[i]);
}
684: 8d 65 f4 lea -0xc(%ebp),%esp
687: 5b pop %ebx
688: 5e pop %esi
689: 5f pop %edi
68a: 5d pop %ebp
68b: c3 ret
68c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
} else {
x = xx;
690: 89 d0 mov %edx,%eax
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
692: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
699: eb 8b jmp 626 <printint+0x26>
69b: 90 nop
69c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000006a0 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
6a0: 55 push %ebp
6a1: 89 e5 mov %esp,%ebp
6a3: 57 push %edi
6a4: 56 push %esi
6a5: 53 push %ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6a6: 8d 45 10 lea 0x10(%ebp),%eax
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
6a9: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6ac: 8b 75 0c mov 0xc(%ebp),%esi
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
6af: 8b 7d 08 mov 0x8(%ebp),%edi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6b2: 89 45 d0 mov %eax,-0x30(%ebp)
6b5: 0f b6 1e movzbl (%esi),%ebx
6b8: 83 c6 01 add $0x1,%esi
6bb: 84 db test %bl,%bl
6bd: 0f 84 b0 00 00 00 je 773 <printf+0xd3>
6c3: 31 d2 xor %edx,%edx
6c5: eb 39 jmp 700 <printf+0x60>
6c7: 89 f6 mov %esi,%esi
6c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
6d0: 83 f8 25 cmp $0x25,%eax
6d3: 89 55 d4 mov %edx,-0x2c(%ebp)
state = '%';
6d6: ba 25 00 00 00 mov $0x25,%edx
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
6db: 74 18 je 6f5 <printf+0x55>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
6dd: 8d 45 e2 lea -0x1e(%ebp),%eax
6e0: 83 ec 04 sub $0x4,%esp
6e3: 88 5d e2 mov %bl,-0x1e(%ebp)
6e6: 6a 01 push $0x1
6e8: 50 push %eax
6e9: 57 push %edi
6ea: e8 73 fe ff ff call 562 <write>
6ef: 8b 55 d4 mov -0x2c(%ebp),%edx
6f2: 83 c4 10 add $0x10,%esp
6f5: 83 c6 01 add $0x1,%esi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6f8: 0f b6 5e ff movzbl -0x1(%esi),%ebx
6fc: 84 db test %bl,%bl
6fe: 74 73 je 773 <printf+0xd3>
c = fmt[i] & 0xff;
if(state == 0){
700: 85 d2 test %edx,%edx
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
702: 0f be cb movsbl %bl,%ecx
705: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
708: 74 c6 je 6d0 <printf+0x30>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
70a: 83 fa 25 cmp $0x25,%edx
70d: 75 e6 jne 6f5 <printf+0x55>
if(c == 'd'){
70f: 83 f8 64 cmp $0x64,%eax
712: 0f 84 f8 00 00 00 je 810 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
718: 81 e1 f7 00 00 00 and $0xf7,%ecx
71e: 83 f9 70 cmp $0x70,%ecx
721: 74 5d je 780 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
723: 83 f8 73 cmp $0x73,%eax
726: 0f 84 84 00 00 00 je 7b0 <printf+0x110>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
72c: 83 f8 63 cmp $0x63,%eax
72f: 0f 84 ea 00 00 00 je 81f <printf+0x17f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
735: 83 f8 25 cmp $0x25,%eax
738: 0f 84 c2 00 00 00 je 800 <printf+0x160>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
73e: 8d 45 e7 lea -0x19(%ebp),%eax
741: 83 ec 04 sub $0x4,%esp
744: c6 45 e7 25 movb $0x25,-0x19(%ebp)
748: 6a 01 push $0x1
74a: 50 push %eax
74b: 57 push %edi
74c: e8 11 fe ff ff call 562 <write>
751: 83 c4 0c add $0xc,%esp
754: 8d 45 e6 lea -0x1a(%ebp),%eax
757: 88 5d e6 mov %bl,-0x1a(%ebp)
75a: 6a 01 push $0x1
75c: 50 push %eax
75d: 57 push %edi
75e: 83 c6 01 add $0x1,%esi
761: e8 fc fd ff ff call 562 <write>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
766: 0f b6 5e ff movzbl -0x1(%esi),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
76a: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
76d: 31 d2 xor %edx,%edx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
76f: 84 db test %bl,%bl
771: 75 8d jne 700 <printf+0x60>
putc(fd, c);
}
state = 0;
}
}
}
773: 8d 65 f4 lea -0xc(%ebp),%esp
776: 5b pop %ebx
777: 5e pop %esi
778: 5f pop %edi
779: 5d pop %ebp
77a: c3 ret
77b: 90 nop
77c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
780: 83 ec 0c sub $0xc,%esp
783: b9 10 00 00 00 mov $0x10,%ecx
788: 6a 00 push $0x0
78a: 8b 5d d0 mov -0x30(%ebp),%ebx
78d: 89 f8 mov %edi,%eax
78f: 8b 13 mov (%ebx),%edx
791: e8 6a fe ff ff call 600 <printint>
ap++;
796: 89 d8 mov %ebx,%eax
798: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
79b: 31 d2 xor %edx,%edx
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
79d: 83 c0 04 add $0x4,%eax
7a0: 89 45 d0 mov %eax,-0x30(%ebp)
7a3: e9 4d ff ff ff jmp 6f5 <printf+0x55>
7a8: 90 nop
7a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else if(c == 's'){
s = (char*)*ap;
7b0: 8b 45 d0 mov -0x30(%ebp),%eax
7b3: 8b 18 mov (%eax),%ebx
ap++;
7b5: 83 c0 04 add $0x4,%eax
7b8: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
s = "(null)";
7bb: b8 02 0b 00 00 mov $0xb02,%eax
7c0: 85 db test %ebx,%ebx
7c2: 0f 44 d8 cmove %eax,%ebx
while(*s != 0){
7c5: 0f b6 03 movzbl (%ebx),%eax
7c8: 84 c0 test %al,%al
7ca: 74 23 je 7ef <printf+0x14f>
7cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
7d0: 88 45 e3 mov %al,-0x1d(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
7d3: 8d 45 e3 lea -0x1d(%ebp),%eax
7d6: 83 ec 04 sub $0x4,%esp
7d9: 6a 01 push $0x1
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
7db: 83 c3 01 add $0x1,%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
7de: 50 push %eax
7df: 57 push %edi
7e0: e8 7d fd ff ff call 562 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
7e5: 0f b6 03 movzbl (%ebx),%eax
7e8: 83 c4 10 add $0x10,%esp
7eb: 84 c0 test %al,%al
7ed: 75 e1 jne 7d0 <printf+0x130>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
7ef: 31 d2 xor %edx,%edx
7f1: e9 ff fe ff ff jmp 6f5 <printf+0x55>
7f6: 8d 76 00 lea 0x0(%esi),%esi
7f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
800: 83 ec 04 sub $0x4,%esp
803: 88 5d e5 mov %bl,-0x1b(%ebp)
806: 8d 45 e5 lea -0x1b(%ebp),%eax
809: 6a 01 push $0x1
80b: e9 4c ff ff ff jmp 75c <printf+0xbc>
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
810: 83 ec 0c sub $0xc,%esp
813: b9 0a 00 00 00 mov $0xa,%ecx
818: 6a 01 push $0x1
81a: e9 6b ff ff ff jmp 78a <printf+0xea>
81f: 8b 5d d0 mov -0x30(%ebp),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
822: 83 ec 04 sub $0x4,%esp
825: 8b 03 mov (%ebx),%eax
827: 6a 01 push $0x1
829: 88 45 e4 mov %al,-0x1c(%ebp)
82c: 8d 45 e4 lea -0x1c(%ebp),%eax
82f: 50 push %eax
830: 57 push %edi
831: e8 2c fd ff ff call 562 <write>
836: e9 5b ff ff ff jmp 796 <printf+0xf6>
83b: 66 90 xchg %ax,%ax
83d: 66 90 xchg %ax,%ax
83f: 90 nop
00000840 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
840: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
841: a1 70 0e 00 00 mov 0xe70,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
846: 89 e5 mov %esp,%ebp
848: 57 push %edi
849: 56 push %esi
84a: 53 push %ebx
84b: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
84e: 8b 10 mov (%eax),%edx
void
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
850: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
853: 39 c8 cmp %ecx,%eax
855: 73 19 jae 870 <free+0x30>
857: 89 f6 mov %esi,%esi
859: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
860: 39 d1 cmp %edx,%ecx
862: 72 1c jb 880 <free+0x40>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
864: 39 d0 cmp %edx,%eax
866: 73 18 jae 880 <free+0x40>
static Header base;
static Header *freep;
void
free(void *ap)
{
868: 89 d0 mov %edx,%eax
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
86a: 39 c8 cmp %ecx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
86c: 8b 10 mov (%eax),%edx
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
86e: 72 f0 jb 860 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
870: 39 d0 cmp %edx,%eax
872: 72 f4 jb 868 <free+0x28>
874: 39 d1 cmp %edx,%ecx
876: 73 f0 jae 868 <free+0x28>
878: 90 nop
879: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
break;
if(bp + bp->s.size == p->s.ptr){
880: 8b 73 fc mov -0x4(%ebx),%esi
883: 8d 3c f1 lea (%ecx,%esi,8),%edi
886: 39 d7 cmp %edx,%edi
888: 74 19 je 8a3 <free+0x63>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
88a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
88d: 8b 50 04 mov 0x4(%eax),%edx
890: 8d 34 d0 lea (%eax,%edx,8),%esi
893: 39 f1 cmp %esi,%ecx
895: 74 23 je 8ba <free+0x7a>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
897: 89 08 mov %ecx,(%eax)
freep = p;
899: a3 70 0e 00 00 mov %eax,0xe70
}
89e: 5b pop %ebx
89f: 5e pop %esi
8a0: 5f pop %edi
8a1: 5d pop %ebp
8a2: c3 ret
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
8a3: 03 72 04 add 0x4(%edx),%esi
8a6: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
8a9: 8b 10 mov (%eax),%edx
8ab: 8b 12 mov (%edx),%edx
8ad: 89 53 f8 mov %edx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
8b0: 8b 50 04 mov 0x4(%eax),%edx
8b3: 8d 34 d0 lea (%eax,%edx,8),%esi
8b6: 39 f1 cmp %esi,%ecx
8b8: 75 dd jne 897 <free+0x57>
p->s.size += bp->s.size;
8ba: 03 53 fc add -0x4(%ebx),%edx
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
8bd: a3 70 0e 00 00 mov %eax,0xe70
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
8c2: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
8c5: 8b 53 f8 mov -0x8(%ebx),%edx
8c8: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
}
8ca: 5b pop %ebx
8cb: 5e pop %esi
8cc: 5f pop %edi
8cd: 5d pop %ebp
8ce: c3 ret
8cf: 90 nop
000008d0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
8d0: 55 push %ebp
8d1: 89 e5 mov %esp,%ebp
8d3: 57 push %edi
8d4: 56 push %esi
8d5: 53 push %ebx
8d6: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
8d9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
8dc: 8b 15 70 0e 00 00 mov 0xe70,%edx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
8e2: 8d 78 07 lea 0x7(%eax),%edi
8e5: c1 ef 03 shr $0x3,%edi
8e8: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
8eb: 85 d2 test %edx,%edx
8ed: 0f 84 a3 00 00 00 je 996 <malloc+0xc6>
8f3: 8b 02 mov (%edx),%eax
8f5: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
8f8: 39 cf cmp %ecx,%edi
8fa: 76 74 jbe 970 <malloc+0xa0>
8fc: 81 ff 00 10 00 00 cmp $0x1000,%edi
902: be 00 10 00 00 mov $0x1000,%esi
907: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx
90e: 0f 43 f7 cmovae %edi,%esi
911: ba 00 80 00 00 mov $0x8000,%edx
916: 81 ff ff 0f 00 00 cmp $0xfff,%edi
91c: 0f 46 da cmovbe %edx,%ebx
91f: eb 10 jmp 931 <malloc+0x61>
921: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
928: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
92a: 8b 48 04 mov 0x4(%eax),%ecx
92d: 39 cf cmp %ecx,%edi
92f: 76 3f jbe 970 <malloc+0xa0>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
931: 39 05 70 0e 00 00 cmp %eax,0xe70
937: 89 c2 mov %eax,%edx
939: 75 ed jne 928 <malloc+0x58>
char *p;
Header *hp;
if(nu < 4096)
nu = 4096;
p = sbrk(nu * sizeof(Header));
93b: 83 ec 0c sub $0xc,%esp
93e: 53 push %ebx
93f: e8 86 fc ff ff call 5ca <sbrk>
if(p == (char*)-1)
944: 83 c4 10 add $0x10,%esp
947: 83 f8 ff cmp $0xffffffff,%eax
94a: 74 1c je 968 <malloc+0x98>
return 0;
hp = (Header*)p;
hp->s.size = nu;
94c: 89 70 04 mov %esi,0x4(%eax)
free((void*)(hp + 1));
94f: 83 ec 0c sub $0xc,%esp
952: 83 c0 08 add $0x8,%eax
955: 50 push %eax
956: e8 e5 fe ff ff call 840 <free>
return freep;
95b: 8b 15 70 0e 00 00 mov 0xe70,%edx
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
961: 83 c4 10 add $0x10,%esp
964: 85 d2 test %edx,%edx
966: 75 c0 jne 928 <malloc+0x58>
return 0;
968: 31 c0 xor %eax,%eax
96a: eb 1c jmp 988 <malloc+0xb8>
96c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
970: 39 cf cmp %ecx,%edi
972: 74 1c je 990 <malloc+0xc0>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
974: 29 f9 sub %edi,%ecx
976: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
979: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
97c: 89 78 04 mov %edi,0x4(%eax)
}
freep = prevp;
97f: 89 15 70 0e 00 00 mov %edx,0xe70
return (void*)(p + 1);
985: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
988: 8d 65 f4 lea -0xc(%ebp),%esp
98b: 5b pop %ebx
98c: 5e pop %esi
98d: 5f pop %edi
98e: 5d pop %ebp
98f: c3 ret
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
prevp->s.ptr = p->s.ptr;
990: 8b 08 mov (%eax),%ecx
992: 89 0a mov %ecx,(%edx)
994: eb e9 jmp 97f <malloc+0xaf>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
996: c7 05 70 0e 00 00 74 movl $0xe74,0xe70
99d: 0e 00 00
9a0: c7 05 74 0e 00 00 74 movl $0xe74,0xe74
9a7: 0e 00 00
base.s.size = 0;
9aa: b8 74 0e 00 00 mov $0xe74,%eax
9af: c7 05 78 0e 00 00 00 movl $0x0,0xe78
9b6: 00 00 00
9b9: e9 3e ff ff ff jmp 8fc <malloc+0x2c>
| 32.764344 | 159 | 0.428263 |
d5ea714ca5a59dc8a07416b7e683a11e7aeb3486 | 225 | asm | Assembly | libsrc/strings/strrchr.asm | andydansby/z88dk-mk2 | 51c15f1387293809c496f5eaf7b196f8a0e9b66b | [
"ClArtistic"
] | 1 | 2020-09-15T08:35:49.000Z | 2020-09-15T08:35:49.000Z | libsrc/strings/strrchr.asm | dex4er/deb-z88dk | 9ee4f23444fa6f6043462332a1bff7ae20a8504b | [
"ClArtistic"
] | null | null | null | libsrc/strings/strrchr.asm | dex4er/deb-z88dk | 9ee4f23444fa6f6043462332a1bff7ae20a8504b | [
"ClArtistic"
] | null | null | null | ; CALLER linkage for function pointers
XLIB strrchr
LIB strrchr_callee
XREF ASMDISP_STRRCHR_CALLEE
.strrchr
pop hl
pop bc
pop de
push de
push bc
push hl
jp strrchr_callee + ASMDISP_STRRCHR_CALLEE
| 12.5 | 45 | 0.728889 |
4a84bfcc319593de95d2f3c75ce53a552e16cd21 | 746 | asm | Assembly | Computer Organization and Architecture/Assignments/calltest.asm | MekAkUActOR/Ugrad_Projects | bf74d37d4f86d4d43f971ba3712821d8a3ea9772 | [
"MIT"
] | null | null | null | Computer Organization and Architecture/Assignments/calltest.asm | MekAkUActOR/Ugrad_Projects | bf74d37d4f86d4d43f971ba3712821d8a3ea9772 | [
"MIT"
] | null | null | null | Computer Organization and Architecture/Assignments/calltest.asm | MekAkUActOR/Ugrad_Projects | bf74d37d4f86d4d43f971ba3712821d8a3ea9772 | [
"MIT"
] | null | null | null | ;an x86 assembly language program: call a function
data_seg segment
C DW 0H
ends
stack_seg segment
ST DB 100DUP(0)
TOP EQU 100
ends
code_seg segment
assume cs:code_seg, ds:data_seg, ss:stack_seg
start:
MOV AX, data_seg
MOV DS, AX
MOV AX, stack_seg
MOV SS, AX
MOV SP, TOP
MOV BX, 5
PUSH 9
PUSH 7
CALL compute
ADD BX, AX
MOV C, BX
mov ax, 4c00h
int 21h
compute proc near
PUSH BX
PUSH DX
PUSH SI
MOV SI, SP
MOV AX, SS:[SI + 10]
MOV BX, 10
MUL BX
ADD AX, SS:[SI + 8]
POP SI
POP DX
POP BX
RET
compute endp
ends
end start
| 15.541667 | 51 | 0.510724 |
8962793815545972e3555365922a8f12b7248c50 | 2,894 | asm | Assembly | src/third_party/red_tamarin_stable/tamarin-cental/platform/win32/win64setjmp.asm | michaelpdu/flash_feature_extraction | 29226a4c0e81240fd5c53fd9c80b0f6b0f5a8f95 | [
"Apache-2.0"
] | 1 | 2018-11-25T01:05:03.000Z | 2018-11-25T01:05:03.000Z | avmplus/platform/win32/win64setjmp.asm | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | null | null | null | avmplus/platform/win32/win64setjmp.asm | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | 1 | 2019-04-12T04:18:27.000Z | 2019-04-12T04:18:27.000Z | ; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
PUBLIC longjmp64
PUBLIC _setjmp3
PUBLIC modInternal
.data?
.code
_setjmp3 : ; proc jmp_buf : qword arg : qword
; RCX = jmp_buf structure
; RDX = addr to jump back to
mov qword ptr [rcx],rdx
mov qword ptr [rcx+8],rbx
mov qword ptr [rcx+18h],rbp
mov qword ptr [rcx+20h],rsi
mov qword ptr [rcx+28h],rdi
mov qword ptr [rcx+30h],r12
mov qword ptr [rcx+38h],r13
mov qword ptr [rcx+40h],r14
mov qword ptr [rcx+48h],r15
lea r8,[rsp+8]
mov qword ptr [rcx+10h],r8
mov r8,qword ptr [rsp]
mov qword ptr [rcx+50h],r8
stmxcsr dword ptr [rcx+58h]
fnstcw word ptr [rcx+5Ch]
movdqu xmmword ptr [rcx+60h],xmm6
movdqu xmmword ptr [rcx+70h],xmm7
movdqu xmmword ptr [rcx+80h],xmm8
movdqu xmmword ptr [rcx+90h],xmm9
movdqu xmmword ptr [rcx+0A0h],xmm10
movdqu xmmword ptr [rcx+0B0h],xmm11
movdqu xmmword ptr [rcx+0C0h],xmm12
movdqu xmmword ptr [rcx+0D0h],xmm13
movdqu xmmword ptr [rcx+0E0h],xmm14
movdqu xmmword ptr [rcx+0F0h],xmm15
xor eax,eax
ret
longjmp64: ; proc jmp_buf : qword result qword)
mov rax,rdx
mov rbx,qword ptr [rcx+8]
; rsp see below
; rbp see below
mov rsi,qword ptr [rcx+20h]
mov rdi,qword ptr [rcx+28h]
mov r12,qword ptr [rcx+30h]
mov r13,qword ptr [rcx+38h]
mov r14,qword ptr [rcx+40h]
mov r15,qword ptr [rcx+48h]
; rip see below
ldmxcsr dword ptr [rcx+58h] ; spare?
fnclex
fldcw word ptr [rcx+5Ch]
movdqu xmm6,xmmword ptr [rcx+60h]
movdqu xmm7,xmmword ptr [rcx+70h]
movdqu xmm8,xmmword ptr [rcx+80h]
movdqu xmm9,xmmword ptr [rcx+90h]
movdqu xmm10,xmmword ptr [rcx+0A0h]
movdqu xmm11,xmmword ptr [rcx+0B0h]
movdqu xmm12,xmmword ptr [rcx+0C0h]
movdqu xmm13,xmmword ptr [rcx+0D0h]
movdqu xmm14,xmmword ptr [rcx+0E0h]
movdqu xmm15,xmmword ptr [rcx+0F0h]
mov rdx,qword ptr [rcx+50h] ; rip
mov rbp,qword ptr [rcx+18h]
mov rsp,qword ptr [rcx+10h]
jmp rdx
modInternal:
emms
sub rsp,28h
movsd mmword ptr [rsp+10h],xmm1
movsd mmword ptr [rsp+20h],xmm0
fld qword ptr [rsp+10h]
fld qword ptr [rsp+20h]
ModLoop:
fprem
wait
fnstsw ax
test ax,400h
jne ModLoop
fstp qword ptr [rsp]
movlpd xmm0,qword ptr [rsp]
add rsp,28h
ret
END | 26.309091 | 69 | 0.566344 |
ec1fcb508596bc4dd060ad5543c6e0224b32662b | 145 | asm | Assembly | src/src/c/borlandc/dpmi32/parsfnm.asm | amindlost/wdosx | 1e256d22c1547e7b1f1ccd23e400f5b81b8bd013 | [
"Unlicense"
] | 7 | 2022-01-20T08:27:54.000Z | 2022-03-17T10:15:31.000Z | src/src/c/borlandc/dpmi32/parsfnm.asm | amindlost/wdosx | 1e256d22c1547e7b1f1ccd23e400f5b81b8bd013 | [
"Unlicense"
] | null | null | null | src/src/c/borlandc/dpmi32/parsfnm.asm | amindlost/wdosx | 1e256d22c1547e7b1f1ccd23e400f5b81b8bd013 | [
"Unlicense"
] | null | null | null | .386
.model flat,C
PUBLIC parsfnm
.code
; FCB functions are plain silly, I don't care
parsfnm proc near
sub eax,eax
ret
parsfnm endp
end
| 9.0625 | 45 | 0.724138 |
8936c6ee4669258bb3c1d677a7482bdf17216159 | 297 | asm | Assembly | laborator/lab-04/5-min/min.asm | Matei-Iordache/IOCLA-labs | ef82c212c68b2cee0f792cf356ea42fc9422e466 | [
"MIT"
] | null | null | null | laborator/lab-04/5-min/min.asm | Matei-Iordache/IOCLA-labs | ef82c212c68b2cee0f792cf356ea42fc9422e466 | [
"MIT"
] | null | null | null | laborator/lab-04/5-min/min.asm | Matei-Iordache/IOCLA-labs | ef82c212c68b2cee0f792cf356ea42fc9422e466 | [
"MIT"
] | null | null | null | %include "../io.mac"
section .text
global main
extern printf
main:
;cele doua numere se gasesc in eax si ebx
; TODO: aflati minimul
mov eax, 4
mov ebx, 1
cmp eax, ebx
jl min
xchg eax, ebx
min:
PRINTF32 `%d\n\x0`, eax ; afiseaza minimul
ret
| 12.913043 | 46 | 0.579125 |
f5c3f88d81b32d170da5aa2a450ac335cea97f1e | 568,005 | asm | Assembly | kernel/kernel.asm | noakrams/OS-assignment1 | fd87b500b2e47ee94db540c4ce241e55b6dc34b6 | [
"MIT-0"
] | null | null | null | kernel/kernel.asm | noakrams/OS-assignment1 | fd87b500b2e47ee94db540c4ce241e55b6dc34b6 | [
"MIT-0"
] | null | null | null | kernel/kernel.asm | noakrams/OS-assignment1 | fd87b500b2e47ee94db540c4ce241e55b6dc34b6 | [
"MIT-0"
] | null | null | null |
kernel/kernel: file format elf64-littleriscv
Disassembly of section .text:
0000000080000000 <_entry>:
80000000: 00009117 auipc sp,0x9
80000004: 18010113 addi sp,sp,384 # 80009180 <stack0>
80000008: 6505 lui a0,0x1
8000000a: f14025f3 csrr a1,mhartid
8000000e: 0585 addi a1,a1,1
80000010: 02b50533 mul a0,a0,a1
80000014: 912a add sp,sp,a0
80000016: 078000ef jal ra,8000008e <start>
000000008000001a <spin>:
8000001a: a001 j 8000001a <spin>
000000008000001c <timerinit>:
// which arrive at timervec in kernelvec.S,
// which turns them into software interrupts for
// devintr() in trap.c.
void
timerinit()
{
8000001c: 1141 addi sp,sp,-16
8000001e: e422 sd s0,8(sp)
80000020: 0800 addi s0,sp,16
// which hart (core) is this?
static inline uint64
r_mhartid()
{
uint64 x;
asm volatile("csrr %0, mhartid" : "=r" (x) );
80000022: f14027f3 csrr a5,mhartid
// each CPU has a separate source of timer interrupts.
int id = r_mhartid();
80000026: 0007869b sext.w a3,a5
// ask the CLINT for a timer interrupt.
int interval = 1000000; // cycles; about 1/10th second in qemu.
*(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;
8000002a: 0037979b slliw a5,a5,0x3
8000002e: 02004737 lui a4,0x2004
80000032: 97ba add a5,a5,a4
80000034: 0200c737 lui a4,0x200c
80000038: ff873583 ld a1,-8(a4) # 200bff8 <_entry-0x7dff4008>
8000003c: 000f4637 lui a2,0xf4
80000040: 24060613 addi a2,a2,576 # f4240 <_entry-0x7ff0bdc0>
80000044: 95b2 add a1,a1,a2
80000046: e38c sd a1,0(a5)
// prepare information in scratch[] for timervec.
// scratch[0..2] : space for timervec to save registers.
// scratch[3] : address of CLINT MTIMECMP register.
// scratch[4] : desired interval (in cycles) between timer interrupts.
uint64 *scratch = &timer_scratch[id][0];
80000048: 00269713 slli a4,a3,0x2
8000004c: 9736 add a4,a4,a3
8000004e: 00371693 slli a3,a4,0x3
80000052: 00009717 auipc a4,0x9
80000056: fee70713 addi a4,a4,-18 # 80009040 <timer_scratch>
8000005a: 9736 add a4,a4,a3
scratch[3] = CLINT_MTIMECMP(id);
8000005c: ef1c sd a5,24(a4)
scratch[4] = interval;
8000005e: f310 sd a2,32(a4)
}
static inline void
w_mscratch(uint64 x)
{
asm volatile("csrw mscratch, %0" : : "r" (x));
80000060: 34071073 csrw mscratch,a4
asm volatile("csrw mtvec, %0" : : "r" (x));
80000064: 00006797 auipc a5,0x6
80000068: fbc78793 addi a5,a5,-68 # 80006020 <timervec>
8000006c: 30579073 csrw mtvec,a5
asm volatile("csrr %0, mstatus" : "=r" (x) );
80000070: 300027f3 csrr a5,mstatus
// set the machine-mode trap handler.
w_mtvec((uint64)timervec);
// enable machine-mode interrupts.
w_mstatus(r_mstatus() | MSTATUS_MIE);
80000074: 0087e793 ori a5,a5,8
asm volatile("csrw mstatus, %0" : : "r" (x));
80000078: 30079073 csrw mstatus,a5
asm volatile("csrr %0, mie" : "=r" (x) );
8000007c: 304027f3 csrr a5,mie
// enable machine-mode timer interrupts.
w_mie(r_mie() | MIE_MTIE);
80000080: 0807e793 ori a5,a5,128
asm volatile("csrw mie, %0" : : "r" (x));
80000084: 30479073 csrw mie,a5
}
80000088: 6422 ld s0,8(sp)
8000008a: 0141 addi sp,sp,16
8000008c: 8082 ret
000000008000008e <start>:
{
8000008e: 1141 addi sp,sp,-16
80000090: e406 sd ra,8(sp)
80000092: e022 sd s0,0(sp)
80000094: 0800 addi s0,sp,16
asm volatile("csrr %0, mstatus" : "=r" (x) );
80000096: 300027f3 csrr a5,mstatus
x &= ~MSTATUS_MPP_MASK;
8000009a: 7779 lui a4,0xffffe
8000009c: 7ff70713 addi a4,a4,2047 # ffffffffffffe7ff <end+0xffffffff7ffd77ff>
800000a0: 8ff9 and a5,a5,a4
x |= MSTATUS_MPP_S;
800000a2: 6705 lui a4,0x1
800000a4: 80070713 addi a4,a4,-2048 # 800 <_entry-0x7ffff800>
800000a8: 8fd9 or a5,a5,a4
asm volatile("csrw mstatus, %0" : : "r" (x));
800000aa: 30079073 csrw mstatus,a5
asm volatile("csrw mepc, %0" : : "r" (x));
800000ae: 00001797 auipc a5,0x1
800000b2: dbe78793 addi a5,a5,-578 # 80000e6c <main>
800000b6: 34179073 csrw mepc,a5
asm volatile("csrw satp, %0" : : "r" (x));
800000ba: 4781 li a5,0
800000bc: 18079073 csrw satp,a5
asm volatile("csrw medeleg, %0" : : "r" (x));
800000c0: 67c1 lui a5,0x10
800000c2: 17fd addi a5,a5,-1
800000c4: 30279073 csrw medeleg,a5
asm volatile("csrw mideleg, %0" : : "r" (x));
800000c8: 30379073 csrw mideleg,a5
asm volatile("csrr %0, sie" : "=r" (x) );
800000cc: 104027f3 csrr a5,sie
w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
800000d0: 2227e793 ori a5,a5,546
asm volatile("csrw sie, %0" : : "r" (x));
800000d4: 10479073 csrw sie,a5
timerinit();
800000d8: 00000097 auipc ra,0x0
800000dc: f44080e7 jalr -188(ra) # 8000001c <timerinit>
asm volatile("csrr %0, mhartid" : "=r" (x) );
800000e0: f14027f3 csrr a5,mhartid
w_tp(id);
800000e4: 2781 sext.w a5,a5
}
static inline void
w_tp(uint64 x)
{
asm volatile("mv tp, %0" : : "r" (x));
800000e6: 823e mv tp,a5
asm volatile("mret");
800000e8: 30200073 mret
}
800000ec: 60a2 ld ra,8(sp)
800000ee: 6402 ld s0,0(sp)
800000f0: 0141 addi sp,sp,16
800000f2: 8082 ret
00000000800000f4 <consolewrite>:
//
// user write()s to the console go here.
//
int
consolewrite(int user_src, uint64 src, int n)
{
800000f4: 715d addi sp,sp,-80
800000f6: e486 sd ra,72(sp)
800000f8: e0a2 sd s0,64(sp)
800000fa: fc26 sd s1,56(sp)
800000fc: f84a sd s2,48(sp)
800000fe: f44e sd s3,40(sp)
80000100: f052 sd s4,32(sp)
80000102: ec56 sd s5,24(sp)
80000104: 0880 addi s0,sp,80
int i;
for(i = 0; i < n; i++){
80000106: 04c05663 blez a2,80000152 <consolewrite+0x5e>
8000010a: 8a2a mv s4,a0
8000010c: 84ae mv s1,a1
8000010e: 89b2 mv s3,a2
80000110: 4901 li s2,0
char c;
if(either_copyin(&c, user_src, src+i, 1) == -1)
80000112: 5afd li s5,-1
80000114: 4685 li a3,1
80000116: 8626 mv a2,s1
80000118: 85d2 mv a1,s4
8000011a: fbf40513 addi a0,s0,-65
8000011e: 00002097 auipc ra,0x2
80000122: 5da080e7 jalr 1498(ra) # 800026f8 <either_copyin>
80000126: 01550c63 beq a0,s5,8000013e <consolewrite+0x4a>
break;
uartputc(c);
8000012a: fbf44503 lbu a0,-65(s0)
8000012e: 00000097 auipc ra,0x0
80000132: 77a080e7 jalr 1914(ra) # 800008a8 <uartputc>
for(i = 0; i < n; i++){
80000136: 2905 addiw s2,s2,1
80000138: 0485 addi s1,s1,1
8000013a: fd299de3 bne s3,s2,80000114 <consolewrite+0x20>
}
return i;
}
8000013e: 854a mv a0,s2
80000140: 60a6 ld ra,72(sp)
80000142: 6406 ld s0,64(sp)
80000144: 74e2 ld s1,56(sp)
80000146: 7942 ld s2,48(sp)
80000148: 79a2 ld s3,40(sp)
8000014a: 7a02 ld s4,32(sp)
8000014c: 6ae2 ld s5,24(sp)
8000014e: 6161 addi sp,sp,80
80000150: 8082 ret
for(i = 0; i < n; i++){
80000152: 4901 li s2,0
80000154: b7ed j 8000013e <consolewrite+0x4a>
0000000080000156 <consoleread>:
// user_dist indicates whether dst is a user
// or kernel address.
//
int
consoleread(int user_dst, uint64 dst, int n)
{
80000156: 7159 addi sp,sp,-112
80000158: f486 sd ra,104(sp)
8000015a: f0a2 sd s0,96(sp)
8000015c: eca6 sd s1,88(sp)
8000015e: e8ca sd s2,80(sp)
80000160: e4ce sd s3,72(sp)
80000162: e0d2 sd s4,64(sp)
80000164: fc56 sd s5,56(sp)
80000166: f85a sd s6,48(sp)
80000168: f45e sd s7,40(sp)
8000016a: f062 sd s8,32(sp)
8000016c: ec66 sd s9,24(sp)
8000016e: e86a sd s10,16(sp)
80000170: 1880 addi s0,sp,112
80000172: 8aaa mv s5,a0
80000174: 8a2e mv s4,a1
80000176: 89b2 mv s3,a2
uint target;
int c;
char cbuf;
target = n;
80000178: 00060b1b sext.w s6,a2
acquire(&cons.lock);
8000017c: 00011517 auipc a0,0x11
80000180: 00450513 addi a0,a0,4 # 80011180 <cons>
80000184: 00001097 auipc ra,0x1
80000188: a3e080e7 jalr -1474(ra) # 80000bc2 <acquire>
while(n > 0){
// wait until interrupt handler has put some
// input into cons.buffer.
while(cons.r == cons.w){
8000018c: 00011497 auipc s1,0x11
80000190: ff448493 addi s1,s1,-12 # 80011180 <cons>
if(myproc()->killed){
release(&cons.lock);
return -1;
}
sleep(&cons.r, &cons.lock);
80000194: 00011917 auipc s2,0x11
80000198: 08490913 addi s2,s2,132 # 80011218 <cons+0x98>
}
c = cons.buf[cons.r++ % INPUT_BUF];
if(c == C('D')){ // end-of-file
8000019c: 4b91 li s7,4
break;
}
// copy the input byte to the user-space buffer.
cbuf = c;
if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
8000019e: 5c7d li s8,-1
break;
dst++;
--n;
if(c == '\n'){
800001a0: 4ca9 li s9,10
while(n > 0){
800001a2: 07305863 blez s3,80000212 <consoleread+0xbc>
while(cons.r == cons.w){
800001a6: 0984a783 lw a5,152(s1)
800001aa: 09c4a703 lw a4,156(s1)
800001ae: 02f71463 bne a4,a5,800001d6 <consoleread+0x80>
if(myproc()->killed){
800001b2: 00001097 auipc ra,0x1
800001b6: 7cc080e7 jalr 1996(ra) # 8000197e <myproc>
800001ba: 551c lw a5,40(a0)
800001bc: e7b5 bnez a5,80000228 <consoleread+0xd2>
sleep(&cons.r, &cons.lock);
800001be: 85a6 mv a1,s1
800001c0: 854a mv a0,s2
800001c2: 00002097 auipc ra,0x2
800001c6: f32080e7 jalr -206(ra) # 800020f4 <sleep>
while(cons.r == cons.w){
800001ca: 0984a783 lw a5,152(s1)
800001ce: 09c4a703 lw a4,156(s1)
800001d2: fef700e3 beq a4,a5,800001b2 <consoleread+0x5c>
c = cons.buf[cons.r++ % INPUT_BUF];
800001d6: 0017871b addiw a4,a5,1
800001da: 08e4ac23 sw a4,152(s1)
800001de: 07f7f713 andi a4,a5,127
800001e2: 9726 add a4,a4,s1
800001e4: 01874703 lbu a4,24(a4)
800001e8: 00070d1b sext.w s10,a4
if(c == C('D')){ // end-of-file
800001ec: 077d0563 beq s10,s7,80000256 <consoleread+0x100>
cbuf = c;
800001f0: f8e40fa3 sb a4,-97(s0)
if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
800001f4: 4685 li a3,1
800001f6: f9f40613 addi a2,s0,-97
800001fa: 85d2 mv a1,s4
800001fc: 8556 mv a0,s5
800001fe: 00002097 auipc ra,0x2
80000202: 4a4080e7 jalr 1188(ra) # 800026a2 <either_copyout>
80000206: 01850663 beq a0,s8,80000212 <consoleread+0xbc>
dst++;
8000020a: 0a05 addi s4,s4,1
--n;
8000020c: 39fd addiw s3,s3,-1
if(c == '\n'){
8000020e: f99d1ae3 bne s10,s9,800001a2 <consoleread+0x4c>
// a whole line has arrived, return to
// the user-level read().
break;
}
}
release(&cons.lock);
80000212: 00011517 auipc a0,0x11
80000216: f6e50513 addi a0,a0,-146 # 80011180 <cons>
8000021a: 00001097 auipc ra,0x1
8000021e: a5c080e7 jalr -1444(ra) # 80000c76 <release>
return target - n;
80000222: 413b053b subw a0,s6,s3
80000226: a811 j 8000023a <consoleread+0xe4>
release(&cons.lock);
80000228: 00011517 auipc a0,0x11
8000022c: f5850513 addi a0,a0,-168 # 80011180 <cons>
80000230: 00001097 auipc ra,0x1
80000234: a46080e7 jalr -1466(ra) # 80000c76 <release>
return -1;
80000238: 557d li a0,-1
}
8000023a: 70a6 ld ra,104(sp)
8000023c: 7406 ld s0,96(sp)
8000023e: 64e6 ld s1,88(sp)
80000240: 6946 ld s2,80(sp)
80000242: 69a6 ld s3,72(sp)
80000244: 6a06 ld s4,64(sp)
80000246: 7ae2 ld s5,56(sp)
80000248: 7b42 ld s6,48(sp)
8000024a: 7ba2 ld s7,40(sp)
8000024c: 7c02 ld s8,32(sp)
8000024e: 6ce2 ld s9,24(sp)
80000250: 6d42 ld s10,16(sp)
80000252: 6165 addi sp,sp,112
80000254: 8082 ret
if(n < target){
80000256: 0009871b sext.w a4,s3
8000025a: fb677ce3 bgeu a4,s6,80000212 <consoleread+0xbc>
cons.r--;
8000025e: 00011717 auipc a4,0x11
80000262: faf72d23 sw a5,-70(a4) # 80011218 <cons+0x98>
80000266: b775 j 80000212 <consoleread+0xbc>
0000000080000268 <consputc>:
{
80000268: 1141 addi sp,sp,-16
8000026a: e406 sd ra,8(sp)
8000026c: e022 sd s0,0(sp)
8000026e: 0800 addi s0,sp,16
if(c == BACKSPACE){
80000270: 10000793 li a5,256
80000274: 00f50a63 beq a0,a5,80000288 <consputc+0x20>
uartputc_sync(c);
80000278: 00000097 auipc ra,0x0
8000027c: 55e080e7 jalr 1374(ra) # 800007d6 <uartputc_sync>
}
80000280: 60a2 ld ra,8(sp)
80000282: 6402 ld s0,0(sp)
80000284: 0141 addi sp,sp,16
80000286: 8082 ret
uartputc_sync('\b'); uartputc_sync(' '); uartputc_sync('\b');
80000288: 4521 li a0,8
8000028a: 00000097 auipc ra,0x0
8000028e: 54c080e7 jalr 1356(ra) # 800007d6 <uartputc_sync>
80000292: 02000513 li a0,32
80000296: 00000097 auipc ra,0x0
8000029a: 540080e7 jalr 1344(ra) # 800007d6 <uartputc_sync>
8000029e: 4521 li a0,8
800002a0: 00000097 auipc ra,0x0
800002a4: 536080e7 jalr 1334(ra) # 800007d6 <uartputc_sync>
800002a8: bfe1 j 80000280 <consputc+0x18>
00000000800002aa <consoleintr>:
// do erase/kill processing, append to cons.buf,
// wake up consoleread() if a whole line has arrived.
//
void
consoleintr(int c)
{
800002aa: 1101 addi sp,sp,-32
800002ac: ec06 sd ra,24(sp)
800002ae: e822 sd s0,16(sp)
800002b0: e426 sd s1,8(sp)
800002b2: e04a sd s2,0(sp)
800002b4: 1000 addi s0,sp,32
800002b6: 84aa mv s1,a0
acquire(&cons.lock);
800002b8: 00011517 auipc a0,0x11
800002bc: ec850513 addi a0,a0,-312 # 80011180 <cons>
800002c0: 00001097 auipc ra,0x1
800002c4: 902080e7 jalr -1790(ra) # 80000bc2 <acquire>
switch(c){
800002c8: 47d5 li a5,21
800002ca: 0af48663 beq s1,a5,80000376 <consoleintr+0xcc>
800002ce: 0297ca63 blt a5,s1,80000302 <consoleintr+0x58>
800002d2: 47a1 li a5,8
800002d4: 0ef48763 beq s1,a5,800003c2 <consoleintr+0x118>
800002d8: 47c1 li a5,16
800002da: 10f49a63 bne s1,a5,800003ee <consoleintr+0x144>
case C('P'): // Print process list.
procdump();
800002de: 00002097 auipc ra,0x2
800002e2: 470080e7 jalr 1136(ra) # 8000274e <procdump>
}
}
break;
}
release(&cons.lock);
800002e6: 00011517 auipc a0,0x11
800002ea: e9a50513 addi a0,a0,-358 # 80011180 <cons>
800002ee: 00001097 auipc ra,0x1
800002f2: 988080e7 jalr -1656(ra) # 80000c76 <release>
}
800002f6: 60e2 ld ra,24(sp)
800002f8: 6442 ld s0,16(sp)
800002fa: 64a2 ld s1,8(sp)
800002fc: 6902 ld s2,0(sp)
800002fe: 6105 addi sp,sp,32
80000300: 8082 ret
switch(c){
80000302: 07f00793 li a5,127
80000306: 0af48e63 beq s1,a5,800003c2 <consoleintr+0x118>
if(c != 0 && cons.e-cons.r < INPUT_BUF){
8000030a: 00011717 auipc a4,0x11
8000030e: e7670713 addi a4,a4,-394 # 80011180 <cons>
80000312: 0a072783 lw a5,160(a4)
80000316: 09872703 lw a4,152(a4)
8000031a: 9f99 subw a5,a5,a4
8000031c: 07f00713 li a4,127
80000320: fcf763e3 bltu a4,a5,800002e6 <consoleintr+0x3c>
c = (c == '\r') ? '\n' : c;
80000324: 47b5 li a5,13
80000326: 0cf48763 beq s1,a5,800003f4 <consoleintr+0x14a>
consputc(c);
8000032a: 8526 mv a0,s1
8000032c: 00000097 auipc ra,0x0
80000330: f3c080e7 jalr -196(ra) # 80000268 <consputc>
cons.buf[cons.e++ % INPUT_BUF] = c;
80000334: 00011797 auipc a5,0x11
80000338: e4c78793 addi a5,a5,-436 # 80011180 <cons>
8000033c: 0a07a703 lw a4,160(a5)
80000340: 0017069b addiw a3,a4,1
80000344: 0006861b sext.w a2,a3
80000348: 0ad7a023 sw a3,160(a5)
8000034c: 07f77713 andi a4,a4,127
80000350: 97ba add a5,a5,a4
80000352: 00978c23 sb s1,24(a5)
if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){
80000356: 47a9 li a5,10
80000358: 0cf48563 beq s1,a5,80000422 <consoleintr+0x178>
8000035c: 4791 li a5,4
8000035e: 0cf48263 beq s1,a5,80000422 <consoleintr+0x178>
80000362: 00011797 auipc a5,0x11
80000366: eb67a783 lw a5,-330(a5) # 80011218 <cons+0x98>
8000036a: 0807879b addiw a5,a5,128
8000036e: f6f61ce3 bne a2,a5,800002e6 <consoleintr+0x3c>
cons.buf[cons.e++ % INPUT_BUF] = c;
80000372: 863e mv a2,a5
80000374: a07d j 80000422 <consoleintr+0x178>
while(cons.e != cons.w &&
80000376: 00011717 auipc a4,0x11
8000037a: e0a70713 addi a4,a4,-502 # 80011180 <cons>
8000037e: 0a072783 lw a5,160(a4)
80000382: 09c72703 lw a4,156(a4)
cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
80000386: 00011497 auipc s1,0x11
8000038a: dfa48493 addi s1,s1,-518 # 80011180 <cons>
while(cons.e != cons.w &&
8000038e: 4929 li s2,10
80000390: f4f70be3 beq a4,a5,800002e6 <consoleintr+0x3c>
cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
80000394: 37fd addiw a5,a5,-1
80000396: 07f7f713 andi a4,a5,127
8000039a: 9726 add a4,a4,s1
while(cons.e != cons.w &&
8000039c: 01874703 lbu a4,24(a4)
800003a0: f52703e3 beq a4,s2,800002e6 <consoleintr+0x3c>
cons.e--;
800003a4: 0af4a023 sw a5,160(s1)
consputc(BACKSPACE);
800003a8: 10000513 li a0,256
800003ac: 00000097 auipc ra,0x0
800003b0: ebc080e7 jalr -324(ra) # 80000268 <consputc>
while(cons.e != cons.w &&
800003b4: 0a04a783 lw a5,160(s1)
800003b8: 09c4a703 lw a4,156(s1)
800003bc: fcf71ce3 bne a4,a5,80000394 <consoleintr+0xea>
800003c0: b71d j 800002e6 <consoleintr+0x3c>
if(cons.e != cons.w){
800003c2: 00011717 auipc a4,0x11
800003c6: dbe70713 addi a4,a4,-578 # 80011180 <cons>
800003ca: 0a072783 lw a5,160(a4)
800003ce: 09c72703 lw a4,156(a4)
800003d2: f0f70ae3 beq a4,a5,800002e6 <consoleintr+0x3c>
cons.e--;
800003d6: 37fd addiw a5,a5,-1
800003d8: 00011717 auipc a4,0x11
800003dc: e4f72423 sw a5,-440(a4) # 80011220 <cons+0xa0>
consputc(BACKSPACE);
800003e0: 10000513 li a0,256
800003e4: 00000097 auipc ra,0x0
800003e8: e84080e7 jalr -380(ra) # 80000268 <consputc>
800003ec: bded j 800002e6 <consoleintr+0x3c>
if(c != 0 && cons.e-cons.r < INPUT_BUF){
800003ee: ee048ce3 beqz s1,800002e6 <consoleintr+0x3c>
800003f2: bf21 j 8000030a <consoleintr+0x60>
consputc(c);
800003f4: 4529 li a0,10
800003f6: 00000097 auipc ra,0x0
800003fa: e72080e7 jalr -398(ra) # 80000268 <consputc>
cons.buf[cons.e++ % INPUT_BUF] = c;
800003fe: 00011797 auipc a5,0x11
80000402: d8278793 addi a5,a5,-638 # 80011180 <cons>
80000406: 0a07a703 lw a4,160(a5)
8000040a: 0017069b addiw a3,a4,1
8000040e: 0006861b sext.w a2,a3
80000412: 0ad7a023 sw a3,160(a5)
80000416: 07f77713 andi a4,a4,127
8000041a: 97ba add a5,a5,a4
8000041c: 4729 li a4,10
8000041e: 00e78c23 sb a4,24(a5)
cons.w = cons.e;
80000422: 00011797 auipc a5,0x11
80000426: dec7ad23 sw a2,-518(a5) # 8001121c <cons+0x9c>
wakeup(&cons.r);
8000042a: 00011517 auipc a0,0x11
8000042e: dee50513 addi a0,a0,-530 # 80011218 <cons+0x98>
80000432: 00002097 auipc ra,0x2
80000436: f36080e7 jalr -202(ra) # 80002368 <wakeup>
8000043a: b575 j 800002e6 <consoleintr+0x3c>
000000008000043c <consoleinit>:
void
consoleinit(void)
{
8000043c: 1141 addi sp,sp,-16
8000043e: e406 sd ra,8(sp)
80000440: e022 sd s0,0(sp)
80000442: 0800 addi s0,sp,16
initlock(&cons.lock, "cons");
80000444: 00008597 auipc a1,0x8
80000448: bcc58593 addi a1,a1,-1076 # 80008010 <etext+0x10>
8000044c: 00011517 auipc a0,0x11
80000450: d3450513 addi a0,a0,-716 # 80011180 <cons>
80000454: 00000097 auipc ra,0x0
80000458: 6de080e7 jalr 1758(ra) # 80000b32 <initlock>
uartinit();
8000045c: 00000097 auipc ra,0x0
80000460: 32a080e7 jalr 810(ra) # 80000786 <uartinit>
// connect read and write system calls
// to consoleread and consolewrite.
devsw[CONSOLE].read = consoleread;
80000464: 00022797 auipc a5,0x22
80000468: cb478793 addi a5,a5,-844 # 80022118 <devsw>
8000046c: 00000717 auipc a4,0x0
80000470: cea70713 addi a4,a4,-790 # 80000156 <consoleread>
80000474: eb98 sd a4,16(a5)
devsw[CONSOLE].write = consolewrite;
80000476: 00000717 auipc a4,0x0
8000047a: c7e70713 addi a4,a4,-898 # 800000f4 <consolewrite>
8000047e: ef98 sd a4,24(a5)
}
80000480: 60a2 ld ra,8(sp)
80000482: 6402 ld s0,0(sp)
80000484: 0141 addi sp,sp,16
80000486: 8082 ret
0000000080000488 <printint>:
static char digits[] = "0123456789abcdef";
static void
printint(int xx, int base, int sign)
{
80000488: 7179 addi sp,sp,-48
8000048a: f406 sd ra,40(sp)
8000048c: f022 sd s0,32(sp)
8000048e: ec26 sd s1,24(sp)
80000490: e84a sd s2,16(sp)
80000492: 1800 addi s0,sp,48
char buf[16];
int i;
uint x;
if(sign && (sign = xx < 0))
80000494: c219 beqz a2,8000049a <printint+0x12>
80000496: 08054663 bltz a0,80000522 <printint+0x9a>
x = -xx;
else
x = xx;
8000049a: 2501 sext.w a0,a0
8000049c: 4881 li a7,0
8000049e: fd040693 addi a3,s0,-48
i = 0;
800004a2: 4701 li a4,0
do {
buf[i++] = digits[x % base];
800004a4: 2581 sext.w a1,a1
800004a6: 00008617 auipc a2,0x8
800004aa: b9a60613 addi a2,a2,-1126 # 80008040 <digits>
800004ae: 883a mv a6,a4
800004b0: 2705 addiw a4,a4,1
800004b2: 02b577bb remuw a5,a0,a1
800004b6: 1782 slli a5,a5,0x20
800004b8: 9381 srli a5,a5,0x20
800004ba: 97b2 add a5,a5,a2
800004bc: 0007c783 lbu a5,0(a5)
800004c0: 00f68023 sb a5,0(a3)
} while((x /= base) != 0);
800004c4: 0005079b sext.w a5,a0
800004c8: 02b5553b divuw a0,a0,a1
800004cc: 0685 addi a3,a3,1
800004ce: feb7f0e3 bgeu a5,a1,800004ae <printint+0x26>
if(sign)
800004d2: 00088b63 beqz a7,800004e8 <printint+0x60>
buf[i++] = '-';
800004d6: fe040793 addi a5,s0,-32
800004da: 973e add a4,a4,a5
800004dc: 02d00793 li a5,45
800004e0: fef70823 sb a5,-16(a4)
800004e4: 0028071b addiw a4,a6,2
while(--i >= 0)
800004e8: 02e05763 blez a4,80000516 <printint+0x8e>
800004ec: fd040793 addi a5,s0,-48
800004f0: 00e784b3 add s1,a5,a4
800004f4: fff78913 addi s2,a5,-1
800004f8: 993a add s2,s2,a4
800004fa: 377d addiw a4,a4,-1
800004fc: 1702 slli a4,a4,0x20
800004fe: 9301 srli a4,a4,0x20
80000500: 40e90933 sub s2,s2,a4
consputc(buf[i]);
80000504: fff4c503 lbu a0,-1(s1)
80000508: 00000097 auipc ra,0x0
8000050c: d60080e7 jalr -672(ra) # 80000268 <consputc>
while(--i >= 0)
80000510: 14fd addi s1,s1,-1
80000512: ff2499e3 bne s1,s2,80000504 <printint+0x7c>
}
80000516: 70a2 ld ra,40(sp)
80000518: 7402 ld s0,32(sp)
8000051a: 64e2 ld s1,24(sp)
8000051c: 6942 ld s2,16(sp)
8000051e: 6145 addi sp,sp,48
80000520: 8082 ret
x = -xx;
80000522: 40a0053b negw a0,a0
if(sign && (sign = xx < 0))
80000526: 4885 li a7,1
x = -xx;
80000528: bf9d j 8000049e <printint+0x16>
000000008000052a <panic>:
release(&pr.lock);
}
void
panic(char *s)
{
8000052a: 1101 addi sp,sp,-32
8000052c: ec06 sd ra,24(sp)
8000052e: e822 sd s0,16(sp)
80000530: e426 sd s1,8(sp)
80000532: 1000 addi s0,sp,32
80000534: 84aa mv s1,a0
pr.locking = 0;
80000536: 00011797 auipc a5,0x11
8000053a: d007a523 sw zero,-758(a5) # 80011240 <pr+0x18>
printf("panic: ");
8000053e: 00008517 auipc a0,0x8
80000542: ada50513 addi a0,a0,-1318 # 80008018 <etext+0x18>
80000546: 00000097 auipc ra,0x0
8000054a: 02e080e7 jalr 46(ra) # 80000574 <printf>
printf(s);
8000054e: 8526 mv a0,s1
80000550: 00000097 auipc ra,0x0
80000554: 024080e7 jalr 36(ra) # 80000574 <printf>
printf("\n");
80000558: 00008517 auipc a0,0x8
8000055c: b7050513 addi a0,a0,-1168 # 800080c8 <digits+0x88>
80000560: 00000097 auipc ra,0x0
80000564: 014080e7 jalr 20(ra) # 80000574 <printf>
panicked = 1; // freeze uart output from other CPUs
80000568: 4785 li a5,1
8000056a: 00009717 auipc a4,0x9
8000056e: a8f72b23 sw a5,-1386(a4) # 80009000 <panicked>
for(;;)
80000572: a001 j 80000572 <panic+0x48>
0000000080000574 <printf>:
{
80000574: 7131 addi sp,sp,-192
80000576: fc86 sd ra,120(sp)
80000578: f8a2 sd s0,112(sp)
8000057a: f4a6 sd s1,104(sp)
8000057c: f0ca sd s2,96(sp)
8000057e: ecce sd s3,88(sp)
80000580: e8d2 sd s4,80(sp)
80000582: e4d6 sd s5,72(sp)
80000584: e0da sd s6,64(sp)
80000586: fc5e sd s7,56(sp)
80000588: f862 sd s8,48(sp)
8000058a: f466 sd s9,40(sp)
8000058c: f06a sd s10,32(sp)
8000058e: ec6e sd s11,24(sp)
80000590: 0100 addi s0,sp,128
80000592: 8a2a mv s4,a0
80000594: e40c sd a1,8(s0)
80000596: e810 sd a2,16(s0)
80000598: ec14 sd a3,24(s0)
8000059a: f018 sd a4,32(s0)
8000059c: f41c sd a5,40(s0)
8000059e: 03043823 sd a6,48(s0)
800005a2: 03143c23 sd a7,56(s0)
locking = pr.locking;
800005a6: 00011d97 auipc s11,0x11
800005aa: c9adad83 lw s11,-870(s11) # 80011240 <pr+0x18>
if(locking)
800005ae: 020d9b63 bnez s11,800005e4 <printf+0x70>
if (fmt == 0)
800005b2: 040a0263 beqz s4,800005f6 <printf+0x82>
va_start(ap, fmt);
800005b6: 00840793 addi a5,s0,8
800005ba: f8f43423 sd a5,-120(s0)
for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
800005be: 000a4503 lbu a0,0(s4)
800005c2: 14050f63 beqz a0,80000720 <printf+0x1ac>
800005c6: 4981 li s3,0
if(c != '%'){
800005c8: 02500a93 li s5,37
switch(c){
800005cc: 07000b93 li s7,112
consputc('x');
800005d0: 4d41 li s10,16
consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
800005d2: 00008b17 auipc s6,0x8
800005d6: a6eb0b13 addi s6,s6,-1426 # 80008040 <digits>
switch(c){
800005da: 07300c93 li s9,115
800005de: 06400c13 li s8,100
800005e2: a82d j 8000061c <printf+0xa8>
acquire(&pr.lock);
800005e4: 00011517 auipc a0,0x11
800005e8: c4450513 addi a0,a0,-956 # 80011228 <pr>
800005ec: 00000097 auipc ra,0x0
800005f0: 5d6080e7 jalr 1494(ra) # 80000bc2 <acquire>
800005f4: bf7d j 800005b2 <printf+0x3e>
panic("null fmt");
800005f6: 00008517 auipc a0,0x8
800005fa: a3250513 addi a0,a0,-1486 # 80008028 <etext+0x28>
800005fe: 00000097 auipc ra,0x0
80000602: f2c080e7 jalr -212(ra) # 8000052a <panic>
consputc(c);
80000606: 00000097 auipc ra,0x0
8000060a: c62080e7 jalr -926(ra) # 80000268 <consputc>
for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
8000060e: 2985 addiw s3,s3,1
80000610: 013a07b3 add a5,s4,s3
80000614: 0007c503 lbu a0,0(a5)
80000618: 10050463 beqz a0,80000720 <printf+0x1ac>
if(c != '%'){
8000061c: ff5515e3 bne a0,s5,80000606 <printf+0x92>
c = fmt[++i] & 0xff;
80000620: 2985 addiw s3,s3,1
80000622: 013a07b3 add a5,s4,s3
80000626: 0007c783 lbu a5,0(a5)
8000062a: 0007849b sext.w s1,a5
if(c == 0)
8000062e: cbed beqz a5,80000720 <printf+0x1ac>
switch(c){
80000630: 05778a63 beq a5,s7,80000684 <printf+0x110>
80000634: 02fbf663 bgeu s7,a5,80000660 <printf+0xec>
80000638: 09978863 beq a5,s9,800006c8 <printf+0x154>
8000063c: 07800713 li a4,120
80000640: 0ce79563 bne a5,a4,8000070a <printf+0x196>
printint(va_arg(ap, int), 16, 1);
80000644: f8843783 ld a5,-120(s0)
80000648: 00878713 addi a4,a5,8
8000064c: f8e43423 sd a4,-120(s0)
80000650: 4605 li a2,1
80000652: 85ea mv a1,s10
80000654: 4388 lw a0,0(a5)
80000656: 00000097 auipc ra,0x0
8000065a: e32080e7 jalr -462(ra) # 80000488 <printint>
break;
8000065e: bf45 j 8000060e <printf+0x9a>
switch(c){
80000660: 09578f63 beq a5,s5,800006fe <printf+0x18a>
80000664: 0b879363 bne a5,s8,8000070a <printf+0x196>
printint(va_arg(ap, int), 10, 1);
80000668: f8843783 ld a5,-120(s0)
8000066c: 00878713 addi a4,a5,8
80000670: f8e43423 sd a4,-120(s0)
80000674: 4605 li a2,1
80000676: 45a9 li a1,10
80000678: 4388 lw a0,0(a5)
8000067a: 00000097 auipc ra,0x0
8000067e: e0e080e7 jalr -498(ra) # 80000488 <printint>
break;
80000682: b771 j 8000060e <printf+0x9a>
printptr(va_arg(ap, uint64));
80000684: f8843783 ld a5,-120(s0)
80000688: 00878713 addi a4,a5,8
8000068c: f8e43423 sd a4,-120(s0)
80000690: 0007b903 ld s2,0(a5)
consputc('0');
80000694: 03000513 li a0,48
80000698: 00000097 auipc ra,0x0
8000069c: bd0080e7 jalr -1072(ra) # 80000268 <consputc>
consputc('x');
800006a0: 07800513 li a0,120
800006a4: 00000097 auipc ra,0x0
800006a8: bc4080e7 jalr -1084(ra) # 80000268 <consputc>
800006ac: 84ea mv s1,s10
consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
800006ae: 03c95793 srli a5,s2,0x3c
800006b2: 97da add a5,a5,s6
800006b4: 0007c503 lbu a0,0(a5)
800006b8: 00000097 auipc ra,0x0
800006bc: bb0080e7 jalr -1104(ra) # 80000268 <consputc>
for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
800006c0: 0912 slli s2,s2,0x4
800006c2: 34fd addiw s1,s1,-1
800006c4: f4ed bnez s1,800006ae <printf+0x13a>
800006c6: b7a1 j 8000060e <printf+0x9a>
if((s = va_arg(ap, char*)) == 0)
800006c8: f8843783 ld a5,-120(s0)
800006cc: 00878713 addi a4,a5,8
800006d0: f8e43423 sd a4,-120(s0)
800006d4: 6384 ld s1,0(a5)
800006d6: cc89 beqz s1,800006f0 <printf+0x17c>
for(; *s; s++)
800006d8: 0004c503 lbu a0,0(s1)
800006dc: d90d beqz a0,8000060e <printf+0x9a>
consputc(*s);
800006de: 00000097 auipc ra,0x0
800006e2: b8a080e7 jalr -1142(ra) # 80000268 <consputc>
for(; *s; s++)
800006e6: 0485 addi s1,s1,1
800006e8: 0004c503 lbu a0,0(s1)
800006ec: f96d bnez a0,800006de <printf+0x16a>
800006ee: b705 j 8000060e <printf+0x9a>
s = "(null)";
800006f0: 00008497 auipc s1,0x8
800006f4: 93048493 addi s1,s1,-1744 # 80008020 <etext+0x20>
for(; *s; s++)
800006f8: 02800513 li a0,40
800006fc: b7cd j 800006de <printf+0x16a>
consputc('%');
800006fe: 8556 mv a0,s5
80000700: 00000097 auipc ra,0x0
80000704: b68080e7 jalr -1176(ra) # 80000268 <consputc>
break;
80000708: b719 j 8000060e <printf+0x9a>
consputc('%');
8000070a: 8556 mv a0,s5
8000070c: 00000097 auipc ra,0x0
80000710: b5c080e7 jalr -1188(ra) # 80000268 <consputc>
consputc(c);
80000714: 8526 mv a0,s1
80000716: 00000097 auipc ra,0x0
8000071a: b52080e7 jalr -1198(ra) # 80000268 <consputc>
break;
8000071e: bdc5 j 8000060e <printf+0x9a>
if(locking)
80000720: 020d9163 bnez s11,80000742 <printf+0x1ce>
}
80000724: 70e6 ld ra,120(sp)
80000726: 7446 ld s0,112(sp)
80000728: 74a6 ld s1,104(sp)
8000072a: 7906 ld s2,96(sp)
8000072c: 69e6 ld s3,88(sp)
8000072e: 6a46 ld s4,80(sp)
80000730: 6aa6 ld s5,72(sp)
80000732: 6b06 ld s6,64(sp)
80000734: 7be2 ld s7,56(sp)
80000736: 7c42 ld s8,48(sp)
80000738: 7ca2 ld s9,40(sp)
8000073a: 7d02 ld s10,32(sp)
8000073c: 6de2 ld s11,24(sp)
8000073e: 6129 addi sp,sp,192
80000740: 8082 ret
release(&pr.lock);
80000742: 00011517 auipc a0,0x11
80000746: ae650513 addi a0,a0,-1306 # 80011228 <pr>
8000074a: 00000097 auipc ra,0x0
8000074e: 52c080e7 jalr 1324(ra) # 80000c76 <release>
}
80000752: bfc9 j 80000724 <printf+0x1b0>
0000000080000754 <printfinit>:
;
}
void
printfinit(void)
{
80000754: 1101 addi sp,sp,-32
80000756: ec06 sd ra,24(sp)
80000758: e822 sd s0,16(sp)
8000075a: e426 sd s1,8(sp)
8000075c: 1000 addi s0,sp,32
initlock(&pr.lock, "pr");
8000075e: 00011497 auipc s1,0x11
80000762: aca48493 addi s1,s1,-1334 # 80011228 <pr>
80000766: 00008597 auipc a1,0x8
8000076a: 8d258593 addi a1,a1,-1838 # 80008038 <etext+0x38>
8000076e: 8526 mv a0,s1
80000770: 00000097 auipc ra,0x0
80000774: 3c2080e7 jalr 962(ra) # 80000b32 <initlock>
pr.locking = 1;
80000778: 4785 li a5,1
8000077a: cc9c sw a5,24(s1)
}
8000077c: 60e2 ld ra,24(sp)
8000077e: 6442 ld s0,16(sp)
80000780: 64a2 ld s1,8(sp)
80000782: 6105 addi sp,sp,32
80000784: 8082 ret
0000000080000786 <uartinit>:
void uartstart();
void
uartinit(void)
{
80000786: 1141 addi sp,sp,-16
80000788: e406 sd ra,8(sp)
8000078a: e022 sd s0,0(sp)
8000078c: 0800 addi s0,sp,16
// disable interrupts.
WriteReg(IER, 0x00);
8000078e: 100007b7 lui a5,0x10000
80000792: 000780a3 sb zero,1(a5) # 10000001 <_entry-0x6fffffff>
// special mode to set baud rate.
WriteReg(LCR, LCR_BAUD_LATCH);
80000796: f8000713 li a4,-128
8000079a: 00e781a3 sb a4,3(a5)
// LSB for baud rate of 38.4K.
WriteReg(0, 0x03);
8000079e: 470d li a4,3
800007a0: 00e78023 sb a4,0(a5)
// MSB for baud rate of 38.4K.
WriteReg(1, 0x00);
800007a4: 000780a3 sb zero,1(a5)
// leave set-baud mode,
// and set word length to 8 bits, no parity.
WriteReg(LCR, LCR_EIGHT_BITS);
800007a8: 00e781a3 sb a4,3(a5)
// reset and enable FIFOs.
WriteReg(FCR, FCR_FIFO_ENABLE | FCR_FIFO_CLEAR);
800007ac: 469d li a3,7
800007ae: 00d78123 sb a3,2(a5)
// enable transmit and receive interrupts.
WriteReg(IER, IER_TX_ENABLE | IER_RX_ENABLE);
800007b2: 00e780a3 sb a4,1(a5)
initlock(&uart_tx_lock, "uart");
800007b6: 00008597 auipc a1,0x8
800007ba: 8a258593 addi a1,a1,-1886 # 80008058 <digits+0x18>
800007be: 00011517 auipc a0,0x11
800007c2: a8a50513 addi a0,a0,-1398 # 80011248 <uart_tx_lock>
800007c6: 00000097 auipc ra,0x0
800007ca: 36c080e7 jalr 876(ra) # 80000b32 <initlock>
}
800007ce: 60a2 ld ra,8(sp)
800007d0: 6402 ld s0,0(sp)
800007d2: 0141 addi sp,sp,16
800007d4: 8082 ret
00000000800007d6 <uartputc_sync>:
// use interrupts, for use by kernel printf() and
// to echo characters. it spins waiting for the uart's
// output register to be empty.
void
uartputc_sync(int c)
{
800007d6: 1101 addi sp,sp,-32
800007d8: ec06 sd ra,24(sp)
800007da: e822 sd s0,16(sp)
800007dc: e426 sd s1,8(sp)
800007de: 1000 addi s0,sp,32
800007e0: 84aa mv s1,a0
push_off();
800007e2: 00000097 auipc ra,0x0
800007e6: 394080e7 jalr 916(ra) # 80000b76 <push_off>
if(panicked){
800007ea: 00009797 auipc a5,0x9
800007ee: 8167a783 lw a5,-2026(a5) # 80009000 <panicked>
for(;;)
;
}
// wait for Transmit Holding Empty to be set in LSR.
while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
800007f2: 10000737 lui a4,0x10000
if(panicked){
800007f6: c391 beqz a5,800007fa <uartputc_sync+0x24>
for(;;)
800007f8: a001 j 800007f8 <uartputc_sync+0x22>
while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
800007fa: 00574783 lbu a5,5(a4) # 10000005 <_entry-0x6ffffffb>
800007fe: 0207f793 andi a5,a5,32
80000802: dfe5 beqz a5,800007fa <uartputc_sync+0x24>
;
WriteReg(THR, c);
80000804: 0ff4f513 andi a0,s1,255
80000808: 100007b7 lui a5,0x10000
8000080c: 00a78023 sb a0,0(a5) # 10000000 <_entry-0x70000000>
pop_off();
80000810: 00000097 auipc ra,0x0
80000814: 406080e7 jalr 1030(ra) # 80000c16 <pop_off>
}
80000818: 60e2 ld ra,24(sp)
8000081a: 6442 ld s0,16(sp)
8000081c: 64a2 ld s1,8(sp)
8000081e: 6105 addi sp,sp,32
80000820: 8082 ret
0000000080000822 <uartstart>:
// called from both the top- and bottom-half.
void
uartstart()
{
while(1){
if(uart_tx_w == uart_tx_r){
80000822: 00008797 auipc a5,0x8
80000826: 7e67b783 ld a5,2022(a5) # 80009008 <uart_tx_r>
8000082a: 00008717 auipc a4,0x8
8000082e: 7e673703 ld a4,2022(a4) # 80009010 <uart_tx_w>
80000832: 06f70a63 beq a4,a5,800008a6 <uartstart+0x84>
{
80000836: 7139 addi sp,sp,-64
80000838: fc06 sd ra,56(sp)
8000083a: f822 sd s0,48(sp)
8000083c: f426 sd s1,40(sp)
8000083e: f04a sd s2,32(sp)
80000840: ec4e sd s3,24(sp)
80000842: e852 sd s4,16(sp)
80000844: e456 sd s5,8(sp)
80000846: 0080 addi s0,sp,64
// transmit buffer is empty.
return;
}
if((ReadReg(LSR) & LSR_TX_IDLE) == 0){
80000848: 10000937 lui s2,0x10000
// so we cannot give it another byte.
// it will interrupt when it's ready for a new byte.
return;
}
int c = uart_tx_buf[uart_tx_r % UART_TX_BUF_SIZE];
8000084c: 00011a17 auipc s4,0x11
80000850: 9fca0a13 addi s4,s4,-1540 # 80011248 <uart_tx_lock>
uart_tx_r += 1;
80000854: 00008497 auipc s1,0x8
80000858: 7b448493 addi s1,s1,1972 # 80009008 <uart_tx_r>
if(uart_tx_w == uart_tx_r){
8000085c: 00008997 auipc s3,0x8
80000860: 7b498993 addi s3,s3,1972 # 80009010 <uart_tx_w>
if((ReadReg(LSR) & LSR_TX_IDLE) == 0){
80000864: 00594703 lbu a4,5(s2) # 10000005 <_entry-0x6ffffffb>
80000868: 02077713 andi a4,a4,32
8000086c: c705 beqz a4,80000894 <uartstart+0x72>
int c = uart_tx_buf[uart_tx_r % UART_TX_BUF_SIZE];
8000086e: 01f7f713 andi a4,a5,31
80000872: 9752 add a4,a4,s4
80000874: 01874a83 lbu s5,24(a4)
uart_tx_r += 1;
80000878: 0785 addi a5,a5,1
8000087a: e09c sd a5,0(s1)
// maybe uartputc() is waiting for space in the buffer.
wakeup(&uart_tx_r);
8000087c: 8526 mv a0,s1
8000087e: 00002097 auipc ra,0x2
80000882: aea080e7 jalr -1302(ra) # 80002368 <wakeup>
WriteReg(THR, c);
80000886: 01590023 sb s5,0(s2)
if(uart_tx_w == uart_tx_r){
8000088a: 609c ld a5,0(s1)
8000088c: 0009b703 ld a4,0(s3)
80000890: fcf71ae3 bne a4,a5,80000864 <uartstart+0x42>
}
}
80000894: 70e2 ld ra,56(sp)
80000896: 7442 ld s0,48(sp)
80000898: 74a2 ld s1,40(sp)
8000089a: 7902 ld s2,32(sp)
8000089c: 69e2 ld s3,24(sp)
8000089e: 6a42 ld s4,16(sp)
800008a0: 6aa2 ld s5,8(sp)
800008a2: 6121 addi sp,sp,64
800008a4: 8082 ret
800008a6: 8082 ret
00000000800008a8 <uartputc>:
{
800008a8: 7179 addi sp,sp,-48
800008aa: f406 sd ra,40(sp)
800008ac: f022 sd s0,32(sp)
800008ae: ec26 sd s1,24(sp)
800008b0: e84a sd s2,16(sp)
800008b2: e44e sd s3,8(sp)
800008b4: e052 sd s4,0(sp)
800008b6: 1800 addi s0,sp,48
800008b8: 8a2a mv s4,a0
acquire(&uart_tx_lock);
800008ba: 00011517 auipc a0,0x11
800008be: 98e50513 addi a0,a0,-1650 # 80011248 <uart_tx_lock>
800008c2: 00000097 auipc ra,0x0
800008c6: 300080e7 jalr 768(ra) # 80000bc2 <acquire>
if(panicked){
800008ca: 00008797 auipc a5,0x8
800008ce: 7367a783 lw a5,1846(a5) # 80009000 <panicked>
800008d2: c391 beqz a5,800008d6 <uartputc+0x2e>
for(;;)
800008d4: a001 j 800008d4 <uartputc+0x2c>
if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
800008d6: 00008717 auipc a4,0x8
800008da: 73a73703 ld a4,1850(a4) # 80009010 <uart_tx_w>
800008de: 00008797 auipc a5,0x8
800008e2: 72a7b783 ld a5,1834(a5) # 80009008 <uart_tx_r>
800008e6: 02078793 addi a5,a5,32
800008ea: 02e79b63 bne a5,a4,80000920 <uartputc+0x78>
sleep(&uart_tx_r, &uart_tx_lock);
800008ee: 00011997 auipc s3,0x11
800008f2: 95a98993 addi s3,s3,-1702 # 80011248 <uart_tx_lock>
800008f6: 00008497 auipc s1,0x8
800008fa: 71248493 addi s1,s1,1810 # 80009008 <uart_tx_r>
if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
800008fe: 00008917 auipc s2,0x8
80000902: 71290913 addi s2,s2,1810 # 80009010 <uart_tx_w>
sleep(&uart_tx_r, &uart_tx_lock);
80000906: 85ce mv a1,s3
80000908: 8526 mv a0,s1
8000090a: 00001097 auipc ra,0x1
8000090e: 7ea080e7 jalr 2026(ra) # 800020f4 <sleep>
if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
80000912: 00093703 ld a4,0(s2)
80000916: 609c ld a5,0(s1)
80000918: 02078793 addi a5,a5,32
8000091c: fee785e3 beq a5,a4,80000906 <uartputc+0x5e>
uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE] = c;
80000920: 00011497 auipc s1,0x11
80000924: 92848493 addi s1,s1,-1752 # 80011248 <uart_tx_lock>
80000928: 01f77793 andi a5,a4,31
8000092c: 97a6 add a5,a5,s1
8000092e: 01478c23 sb s4,24(a5)
uart_tx_w += 1;
80000932: 0705 addi a4,a4,1
80000934: 00008797 auipc a5,0x8
80000938: 6ce7be23 sd a4,1756(a5) # 80009010 <uart_tx_w>
uartstart();
8000093c: 00000097 auipc ra,0x0
80000940: ee6080e7 jalr -282(ra) # 80000822 <uartstart>
release(&uart_tx_lock);
80000944: 8526 mv a0,s1
80000946: 00000097 auipc ra,0x0
8000094a: 330080e7 jalr 816(ra) # 80000c76 <release>
}
8000094e: 70a2 ld ra,40(sp)
80000950: 7402 ld s0,32(sp)
80000952: 64e2 ld s1,24(sp)
80000954: 6942 ld s2,16(sp)
80000956: 69a2 ld s3,8(sp)
80000958: 6a02 ld s4,0(sp)
8000095a: 6145 addi sp,sp,48
8000095c: 8082 ret
000000008000095e <uartgetc>:
// read one input character from the UART.
// return -1 if none is waiting.
int
uartgetc(void)
{
8000095e: 1141 addi sp,sp,-16
80000960: e422 sd s0,8(sp)
80000962: 0800 addi s0,sp,16
if(ReadReg(LSR) & 0x01){
80000964: 100007b7 lui a5,0x10000
80000968: 0057c783 lbu a5,5(a5) # 10000005 <_entry-0x6ffffffb>
8000096c: 8b85 andi a5,a5,1
8000096e: cb91 beqz a5,80000982 <uartgetc+0x24>
// input data is ready.
return ReadReg(RHR);
80000970: 100007b7 lui a5,0x10000
80000974: 0007c503 lbu a0,0(a5) # 10000000 <_entry-0x70000000>
80000978: 0ff57513 andi a0,a0,255
} else {
return -1;
}
}
8000097c: 6422 ld s0,8(sp)
8000097e: 0141 addi sp,sp,16
80000980: 8082 ret
return -1;
80000982: 557d li a0,-1
80000984: bfe5 j 8000097c <uartgetc+0x1e>
0000000080000986 <uartintr>:
// handle a uart interrupt, raised because input has
// arrived, or the uart is ready for more output, or
// both. called from trap.c.
void
uartintr(void)
{
80000986: 1101 addi sp,sp,-32
80000988: ec06 sd ra,24(sp)
8000098a: e822 sd s0,16(sp)
8000098c: e426 sd s1,8(sp)
8000098e: 1000 addi s0,sp,32
// read and process incoming characters.
while(1){
int c = uartgetc();
if(c == -1)
80000990: 54fd li s1,-1
80000992: a029 j 8000099c <uartintr+0x16>
break;
consoleintr(c);
80000994: 00000097 auipc ra,0x0
80000998: 916080e7 jalr -1770(ra) # 800002aa <consoleintr>
int c = uartgetc();
8000099c: 00000097 auipc ra,0x0
800009a0: fc2080e7 jalr -62(ra) # 8000095e <uartgetc>
if(c == -1)
800009a4: fe9518e3 bne a0,s1,80000994 <uartintr+0xe>
}
// send buffered characters.
acquire(&uart_tx_lock);
800009a8: 00011497 auipc s1,0x11
800009ac: 8a048493 addi s1,s1,-1888 # 80011248 <uart_tx_lock>
800009b0: 8526 mv a0,s1
800009b2: 00000097 auipc ra,0x0
800009b6: 210080e7 jalr 528(ra) # 80000bc2 <acquire>
uartstart();
800009ba: 00000097 auipc ra,0x0
800009be: e68080e7 jalr -408(ra) # 80000822 <uartstart>
release(&uart_tx_lock);
800009c2: 8526 mv a0,s1
800009c4: 00000097 auipc ra,0x0
800009c8: 2b2080e7 jalr 690(ra) # 80000c76 <release>
}
800009cc: 60e2 ld ra,24(sp)
800009ce: 6442 ld s0,16(sp)
800009d0: 64a2 ld s1,8(sp)
800009d2: 6105 addi sp,sp,32
800009d4: 8082 ret
00000000800009d6 <kfree>:
// which normally should have been returned by a
// call to kalloc(). (The exception is when
// initializing the allocator; see kinit above.)
void
kfree(void *pa)
{
800009d6: 1101 addi sp,sp,-32
800009d8: ec06 sd ra,24(sp)
800009da: e822 sd s0,16(sp)
800009dc: e426 sd s1,8(sp)
800009de: e04a sd s2,0(sp)
800009e0: 1000 addi s0,sp,32
struct run *r;
if(((uint64)pa % PGSIZE) != 0 || (char*)pa < end || (uint64)pa >= PHYSTOP)
800009e2: 03451793 slli a5,a0,0x34
800009e6: ebb9 bnez a5,80000a3c <kfree+0x66>
800009e8: 84aa mv s1,a0
800009ea: 00026797 auipc a5,0x26
800009ee: 61678793 addi a5,a5,1558 # 80027000 <end>
800009f2: 04f56563 bltu a0,a5,80000a3c <kfree+0x66>
800009f6: 47c5 li a5,17
800009f8: 07ee slli a5,a5,0x1b
800009fa: 04f57163 bgeu a0,a5,80000a3c <kfree+0x66>
panic("kfree");
// Fill with junk to catch dangling refs.
memset(pa, 1, PGSIZE);
800009fe: 6605 lui a2,0x1
80000a00: 4585 li a1,1
80000a02: 00000097 auipc ra,0x0
80000a06: 2bc080e7 jalr 700(ra) # 80000cbe <memset>
r = (struct run*)pa;
acquire(&kmem.lock);
80000a0a: 00011917 auipc s2,0x11
80000a0e: 87690913 addi s2,s2,-1930 # 80011280 <kmem>
80000a12: 854a mv a0,s2
80000a14: 00000097 auipc ra,0x0
80000a18: 1ae080e7 jalr 430(ra) # 80000bc2 <acquire>
r->next = kmem.freelist;
80000a1c: 01893783 ld a5,24(s2)
80000a20: e09c sd a5,0(s1)
kmem.freelist = r;
80000a22: 00993c23 sd s1,24(s2)
release(&kmem.lock);
80000a26: 854a mv a0,s2
80000a28: 00000097 auipc ra,0x0
80000a2c: 24e080e7 jalr 590(ra) # 80000c76 <release>
}
80000a30: 60e2 ld ra,24(sp)
80000a32: 6442 ld s0,16(sp)
80000a34: 64a2 ld s1,8(sp)
80000a36: 6902 ld s2,0(sp)
80000a38: 6105 addi sp,sp,32
80000a3a: 8082 ret
panic("kfree");
80000a3c: 00007517 auipc a0,0x7
80000a40: 62450513 addi a0,a0,1572 # 80008060 <digits+0x20>
80000a44: 00000097 auipc ra,0x0
80000a48: ae6080e7 jalr -1306(ra) # 8000052a <panic>
0000000080000a4c <freerange>:
{
80000a4c: 7179 addi sp,sp,-48
80000a4e: f406 sd ra,40(sp)
80000a50: f022 sd s0,32(sp)
80000a52: ec26 sd s1,24(sp)
80000a54: e84a sd s2,16(sp)
80000a56: e44e sd s3,8(sp)
80000a58: e052 sd s4,0(sp)
80000a5a: 1800 addi s0,sp,48
p = (char*)PGROUNDUP((uint64)pa_start);
80000a5c: 6785 lui a5,0x1
80000a5e: fff78493 addi s1,a5,-1 # fff <_entry-0x7ffff001>
80000a62: 94aa add s1,s1,a0
80000a64: 757d lui a0,0xfffff
80000a66: 8ce9 and s1,s1,a0
for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
80000a68: 94be add s1,s1,a5
80000a6a: 0095ee63 bltu a1,s1,80000a86 <freerange+0x3a>
80000a6e: 892e mv s2,a1
kfree(p);
80000a70: 7a7d lui s4,0xfffff
for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
80000a72: 6985 lui s3,0x1
kfree(p);
80000a74: 01448533 add a0,s1,s4
80000a78: 00000097 auipc ra,0x0
80000a7c: f5e080e7 jalr -162(ra) # 800009d6 <kfree>
for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
80000a80: 94ce add s1,s1,s3
80000a82: fe9979e3 bgeu s2,s1,80000a74 <freerange+0x28>
}
80000a86: 70a2 ld ra,40(sp)
80000a88: 7402 ld s0,32(sp)
80000a8a: 64e2 ld s1,24(sp)
80000a8c: 6942 ld s2,16(sp)
80000a8e: 69a2 ld s3,8(sp)
80000a90: 6a02 ld s4,0(sp)
80000a92: 6145 addi sp,sp,48
80000a94: 8082 ret
0000000080000a96 <kinit>:
{
80000a96: 1141 addi sp,sp,-16
80000a98: e406 sd ra,8(sp)
80000a9a: e022 sd s0,0(sp)
80000a9c: 0800 addi s0,sp,16
initlock(&kmem.lock, "kmem");
80000a9e: 00007597 auipc a1,0x7
80000aa2: 5ca58593 addi a1,a1,1482 # 80008068 <digits+0x28>
80000aa6: 00010517 auipc a0,0x10
80000aaa: 7da50513 addi a0,a0,2010 # 80011280 <kmem>
80000aae: 00000097 auipc ra,0x0
80000ab2: 084080e7 jalr 132(ra) # 80000b32 <initlock>
freerange(end, (void*)PHYSTOP);
80000ab6: 45c5 li a1,17
80000ab8: 05ee slli a1,a1,0x1b
80000aba: 00026517 auipc a0,0x26
80000abe: 54650513 addi a0,a0,1350 # 80027000 <end>
80000ac2: 00000097 auipc ra,0x0
80000ac6: f8a080e7 jalr -118(ra) # 80000a4c <freerange>
}
80000aca: 60a2 ld ra,8(sp)
80000acc: 6402 ld s0,0(sp)
80000ace: 0141 addi sp,sp,16
80000ad0: 8082 ret
0000000080000ad2 <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.
void *
kalloc(void)
{
80000ad2: 1101 addi sp,sp,-32
80000ad4: ec06 sd ra,24(sp)
80000ad6: e822 sd s0,16(sp)
80000ad8: e426 sd s1,8(sp)
80000ada: 1000 addi s0,sp,32
struct run *r;
acquire(&kmem.lock);
80000adc: 00010497 auipc s1,0x10
80000ae0: 7a448493 addi s1,s1,1956 # 80011280 <kmem>
80000ae4: 8526 mv a0,s1
80000ae6: 00000097 auipc ra,0x0
80000aea: 0dc080e7 jalr 220(ra) # 80000bc2 <acquire>
r = kmem.freelist;
80000aee: 6c84 ld s1,24(s1)
if(r)
80000af0: c885 beqz s1,80000b20 <kalloc+0x4e>
kmem.freelist = r->next;
80000af2: 609c ld a5,0(s1)
80000af4: 00010517 auipc a0,0x10
80000af8: 78c50513 addi a0,a0,1932 # 80011280 <kmem>
80000afc: ed1c sd a5,24(a0)
release(&kmem.lock);
80000afe: 00000097 auipc ra,0x0
80000b02: 178080e7 jalr 376(ra) # 80000c76 <release>
if(r)
memset((char*)r, 5, PGSIZE); // fill with junk
80000b06: 6605 lui a2,0x1
80000b08: 4595 li a1,5
80000b0a: 8526 mv a0,s1
80000b0c: 00000097 auipc ra,0x0
80000b10: 1b2080e7 jalr 434(ra) # 80000cbe <memset>
return (void*)r;
}
80000b14: 8526 mv a0,s1
80000b16: 60e2 ld ra,24(sp)
80000b18: 6442 ld s0,16(sp)
80000b1a: 64a2 ld s1,8(sp)
80000b1c: 6105 addi sp,sp,32
80000b1e: 8082 ret
release(&kmem.lock);
80000b20: 00010517 auipc a0,0x10
80000b24: 76050513 addi a0,a0,1888 # 80011280 <kmem>
80000b28: 00000097 auipc ra,0x0
80000b2c: 14e080e7 jalr 334(ra) # 80000c76 <release>
if(r)
80000b30: b7d5 j 80000b14 <kalloc+0x42>
0000000080000b32 <initlock>:
#include "proc.h"
#include "defs.h"
void
initlock(struct spinlock *lk, char *name)
{
80000b32: 1141 addi sp,sp,-16
80000b34: e422 sd s0,8(sp)
80000b36: 0800 addi s0,sp,16
lk->name = name;
80000b38: e50c sd a1,8(a0)
lk->locked = 0;
80000b3a: 00052023 sw zero,0(a0)
lk->cpu = 0;
80000b3e: 00053823 sd zero,16(a0)
}
80000b42: 6422 ld s0,8(sp)
80000b44: 0141 addi sp,sp,16
80000b46: 8082 ret
0000000080000b48 <holding>:
// Interrupts must be off.
int
holding(struct spinlock *lk)
{
int r;
r = (lk->locked && lk->cpu == mycpu());
80000b48: 411c lw a5,0(a0)
80000b4a: e399 bnez a5,80000b50 <holding+0x8>
80000b4c: 4501 li a0,0
return r;
}
80000b4e: 8082 ret
{
80000b50: 1101 addi sp,sp,-32
80000b52: ec06 sd ra,24(sp)
80000b54: e822 sd s0,16(sp)
80000b56: e426 sd s1,8(sp)
80000b58: 1000 addi s0,sp,32
r = (lk->locked && lk->cpu == mycpu());
80000b5a: 6904 ld s1,16(a0)
80000b5c: 00001097 auipc ra,0x1
80000b60: e06080e7 jalr -506(ra) # 80001962 <mycpu>
80000b64: 40a48533 sub a0,s1,a0
80000b68: 00153513 seqz a0,a0
}
80000b6c: 60e2 ld ra,24(sp)
80000b6e: 6442 ld s0,16(sp)
80000b70: 64a2 ld s1,8(sp)
80000b72: 6105 addi sp,sp,32
80000b74: 8082 ret
0000000080000b76 <push_off>:
// it takes two pop_off()s to undo two push_off()s. Also, if interrupts
// are initially off, then push_off, pop_off leaves them off.
void
push_off(void)
{
80000b76: 1101 addi sp,sp,-32
80000b78: ec06 sd ra,24(sp)
80000b7a: e822 sd s0,16(sp)
80000b7c: e426 sd s1,8(sp)
80000b7e: 1000 addi s0,sp,32
asm volatile("csrr %0, sstatus" : "=r" (x) );
80000b80: 100024f3 csrr s1,sstatus
80000b84: 100027f3 csrr a5,sstatus
w_sstatus(r_sstatus() & ~SSTATUS_SIE);
80000b88: 9bf5 andi a5,a5,-3
asm volatile("csrw sstatus, %0" : : "r" (x));
80000b8a: 10079073 csrw sstatus,a5
int old = intr_get();
intr_off();
if(mycpu()->noff == 0)
80000b8e: 00001097 auipc ra,0x1
80000b92: dd4080e7 jalr -556(ra) # 80001962 <mycpu>
80000b96: 5d3c lw a5,120(a0)
80000b98: cf89 beqz a5,80000bb2 <push_off+0x3c>
mycpu()->intena = old;
mycpu()->noff += 1;
80000b9a: 00001097 auipc ra,0x1
80000b9e: dc8080e7 jalr -568(ra) # 80001962 <mycpu>
80000ba2: 5d3c lw a5,120(a0)
80000ba4: 2785 addiw a5,a5,1
80000ba6: dd3c sw a5,120(a0)
}
80000ba8: 60e2 ld ra,24(sp)
80000baa: 6442 ld s0,16(sp)
80000bac: 64a2 ld s1,8(sp)
80000bae: 6105 addi sp,sp,32
80000bb0: 8082 ret
mycpu()->intena = old;
80000bb2: 00001097 auipc ra,0x1
80000bb6: db0080e7 jalr -592(ra) # 80001962 <mycpu>
return (x & SSTATUS_SIE) != 0;
80000bba: 8085 srli s1,s1,0x1
80000bbc: 8885 andi s1,s1,1
80000bbe: dd64 sw s1,124(a0)
80000bc0: bfe9 j 80000b9a <push_off+0x24>
0000000080000bc2 <acquire>:
{
80000bc2: 1101 addi sp,sp,-32
80000bc4: ec06 sd ra,24(sp)
80000bc6: e822 sd s0,16(sp)
80000bc8: e426 sd s1,8(sp)
80000bca: 1000 addi s0,sp,32
80000bcc: 84aa mv s1,a0
push_off(); // disable interrupts to avoid deadlock.
80000bce: 00000097 auipc ra,0x0
80000bd2: fa8080e7 jalr -88(ra) # 80000b76 <push_off>
if(holding(lk))
80000bd6: 8526 mv a0,s1
80000bd8: 00000097 auipc ra,0x0
80000bdc: f70080e7 jalr -144(ra) # 80000b48 <holding>
while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
80000be0: 4705 li a4,1
if(holding(lk))
80000be2: e115 bnez a0,80000c06 <acquire+0x44>
while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
80000be4: 87ba mv a5,a4
80000be6: 0cf4a7af amoswap.w.aq a5,a5,(s1)
80000bea: 2781 sext.w a5,a5
80000bec: ffe5 bnez a5,80000be4 <acquire+0x22>
__sync_synchronize();
80000bee: 0ff0000f fence
lk->cpu = mycpu();
80000bf2: 00001097 auipc ra,0x1
80000bf6: d70080e7 jalr -656(ra) # 80001962 <mycpu>
80000bfa: e888 sd a0,16(s1)
}
80000bfc: 60e2 ld ra,24(sp)
80000bfe: 6442 ld s0,16(sp)
80000c00: 64a2 ld s1,8(sp)
80000c02: 6105 addi sp,sp,32
80000c04: 8082 ret
panic("acquire");
80000c06: 00007517 auipc a0,0x7
80000c0a: 46a50513 addi a0,a0,1130 # 80008070 <digits+0x30>
80000c0e: 00000097 auipc ra,0x0
80000c12: 91c080e7 jalr -1764(ra) # 8000052a <panic>
0000000080000c16 <pop_off>:
void
pop_off(void)
{
80000c16: 1141 addi sp,sp,-16
80000c18: e406 sd ra,8(sp)
80000c1a: e022 sd s0,0(sp)
80000c1c: 0800 addi s0,sp,16
struct cpu *c = mycpu();
80000c1e: 00001097 auipc ra,0x1
80000c22: d44080e7 jalr -700(ra) # 80001962 <mycpu>
asm volatile("csrr %0, sstatus" : "=r" (x) );
80000c26: 100027f3 csrr a5,sstatus
return (x & SSTATUS_SIE) != 0;
80000c2a: 8b89 andi a5,a5,2
if(intr_get())
80000c2c: e78d bnez a5,80000c56 <pop_off+0x40>
panic("pop_off - interruptible");
if(c->noff < 1)
80000c2e: 5d3c lw a5,120(a0)
80000c30: 02f05b63 blez a5,80000c66 <pop_off+0x50>
panic("pop_off");
c->noff -= 1;
80000c34: 37fd addiw a5,a5,-1
80000c36: 0007871b sext.w a4,a5
80000c3a: dd3c sw a5,120(a0)
if(c->noff == 0 && c->intena)
80000c3c: eb09 bnez a4,80000c4e <pop_off+0x38>
80000c3e: 5d7c lw a5,124(a0)
80000c40: c799 beqz a5,80000c4e <pop_off+0x38>
asm volatile("csrr %0, sstatus" : "=r" (x) );
80000c42: 100027f3 csrr a5,sstatus
w_sstatus(r_sstatus() | SSTATUS_SIE);
80000c46: 0027e793 ori a5,a5,2
asm volatile("csrw sstatus, %0" : : "r" (x));
80000c4a: 10079073 csrw sstatus,a5
intr_on();
}
80000c4e: 60a2 ld ra,8(sp)
80000c50: 6402 ld s0,0(sp)
80000c52: 0141 addi sp,sp,16
80000c54: 8082 ret
panic("pop_off - interruptible");
80000c56: 00007517 auipc a0,0x7
80000c5a: 42250513 addi a0,a0,1058 # 80008078 <digits+0x38>
80000c5e: 00000097 auipc ra,0x0
80000c62: 8cc080e7 jalr -1844(ra) # 8000052a <panic>
panic("pop_off");
80000c66: 00007517 auipc a0,0x7
80000c6a: 42a50513 addi a0,a0,1066 # 80008090 <digits+0x50>
80000c6e: 00000097 auipc ra,0x0
80000c72: 8bc080e7 jalr -1860(ra) # 8000052a <panic>
0000000080000c76 <release>:
{
80000c76: 1101 addi sp,sp,-32
80000c78: ec06 sd ra,24(sp)
80000c7a: e822 sd s0,16(sp)
80000c7c: e426 sd s1,8(sp)
80000c7e: 1000 addi s0,sp,32
80000c80: 84aa mv s1,a0
if(!holding(lk))
80000c82: 00000097 auipc ra,0x0
80000c86: ec6080e7 jalr -314(ra) # 80000b48 <holding>
80000c8a: c115 beqz a0,80000cae <release+0x38>
lk->cpu = 0;
80000c8c: 0004b823 sd zero,16(s1)
__sync_synchronize();
80000c90: 0ff0000f fence
__sync_lock_release(&lk->locked);
80000c94: 0f50000f fence iorw,ow
80000c98: 0804a02f amoswap.w zero,zero,(s1)
pop_off();
80000c9c: 00000097 auipc ra,0x0
80000ca0: f7a080e7 jalr -134(ra) # 80000c16 <pop_off>
}
80000ca4: 60e2 ld ra,24(sp)
80000ca6: 6442 ld s0,16(sp)
80000ca8: 64a2 ld s1,8(sp)
80000caa: 6105 addi sp,sp,32
80000cac: 8082 ret
panic("release");
80000cae: 00007517 auipc a0,0x7
80000cb2: 3ea50513 addi a0,a0,1002 # 80008098 <digits+0x58>
80000cb6: 00000097 auipc ra,0x0
80000cba: 874080e7 jalr -1932(ra) # 8000052a <panic>
0000000080000cbe <memset>:
#include "types.h"
void*
memset(void *dst, int c, uint n)
{
80000cbe: 1141 addi sp,sp,-16
80000cc0: e422 sd s0,8(sp)
80000cc2: 0800 addi s0,sp,16
char *cdst = (char *) dst;
int i;
for(i = 0; i < n; i++){
80000cc4: ca19 beqz a2,80000cda <memset+0x1c>
80000cc6: 87aa mv a5,a0
80000cc8: 1602 slli a2,a2,0x20
80000cca: 9201 srli a2,a2,0x20
80000ccc: 00a60733 add a4,a2,a0
cdst[i] = c;
80000cd0: 00b78023 sb a1,0(a5)
for(i = 0; i < n; i++){
80000cd4: 0785 addi a5,a5,1
80000cd6: fee79de3 bne a5,a4,80000cd0 <memset+0x12>
}
return dst;
}
80000cda: 6422 ld s0,8(sp)
80000cdc: 0141 addi sp,sp,16
80000cde: 8082 ret
0000000080000ce0 <memcmp>:
int
memcmp(const void *v1, const void *v2, uint n)
{
80000ce0: 1141 addi sp,sp,-16
80000ce2: e422 sd s0,8(sp)
80000ce4: 0800 addi s0,sp,16
const uchar *s1, *s2;
s1 = v1;
s2 = v2;
while(n-- > 0){
80000ce6: ca05 beqz a2,80000d16 <memcmp+0x36>
80000ce8: fff6069b addiw a3,a2,-1
80000cec: 1682 slli a3,a3,0x20
80000cee: 9281 srli a3,a3,0x20
80000cf0: 0685 addi a3,a3,1
80000cf2: 96aa add a3,a3,a0
if(*s1 != *s2)
80000cf4: 00054783 lbu a5,0(a0)
80000cf8: 0005c703 lbu a4,0(a1)
80000cfc: 00e79863 bne a5,a4,80000d0c <memcmp+0x2c>
return *s1 - *s2;
s1++, s2++;
80000d00: 0505 addi a0,a0,1
80000d02: 0585 addi a1,a1,1
while(n-- > 0){
80000d04: fed518e3 bne a0,a3,80000cf4 <memcmp+0x14>
}
return 0;
80000d08: 4501 li a0,0
80000d0a: a019 j 80000d10 <memcmp+0x30>
return *s1 - *s2;
80000d0c: 40e7853b subw a0,a5,a4
}
80000d10: 6422 ld s0,8(sp)
80000d12: 0141 addi sp,sp,16
80000d14: 8082 ret
return 0;
80000d16: 4501 li a0,0
80000d18: bfe5 j 80000d10 <memcmp+0x30>
0000000080000d1a <memmove>:
void*
memmove(void *dst, const void *src, uint n)
{
80000d1a: 1141 addi sp,sp,-16
80000d1c: e422 sd s0,8(sp)
80000d1e: 0800 addi s0,sp,16
const char *s;
char *d;
s = src;
d = dst;
if(s < d && s + n > d){
80000d20: 02a5e563 bltu a1,a0,80000d4a <memmove+0x30>
s += n;
d += n;
while(n-- > 0)
*--d = *--s;
} else
while(n-- > 0)
80000d24: fff6069b addiw a3,a2,-1
80000d28: ce11 beqz a2,80000d44 <memmove+0x2a>
80000d2a: 1682 slli a3,a3,0x20
80000d2c: 9281 srli a3,a3,0x20
80000d2e: 0685 addi a3,a3,1
80000d30: 96ae add a3,a3,a1
80000d32: 87aa mv a5,a0
*d++ = *s++;
80000d34: 0585 addi a1,a1,1
80000d36: 0785 addi a5,a5,1
80000d38: fff5c703 lbu a4,-1(a1)
80000d3c: fee78fa3 sb a4,-1(a5)
while(n-- > 0)
80000d40: fed59ae3 bne a1,a3,80000d34 <memmove+0x1a>
return dst;
}
80000d44: 6422 ld s0,8(sp)
80000d46: 0141 addi sp,sp,16
80000d48: 8082 ret
if(s < d && s + n > d){
80000d4a: 02061713 slli a4,a2,0x20
80000d4e: 9301 srli a4,a4,0x20
80000d50: 00e587b3 add a5,a1,a4
80000d54: fcf578e3 bgeu a0,a5,80000d24 <memmove+0xa>
d += n;
80000d58: 972a add a4,a4,a0
while(n-- > 0)
80000d5a: fff6069b addiw a3,a2,-1
80000d5e: d27d beqz a2,80000d44 <memmove+0x2a>
80000d60: 02069613 slli a2,a3,0x20
80000d64: 9201 srli a2,a2,0x20
80000d66: fff64613 not a2,a2
80000d6a: 963e add a2,a2,a5
*--d = *--s;
80000d6c: 17fd addi a5,a5,-1
80000d6e: 177d addi a4,a4,-1
80000d70: 0007c683 lbu a3,0(a5)
80000d74: 00d70023 sb a3,0(a4)
while(n-- > 0)
80000d78: fef61ae3 bne a2,a5,80000d6c <memmove+0x52>
80000d7c: b7e1 j 80000d44 <memmove+0x2a>
0000000080000d7e <memcpy>:
// memcpy exists to placate GCC. Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
80000d7e: 1141 addi sp,sp,-16
80000d80: e406 sd ra,8(sp)
80000d82: e022 sd s0,0(sp)
80000d84: 0800 addi s0,sp,16
return memmove(dst, src, n);
80000d86: 00000097 auipc ra,0x0
80000d8a: f94080e7 jalr -108(ra) # 80000d1a <memmove>
}
80000d8e: 60a2 ld ra,8(sp)
80000d90: 6402 ld s0,0(sp)
80000d92: 0141 addi sp,sp,16
80000d94: 8082 ret
0000000080000d96 <strncmp>:
int
strncmp(const char *p, const char *q, uint n)
{
80000d96: 1141 addi sp,sp,-16
80000d98: e422 sd s0,8(sp)
80000d9a: 0800 addi s0,sp,16
while(n > 0 && *p && *p == *q)
80000d9c: ce11 beqz a2,80000db8 <strncmp+0x22>
80000d9e: 00054783 lbu a5,0(a0)
80000da2: cf89 beqz a5,80000dbc <strncmp+0x26>
80000da4: 0005c703 lbu a4,0(a1)
80000da8: 00f71a63 bne a4,a5,80000dbc <strncmp+0x26>
n--, p++, q++;
80000dac: 367d addiw a2,a2,-1
80000dae: 0505 addi a0,a0,1
80000db0: 0585 addi a1,a1,1
while(n > 0 && *p && *p == *q)
80000db2: f675 bnez a2,80000d9e <strncmp+0x8>
if(n == 0)
return 0;
80000db4: 4501 li a0,0
80000db6: a809 j 80000dc8 <strncmp+0x32>
80000db8: 4501 li a0,0
80000dba: a039 j 80000dc8 <strncmp+0x32>
if(n == 0)
80000dbc: ca09 beqz a2,80000dce <strncmp+0x38>
return (uchar)*p - (uchar)*q;
80000dbe: 00054503 lbu a0,0(a0)
80000dc2: 0005c783 lbu a5,0(a1)
80000dc6: 9d1d subw a0,a0,a5
}
80000dc8: 6422 ld s0,8(sp)
80000dca: 0141 addi sp,sp,16
80000dcc: 8082 ret
return 0;
80000dce: 4501 li a0,0
80000dd0: bfe5 j 80000dc8 <strncmp+0x32>
0000000080000dd2 <strncpy>:
char*
strncpy(char *s, const char *t, int n)
{
80000dd2: 1141 addi sp,sp,-16
80000dd4: e422 sd s0,8(sp)
80000dd6: 0800 addi s0,sp,16
char *os;
os = s;
while(n-- > 0 && (*s++ = *t++) != 0)
80000dd8: 872a mv a4,a0
80000dda: 8832 mv a6,a2
80000ddc: 367d addiw a2,a2,-1
80000dde: 01005963 blez a6,80000df0 <strncpy+0x1e>
80000de2: 0705 addi a4,a4,1
80000de4: 0005c783 lbu a5,0(a1)
80000de8: fef70fa3 sb a5,-1(a4)
80000dec: 0585 addi a1,a1,1
80000dee: f7f5 bnez a5,80000dda <strncpy+0x8>
;
while(n-- > 0)
80000df0: 86ba mv a3,a4
80000df2: 00c05c63 blez a2,80000e0a <strncpy+0x38>
*s++ = 0;
80000df6: 0685 addi a3,a3,1
80000df8: fe068fa3 sb zero,-1(a3)
while(n-- > 0)
80000dfc: fff6c793 not a5,a3
80000e00: 9fb9 addw a5,a5,a4
80000e02: 010787bb addw a5,a5,a6
80000e06: fef048e3 bgtz a5,80000df6 <strncpy+0x24>
return os;
}
80000e0a: 6422 ld s0,8(sp)
80000e0c: 0141 addi sp,sp,16
80000e0e: 8082 ret
0000000080000e10 <safestrcpy>:
// Like strncpy but guaranteed to NUL-terminate.
char*
safestrcpy(char *s, const char *t, int n)
{
80000e10: 1141 addi sp,sp,-16
80000e12: e422 sd s0,8(sp)
80000e14: 0800 addi s0,sp,16
char *os;
os = s;
if(n <= 0)
80000e16: 02c05363 blez a2,80000e3c <safestrcpy+0x2c>
80000e1a: fff6069b addiw a3,a2,-1
80000e1e: 1682 slli a3,a3,0x20
80000e20: 9281 srli a3,a3,0x20
80000e22: 96ae add a3,a3,a1
80000e24: 87aa mv a5,a0
return os;
while(--n > 0 && (*s++ = *t++) != 0)
80000e26: 00d58963 beq a1,a3,80000e38 <safestrcpy+0x28>
80000e2a: 0585 addi a1,a1,1
80000e2c: 0785 addi a5,a5,1
80000e2e: fff5c703 lbu a4,-1(a1)
80000e32: fee78fa3 sb a4,-1(a5)
80000e36: fb65 bnez a4,80000e26 <safestrcpy+0x16>
;
*s = 0;
80000e38: 00078023 sb zero,0(a5)
return os;
}
80000e3c: 6422 ld s0,8(sp)
80000e3e: 0141 addi sp,sp,16
80000e40: 8082 ret
0000000080000e42 <strlen>:
int
strlen(const char *s)
{
80000e42: 1141 addi sp,sp,-16
80000e44: e422 sd s0,8(sp)
80000e46: 0800 addi s0,sp,16
int n;
for(n = 0; s[n]; n++)
80000e48: 00054783 lbu a5,0(a0)
80000e4c: cf91 beqz a5,80000e68 <strlen+0x26>
80000e4e: 0505 addi a0,a0,1
80000e50: 87aa mv a5,a0
80000e52: 4685 li a3,1
80000e54: 9e89 subw a3,a3,a0
80000e56: 00f6853b addw a0,a3,a5
80000e5a: 0785 addi a5,a5,1
80000e5c: fff7c703 lbu a4,-1(a5)
80000e60: fb7d bnez a4,80000e56 <strlen+0x14>
;
return n;
}
80000e62: 6422 ld s0,8(sp)
80000e64: 0141 addi sp,sp,16
80000e66: 8082 ret
for(n = 0; s[n]; n++)
80000e68: 4501 li a0,0
80000e6a: bfe5 j 80000e62 <strlen+0x20>
0000000080000e6c <main>:
volatile static int started = 0;
// start() jumps here in supervisor mode on all CPUs.
void
main()
{
80000e6c: 1141 addi sp,sp,-16
80000e6e: e406 sd ra,8(sp)
80000e70: e022 sd s0,0(sp)
80000e72: 0800 addi s0,sp,16
if(cpuid() == 0){
80000e74: 00001097 auipc ra,0x1
80000e78: ade080e7 jalr -1314(ra) # 80001952 <cpuid>
virtio_disk_init(); // emulated hard disk
userinit(); // first user process
__sync_synchronize();
started = 1;
} else {
while(started == 0)
80000e7c: 00008717 auipc a4,0x8
80000e80: 19c70713 addi a4,a4,412 # 80009018 <started>
if(cpuid() == 0){
80000e84: c139 beqz a0,80000eca <main+0x5e>
while(started == 0)
80000e86: 431c lw a5,0(a4)
80000e88: 2781 sext.w a5,a5
80000e8a: dff5 beqz a5,80000e86 <main+0x1a>
;
__sync_synchronize();
80000e8c: 0ff0000f fence
printf("hart %d starting\n", cpuid());
80000e90: 00001097 auipc ra,0x1
80000e94: ac2080e7 jalr -1342(ra) # 80001952 <cpuid>
80000e98: 85aa mv a1,a0
80000e9a: 00007517 auipc a0,0x7
80000e9e: 21e50513 addi a0,a0,542 # 800080b8 <digits+0x78>
80000ea2: fffff097 auipc ra,0xfffff
80000ea6: 6d2080e7 jalr 1746(ra) # 80000574 <printf>
kvminithart(); // turn on paging
80000eaa: 00000097 auipc ra,0x0
80000eae: 0d8080e7 jalr 216(ra) # 80000f82 <kvminithart>
trapinithart(); // install kernel trap vector
80000eb2: 00002097 auipc ra,0x2
80000eb6: a98080e7 jalr -1384(ra) # 8000294a <trapinithart>
plicinithart(); // ask PLIC for device interrupts
80000eba: 00005097 auipc ra,0x5
80000ebe: 1a6080e7 jalr 422(ra) # 80006060 <plicinithart>
}
scheduler();
80000ec2: 00001097 auipc ra,0x1
80000ec6: 03c080e7 jalr 60(ra) # 80001efe <scheduler>
consoleinit();
80000eca: fffff097 auipc ra,0xfffff
80000ece: 572080e7 jalr 1394(ra) # 8000043c <consoleinit>
printfinit();
80000ed2: 00000097 auipc ra,0x0
80000ed6: 882080e7 jalr -1918(ra) # 80000754 <printfinit>
printf("\n");
80000eda: 00007517 auipc a0,0x7
80000ede: 1ee50513 addi a0,a0,494 # 800080c8 <digits+0x88>
80000ee2: fffff097 auipc ra,0xfffff
80000ee6: 692080e7 jalr 1682(ra) # 80000574 <printf>
printf("xv6 kernel is booting\n");
80000eea: 00007517 auipc a0,0x7
80000eee: 1b650513 addi a0,a0,438 # 800080a0 <digits+0x60>
80000ef2: fffff097 auipc ra,0xfffff
80000ef6: 682080e7 jalr 1666(ra) # 80000574 <printf>
printf("\n");
80000efa: 00007517 auipc a0,0x7
80000efe: 1ce50513 addi a0,a0,462 # 800080c8 <digits+0x88>
80000f02: fffff097 auipc ra,0xfffff
80000f06: 672080e7 jalr 1650(ra) # 80000574 <printf>
kinit(); // physical page allocator
80000f0a: 00000097 auipc ra,0x0
80000f0e: b8c080e7 jalr -1140(ra) # 80000a96 <kinit>
kvminit(); // create kernel page table
80000f12: 00000097 auipc ra,0x0
80000f16: 310080e7 jalr 784(ra) # 80001222 <kvminit>
kvminithart(); // turn on paging
80000f1a: 00000097 auipc ra,0x0
80000f1e: 068080e7 jalr 104(ra) # 80000f82 <kvminithart>
procinit(); // process table
80000f22: 00001097 auipc ra,0x1
80000f26: 980080e7 jalr -1664(ra) # 800018a2 <procinit>
trapinit(); // trap vectors
80000f2a: 00002097 auipc ra,0x2
80000f2e: 9f8080e7 jalr -1544(ra) # 80002922 <trapinit>
trapinithart(); // install kernel trap vector
80000f32: 00002097 auipc ra,0x2
80000f36: a18080e7 jalr -1512(ra) # 8000294a <trapinithart>
plicinit(); // set up interrupt controller
80000f3a: 00005097 auipc ra,0x5
80000f3e: 110080e7 jalr 272(ra) # 8000604a <plicinit>
plicinithart(); // ask PLIC for device interrupts
80000f42: 00005097 auipc ra,0x5
80000f46: 11e080e7 jalr 286(ra) # 80006060 <plicinithart>
binit(); // buffer cache
80000f4a: 00002097 auipc ra,0x2
80000f4e: 2de080e7 jalr 734(ra) # 80003228 <binit>
iinit(); // inode cache
80000f52: 00003097 auipc ra,0x3
80000f56: 970080e7 jalr -1680(ra) # 800038c2 <iinit>
fileinit(); // file table
80000f5a: 00004097 auipc ra,0x4
80000f5e: 91e080e7 jalr -1762(ra) # 80004878 <fileinit>
virtio_disk_init(); // emulated hard disk
80000f62: 00005097 auipc ra,0x5
80000f66: 220080e7 jalr 544(ra) # 80006182 <virtio_disk_init>
userinit(); // first user process
80000f6a: 00001097 auipc ra,0x1
80000f6e: d2c080e7 jalr -724(ra) # 80001c96 <userinit>
__sync_synchronize();
80000f72: 0ff0000f fence
started = 1;
80000f76: 4785 li a5,1
80000f78: 00008717 auipc a4,0x8
80000f7c: 0af72023 sw a5,160(a4) # 80009018 <started>
80000f80: b789 j 80000ec2 <main+0x56>
0000000080000f82 <kvminithart>:
// Switch h/w page table register to the kernel's page table,
// and enable paging.
void
kvminithart()
{
80000f82: 1141 addi sp,sp,-16
80000f84: e422 sd s0,8(sp)
80000f86: 0800 addi s0,sp,16
w_satp(MAKE_SATP(kernel_pagetable));
80000f88: 00008797 auipc a5,0x8
80000f8c: 0987b783 ld a5,152(a5) # 80009020 <kernel_pagetable>
80000f90: 83b1 srli a5,a5,0xc
80000f92: 577d li a4,-1
80000f94: 177e slli a4,a4,0x3f
80000f96: 8fd9 or a5,a5,a4
asm volatile("csrw satp, %0" : : "r" (x));
80000f98: 18079073 csrw satp,a5
// flush the TLB.
static inline void
sfence_vma()
{
// the zero, zero means flush all TLB entries.
asm volatile("sfence.vma zero, zero");
80000f9c: 12000073 sfence.vma
sfence_vma();
}
80000fa0: 6422 ld s0,8(sp)
80000fa2: 0141 addi sp,sp,16
80000fa4: 8082 ret
0000000080000fa6 <walk>:
// 21..29 -- 9 bits of level-1 index.
// 12..20 -- 9 bits of level-0 index.
// 0..11 -- 12 bits of byte offset within the page.
pte_t *
walk(pagetable_t pagetable, uint64 va, int alloc)
{
80000fa6: 7139 addi sp,sp,-64
80000fa8: fc06 sd ra,56(sp)
80000faa: f822 sd s0,48(sp)
80000fac: f426 sd s1,40(sp)
80000fae: f04a sd s2,32(sp)
80000fb0: ec4e sd s3,24(sp)
80000fb2: e852 sd s4,16(sp)
80000fb4: e456 sd s5,8(sp)
80000fb6: e05a sd s6,0(sp)
80000fb8: 0080 addi s0,sp,64
80000fba: 84aa mv s1,a0
80000fbc: 89ae mv s3,a1
80000fbe: 8ab2 mv s5,a2
if(va >= MAXVA)
80000fc0: 57fd li a5,-1
80000fc2: 83e9 srli a5,a5,0x1a
80000fc4: 4a79 li s4,30
panic("walk");
for(int level = 2; level > 0; level--) {
80000fc6: 4b31 li s6,12
if(va >= MAXVA)
80000fc8: 04b7f263 bgeu a5,a1,8000100c <walk+0x66>
panic("walk");
80000fcc: 00007517 auipc a0,0x7
80000fd0: 10450513 addi a0,a0,260 # 800080d0 <digits+0x90>
80000fd4: fffff097 auipc ra,0xfffff
80000fd8: 556080e7 jalr 1366(ra) # 8000052a <panic>
pte_t *pte = &pagetable[PX(level, va)];
if(*pte & PTE_V) {
pagetable = (pagetable_t)PTE2PA(*pte);
} else {
if(!alloc || (pagetable = (pde_t*)kalloc()) == 0)
80000fdc: 060a8663 beqz s5,80001048 <walk+0xa2>
80000fe0: 00000097 auipc ra,0x0
80000fe4: af2080e7 jalr -1294(ra) # 80000ad2 <kalloc>
80000fe8: 84aa mv s1,a0
80000fea: c529 beqz a0,80001034 <walk+0x8e>
return 0;
memset(pagetable, 0, PGSIZE);
80000fec: 6605 lui a2,0x1
80000fee: 4581 li a1,0
80000ff0: 00000097 auipc ra,0x0
80000ff4: cce080e7 jalr -818(ra) # 80000cbe <memset>
*pte = PA2PTE(pagetable) | PTE_V;
80000ff8: 00c4d793 srli a5,s1,0xc
80000ffc: 07aa slli a5,a5,0xa
80000ffe: 0017e793 ori a5,a5,1
80001002: 00f93023 sd a5,0(s2)
for(int level = 2; level > 0; level--) {
80001006: 3a5d addiw s4,s4,-9
80001008: 036a0063 beq s4,s6,80001028 <walk+0x82>
pte_t *pte = &pagetable[PX(level, va)];
8000100c: 0149d933 srl s2,s3,s4
80001010: 1ff97913 andi s2,s2,511
80001014: 090e slli s2,s2,0x3
80001016: 9926 add s2,s2,s1
if(*pte & PTE_V) {
80001018: 00093483 ld s1,0(s2)
8000101c: 0014f793 andi a5,s1,1
80001020: dfd5 beqz a5,80000fdc <walk+0x36>
pagetable = (pagetable_t)PTE2PA(*pte);
80001022: 80a9 srli s1,s1,0xa
80001024: 04b2 slli s1,s1,0xc
80001026: b7c5 j 80001006 <walk+0x60>
}
}
return &pagetable[PX(0, va)];
80001028: 00c9d513 srli a0,s3,0xc
8000102c: 1ff57513 andi a0,a0,511
80001030: 050e slli a0,a0,0x3
80001032: 9526 add a0,a0,s1
}
80001034: 70e2 ld ra,56(sp)
80001036: 7442 ld s0,48(sp)
80001038: 74a2 ld s1,40(sp)
8000103a: 7902 ld s2,32(sp)
8000103c: 69e2 ld s3,24(sp)
8000103e: 6a42 ld s4,16(sp)
80001040: 6aa2 ld s5,8(sp)
80001042: 6b02 ld s6,0(sp)
80001044: 6121 addi sp,sp,64
80001046: 8082 ret
return 0;
80001048: 4501 li a0,0
8000104a: b7ed j 80001034 <walk+0x8e>
000000008000104c <walkaddr>:
walkaddr(pagetable_t pagetable, uint64 va)
{
pte_t *pte;
uint64 pa;
if(va >= MAXVA)
8000104c: 57fd li a5,-1
8000104e: 83e9 srli a5,a5,0x1a
80001050: 00b7f463 bgeu a5,a1,80001058 <walkaddr+0xc>
return 0;
80001054: 4501 li a0,0
return 0;
if((*pte & PTE_U) == 0)
return 0;
pa = PTE2PA(*pte);
return pa;
}
80001056: 8082 ret
{
80001058: 1141 addi sp,sp,-16
8000105a: e406 sd ra,8(sp)
8000105c: e022 sd s0,0(sp)
8000105e: 0800 addi s0,sp,16
pte = walk(pagetable, va, 0);
80001060: 4601 li a2,0
80001062: 00000097 auipc ra,0x0
80001066: f44080e7 jalr -188(ra) # 80000fa6 <walk>
if(pte == 0)
8000106a: c105 beqz a0,8000108a <walkaddr+0x3e>
if((*pte & PTE_V) == 0)
8000106c: 611c ld a5,0(a0)
if((*pte & PTE_U) == 0)
8000106e: 0117f693 andi a3,a5,17
80001072: 4745 li a4,17
return 0;
80001074: 4501 li a0,0
if((*pte & PTE_U) == 0)
80001076: 00e68663 beq a3,a4,80001082 <walkaddr+0x36>
}
8000107a: 60a2 ld ra,8(sp)
8000107c: 6402 ld s0,0(sp)
8000107e: 0141 addi sp,sp,16
80001080: 8082 ret
pa = PTE2PA(*pte);
80001082: 00a7d513 srli a0,a5,0xa
80001086: 0532 slli a0,a0,0xc
return pa;
80001088: bfcd j 8000107a <walkaddr+0x2e>
return 0;
8000108a: 4501 li a0,0
8000108c: b7fd j 8000107a <walkaddr+0x2e>
000000008000108e <mappages>:
// physical addresses starting at pa. va and size might not
// be page-aligned. Returns 0 on success, -1 if walk() couldn't
// allocate a needed page-table page.
int
mappages(pagetable_t pagetable, uint64 va, uint64 size, uint64 pa, int perm)
{
8000108e: 715d addi sp,sp,-80
80001090: e486 sd ra,72(sp)
80001092: e0a2 sd s0,64(sp)
80001094: fc26 sd s1,56(sp)
80001096: f84a sd s2,48(sp)
80001098: f44e sd s3,40(sp)
8000109a: f052 sd s4,32(sp)
8000109c: ec56 sd s5,24(sp)
8000109e: e85a sd s6,16(sp)
800010a0: e45e sd s7,8(sp)
800010a2: 0880 addi s0,sp,80
800010a4: 8aaa mv s5,a0
800010a6: 8b3a mv s6,a4
uint64 a, last;
pte_t *pte;
a = PGROUNDDOWN(va);
800010a8: 777d lui a4,0xfffff
800010aa: 00e5f7b3 and a5,a1,a4
last = PGROUNDDOWN(va + size - 1);
800010ae: 167d addi a2,a2,-1
800010b0: 00b609b3 add s3,a2,a1
800010b4: 00e9f9b3 and s3,s3,a4
a = PGROUNDDOWN(va);
800010b8: 893e mv s2,a5
800010ba: 40f68a33 sub s4,a3,a5
if(*pte & PTE_V)
panic("remap");
*pte = PA2PTE(pa) | perm | PTE_V;
if(a == last)
break;
a += PGSIZE;
800010be: 6b85 lui s7,0x1
800010c0: 012a04b3 add s1,s4,s2
if((pte = walk(pagetable, a, 1)) == 0)
800010c4: 4605 li a2,1
800010c6: 85ca mv a1,s2
800010c8: 8556 mv a0,s5
800010ca: 00000097 auipc ra,0x0
800010ce: edc080e7 jalr -292(ra) # 80000fa6 <walk>
800010d2: c51d beqz a0,80001100 <mappages+0x72>
if(*pte & PTE_V)
800010d4: 611c ld a5,0(a0)
800010d6: 8b85 andi a5,a5,1
800010d8: ef81 bnez a5,800010f0 <mappages+0x62>
*pte = PA2PTE(pa) | perm | PTE_V;
800010da: 80b1 srli s1,s1,0xc
800010dc: 04aa slli s1,s1,0xa
800010de: 0164e4b3 or s1,s1,s6
800010e2: 0014e493 ori s1,s1,1
800010e6: e104 sd s1,0(a0)
if(a == last)
800010e8: 03390863 beq s2,s3,80001118 <mappages+0x8a>
a += PGSIZE;
800010ec: 995e add s2,s2,s7
if((pte = walk(pagetable, a, 1)) == 0)
800010ee: bfc9 j 800010c0 <mappages+0x32>
panic("remap");
800010f0: 00007517 auipc a0,0x7
800010f4: fe850513 addi a0,a0,-24 # 800080d8 <digits+0x98>
800010f8: fffff097 auipc ra,0xfffff
800010fc: 432080e7 jalr 1074(ra) # 8000052a <panic>
return -1;
80001100: 557d li a0,-1
pa += PGSIZE;
}
return 0;
}
80001102: 60a6 ld ra,72(sp)
80001104: 6406 ld s0,64(sp)
80001106: 74e2 ld s1,56(sp)
80001108: 7942 ld s2,48(sp)
8000110a: 79a2 ld s3,40(sp)
8000110c: 7a02 ld s4,32(sp)
8000110e: 6ae2 ld s5,24(sp)
80001110: 6b42 ld s6,16(sp)
80001112: 6ba2 ld s7,8(sp)
80001114: 6161 addi sp,sp,80
80001116: 8082 ret
return 0;
80001118: 4501 li a0,0
8000111a: b7e5 j 80001102 <mappages+0x74>
000000008000111c <kvmmap>:
{
8000111c: 1141 addi sp,sp,-16
8000111e: e406 sd ra,8(sp)
80001120: e022 sd s0,0(sp)
80001122: 0800 addi s0,sp,16
80001124: 87b6 mv a5,a3
if(mappages(kpgtbl, va, sz, pa, perm) != 0)
80001126: 86b2 mv a3,a2
80001128: 863e mv a2,a5
8000112a: 00000097 auipc ra,0x0
8000112e: f64080e7 jalr -156(ra) # 8000108e <mappages>
80001132: e509 bnez a0,8000113c <kvmmap+0x20>
}
80001134: 60a2 ld ra,8(sp)
80001136: 6402 ld s0,0(sp)
80001138: 0141 addi sp,sp,16
8000113a: 8082 ret
panic("kvmmap");
8000113c: 00007517 auipc a0,0x7
80001140: fa450513 addi a0,a0,-92 # 800080e0 <digits+0xa0>
80001144: fffff097 auipc ra,0xfffff
80001148: 3e6080e7 jalr 998(ra) # 8000052a <panic>
000000008000114c <kvmmake>:
{
8000114c: 1101 addi sp,sp,-32
8000114e: ec06 sd ra,24(sp)
80001150: e822 sd s0,16(sp)
80001152: e426 sd s1,8(sp)
80001154: e04a sd s2,0(sp)
80001156: 1000 addi s0,sp,32
kpgtbl = (pagetable_t) kalloc();
80001158: 00000097 auipc ra,0x0
8000115c: 97a080e7 jalr -1670(ra) # 80000ad2 <kalloc>
80001160: 84aa mv s1,a0
memset(kpgtbl, 0, PGSIZE);
80001162: 6605 lui a2,0x1
80001164: 4581 li a1,0
80001166: 00000097 auipc ra,0x0
8000116a: b58080e7 jalr -1192(ra) # 80000cbe <memset>
kvmmap(kpgtbl, UART0, UART0, PGSIZE, PTE_R | PTE_W);
8000116e: 4719 li a4,6
80001170: 6685 lui a3,0x1
80001172: 10000637 lui a2,0x10000
80001176: 100005b7 lui a1,0x10000
8000117a: 8526 mv a0,s1
8000117c: 00000097 auipc ra,0x0
80001180: fa0080e7 jalr -96(ra) # 8000111c <kvmmap>
kvmmap(kpgtbl, VIRTIO0, VIRTIO0, PGSIZE, PTE_R | PTE_W);
80001184: 4719 li a4,6
80001186: 6685 lui a3,0x1
80001188: 10001637 lui a2,0x10001
8000118c: 100015b7 lui a1,0x10001
80001190: 8526 mv a0,s1
80001192: 00000097 auipc ra,0x0
80001196: f8a080e7 jalr -118(ra) # 8000111c <kvmmap>
kvmmap(kpgtbl, PLIC, PLIC, 0x400000, PTE_R | PTE_W);
8000119a: 4719 li a4,6
8000119c: 004006b7 lui a3,0x400
800011a0: 0c000637 lui a2,0xc000
800011a4: 0c0005b7 lui a1,0xc000
800011a8: 8526 mv a0,s1
800011aa: 00000097 auipc ra,0x0
800011ae: f72080e7 jalr -142(ra) # 8000111c <kvmmap>
kvmmap(kpgtbl, KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);
800011b2: 00007917 auipc s2,0x7
800011b6: e4e90913 addi s2,s2,-434 # 80008000 <etext>
800011ba: 4729 li a4,10
800011bc: 80007697 auipc a3,0x80007
800011c0: e4468693 addi a3,a3,-444 # 8000 <_entry-0x7fff8000>
800011c4: 4605 li a2,1
800011c6: 067e slli a2,a2,0x1f
800011c8: 85b2 mv a1,a2
800011ca: 8526 mv a0,s1
800011cc: 00000097 auipc ra,0x0
800011d0: f50080e7 jalr -176(ra) # 8000111c <kvmmap>
kvmmap(kpgtbl, (uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
800011d4: 4719 li a4,6
800011d6: 46c5 li a3,17
800011d8: 06ee slli a3,a3,0x1b
800011da: 412686b3 sub a3,a3,s2
800011de: 864a mv a2,s2
800011e0: 85ca mv a1,s2
800011e2: 8526 mv a0,s1
800011e4: 00000097 auipc ra,0x0
800011e8: f38080e7 jalr -200(ra) # 8000111c <kvmmap>
kvmmap(kpgtbl, TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
800011ec: 4729 li a4,10
800011ee: 6685 lui a3,0x1
800011f0: 00006617 auipc a2,0x6
800011f4: e1060613 addi a2,a2,-496 # 80007000 <_trampoline>
800011f8: 040005b7 lui a1,0x4000
800011fc: 15fd addi a1,a1,-1
800011fe: 05b2 slli a1,a1,0xc
80001200: 8526 mv a0,s1
80001202: 00000097 auipc ra,0x0
80001206: f1a080e7 jalr -230(ra) # 8000111c <kvmmap>
proc_mapstacks(kpgtbl);
8000120a: 8526 mv a0,s1
8000120c: 00000097 auipc ra,0x0
80001210: 600080e7 jalr 1536(ra) # 8000180c <proc_mapstacks>
}
80001214: 8526 mv a0,s1
80001216: 60e2 ld ra,24(sp)
80001218: 6442 ld s0,16(sp)
8000121a: 64a2 ld s1,8(sp)
8000121c: 6902 ld s2,0(sp)
8000121e: 6105 addi sp,sp,32
80001220: 8082 ret
0000000080001222 <kvminit>:
{
80001222: 1141 addi sp,sp,-16
80001224: e406 sd ra,8(sp)
80001226: e022 sd s0,0(sp)
80001228: 0800 addi s0,sp,16
kernel_pagetable = kvmmake();
8000122a: 00000097 auipc ra,0x0
8000122e: f22080e7 jalr -222(ra) # 8000114c <kvmmake>
80001232: 00008797 auipc a5,0x8
80001236: dea7b723 sd a0,-530(a5) # 80009020 <kernel_pagetable>
}
8000123a: 60a2 ld ra,8(sp)
8000123c: 6402 ld s0,0(sp)
8000123e: 0141 addi sp,sp,16
80001240: 8082 ret
0000000080001242 <uvmunmap>:
// Remove npages of mappings starting from va. va must be
// page-aligned. The mappings must exist.
// Optionally free the physical memory.
void
uvmunmap(pagetable_t pagetable, uint64 va, uint64 npages, int do_free)
{
80001242: 715d addi sp,sp,-80
80001244: e486 sd ra,72(sp)
80001246: e0a2 sd s0,64(sp)
80001248: fc26 sd s1,56(sp)
8000124a: f84a sd s2,48(sp)
8000124c: f44e sd s3,40(sp)
8000124e: f052 sd s4,32(sp)
80001250: ec56 sd s5,24(sp)
80001252: e85a sd s6,16(sp)
80001254: e45e sd s7,8(sp)
80001256: 0880 addi s0,sp,80
uint64 a;
pte_t *pte;
if((va % PGSIZE) != 0)
80001258: 03459793 slli a5,a1,0x34
8000125c: e795 bnez a5,80001288 <uvmunmap+0x46>
8000125e: 8a2a mv s4,a0
80001260: 892e mv s2,a1
80001262: 8ab6 mv s5,a3
panic("uvmunmap: not aligned");
for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
80001264: 0632 slli a2,a2,0xc
80001266: 00b609b3 add s3,a2,a1
if((pte = walk(pagetable, a, 0)) == 0)
panic("uvmunmap: walk");
if((*pte & PTE_V) == 0)
panic("uvmunmap: not mapped");
if(PTE_FLAGS(*pte) == PTE_V)
8000126a: 4b85 li s7,1
for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
8000126c: 6b05 lui s6,0x1
8000126e: 0735e263 bltu a1,s3,800012d2 <uvmunmap+0x90>
uint64 pa = PTE2PA(*pte);
kfree((void*)pa);
}
*pte = 0;
}
}
80001272: 60a6 ld ra,72(sp)
80001274: 6406 ld s0,64(sp)
80001276: 74e2 ld s1,56(sp)
80001278: 7942 ld s2,48(sp)
8000127a: 79a2 ld s3,40(sp)
8000127c: 7a02 ld s4,32(sp)
8000127e: 6ae2 ld s5,24(sp)
80001280: 6b42 ld s6,16(sp)
80001282: 6ba2 ld s7,8(sp)
80001284: 6161 addi sp,sp,80
80001286: 8082 ret
panic("uvmunmap: not aligned");
80001288: 00007517 auipc a0,0x7
8000128c: e6050513 addi a0,a0,-416 # 800080e8 <digits+0xa8>
80001290: fffff097 auipc ra,0xfffff
80001294: 29a080e7 jalr 666(ra) # 8000052a <panic>
panic("uvmunmap: walk");
80001298: 00007517 auipc a0,0x7
8000129c: e6850513 addi a0,a0,-408 # 80008100 <digits+0xc0>
800012a0: fffff097 auipc ra,0xfffff
800012a4: 28a080e7 jalr 650(ra) # 8000052a <panic>
panic("uvmunmap: not mapped");
800012a8: 00007517 auipc a0,0x7
800012ac: e6850513 addi a0,a0,-408 # 80008110 <digits+0xd0>
800012b0: fffff097 auipc ra,0xfffff
800012b4: 27a080e7 jalr 634(ra) # 8000052a <panic>
panic("uvmunmap: not a leaf");
800012b8: 00007517 auipc a0,0x7
800012bc: e7050513 addi a0,a0,-400 # 80008128 <digits+0xe8>
800012c0: fffff097 auipc ra,0xfffff
800012c4: 26a080e7 jalr 618(ra) # 8000052a <panic>
*pte = 0;
800012c8: 0004b023 sd zero,0(s1)
for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
800012cc: 995a add s2,s2,s6
800012ce: fb3972e3 bgeu s2,s3,80001272 <uvmunmap+0x30>
if((pte = walk(pagetable, a, 0)) == 0)
800012d2: 4601 li a2,0
800012d4: 85ca mv a1,s2
800012d6: 8552 mv a0,s4
800012d8: 00000097 auipc ra,0x0
800012dc: cce080e7 jalr -818(ra) # 80000fa6 <walk>
800012e0: 84aa mv s1,a0
800012e2: d95d beqz a0,80001298 <uvmunmap+0x56>
if((*pte & PTE_V) == 0)
800012e4: 6108 ld a0,0(a0)
800012e6: 00157793 andi a5,a0,1
800012ea: dfdd beqz a5,800012a8 <uvmunmap+0x66>
if(PTE_FLAGS(*pte) == PTE_V)
800012ec: 3ff57793 andi a5,a0,1023
800012f0: fd7784e3 beq a5,s7,800012b8 <uvmunmap+0x76>
if(do_free){
800012f4: fc0a8ae3 beqz s5,800012c8 <uvmunmap+0x86>
uint64 pa = PTE2PA(*pte);
800012f8: 8129 srli a0,a0,0xa
kfree((void*)pa);
800012fa: 0532 slli a0,a0,0xc
800012fc: fffff097 auipc ra,0xfffff
80001300: 6da080e7 jalr 1754(ra) # 800009d6 <kfree>
80001304: b7d1 j 800012c8 <uvmunmap+0x86>
0000000080001306 <uvmcreate>:
// create an empty user page table.
// returns 0 if out of memory.
pagetable_t
uvmcreate()
{
80001306: 1101 addi sp,sp,-32
80001308: ec06 sd ra,24(sp)
8000130a: e822 sd s0,16(sp)
8000130c: e426 sd s1,8(sp)
8000130e: 1000 addi s0,sp,32
pagetable_t pagetable;
pagetable = (pagetable_t) kalloc();
80001310: fffff097 auipc ra,0xfffff
80001314: 7c2080e7 jalr 1986(ra) # 80000ad2 <kalloc>
80001318: 84aa mv s1,a0
if(pagetable == 0)
8000131a: c519 beqz a0,80001328 <uvmcreate+0x22>
return 0;
memset(pagetable, 0, PGSIZE);
8000131c: 6605 lui a2,0x1
8000131e: 4581 li a1,0
80001320: 00000097 auipc ra,0x0
80001324: 99e080e7 jalr -1634(ra) # 80000cbe <memset>
return pagetable;
}
80001328: 8526 mv a0,s1
8000132a: 60e2 ld ra,24(sp)
8000132c: 6442 ld s0,16(sp)
8000132e: 64a2 ld s1,8(sp)
80001330: 6105 addi sp,sp,32
80001332: 8082 ret
0000000080001334 <uvminit>:
// Load the user initcode into address 0 of pagetable,
// for the very first process.
// sz must be less than a page.
void
uvminit(pagetable_t pagetable, uchar *src, uint sz)
{
80001334: 7179 addi sp,sp,-48
80001336: f406 sd ra,40(sp)
80001338: f022 sd s0,32(sp)
8000133a: ec26 sd s1,24(sp)
8000133c: e84a sd s2,16(sp)
8000133e: e44e sd s3,8(sp)
80001340: e052 sd s4,0(sp)
80001342: 1800 addi s0,sp,48
char *mem;
if(sz >= PGSIZE)
80001344: 6785 lui a5,0x1
80001346: 04f67863 bgeu a2,a5,80001396 <uvminit+0x62>
8000134a: 8a2a mv s4,a0
8000134c: 89ae mv s3,a1
8000134e: 84b2 mv s1,a2
panic("inituvm: more than a page");
mem = kalloc();
80001350: fffff097 auipc ra,0xfffff
80001354: 782080e7 jalr 1922(ra) # 80000ad2 <kalloc>
80001358: 892a mv s2,a0
memset(mem, 0, PGSIZE);
8000135a: 6605 lui a2,0x1
8000135c: 4581 li a1,0
8000135e: 00000097 auipc ra,0x0
80001362: 960080e7 jalr -1696(ra) # 80000cbe <memset>
mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
80001366: 4779 li a4,30
80001368: 86ca mv a3,s2
8000136a: 6605 lui a2,0x1
8000136c: 4581 li a1,0
8000136e: 8552 mv a0,s4
80001370: 00000097 auipc ra,0x0
80001374: d1e080e7 jalr -738(ra) # 8000108e <mappages>
memmove(mem, src, sz);
80001378: 8626 mv a2,s1
8000137a: 85ce mv a1,s3
8000137c: 854a mv a0,s2
8000137e: 00000097 auipc ra,0x0
80001382: 99c080e7 jalr -1636(ra) # 80000d1a <memmove>
}
80001386: 70a2 ld ra,40(sp)
80001388: 7402 ld s0,32(sp)
8000138a: 64e2 ld s1,24(sp)
8000138c: 6942 ld s2,16(sp)
8000138e: 69a2 ld s3,8(sp)
80001390: 6a02 ld s4,0(sp)
80001392: 6145 addi sp,sp,48
80001394: 8082 ret
panic("inituvm: more than a page");
80001396: 00007517 auipc a0,0x7
8000139a: daa50513 addi a0,a0,-598 # 80008140 <digits+0x100>
8000139e: fffff097 auipc ra,0xfffff
800013a2: 18c080e7 jalr 396(ra) # 8000052a <panic>
00000000800013a6 <uvmdealloc>:
// 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.
uint64
uvmdealloc(pagetable_t pagetable, uint64 oldsz, uint64 newsz)
{
800013a6: 1101 addi sp,sp,-32
800013a8: ec06 sd ra,24(sp)
800013aa: e822 sd s0,16(sp)
800013ac: e426 sd s1,8(sp)
800013ae: 1000 addi s0,sp,32
if(newsz >= oldsz)
return oldsz;
800013b0: 84ae mv s1,a1
if(newsz >= oldsz)
800013b2: 00b67d63 bgeu a2,a1,800013cc <uvmdealloc+0x26>
800013b6: 84b2 mv s1,a2
if(PGROUNDUP(newsz) < PGROUNDUP(oldsz)){
800013b8: 6785 lui a5,0x1
800013ba: 17fd addi a5,a5,-1
800013bc: 00f60733 add a4,a2,a5
800013c0: 767d lui a2,0xfffff
800013c2: 8f71 and a4,a4,a2
800013c4: 97ae add a5,a5,a1
800013c6: 8ff1 and a5,a5,a2
800013c8: 00f76863 bltu a4,a5,800013d8 <uvmdealloc+0x32>
int npages = (PGROUNDUP(oldsz) - PGROUNDUP(newsz)) / PGSIZE;
uvmunmap(pagetable, PGROUNDUP(newsz), npages, 1);
}
return newsz;
}
800013cc: 8526 mv a0,s1
800013ce: 60e2 ld ra,24(sp)
800013d0: 6442 ld s0,16(sp)
800013d2: 64a2 ld s1,8(sp)
800013d4: 6105 addi sp,sp,32
800013d6: 8082 ret
int npages = (PGROUNDUP(oldsz) - PGROUNDUP(newsz)) / PGSIZE;
800013d8: 8f99 sub a5,a5,a4
800013da: 83b1 srli a5,a5,0xc
uvmunmap(pagetable, PGROUNDUP(newsz), npages, 1);
800013dc: 4685 li a3,1
800013de: 0007861b sext.w a2,a5
800013e2: 85ba mv a1,a4
800013e4: 00000097 auipc ra,0x0
800013e8: e5e080e7 jalr -418(ra) # 80001242 <uvmunmap>
800013ec: b7c5 j 800013cc <uvmdealloc+0x26>
00000000800013ee <uvmalloc>:
if(newsz < oldsz)
800013ee: 0ab66163 bltu a2,a1,80001490 <uvmalloc+0xa2>
{
800013f2: 7139 addi sp,sp,-64
800013f4: fc06 sd ra,56(sp)
800013f6: f822 sd s0,48(sp)
800013f8: f426 sd s1,40(sp)
800013fa: f04a sd s2,32(sp)
800013fc: ec4e sd s3,24(sp)
800013fe: e852 sd s4,16(sp)
80001400: e456 sd s5,8(sp)
80001402: 0080 addi s0,sp,64
80001404: 8aaa mv s5,a0
80001406: 8a32 mv s4,a2
oldsz = PGROUNDUP(oldsz);
80001408: 6985 lui s3,0x1
8000140a: 19fd addi s3,s3,-1
8000140c: 95ce add a1,a1,s3
8000140e: 79fd lui s3,0xfffff
80001410: 0135f9b3 and s3,a1,s3
for(a = oldsz; a < newsz; a += PGSIZE){
80001414: 08c9f063 bgeu s3,a2,80001494 <uvmalloc+0xa6>
80001418: 894e mv s2,s3
mem = kalloc();
8000141a: fffff097 auipc ra,0xfffff
8000141e: 6b8080e7 jalr 1720(ra) # 80000ad2 <kalloc>
80001422: 84aa mv s1,a0
if(mem == 0){
80001424: c51d beqz a0,80001452 <uvmalloc+0x64>
memset(mem, 0, PGSIZE);
80001426: 6605 lui a2,0x1
80001428: 4581 li a1,0
8000142a: 00000097 auipc ra,0x0
8000142e: 894080e7 jalr -1900(ra) # 80000cbe <memset>
if(mappages(pagetable, a, PGSIZE, (uint64)mem, PTE_W|PTE_X|PTE_R|PTE_U) != 0){
80001432: 4779 li a4,30
80001434: 86a6 mv a3,s1
80001436: 6605 lui a2,0x1
80001438: 85ca mv a1,s2
8000143a: 8556 mv a0,s5
8000143c: 00000097 auipc ra,0x0
80001440: c52080e7 jalr -942(ra) # 8000108e <mappages>
80001444: e905 bnez a0,80001474 <uvmalloc+0x86>
for(a = oldsz; a < newsz; a += PGSIZE){
80001446: 6785 lui a5,0x1
80001448: 993e add s2,s2,a5
8000144a: fd4968e3 bltu s2,s4,8000141a <uvmalloc+0x2c>
return newsz;
8000144e: 8552 mv a0,s4
80001450: a809 j 80001462 <uvmalloc+0x74>
uvmdealloc(pagetable, a, oldsz);
80001452: 864e mv a2,s3
80001454: 85ca mv a1,s2
80001456: 8556 mv a0,s5
80001458: 00000097 auipc ra,0x0
8000145c: f4e080e7 jalr -178(ra) # 800013a6 <uvmdealloc>
return 0;
80001460: 4501 li a0,0
}
80001462: 70e2 ld ra,56(sp)
80001464: 7442 ld s0,48(sp)
80001466: 74a2 ld s1,40(sp)
80001468: 7902 ld s2,32(sp)
8000146a: 69e2 ld s3,24(sp)
8000146c: 6a42 ld s4,16(sp)
8000146e: 6aa2 ld s5,8(sp)
80001470: 6121 addi sp,sp,64
80001472: 8082 ret
kfree(mem);
80001474: 8526 mv a0,s1
80001476: fffff097 auipc ra,0xfffff
8000147a: 560080e7 jalr 1376(ra) # 800009d6 <kfree>
uvmdealloc(pagetable, a, oldsz);
8000147e: 864e mv a2,s3
80001480: 85ca mv a1,s2
80001482: 8556 mv a0,s5
80001484: 00000097 auipc ra,0x0
80001488: f22080e7 jalr -222(ra) # 800013a6 <uvmdealloc>
return 0;
8000148c: 4501 li a0,0
8000148e: bfd1 j 80001462 <uvmalloc+0x74>
return oldsz;
80001490: 852e mv a0,a1
}
80001492: 8082 ret
return newsz;
80001494: 8532 mv a0,a2
80001496: b7f1 j 80001462 <uvmalloc+0x74>
0000000080001498 <freewalk>:
// Recursively free page-table pages.
// All leaf mappings must already have been removed.
void
freewalk(pagetable_t pagetable)
{
80001498: 7179 addi sp,sp,-48
8000149a: f406 sd ra,40(sp)
8000149c: f022 sd s0,32(sp)
8000149e: ec26 sd s1,24(sp)
800014a0: e84a sd s2,16(sp)
800014a2: e44e sd s3,8(sp)
800014a4: e052 sd s4,0(sp)
800014a6: 1800 addi s0,sp,48
800014a8: 8a2a mv s4,a0
// there are 2^9 = 512 PTEs in a page table.
for(int i = 0; i < 512; i++){
800014aa: 84aa mv s1,a0
800014ac: 6905 lui s2,0x1
800014ae: 992a add s2,s2,a0
pte_t pte = pagetable[i];
if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
800014b0: 4985 li s3,1
800014b2: a821 j 800014ca <freewalk+0x32>
// this PTE points to a lower-level page table.
uint64 child = PTE2PA(pte);
800014b4: 8129 srli a0,a0,0xa
freewalk((pagetable_t)child);
800014b6: 0532 slli a0,a0,0xc
800014b8: 00000097 auipc ra,0x0
800014bc: fe0080e7 jalr -32(ra) # 80001498 <freewalk>
pagetable[i] = 0;
800014c0: 0004b023 sd zero,0(s1)
for(int i = 0; i < 512; i++){
800014c4: 04a1 addi s1,s1,8
800014c6: 03248163 beq s1,s2,800014e8 <freewalk+0x50>
pte_t pte = pagetable[i];
800014ca: 6088 ld a0,0(s1)
if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
800014cc: 00f57793 andi a5,a0,15
800014d0: ff3782e3 beq a5,s3,800014b4 <freewalk+0x1c>
} else if(pte & PTE_V){
800014d4: 8905 andi a0,a0,1
800014d6: d57d beqz a0,800014c4 <freewalk+0x2c>
panic("freewalk: leaf");
800014d8: 00007517 auipc a0,0x7
800014dc: c8850513 addi a0,a0,-888 # 80008160 <digits+0x120>
800014e0: fffff097 auipc ra,0xfffff
800014e4: 04a080e7 jalr 74(ra) # 8000052a <panic>
}
}
kfree((void*)pagetable);
800014e8: 8552 mv a0,s4
800014ea: fffff097 auipc ra,0xfffff
800014ee: 4ec080e7 jalr 1260(ra) # 800009d6 <kfree>
}
800014f2: 70a2 ld ra,40(sp)
800014f4: 7402 ld s0,32(sp)
800014f6: 64e2 ld s1,24(sp)
800014f8: 6942 ld s2,16(sp)
800014fa: 69a2 ld s3,8(sp)
800014fc: 6a02 ld s4,0(sp)
800014fe: 6145 addi sp,sp,48
80001500: 8082 ret
0000000080001502 <uvmfree>:
// Free user memory pages,
// then free page-table pages.
void
uvmfree(pagetable_t pagetable, uint64 sz)
{
80001502: 1101 addi sp,sp,-32
80001504: ec06 sd ra,24(sp)
80001506: e822 sd s0,16(sp)
80001508: e426 sd s1,8(sp)
8000150a: 1000 addi s0,sp,32
8000150c: 84aa mv s1,a0
if(sz > 0)
8000150e: e999 bnez a1,80001524 <uvmfree+0x22>
uvmunmap(pagetable, 0, PGROUNDUP(sz)/PGSIZE, 1);
freewalk(pagetable);
80001510: 8526 mv a0,s1
80001512: 00000097 auipc ra,0x0
80001516: f86080e7 jalr -122(ra) # 80001498 <freewalk>
}
8000151a: 60e2 ld ra,24(sp)
8000151c: 6442 ld s0,16(sp)
8000151e: 64a2 ld s1,8(sp)
80001520: 6105 addi sp,sp,32
80001522: 8082 ret
uvmunmap(pagetable, 0, PGROUNDUP(sz)/PGSIZE, 1);
80001524: 6605 lui a2,0x1
80001526: 167d addi a2,a2,-1
80001528: 962e add a2,a2,a1
8000152a: 4685 li a3,1
8000152c: 8231 srli a2,a2,0xc
8000152e: 4581 li a1,0
80001530: 00000097 auipc ra,0x0
80001534: d12080e7 jalr -750(ra) # 80001242 <uvmunmap>
80001538: bfe1 j 80001510 <uvmfree+0xe>
000000008000153a <uvmcopy>:
pte_t *pte;
uint64 pa, i;
uint flags;
char *mem;
for(i = 0; i < sz; i += PGSIZE){
8000153a: c679 beqz a2,80001608 <uvmcopy+0xce>
{
8000153c: 715d addi sp,sp,-80
8000153e: e486 sd ra,72(sp)
80001540: e0a2 sd s0,64(sp)
80001542: fc26 sd s1,56(sp)
80001544: f84a sd s2,48(sp)
80001546: f44e sd s3,40(sp)
80001548: f052 sd s4,32(sp)
8000154a: ec56 sd s5,24(sp)
8000154c: e85a sd s6,16(sp)
8000154e: e45e sd s7,8(sp)
80001550: 0880 addi s0,sp,80
80001552: 8b2a mv s6,a0
80001554: 8aae mv s5,a1
80001556: 8a32 mv s4,a2
for(i = 0; i < sz; i += PGSIZE){
80001558: 4981 li s3,0
if((pte = walk(old, i, 0)) == 0)
8000155a: 4601 li a2,0
8000155c: 85ce mv a1,s3
8000155e: 855a mv a0,s6
80001560: 00000097 auipc ra,0x0
80001564: a46080e7 jalr -1466(ra) # 80000fa6 <walk>
80001568: c531 beqz a0,800015b4 <uvmcopy+0x7a>
panic("uvmcopy: pte should exist");
if((*pte & PTE_V) == 0)
8000156a: 6118 ld a4,0(a0)
8000156c: 00177793 andi a5,a4,1
80001570: cbb1 beqz a5,800015c4 <uvmcopy+0x8a>
panic("uvmcopy: page not present");
pa = PTE2PA(*pte);
80001572: 00a75593 srli a1,a4,0xa
80001576: 00c59b93 slli s7,a1,0xc
flags = PTE_FLAGS(*pte);
8000157a: 3ff77493 andi s1,a4,1023
if((mem = kalloc()) == 0)
8000157e: fffff097 auipc ra,0xfffff
80001582: 554080e7 jalr 1364(ra) # 80000ad2 <kalloc>
80001586: 892a mv s2,a0
80001588: c939 beqz a0,800015de <uvmcopy+0xa4>
goto err;
memmove(mem, (char*)pa, PGSIZE);
8000158a: 6605 lui a2,0x1
8000158c: 85de mv a1,s7
8000158e: fffff097 auipc ra,0xfffff
80001592: 78c080e7 jalr 1932(ra) # 80000d1a <memmove>
if(mappages(new, i, PGSIZE, (uint64)mem, flags) != 0){
80001596: 8726 mv a4,s1
80001598: 86ca mv a3,s2
8000159a: 6605 lui a2,0x1
8000159c: 85ce mv a1,s3
8000159e: 8556 mv a0,s5
800015a0: 00000097 auipc ra,0x0
800015a4: aee080e7 jalr -1298(ra) # 8000108e <mappages>
800015a8: e515 bnez a0,800015d4 <uvmcopy+0x9a>
for(i = 0; i < sz; i += PGSIZE){
800015aa: 6785 lui a5,0x1
800015ac: 99be add s3,s3,a5
800015ae: fb49e6e3 bltu s3,s4,8000155a <uvmcopy+0x20>
800015b2: a081 j 800015f2 <uvmcopy+0xb8>
panic("uvmcopy: pte should exist");
800015b4: 00007517 auipc a0,0x7
800015b8: bbc50513 addi a0,a0,-1092 # 80008170 <digits+0x130>
800015bc: fffff097 auipc ra,0xfffff
800015c0: f6e080e7 jalr -146(ra) # 8000052a <panic>
panic("uvmcopy: page not present");
800015c4: 00007517 auipc a0,0x7
800015c8: bcc50513 addi a0,a0,-1076 # 80008190 <digits+0x150>
800015cc: fffff097 auipc ra,0xfffff
800015d0: f5e080e7 jalr -162(ra) # 8000052a <panic>
kfree(mem);
800015d4: 854a mv a0,s2
800015d6: fffff097 auipc ra,0xfffff
800015da: 400080e7 jalr 1024(ra) # 800009d6 <kfree>
}
}
return 0;
err:
uvmunmap(new, 0, i / PGSIZE, 1);
800015de: 4685 li a3,1
800015e0: 00c9d613 srli a2,s3,0xc
800015e4: 4581 li a1,0
800015e6: 8556 mv a0,s5
800015e8: 00000097 auipc ra,0x0
800015ec: c5a080e7 jalr -934(ra) # 80001242 <uvmunmap>
return -1;
800015f0: 557d li a0,-1
}
800015f2: 60a6 ld ra,72(sp)
800015f4: 6406 ld s0,64(sp)
800015f6: 74e2 ld s1,56(sp)
800015f8: 7942 ld s2,48(sp)
800015fa: 79a2 ld s3,40(sp)
800015fc: 7a02 ld s4,32(sp)
800015fe: 6ae2 ld s5,24(sp)
80001600: 6b42 ld s6,16(sp)
80001602: 6ba2 ld s7,8(sp)
80001604: 6161 addi sp,sp,80
80001606: 8082 ret
return 0;
80001608: 4501 li a0,0
}
8000160a: 8082 ret
000000008000160c <uvmclear>:
// mark a PTE invalid for user access.
// used by exec for the user stack guard page.
void
uvmclear(pagetable_t pagetable, uint64 va)
{
8000160c: 1141 addi sp,sp,-16
8000160e: e406 sd ra,8(sp)
80001610: e022 sd s0,0(sp)
80001612: 0800 addi s0,sp,16
pte_t *pte;
pte = walk(pagetable, va, 0);
80001614: 4601 li a2,0
80001616: 00000097 auipc ra,0x0
8000161a: 990080e7 jalr -1648(ra) # 80000fa6 <walk>
if(pte == 0)
8000161e: c901 beqz a0,8000162e <uvmclear+0x22>
panic("uvmclear");
*pte &= ~PTE_U;
80001620: 611c ld a5,0(a0)
80001622: 9bbd andi a5,a5,-17
80001624: e11c sd a5,0(a0)
}
80001626: 60a2 ld ra,8(sp)
80001628: 6402 ld s0,0(sp)
8000162a: 0141 addi sp,sp,16
8000162c: 8082 ret
panic("uvmclear");
8000162e: 00007517 auipc a0,0x7
80001632: b8250513 addi a0,a0,-1150 # 800081b0 <digits+0x170>
80001636: fffff097 auipc ra,0xfffff
8000163a: ef4080e7 jalr -268(ra) # 8000052a <panic>
000000008000163e <copyout>:
int
copyout(pagetable_t pagetable, uint64 dstva, char *src, uint64 len)
{
uint64 n, va0, pa0;
while(len > 0){
8000163e: c6bd beqz a3,800016ac <copyout+0x6e>
{
80001640: 715d addi sp,sp,-80
80001642: e486 sd ra,72(sp)
80001644: e0a2 sd s0,64(sp)
80001646: fc26 sd s1,56(sp)
80001648: f84a sd s2,48(sp)
8000164a: f44e sd s3,40(sp)
8000164c: f052 sd s4,32(sp)
8000164e: ec56 sd s5,24(sp)
80001650: e85a sd s6,16(sp)
80001652: e45e sd s7,8(sp)
80001654: e062 sd s8,0(sp)
80001656: 0880 addi s0,sp,80
80001658: 8b2a mv s6,a0
8000165a: 8c2e mv s8,a1
8000165c: 8a32 mv s4,a2
8000165e: 89b6 mv s3,a3
va0 = PGROUNDDOWN(dstva);
80001660: 7bfd lui s7,0xfffff
pa0 = walkaddr(pagetable, va0);
if(pa0 == 0)
return -1;
n = PGSIZE - (dstva - va0);
80001662: 6a85 lui s5,0x1
80001664: a015 j 80001688 <copyout+0x4a>
if(n > len)
n = len;
memmove((void *)(pa0 + (dstva - va0)), src, n);
80001666: 9562 add a0,a0,s8
80001668: 0004861b sext.w a2,s1
8000166c: 85d2 mv a1,s4
8000166e: 41250533 sub a0,a0,s2
80001672: fffff097 auipc ra,0xfffff
80001676: 6a8080e7 jalr 1704(ra) # 80000d1a <memmove>
len -= n;
8000167a: 409989b3 sub s3,s3,s1
src += n;
8000167e: 9a26 add s4,s4,s1
dstva = va0 + PGSIZE;
80001680: 01590c33 add s8,s2,s5
while(len > 0){
80001684: 02098263 beqz s3,800016a8 <copyout+0x6a>
va0 = PGROUNDDOWN(dstva);
80001688: 017c7933 and s2,s8,s7
pa0 = walkaddr(pagetable, va0);
8000168c: 85ca mv a1,s2
8000168e: 855a mv a0,s6
80001690: 00000097 auipc ra,0x0
80001694: 9bc080e7 jalr -1604(ra) # 8000104c <walkaddr>
if(pa0 == 0)
80001698: cd01 beqz a0,800016b0 <copyout+0x72>
n = PGSIZE - (dstva - va0);
8000169a: 418904b3 sub s1,s2,s8
8000169e: 94d6 add s1,s1,s5
if(n > len)
800016a0: fc99f3e3 bgeu s3,s1,80001666 <copyout+0x28>
800016a4: 84ce mv s1,s3
800016a6: b7c1 j 80001666 <copyout+0x28>
}
return 0;
800016a8: 4501 li a0,0
800016aa: a021 j 800016b2 <copyout+0x74>
800016ac: 4501 li a0,0
}
800016ae: 8082 ret
return -1;
800016b0: 557d li a0,-1
}
800016b2: 60a6 ld ra,72(sp)
800016b4: 6406 ld s0,64(sp)
800016b6: 74e2 ld s1,56(sp)
800016b8: 7942 ld s2,48(sp)
800016ba: 79a2 ld s3,40(sp)
800016bc: 7a02 ld s4,32(sp)
800016be: 6ae2 ld s5,24(sp)
800016c0: 6b42 ld s6,16(sp)
800016c2: 6ba2 ld s7,8(sp)
800016c4: 6c02 ld s8,0(sp)
800016c6: 6161 addi sp,sp,80
800016c8: 8082 ret
00000000800016ca <copyin>:
int
copyin(pagetable_t pagetable, char *dst, uint64 srcva, uint64 len)
{
uint64 n, va0, pa0;
while(len > 0){
800016ca: caa5 beqz a3,8000173a <copyin+0x70>
{
800016cc: 715d addi sp,sp,-80
800016ce: e486 sd ra,72(sp)
800016d0: e0a2 sd s0,64(sp)
800016d2: fc26 sd s1,56(sp)
800016d4: f84a sd s2,48(sp)
800016d6: f44e sd s3,40(sp)
800016d8: f052 sd s4,32(sp)
800016da: ec56 sd s5,24(sp)
800016dc: e85a sd s6,16(sp)
800016de: e45e sd s7,8(sp)
800016e0: e062 sd s8,0(sp)
800016e2: 0880 addi s0,sp,80
800016e4: 8b2a mv s6,a0
800016e6: 8a2e mv s4,a1
800016e8: 8c32 mv s8,a2
800016ea: 89b6 mv s3,a3
va0 = PGROUNDDOWN(srcva);
800016ec: 7bfd lui s7,0xfffff
pa0 = walkaddr(pagetable, va0);
if(pa0 == 0)
return -1;
n = PGSIZE - (srcva - va0);
800016ee: 6a85 lui s5,0x1
800016f0: a01d j 80001716 <copyin+0x4c>
if(n > len)
n = len;
memmove(dst, (void *)(pa0 + (srcva - va0)), n);
800016f2: 018505b3 add a1,a0,s8
800016f6: 0004861b sext.w a2,s1
800016fa: 412585b3 sub a1,a1,s2
800016fe: 8552 mv a0,s4
80001700: fffff097 auipc ra,0xfffff
80001704: 61a080e7 jalr 1562(ra) # 80000d1a <memmove>
len -= n;
80001708: 409989b3 sub s3,s3,s1
dst += n;
8000170c: 9a26 add s4,s4,s1
srcva = va0 + PGSIZE;
8000170e: 01590c33 add s8,s2,s5
while(len > 0){
80001712: 02098263 beqz s3,80001736 <copyin+0x6c>
va0 = PGROUNDDOWN(srcva);
80001716: 017c7933 and s2,s8,s7
pa0 = walkaddr(pagetable, va0);
8000171a: 85ca mv a1,s2
8000171c: 855a mv a0,s6
8000171e: 00000097 auipc ra,0x0
80001722: 92e080e7 jalr -1746(ra) # 8000104c <walkaddr>
if(pa0 == 0)
80001726: cd01 beqz a0,8000173e <copyin+0x74>
n = PGSIZE - (srcva - va0);
80001728: 418904b3 sub s1,s2,s8
8000172c: 94d6 add s1,s1,s5
if(n > len)
8000172e: fc99f2e3 bgeu s3,s1,800016f2 <copyin+0x28>
80001732: 84ce mv s1,s3
80001734: bf7d j 800016f2 <copyin+0x28>
}
return 0;
80001736: 4501 li a0,0
80001738: a021 j 80001740 <copyin+0x76>
8000173a: 4501 li a0,0
}
8000173c: 8082 ret
return -1;
8000173e: 557d li a0,-1
}
80001740: 60a6 ld ra,72(sp)
80001742: 6406 ld s0,64(sp)
80001744: 74e2 ld s1,56(sp)
80001746: 7942 ld s2,48(sp)
80001748: 79a2 ld s3,40(sp)
8000174a: 7a02 ld s4,32(sp)
8000174c: 6ae2 ld s5,24(sp)
8000174e: 6b42 ld s6,16(sp)
80001750: 6ba2 ld s7,8(sp)
80001752: 6c02 ld s8,0(sp)
80001754: 6161 addi sp,sp,80
80001756: 8082 ret
0000000080001758 <copyinstr>:
copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max)
{
uint64 n, va0, pa0;
int got_null = 0;
while(got_null == 0 && max > 0){
80001758: c6c5 beqz a3,80001800 <copyinstr+0xa8>
{
8000175a: 715d addi sp,sp,-80
8000175c: e486 sd ra,72(sp)
8000175e: e0a2 sd s0,64(sp)
80001760: fc26 sd s1,56(sp)
80001762: f84a sd s2,48(sp)
80001764: f44e sd s3,40(sp)
80001766: f052 sd s4,32(sp)
80001768: ec56 sd s5,24(sp)
8000176a: e85a sd s6,16(sp)
8000176c: e45e sd s7,8(sp)
8000176e: 0880 addi s0,sp,80
80001770: 8a2a mv s4,a0
80001772: 8b2e mv s6,a1
80001774: 8bb2 mv s7,a2
80001776: 84b6 mv s1,a3
va0 = PGROUNDDOWN(srcva);
80001778: 7afd lui s5,0xfffff
pa0 = walkaddr(pagetable, va0);
if(pa0 == 0)
return -1;
n = PGSIZE - (srcva - va0);
8000177a: 6985 lui s3,0x1
8000177c: a035 j 800017a8 <copyinstr+0x50>
n = max;
char *p = (char *) (pa0 + (srcva - va0));
while(n > 0){
if(*p == '\0'){
*dst = '\0';
8000177e: 00078023 sb zero,0(a5) # 1000 <_entry-0x7ffff000>
80001782: 4785 li a5,1
dst++;
}
srcva = va0 + PGSIZE;
}
if(got_null){
80001784: 0017b793 seqz a5,a5
80001788: 40f00533 neg a0,a5
return 0;
} else {
return -1;
}
}
8000178c: 60a6 ld ra,72(sp)
8000178e: 6406 ld s0,64(sp)
80001790: 74e2 ld s1,56(sp)
80001792: 7942 ld s2,48(sp)
80001794: 79a2 ld s3,40(sp)
80001796: 7a02 ld s4,32(sp)
80001798: 6ae2 ld s5,24(sp)
8000179a: 6b42 ld s6,16(sp)
8000179c: 6ba2 ld s7,8(sp)
8000179e: 6161 addi sp,sp,80
800017a0: 8082 ret
srcva = va0 + PGSIZE;
800017a2: 01390bb3 add s7,s2,s3
while(got_null == 0 && max > 0){
800017a6: c8a9 beqz s1,800017f8 <copyinstr+0xa0>
va0 = PGROUNDDOWN(srcva);
800017a8: 015bf933 and s2,s7,s5
pa0 = walkaddr(pagetable, va0);
800017ac: 85ca mv a1,s2
800017ae: 8552 mv a0,s4
800017b0: 00000097 auipc ra,0x0
800017b4: 89c080e7 jalr -1892(ra) # 8000104c <walkaddr>
if(pa0 == 0)
800017b8: c131 beqz a0,800017fc <copyinstr+0xa4>
n = PGSIZE - (srcva - va0);
800017ba: 41790833 sub a6,s2,s7
800017be: 984e add a6,a6,s3
if(n > max)
800017c0: 0104f363 bgeu s1,a6,800017c6 <copyinstr+0x6e>
800017c4: 8826 mv a6,s1
char *p = (char *) (pa0 + (srcva - va0));
800017c6: 955e add a0,a0,s7
800017c8: 41250533 sub a0,a0,s2
while(n > 0){
800017cc: fc080be3 beqz a6,800017a2 <copyinstr+0x4a>
800017d0: 985a add a6,a6,s6
800017d2: 87da mv a5,s6
if(*p == '\0'){
800017d4: 41650633 sub a2,a0,s6
800017d8: 14fd addi s1,s1,-1
800017da: 9b26 add s6,s6,s1
800017dc: 00f60733 add a4,a2,a5
800017e0: 00074703 lbu a4,0(a4) # fffffffffffff000 <end+0xffffffff7ffd8000>
800017e4: df49 beqz a4,8000177e <copyinstr+0x26>
*dst = *p;
800017e6: 00e78023 sb a4,0(a5)
--max;
800017ea: 40fb04b3 sub s1,s6,a5
dst++;
800017ee: 0785 addi a5,a5,1
while(n > 0){
800017f0: ff0796e3 bne a5,a6,800017dc <copyinstr+0x84>
dst++;
800017f4: 8b42 mv s6,a6
800017f6: b775 j 800017a2 <copyinstr+0x4a>
800017f8: 4781 li a5,0
800017fa: b769 j 80001784 <copyinstr+0x2c>
return -1;
800017fc: 557d li a0,-1
800017fe: b779 j 8000178c <copyinstr+0x34>
int got_null = 0;
80001800: 4781 li a5,0
if(got_null){
80001802: 0017b793 seqz a5,a5
80001806: 40f00533 neg a0,a5
}
8000180a: 8082 ret
000000008000180c <proc_mapstacks>:
// Allocate a page for each process's kernel stack.
// Map it high in memory, followed by an invalid
// guard page.
void
proc_mapstacks(pagetable_t kpgtbl) {
8000180c: 7139 addi sp,sp,-64
8000180e: fc06 sd ra,56(sp)
80001810: f822 sd s0,48(sp)
80001812: f426 sd s1,40(sp)
80001814: f04a sd s2,32(sp)
80001816: ec4e sd s3,24(sp)
80001818: e852 sd s4,16(sp)
8000181a: e456 sd s5,8(sp)
8000181c: e05a sd s6,0(sp)
8000181e: 0080 addi s0,sp,64
80001820: 89aa mv s3,a0
struct proc *p;
for(p = proc; p < &proc[NPROC]; p++) {
80001822: 00010497 auipc s1,0x10
80001826: eae48493 addi s1,s1,-338 # 800116d0 <proc>
char *pa = kalloc();
if(pa == 0)
panic("kalloc");
uint64 va = KSTACK((int) (p - proc));
8000182a: 8b26 mv s6,s1
8000182c: 00006a97 auipc s5,0x6
80001830: 7d4a8a93 addi s5,s5,2004 # 80008000 <etext>
80001834: 04000937 lui s2,0x4000
80001838: 197d addi s2,s2,-1
8000183a: 0932 slli s2,s2,0xc
for(p = proc; p < &proc[NPROC]; p++) {
8000183c: 00016a17 auipc s4,0x16
80001840: 694a0a13 addi s4,s4,1684 # 80017ed0 <tickslock>
char *pa = kalloc();
80001844: fffff097 auipc ra,0xfffff
80001848: 28e080e7 jalr 654(ra) # 80000ad2 <kalloc>
8000184c: 862a mv a2,a0
if(pa == 0)
8000184e: c131 beqz a0,80001892 <proc_mapstacks+0x86>
uint64 va = KSTACK((int) (p - proc));
80001850: 416485b3 sub a1,s1,s6
80001854: 8595 srai a1,a1,0x5
80001856: 000ab783 ld a5,0(s5)
8000185a: 02f585b3 mul a1,a1,a5
8000185e: 2585 addiw a1,a1,1
80001860: 00d5959b slliw a1,a1,0xd
kvmmap(kpgtbl, va, (uint64)pa, PGSIZE, PTE_R | PTE_W);
80001864: 4719 li a4,6
80001866: 6685 lui a3,0x1
80001868: 40b905b3 sub a1,s2,a1
8000186c: 854e mv a0,s3
8000186e: 00000097 auipc ra,0x0
80001872: 8ae080e7 jalr -1874(ra) # 8000111c <kvmmap>
for(p = proc; p < &proc[NPROC]; p++) {
80001876: 1a048493 addi s1,s1,416
8000187a: fd4495e3 bne s1,s4,80001844 <proc_mapstacks+0x38>
}
}
8000187e: 70e2 ld ra,56(sp)
80001880: 7442 ld s0,48(sp)
80001882: 74a2 ld s1,40(sp)
80001884: 7902 ld s2,32(sp)
80001886: 69e2 ld s3,24(sp)
80001888: 6a42 ld s4,16(sp)
8000188a: 6aa2 ld s5,8(sp)
8000188c: 6b02 ld s6,0(sp)
8000188e: 6121 addi sp,sp,64
80001890: 8082 ret
panic("kalloc");
80001892: 00007517 auipc a0,0x7
80001896: 92e50513 addi a0,a0,-1746 # 800081c0 <digits+0x180>
8000189a: fffff097 auipc ra,0xfffff
8000189e: c90080e7 jalr -880(ra) # 8000052a <panic>
00000000800018a2 <procinit>:
}
// initialize the proc table at boot time.
void
procinit(void)
{
800018a2: 7139 addi sp,sp,-64
800018a4: fc06 sd ra,56(sp)
800018a6: f822 sd s0,48(sp)
800018a8: f426 sd s1,40(sp)
800018aa: f04a sd s2,32(sp)
800018ac: ec4e sd s3,24(sp)
800018ae: e852 sd s4,16(sp)
800018b0: e456 sd s5,8(sp)
800018b2: e05a sd s6,0(sp)
800018b4: 0080 addi s0,sp,64
struct proc *p;
initlock(&pid_lock, "nextpid");
800018b6: 00007597 auipc a1,0x7
800018ba: 91258593 addi a1,a1,-1774 # 800081c8 <digits+0x188>
800018be: 00010517 auipc a0,0x10
800018c2: 9e250513 addi a0,a0,-1566 # 800112a0 <pid_lock>
800018c6: fffff097 auipc ra,0xfffff
800018ca: 26c080e7 jalr 620(ra) # 80000b32 <initlock>
initlock(&wait_lock, "wait_lock");
800018ce: 00007597 auipc a1,0x7
800018d2: 90258593 addi a1,a1,-1790 # 800081d0 <digits+0x190>
800018d6: 00010517 auipc a0,0x10
800018da: 9e250513 addi a0,a0,-1566 # 800112b8 <wait_lock>
800018de: fffff097 auipc ra,0xfffff
800018e2: 254080e7 jalr 596(ra) # 80000b32 <initlock>
for(p = proc; p < &proc[NPROC]; p++) {
800018e6: 00010497 auipc s1,0x10
800018ea: dea48493 addi s1,s1,-534 # 800116d0 <proc>
initlock(&p->lock, "proc");
800018ee: 00007b17 auipc s6,0x7
800018f2: 8f2b0b13 addi s6,s6,-1806 # 800081e0 <digits+0x1a0>
p->kstack = KSTACK((int) (p - proc));
800018f6: 8aa6 mv s5,s1
800018f8: 00006a17 auipc s4,0x6
800018fc: 708a0a13 addi s4,s4,1800 # 80008000 <etext>
80001900: 04000937 lui s2,0x4000
80001904: 197d addi s2,s2,-1
80001906: 0932 slli s2,s2,0xc
for(p = proc; p < &proc[NPROC]; p++) {
80001908: 00016997 auipc s3,0x16
8000190c: 5c898993 addi s3,s3,1480 # 80017ed0 <tickslock>
initlock(&p->lock, "proc");
80001910: 85da mv a1,s6
80001912: 8526 mv a0,s1
80001914: fffff097 auipc ra,0xfffff
80001918: 21e080e7 jalr 542(ra) # 80000b32 <initlock>
p->kstack = KSTACK((int) (p - proc));
8000191c: 415487b3 sub a5,s1,s5
80001920: 8795 srai a5,a5,0x5
80001922: 000a3703 ld a4,0(s4)
80001926: 02e787b3 mul a5,a5,a4
8000192a: 2785 addiw a5,a5,1
8000192c: 00d7979b slliw a5,a5,0xd
80001930: 40f907b3 sub a5,s2,a5
80001934: fcbc sd a5,120(s1)
for(p = proc; p < &proc[NPROC]; p++) {
80001936: 1a048493 addi s1,s1,416
8000193a: fd349be3 bne s1,s3,80001910 <procinit+0x6e>
}
}
8000193e: 70e2 ld ra,56(sp)
80001940: 7442 ld s0,48(sp)
80001942: 74a2 ld s1,40(sp)
80001944: 7902 ld s2,32(sp)
80001946: 69e2 ld s3,24(sp)
80001948: 6a42 ld s4,16(sp)
8000194a: 6aa2 ld s5,8(sp)
8000194c: 6b02 ld s6,0(sp)
8000194e: 6121 addi sp,sp,64
80001950: 8082 ret
0000000080001952 <cpuid>:
// Must be called with interrupts disabled,
// to prevent race with process being moved
// to a different CPU.
int
cpuid()
{
80001952: 1141 addi sp,sp,-16
80001954: e422 sd s0,8(sp)
80001956: 0800 addi s0,sp,16
asm volatile("mv %0, tp" : "=r" (x) );
80001958: 8512 mv a0,tp
int id = r_tp();
return id;
}
8000195a: 2501 sext.w a0,a0
8000195c: 6422 ld s0,8(sp)
8000195e: 0141 addi sp,sp,16
80001960: 8082 ret
0000000080001962 <mycpu>:
// Return this CPU's cpu struct.
// Interrupts must be disabled.
struct cpu*
mycpu(void) {
80001962: 1141 addi sp,sp,-16
80001964: e422 sd s0,8(sp)
80001966: 0800 addi s0,sp,16
80001968: 8792 mv a5,tp
int id = cpuid();
struct cpu *c = &cpus[id];
8000196a: 2781 sext.w a5,a5
8000196c: 079e slli a5,a5,0x7
return c;
}
8000196e: 00010517 auipc a0,0x10
80001972: 96250513 addi a0,a0,-1694 # 800112d0 <cpus>
80001976: 953e add a0,a0,a5
80001978: 6422 ld s0,8(sp)
8000197a: 0141 addi sp,sp,16
8000197c: 8082 ret
000000008000197e <myproc>:
// Return the current struct proc *, or zero if none.
struct proc*
myproc(void) {
8000197e: 1101 addi sp,sp,-32
80001980: ec06 sd ra,24(sp)
80001982: e822 sd s0,16(sp)
80001984: e426 sd s1,8(sp)
80001986: 1000 addi s0,sp,32
push_off();
80001988: fffff097 auipc ra,0xfffff
8000198c: 1ee080e7 jalr 494(ra) # 80000b76 <push_off>
80001990: 8792 mv a5,tp
struct cpu *c = mycpu();
struct proc *p = c->proc;
80001992: 2781 sext.w a5,a5
80001994: 079e slli a5,a5,0x7
80001996: 00010717 auipc a4,0x10
8000199a: 90a70713 addi a4,a4,-1782 # 800112a0 <pid_lock>
8000199e: 97ba add a5,a5,a4
800019a0: 7b84 ld s1,48(a5)
pop_off();
800019a2: fffff097 auipc ra,0xfffff
800019a6: 274080e7 jalr 628(ra) # 80000c16 <pop_off>
return p;
}
800019aa: 8526 mv a0,s1
800019ac: 60e2 ld ra,24(sp)
800019ae: 6442 ld s0,16(sp)
800019b0: 64a2 ld s1,8(sp)
800019b2: 6105 addi sp,sp,32
800019b4: 8082 ret
00000000800019b6 <forkret>:
// A fork child's very first scheduling by scheduler()
// will swtch to forkret.
void
forkret(void)
{
800019b6: 1141 addi sp,sp,-16
800019b8: e406 sd ra,8(sp)
800019ba: e022 sd s0,0(sp)
800019bc: 0800 addi s0,sp,16
static int first = 1;
// Still holding p->lock from scheduler.
release(&myproc()->lock);
800019be: 00000097 auipc ra,0x0
800019c2: fc0080e7 jalr -64(ra) # 8000197e <myproc>
800019c6: fffff097 auipc ra,0xfffff
800019ca: 2b0080e7 jalr 688(ra) # 80000c76 <release>
if (first) {
800019ce: 00007797 auipc a5,0x7
800019d2: f627a783 lw a5,-158(a5) # 80008930 <first.1>
800019d6: eb89 bnez a5,800019e8 <forkret+0x32>
// be run from main().
first = 0;
fsinit(ROOTDEV);
}
usertrapret();
800019d8: 00001097 auipc ra,0x1
800019dc: f8a080e7 jalr -118(ra) # 80002962 <usertrapret>
}
800019e0: 60a2 ld ra,8(sp)
800019e2: 6402 ld s0,0(sp)
800019e4: 0141 addi sp,sp,16
800019e6: 8082 ret
first = 0;
800019e8: 00007797 auipc a5,0x7
800019ec: f407a423 sw zero,-184(a5) # 80008930 <first.1>
fsinit(ROOTDEV);
800019f0: 4505 li a0,1
800019f2: 00002097 auipc ra,0x2
800019f6: e50080e7 jalr -432(ra) # 80003842 <fsinit>
800019fa: bff9 j 800019d8 <forkret+0x22>
00000000800019fc <allocpid>:
allocpid() {
800019fc: 1101 addi sp,sp,-32
800019fe: ec06 sd ra,24(sp)
80001a00: e822 sd s0,16(sp)
80001a02: e426 sd s1,8(sp)
80001a04: e04a sd s2,0(sp)
80001a06: 1000 addi s0,sp,32
acquire(&pid_lock);
80001a08: 00010917 auipc s2,0x10
80001a0c: 89890913 addi s2,s2,-1896 # 800112a0 <pid_lock>
80001a10: 854a mv a0,s2
80001a12: fffff097 auipc ra,0xfffff
80001a16: 1b0080e7 jalr 432(ra) # 80000bc2 <acquire>
pid = nextpid;
80001a1a: 00007797 auipc a5,0x7
80001a1e: f1a78793 addi a5,a5,-230 # 80008934 <nextpid>
80001a22: 4384 lw s1,0(a5)
nextpid = nextpid + 1;
80001a24: 0014871b addiw a4,s1,1
80001a28: c398 sw a4,0(a5)
release(&pid_lock);
80001a2a: 854a mv a0,s2
80001a2c: fffff097 auipc ra,0xfffff
80001a30: 24a080e7 jalr 586(ra) # 80000c76 <release>
}
80001a34: 8526 mv a0,s1
80001a36: 60e2 ld ra,24(sp)
80001a38: 6442 ld s0,16(sp)
80001a3a: 64a2 ld s1,8(sp)
80001a3c: 6902 ld s2,0(sp)
80001a3e: 6105 addi sp,sp,32
80001a40: 8082 ret
0000000080001a42 <proc_pagetable>:
{
80001a42: 1101 addi sp,sp,-32
80001a44: ec06 sd ra,24(sp)
80001a46: e822 sd s0,16(sp)
80001a48: e426 sd s1,8(sp)
80001a4a: e04a sd s2,0(sp)
80001a4c: 1000 addi s0,sp,32
80001a4e: 892a mv s2,a0
pagetable = uvmcreate();
80001a50: 00000097 auipc ra,0x0
80001a54: 8b6080e7 jalr -1866(ra) # 80001306 <uvmcreate>
80001a58: 84aa mv s1,a0
if(pagetable == 0)
80001a5a: c121 beqz a0,80001a9a <proc_pagetable+0x58>
if(mappages(pagetable, TRAMPOLINE, PGSIZE,
80001a5c: 4729 li a4,10
80001a5e: 00005697 auipc a3,0x5
80001a62: 5a268693 addi a3,a3,1442 # 80007000 <_trampoline>
80001a66: 6605 lui a2,0x1
80001a68: 040005b7 lui a1,0x4000
80001a6c: 15fd addi a1,a1,-1
80001a6e: 05b2 slli a1,a1,0xc
80001a70: fffff097 auipc ra,0xfffff
80001a74: 61e080e7 jalr 1566(ra) # 8000108e <mappages>
80001a78: 02054863 bltz a0,80001aa8 <proc_pagetable+0x66>
if(mappages(pagetable, TRAPFRAME, PGSIZE,
80001a7c: 4719 li a4,6
80001a7e: 09093683 ld a3,144(s2)
80001a82: 6605 lui a2,0x1
80001a84: 020005b7 lui a1,0x2000
80001a88: 15fd addi a1,a1,-1
80001a8a: 05b6 slli a1,a1,0xd
80001a8c: 8526 mv a0,s1
80001a8e: fffff097 auipc ra,0xfffff
80001a92: 600080e7 jalr 1536(ra) # 8000108e <mappages>
80001a96: 02054163 bltz a0,80001ab8 <proc_pagetable+0x76>
}
80001a9a: 8526 mv a0,s1
80001a9c: 60e2 ld ra,24(sp)
80001a9e: 6442 ld s0,16(sp)
80001aa0: 64a2 ld s1,8(sp)
80001aa2: 6902 ld s2,0(sp)
80001aa4: 6105 addi sp,sp,32
80001aa6: 8082 ret
uvmfree(pagetable, 0);
80001aa8: 4581 li a1,0
80001aaa: 8526 mv a0,s1
80001aac: 00000097 auipc ra,0x0
80001ab0: a56080e7 jalr -1450(ra) # 80001502 <uvmfree>
return 0;
80001ab4: 4481 li s1,0
80001ab6: b7d5 j 80001a9a <proc_pagetable+0x58>
uvmunmap(pagetable, TRAMPOLINE, 1, 0);
80001ab8: 4681 li a3,0
80001aba: 4605 li a2,1
80001abc: 040005b7 lui a1,0x4000
80001ac0: 15fd addi a1,a1,-1
80001ac2: 05b2 slli a1,a1,0xc
80001ac4: 8526 mv a0,s1
80001ac6: fffff097 auipc ra,0xfffff
80001aca: 77c080e7 jalr 1916(ra) # 80001242 <uvmunmap>
uvmfree(pagetable, 0);
80001ace: 4581 li a1,0
80001ad0: 8526 mv a0,s1
80001ad2: 00000097 auipc ra,0x0
80001ad6: a30080e7 jalr -1488(ra) # 80001502 <uvmfree>
return 0;
80001ada: 4481 li s1,0
80001adc: bf7d j 80001a9a <proc_pagetable+0x58>
0000000080001ade <proc_freepagetable>:
{
80001ade: 1101 addi sp,sp,-32
80001ae0: ec06 sd ra,24(sp)
80001ae2: e822 sd s0,16(sp)
80001ae4: e426 sd s1,8(sp)
80001ae6: e04a sd s2,0(sp)
80001ae8: 1000 addi s0,sp,32
80001aea: 84aa mv s1,a0
80001aec: 892e mv s2,a1
uvmunmap(pagetable, TRAMPOLINE, 1, 0);
80001aee: 4681 li a3,0
80001af0: 4605 li a2,1
80001af2: 040005b7 lui a1,0x4000
80001af6: 15fd addi a1,a1,-1
80001af8: 05b2 slli a1,a1,0xc
80001afa: fffff097 auipc ra,0xfffff
80001afe: 748080e7 jalr 1864(ra) # 80001242 <uvmunmap>
uvmunmap(pagetable, TRAPFRAME, 1, 0);
80001b02: 4681 li a3,0
80001b04: 4605 li a2,1
80001b06: 020005b7 lui a1,0x2000
80001b0a: 15fd addi a1,a1,-1
80001b0c: 05b6 slli a1,a1,0xd
80001b0e: 8526 mv a0,s1
80001b10: fffff097 auipc ra,0xfffff
80001b14: 732080e7 jalr 1842(ra) # 80001242 <uvmunmap>
uvmfree(pagetable, sz);
80001b18: 85ca mv a1,s2
80001b1a: 8526 mv a0,s1
80001b1c: 00000097 auipc ra,0x0
80001b20: 9e6080e7 jalr -1562(ra) # 80001502 <uvmfree>
}
80001b24: 60e2 ld ra,24(sp)
80001b26: 6442 ld s0,16(sp)
80001b28: 64a2 ld s1,8(sp)
80001b2a: 6902 ld s2,0(sp)
80001b2c: 6105 addi sp,sp,32
80001b2e: 8082 ret
0000000080001b30 <freeproc>:
{
80001b30: 1101 addi sp,sp,-32
80001b32: ec06 sd ra,24(sp)
80001b34: e822 sd s0,16(sp)
80001b36: e426 sd s1,8(sp)
80001b38: 1000 addi s0,sp,32
80001b3a: 84aa mv s1,a0
if(p->trapframe)
80001b3c: 6948 ld a0,144(a0)
80001b3e: c509 beqz a0,80001b48 <freeproc+0x18>
kfree((void*)p->trapframe);
80001b40: fffff097 auipc ra,0xfffff
80001b44: e96080e7 jalr -362(ra) # 800009d6 <kfree>
p->trapframe = 0;
80001b48: 0804b823 sd zero,144(s1)
if(p->pagetable)
80001b4c: 64c8 ld a0,136(s1)
80001b4e: c511 beqz a0,80001b5a <freeproc+0x2a>
proc_freepagetable(p->pagetable, p->sz);
80001b50: 60cc ld a1,128(s1)
80001b52: 00000097 auipc ra,0x0
80001b56: f8c080e7 jalr -116(ra) # 80001ade <proc_freepagetable>
p->pagetable = 0;
80001b5a: 0804b423 sd zero,136(s1)
p->sz = 0;
80001b5e: 0804b023 sd zero,128(s1)
p->pid = 0;
80001b62: 0204a823 sw zero,48(s1)
p->parent = 0;
80001b66: 0604b823 sd zero,112(s1)
p->name[0] = 0;
80001b6a: 18048823 sb zero,400(s1)
p->chan = 0;
80001b6e: 0204b023 sd zero,32(s1)
p->killed = 0;
80001b72: 0204a423 sw zero,40(s1)
p->xstate = 0;
80001b76: 0204a623 sw zero,44(s1)
p->ctime = 0;
80001b7a: 0404a023 sw zero,64(s1)
p->ttime = 0;
80001b7e: 0404a223 sw zero,68(s1)
p->stime = 0;
80001b82: 0404a423 sw zero,72(s1)
p->retime = 0;
80001b86: 0404a623 sw zero,76(s1)
p->rutime = 0;
80001b8a: 0404a823 sw zero,80(s1)
p->average_bursttime = 0;
80001b8e: 0404aa23 sw zero,84(s1)
p->state = UNUSED;
80001b92: 0004ac23 sw zero,24(s1)
}
80001b96: 60e2 ld ra,24(sp)
80001b98: 6442 ld s0,16(sp)
80001b9a: 64a2 ld s1,8(sp)
80001b9c: 6105 addi sp,sp,32
80001b9e: 8082 ret
0000000080001ba0 <allocproc>:
{
80001ba0: 1101 addi sp,sp,-32
80001ba2: ec06 sd ra,24(sp)
80001ba4: e822 sd s0,16(sp)
80001ba6: e426 sd s1,8(sp)
80001ba8: e04a sd s2,0(sp)
80001baa: 1000 addi s0,sp,32
for(p = proc; p < &proc[NPROC]; p++) {
80001bac: 00010497 auipc s1,0x10
80001bb0: b2448493 addi s1,s1,-1244 # 800116d0 <proc>
80001bb4: 00016917 auipc s2,0x16
80001bb8: 31c90913 addi s2,s2,796 # 80017ed0 <tickslock>
acquire(&p->lock);
80001bbc: 8526 mv a0,s1
80001bbe: fffff097 auipc ra,0xfffff
80001bc2: 004080e7 jalr 4(ra) # 80000bc2 <acquire>
if(p->state == UNUSED) {
80001bc6: 4c9c lw a5,24(s1)
80001bc8: cf81 beqz a5,80001be0 <allocproc+0x40>
release(&p->lock);
80001bca: 8526 mv a0,s1
80001bcc: fffff097 auipc ra,0xfffff
80001bd0: 0aa080e7 jalr 170(ra) # 80000c76 <release>
for(p = proc; p < &proc[NPROC]; p++) {
80001bd4: 1a048493 addi s1,s1,416
80001bd8: ff2492e3 bne s1,s2,80001bbc <allocproc+0x1c>
return 0;
80001bdc: 4481 li s1,0
80001bde: a8ad j 80001c58 <allocproc+0xb8>
p->pid = allocpid();
80001be0: 00000097 auipc ra,0x0
80001be4: e1c080e7 jalr -484(ra) # 800019fc <allocpid>
80001be8: d888 sw a0,48(s1)
p->state = USED;
80001bea: 4785 li a5,1
80001bec: cc9c sw a5,24(s1)
p->mask = 0;
80001bee: 0204aa23 sw zero,52(s1)
p->tickcounter = 0;
80001bf2: 0204ac23 sw zero,56(s1)
p->priority = NORMAL_PRIORITY;
80001bf6: 4795 li a5,5
80001bf8: dcdc sw a5,60(s1)
p->average_bursttime = QUANTUM * 100;
80001bfa: 1f400793 li a5,500
80001bfe: c8fc sw a5,84(s1)
p->ctime = ticks;
80001c00: 00007797 auipc a5,0x7
80001c04: 4307a783 lw a5,1072(a5) # 80009030 <ticks>
80001c08: c0bc sw a5,64(s1)
p->readyTime = 0;
80001c0a: 0404bc23 sd zero,88(s1)
p->rutime = 0;
80001c0e: 0404a823 sw zero,80(s1)
p->stime = 0;
80001c12: 0404a423 sw zero,72(s1)
if((p->trapframe = (struct trapframe *)kalloc()) == 0){
80001c16: fffff097 auipc ra,0xfffff
80001c1a: ebc080e7 jalr -324(ra) # 80000ad2 <kalloc>
80001c1e: 892a mv s2,a0
80001c20: e8c8 sd a0,144(s1)
80001c22: c131 beqz a0,80001c66 <allocproc+0xc6>
p->pagetable = proc_pagetable(p);
80001c24: 8526 mv a0,s1
80001c26: 00000097 auipc ra,0x0
80001c2a: e1c080e7 jalr -484(ra) # 80001a42 <proc_pagetable>
80001c2e: 892a mv s2,a0
80001c30: e4c8 sd a0,136(s1)
if(p->pagetable == 0){
80001c32: c531 beqz a0,80001c7e <allocproc+0xde>
memset(&p->context, 0, sizeof(p->context));
80001c34: 07000613 li a2,112
80001c38: 4581 li a1,0
80001c3a: 09848513 addi a0,s1,152
80001c3e: fffff097 auipc ra,0xfffff
80001c42: 080080e7 jalr 128(ra) # 80000cbe <memset>
p->context.ra = (uint64)forkret;
80001c46: 00000797 auipc a5,0x0
80001c4a: d7078793 addi a5,a5,-656 # 800019b6 <forkret>
80001c4e: ecdc sd a5,152(s1)
p->context.sp = p->kstack + PGSIZE;
80001c50: 7cbc ld a5,120(s1)
80001c52: 6705 lui a4,0x1
80001c54: 97ba add a5,a5,a4
80001c56: f0dc sd a5,160(s1)
}
80001c58: 8526 mv a0,s1
80001c5a: 60e2 ld ra,24(sp)
80001c5c: 6442 ld s0,16(sp)
80001c5e: 64a2 ld s1,8(sp)
80001c60: 6902 ld s2,0(sp)
80001c62: 6105 addi sp,sp,32
80001c64: 8082 ret
freeproc(p);
80001c66: 8526 mv a0,s1
80001c68: 00000097 auipc ra,0x0
80001c6c: ec8080e7 jalr -312(ra) # 80001b30 <freeproc>
release(&p->lock);
80001c70: 8526 mv a0,s1
80001c72: fffff097 auipc ra,0xfffff
80001c76: 004080e7 jalr 4(ra) # 80000c76 <release>
return 0;
80001c7a: 84ca mv s1,s2
80001c7c: bff1 j 80001c58 <allocproc+0xb8>
freeproc(p);
80001c7e: 8526 mv a0,s1
80001c80: 00000097 auipc ra,0x0
80001c84: eb0080e7 jalr -336(ra) # 80001b30 <freeproc>
release(&p->lock);
80001c88: 8526 mv a0,s1
80001c8a: fffff097 auipc ra,0xfffff
80001c8e: fec080e7 jalr -20(ra) # 80000c76 <release>
return 0;
80001c92: 84ca mv s1,s2
80001c94: b7d1 j 80001c58 <allocproc+0xb8>
0000000080001c96 <userinit>:
{
80001c96: 1101 addi sp,sp,-32
80001c98: ec06 sd ra,24(sp)
80001c9a: e822 sd s0,16(sp)
80001c9c: e426 sd s1,8(sp)
80001c9e: 1000 addi s0,sp,32
p = allocproc();
80001ca0: 00000097 auipc ra,0x0
80001ca4: f00080e7 jalr -256(ra) # 80001ba0 <allocproc>
80001ca8: 84aa mv s1,a0
initproc = p;
80001caa: 00007797 auipc a5,0x7
80001cae: 36a7bf23 sd a0,894(a5) # 80009028 <initproc>
uvminit(p->pagetable, initcode, sizeof(initcode));
80001cb2: 03400613 li a2,52
80001cb6: 00007597 auipc a1,0x7
80001cba: c8a58593 addi a1,a1,-886 # 80008940 <initcode>
80001cbe: 6548 ld a0,136(a0)
80001cc0: fffff097 auipc ra,0xfffff
80001cc4: 674080e7 jalr 1652(ra) # 80001334 <uvminit>
p->sz = PGSIZE;
80001cc8: 6785 lui a5,0x1
80001cca: e0dc sd a5,128(s1)
p->trapframe->epc = 0; // user program counter
80001ccc: 68d8 ld a4,144(s1)
80001cce: 00073c23 sd zero,24(a4) # 1018 <_entry-0x7fffefe8>
p->trapframe->sp = PGSIZE; // user stack pointer
80001cd2: 68d8 ld a4,144(s1)
80001cd4: fb1c sd a5,48(a4)
safestrcpy(p->name, "initcode", sizeof(p->name));
80001cd6: 4641 li a2,16
80001cd8: 00006597 auipc a1,0x6
80001cdc: 51058593 addi a1,a1,1296 # 800081e8 <digits+0x1a8>
80001ce0: 19048513 addi a0,s1,400
80001ce4: fffff097 auipc ra,0xfffff
80001ce8: 12c080e7 jalr 300(ra) # 80000e10 <safestrcpy>
p->cwd = namei("/");
80001cec: 00006517 auipc a0,0x6
80001cf0: 50c50513 addi a0,a0,1292 # 800081f8 <digits+0x1b8>
80001cf4: 00002097 auipc ra,0x2
80001cf8: 57c080e7 jalr 1404(ra) # 80004270 <namei>
80001cfc: 18a4b423 sd a0,392(s1)
p->state = RUNNABLE;
80001d00: 478d li a5,3
80001d02: cc9c sw a5,24(s1)
p->readyTime = ticks;
80001d04: 00007797 auipc a5,0x7
80001d08: 32c7e783 lwu a5,812(a5) # 80009030 <ticks>
80001d0c: ecbc sd a5,88(s1)
release(&p->lock);
80001d0e: 8526 mv a0,s1
80001d10: fffff097 auipc ra,0xfffff
80001d14: f66080e7 jalr -154(ra) # 80000c76 <release>
}
80001d18: 60e2 ld ra,24(sp)
80001d1a: 6442 ld s0,16(sp)
80001d1c: 64a2 ld s1,8(sp)
80001d1e: 6105 addi sp,sp,32
80001d20: 8082 ret
0000000080001d22 <growproc>:
{
80001d22: 1101 addi sp,sp,-32
80001d24: ec06 sd ra,24(sp)
80001d26: e822 sd s0,16(sp)
80001d28: e426 sd s1,8(sp)
80001d2a: e04a sd s2,0(sp)
80001d2c: 1000 addi s0,sp,32
80001d2e: 84aa mv s1,a0
struct proc *p = myproc();
80001d30: 00000097 auipc ra,0x0
80001d34: c4e080e7 jalr -946(ra) # 8000197e <myproc>
80001d38: 892a mv s2,a0
sz = p->sz;
80001d3a: 614c ld a1,128(a0)
80001d3c: 0005861b sext.w a2,a1
if(n > 0){
80001d40: 00904f63 bgtz s1,80001d5e <growproc+0x3c>
} else if(n < 0){
80001d44: 0204cc63 bltz s1,80001d7c <growproc+0x5a>
p->sz = sz;
80001d48: 1602 slli a2,a2,0x20
80001d4a: 9201 srli a2,a2,0x20
80001d4c: 08c93023 sd a2,128(s2)
return 0;
80001d50: 4501 li a0,0
}
80001d52: 60e2 ld ra,24(sp)
80001d54: 6442 ld s0,16(sp)
80001d56: 64a2 ld s1,8(sp)
80001d58: 6902 ld s2,0(sp)
80001d5a: 6105 addi sp,sp,32
80001d5c: 8082 ret
if((sz = uvmalloc(p->pagetable, sz, sz + n)) == 0) {
80001d5e: 9e25 addw a2,a2,s1
80001d60: 1602 slli a2,a2,0x20
80001d62: 9201 srli a2,a2,0x20
80001d64: 1582 slli a1,a1,0x20
80001d66: 9181 srli a1,a1,0x20
80001d68: 6548 ld a0,136(a0)
80001d6a: fffff097 auipc ra,0xfffff
80001d6e: 684080e7 jalr 1668(ra) # 800013ee <uvmalloc>
80001d72: 0005061b sext.w a2,a0
80001d76: fa69 bnez a2,80001d48 <growproc+0x26>
return -1;
80001d78: 557d li a0,-1
80001d7a: bfe1 j 80001d52 <growproc+0x30>
sz = uvmdealloc(p->pagetable, sz, sz + n);
80001d7c: 9e25 addw a2,a2,s1
80001d7e: 1602 slli a2,a2,0x20
80001d80: 9201 srli a2,a2,0x20
80001d82: 1582 slli a1,a1,0x20
80001d84: 9181 srli a1,a1,0x20
80001d86: 6548 ld a0,136(a0)
80001d88: fffff097 auipc ra,0xfffff
80001d8c: 61e080e7 jalr 1566(ra) # 800013a6 <uvmdealloc>
80001d90: 0005061b sext.w a2,a0
80001d94: bf55 j 80001d48 <growproc+0x26>
0000000080001d96 <fork>:
{
80001d96: 7139 addi sp,sp,-64
80001d98: fc06 sd ra,56(sp)
80001d9a: f822 sd s0,48(sp)
80001d9c: f426 sd s1,40(sp)
80001d9e: f04a sd s2,32(sp)
80001da0: ec4e sd s3,24(sp)
80001da2: e852 sd s4,16(sp)
80001da4: e456 sd s5,8(sp)
80001da6: 0080 addi s0,sp,64
struct proc *p = myproc();
80001da8: 00000097 auipc ra,0x0
80001dac: bd6080e7 jalr -1066(ra) # 8000197e <myproc>
80001db0: 8aaa mv s5,a0
if((np = allocproc()) == 0){
80001db2: 00000097 auipc ra,0x0
80001db6: dee080e7 jalr -530(ra) # 80001ba0 <allocproc>
80001dba: 14050063 beqz a0,80001efa <fork+0x164>
80001dbe: 89aa mv s3,a0
if(uvmcopy(p->pagetable, np->pagetable, p->sz) < 0){
80001dc0: 080ab603 ld a2,128(s5)
80001dc4: 654c ld a1,136(a0)
80001dc6: 088ab503 ld a0,136(s5)
80001dca: fffff097 auipc ra,0xfffff
80001dce: 770080e7 jalr 1904(ra) # 8000153a <uvmcopy>
80001dd2: 06054663 bltz a0,80001e3e <fork+0xa8>
np->sz = p->sz;
80001dd6: 080ab783 ld a5,128(s5)
80001dda: 08f9b023 sd a5,128(s3)
np->mask = p->mask;
80001dde: 034aa783 lw a5,52(s5)
80001de2: 02f9aa23 sw a5,52(s3)
np->priority = p->priority;
80001de6: 03caa783 lw a5,60(s5)
80001dea: 02f9ae23 sw a5,60(s3)
np->tickcounter = 0;
80001dee: 0209ac23 sw zero,56(s3)
np->average_bursttime = QUANTUM * 100;
80001df2: 1f400793 li a5,500
80001df6: 04f9aa23 sw a5,84(s3)
*(np->trapframe) = *(p->trapframe);
80001dfa: 090ab683 ld a3,144(s5)
80001dfe: 87b6 mv a5,a3
80001e00: 0909b703 ld a4,144(s3)
80001e04: 12068693 addi a3,a3,288
80001e08: 0007b803 ld a6,0(a5)
80001e0c: 6788 ld a0,8(a5)
80001e0e: 6b8c ld a1,16(a5)
80001e10: 6f90 ld a2,24(a5)
80001e12: 01073023 sd a6,0(a4)
80001e16: e708 sd a0,8(a4)
80001e18: eb0c sd a1,16(a4)
80001e1a: ef10 sd a2,24(a4)
80001e1c: 02078793 addi a5,a5,32
80001e20: 02070713 addi a4,a4,32
80001e24: fed792e3 bne a5,a3,80001e08 <fork+0x72>
np->trapframe->a0 = 0;
80001e28: 0909b783 ld a5,144(s3)
80001e2c: 0607b823 sd zero,112(a5)
for(i = 0; i < NOFILE; i++)
80001e30: 108a8493 addi s1,s5,264
80001e34: 10898913 addi s2,s3,264
80001e38: 188a8a13 addi s4,s5,392
80001e3c: a00d j 80001e5e <fork+0xc8>
freeproc(np);
80001e3e: 854e mv a0,s3
80001e40: 00000097 auipc ra,0x0
80001e44: cf0080e7 jalr -784(ra) # 80001b30 <freeproc>
release(&np->lock);
80001e48: 854e mv a0,s3
80001e4a: fffff097 auipc ra,0xfffff
80001e4e: e2c080e7 jalr -468(ra) # 80000c76 <release>
return -1;
80001e52: 597d li s2,-1
80001e54: a849 j 80001ee6 <fork+0x150>
for(i = 0; i < NOFILE; i++)
80001e56: 04a1 addi s1,s1,8
80001e58: 0921 addi s2,s2,8
80001e5a: 01448b63 beq s1,s4,80001e70 <fork+0xda>
if(p->ofile[i])
80001e5e: 6088 ld a0,0(s1)
80001e60: d97d beqz a0,80001e56 <fork+0xc0>
np->ofile[i] = filedup(p->ofile[i]);
80001e62: 00003097 auipc ra,0x3
80001e66: aa8080e7 jalr -1368(ra) # 8000490a <filedup>
80001e6a: 00a93023 sd a0,0(s2)
80001e6e: b7e5 j 80001e56 <fork+0xc0>
np->cwd = idup(p->cwd);
80001e70: 188ab503 ld a0,392(s5)
80001e74: 00002097 auipc ra,0x2
80001e78: c08080e7 jalr -1016(ra) # 80003a7c <idup>
80001e7c: 18a9b423 sd a0,392(s3)
safestrcpy(np->name, p->name, sizeof(p->name));
80001e80: 4641 li a2,16
80001e82: 190a8593 addi a1,s5,400
80001e86: 19098513 addi a0,s3,400
80001e8a: fffff097 auipc ra,0xfffff
80001e8e: f86080e7 jalr -122(ra) # 80000e10 <safestrcpy>
pid = np->pid;
80001e92: 0309a903 lw s2,48(s3)
release(&np->lock);
80001e96: 854e mv a0,s3
80001e98: fffff097 auipc ra,0xfffff
80001e9c: dde080e7 jalr -546(ra) # 80000c76 <release>
acquire(&wait_lock);
80001ea0: 0000f497 auipc s1,0xf
80001ea4: 41848493 addi s1,s1,1048 # 800112b8 <wait_lock>
80001ea8: 8526 mv a0,s1
80001eaa: fffff097 auipc ra,0xfffff
80001eae: d18080e7 jalr -744(ra) # 80000bc2 <acquire>
np->parent = p;
80001eb2: 0759b823 sd s5,112(s3)
release(&wait_lock);
80001eb6: 8526 mv a0,s1
80001eb8: fffff097 auipc ra,0xfffff
80001ebc: dbe080e7 jalr -578(ra) # 80000c76 <release>
acquire(&np->lock);
80001ec0: 854e mv a0,s3
80001ec2: fffff097 auipc ra,0xfffff
80001ec6: d00080e7 jalr -768(ra) # 80000bc2 <acquire>
np->state = RUNNABLE;
80001eca: 478d li a5,3
80001ecc: 00f9ac23 sw a5,24(s3)
np->readyTime = ticks;
80001ed0: 00007797 auipc a5,0x7
80001ed4: 1607e783 lwu a5,352(a5) # 80009030 <ticks>
80001ed8: 04f9bc23 sd a5,88(s3)
release(&np->lock);
80001edc: 854e mv a0,s3
80001ede: fffff097 auipc ra,0xfffff
80001ee2: d98080e7 jalr -616(ra) # 80000c76 <release>
}
80001ee6: 854a mv a0,s2
80001ee8: 70e2 ld ra,56(sp)
80001eea: 7442 ld s0,48(sp)
80001eec: 74a2 ld s1,40(sp)
80001eee: 7902 ld s2,32(sp)
80001ef0: 69e2 ld s3,24(sp)
80001ef2: 6a42 ld s4,16(sp)
80001ef4: 6aa2 ld s5,8(sp)
80001ef6: 6121 addi sp,sp,64
80001ef8: 8082 ret
return -1;
80001efa: 597d li s2,-1
80001efc: b7ed j 80001ee6 <fork+0x150>
0000000080001efe <scheduler>:
{
80001efe: 715d addi sp,sp,-80
80001f00: e486 sd ra,72(sp)
80001f02: e0a2 sd s0,64(sp)
80001f04: fc26 sd s1,56(sp)
80001f06: f84a sd s2,48(sp)
80001f08: f44e sd s3,40(sp)
80001f0a: f052 sd s4,32(sp)
80001f0c: ec56 sd s5,24(sp)
80001f0e: e85a sd s6,16(sp)
80001f10: e45e sd s7,8(sp)
80001f12: 0880 addi s0,sp,80
80001f14: 8792 mv a5,tp
int id = r_tp();
80001f16: 2781 sext.w a5,a5
c->proc = 0;
80001f18: 00779b13 slli s6,a5,0x7
80001f1c: 0000f717 auipc a4,0xf
80001f20: 38470713 addi a4,a4,900 # 800112a0 <pid_lock>
80001f24: 975a add a4,a4,s6
80001f26: 02073823 sd zero,48(a4)
swtch(&c->context, &p->context);
80001f2a: 0000f717 auipc a4,0xf
80001f2e: 3ae70713 addi a4,a4,942 # 800112d8 <cpus+0x8>
80001f32: 9b3a add s6,s6,a4
if(p->state != RUNNABLE) {
80001f34: 498d li s3,3
p->runningTime = ticks;
80001f36: 00007b97 auipc s7,0x7
80001f3a: 0fab8b93 addi s7,s7,250 # 80009030 <ticks>
c->proc = p;
80001f3e: 079e slli a5,a5,0x7
80001f40: 0000fa17 auipc s4,0xf
80001f44: 360a0a13 addi s4,s4,864 # 800112a0 <pid_lock>
80001f48: 9a3e add s4,s4,a5
for(p = proc; p < &proc[NPROC]; p++) {
80001f4a: 00016917 auipc s2,0x16
80001f4e: f8690913 addi s2,s2,-122 # 80017ed0 <tickslock>
asm volatile("csrr %0, sstatus" : "=r" (x) );
80001f52: 100027f3 csrr a5,sstatus
w_sstatus(r_sstatus() | SSTATUS_SIE);
80001f56: 0027e793 ori a5,a5,2
asm volatile("csrw sstatus, %0" : : "r" (x));
80001f5a: 10079073 csrw sstatus,a5
80001f5e: 0000f497 auipc s1,0xf
80001f62: 77248493 addi s1,s1,1906 # 800116d0 <proc>
p->state = RUNNING;
80001f66: 4a91 li s5,4
80001f68: a811 j 80001f7c <scheduler+0x7e>
release(&p->lock);
80001f6a: 8526 mv a0,s1
80001f6c: fffff097 auipc ra,0xfffff
80001f70: d0a080e7 jalr -758(ra) # 80000c76 <release>
for(p = proc; p < &proc[NPROC]; p++) {
80001f74: 1a048493 addi s1,s1,416
80001f78: fd248de3 beq s1,s2,80001f52 <scheduler+0x54>
acquire(&p->lock);
80001f7c: 8526 mv a0,s1
80001f7e: fffff097 auipc ra,0xfffff
80001f82: c44080e7 jalr -956(ra) # 80000bc2 <acquire>
if(p->state != RUNNABLE) {
80001f86: 4c9c lw a5,24(s1)
80001f88: ff3791e3 bne a5,s3,80001f6a <scheduler+0x6c>
p->state = RUNNING;
80001f8c: 0154ac23 sw s5,24(s1)
p->runningTime = ticks;
80001f90: 000ba703 lw a4,0(s7)
80001f94: 02071793 slli a5,a4,0x20
80001f98: 9381 srli a5,a5,0x20
80001f9a: f0bc sd a5,96(s1)
p->retime += ticks - p->readyTime;
80001f9c: 44fc lw a5,76(s1)
80001f9e: 9fb9 addw a5,a5,a4
80001fa0: 6cb8 ld a4,88(s1)
80001fa2: 9f99 subw a5,a5,a4
80001fa4: c4fc sw a5,76(s1)
c->proc = p;
80001fa6: 029a3823 sd s1,48(s4)
swtch(&c->context, &p->context);
80001faa: 09848593 addi a1,s1,152
80001fae: 855a mv a0,s6
80001fb0: 00001097 auipc ra,0x1
80001fb4: 908080e7 jalr -1784(ra) # 800028b8 <swtch>
c->proc = 0;
80001fb8: 020a3823 sd zero,48(s4)
release(&p->lock);
80001fbc: 8526 mv a0,s1
80001fbe: fffff097 auipc ra,0xfffff
80001fc2: cb8080e7 jalr -840(ra) # 80000c76 <release>
80001fc6: b77d j 80001f74 <scheduler+0x76>
0000000080001fc8 <sched>:
{
80001fc8: 7179 addi sp,sp,-48
80001fca: f406 sd ra,40(sp)
80001fcc: f022 sd s0,32(sp)
80001fce: ec26 sd s1,24(sp)
80001fd0: e84a sd s2,16(sp)
80001fd2: e44e sd s3,8(sp)
80001fd4: 1800 addi s0,sp,48
struct proc *p = myproc();
80001fd6: 00000097 auipc ra,0x0
80001fda: 9a8080e7 jalr -1624(ra) # 8000197e <myproc>
80001fde: 84aa mv s1,a0
if(!holding(&p->lock))
80001fe0: fffff097 auipc ra,0xfffff
80001fe4: b68080e7 jalr -1176(ra) # 80000b48 <holding>
80001fe8: c93d beqz a0,8000205e <sched+0x96>
asm volatile("mv %0, tp" : "=r" (x) );
80001fea: 8792 mv a5,tp
if(mycpu()->noff != 1)
80001fec: 2781 sext.w a5,a5
80001fee: 079e slli a5,a5,0x7
80001ff0: 0000f717 auipc a4,0xf
80001ff4: 2b070713 addi a4,a4,688 # 800112a0 <pid_lock>
80001ff8: 97ba add a5,a5,a4
80001ffa: 0a87a703 lw a4,168(a5)
80001ffe: 4785 li a5,1
80002000: 06f71763 bne a4,a5,8000206e <sched+0xa6>
if(p->state == RUNNING)
80002004: 4c98 lw a4,24(s1)
80002006: 4791 li a5,4
80002008: 06f70b63 beq a4,a5,8000207e <sched+0xb6>
asm volatile("csrr %0, sstatus" : "=r" (x) );
8000200c: 100027f3 csrr a5,sstatus
return (x & SSTATUS_SIE) != 0;
80002010: 8b89 andi a5,a5,2
if(intr_get())
80002012: efb5 bnez a5,8000208e <sched+0xc6>
asm volatile("mv %0, tp" : "=r" (x) );
80002014: 8792 mv a5,tp
intena = mycpu()->intena;
80002016: 0000f917 auipc s2,0xf
8000201a: 28a90913 addi s2,s2,650 # 800112a0 <pid_lock>
8000201e: 2781 sext.w a5,a5
80002020: 079e slli a5,a5,0x7
80002022: 97ca add a5,a5,s2
80002024: 0ac7a983 lw s3,172(a5)
80002028: 8792 mv a5,tp
swtch(&p->context, &mycpu()->context);
8000202a: 2781 sext.w a5,a5
8000202c: 079e slli a5,a5,0x7
8000202e: 0000f597 auipc a1,0xf
80002032: 2aa58593 addi a1,a1,682 # 800112d8 <cpus+0x8>
80002036: 95be add a1,a1,a5
80002038: 09848513 addi a0,s1,152
8000203c: 00001097 auipc ra,0x1
80002040: 87c080e7 jalr -1924(ra) # 800028b8 <swtch>
80002044: 8792 mv a5,tp
mycpu()->intena = intena;
80002046: 2781 sext.w a5,a5
80002048: 079e slli a5,a5,0x7
8000204a: 97ca add a5,a5,s2
8000204c: 0b37a623 sw s3,172(a5)
}
80002050: 70a2 ld ra,40(sp)
80002052: 7402 ld s0,32(sp)
80002054: 64e2 ld s1,24(sp)
80002056: 6942 ld s2,16(sp)
80002058: 69a2 ld s3,8(sp)
8000205a: 6145 addi sp,sp,48
8000205c: 8082 ret
panic("sched p->lock");
8000205e: 00006517 auipc a0,0x6
80002062: 1a250513 addi a0,a0,418 # 80008200 <digits+0x1c0>
80002066: ffffe097 auipc ra,0xffffe
8000206a: 4c4080e7 jalr 1220(ra) # 8000052a <panic>
panic("sched locks");
8000206e: 00006517 auipc a0,0x6
80002072: 1a250513 addi a0,a0,418 # 80008210 <digits+0x1d0>
80002076: ffffe097 auipc ra,0xffffe
8000207a: 4b4080e7 jalr 1204(ra) # 8000052a <panic>
panic("sched running");
8000207e: 00006517 auipc a0,0x6
80002082: 1a250513 addi a0,a0,418 # 80008220 <digits+0x1e0>
80002086: ffffe097 auipc ra,0xffffe
8000208a: 4a4080e7 jalr 1188(ra) # 8000052a <panic>
panic("sched interruptible");
8000208e: 00006517 auipc a0,0x6
80002092: 1a250513 addi a0,a0,418 # 80008230 <digits+0x1f0>
80002096: ffffe097 auipc ra,0xffffe
8000209a: 494080e7 jalr 1172(ra) # 8000052a <panic>
000000008000209e <yield>:
{
8000209e: 1101 addi sp,sp,-32
800020a0: ec06 sd ra,24(sp)
800020a2: e822 sd s0,16(sp)
800020a4: e426 sd s1,8(sp)
800020a6: 1000 addi s0,sp,32
struct proc *p = myproc();
800020a8: 00000097 auipc ra,0x0
800020ac: 8d6080e7 jalr -1834(ra) # 8000197e <myproc>
800020b0: 84aa mv s1,a0
acquire(&p->lock);
800020b2: fffff097 auipc ra,0xfffff
800020b6: b10080e7 jalr -1264(ra) # 80000bc2 <acquire>
p->state = RUNNABLE;
800020ba: 478d li a5,3
800020bc: cc9c sw a5,24(s1)
p->readyTime = ticks;
800020be: 00007717 auipc a4,0x7
800020c2: f7272703 lw a4,-142(a4) # 80009030 <ticks>
800020c6: 02071793 slli a5,a4,0x20
800020ca: 9381 srli a5,a5,0x20
800020cc: ecbc sd a5,88(s1)
p->rutime += ticks - p->runningTime;
800020ce: 48bc lw a5,80(s1)
800020d0: 9fb9 addw a5,a5,a4
800020d2: 70b8 ld a4,96(s1)
800020d4: 9f99 subw a5,a5,a4
800020d6: c8bc sw a5,80(s1)
sched();
800020d8: 00000097 auipc ra,0x0
800020dc: ef0080e7 jalr -272(ra) # 80001fc8 <sched>
release(&p->lock);
800020e0: 8526 mv a0,s1
800020e2: fffff097 auipc ra,0xfffff
800020e6: b94080e7 jalr -1132(ra) # 80000c76 <release>
}
800020ea: 60e2 ld ra,24(sp)
800020ec: 6442 ld s0,16(sp)
800020ee: 64a2 ld s1,8(sp)
800020f0: 6105 addi sp,sp,32
800020f2: 8082 ret
00000000800020f4 <sleep>:
// Atomically release lock and sleep on chan.
// Reacquires lock when awakened.
void
sleep(void *chan, struct spinlock *lk)
{
800020f4: 7179 addi sp,sp,-48
800020f6: f406 sd ra,40(sp)
800020f8: f022 sd s0,32(sp)
800020fa: ec26 sd s1,24(sp)
800020fc: e84a sd s2,16(sp)
800020fe: e44e sd s3,8(sp)
80002100: 1800 addi s0,sp,48
80002102: 89aa mv s3,a0
80002104: 892e mv s2,a1
struct proc *p = myproc();
80002106: 00000097 auipc ra,0x0
8000210a: 878080e7 jalr -1928(ra) # 8000197e <myproc>
8000210e: 84aa mv s1,a0
// Once we hold p->lock, we can be
// guaranteed that we won't miss any wakeup
// (wakeup locks p->lock),
// so it's okay to release lk.
acquire(&p->lock); //DOC: sleeplock1
80002110: fffff097 auipc ra,0xfffff
80002114: ab2080e7 jalr -1358(ra) # 80000bc2 <acquire>
release(lk);
80002118: 854a mv a0,s2
8000211a: fffff097 auipc ra,0xfffff
8000211e: b5c080e7 jalr -1188(ra) # 80000c76 <release>
// Go to sleep.
p->chan = chan;
80002122: 0334b023 sd s3,32(s1)
p->rutime += ticks - p->runningTime;
80002126: 48bc lw a5,80(s1)
80002128: 00007717 auipc a4,0x7
8000212c: f0872703 lw a4,-248(a4) # 80009030 <ticks>
80002130: 9fb9 addw a5,a5,a4
80002132: 70b8 ld a4,96(s1)
80002134: 9f99 subw a5,a5,a4
80002136: c8bc sw a5,80(s1)
p->state = SLEEPING;
80002138: 4789 li a5,2
8000213a: cc9c sw a5,24(s1)
sched();
8000213c: 00000097 auipc ra,0x0
80002140: e8c080e7 jalr -372(ra) # 80001fc8 <sched>
// Tidy up.
p->chan = 0;
80002144: 0204b023 sd zero,32(s1)
// Reacquire original lock.
release(&p->lock);
80002148: 8526 mv a0,s1
8000214a: fffff097 auipc ra,0xfffff
8000214e: b2c080e7 jalr -1236(ra) # 80000c76 <release>
acquire(lk);
80002152: 854a mv a0,s2
80002154: fffff097 auipc ra,0xfffff
80002158: a6e080e7 jalr -1426(ra) # 80000bc2 <acquire>
}
8000215c: 70a2 ld ra,40(sp)
8000215e: 7402 ld s0,32(sp)
80002160: 64e2 ld s1,24(sp)
80002162: 6942 ld s2,16(sp)
80002164: 69a2 ld s3,8(sp)
80002166: 6145 addi sp,sp,48
80002168: 8082 ret
000000008000216a <wait_extension>:
{
8000216a: 711d addi sp,sp,-96
8000216c: ec86 sd ra,88(sp)
8000216e: e8a2 sd s0,80(sp)
80002170: e4a6 sd s1,72(sp)
80002172: e0ca sd s2,64(sp)
80002174: fc4e sd s3,56(sp)
80002176: f852 sd s4,48(sp)
80002178: f456 sd s5,40(sp)
8000217a: f05a sd s6,32(sp)
8000217c: ec5e sd s7,24(sp)
8000217e: e862 sd s8,16(sp)
80002180: e466 sd s9,8(sp)
80002182: 1080 addi s0,sp,96
80002184: 8baa mv s7,a0
80002186: 8b2e mv s6,a1
struct proc *p = myproc();
80002188: fffff097 auipc ra,0xfffff
8000218c: 7f6080e7 jalr 2038(ra) # 8000197e <myproc>
80002190: 892a mv s2,a0
acquire(&wait_lock);
80002192: 0000f517 auipc a0,0xf
80002196: 12650513 addi a0,a0,294 # 800112b8 <wait_lock>
8000219a: fffff097 auipc ra,0xfffff
8000219e: a28080e7 jalr -1496(ra) # 80000bc2 <acquire>
havekids = 0;
800021a2: 4c01 li s8,0
if(np->state == ZOMBIE){
800021a4: 4a15 li s4,5
havekids = 1;
800021a6: 4a85 li s5,1
for(np = proc; np < &proc[NPROC]; np++){
800021a8: 00016997 auipc s3,0x16
800021ac: d2898993 addi s3,s3,-728 # 80017ed0 <tickslock>
sleep(p, &wait_lock); //DOC: wait-sleep
800021b0: 0000fc97 auipc s9,0xf
800021b4: 108c8c93 addi s9,s9,264 # 800112b8 <wait_lock>
havekids = 0;
800021b8: 8762 mv a4,s8
for(np = proc; np < &proc[NPROC]; np++){
800021ba: 0000f497 auipc s1,0xf
800021be: 51648493 addi s1,s1,1302 # 800116d0 <proc>
800021c2: a231 j 800022ce <wait_extension+0x164>
pid = np->pid;
800021c4: 0304a983 lw s3,48(s1)
if(addr != 0 && copyout(p->pagetable, addr, (char *)&np->xstate,
800021c8: 0c0b9463 bnez s7,80002290 <wait_extension+0x126>
if (performance){
800021cc: 080b0f63 beqz s6,8000226a <wait_extension+0x100>
copyout(p->pagetable, (uint64) performance, (char*)&np->ctime, sizeof(int))< 0 ||
800021d0: 4691 li a3,4
800021d2: 04048613 addi a2,s1,64
800021d6: 85da mv a1,s6
800021d8: 08893503 ld a0,136(s2)
800021dc: fffff097 auipc ra,0xfffff
800021e0: 462080e7 jalr 1122(ra) # 8000163e <copyout>
if(
800021e4: 14054963 bltz a0,80002336 <wait_extension+0x1cc>
copyout(p->pagetable, (uint64) performance+4, (char*)&np->ttime, sizeof(int))< 0 ||
800021e8: 4691 li a3,4
800021ea: 04448613 addi a2,s1,68
800021ee: 004b0593 addi a1,s6,4
800021f2: 08893503 ld a0,136(s2)
800021f6: fffff097 auipc ra,0xfffff
800021fa: 448080e7 jalr 1096(ra) # 8000163e <copyout>
copyout(p->pagetable, (uint64) performance, (char*)&np->ctime, sizeof(int))< 0 ||
800021fe: 12054e63 bltz a0,8000233a <wait_extension+0x1d0>
copyout(p->pagetable, (uint64) performance+8, (char*)&np->stime, sizeof(int))< 0 ||
80002202: 4691 li a3,4
80002204: 04848613 addi a2,s1,72
80002208: 008b0593 addi a1,s6,8
8000220c: 08893503 ld a0,136(s2)
80002210: fffff097 auipc ra,0xfffff
80002214: 42e080e7 jalr 1070(ra) # 8000163e <copyout>
copyout(p->pagetable, (uint64) performance+4, (char*)&np->ttime, sizeof(int))< 0 ||
80002218: 12054363 bltz a0,8000233e <wait_extension+0x1d4>
copyout(p->pagetable, (uint64) performance+12, (char*)&np->retime, sizeof(int))< 0 ||
8000221c: 4691 li a3,4
8000221e: 04c48613 addi a2,s1,76
80002222: 00cb0593 addi a1,s6,12
80002226: 08893503 ld a0,136(s2)
8000222a: fffff097 auipc ra,0xfffff
8000222e: 414080e7 jalr 1044(ra) # 8000163e <copyout>
copyout(p->pagetable, (uint64) performance+8, (char*)&np->stime, sizeof(int))< 0 ||
80002232: 10054863 bltz a0,80002342 <wait_extension+0x1d8>
copyout(p->pagetable, (uint64) performance+16, (char*)&np->rutime, sizeof(int))< 0 ||
80002236: 4691 li a3,4
80002238: 05048613 addi a2,s1,80
8000223c: 010b0593 addi a1,s6,16
80002240: 08893503 ld a0,136(s2)
80002244: fffff097 auipc ra,0xfffff
80002248: 3fa080e7 jalr 1018(ra) # 8000163e <copyout>
copyout(p->pagetable, (uint64) performance+12, (char*)&np->retime, sizeof(int))< 0 ||
8000224c: 0e054d63 bltz a0,80002346 <wait_extension+0x1dc>
copyout(p->pagetable, (uint64) performance+20, (char*)&np->average_bursttime, sizeof(int))< 0
80002250: 4691 li a3,4
80002252: 05448613 addi a2,s1,84
80002256: 014b0593 addi a1,s6,20
8000225a: 08893503 ld a0,136(s2)
8000225e: fffff097 auipc ra,0xfffff
80002262: 3e0080e7 jalr 992(ra) # 8000163e <copyout>
copyout(p->pagetable, (uint64) performance+16, (char*)&np->rutime, sizeof(int))< 0 ||
80002266: 0e054263 bltz a0,8000234a <wait_extension+0x1e0>
freeproc(np);
8000226a: 8526 mv a0,s1
8000226c: 00000097 auipc ra,0x0
80002270: 8c4080e7 jalr -1852(ra) # 80001b30 <freeproc>
release(&np->lock);
80002274: 8526 mv a0,s1
80002276: fffff097 auipc ra,0xfffff
8000227a: a00080e7 jalr -1536(ra) # 80000c76 <release>
release(&wait_lock);
8000227e: 0000f517 auipc a0,0xf
80002282: 03a50513 addi a0,a0,58 # 800112b8 <wait_lock>
80002286: fffff097 auipc ra,0xfffff
8000228a: 9f0080e7 jalr -1552(ra) # 80000c76 <release>
return pid;
8000228e: a8bd j 8000230c <wait_extension+0x1a2>
if(addr != 0 && copyout(p->pagetable, addr, (char *)&np->xstate,
80002290: 4691 li a3,4
80002292: 02c48613 addi a2,s1,44
80002296: 85de mv a1,s7
80002298: 08893503 ld a0,136(s2)
8000229c: fffff097 auipc ra,0xfffff
800022a0: 3a2080e7 jalr 930(ra) # 8000163e <copyout>
800022a4: f20554e3 bgez a0,800021cc <wait_extension+0x62>
release(&np->lock);
800022a8: 8526 mv a0,s1
800022aa: fffff097 auipc ra,0xfffff
800022ae: 9cc080e7 jalr -1588(ra) # 80000c76 <release>
release(&wait_lock);
800022b2: 0000f517 auipc a0,0xf
800022b6: 00650513 addi a0,a0,6 # 800112b8 <wait_lock>
800022ba: fffff097 auipc ra,0xfffff
800022be: 9bc080e7 jalr -1604(ra) # 80000c76 <release>
return -1;
800022c2: 59fd li s3,-1
800022c4: a0a1 j 8000230c <wait_extension+0x1a2>
for(np = proc; np < &proc[NPROC]; np++){
800022c6: 1a048493 addi s1,s1,416
800022ca: 03348463 beq s1,s3,800022f2 <wait_extension+0x188>
if(np->parent == p){
800022ce: 78bc ld a5,112(s1)
800022d0: ff279be3 bne a5,s2,800022c6 <wait_extension+0x15c>
acquire(&np->lock);
800022d4: 8526 mv a0,s1
800022d6: fffff097 auipc ra,0xfffff
800022da: 8ec080e7 jalr -1812(ra) # 80000bc2 <acquire>
if(np->state == ZOMBIE){
800022de: 4c9c lw a5,24(s1)
800022e0: ef4782e3 beq a5,s4,800021c4 <wait_extension+0x5a>
release(&np->lock);
800022e4: 8526 mv a0,s1
800022e6: fffff097 auipc ra,0xfffff
800022ea: 990080e7 jalr -1648(ra) # 80000c76 <release>
havekids = 1;
800022ee: 8756 mv a4,s5
800022f0: bfd9 j 800022c6 <wait_extension+0x15c>
if(!havekids || p->killed){
800022f2: c701 beqz a4,800022fa <wait_extension+0x190>
800022f4: 02892783 lw a5,40(s2)
800022f8: cb85 beqz a5,80002328 <wait_extension+0x1be>
release(&wait_lock);
800022fa: 0000f517 auipc a0,0xf
800022fe: fbe50513 addi a0,a0,-66 # 800112b8 <wait_lock>
80002302: fffff097 auipc ra,0xfffff
80002306: 974080e7 jalr -1676(ra) # 80000c76 <release>
return -1;
8000230a: 59fd li s3,-1
}
8000230c: 854e mv a0,s3
8000230e: 60e6 ld ra,88(sp)
80002310: 6446 ld s0,80(sp)
80002312: 64a6 ld s1,72(sp)
80002314: 6906 ld s2,64(sp)
80002316: 79e2 ld s3,56(sp)
80002318: 7a42 ld s4,48(sp)
8000231a: 7aa2 ld s5,40(sp)
8000231c: 7b02 ld s6,32(sp)
8000231e: 6be2 ld s7,24(sp)
80002320: 6c42 ld s8,16(sp)
80002322: 6ca2 ld s9,8(sp)
80002324: 6125 addi sp,sp,96
80002326: 8082 ret
sleep(p, &wait_lock); //DOC: wait-sleep
80002328: 85e6 mv a1,s9
8000232a: 854a mv a0,s2
8000232c: 00000097 auipc ra,0x0
80002330: dc8080e7 jalr -568(ra) # 800020f4 <sleep>
havekids = 0;
80002334: b551 j 800021b8 <wait_extension+0x4e>
return -1;
80002336: 59fd li s3,-1
80002338: bfd1 j 8000230c <wait_extension+0x1a2>
8000233a: 59fd li s3,-1
8000233c: bfc1 j 8000230c <wait_extension+0x1a2>
8000233e: 59fd li s3,-1
80002340: b7f1 j 8000230c <wait_extension+0x1a2>
80002342: 59fd li s3,-1
80002344: b7e1 j 8000230c <wait_extension+0x1a2>
80002346: 59fd li s3,-1
80002348: b7d1 j 8000230c <wait_extension+0x1a2>
8000234a: 59fd li s3,-1
8000234c: b7c1 j 8000230c <wait_extension+0x1a2>
000000008000234e <wait>:
{
8000234e: 1141 addi sp,sp,-16
80002350: e406 sd ra,8(sp)
80002352: e022 sd s0,0(sp)
80002354: 0800 addi s0,sp,16
return wait_extension (addr, 0);
80002356: 4581 li a1,0
80002358: 00000097 auipc ra,0x0
8000235c: e12080e7 jalr -494(ra) # 8000216a <wait_extension>
}
80002360: 60a2 ld ra,8(sp)
80002362: 6402 ld s0,0(sp)
80002364: 0141 addi sp,sp,16
80002366: 8082 ret
0000000080002368 <wakeup>:
// Wake up all processes sleeping on chan.
// Must be called without any p->lock.
void
wakeup(void *chan)
{
80002368: 7139 addi sp,sp,-64
8000236a: fc06 sd ra,56(sp)
8000236c: f822 sd s0,48(sp)
8000236e: f426 sd s1,40(sp)
80002370: f04a sd s2,32(sp)
80002372: ec4e sd s3,24(sp)
80002374: e852 sd s4,16(sp)
80002376: e456 sd s5,8(sp)
80002378: e05a sd s6,0(sp)
8000237a: 0080 addi s0,sp,64
8000237c: 8a2a mv s4,a0
struct proc *p;
for(p = proc; p < &proc[NPROC]; p++) {
8000237e: 0000f497 auipc s1,0xf
80002382: 35248493 addi s1,s1,850 # 800116d0 <proc>
if(p != myproc()){
acquire(&p->lock);
if(p->state == SLEEPING && p->chan == chan) {
80002386: 4989 li s3,2
p->state = RUNNABLE;
80002388: 4b0d li s6,3
p->stime += ticks - p->sleepTime;
8000238a: 00007a97 auipc s5,0x7
8000238e: ca6a8a93 addi s5,s5,-858 # 80009030 <ticks>
for(p = proc; p < &proc[NPROC]; p++) {
80002392: 00016917 auipc s2,0x16
80002396: b3e90913 addi s2,s2,-1218 # 80017ed0 <tickslock>
8000239a: a811 j 800023ae <wakeup+0x46>
p->readyTime = ticks;
}
release(&p->lock);
8000239c: 8526 mv a0,s1
8000239e: fffff097 auipc ra,0xfffff
800023a2: 8d8080e7 jalr -1832(ra) # 80000c76 <release>
for(p = proc; p < &proc[NPROC]; p++) {
800023a6: 1a048493 addi s1,s1,416
800023aa: 05248063 beq s1,s2,800023ea <wakeup+0x82>
if(p != myproc()){
800023ae: fffff097 auipc ra,0xfffff
800023b2: 5d0080e7 jalr 1488(ra) # 8000197e <myproc>
800023b6: fea488e3 beq s1,a0,800023a6 <wakeup+0x3e>
acquire(&p->lock);
800023ba: 8526 mv a0,s1
800023bc: fffff097 auipc ra,0xfffff
800023c0: 806080e7 jalr -2042(ra) # 80000bc2 <acquire>
if(p->state == SLEEPING && p->chan == chan) {
800023c4: 4c9c lw a5,24(s1)
800023c6: fd379be3 bne a5,s3,8000239c <wakeup+0x34>
800023ca: 709c ld a5,32(s1)
800023cc: fd4798e3 bne a5,s4,8000239c <wakeup+0x34>
p->state = RUNNABLE;
800023d0: 0164ac23 sw s6,24(s1)
p->stime += ticks - p->sleepTime;
800023d4: 000aa703 lw a4,0(s5)
800023d8: 44bc lw a5,72(s1)
800023da: 9fb9 addw a5,a5,a4
800023dc: 74b4 ld a3,104(s1)
800023de: 9f95 subw a5,a5,a3
800023e0: c4bc sw a5,72(s1)
p->readyTime = ticks;
800023e2: 1702 slli a4,a4,0x20
800023e4: 9301 srli a4,a4,0x20
800023e6: ecb8 sd a4,88(s1)
800023e8: bf55 j 8000239c <wakeup+0x34>
}
}
}
800023ea: 70e2 ld ra,56(sp)
800023ec: 7442 ld s0,48(sp)
800023ee: 74a2 ld s1,40(sp)
800023f0: 7902 ld s2,32(sp)
800023f2: 69e2 ld s3,24(sp)
800023f4: 6a42 ld s4,16(sp)
800023f6: 6aa2 ld s5,8(sp)
800023f8: 6b02 ld s6,0(sp)
800023fa: 6121 addi sp,sp,64
800023fc: 8082 ret
00000000800023fe <reparent>:
{
800023fe: 7179 addi sp,sp,-48
80002400: f406 sd ra,40(sp)
80002402: f022 sd s0,32(sp)
80002404: ec26 sd s1,24(sp)
80002406: e84a sd s2,16(sp)
80002408: e44e sd s3,8(sp)
8000240a: e052 sd s4,0(sp)
8000240c: 1800 addi s0,sp,48
8000240e: 892a mv s2,a0
for(pp = proc; pp < &proc[NPROC]; pp++){
80002410: 0000f497 auipc s1,0xf
80002414: 2c048493 addi s1,s1,704 # 800116d0 <proc>
pp->parent = initproc;
80002418: 00007a17 auipc s4,0x7
8000241c: c10a0a13 addi s4,s4,-1008 # 80009028 <initproc>
for(pp = proc; pp < &proc[NPROC]; pp++){
80002420: 00016997 auipc s3,0x16
80002424: ab098993 addi s3,s3,-1360 # 80017ed0 <tickslock>
80002428: a029 j 80002432 <reparent+0x34>
8000242a: 1a048493 addi s1,s1,416
8000242e: 01348d63 beq s1,s3,80002448 <reparent+0x4a>
if(pp->parent == p){
80002432: 78bc ld a5,112(s1)
80002434: ff279be3 bne a5,s2,8000242a <reparent+0x2c>
pp->parent = initproc;
80002438: 000a3503 ld a0,0(s4)
8000243c: f8a8 sd a0,112(s1)
wakeup(initproc);
8000243e: 00000097 auipc ra,0x0
80002442: f2a080e7 jalr -214(ra) # 80002368 <wakeup>
80002446: b7d5 j 8000242a <reparent+0x2c>
}
80002448: 70a2 ld ra,40(sp)
8000244a: 7402 ld s0,32(sp)
8000244c: 64e2 ld s1,24(sp)
8000244e: 6942 ld s2,16(sp)
80002450: 69a2 ld s3,8(sp)
80002452: 6a02 ld s4,0(sp)
80002454: 6145 addi sp,sp,48
80002456: 8082 ret
0000000080002458 <exit>:
{
80002458: 7179 addi sp,sp,-48
8000245a: f406 sd ra,40(sp)
8000245c: f022 sd s0,32(sp)
8000245e: ec26 sd s1,24(sp)
80002460: e84a sd s2,16(sp)
80002462: e44e sd s3,8(sp)
80002464: e052 sd s4,0(sp)
80002466: 1800 addi s0,sp,48
80002468: 8a2a mv s4,a0
struct proc *p = myproc();
8000246a: fffff097 auipc ra,0xfffff
8000246e: 514080e7 jalr 1300(ra) # 8000197e <myproc>
80002472: 892a mv s2,a0
p->ttime = ticks;
80002474: 00007797 auipc a5,0x7
80002478: bbc7a783 lw a5,-1092(a5) # 80009030 <ticks>
8000247c: c17c sw a5,68(a0)
if(p == initproc)
8000247e: 00007797 auipc a5,0x7
80002482: baa7b783 ld a5,-1110(a5) # 80009028 <initproc>
80002486: 10850493 addi s1,a0,264
8000248a: 18850993 addi s3,a0,392
8000248e: 02a79363 bne a5,a0,800024b4 <exit+0x5c>
panic("init exiting");
80002492: 00006517 auipc a0,0x6
80002496: db650513 addi a0,a0,-586 # 80008248 <digits+0x208>
8000249a: ffffe097 auipc ra,0xffffe
8000249e: 090080e7 jalr 144(ra) # 8000052a <panic>
fileclose(f);
800024a2: 00002097 auipc ra,0x2
800024a6: 4ba080e7 jalr 1210(ra) # 8000495c <fileclose>
p->ofile[fd] = 0;
800024aa: 0004b023 sd zero,0(s1)
for(int fd = 0; fd < NOFILE; fd++){
800024ae: 04a1 addi s1,s1,8
800024b0: 01348563 beq s1,s3,800024ba <exit+0x62>
if(p->ofile[fd]){
800024b4: 6088 ld a0,0(s1)
800024b6: f575 bnez a0,800024a2 <exit+0x4a>
800024b8: bfdd j 800024ae <exit+0x56>
begin_op();
800024ba: 00002097 auipc ra,0x2
800024be: fd6080e7 jalr -42(ra) # 80004490 <begin_op>
iput(p->cwd);
800024c2: 18893503 ld a0,392(s2)
800024c6: 00001097 auipc ra,0x1
800024ca: 7ae080e7 jalr 1966(ra) # 80003c74 <iput>
end_op();
800024ce: 00002097 auipc ra,0x2
800024d2: 042080e7 jalr 66(ra) # 80004510 <end_op>
p->cwd = 0;
800024d6: 18093423 sd zero,392(s2)
acquire(&wait_lock);
800024da: 0000f517 auipc a0,0xf
800024de: dde50513 addi a0,a0,-546 # 800112b8 <wait_lock>
800024e2: ffffe097 auipc ra,0xffffe
800024e6: 6e0080e7 jalr 1760(ra) # 80000bc2 <acquire>
reparent(p);
800024ea: 854a mv a0,s2
800024ec: 00000097 auipc ra,0x0
800024f0: f12080e7 jalr -238(ra) # 800023fe <reparent>
wakeup(p->parent);
800024f4: 07093503 ld a0,112(s2)
800024f8: 00000097 auipc ra,0x0
800024fc: e70080e7 jalr -400(ra) # 80002368 <wakeup>
acquire(&p->lock);
80002500: 854a mv a0,s2
80002502: ffffe097 auipc ra,0xffffe
80002506: 6c0080e7 jalr 1728(ra) # 80000bc2 <acquire>
p->xstate = status;
8000250a: 03492623 sw s4,44(s2)
if(p->state == RUNNING)
8000250e: 01892703 lw a4,24(s2)
80002512: 4791 li a5,4
80002514: 02f70963 beq a4,a5,80002546 <exit+0xee>
p->state = ZOMBIE;
80002518: 4795 li a5,5
8000251a: 00f92c23 sw a5,24(s2)
release(&wait_lock);
8000251e: 0000f517 auipc a0,0xf
80002522: d9a50513 addi a0,a0,-614 # 800112b8 <wait_lock>
80002526: ffffe097 auipc ra,0xffffe
8000252a: 750080e7 jalr 1872(ra) # 80000c76 <release>
sched();
8000252e: 00000097 auipc ra,0x0
80002532: a9a080e7 jalr -1382(ra) # 80001fc8 <sched>
panic("zombie exit");
80002536: 00006517 auipc a0,0x6
8000253a: d2250513 addi a0,a0,-734 # 80008258 <digits+0x218>
8000253e: ffffe097 auipc ra,0xffffe
80002542: fec080e7 jalr -20(ra) # 8000052a <panic>
p->rutime += ticks - p->runningTime;
80002546: 05092783 lw a5,80(s2)
8000254a: 00007717 auipc a4,0x7
8000254e: ae672703 lw a4,-1306(a4) # 80009030 <ticks>
80002552: 9fb9 addw a5,a5,a4
80002554: 06093703 ld a4,96(s2)
80002558: 9f99 subw a5,a5,a4
8000255a: 04f92823 sw a5,80(s2)
8000255e: bf6d j 80002518 <exit+0xc0>
0000000080002560 <set_priority>:
int
set_priority(int prio)
{
if(prio != TEST_HIGH_PRIORITY && prio != HIGH_PRIORITY && prio != NORMAL_PRIORITY
80002560: 47e5 li a5,25
80002562: 04a7e963 bltu a5,a0,800025b4 <set_priority+0x54>
{
80002566: 1101 addi sp,sp,-32
80002568: ec06 sd ra,24(sp)
8000256a: e822 sd s0,16(sp)
8000256c: e426 sd s1,8(sp)
8000256e: e04a sd s2,0(sp)
80002570: 1000 addi s0,sp,32
80002572: 892a mv s2,a0
if(prio != TEST_HIGH_PRIORITY && prio != HIGH_PRIORITY && prio != NORMAL_PRIORITY
80002574: 020007b7 lui a5,0x2000
80002578: 0aa78793 addi a5,a5,170 # 20000aa <_entry-0x7dffff56>
8000257c: 00a7d7b3 srl a5,a5,a0
80002580: 8b85 andi a5,a5,1
&& prio != LOW_PRIORITY && prio != TEST_LOW_PRIORITY){
return -1;
80002582: 557d li a0,-1
if(prio != TEST_HIGH_PRIORITY && prio != HIGH_PRIORITY && prio != NORMAL_PRIORITY
80002584: c395 beqz a5,800025a8 <set_priority+0x48>
}
struct proc *p = myproc();
80002586: fffff097 auipc ra,0xfffff
8000258a: 3f8080e7 jalr 1016(ra) # 8000197e <myproc>
8000258e: 84aa mv s1,a0
acquire(&p->lock);
80002590: ffffe097 auipc ra,0xffffe
80002594: 632080e7 jalr 1586(ra) # 80000bc2 <acquire>
p->priority = prio;
80002598: 0324ae23 sw s2,60(s1)
release(&p->lock);
8000259c: 8526 mv a0,s1
8000259e: ffffe097 auipc ra,0xffffe
800025a2: 6d8080e7 jalr 1752(ra) # 80000c76 <release>
return 0;
800025a6: 4501 li a0,0
}
800025a8: 60e2 ld ra,24(sp)
800025aa: 6442 ld s0,16(sp)
800025ac: 64a2 ld s1,8(sp)
800025ae: 6902 ld s2,0(sp)
800025b0: 6105 addi sp,sp,32
800025b2: 8082 ret
return -1;
800025b4: 557d li a0,-1
}
800025b6: 8082 ret
00000000800025b8 <trace>:
int
trace(int mask_input, int pid)
{
800025b8: 7179 addi sp,sp,-48
800025ba: f406 sd ra,40(sp)
800025bc: f022 sd s0,32(sp)
800025be: ec26 sd s1,24(sp)
800025c0: e84a sd s2,16(sp)
800025c2: e44e sd s3,8(sp)
800025c4: e052 sd s4,0(sp)
800025c6: 1800 addi s0,sp,48
800025c8: 8a2a mv s4,a0
800025ca: 892e mv s2,a1
struct proc *p;
for(p = proc; p < &proc[NPROC]; p++){
800025cc: 0000f497 auipc s1,0xf
800025d0: 10448493 addi s1,s1,260 # 800116d0 <proc>
800025d4: 00016997 auipc s3,0x16
800025d8: 8fc98993 addi s3,s3,-1796 # 80017ed0 <tickslock>
800025dc: a811 j 800025f0 <trace+0x38>
acquire(&p->lock);
if(p->pid == pid)
p->mask = mask_input;
release(&p->lock);
800025de: 8526 mv a0,s1
800025e0: ffffe097 auipc ra,0xffffe
800025e4: 696080e7 jalr 1686(ra) # 80000c76 <release>
for(p = proc; p < &proc[NPROC]; p++){
800025e8: 1a048493 addi s1,s1,416
800025ec: 01348d63 beq s1,s3,80002606 <trace+0x4e>
acquire(&p->lock);
800025f0: 8526 mv a0,s1
800025f2: ffffe097 auipc ra,0xffffe
800025f6: 5d0080e7 jalr 1488(ra) # 80000bc2 <acquire>
if(p->pid == pid)
800025fa: 589c lw a5,48(s1)
800025fc: ff2791e3 bne a5,s2,800025de <trace+0x26>
p->mask = mask_input;
80002600: 0344aa23 sw s4,52(s1)
80002604: bfe9 j 800025de <trace+0x26>
}
return 0;
}
80002606: 4501 li a0,0
80002608: 70a2 ld ra,40(sp)
8000260a: 7402 ld s0,32(sp)
8000260c: 64e2 ld s1,24(sp)
8000260e: 6942 ld s2,16(sp)
80002610: 69a2 ld s3,8(sp)
80002612: 6a02 ld s4,0(sp)
80002614: 6145 addi sp,sp,48
80002616: 8082 ret
0000000080002618 <kill>:
// Kill the process with the given pid.
// The victim won't exit until it tries to return
// to user space (see usertrap() in trap.c).
int
kill(int pid)
{
80002618: 7179 addi sp,sp,-48
8000261a: f406 sd ra,40(sp)
8000261c: f022 sd s0,32(sp)
8000261e: ec26 sd s1,24(sp)
80002620: e84a sd s2,16(sp)
80002622: e44e sd s3,8(sp)
80002624: 1800 addi s0,sp,48
80002626: 892a mv s2,a0
struct proc *p;
for(p = proc; p < &proc[NPROC]; p++){
80002628: 0000f497 auipc s1,0xf
8000262c: 0a848493 addi s1,s1,168 # 800116d0 <proc>
80002630: 00016997 auipc s3,0x16
80002634: 8a098993 addi s3,s3,-1888 # 80017ed0 <tickslock>
acquire(&p->lock);
80002638: 8526 mv a0,s1
8000263a: ffffe097 auipc ra,0xffffe
8000263e: 588080e7 jalr 1416(ra) # 80000bc2 <acquire>
if(p->pid == pid){
80002642: 589c lw a5,48(s1)
80002644: 01278d63 beq a5,s2,8000265e <kill+0x46>
p->readyTime = ticks;
}
release(&p->lock);
return 0;
}
release(&p->lock);
80002648: 8526 mv a0,s1
8000264a: ffffe097 auipc ra,0xffffe
8000264e: 62c080e7 jalr 1580(ra) # 80000c76 <release>
for(p = proc; p < &proc[NPROC]; p++){
80002652: 1a048493 addi s1,s1,416
80002656: ff3491e3 bne s1,s3,80002638 <kill+0x20>
}
return -1;
8000265a: 557d li a0,-1
8000265c: a829 j 80002676 <kill+0x5e>
p->killed = 1;
8000265e: 4785 li a5,1
80002660: d49c sw a5,40(s1)
if(p->state == SLEEPING){
80002662: 4c98 lw a4,24(s1)
80002664: 4789 li a5,2
80002666: 00f70f63 beq a4,a5,80002684 <kill+0x6c>
release(&p->lock);
8000266a: 8526 mv a0,s1
8000266c: ffffe097 auipc ra,0xffffe
80002670: 60a080e7 jalr 1546(ra) # 80000c76 <release>
return 0;
80002674: 4501 li a0,0
}
80002676: 70a2 ld ra,40(sp)
80002678: 7402 ld s0,32(sp)
8000267a: 64e2 ld s1,24(sp)
8000267c: 6942 ld s2,16(sp)
8000267e: 69a2 ld s3,8(sp)
80002680: 6145 addi sp,sp,48
80002682: 8082 ret
p->state = RUNNABLE;
80002684: 478d li a5,3
80002686: cc9c sw a5,24(s1)
p->stime += ticks - p->sleepTime;
80002688: 00007717 auipc a4,0x7
8000268c: 9a872703 lw a4,-1624(a4) # 80009030 <ticks>
80002690: 44bc lw a5,72(s1)
80002692: 9fb9 addw a5,a5,a4
80002694: 74b4 ld a3,104(s1)
80002696: 9f95 subw a5,a5,a3
80002698: c4bc sw a5,72(s1)
p->readyTime = ticks;
8000269a: 1702 slli a4,a4,0x20
8000269c: 9301 srli a4,a4,0x20
8000269e: ecb8 sd a4,88(s1)
800026a0: b7e9 j 8000266a <kill+0x52>
00000000800026a2 <either_copyout>:
// Copy to either a user address, or kernel address,
// depending on usr_dst.
// Returns 0 on success, -1 on error.
int
either_copyout(int user_dst, uint64 dst, void *src, uint64 len)
{
800026a2: 7179 addi sp,sp,-48
800026a4: f406 sd ra,40(sp)
800026a6: f022 sd s0,32(sp)
800026a8: ec26 sd s1,24(sp)
800026aa: e84a sd s2,16(sp)
800026ac: e44e sd s3,8(sp)
800026ae: e052 sd s4,0(sp)
800026b0: 1800 addi s0,sp,48
800026b2: 84aa mv s1,a0
800026b4: 892e mv s2,a1
800026b6: 89b2 mv s3,a2
800026b8: 8a36 mv s4,a3
struct proc *p = myproc();
800026ba: fffff097 auipc ra,0xfffff
800026be: 2c4080e7 jalr 708(ra) # 8000197e <myproc>
if(user_dst){
800026c2: c08d beqz s1,800026e4 <either_copyout+0x42>
return copyout(p->pagetable, dst, src, len);
800026c4: 86d2 mv a3,s4
800026c6: 864e mv a2,s3
800026c8: 85ca mv a1,s2
800026ca: 6548 ld a0,136(a0)
800026cc: fffff097 auipc ra,0xfffff
800026d0: f72080e7 jalr -142(ra) # 8000163e <copyout>
} else {
memmove((char *)dst, src, len);
return 0;
}
}
800026d4: 70a2 ld ra,40(sp)
800026d6: 7402 ld s0,32(sp)
800026d8: 64e2 ld s1,24(sp)
800026da: 6942 ld s2,16(sp)
800026dc: 69a2 ld s3,8(sp)
800026de: 6a02 ld s4,0(sp)
800026e0: 6145 addi sp,sp,48
800026e2: 8082 ret
memmove((char *)dst, src, len);
800026e4: 000a061b sext.w a2,s4
800026e8: 85ce mv a1,s3
800026ea: 854a mv a0,s2
800026ec: ffffe097 auipc ra,0xffffe
800026f0: 62e080e7 jalr 1582(ra) # 80000d1a <memmove>
return 0;
800026f4: 8526 mv a0,s1
800026f6: bff9 j 800026d4 <either_copyout+0x32>
00000000800026f8 <either_copyin>:
// Copy from either a user address, or kernel address,
// depending on usr_src.
// Returns 0 on success, -1 on error.
int
either_copyin(void *dst, int user_src, uint64 src, uint64 len)
{
800026f8: 7179 addi sp,sp,-48
800026fa: f406 sd ra,40(sp)
800026fc: f022 sd s0,32(sp)
800026fe: ec26 sd s1,24(sp)
80002700: e84a sd s2,16(sp)
80002702: e44e sd s3,8(sp)
80002704: e052 sd s4,0(sp)
80002706: 1800 addi s0,sp,48
80002708: 892a mv s2,a0
8000270a: 84ae mv s1,a1
8000270c: 89b2 mv s3,a2
8000270e: 8a36 mv s4,a3
struct proc *p = myproc();
80002710: fffff097 auipc ra,0xfffff
80002714: 26e080e7 jalr 622(ra) # 8000197e <myproc>
if(user_src){
80002718: c08d beqz s1,8000273a <either_copyin+0x42>
return copyin(p->pagetable, dst, src, len);
8000271a: 86d2 mv a3,s4
8000271c: 864e mv a2,s3
8000271e: 85ca mv a1,s2
80002720: 6548 ld a0,136(a0)
80002722: fffff097 auipc ra,0xfffff
80002726: fa8080e7 jalr -88(ra) # 800016ca <copyin>
} else {
memmove(dst, (char*)src, len);
return 0;
}
}
8000272a: 70a2 ld ra,40(sp)
8000272c: 7402 ld s0,32(sp)
8000272e: 64e2 ld s1,24(sp)
80002730: 6942 ld s2,16(sp)
80002732: 69a2 ld s3,8(sp)
80002734: 6a02 ld s4,0(sp)
80002736: 6145 addi sp,sp,48
80002738: 8082 ret
memmove(dst, (char*)src, len);
8000273a: 000a061b sext.w a2,s4
8000273e: 85ce mv a1,s3
80002740: 854a mv a0,s2
80002742: ffffe097 auipc ra,0xffffe
80002746: 5d8080e7 jalr 1496(ra) # 80000d1a <memmove>
return 0;
8000274a: 8526 mv a0,s1
8000274c: bff9 j 8000272a <either_copyin+0x32>
000000008000274e <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)
{
8000274e: 715d addi sp,sp,-80
80002750: e486 sd ra,72(sp)
80002752: e0a2 sd s0,64(sp)
80002754: fc26 sd s1,56(sp)
80002756: f84a sd s2,48(sp)
80002758: f44e sd s3,40(sp)
8000275a: f052 sd s4,32(sp)
8000275c: ec56 sd s5,24(sp)
8000275e: e85a sd s6,16(sp)
80002760: e45e sd s7,8(sp)
80002762: 0880 addi s0,sp,80
[ZOMBIE] "zombie"
};
struct proc *p;
char *state;
printf("\n");
80002764: 00006517 auipc a0,0x6
80002768: 96450513 addi a0,a0,-1692 # 800080c8 <digits+0x88>
8000276c: ffffe097 auipc ra,0xffffe
80002770: e08080e7 jalr -504(ra) # 80000574 <printf>
for(p = proc; p < &proc[NPROC]; p++){
80002774: 0000f497 auipc s1,0xf
80002778: 0ec48493 addi s1,s1,236 # 80011860 <proc+0x190>
8000277c: 00016917 auipc s2,0x16
80002780: 8e490913 addi s2,s2,-1820 # 80018060 <bcache+0x178>
if(p->state == UNUSED)
continue;
if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
80002784: 4b15 li s6,5
state = states[p->state];
else
state = "???";
80002786: 00006997 auipc s3,0x6
8000278a: ae298993 addi s3,s3,-1310 # 80008268 <digits+0x228>
printf("%d %s %s", p->pid, state, p->name);
8000278e: 00006a97 auipc s5,0x6
80002792: ae2a8a93 addi s5,s5,-1310 # 80008270 <digits+0x230>
printf("\n");
80002796: 00006a17 auipc s4,0x6
8000279a: 932a0a13 addi s4,s4,-1742 # 800080c8 <digits+0x88>
if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
8000279e: 00006b97 auipc s7,0x6
800027a2: b0ab8b93 addi s7,s7,-1270 # 800082a8 <states.0>
800027a6: a00d j 800027c8 <procdump+0x7a>
printf("%d %s %s", p->pid, state, p->name);
800027a8: ea06a583 lw a1,-352(a3)
800027ac: 8556 mv a0,s5
800027ae: ffffe097 auipc ra,0xffffe
800027b2: dc6080e7 jalr -570(ra) # 80000574 <printf>
printf("\n");
800027b6: 8552 mv a0,s4
800027b8: ffffe097 auipc ra,0xffffe
800027bc: dbc080e7 jalr -580(ra) # 80000574 <printf>
for(p = proc; p < &proc[NPROC]; p++){
800027c0: 1a048493 addi s1,s1,416
800027c4: 03248263 beq s1,s2,800027e8 <procdump+0x9a>
if(p->state == UNUSED)
800027c8: 86a6 mv a3,s1
800027ca: e884a783 lw a5,-376(s1)
800027ce: dbed beqz a5,800027c0 <procdump+0x72>
state = "???";
800027d0: 864e mv a2,s3
if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
800027d2: fcfb6be3 bltu s6,a5,800027a8 <procdump+0x5a>
800027d6: 02079713 slli a4,a5,0x20
800027da: 01d75793 srli a5,a4,0x1d
800027de: 97de add a5,a5,s7
800027e0: 6390 ld a2,0(a5)
800027e2: f279 bnez a2,800027a8 <procdump+0x5a>
state = "???";
800027e4: 864e mv a2,s3
800027e6: b7c9 j 800027a8 <procdump+0x5a>
}
}
800027e8: 60a6 ld ra,72(sp)
800027ea: 6406 ld s0,64(sp)
800027ec: 74e2 ld s1,56(sp)
800027ee: 7942 ld s2,48(sp)
800027f0: 79a2 ld s3,40(sp)
800027f2: 7a02 ld s4,32(sp)
800027f4: 6ae2 ld s5,24(sp)
800027f6: 6b42 ld s6,16(sp)
800027f8: 6ba2 ld s7,8(sp)
800027fa: 6161 addi sp,sp,80
800027fc: 8082 ret
00000000800027fe <wait_stat>:
int
wait_stat(int* status, struct perf* performance)
{
800027fe: 1141 addi sp,sp,-16
80002800: e406 sd ra,8(sp)
80002802: e022 sd s0,0(sp)
80002804: 0800 addi s0,sp,16
return wait_extension ((uint64)*status, performance);
80002806: 4108 lw a0,0(a0)
80002808: 00000097 auipc ra,0x0
8000280c: 962080e7 jalr -1694(ra) # 8000216a <wait_extension>
}
80002810: 60a2 ld ra,8(sp)
80002812: 6402 ld s0,0(sp)
80002814: 0141 addi sp,sp,16
80002816: 8082 ret
0000000080002818 <inctickcounter>:
int inctickcounter() {
80002818: 1101 addi sp,sp,-32
8000281a: ec06 sd ra,24(sp)
8000281c: e822 sd s0,16(sp)
8000281e: e426 sd s1,8(sp)
80002820: e04a sd s2,0(sp)
80002822: 1000 addi s0,sp,32
int res;
struct proc *p = myproc();
80002824: fffff097 auipc ra,0xfffff
80002828: 15a080e7 jalr 346(ra) # 8000197e <myproc>
8000282c: 84aa mv s1,a0
acquire(&p->lock);
8000282e: ffffe097 auipc ra,0xffffe
80002832: 394080e7 jalr 916(ra) # 80000bc2 <acquire>
res = proc->tickcounter;
80002836: 0000f917 auipc s2,0xf
8000283a: ed292903 lw s2,-302(s2) # 80011708 <proc+0x38>
res++;
release(&p->lock);
8000283e: 8526 mv a0,s1
80002840: ffffe097 auipc ra,0xffffe
80002844: 436080e7 jalr 1078(ra) # 80000c76 <release>
return res;
}
80002848: 0019051b addiw a0,s2,1
8000284c: 60e2 ld ra,24(sp)
8000284e: 6442 ld s0,16(sp)
80002850: 64a2 ld s1,8(sp)
80002852: 6902 ld s2,0(sp)
80002854: 6105 addi sp,sp,32
80002856: 8082 ret
0000000080002858 <switch_to_process>:
void switch_to_process(struct proc *p, struct cpu *c){
80002858: 1101 addi sp,sp,-32
8000285a: ec06 sd ra,24(sp)
8000285c: e822 sd s0,16(sp)
8000285e: e426 sd s1,8(sp)
80002860: 1000 addi s0,sp,32
80002862: 84ae mv s1,a1
// Switch to chosen process. It is the process's job
// to release its lock and then reacquire it
// before jumping back to us.
p->state = RUNNING;
80002864: 4791 li a5,4
80002866: cd1c sw a5,24(a0)
p->retime += ticks - p->readyTime;
80002868: 457c lw a5,76(a0)
8000286a: 00006717 auipc a4,0x6
8000286e: 7c672703 lw a4,1990(a4) # 80009030 <ticks>
80002872: 9fb9 addw a5,a5,a4
80002874: 6d38 ld a4,88(a0)
80002876: 9f99 subw a5,a5,a4
80002878: c57c sw a5,76(a0)
p->average_bursttime = (ALPHA * p->tickcounter) + (((100 - ALPHA) * p->average_bursttime) / 100);
8000287a: 5d18 lw a4,56(a0)
8000287c: 03200793 li a5,50
80002880: 02e787bb mulw a5,a5,a4
80002884: 4974 lw a3,84(a0)
80002886: 01f6d71b srliw a4,a3,0x1f
8000288a: 9f35 addw a4,a4,a3
8000288c: 4017571b sraiw a4,a4,0x1
80002890: 9fb9 addw a5,a5,a4
80002892: c97c sw a5,84(a0)
p->tickcounter = 0;
80002894: 02052c23 sw zero,56(a0)
c->proc = p;
80002898: e188 sd a0,0(a1)
swtch(&c->context, &p->context);
8000289a: 09850593 addi a1,a0,152
8000289e: 00848513 addi a0,s1,8
800028a2: 00000097 auipc ra,0x0
800028a6: 016080e7 jalr 22(ra) # 800028b8 <swtch>
// Process is done running for now.
// It should have changed its p->state before coming back.
c->proc = 0;
800028aa: 0004b023 sd zero,0(s1)
}
800028ae: 60e2 ld ra,24(sp)
800028b0: 6442 ld s0,16(sp)
800028b2: 64a2 ld s1,8(sp)
800028b4: 6105 addi sp,sp,32
800028b6: 8082 ret
00000000800028b8 <swtch>:
800028b8: 00153023 sd ra,0(a0)
800028bc: 00253423 sd sp,8(a0)
800028c0: e900 sd s0,16(a0)
800028c2: ed04 sd s1,24(a0)
800028c4: 03253023 sd s2,32(a0)
800028c8: 03353423 sd s3,40(a0)
800028cc: 03453823 sd s4,48(a0)
800028d0: 03553c23 sd s5,56(a0)
800028d4: 05653023 sd s6,64(a0)
800028d8: 05753423 sd s7,72(a0)
800028dc: 05853823 sd s8,80(a0)
800028e0: 05953c23 sd s9,88(a0)
800028e4: 07a53023 sd s10,96(a0)
800028e8: 07b53423 sd s11,104(a0)
800028ec: 0005b083 ld ra,0(a1)
800028f0: 0085b103 ld sp,8(a1)
800028f4: 6980 ld s0,16(a1)
800028f6: 6d84 ld s1,24(a1)
800028f8: 0205b903 ld s2,32(a1)
800028fc: 0285b983 ld s3,40(a1)
80002900: 0305ba03 ld s4,48(a1)
80002904: 0385ba83 ld s5,56(a1)
80002908: 0405bb03 ld s6,64(a1)
8000290c: 0485bb83 ld s7,72(a1)
80002910: 0505bc03 ld s8,80(a1)
80002914: 0585bc83 ld s9,88(a1)
80002918: 0605bd03 ld s10,96(a1)
8000291c: 0685bd83 ld s11,104(a1)
80002920: 8082 ret
0000000080002922 <trapinit>:
extern int devintr();
void
trapinit(void)
{
80002922: 1141 addi sp,sp,-16
80002924: e406 sd ra,8(sp)
80002926: e022 sd s0,0(sp)
80002928: 0800 addi s0,sp,16
initlock(&tickslock, "time");
8000292a: 00006597 auipc a1,0x6
8000292e: 9ae58593 addi a1,a1,-1618 # 800082d8 <states.0+0x30>
80002932: 00015517 auipc a0,0x15
80002936: 59e50513 addi a0,a0,1438 # 80017ed0 <tickslock>
8000293a: ffffe097 auipc ra,0xffffe
8000293e: 1f8080e7 jalr 504(ra) # 80000b32 <initlock>
}
80002942: 60a2 ld ra,8(sp)
80002944: 6402 ld s0,0(sp)
80002946: 0141 addi sp,sp,16
80002948: 8082 ret
000000008000294a <trapinithart>:
// set up to take exceptions and traps while in the kernel.
void
trapinithart(void)
{
8000294a: 1141 addi sp,sp,-16
8000294c: e422 sd s0,8(sp)
8000294e: 0800 addi s0,sp,16
asm volatile("csrw stvec, %0" : : "r" (x));
80002950: 00003797 auipc a5,0x3
80002954: 64078793 addi a5,a5,1600 # 80005f90 <kernelvec>
80002958: 10579073 csrw stvec,a5
w_stvec((uint64)kernelvec);
}
8000295c: 6422 ld s0,8(sp)
8000295e: 0141 addi sp,sp,16
80002960: 8082 ret
0000000080002962 <usertrapret>:
//
// return to user space
//
void
usertrapret(void)
{
80002962: 1141 addi sp,sp,-16
80002964: e406 sd ra,8(sp)
80002966: e022 sd s0,0(sp)
80002968: 0800 addi s0,sp,16
struct proc *p = myproc();
8000296a: fffff097 auipc ra,0xfffff
8000296e: 014080e7 jalr 20(ra) # 8000197e <myproc>
asm volatile("csrr %0, sstatus" : "=r" (x) );
80002972: 100027f3 csrr a5,sstatus
w_sstatus(r_sstatus() & ~SSTATUS_SIE);
80002976: 9bf5 andi a5,a5,-3
asm volatile("csrw sstatus, %0" : : "r" (x));
80002978: 10079073 csrw sstatus,a5
// kerneltrap() to usertrap(), so turn off interrupts until
// we're back in user space, where usertrap() is correct.
intr_off();
// send syscalls, interrupts, and exceptions to trampoline.S
w_stvec(TRAMPOLINE + (uservec - trampoline));
8000297c: 00004617 auipc a2,0x4
80002980: 68460613 addi a2,a2,1668 # 80007000 <_trampoline>
80002984: 00004697 auipc a3,0x4
80002988: 67c68693 addi a3,a3,1660 # 80007000 <_trampoline>
8000298c: 8e91 sub a3,a3,a2
8000298e: 040007b7 lui a5,0x4000
80002992: 17fd addi a5,a5,-1
80002994: 07b2 slli a5,a5,0xc
80002996: 96be add a3,a3,a5
asm volatile("csrw stvec, %0" : : "r" (x));
80002998: 10569073 csrw stvec,a3
// set up trapframe values that uservec will need when
// the process next re-enters the kernel.
p->trapframe->kernel_satp = r_satp(); // kernel page table
8000299c: 6958 ld a4,144(a0)
asm volatile("csrr %0, satp" : "=r" (x) );
8000299e: 180026f3 csrr a3,satp
800029a2: e314 sd a3,0(a4)
p->trapframe->kernel_sp = p->kstack + PGSIZE; // process's kernel stack
800029a4: 6958 ld a4,144(a0)
800029a6: 7d34 ld a3,120(a0)
800029a8: 6585 lui a1,0x1
800029aa: 96ae add a3,a3,a1
800029ac: e714 sd a3,8(a4)
p->trapframe->kernel_trap = (uint64)usertrap;
800029ae: 6958 ld a4,144(a0)
800029b0: 00000697 auipc a3,0x0
800029b4: 13868693 addi a3,a3,312 # 80002ae8 <usertrap>
800029b8: eb14 sd a3,16(a4)
p->trapframe->kernel_hartid = r_tp(); // hartid for cpuid()
800029ba: 6958 ld a4,144(a0)
asm volatile("mv %0, tp" : "=r" (x) );
800029bc: 8692 mv a3,tp
800029be: f314 sd a3,32(a4)
asm volatile("csrr %0, sstatus" : "=r" (x) );
800029c0: 100026f3 csrr a3,sstatus
// set up the registers that trampoline.S's sret will use
// to get to user space.
// set S Previous Privilege mode to User.
unsigned long x = r_sstatus();
x &= ~SSTATUS_SPP; // clear SPP to 0 for user mode
800029c4: eff6f693 andi a3,a3,-257
x |= SSTATUS_SPIE; // enable interrupts in user mode
800029c8: 0206e693 ori a3,a3,32
asm volatile("csrw sstatus, %0" : : "r" (x));
800029cc: 10069073 csrw sstatus,a3
w_sstatus(x);
// set S Exception Program Counter to the saved user pc.
w_sepc(p->trapframe->epc);
800029d0: 6958 ld a4,144(a0)
asm volatile("csrw sepc, %0" : : "r" (x));
800029d2: 6f18 ld a4,24(a4)
800029d4: 14171073 csrw sepc,a4
// tell trampoline.S the user page table to switch to.
uint64 satp = MAKE_SATP(p->pagetable);
800029d8: 654c ld a1,136(a0)
800029da: 81b1 srli a1,a1,0xc
// jump to trampoline.S at the top of memory, which
// switches to the user page table, restores user registers,
// and switches to user mode with sret.
uint64 fn = TRAMPOLINE + (userret - trampoline);
800029dc: 00004717 auipc a4,0x4
800029e0: 6b470713 addi a4,a4,1716 # 80007090 <userret>
800029e4: 8f11 sub a4,a4,a2
800029e6: 97ba add a5,a5,a4
((void (*)(uint64,uint64))fn)(TRAPFRAME, satp);
800029e8: 577d li a4,-1
800029ea: 177e slli a4,a4,0x3f
800029ec: 8dd9 or a1,a1,a4
800029ee: 02000537 lui a0,0x2000
800029f2: 157d addi a0,a0,-1
800029f4: 0536 slli a0,a0,0xd
800029f6: 9782 jalr a5
}
800029f8: 60a2 ld ra,8(sp)
800029fa: 6402 ld s0,0(sp)
800029fc: 0141 addi sp,sp,16
800029fe: 8082 ret
0000000080002a00 <clockintr>:
w_sstatus(sstatus);
}
void
clockintr()
{
80002a00: 1101 addi sp,sp,-32
80002a02: ec06 sd ra,24(sp)
80002a04: e822 sd s0,16(sp)
80002a06: e426 sd s1,8(sp)
80002a08: 1000 addi s0,sp,32
acquire(&tickslock);
80002a0a: 00015497 auipc s1,0x15
80002a0e: 4c648493 addi s1,s1,1222 # 80017ed0 <tickslock>
80002a12: 8526 mv a0,s1
80002a14: ffffe097 auipc ra,0xffffe
80002a18: 1ae080e7 jalr 430(ra) # 80000bc2 <acquire>
ticks++;
80002a1c: 00006517 auipc a0,0x6
80002a20: 61450513 addi a0,a0,1556 # 80009030 <ticks>
80002a24: 411c lw a5,0(a0)
80002a26: 2785 addiw a5,a5,1
80002a28: c11c sw a5,0(a0)
wakeup(&ticks);
80002a2a: 00000097 auipc ra,0x0
80002a2e: 93e080e7 jalr -1730(ra) # 80002368 <wakeup>
release(&tickslock);
80002a32: 8526 mv a0,s1
80002a34: ffffe097 auipc ra,0xffffe
80002a38: 242080e7 jalr 578(ra) # 80000c76 <release>
}
80002a3c: 60e2 ld ra,24(sp)
80002a3e: 6442 ld s0,16(sp)
80002a40: 64a2 ld s1,8(sp)
80002a42: 6105 addi sp,sp,32
80002a44: 8082 ret
0000000080002a46 <devintr>:
// returns 2 if timer interrupt,
// 1 if other device,
// 0 if not recognized.
int
devintr()
{
80002a46: 1101 addi sp,sp,-32
80002a48: ec06 sd ra,24(sp)
80002a4a: e822 sd s0,16(sp)
80002a4c: e426 sd s1,8(sp)
80002a4e: 1000 addi s0,sp,32
asm volatile("csrr %0, scause" : "=r" (x) );
80002a50: 14202773 csrr a4,scause
uint64 scause = r_scause();
if((scause & 0x8000000000000000L) &&
80002a54: 00074d63 bltz a4,80002a6e <devintr+0x28>
// now allowed to interrupt again.
if(irq)
plic_complete(irq);
return 1;
} else if(scause == 0x8000000000000001L){
80002a58: 57fd li a5,-1
80002a5a: 17fe slli a5,a5,0x3f
80002a5c: 0785 addi a5,a5,1
// the SSIP bit in sip.
w_sip(r_sip() & ~2);
return 2;
} else {
return 0;
80002a5e: 4501 li a0,0
} else if(scause == 0x8000000000000001L){
80002a60: 06f70363 beq a4,a5,80002ac6 <devintr+0x80>
}
}
80002a64: 60e2 ld ra,24(sp)
80002a66: 6442 ld s0,16(sp)
80002a68: 64a2 ld s1,8(sp)
80002a6a: 6105 addi sp,sp,32
80002a6c: 8082 ret
(scause & 0xff) == 9){
80002a6e: 0ff77793 andi a5,a4,255
if((scause & 0x8000000000000000L) &&
80002a72: 46a5 li a3,9
80002a74: fed792e3 bne a5,a3,80002a58 <devintr+0x12>
int irq = plic_claim();
80002a78: 00003097 auipc ra,0x3
80002a7c: 620080e7 jalr 1568(ra) # 80006098 <plic_claim>
80002a80: 84aa mv s1,a0
if(irq == UART0_IRQ){
80002a82: 47a9 li a5,10
80002a84: 02f50763 beq a0,a5,80002ab2 <devintr+0x6c>
} else if(irq == VIRTIO0_IRQ){
80002a88: 4785 li a5,1
80002a8a: 02f50963 beq a0,a5,80002abc <devintr+0x76>
return 1;
80002a8e: 4505 li a0,1
} else if(irq){
80002a90: d8f1 beqz s1,80002a64 <devintr+0x1e>
printf("unexpected interrupt irq=%d\n", irq);
80002a92: 85a6 mv a1,s1
80002a94: 00006517 auipc a0,0x6
80002a98: 84c50513 addi a0,a0,-1972 # 800082e0 <states.0+0x38>
80002a9c: ffffe097 auipc ra,0xffffe
80002aa0: ad8080e7 jalr -1320(ra) # 80000574 <printf>
plic_complete(irq);
80002aa4: 8526 mv a0,s1
80002aa6: 00003097 auipc ra,0x3
80002aaa: 616080e7 jalr 1558(ra) # 800060bc <plic_complete>
return 1;
80002aae: 4505 li a0,1
80002ab0: bf55 j 80002a64 <devintr+0x1e>
uartintr();
80002ab2: ffffe097 auipc ra,0xffffe
80002ab6: ed4080e7 jalr -300(ra) # 80000986 <uartintr>
80002aba: b7ed j 80002aa4 <devintr+0x5e>
virtio_disk_intr();
80002abc: 00004097 auipc ra,0x4
80002ac0: a92080e7 jalr -1390(ra) # 8000654e <virtio_disk_intr>
80002ac4: b7c5 j 80002aa4 <devintr+0x5e>
if(cpuid() == 0){
80002ac6: fffff097 auipc ra,0xfffff
80002aca: e8c080e7 jalr -372(ra) # 80001952 <cpuid>
80002ace: c901 beqz a0,80002ade <devintr+0x98>
asm volatile("csrr %0, sip" : "=r" (x) );
80002ad0: 144027f3 csrr a5,sip
w_sip(r_sip() & ~2);
80002ad4: 9bf5 andi a5,a5,-3
asm volatile("csrw sip, %0" : : "r" (x));
80002ad6: 14479073 csrw sip,a5
return 2;
80002ada: 4509 li a0,2
80002adc: b761 j 80002a64 <devintr+0x1e>
clockintr();
80002ade: 00000097 auipc ra,0x0
80002ae2: f22080e7 jalr -222(ra) # 80002a00 <clockintr>
80002ae6: b7ed j 80002ad0 <devintr+0x8a>
0000000080002ae8 <usertrap>:
{
80002ae8: 1101 addi sp,sp,-32
80002aea: ec06 sd ra,24(sp)
80002aec: e822 sd s0,16(sp)
80002aee: e426 sd s1,8(sp)
80002af0: e04a sd s2,0(sp)
80002af2: 1000 addi s0,sp,32
asm volatile("csrr %0, sstatus" : "=r" (x) );
80002af4: 100027f3 csrr a5,sstatus
if((r_sstatus() & SSTATUS_SPP) != 0)
80002af8: 1007f793 andi a5,a5,256
80002afc: e3ad bnez a5,80002b5e <usertrap+0x76>
asm volatile("csrw stvec, %0" : : "r" (x));
80002afe: 00003797 auipc a5,0x3
80002b02: 49278793 addi a5,a5,1170 # 80005f90 <kernelvec>
80002b06: 10579073 csrw stvec,a5
struct proc *p = myproc();
80002b0a: fffff097 auipc ra,0xfffff
80002b0e: e74080e7 jalr -396(ra) # 8000197e <myproc>
80002b12: 84aa mv s1,a0
p->trapframe->epc = r_sepc();
80002b14: 695c ld a5,144(a0)
asm volatile("csrr %0, sepc" : "=r" (x) );
80002b16: 14102773 csrr a4,sepc
80002b1a: ef98 sd a4,24(a5)
asm volatile("csrr %0, scause" : "=r" (x) );
80002b1c: 14202773 csrr a4,scause
if(r_scause() == 8){
80002b20: 47a1 li a5,8
80002b22: 04f71c63 bne a4,a5,80002b7a <usertrap+0x92>
if(p->killed)
80002b26: 551c lw a5,40(a0)
80002b28: e3b9 bnez a5,80002b6e <usertrap+0x86>
p->trapframe->epc += 4;
80002b2a: 68d8 ld a4,144(s1)
80002b2c: 6f1c ld a5,24(a4)
80002b2e: 0791 addi a5,a5,4
80002b30: ef1c sd a5,24(a4)
asm volatile("csrr %0, sstatus" : "=r" (x) );
80002b32: 100027f3 csrr a5,sstatus
w_sstatus(r_sstatus() | SSTATUS_SIE);
80002b36: 0027e793 ori a5,a5,2
asm volatile("csrw sstatus, %0" : : "r" (x));
80002b3a: 10079073 csrw sstatus,a5
syscall();
80002b3e: 00000097 auipc ra,0x0
80002b42: 2fc080e7 jalr 764(ra) # 80002e3a <syscall>
if(p->killed)
80002b46: 549c lw a5,40(s1)
80002b48: efd9 bnez a5,80002be6 <usertrap+0xfe>
usertrapret();
80002b4a: 00000097 auipc ra,0x0
80002b4e: e18080e7 jalr -488(ra) # 80002962 <usertrapret>
}
80002b52: 60e2 ld ra,24(sp)
80002b54: 6442 ld s0,16(sp)
80002b56: 64a2 ld s1,8(sp)
80002b58: 6902 ld s2,0(sp)
80002b5a: 6105 addi sp,sp,32
80002b5c: 8082 ret
panic("usertrap: not from user mode");
80002b5e: 00005517 auipc a0,0x5
80002b62: 7a250513 addi a0,a0,1954 # 80008300 <states.0+0x58>
80002b66: ffffe097 auipc ra,0xffffe
80002b6a: 9c4080e7 jalr -1596(ra) # 8000052a <panic>
exit(-1);
80002b6e: 557d li a0,-1
80002b70: 00000097 auipc ra,0x0
80002b74: 8e8080e7 jalr -1816(ra) # 80002458 <exit>
80002b78: bf4d j 80002b2a <usertrap+0x42>
} else if((which_dev = devintr()) != 0){
80002b7a: 00000097 auipc ra,0x0
80002b7e: ecc080e7 jalr -308(ra) # 80002a46 <devintr>
80002b82: 892a mv s2,a0
80002b84: c501 beqz a0,80002b8c <usertrap+0xa4>
if(p->killed)
80002b86: 549c lw a5,40(s1)
80002b88: c3a1 beqz a5,80002bc8 <usertrap+0xe0>
80002b8a: a815 j 80002bbe <usertrap+0xd6>
asm volatile("csrr %0, scause" : "=r" (x) );
80002b8c: 142025f3 csrr a1,scause
printf("usertrap(): unexpected scause %p pid=%d\n", r_scause(), p->pid);
80002b90: 5890 lw a2,48(s1)
80002b92: 00005517 auipc a0,0x5
80002b96: 78e50513 addi a0,a0,1934 # 80008320 <states.0+0x78>
80002b9a: ffffe097 auipc ra,0xffffe
80002b9e: 9da080e7 jalr -1574(ra) # 80000574 <printf>
asm volatile("csrr %0, sepc" : "=r" (x) );
80002ba2: 141025f3 csrr a1,sepc
asm volatile("csrr %0, stval" : "=r" (x) );
80002ba6: 14302673 csrr a2,stval
printf(" sepc=%p stval=%p\n", r_sepc(), r_stval());
80002baa: 00005517 auipc a0,0x5
80002bae: 7a650513 addi a0,a0,1958 # 80008350 <states.0+0xa8>
80002bb2: ffffe097 auipc ra,0xffffe
80002bb6: 9c2080e7 jalr -1598(ra) # 80000574 <printf>
p->killed = 1;
80002bba: 4785 li a5,1
80002bbc: d49c sw a5,40(s1)
exit(-1);
80002bbe: 557d li a0,-1
80002bc0: 00000097 auipc ra,0x0
80002bc4: 898080e7 jalr -1896(ra) # 80002458 <exit>
if(which_dev == 2){
80002bc8: 4789 li a5,2
80002bca: f8f910e3 bne s2,a5,80002b4a <usertrap+0x62>
if(inctickcounter() == QUANTUM){
80002bce: 00000097 auipc ra,0x0
80002bd2: c4a080e7 jalr -950(ra) # 80002818 <inctickcounter>
80002bd6: 4795 li a5,5
80002bd8: f6f519e3 bne a0,a5,80002b4a <usertrap+0x62>
yield();
80002bdc: fffff097 auipc ra,0xfffff
80002be0: 4c2080e7 jalr 1218(ra) # 8000209e <yield>
80002be4: b79d j 80002b4a <usertrap+0x62>
int which_dev = 0;
80002be6: 4901 li s2,0
80002be8: bfd9 j 80002bbe <usertrap+0xd6>
0000000080002bea <kerneltrap>:
{
80002bea: 7179 addi sp,sp,-48
80002bec: f406 sd ra,40(sp)
80002bee: f022 sd s0,32(sp)
80002bf0: ec26 sd s1,24(sp)
80002bf2: e84a sd s2,16(sp)
80002bf4: e44e sd s3,8(sp)
80002bf6: 1800 addi s0,sp,48
asm volatile("csrr %0, sepc" : "=r" (x) );
80002bf8: 14102973 csrr s2,sepc
asm volatile("csrr %0, sstatus" : "=r" (x) );
80002bfc: 100024f3 csrr s1,sstatus
asm volatile("csrr %0, scause" : "=r" (x) );
80002c00: 142029f3 csrr s3,scause
if((sstatus & SSTATUS_SPP) == 0)
80002c04: 1004f793 andi a5,s1,256
80002c08: cb85 beqz a5,80002c38 <kerneltrap+0x4e>
asm volatile("csrr %0, sstatus" : "=r" (x) );
80002c0a: 100027f3 csrr a5,sstatus
return (x & SSTATUS_SIE) != 0;
80002c0e: 8b89 andi a5,a5,2
if(intr_get() != 0)
80002c10: ef85 bnez a5,80002c48 <kerneltrap+0x5e>
if((which_dev = devintr()) == 0){
80002c12: 00000097 auipc ra,0x0
80002c16: e34080e7 jalr -460(ra) # 80002a46 <devintr>
80002c1a: cd1d beqz a0,80002c58 <kerneltrap+0x6e>
if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING && inctickcounter() == QUANTUM){
80002c1c: 4789 li a5,2
80002c1e: 06f50a63 beq a0,a5,80002c92 <kerneltrap+0xa8>
asm volatile("csrw sepc, %0" : : "r" (x));
80002c22: 14191073 csrw sepc,s2
asm volatile("csrw sstatus, %0" : : "r" (x));
80002c26: 10049073 csrw sstatus,s1
}
80002c2a: 70a2 ld ra,40(sp)
80002c2c: 7402 ld s0,32(sp)
80002c2e: 64e2 ld s1,24(sp)
80002c30: 6942 ld s2,16(sp)
80002c32: 69a2 ld s3,8(sp)
80002c34: 6145 addi sp,sp,48
80002c36: 8082 ret
panic("kerneltrap: not from supervisor mode");
80002c38: 00005517 auipc a0,0x5
80002c3c: 73850513 addi a0,a0,1848 # 80008370 <states.0+0xc8>
80002c40: ffffe097 auipc ra,0xffffe
80002c44: 8ea080e7 jalr -1814(ra) # 8000052a <panic>
panic("kerneltrap: interrupts enabled");
80002c48: 00005517 auipc a0,0x5
80002c4c: 75050513 addi a0,a0,1872 # 80008398 <states.0+0xf0>
80002c50: ffffe097 auipc ra,0xffffe
80002c54: 8da080e7 jalr -1830(ra) # 8000052a <panic>
printf("scause %p\n", scause);
80002c58: 85ce mv a1,s3
80002c5a: 00005517 auipc a0,0x5
80002c5e: 75e50513 addi a0,a0,1886 # 800083b8 <states.0+0x110>
80002c62: ffffe097 auipc ra,0xffffe
80002c66: 912080e7 jalr -1774(ra) # 80000574 <printf>
asm volatile("csrr %0, sepc" : "=r" (x) );
80002c6a: 141025f3 csrr a1,sepc
asm volatile("csrr %0, stval" : "=r" (x) );
80002c6e: 14302673 csrr a2,stval
printf("sepc=%p stval=%p\n", r_sepc(), r_stval());
80002c72: 00005517 auipc a0,0x5
80002c76: 75650513 addi a0,a0,1878 # 800083c8 <states.0+0x120>
80002c7a: ffffe097 auipc ra,0xffffe
80002c7e: 8fa080e7 jalr -1798(ra) # 80000574 <printf>
panic("kerneltrap");
80002c82: 00005517 auipc a0,0x5
80002c86: 75e50513 addi a0,a0,1886 # 800083e0 <states.0+0x138>
80002c8a: ffffe097 auipc ra,0xffffe
80002c8e: 8a0080e7 jalr -1888(ra) # 8000052a <panic>
if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING && inctickcounter() == QUANTUM){
80002c92: fffff097 auipc ra,0xfffff
80002c96: cec080e7 jalr -788(ra) # 8000197e <myproc>
80002c9a: d541 beqz a0,80002c22 <kerneltrap+0x38>
80002c9c: fffff097 auipc ra,0xfffff
80002ca0: ce2080e7 jalr -798(ra) # 8000197e <myproc>
80002ca4: 4d18 lw a4,24(a0)
80002ca6: 4791 li a5,4
80002ca8: f6f71de3 bne a4,a5,80002c22 <kerneltrap+0x38>
80002cac: 00000097 auipc ra,0x0
80002cb0: b6c080e7 jalr -1172(ra) # 80002818 <inctickcounter>
80002cb4: 4795 li a5,5
80002cb6: f6f516e3 bne a0,a5,80002c22 <kerneltrap+0x38>
yield();
80002cba: fffff097 auipc ra,0xfffff
80002cbe: 3e4080e7 jalr 996(ra) # 8000209e <yield>
80002cc2: b785 j 80002c22 <kerneltrap+0x38>
0000000080002cc4 <argraw>:
return strlen(buf);
}
static uint64
argraw(int n)
{
80002cc4: 1101 addi sp,sp,-32
80002cc6: ec06 sd ra,24(sp)
80002cc8: e822 sd s0,16(sp)
80002cca: e426 sd s1,8(sp)
80002ccc: 1000 addi s0,sp,32
80002cce: 84aa mv s1,a0
struct proc *p = myproc();
80002cd0: fffff097 auipc ra,0xfffff
80002cd4: cae080e7 jalr -850(ra) # 8000197e <myproc>
switch (n) {
80002cd8: 4795 li a5,5
80002cda: 0497e163 bltu a5,s1,80002d1c <argraw+0x58>
80002cde: 048a slli s1,s1,0x2
80002ce0: 00006717 auipc a4,0x6
80002ce4: 85870713 addi a4,a4,-1960 # 80008538 <states.0+0x290>
80002ce8: 94ba add s1,s1,a4
80002cea: 409c lw a5,0(s1)
80002cec: 97ba add a5,a5,a4
80002cee: 8782 jr a5
case 0:
return p->trapframe->a0;
80002cf0: 695c ld a5,144(a0)
80002cf2: 7ba8 ld a0,112(a5)
case 5:
return p->trapframe->a5;
}
panic("argraw");
return -1;
}
80002cf4: 60e2 ld ra,24(sp)
80002cf6: 6442 ld s0,16(sp)
80002cf8: 64a2 ld s1,8(sp)
80002cfa: 6105 addi sp,sp,32
80002cfc: 8082 ret
return p->trapframe->a1;
80002cfe: 695c ld a5,144(a0)
80002d00: 7fa8 ld a0,120(a5)
80002d02: bfcd j 80002cf4 <argraw+0x30>
return p->trapframe->a2;
80002d04: 695c ld a5,144(a0)
80002d06: 63c8 ld a0,128(a5)
80002d08: b7f5 j 80002cf4 <argraw+0x30>
return p->trapframe->a3;
80002d0a: 695c ld a5,144(a0)
80002d0c: 67c8 ld a0,136(a5)
80002d0e: b7dd j 80002cf4 <argraw+0x30>
return p->trapframe->a4;
80002d10: 695c ld a5,144(a0)
80002d12: 6bc8 ld a0,144(a5)
80002d14: b7c5 j 80002cf4 <argraw+0x30>
return p->trapframe->a5;
80002d16: 695c ld a5,144(a0)
80002d18: 6fc8 ld a0,152(a5)
80002d1a: bfe9 j 80002cf4 <argraw+0x30>
panic("argraw");
80002d1c: 00005517 auipc a0,0x5
80002d20: 6d450513 addi a0,a0,1748 # 800083f0 <states.0+0x148>
80002d24: ffffe097 auipc ra,0xffffe
80002d28: 806080e7 jalr -2042(ra) # 8000052a <panic>
0000000080002d2c <fetchaddr>:
{
80002d2c: 1101 addi sp,sp,-32
80002d2e: ec06 sd ra,24(sp)
80002d30: e822 sd s0,16(sp)
80002d32: e426 sd s1,8(sp)
80002d34: e04a sd s2,0(sp)
80002d36: 1000 addi s0,sp,32
80002d38: 84aa mv s1,a0
80002d3a: 892e mv s2,a1
struct proc *p = myproc();
80002d3c: fffff097 auipc ra,0xfffff
80002d40: c42080e7 jalr -958(ra) # 8000197e <myproc>
if(addr >= p->sz || addr+sizeof(uint64) > p->sz)
80002d44: 615c ld a5,128(a0)
80002d46: 02f4f863 bgeu s1,a5,80002d76 <fetchaddr+0x4a>
80002d4a: 00848713 addi a4,s1,8
80002d4e: 02e7e663 bltu a5,a4,80002d7a <fetchaddr+0x4e>
if(copyin(p->pagetable, (char *)ip, addr, sizeof(*ip)) != 0)
80002d52: 46a1 li a3,8
80002d54: 8626 mv a2,s1
80002d56: 85ca mv a1,s2
80002d58: 6548 ld a0,136(a0)
80002d5a: fffff097 auipc ra,0xfffff
80002d5e: 970080e7 jalr -1680(ra) # 800016ca <copyin>
80002d62: 00a03533 snez a0,a0
80002d66: 40a00533 neg a0,a0
}
80002d6a: 60e2 ld ra,24(sp)
80002d6c: 6442 ld s0,16(sp)
80002d6e: 64a2 ld s1,8(sp)
80002d70: 6902 ld s2,0(sp)
80002d72: 6105 addi sp,sp,32
80002d74: 8082 ret
return -1;
80002d76: 557d li a0,-1
80002d78: bfcd j 80002d6a <fetchaddr+0x3e>
80002d7a: 557d li a0,-1
80002d7c: b7fd j 80002d6a <fetchaddr+0x3e>
0000000080002d7e <fetchstr>:
{
80002d7e: 7179 addi sp,sp,-48
80002d80: f406 sd ra,40(sp)
80002d82: f022 sd s0,32(sp)
80002d84: ec26 sd s1,24(sp)
80002d86: e84a sd s2,16(sp)
80002d88: e44e sd s3,8(sp)
80002d8a: 1800 addi s0,sp,48
80002d8c: 892a mv s2,a0
80002d8e: 84ae mv s1,a1
80002d90: 89b2 mv s3,a2
struct proc *p = myproc();
80002d92: fffff097 auipc ra,0xfffff
80002d96: bec080e7 jalr -1044(ra) # 8000197e <myproc>
int err = copyinstr(p->pagetable, buf, addr, max);
80002d9a: 86ce mv a3,s3
80002d9c: 864a mv a2,s2
80002d9e: 85a6 mv a1,s1
80002da0: 6548 ld a0,136(a0)
80002da2: fffff097 auipc ra,0xfffff
80002da6: 9b6080e7 jalr -1610(ra) # 80001758 <copyinstr>
if(err < 0)
80002daa: 00054763 bltz a0,80002db8 <fetchstr+0x3a>
return strlen(buf);
80002dae: 8526 mv a0,s1
80002db0: ffffe097 auipc ra,0xffffe
80002db4: 092080e7 jalr 146(ra) # 80000e42 <strlen>
}
80002db8: 70a2 ld ra,40(sp)
80002dba: 7402 ld s0,32(sp)
80002dbc: 64e2 ld s1,24(sp)
80002dbe: 6942 ld s2,16(sp)
80002dc0: 69a2 ld s3,8(sp)
80002dc2: 6145 addi sp,sp,48
80002dc4: 8082 ret
0000000080002dc6 <argint>:
// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
80002dc6: 1101 addi sp,sp,-32
80002dc8: ec06 sd ra,24(sp)
80002dca: e822 sd s0,16(sp)
80002dcc: e426 sd s1,8(sp)
80002dce: 1000 addi s0,sp,32
80002dd0: 84ae mv s1,a1
*ip = argraw(n);
80002dd2: 00000097 auipc ra,0x0
80002dd6: ef2080e7 jalr -270(ra) # 80002cc4 <argraw>
80002dda: c088 sw a0,0(s1)
return 0;
}
80002ddc: 4501 li a0,0
80002dde: 60e2 ld ra,24(sp)
80002de0: 6442 ld s0,16(sp)
80002de2: 64a2 ld s1,8(sp)
80002de4: 6105 addi sp,sp,32
80002de6: 8082 ret
0000000080002de8 <argaddr>:
// Retrieve an argument as a pointer.
// Doesn't check for legality, since
// copyin/copyout will do that.
int
argaddr(int n, uint64 *ip)
{
80002de8: 1101 addi sp,sp,-32
80002dea: ec06 sd ra,24(sp)
80002dec: e822 sd s0,16(sp)
80002dee: e426 sd s1,8(sp)
80002df0: 1000 addi s0,sp,32
80002df2: 84ae mv s1,a1
*ip = argraw(n);
80002df4: 00000097 auipc ra,0x0
80002df8: ed0080e7 jalr -304(ra) # 80002cc4 <argraw>
80002dfc: e088 sd a0,0(s1)
return 0;
}
80002dfe: 4501 li a0,0
80002e00: 60e2 ld ra,24(sp)
80002e02: 6442 ld s0,16(sp)
80002e04: 64a2 ld s1,8(sp)
80002e06: 6105 addi sp,sp,32
80002e08: 8082 ret
0000000080002e0a <argstr>:
// Fetch the nth word-sized system call argument as a null-terminated string.
// Copies into buf, at most max.
// Returns string length if OK (including nul), -1 if error.
int
argstr(int n, char *buf, int max)
{
80002e0a: 1101 addi sp,sp,-32
80002e0c: ec06 sd ra,24(sp)
80002e0e: e822 sd s0,16(sp)
80002e10: e426 sd s1,8(sp)
80002e12: e04a sd s2,0(sp)
80002e14: 1000 addi s0,sp,32
80002e16: 84ae mv s1,a1
80002e18: 8932 mv s2,a2
*ip = argraw(n);
80002e1a: 00000097 auipc ra,0x0
80002e1e: eaa080e7 jalr -342(ra) # 80002cc4 <argraw>
uint64 addr;
if(argaddr(n, &addr) < 0)
return -1;
return fetchstr(addr, buf, max);
80002e22: 864a mv a2,s2
80002e24: 85a6 mv a1,s1
80002e26: 00000097 auipc ra,0x0
80002e2a: f58080e7 jalr -168(ra) # 80002d7e <fetchstr>
}
80002e2e: 60e2 ld ra,24(sp)
80002e30: 6442 ld s0,16(sp)
80002e32: 64a2 ld s1,8(sp)
80002e34: 6902 ld s2,0(sp)
80002e36: 6105 addi sp,sp,32
80002e38: 8082 ret
0000000080002e3a <syscall>:
"unlink", "link", "mkdir", "close", "trace" ,"wait_stat", "set_priority"};
void
syscall(void)
{
80002e3a: 7139 addi sp,sp,-64
80002e3c: fc06 sd ra,56(sp)
80002e3e: f822 sd s0,48(sp)
80002e40: f426 sd s1,40(sp)
80002e42: f04a sd s2,32(sp)
80002e44: ec4e sd s3,24(sp)
80002e46: 0080 addi s0,sp,64
int num;
struct proc *p = myproc();
80002e48: fffff097 auipc ra,0xfffff
80002e4c: b36080e7 jalr -1226(ra) # 8000197e <myproc>
80002e50: 892a mv s2,a0
num = p->trapframe->a7;
80002e52: 695c ld a5,144(a0)
80002e54: 0a87a483 lw s1,168(a5)
int argument = 0;
80002e58: fc042623 sw zero,-52(s0)
if(num == SYS_fork || num == SYS_kill || num == SYS_sbrk)
80002e5c: 47b1 li a5,12
80002e5e: 0297e063 bltu a5,s1,80002e7e <syscall+0x44>
80002e62: 6785 lui a5,0x1
80002e64: 04278793 addi a5,a5,66 # 1042 <_entry-0x7fffefbe>
80002e68: 0097d7b3 srl a5,a5,s1
80002e6c: 8b85 andi a5,a5,1
80002e6e: cb81 beqz a5,80002e7e <syscall+0x44>
argint(0, &argument);
80002e70: fcc40593 addi a1,s0,-52
80002e74: 4501 li a0,0
80002e76: 00000097 auipc ra,0x0
80002e7a: f50080e7 jalr -176(ra) # 80002dc6 <argint>
if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
80002e7e: fff4879b addiw a5,s1,-1
80002e82: 475d li a4,23
80002e84: 02f76163 bltu a4,a5,80002ea6 <syscall+0x6c>
80002e88: 00349713 slli a4,s1,0x3
80002e8c: 00005797 auipc a5,0x5
80002e90: 6c478793 addi a5,a5,1732 # 80008550 <syscalls>
80002e94: 97ba add a5,a5,a4
80002e96: 639c ld a5,0(a5)
80002e98: c799 beqz a5,80002ea6 <syscall+0x6c>
p->trapframe->a0 = syscalls[num]();
80002e9a: 09093983 ld s3,144(s2)
80002e9e: 9782 jalr a5
80002ea0: 06a9b823 sd a0,112(s3)
80002ea4: a015 j 80002ec8 <syscall+0x8e>
} else {
printf("%d %s: unknown sys call %d\n",
80002ea6: 86a6 mv a3,s1
80002ea8: 19090613 addi a2,s2,400
80002eac: 03092583 lw a1,48(s2)
80002eb0: 00005517 auipc a0,0x5
80002eb4: 54850513 addi a0,a0,1352 # 800083f8 <states.0+0x150>
80002eb8: ffffd097 auipc ra,0xffffd
80002ebc: 6bc080e7 jalr 1724(ra) # 80000574 <printf>
p->pid, p->name, num);
p->trapframe->a0 = -1;
80002ec0: 09093783 ld a5,144(s2)
80002ec4: 577d li a4,-1
80002ec6: fbb8 sd a4,112(a5)
int ret = p->trapframe->a0;
/* If the system calls bit is on in the mask of the process,
then print the trace of the system call. */
if(p->mask & (1 << num)){
80002ec8: 03492783 lw a5,52(s2)
80002ecc: 4097d7bb sraw a5,a5,s1
80002ed0: 8b85 andi a5,a5,1
80002ed2: c3a9 beqz a5,80002f14 <syscall+0xda>
int ret = p->trapframe->a0;
80002ed4: 09093783 ld a5,144(s2)
80002ed8: 5bb4 lw a3,112(a5)
if(num == SYS_fork)
80002eda: 4785 li a5,1
80002edc: 04f48363 beq s1,a5,80002f22 <syscall+0xe8>
printf("%d: syscall %s NULL -> %d\n", p->pid, sys_calls_names[num], ret);
else if(num == SYS_kill || num == SYS_sbrk)
80002ee0: 4799 li a5,6
80002ee2: 00f48563 beq s1,a5,80002eec <syscall+0xb2>
80002ee6: 47b1 li a5,12
80002ee8: 04f49c63 bne s1,a5,80002f40 <syscall+0x106>
printf("%d: syscall %s %d -> %d\n", p->pid, sys_calls_names[num], argument, ret);
80002eec: 048e slli s1,s1,0x3
80002eee: 00006797 auipc a5,0x6
80002ef2: a8a78793 addi a5,a5,-1398 # 80008978 <sys_calls_names>
80002ef6: 94be add s1,s1,a5
80002ef8: 8736 mv a4,a3
80002efa: fcc42683 lw a3,-52(s0)
80002efe: 6090 ld a2,0(s1)
80002f00: 03092583 lw a1,48(s2)
80002f04: 00005517 auipc a0,0x5
80002f08: 53450513 addi a0,a0,1332 # 80008438 <states.0+0x190>
80002f0c: ffffd097 auipc ra,0xffffd
80002f10: 668080e7 jalr 1640(ra) # 80000574 <printf>
else
printf("%d: syscall %s -> %d\n", p->pid, sys_calls_names[num], ret);
}
}
80002f14: 70e2 ld ra,56(sp)
80002f16: 7442 ld s0,48(sp)
80002f18: 74a2 ld s1,40(sp)
80002f1a: 7902 ld s2,32(sp)
80002f1c: 69e2 ld s3,24(sp)
80002f1e: 6121 addi sp,sp,64
80002f20: 8082 ret
printf("%d: syscall %s NULL -> %d\n", p->pid, sys_calls_names[num], ret);
80002f22: 00006617 auipc a2,0x6
80002f26: a5e63603 ld a2,-1442(a2) # 80008980 <sys_calls_names+0x8>
80002f2a: 03092583 lw a1,48(s2)
80002f2e: 00005517 auipc a0,0x5
80002f32: 4ea50513 addi a0,a0,1258 # 80008418 <states.0+0x170>
80002f36: ffffd097 auipc ra,0xffffd
80002f3a: 63e080e7 jalr 1598(ra) # 80000574 <printf>
80002f3e: bfd9 j 80002f14 <syscall+0xda>
printf("%d: syscall %s -> %d\n", p->pid, sys_calls_names[num], ret);
80002f40: 048e slli s1,s1,0x3
80002f42: 00006797 auipc a5,0x6
80002f46: a3678793 addi a5,a5,-1482 # 80008978 <sys_calls_names>
80002f4a: 94be add s1,s1,a5
80002f4c: 6090 ld a2,0(s1)
80002f4e: 03092583 lw a1,48(s2)
80002f52: 00005517 auipc a0,0x5
80002f56: 50650513 addi a0,a0,1286 # 80008458 <states.0+0x1b0>
80002f5a: ffffd097 auipc ra,0xffffd
80002f5e: 61a080e7 jalr 1562(ra) # 80000574 <printf>
}
80002f62: bf4d j 80002f14 <syscall+0xda>
0000000080002f64 <sys_exit>:
#include "perf.h"
uint64
sys_exit(void)
{
80002f64: 1101 addi sp,sp,-32
80002f66: ec06 sd ra,24(sp)
80002f68: e822 sd s0,16(sp)
80002f6a: 1000 addi s0,sp,32
int n;
if(argint(0, &n) < 0)
80002f6c: fec40593 addi a1,s0,-20
80002f70: 4501 li a0,0
80002f72: 00000097 auipc ra,0x0
80002f76: e54080e7 jalr -428(ra) # 80002dc6 <argint>
return -1;
80002f7a: 57fd li a5,-1
if(argint(0, &n) < 0)
80002f7c: 00054963 bltz a0,80002f8e <sys_exit+0x2a>
exit(n);
80002f80: fec42503 lw a0,-20(s0)
80002f84: fffff097 auipc ra,0xfffff
80002f88: 4d4080e7 jalr 1236(ra) # 80002458 <exit>
return 0; // not reached
80002f8c: 4781 li a5,0
}
80002f8e: 853e mv a0,a5
80002f90: 60e2 ld ra,24(sp)
80002f92: 6442 ld s0,16(sp)
80002f94: 6105 addi sp,sp,32
80002f96: 8082 ret
0000000080002f98 <sys_getpid>:
uint64
sys_getpid(void)
{
80002f98: 1141 addi sp,sp,-16
80002f9a: e406 sd ra,8(sp)
80002f9c: e022 sd s0,0(sp)
80002f9e: 0800 addi s0,sp,16
return myproc()->pid;
80002fa0: fffff097 auipc ra,0xfffff
80002fa4: 9de080e7 jalr -1570(ra) # 8000197e <myproc>
}
80002fa8: 5908 lw a0,48(a0)
80002faa: 60a2 ld ra,8(sp)
80002fac: 6402 ld s0,0(sp)
80002fae: 0141 addi sp,sp,16
80002fb0: 8082 ret
0000000080002fb2 <sys_fork>:
uint64
sys_fork(void)
{
80002fb2: 1141 addi sp,sp,-16
80002fb4: e406 sd ra,8(sp)
80002fb6: e022 sd s0,0(sp)
80002fb8: 0800 addi s0,sp,16
return fork();
80002fba: fffff097 auipc ra,0xfffff
80002fbe: ddc080e7 jalr -548(ra) # 80001d96 <fork>
}
80002fc2: 60a2 ld ra,8(sp)
80002fc4: 6402 ld s0,0(sp)
80002fc6: 0141 addi sp,sp,16
80002fc8: 8082 ret
0000000080002fca <sys_wait>:
uint64
sys_wait(void)
{
80002fca: 1101 addi sp,sp,-32
80002fcc: ec06 sd ra,24(sp)
80002fce: e822 sd s0,16(sp)
80002fd0: 1000 addi s0,sp,32
uint64 p;
if(argaddr(0, &p) < 0)
80002fd2: fe840593 addi a1,s0,-24
80002fd6: 4501 li a0,0
80002fd8: 00000097 auipc ra,0x0
80002fdc: e10080e7 jalr -496(ra) # 80002de8 <argaddr>
80002fe0: 87aa mv a5,a0
return -1;
80002fe2: 557d li a0,-1
if(argaddr(0, &p) < 0)
80002fe4: 0007c863 bltz a5,80002ff4 <sys_wait+0x2a>
return wait(p);
80002fe8: fe843503 ld a0,-24(s0)
80002fec: fffff097 auipc ra,0xfffff
80002ff0: 362080e7 jalr 866(ra) # 8000234e <wait>
}
80002ff4: 60e2 ld ra,24(sp)
80002ff6: 6442 ld s0,16(sp)
80002ff8: 6105 addi sp,sp,32
80002ffa: 8082 ret
0000000080002ffc <sys_sbrk>:
uint64
sys_sbrk(void)
{
80002ffc: 7179 addi sp,sp,-48
80002ffe: f406 sd ra,40(sp)
80003000: f022 sd s0,32(sp)
80003002: ec26 sd s1,24(sp)
80003004: 1800 addi s0,sp,48
int addr;
int n;
if(argint(0, &n) < 0)
80003006: fdc40593 addi a1,s0,-36
8000300a: 4501 li a0,0
8000300c: 00000097 auipc ra,0x0
80003010: dba080e7 jalr -582(ra) # 80002dc6 <argint>
return -1;
80003014: 54fd li s1,-1
if(argint(0, &n) < 0)
80003016: 02054063 bltz a0,80003036 <sys_sbrk+0x3a>
addr = myproc()->sz;
8000301a: fffff097 auipc ra,0xfffff
8000301e: 964080e7 jalr -1692(ra) # 8000197e <myproc>
80003022: 08052483 lw s1,128(a0)
if(growproc(n) < 0)
80003026: fdc42503 lw a0,-36(s0)
8000302a: fffff097 auipc ra,0xfffff
8000302e: cf8080e7 jalr -776(ra) # 80001d22 <growproc>
80003032: 00054863 bltz a0,80003042 <sys_sbrk+0x46>
return -1;
return addr;
}
80003036: 8526 mv a0,s1
80003038: 70a2 ld ra,40(sp)
8000303a: 7402 ld s0,32(sp)
8000303c: 64e2 ld s1,24(sp)
8000303e: 6145 addi sp,sp,48
80003040: 8082 ret
return -1;
80003042: 54fd li s1,-1
80003044: bfcd j 80003036 <sys_sbrk+0x3a>
0000000080003046 <sys_sleep>:
uint64
sys_sleep(void)
{
80003046: 7139 addi sp,sp,-64
80003048: fc06 sd ra,56(sp)
8000304a: f822 sd s0,48(sp)
8000304c: f426 sd s1,40(sp)
8000304e: f04a sd s2,32(sp)
80003050: ec4e sd s3,24(sp)
80003052: 0080 addi s0,sp,64
int n;
uint ticks0;
if(argint(0, &n) < 0)
80003054: fcc40593 addi a1,s0,-52
80003058: 4501 li a0,0
8000305a: 00000097 auipc ra,0x0
8000305e: d6c080e7 jalr -660(ra) # 80002dc6 <argint>
return -1;
80003062: 57fd li a5,-1
if(argint(0, &n) < 0)
80003064: 06054563 bltz a0,800030ce <sys_sleep+0x88>
acquire(&tickslock);
80003068: 00015517 auipc a0,0x15
8000306c: e6850513 addi a0,a0,-408 # 80017ed0 <tickslock>
80003070: ffffe097 auipc ra,0xffffe
80003074: b52080e7 jalr -1198(ra) # 80000bc2 <acquire>
ticks0 = ticks;
80003078: 00006917 auipc s2,0x6
8000307c: fb892903 lw s2,-72(s2) # 80009030 <ticks>
while(ticks - ticks0 < n){
80003080: fcc42783 lw a5,-52(s0)
80003084: cf85 beqz a5,800030bc <sys_sleep+0x76>
if(myproc()->killed){
release(&tickslock);
return -1;
}
sleep(&ticks, &tickslock);
80003086: 00015997 auipc s3,0x15
8000308a: e4a98993 addi s3,s3,-438 # 80017ed0 <tickslock>
8000308e: 00006497 auipc s1,0x6
80003092: fa248493 addi s1,s1,-94 # 80009030 <ticks>
if(myproc()->killed){
80003096: fffff097 auipc ra,0xfffff
8000309a: 8e8080e7 jalr -1816(ra) # 8000197e <myproc>
8000309e: 551c lw a5,40(a0)
800030a0: ef9d bnez a5,800030de <sys_sleep+0x98>
sleep(&ticks, &tickslock);
800030a2: 85ce mv a1,s3
800030a4: 8526 mv a0,s1
800030a6: fffff097 auipc ra,0xfffff
800030aa: 04e080e7 jalr 78(ra) # 800020f4 <sleep>
while(ticks - ticks0 < n){
800030ae: 409c lw a5,0(s1)
800030b0: 412787bb subw a5,a5,s2
800030b4: fcc42703 lw a4,-52(s0)
800030b8: fce7efe3 bltu a5,a4,80003096 <sys_sleep+0x50>
}
release(&tickslock);
800030bc: 00015517 auipc a0,0x15
800030c0: e1450513 addi a0,a0,-492 # 80017ed0 <tickslock>
800030c4: ffffe097 auipc ra,0xffffe
800030c8: bb2080e7 jalr -1102(ra) # 80000c76 <release>
return 0;
800030cc: 4781 li a5,0
}
800030ce: 853e mv a0,a5
800030d0: 70e2 ld ra,56(sp)
800030d2: 7442 ld s0,48(sp)
800030d4: 74a2 ld s1,40(sp)
800030d6: 7902 ld s2,32(sp)
800030d8: 69e2 ld s3,24(sp)
800030da: 6121 addi sp,sp,64
800030dc: 8082 ret
release(&tickslock);
800030de: 00015517 auipc a0,0x15
800030e2: df250513 addi a0,a0,-526 # 80017ed0 <tickslock>
800030e6: ffffe097 auipc ra,0xffffe
800030ea: b90080e7 jalr -1136(ra) # 80000c76 <release>
return -1;
800030ee: 57fd li a5,-1
800030f0: bff9 j 800030ce <sys_sleep+0x88>
00000000800030f2 <sys_set_priority>:
uint64
sys_set_priority(void)
{
800030f2: 1101 addi sp,sp,-32
800030f4: ec06 sd ra,24(sp)
800030f6: e822 sd s0,16(sp)
800030f8: 1000 addi s0,sp,32
int prio;
if(argint(0, &prio) < 0)
800030fa: fec40593 addi a1,s0,-20
800030fe: 4501 li a0,0
80003100: 00000097 auipc ra,0x0
80003104: cc6080e7 jalr -826(ra) # 80002dc6 <argint>
80003108: 87aa mv a5,a0
return -1;
8000310a: 557d li a0,-1
if(argint(0, &prio) < 0)
8000310c: 0007c863 bltz a5,8000311c <sys_set_priority+0x2a>
return set_priority(prio);
80003110: fec42503 lw a0,-20(s0)
80003114: fffff097 auipc ra,0xfffff
80003118: 44c080e7 jalr 1100(ra) # 80002560 <set_priority>
}
8000311c: 60e2 ld ra,24(sp)
8000311e: 6442 ld s0,16(sp)
80003120: 6105 addi sp,sp,32
80003122: 8082 ret
0000000080003124 <sys_trace>:
uint64
sys_trace(void)
{
80003124: 1101 addi sp,sp,-32
80003126: ec06 sd ra,24(sp)
80003128: e822 sd s0,16(sp)
8000312a: 1000 addi s0,sp,32
int mask;
int pid;
if(argint(0, &mask) < 0 || argint(1, &pid) < 0)
8000312c: fec40593 addi a1,s0,-20
80003130: 4501 li a0,0
80003132: 00000097 auipc ra,0x0
80003136: c94080e7 jalr -876(ra) # 80002dc6 <argint>
return -1;
8000313a: 57fd li a5,-1
if(argint(0, &mask) < 0 || argint(1, &pid) < 0)
8000313c: 02054563 bltz a0,80003166 <sys_trace+0x42>
80003140: fe840593 addi a1,s0,-24
80003144: 4505 li a0,1
80003146: 00000097 auipc ra,0x0
8000314a: c80080e7 jalr -896(ra) # 80002dc6 <argint>
return -1;
8000314e: 57fd li a5,-1
if(argint(0, &mask) < 0 || argint(1, &pid) < 0)
80003150: 00054b63 bltz a0,80003166 <sys_trace+0x42>
return trace(mask, pid);
80003154: fe842583 lw a1,-24(s0)
80003158: fec42503 lw a0,-20(s0)
8000315c: fffff097 auipc ra,0xfffff
80003160: 45c080e7 jalr 1116(ra) # 800025b8 <trace>
80003164: 87aa mv a5,a0
}
80003166: 853e mv a0,a5
80003168: 60e2 ld ra,24(sp)
8000316a: 6442 ld s0,16(sp)
8000316c: 6105 addi sp,sp,32
8000316e: 8082 ret
0000000080003170 <sys_kill>:
uint64
sys_kill(void)
{
80003170: 1101 addi sp,sp,-32
80003172: ec06 sd ra,24(sp)
80003174: e822 sd s0,16(sp)
80003176: 1000 addi s0,sp,32
int pid;
if(argint(0, &pid) < 0)
80003178: fec40593 addi a1,s0,-20
8000317c: 4501 li a0,0
8000317e: 00000097 auipc ra,0x0
80003182: c48080e7 jalr -952(ra) # 80002dc6 <argint>
80003186: 87aa mv a5,a0
return -1;
80003188: 557d li a0,-1
if(argint(0, &pid) < 0)
8000318a: 0007c863 bltz a5,8000319a <sys_kill+0x2a>
return kill(pid);
8000318e: fec42503 lw a0,-20(s0)
80003192: fffff097 auipc ra,0xfffff
80003196: 486080e7 jalr 1158(ra) # 80002618 <kill>
}
8000319a: 60e2 ld ra,24(sp)
8000319c: 6442 ld s0,16(sp)
8000319e: 6105 addi sp,sp,32
800031a0: 8082 ret
00000000800031a2 <sys_uptime>:
// return how many clock tick interrupts have occurred
// since start.
uint64
sys_uptime(void)
{
800031a2: 1101 addi sp,sp,-32
800031a4: ec06 sd ra,24(sp)
800031a6: e822 sd s0,16(sp)
800031a8: e426 sd s1,8(sp)
800031aa: 1000 addi s0,sp,32
uint xticks;
acquire(&tickslock);
800031ac: 00015517 auipc a0,0x15
800031b0: d2450513 addi a0,a0,-732 # 80017ed0 <tickslock>
800031b4: ffffe097 auipc ra,0xffffe
800031b8: a0e080e7 jalr -1522(ra) # 80000bc2 <acquire>
xticks = ticks;
800031bc: 00006497 auipc s1,0x6
800031c0: e744a483 lw s1,-396(s1) # 80009030 <ticks>
release(&tickslock);
800031c4: 00015517 auipc a0,0x15
800031c8: d0c50513 addi a0,a0,-756 # 80017ed0 <tickslock>
800031cc: ffffe097 auipc ra,0xffffe
800031d0: aaa080e7 jalr -1366(ra) # 80000c76 <release>
return xticks;
}
800031d4: 02049513 slli a0,s1,0x20
800031d8: 9101 srli a0,a0,0x20
800031da: 60e2 ld ra,24(sp)
800031dc: 6442 ld s0,16(sp)
800031de: 64a2 ld s1,8(sp)
800031e0: 6105 addi sp,sp,32
800031e2: 8082 ret
00000000800031e4 <sys_wait_stat>:
uint64
sys_wait_stat(void)
{
800031e4: 7179 addi sp,sp,-48
800031e6: f406 sd ra,40(sp)
800031e8: f022 sd s0,32(sp)
800031ea: ec26 sd s1,24(sp)
800031ec: 1800 addi s0,sp,48
int status;
struct perf* tmp = (struct perf*) myproc()->trapframe->a1;
800031ee: ffffe097 auipc ra,0xffffe
800031f2: 790080e7 jalr 1936(ra) # 8000197e <myproc>
800031f6: 695c ld a5,144(a0)
800031f8: 7fa4 ld s1,120(a5)
if(argint(0, &status) < 0)
800031fa: fdc40593 addi a1,s0,-36
800031fe: 4501 li a0,0
80003200: 00000097 auipc ra,0x0
80003204: bc6080e7 jalr -1082(ra) # 80002dc6 <argint>
80003208: 87aa mv a5,a0
return -1;
8000320a: 557d li a0,-1
if(argint(0, &status) < 0)
8000320c: 0007c963 bltz a5,8000321e <sys_wait_stat+0x3a>
int x = wait_stat(&status, tmp);
80003210: 85a6 mv a1,s1
80003212: fdc40513 addi a0,s0,-36
80003216: fffff097 auipc ra,0xfffff
8000321a: 5e8080e7 jalr 1512(ra) # 800027fe <wait_stat>
return x;
}
8000321e: 70a2 ld ra,40(sp)
80003220: 7402 ld s0,32(sp)
80003222: 64e2 ld s1,24(sp)
80003224: 6145 addi sp,sp,48
80003226: 8082 ret
0000000080003228 <binit>:
struct buf head;
} bcache;
void
binit(void)
{
80003228: 7179 addi sp,sp,-48
8000322a: f406 sd ra,40(sp)
8000322c: f022 sd s0,32(sp)
8000322e: ec26 sd s1,24(sp)
80003230: e84a sd s2,16(sp)
80003232: e44e sd s3,8(sp)
80003234: e052 sd s4,0(sp)
80003236: 1800 addi s0,sp,48
struct buf *b;
initlock(&bcache.lock, "bcache");
80003238: 00005597 auipc a1,0x5
8000323c: 3e058593 addi a1,a1,992 # 80008618 <syscalls+0xc8>
80003240: 00015517 auipc a0,0x15
80003244: ca850513 addi a0,a0,-856 # 80017ee8 <bcache>
80003248: ffffe097 auipc ra,0xffffe
8000324c: 8ea080e7 jalr -1814(ra) # 80000b32 <initlock>
// Create linked list of buffers
bcache.head.prev = &bcache.head;
80003250: 0001d797 auipc a5,0x1d
80003254: c9878793 addi a5,a5,-872 # 8001fee8 <bcache+0x8000>
80003258: 0001d717 auipc a4,0x1d
8000325c: ef870713 addi a4,a4,-264 # 80020150 <bcache+0x8268>
80003260: 2ae7b823 sd a4,688(a5)
bcache.head.next = &bcache.head;
80003264: 2ae7bc23 sd a4,696(a5)
for(b = bcache.buf; b < bcache.buf+NBUF; b++){
80003268: 00015497 auipc s1,0x15
8000326c: c9848493 addi s1,s1,-872 # 80017f00 <bcache+0x18>
b->next = bcache.head.next;
80003270: 893e mv s2,a5
b->prev = &bcache.head;
80003272: 89ba mv s3,a4
initsleeplock(&b->lock, "buffer");
80003274: 00005a17 auipc s4,0x5
80003278: 3aca0a13 addi s4,s4,940 # 80008620 <syscalls+0xd0>
b->next = bcache.head.next;
8000327c: 2b893783 ld a5,696(s2)
80003280: e8bc sd a5,80(s1)
b->prev = &bcache.head;
80003282: 0534b423 sd s3,72(s1)
initsleeplock(&b->lock, "buffer");
80003286: 85d2 mv a1,s4
80003288: 01048513 addi a0,s1,16
8000328c: 00001097 auipc ra,0x1
80003290: 4c2080e7 jalr 1218(ra) # 8000474e <initsleeplock>
bcache.head.next->prev = b;
80003294: 2b893783 ld a5,696(s2)
80003298: e7a4 sd s1,72(a5)
bcache.head.next = b;
8000329a: 2a993c23 sd s1,696(s2)
for(b = bcache.buf; b < bcache.buf+NBUF; b++){
8000329e: 45848493 addi s1,s1,1112
800032a2: fd349de3 bne s1,s3,8000327c <binit+0x54>
}
}
800032a6: 70a2 ld ra,40(sp)
800032a8: 7402 ld s0,32(sp)
800032aa: 64e2 ld s1,24(sp)
800032ac: 6942 ld s2,16(sp)
800032ae: 69a2 ld s3,8(sp)
800032b0: 6a02 ld s4,0(sp)
800032b2: 6145 addi sp,sp,48
800032b4: 8082 ret
00000000800032b6 <bread>:
}
// Return a locked buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
800032b6: 7179 addi sp,sp,-48
800032b8: f406 sd ra,40(sp)
800032ba: f022 sd s0,32(sp)
800032bc: ec26 sd s1,24(sp)
800032be: e84a sd s2,16(sp)
800032c0: e44e sd s3,8(sp)
800032c2: 1800 addi s0,sp,48
800032c4: 892a mv s2,a0
800032c6: 89ae mv s3,a1
acquire(&bcache.lock);
800032c8: 00015517 auipc a0,0x15
800032cc: c2050513 addi a0,a0,-992 # 80017ee8 <bcache>
800032d0: ffffe097 auipc ra,0xffffe
800032d4: 8f2080e7 jalr -1806(ra) # 80000bc2 <acquire>
for(b = bcache.head.next; b != &bcache.head; b = b->next){
800032d8: 0001d497 auipc s1,0x1d
800032dc: ec84b483 ld s1,-312(s1) # 800201a0 <bcache+0x82b8>
800032e0: 0001d797 auipc a5,0x1d
800032e4: e7078793 addi a5,a5,-400 # 80020150 <bcache+0x8268>
800032e8: 02f48f63 beq s1,a5,80003326 <bread+0x70>
800032ec: 873e mv a4,a5
800032ee: a021 j 800032f6 <bread+0x40>
800032f0: 68a4 ld s1,80(s1)
800032f2: 02e48a63 beq s1,a4,80003326 <bread+0x70>
if(b->dev == dev && b->blockno == blockno){
800032f6: 449c lw a5,8(s1)
800032f8: ff279ce3 bne a5,s2,800032f0 <bread+0x3a>
800032fc: 44dc lw a5,12(s1)
800032fe: ff3799e3 bne a5,s3,800032f0 <bread+0x3a>
b->refcnt++;
80003302: 40bc lw a5,64(s1)
80003304: 2785 addiw a5,a5,1
80003306: c0bc sw a5,64(s1)
release(&bcache.lock);
80003308: 00015517 auipc a0,0x15
8000330c: be050513 addi a0,a0,-1056 # 80017ee8 <bcache>
80003310: ffffe097 auipc ra,0xffffe
80003314: 966080e7 jalr -1690(ra) # 80000c76 <release>
acquiresleep(&b->lock);
80003318: 01048513 addi a0,s1,16
8000331c: 00001097 auipc ra,0x1
80003320: 46c080e7 jalr 1132(ra) # 80004788 <acquiresleep>
return b;
80003324: a8b9 j 80003382 <bread+0xcc>
for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
80003326: 0001d497 auipc s1,0x1d
8000332a: e724b483 ld s1,-398(s1) # 80020198 <bcache+0x82b0>
8000332e: 0001d797 auipc a5,0x1d
80003332: e2278793 addi a5,a5,-478 # 80020150 <bcache+0x8268>
80003336: 00f48863 beq s1,a5,80003346 <bread+0x90>
8000333a: 873e mv a4,a5
if(b->refcnt == 0) {
8000333c: 40bc lw a5,64(s1)
8000333e: cf81 beqz a5,80003356 <bread+0xa0>
for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
80003340: 64a4 ld s1,72(s1)
80003342: fee49de3 bne s1,a4,8000333c <bread+0x86>
panic("bget: no buffers");
80003346: 00005517 auipc a0,0x5
8000334a: 2e250513 addi a0,a0,738 # 80008628 <syscalls+0xd8>
8000334e: ffffd097 auipc ra,0xffffd
80003352: 1dc080e7 jalr 476(ra) # 8000052a <panic>
b->dev = dev;
80003356: 0124a423 sw s2,8(s1)
b->blockno = blockno;
8000335a: 0134a623 sw s3,12(s1)
b->valid = 0;
8000335e: 0004a023 sw zero,0(s1)
b->refcnt = 1;
80003362: 4785 li a5,1
80003364: c0bc sw a5,64(s1)
release(&bcache.lock);
80003366: 00015517 auipc a0,0x15
8000336a: b8250513 addi a0,a0,-1150 # 80017ee8 <bcache>
8000336e: ffffe097 auipc ra,0xffffe
80003372: 908080e7 jalr -1784(ra) # 80000c76 <release>
acquiresleep(&b->lock);
80003376: 01048513 addi a0,s1,16
8000337a: 00001097 auipc ra,0x1
8000337e: 40e080e7 jalr 1038(ra) # 80004788 <acquiresleep>
struct buf *b;
b = bget(dev, blockno);
if(!b->valid) {
80003382: 409c lw a5,0(s1)
80003384: cb89 beqz a5,80003396 <bread+0xe0>
virtio_disk_rw(b, 0);
b->valid = 1;
}
return b;
}
80003386: 8526 mv a0,s1
80003388: 70a2 ld ra,40(sp)
8000338a: 7402 ld s0,32(sp)
8000338c: 64e2 ld s1,24(sp)
8000338e: 6942 ld s2,16(sp)
80003390: 69a2 ld s3,8(sp)
80003392: 6145 addi sp,sp,48
80003394: 8082 ret
virtio_disk_rw(b, 0);
80003396: 4581 li a1,0
80003398: 8526 mv a0,s1
8000339a: 00003097 auipc ra,0x3
8000339e: f2c080e7 jalr -212(ra) # 800062c6 <virtio_disk_rw>
b->valid = 1;
800033a2: 4785 li a5,1
800033a4: c09c sw a5,0(s1)
return b;
800033a6: b7c5 j 80003386 <bread+0xd0>
00000000800033a8 <bwrite>:
// Write b's contents to disk. Must be locked.
void
bwrite(struct buf *b)
{
800033a8: 1101 addi sp,sp,-32
800033aa: ec06 sd ra,24(sp)
800033ac: e822 sd s0,16(sp)
800033ae: e426 sd s1,8(sp)
800033b0: 1000 addi s0,sp,32
800033b2: 84aa mv s1,a0
if(!holdingsleep(&b->lock))
800033b4: 0541 addi a0,a0,16
800033b6: 00001097 auipc ra,0x1
800033ba: 46c080e7 jalr 1132(ra) # 80004822 <holdingsleep>
800033be: cd01 beqz a0,800033d6 <bwrite+0x2e>
panic("bwrite");
virtio_disk_rw(b, 1);
800033c0: 4585 li a1,1
800033c2: 8526 mv a0,s1
800033c4: 00003097 auipc ra,0x3
800033c8: f02080e7 jalr -254(ra) # 800062c6 <virtio_disk_rw>
}
800033cc: 60e2 ld ra,24(sp)
800033ce: 6442 ld s0,16(sp)
800033d0: 64a2 ld s1,8(sp)
800033d2: 6105 addi sp,sp,32
800033d4: 8082 ret
panic("bwrite");
800033d6: 00005517 auipc a0,0x5
800033da: 26a50513 addi a0,a0,618 # 80008640 <syscalls+0xf0>
800033de: ffffd097 auipc ra,0xffffd
800033e2: 14c080e7 jalr 332(ra) # 8000052a <panic>
00000000800033e6 <brelse>:
// Release a locked buffer.
// Move to the head of the most-recently-used list.
void
brelse(struct buf *b)
{
800033e6: 1101 addi sp,sp,-32
800033e8: ec06 sd ra,24(sp)
800033ea: e822 sd s0,16(sp)
800033ec: e426 sd s1,8(sp)
800033ee: e04a sd s2,0(sp)
800033f0: 1000 addi s0,sp,32
800033f2: 84aa mv s1,a0
if(!holdingsleep(&b->lock))
800033f4: 01050913 addi s2,a0,16
800033f8: 854a mv a0,s2
800033fa: 00001097 auipc ra,0x1
800033fe: 428080e7 jalr 1064(ra) # 80004822 <holdingsleep>
80003402: c92d beqz a0,80003474 <brelse+0x8e>
panic("brelse");
releasesleep(&b->lock);
80003404: 854a mv a0,s2
80003406: 00001097 auipc ra,0x1
8000340a: 3d8080e7 jalr 984(ra) # 800047de <releasesleep>
acquire(&bcache.lock);
8000340e: 00015517 auipc a0,0x15
80003412: ada50513 addi a0,a0,-1318 # 80017ee8 <bcache>
80003416: ffffd097 auipc ra,0xffffd
8000341a: 7ac080e7 jalr 1964(ra) # 80000bc2 <acquire>
b->refcnt--;
8000341e: 40bc lw a5,64(s1)
80003420: 37fd addiw a5,a5,-1
80003422: 0007871b sext.w a4,a5
80003426: c0bc sw a5,64(s1)
if (b->refcnt == 0) {
80003428: eb05 bnez a4,80003458 <brelse+0x72>
// no one is waiting for it.
b->next->prev = b->prev;
8000342a: 68bc ld a5,80(s1)
8000342c: 64b8 ld a4,72(s1)
8000342e: e7b8 sd a4,72(a5)
b->prev->next = b->next;
80003430: 64bc ld a5,72(s1)
80003432: 68b8 ld a4,80(s1)
80003434: ebb8 sd a4,80(a5)
b->next = bcache.head.next;
80003436: 0001d797 auipc a5,0x1d
8000343a: ab278793 addi a5,a5,-1358 # 8001fee8 <bcache+0x8000>
8000343e: 2b87b703 ld a4,696(a5)
80003442: e8b8 sd a4,80(s1)
b->prev = &bcache.head;
80003444: 0001d717 auipc a4,0x1d
80003448: d0c70713 addi a4,a4,-756 # 80020150 <bcache+0x8268>
8000344c: e4b8 sd a4,72(s1)
bcache.head.next->prev = b;
8000344e: 2b87b703 ld a4,696(a5)
80003452: e724 sd s1,72(a4)
bcache.head.next = b;
80003454: 2a97bc23 sd s1,696(a5)
}
release(&bcache.lock);
80003458: 00015517 auipc a0,0x15
8000345c: a9050513 addi a0,a0,-1392 # 80017ee8 <bcache>
80003460: ffffe097 auipc ra,0xffffe
80003464: 816080e7 jalr -2026(ra) # 80000c76 <release>
}
80003468: 60e2 ld ra,24(sp)
8000346a: 6442 ld s0,16(sp)
8000346c: 64a2 ld s1,8(sp)
8000346e: 6902 ld s2,0(sp)
80003470: 6105 addi sp,sp,32
80003472: 8082 ret
panic("brelse");
80003474: 00005517 auipc a0,0x5
80003478: 1d450513 addi a0,a0,468 # 80008648 <syscalls+0xf8>
8000347c: ffffd097 auipc ra,0xffffd
80003480: 0ae080e7 jalr 174(ra) # 8000052a <panic>
0000000080003484 <bpin>:
void
bpin(struct buf *b) {
80003484: 1101 addi sp,sp,-32
80003486: ec06 sd ra,24(sp)
80003488: e822 sd s0,16(sp)
8000348a: e426 sd s1,8(sp)
8000348c: 1000 addi s0,sp,32
8000348e: 84aa mv s1,a0
acquire(&bcache.lock);
80003490: 00015517 auipc a0,0x15
80003494: a5850513 addi a0,a0,-1448 # 80017ee8 <bcache>
80003498: ffffd097 auipc ra,0xffffd
8000349c: 72a080e7 jalr 1834(ra) # 80000bc2 <acquire>
b->refcnt++;
800034a0: 40bc lw a5,64(s1)
800034a2: 2785 addiw a5,a5,1
800034a4: c0bc sw a5,64(s1)
release(&bcache.lock);
800034a6: 00015517 auipc a0,0x15
800034aa: a4250513 addi a0,a0,-1470 # 80017ee8 <bcache>
800034ae: ffffd097 auipc ra,0xffffd
800034b2: 7c8080e7 jalr 1992(ra) # 80000c76 <release>
}
800034b6: 60e2 ld ra,24(sp)
800034b8: 6442 ld s0,16(sp)
800034ba: 64a2 ld s1,8(sp)
800034bc: 6105 addi sp,sp,32
800034be: 8082 ret
00000000800034c0 <bunpin>:
void
bunpin(struct buf *b) {
800034c0: 1101 addi sp,sp,-32
800034c2: ec06 sd ra,24(sp)
800034c4: e822 sd s0,16(sp)
800034c6: e426 sd s1,8(sp)
800034c8: 1000 addi s0,sp,32
800034ca: 84aa mv s1,a0
acquire(&bcache.lock);
800034cc: 00015517 auipc a0,0x15
800034d0: a1c50513 addi a0,a0,-1508 # 80017ee8 <bcache>
800034d4: ffffd097 auipc ra,0xffffd
800034d8: 6ee080e7 jalr 1774(ra) # 80000bc2 <acquire>
b->refcnt--;
800034dc: 40bc lw a5,64(s1)
800034de: 37fd addiw a5,a5,-1
800034e0: c0bc sw a5,64(s1)
release(&bcache.lock);
800034e2: 00015517 auipc a0,0x15
800034e6: a0650513 addi a0,a0,-1530 # 80017ee8 <bcache>
800034ea: ffffd097 auipc ra,0xffffd
800034ee: 78c080e7 jalr 1932(ra) # 80000c76 <release>
}
800034f2: 60e2 ld ra,24(sp)
800034f4: 6442 ld s0,16(sp)
800034f6: 64a2 ld s1,8(sp)
800034f8: 6105 addi sp,sp,32
800034fa: 8082 ret
00000000800034fc <bfree>:
}
// Free a disk block.
static void
bfree(int dev, uint b)
{
800034fc: 1101 addi sp,sp,-32
800034fe: ec06 sd ra,24(sp)
80003500: e822 sd s0,16(sp)
80003502: e426 sd s1,8(sp)
80003504: e04a sd s2,0(sp)
80003506: 1000 addi s0,sp,32
80003508: 84ae mv s1,a1
struct buf *bp;
int bi, m;
bp = bread(dev, BBLOCK(b, sb));
8000350a: 00d5d59b srliw a1,a1,0xd
8000350e: 0001d797 auipc a5,0x1d
80003512: 0b67a783 lw a5,182(a5) # 800205c4 <sb+0x1c>
80003516: 9dbd addw a1,a1,a5
80003518: 00000097 auipc ra,0x0
8000351c: d9e080e7 jalr -610(ra) # 800032b6 <bread>
bi = b % BPB;
m = 1 << (bi % 8);
80003520: 0074f713 andi a4,s1,7
80003524: 4785 li a5,1
80003526: 00e797bb sllw a5,a5,a4
if((bp->data[bi/8] & m) == 0)
8000352a: 14ce slli s1,s1,0x33
8000352c: 90d9 srli s1,s1,0x36
8000352e: 00950733 add a4,a0,s1
80003532: 05874703 lbu a4,88(a4)
80003536: 00e7f6b3 and a3,a5,a4
8000353a: c69d beqz a3,80003568 <bfree+0x6c>
8000353c: 892a mv s2,a0
panic("freeing free block");
bp->data[bi/8] &= ~m;
8000353e: 94aa add s1,s1,a0
80003540: fff7c793 not a5,a5
80003544: 8ff9 and a5,a5,a4
80003546: 04f48c23 sb a5,88(s1)
log_write(bp);
8000354a: 00001097 auipc ra,0x1
8000354e: 11e080e7 jalr 286(ra) # 80004668 <log_write>
brelse(bp);
80003552: 854a mv a0,s2
80003554: 00000097 auipc ra,0x0
80003558: e92080e7 jalr -366(ra) # 800033e6 <brelse>
}
8000355c: 60e2 ld ra,24(sp)
8000355e: 6442 ld s0,16(sp)
80003560: 64a2 ld s1,8(sp)
80003562: 6902 ld s2,0(sp)
80003564: 6105 addi sp,sp,32
80003566: 8082 ret
panic("freeing free block");
80003568: 00005517 auipc a0,0x5
8000356c: 0e850513 addi a0,a0,232 # 80008650 <syscalls+0x100>
80003570: ffffd097 auipc ra,0xffffd
80003574: fba080e7 jalr -70(ra) # 8000052a <panic>
0000000080003578 <balloc>:
{
80003578: 711d addi sp,sp,-96
8000357a: ec86 sd ra,88(sp)
8000357c: e8a2 sd s0,80(sp)
8000357e: e4a6 sd s1,72(sp)
80003580: e0ca sd s2,64(sp)
80003582: fc4e sd s3,56(sp)
80003584: f852 sd s4,48(sp)
80003586: f456 sd s5,40(sp)
80003588: f05a sd s6,32(sp)
8000358a: ec5e sd s7,24(sp)
8000358c: e862 sd s8,16(sp)
8000358e: e466 sd s9,8(sp)
80003590: 1080 addi s0,sp,96
for(b = 0; b < sb.size; b += BPB){
80003592: 0001d797 auipc a5,0x1d
80003596: 01a7a783 lw a5,26(a5) # 800205ac <sb+0x4>
8000359a: cbd1 beqz a5,8000362e <balloc+0xb6>
8000359c: 8baa mv s7,a0
8000359e: 4a81 li s5,0
bp = bread(dev, BBLOCK(b, sb));
800035a0: 0001db17 auipc s6,0x1d
800035a4: 008b0b13 addi s6,s6,8 # 800205a8 <sb>
for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
800035a8: 4c01 li s8,0
m = 1 << (bi % 8);
800035aa: 4985 li s3,1
for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
800035ac: 6a09 lui s4,0x2
for(b = 0; b < sb.size; b += BPB){
800035ae: 6c89 lui s9,0x2
800035b0: a831 j 800035cc <balloc+0x54>
brelse(bp);
800035b2: 854a mv a0,s2
800035b4: 00000097 auipc ra,0x0
800035b8: e32080e7 jalr -462(ra) # 800033e6 <brelse>
for(b = 0; b < sb.size; b += BPB){
800035bc: 015c87bb addw a5,s9,s5
800035c0: 00078a9b sext.w s5,a5
800035c4: 004b2703 lw a4,4(s6)
800035c8: 06eaf363 bgeu s5,a4,8000362e <balloc+0xb6>
bp = bread(dev, BBLOCK(b, sb));
800035cc: 41fad79b sraiw a5,s5,0x1f
800035d0: 0137d79b srliw a5,a5,0x13
800035d4: 015787bb addw a5,a5,s5
800035d8: 40d7d79b sraiw a5,a5,0xd
800035dc: 01cb2583 lw a1,28(s6)
800035e0: 9dbd addw a1,a1,a5
800035e2: 855e mv a0,s7
800035e4: 00000097 auipc ra,0x0
800035e8: cd2080e7 jalr -814(ra) # 800032b6 <bread>
800035ec: 892a mv s2,a0
for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
800035ee: 004b2503 lw a0,4(s6)
800035f2: 000a849b sext.w s1,s5
800035f6: 8662 mv a2,s8
800035f8: faa4fde3 bgeu s1,a0,800035b2 <balloc+0x3a>
m = 1 << (bi % 8);
800035fc: 41f6579b sraiw a5,a2,0x1f
80003600: 01d7d69b srliw a3,a5,0x1d
80003604: 00c6873b addw a4,a3,a2
80003608: 00777793 andi a5,a4,7
8000360c: 9f95 subw a5,a5,a3
8000360e: 00f997bb sllw a5,s3,a5
if((bp->data[bi/8] & m) == 0){ // Is block free?
80003612: 4037571b sraiw a4,a4,0x3
80003616: 00e906b3 add a3,s2,a4
8000361a: 0586c683 lbu a3,88(a3)
8000361e: 00d7f5b3 and a1,a5,a3
80003622: cd91 beqz a1,8000363e <balloc+0xc6>
for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
80003624: 2605 addiw a2,a2,1
80003626: 2485 addiw s1,s1,1
80003628: fd4618e3 bne a2,s4,800035f8 <balloc+0x80>
8000362c: b759 j 800035b2 <balloc+0x3a>
panic("balloc: out of blocks");
8000362e: 00005517 auipc a0,0x5
80003632: 03a50513 addi a0,a0,58 # 80008668 <syscalls+0x118>
80003636: ffffd097 auipc ra,0xffffd
8000363a: ef4080e7 jalr -268(ra) # 8000052a <panic>
bp->data[bi/8] |= m; // Mark block in use.
8000363e: 974a add a4,a4,s2
80003640: 8fd5 or a5,a5,a3
80003642: 04f70c23 sb a5,88(a4)
log_write(bp);
80003646: 854a mv a0,s2
80003648: 00001097 auipc ra,0x1
8000364c: 020080e7 jalr 32(ra) # 80004668 <log_write>
brelse(bp);
80003650: 854a mv a0,s2
80003652: 00000097 auipc ra,0x0
80003656: d94080e7 jalr -620(ra) # 800033e6 <brelse>
bp = bread(dev, bno);
8000365a: 85a6 mv a1,s1
8000365c: 855e mv a0,s7
8000365e: 00000097 auipc ra,0x0
80003662: c58080e7 jalr -936(ra) # 800032b6 <bread>
80003666: 892a mv s2,a0
memset(bp->data, 0, BSIZE);
80003668: 40000613 li a2,1024
8000366c: 4581 li a1,0
8000366e: 05850513 addi a0,a0,88
80003672: ffffd097 auipc ra,0xffffd
80003676: 64c080e7 jalr 1612(ra) # 80000cbe <memset>
log_write(bp);
8000367a: 854a mv a0,s2
8000367c: 00001097 auipc ra,0x1
80003680: fec080e7 jalr -20(ra) # 80004668 <log_write>
brelse(bp);
80003684: 854a mv a0,s2
80003686: 00000097 auipc ra,0x0
8000368a: d60080e7 jalr -672(ra) # 800033e6 <brelse>
}
8000368e: 8526 mv a0,s1
80003690: 60e6 ld ra,88(sp)
80003692: 6446 ld s0,80(sp)
80003694: 64a6 ld s1,72(sp)
80003696: 6906 ld s2,64(sp)
80003698: 79e2 ld s3,56(sp)
8000369a: 7a42 ld s4,48(sp)
8000369c: 7aa2 ld s5,40(sp)
8000369e: 7b02 ld s6,32(sp)
800036a0: 6be2 ld s7,24(sp)
800036a2: 6c42 ld s8,16(sp)
800036a4: 6ca2 ld s9,8(sp)
800036a6: 6125 addi sp,sp,96
800036a8: 8082 ret
00000000800036aa <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)
{
800036aa: 7179 addi sp,sp,-48
800036ac: f406 sd ra,40(sp)
800036ae: f022 sd s0,32(sp)
800036b0: ec26 sd s1,24(sp)
800036b2: e84a sd s2,16(sp)
800036b4: e44e sd s3,8(sp)
800036b6: e052 sd s4,0(sp)
800036b8: 1800 addi s0,sp,48
800036ba: 892a mv s2,a0
uint addr, *a;
struct buf *bp;
if(bn < NDIRECT){
800036bc: 47ad li a5,11
800036be: 04b7fe63 bgeu a5,a1,8000371a <bmap+0x70>
if((addr = ip->addrs[bn]) == 0)
ip->addrs[bn] = addr = balloc(ip->dev);
return addr;
}
bn -= NDIRECT;
800036c2: ff45849b addiw s1,a1,-12
800036c6: 0004871b sext.w a4,s1
if(bn < NINDIRECT){
800036ca: 0ff00793 li a5,255
800036ce: 0ae7e463 bltu a5,a4,80003776 <bmap+0xcc>
// Load indirect block, allocating if necessary.
if((addr = ip->addrs[NDIRECT]) == 0)
800036d2: 08052583 lw a1,128(a0)
800036d6: c5b5 beqz a1,80003742 <bmap+0x98>
ip->addrs[NDIRECT] = addr = balloc(ip->dev);
bp = bread(ip->dev, addr);
800036d8: 00092503 lw a0,0(s2)
800036dc: 00000097 auipc ra,0x0
800036e0: bda080e7 jalr -1062(ra) # 800032b6 <bread>
800036e4: 8a2a mv s4,a0
a = (uint*)bp->data;
800036e6: 05850793 addi a5,a0,88
if((addr = a[bn]) == 0){
800036ea: 02049713 slli a4,s1,0x20
800036ee: 01e75593 srli a1,a4,0x1e
800036f2: 00b784b3 add s1,a5,a1
800036f6: 0004a983 lw s3,0(s1)
800036fa: 04098e63 beqz s3,80003756 <bmap+0xac>
a[bn] = addr = balloc(ip->dev);
log_write(bp);
}
brelse(bp);
800036fe: 8552 mv a0,s4
80003700: 00000097 auipc ra,0x0
80003704: ce6080e7 jalr -794(ra) # 800033e6 <brelse>
return addr;
}
panic("bmap: out of range");
}
80003708: 854e mv a0,s3
8000370a: 70a2 ld ra,40(sp)
8000370c: 7402 ld s0,32(sp)
8000370e: 64e2 ld s1,24(sp)
80003710: 6942 ld s2,16(sp)
80003712: 69a2 ld s3,8(sp)
80003714: 6a02 ld s4,0(sp)
80003716: 6145 addi sp,sp,48
80003718: 8082 ret
if((addr = ip->addrs[bn]) == 0)
8000371a: 02059793 slli a5,a1,0x20
8000371e: 01e7d593 srli a1,a5,0x1e
80003722: 00b504b3 add s1,a0,a1
80003726: 0504a983 lw s3,80(s1)
8000372a: fc099fe3 bnez s3,80003708 <bmap+0x5e>
ip->addrs[bn] = addr = balloc(ip->dev);
8000372e: 4108 lw a0,0(a0)
80003730: 00000097 auipc ra,0x0
80003734: e48080e7 jalr -440(ra) # 80003578 <balloc>
80003738: 0005099b sext.w s3,a0
8000373c: 0534a823 sw s3,80(s1)
80003740: b7e1 j 80003708 <bmap+0x5e>
ip->addrs[NDIRECT] = addr = balloc(ip->dev);
80003742: 4108 lw a0,0(a0)
80003744: 00000097 auipc ra,0x0
80003748: e34080e7 jalr -460(ra) # 80003578 <balloc>
8000374c: 0005059b sext.w a1,a0
80003750: 08b92023 sw a1,128(s2)
80003754: b751 j 800036d8 <bmap+0x2e>
a[bn] = addr = balloc(ip->dev);
80003756: 00092503 lw a0,0(s2)
8000375a: 00000097 auipc ra,0x0
8000375e: e1e080e7 jalr -482(ra) # 80003578 <balloc>
80003762: 0005099b sext.w s3,a0
80003766: 0134a023 sw s3,0(s1)
log_write(bp);
8000376a: 8552 mv a0,s4
8000376c: 00001097 auipc ra,0x1
80003770: efc080e7 jalr -260(ra) # 80004668 <log_write>
80003774: b769 j 800036fe <bmap+0x54>
panic("bmap: out of range");
80003776: 00005517 auipc a0,0x5
8000377a: f0a50513 addi a0,a0,-246 # 80008680 <syscalls+0x130>
8000377e: ffffd097 auipc ra,0xffffd
80003782: dac080e7 jalr -596(ra) # 8000052a <panic>
0000000080003786 <iget>:
{
80003786: 7179 addi sp,sp,-48
80003788: f406 sd ra,40(sp)
8000378a: f022 sd s0,32(sp)
8000378c: ec26 sd s1,24(sp)
8000378e: e84a sd s2,16(sp)
80003790: e44e sd s3,8(sp)
80003792: e052 sd s4,0(sp)
80003794: 1800 addi s0,sp,48
80003796: 89aa mv s3,a0
80003798: 8a2e mv s4,a1
acquire(&itable.lock);
8000379a: 0001d517 auipc a0,0x1d
8000379e: e2e50513 addi a0,a0,-466 # 800205c8 <itable>
800037a2: ffffd097 auipc ra,0xffffd
800037a6: 420080e7 jalr 1056(ra) # 80000bc2 <acquire>
empty = 0;
800037aa: 4901 li s2,0
for(ip = &itable.inode[0]; ip < &itable.inode[NINODE]; ip++){
800037ac: 0001d497 auipc s1,0x1d
800037b0: e3448493 addi s1,s1,-460 # 800205e0 <itable+0x18>
800037b4: 0001f697 auipc a3,0x1f
800037b8: 8bc68693 addi a3,a3,-1860 # 80022070 <log>
800037bc: a039 j 800037ca <iget+0x44>
if(empty == 0 && ip->ref == 0) // Remember empty slot.
800037be: 02090b63 beqz s2,800037f4 <iget+0x6e>
for(ip = &itable.inode[0]; ip < &itable.inode[NINODE]; ip++){
800037c2: 08848493 addi s1,s1,136
800037c6: 02d48a63 beq s1,a3,800037fa <iget+0x74>
if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
800037ca: 449c lw a5,8(s1)
800037cc: fef059e3 blez a5,800037be <iget+0x38>
800037d0: 4098 lw a4,0(s1)
800037d2: ff3716e3 bne a4,s3,800037be <iget+0x38>
800037d6: 40d8 lw a4,4(s1)
800037d8: ff4713e3 bne a4,s4,800037be <iget+0x38>
ip->ref++;
800037dc: 2785 addiw a5,a5,1
800037de: c49c sw a5,8(s1)
release(&itable.lock);
800037e0: 0001d517 auipc a0,0x1d
800037e4: de850513 addi a0,a0,-536 # 800205c8 <itable>
800037e8: ffffd097 auipc ra,0xffffd
800037ec: 48e080e7 jalr 1166(ra) # 80000c76 <release>
return ip;
800037f0: 8926 mv s2,s1
800037f2: a03d j 80003820 <iget+0x9a>
if(empty == 0 && ip->ref == 0) // Remember empty slot.
800037f4: f7f9 bnez a5,800037c2 <iget+0x3c>
800037f6: 8926 mv s2,s1
800037f8: b7e9 j 800037c2 <iget+0x3c>
if(empty == 0)
800037fa: 02090c63 beqz s2,80003832 <iget+0xac>
ip->dev = dev;
800037fe: 01392023 sw s3,0(s2)
ip->inum = inum;
80003802: 01492223 sw s4,4(s2)
ip->ref = 1;
80003806: 4785 li a5,1
80003808: 00f92423 sw a5,8(s2)
ip->valid = 0;
8000380c: 04092023 sw zero,64(s2)
release(&itable.lock);
80003810: 0001d517 auipc a0,0x1d
80003814: db850513 addi a0,a0,-584 # 800205c8 <itable>
80003818: ffffd097 auipc ra,0xffffd
8000381c: 45e080e7 jalr 1118(ra) # 80000c76 <release>
}
80003820: 854a mv a0,s2
80003822: 70a2 ld ra,40(sp)
80003824: 7402 ld s0,32(sp)
80003826: 64e2 ld s1,24(sp)
80003828: 6942 ld s2,16(sp)
8000382a: 69a2 ld s3,8(sp)
8000382c: 6a02 ld s4,0(sp)
8000382e: 6145 addi sp,sp,48
80003830: 8082 ret
panic("iget: no inodes");
80003832: 00005517 auipc a0,0x5
80003836: e6650513 addi a0,a0,-410 # 80008698 <syscalls+0x148>
8000383a: ffffd097 auipc ra,0xffffd
8000383e: cf0080e7 jalr -784(ra) # 8000052a <panic>
0000000080003842 <fsinit>:
fsinit(int dev) {
80003842: 7179 addi sp,sp,-48
80003844: f406 sd ra,40(sp)
80003846: f022 sd s0,32(sp)
80003848: ec26 sd s1,24(sp)
8000384a: e84a sd s2,16(sp)
8000384c: e44e sd s3,8(sp)
8000384e: 1800 addi s0,sp,48
80003850: 892a mv s2,a0
bp = bread(dev, 1);
80003852: 4585 li a1,1
80003854: 00000097 auipc ra,0x0
80003858: a62080e7 jalr -1438(ra) # 800032b6 <bread>
8000385c: 84aa mv s1,a0
memmove(sb, bp->data, sizeof(*sb));
8000385e: 0001d997 auipc s3,0x1d
80003862: d4a98993 addi s3,s3,-694 # 800205a8 <sb>
80003866: 02000613 li a2,32
8000386a: 05850593 addi a1,a0,88
8000386e: 854e mv a0,s3
80003870: ffffd097 auipc ra,0xffffd
80003874: 4aa080e7 jalr 1194(ra) # 80000d1a <memmove>
brelse(bp);
80003878: 8526 mv a0,s1
8000387a: 00000097 auipc ra,0x0
8000387e: b6c080e7 jalr -1172(ra) # 800033e6 <brelse>
if(sb.magic != FSMAGIC)
80003882: 0009a703 lw a4,0(s3)
80003886: 102037b7 lui a5,0x10203
8000388a: 04078793 addi a5,a5,64 # 10203040 <_entry-0x6fdfcfc0>
8000388e: 02f71263 bne a4,a5,800038b2 <fsinit+0x70>
initlog(dev, &sb);
80003892: 0001d597 auipc a1,0x1d
80003896: d1658593 addi a1,a1,-746 # 800205a8 <sb>
8000389a: 854a mv a0,s2
8000389c: 00001097 auipc ra,0x1
800038a0: b4e080e7 jalr -1202(ra) # 800043ea <initlog>
}
800038a4: 70a2 ld ra,40(sp)
800038a6: 7402 ld s0,32(sp)
800038a8: 64e2 ld s1,24(sp)
800038aa: 6942 ld s2,16(sp)
800038ac: 69a2 ld s3,8(sp)
800038ae: 6145 addi sp,sp,48
800038b0: 8082 ret
panic("invalid file system");
800038b2: 00005517 auipc a0,0x5
800038b6: df650513 addi a0,a0,-522 # 800086a8 <syscalls+0x158>
800038ba: ffffd097 auipc ra,0xffffd
800038be: c70080e7 jalr -912(ra) # 8000052a <panic>
00000000800038c2 <iinit>:
{
800038c2: 7179 addi sp,sp,-48
800038c4: f406 sd ra,40(sp)
800038c6: f022 sd s0,32(sp)
800038c8: ec26 sd s1,24(sp)
800038ca: e84a sd s2,16(sp)
800038cc: e44e sd s3,8(sp)
800038ce: 1800 addi s0,sp,48
initlock(&itable.lock, "itable");
800038d0: 00005597 auipc a1,0x5
800038d4: df058593 addi a1,a1,-528 # 800086c0 <syscalls+0x170>
800038d8: 0001d517 auipc a0,0x1d
800038dc: cf050513 addi a0,a0,-784 # 800205c8 <itable>
800038e0: ffffd097 auipc ra,0xffffd
800038e4: 252080e7 jalr 594(ra) # 80000b32 <initlock>
for(i = 0; i < NINODE; i++) {
800038e8: 0001d497 auipc s1,0x1d
800038ec: d0848493 addi s1,s1,-760 # 800205f0 <itable+0x28>
800038f0: 0001e997 auipc s3,0x1e
800038f4: 79098993 addi s3,s3,1936 # 80022080 <log+0x10>
initsleeplock(&itable.inode[i].lock, "inode");
800038f8: 00005917 auipc s2,0x5
800038fc: dd090913 addi s2,s2,-560 # 800086c8 <syscalls+0x178>
80003900: 85ca mv a1,s2
80003902: 8526 mv a0,s1
80003904: 00001097 auipc ra,0x1
80003908: e4a080e7 jalr -438(ra) # 8000474e <initsleeplock>
for(i = 0; i < NINODE; i++) {
8000390c: 08848493 addi s1,s1,136
80003910: ff3498e3 bne s1,s3,80003900 <iinit+0x3e>
}
80003914: 70a2 ld ra,40(sp)
80003916: 7402 ld s0,32(sp)
80003918: 64e2 ld s1,24(sp)
8000391a: 6942 ld s2,16(sp)
8000391c: 69a2 ld s3,8(sp)
8000391e: 6145 addi sp,sp,48
80003920: 8082 ret
0000000080003922 <ialloc>:
{
80003922: 715d addi sp,sp,-80
80003924: e486 sd ra,72(sp)
80003926: e0a2 sd s0,64(sp)
80003928: fc26 sd s1,56(sp)
8000392a: f84a sd s2,48(sp)
8000392c: f44e sd s3,40(sp)
8000392e: f052 sd s4,32(sp)
80003930: ec56 sd s5,24(sp)
80003932: e85a sd s6,16(sp)
80003934: e45e sd s7,8(sp)
80003936: 0880 addi s0,sp,80
for(inum = 1; inum < sb.ninodes; inum++){
80003938: 0001d717 auipc a4,0x1d
8000393c: c7c72703 lw a4,-900(a4) # 800205b4 <sb+0xc>
80003940: 4785 li a5,1
80003942: 04e7fa63 bgeu a5,a4,80003996 <ialloc+0x74>
80003946: 8aaa mv s5,a0
80003948: 8bae mv s7,a1
8000394a: 4485 li s1,1
bp = bread(dev, IBLOCK(inum, sb));
8000394c: 0001da17 auipc s4,0x1d
80003950: c5ca0a13 addi s4,s4,-932 # 800205a8 <sb>
80003954: 00048b1b sext.w s6,s1
80003958: 0044d793 srli a5,s1,0x4
8000395c: 018a2583 lw a1,24(s4)
80003960: 9dbd addw a1,a1,a5
80003962: 8556 mv a0,s5
80003964: 00000097 auipc ra,0x0
80003968: 952080e7 jalr -1710(ra) # 800032b6 <bread>
8000396c: 892a mv s2,a0
dip = (struct dinode*)bp->data + inum%IPB;
8000396e: 05850993 addi s3,a0,88
80003972: 00f4f793 andi a5,s1,15
80003976: 079a slli a5,a5,0x6
80003978: 99be add s3,s3,a5
if(dip->type == 0){ // a free inode
8000397a: 00099783 lh a5,0(s3)
8000397e: c785 beqz a5,800039a6 <ialloc+0x84>
brelse(bp);
80003980: 00000097 auipc ra,0x0
80003984: a66080e7 jalr -1434(ra) # 800033e6 <brelse>
for(inum = 1; inum < sb.ninodes; inum++){
80003988: 0485 addi s1,s1,1
8000398a: 00ca2703 lw a4,12(s4)
8000398e: 0004879b sext.w a5,s1
80003992: fce7e1e3 bltu a5,a4,80003954 <ialloc+0x32>
panic("ialloc: no inodes");
80003996: 00005517 auipc a0,0x5
8000399a: d3a50513 addi a0,a0,-710 # 800086d0 <syscalls+0x180>
8000399e: ffffd097 auipc ra,0xffffd
800039a2: b8c080e7 jalr -1140(ra) # 8000052a <panic>
memset(dip, 0, sizeof(*dip));
800039a6: 04000613 li a2,64
800039aa: 4581 li a1,0
800039ac: 854e mv a0,s3
800039ae: ffffd097 auipc ra,0xffffd
800039b2: 310080e7 jalr 784(ra) # 80000cbe <memset>
dip->type = type;
800039b6: 01799023 sh s7,0(s3)
log_write(bp); // mark it allocated on the disk
800039ba: 854a mv a0,s2
800039bc: 00001097 auipc ra,0x1
800039c0: cac080e7 jalr -852(ra) # 80004668 <log_write>
brelse(bp);
800039c4: 854a mv a0,s2
800039c6: 00000097 auipc ra,0x0
800039ca: a20080e7 jalr -1504(ra) # 800033e6 <brelse>
return iget(dev, inum);
800039ce: 85da mv a1,s6
800039d0: 8556 mv a0,s5
800039d2: 00000097 auipc ra,0x0
800039d6: db4080e7 jalr -588(ra) # 80003786 <iget>
}
800039da: 60a6 ld ra,72(sp)
800039dc: 6406 ld s0,64(sp)
800039de: 74e2 ld s1,56(sp)
800039e0: 7942 ld s2,48(sp)
800039e2: 79a2 ld s3,40(sp)
800039e4: 7a02 ld s4,32(sp)
800039e6: 6ae2 ld s5,24(sp)
800039e8: 6b42 ld s6,16(sp)
800039ea: 6ba2 ld s7,8(sp)
800039ec: 6161 addi sp,sp,80
800039ee: 8082 ret
00000000800039f0 <iupdate>:
{
800039f0: 1101 addi sp,sp,-32
800039f2: ec06 sd ra,24(sp)
800039f4: e822 sd s0,16(sp)
800039f6: e426 sd s1,8(sp)
800039f8: e04a sd s2,0(sp)
800039fa: 1000 addi s0,sp,32
800039fc: 84aa mv s1,a0
bp = bread(ip->dev, IBLOCK(ip->inum, sb));
800039fe: 415c lw a5,4(a0)
80003a00: 0047d79b srliw a5,a5,0x4
80003a04: 0001d597 auipc a1,0x1d
80003a08: bbc5a583 lw a1,-1092(a1) # 800205c0 <sb+0x18>
80003a0c: 9dbd addw a1,a1,a5
80003a0e: 4108 lw a0,0(a0)
80003a10: 00000097 auipc ra,0x0
80003a14: 8a6080e7 jalr -1882(ra) # 800032b6 <bread>
80003a18: 892a mv s2,a0
dip = (struct dinode*)bp->data + ip->inum%IPB;
80003a1a: 05850793 addi a5,a0,88
80003a1e: 40c8 lw a0,4(s1)
80003a20: 893d andi a0,a0,15
80003a22: 051a slli a0,a0,0x6
80003a24: 953e add a0,a0,a5
dip->type = ip->type;
80003a26: 04449703 lh a4,68(s1)
80003a2a: 00e51023 sh a4,0(a0)
dip->major = ip->major;
80003a2e: 04649703 lh a4,70(s1)
80003a32: 00e51123 sh a4,2(a0)
dip->minor = ip->minor;
80003a36: 04849703 lh a4,72(s1)
80003a3a: 00e51223 sh a4,4(a0)
dip->nlink = ip->nlink;
80003a3e: 04a49703 lh a4,74(s1)
80003a42: 00e51323 sh a4,6(a0)
dip->size = ip->size;
80003a46: 44f8 lw a4,76(s1)
80003a48: c518 sw a4,8(a0)
memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
80003a4a: 03400613 li a2,52
80003a4e: 05048593 addi a1,s1,80
80003a52: 0531 addi a0,a0,12
80003a54: ffffd097 auipc ra,0xffffd
80003a58: 2c6080e7 jalr 710(ra) # 80000d1a <memmove>
log_write(bp);
80003a5c: 854a mv a0,s2
80003a5e: 00001097 auipc ra,0x1
80003a62: c0a080e7 jalr -1014(ra) # 80004668 <log_write>
brelse(bp);
80003a66: 854a mv a0,s2
80003a68: 00000097 auipc ra,0x0
80003a6c: 97e080e7 jalr -1666(ra) # 800033e6 <brelse>
}
80003a70: 60e2 ld ra,24(sp)
80003a72: 6442 ld s0,16(sp)
80003a74: 64a2 ld s1,8(sp)
80003a76: 6902 ld s2,0(sp)
80003a78: 6105 addi sp,sp,32
80003a7a: 8082 ret
0000000080003a7c <idup>:
{
80003a7c: 1101 addi sp,sp,-32
80003a7e: ec06 sd ra,24(sp)
80003a80: e822 sd s0,16(sp)
80003a82: e426 sd s1,8(sp)
80003a84: 1000 addi s0,sp,32
80003a86: 84aa mv s1,a0
acquire(&itable.lock);
80003a88: 0001d517 auipc a0,0x1d
80003a8c: b4050513 addi a0,a0,-1216 # 800205c8 <itable>
80003a90: ffffd097 auipc ra,0xffffd
80003a94: 132080e7 jalr 306(ra) # 80000bc2 <acquire>
ip->ref++;
80003a98: 449c lw a5,8(s1)
80003a9a: 2785 addiw a5,a5,1
80003a9c: c49c sw a5,8(s1)
release(&itable.lock);
80003a9e: 0001d517 auipc a0,0x1d
80003aa2: b2a50513 addi a0,a0,-1238 # 800205c8 <itable>
80003aa6: ffffd097 auipc ra,0xffffd
80003aaa: 1d0080e7 jalr 464(ra) # 80000c76 <release>
}
80003aae: 8526 mv a0,s1
80003ab0: 60e2 ld ra,24(sp)
80003ab2: 6442 ld s0,16(sp)
80003ab4: 64a2 ld s1,8(sp)
80003ab6: 6105 addi sp,sp,32
80003ab8: 8082 ret
0000000080003aba <ilock>:
{
80003aba: 1101 addi sp,sp,-32
80003abc: ec06 sd ra,24(sp)
80003abe: e822 sd s0,16(sp)
80003ac0: e426 sd s1,8(sp)
80003ac2: e04a sd s2,0(sp)
80003ac4: 1000 addi s0,sp,32
if(ip == 0 || ip->ref < 1)
80003ac6: c115 beqz a0,80003aea <ilock+0x30>
80003ac8: 84aa mv s1,a0
80003aca: 451c lw a5,8(a0)
80003acc: 00f05f63 blez a5,80003aea <ilock+0x30>
acquiresleep(&ip->lock);
80003ad0: 0541 addi a0,a0,16
80003ad2: 00001097 auipc ra,0x1
80003ad6: cb6080e7 jalr -842(ra) # 80004788 <acquiresleep>
if(ip->valid == 0){
80003ada: 40bc lw a5,64(s1)
80003adc: cf99 beqz a5,80003afa <ilock+0x40>
}
80003ade: 60e2 ld ra,24(sp)
80003ae0: 6442 ld s0,16(sp)
80003ae2: 64a2 ld s1,8(sp)
80003ae4: 6902 ld s2,0(sp)
80003ae6: 6105 addi sp,sp,32
80003ae8: 8082 ret
panic("ilock");
80003aea: 00005517 auipc a0,0x5
80003aee: bfe50513 addi a0,a0,-1026 # 800086e8 <syscalls+0x198>
80003af2: ffffd097 auipc ra,0xffffd
80003af6: a38080e7 jalr -1480(ra) # 8000052a <panic>
bp = bread(ip->dev, IBLOCK(ip->inum, sb));
80003afa: 40dc lw a5,4(s1)
80003afc: 0047d79b srliw a5,a5,0x4
80003b00: 0001d597 auipc a1,0x1d
80003b04: ac05a583 lw a1,-1344(a1) # 800205c0 <sb+0x18>
80003b08: 9dbd addw a1,a1,a5
80003b0a: 4088 lw a0,0(s1)
80003b0c: fffff097 auipc ra,0xfffff
80003b10: 7aa080e7 jalr 1962(ra) # 800032b6 <bread>
80003b14: 892a mv s2,a0
dip = (struct dinode*)bp->data + ip->inum%IPB;
80003b16: 05850593 addi a1,a0,88
80003b1a: 40dc lw a5,4(s1)
80003b1c: 8bbd andi a5,a5,15
80003b1e: 079a slli a5,a5,0x6
80003b20: 95be add a1,a1,a5
ip->type = dip->type;
80003b22: 00059783 lh a5,0(a1)
80003b26: 04f49223 sh a5,68(s1)
ip->major = dip->major;
80003b2a: 00259783 lh a5,2(a1)
80003b2e: 04f49323 sh a5,70(s1)
ip->minor = dip->minor;
80003b32: 00459783 lh a5,4(a1)
80003b36: 04f49423 sh a5,72(s1)
ip->nlink = dip->nlink;
80003b3a: 00659783 lh a5,6(a1)
80003b3e: 04f49523 sh a5,74(s1)
ip->size = dip->size;
80003b42: 459c lw a5,8(a1)
80003b44: c4fc sw a5,76(s1)
memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
80003b46: 03400613 li a2,52
80003b4a: 05b1 addi a1,a1,12
80003b4c: 05048513 addi a0,s1,80
80003b50: ffffd097 auipc ra,0xffffd
80003b54: 1ca080e7 jalr 458(ra) # 80000d1a <memmove>
brelse(bp);
80003b58: 854a mv a0,s2
80003b5a: 00000097 auipc ra,0x0
80003b5e: 88c080e7 jalr -1908(ra) # 800033e6 <brelse>
ip->valid = 1;
80003b62: 4785 li a5,1
80003b64: c0bc sw a5,64(s1)
if(ip->type == 0)
80003b66: 04449783 lh a5,68(s1)
80003b6a: fbb5 bnez a5,80003ade <ilock+0x24>
panic("ilock: no type");
80003b6c: 00005517 auipc a0,0x5
80003b70: b8450513 addi a0,a0,-1148 # 800086f0 <syscalls+0x1a0>
80003b74: ffffd097 auipc ra,0xffffd
80003b78: 9b6080e7 jalr -1610(ra) # 8000052a <panic>
0000000080003b7c <iunlock>:
{
80003b7c: 1101 addi sp,sp,-32
80003b7e: ec06 sd ra,24(sp)
80003b80: e822 sd s0,16(sp)
80003b82: e426 sd s1,8(sp)
80003b84: e04a sd s2,0(sp)
80003b86: 1000 addi s0,sp,32
if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1)
80003b88: c905 beqz a0,80003bb8 <iunlock+0x3c>
80003b8a: 84aa mv s1,a0
80003b8c: 01050913 addi s2,a0,16
80003b90: 854a mv a0,s2
80003b92: 00001097 auipc ra,0x1
80003b96: c90080e7 jalr -880(ra) # 80004822 <holdingsleep>
80003b9a: cd19 beqz a0,80003bb8 <iunlock+0x3c>
80003b9c: 449c lw a5,8(s1)
80003b9e: 00f05d63 blez a5,80003bb8 <iunlock+0x3c>
releasesleep(&ip->lock);
80003ba2: 854a mv a0,s2
80003ba4: 00001097 auipc ra,0x1
80003ba8: c3a080e7 jalr -966(ra) # 800047de <releasesleep>
}
80003bac: 60e2 ld ra,24(sp)
80003bae: 6442 ld s0,16(sp)
80003bb0: 64a2 ld s1,8(sp)
80003bb2: 6902 ld s2,0(sp)
80003bb4: 6105 addi sp,sp,32
80003bb6: 8082 ret
panic("iunlock");
80003bb8: 00005517 auipc a0,0x5
80003bbc: b4850513 addi a0,a0,-1208 # 80008700 <syscalls+0x1b0>
80003bc0: ffffd097 auipc ra,0xffffd
80003bc4: 96a080e7 jalr -1686(ra) # 8000052a <panic>
0000000080003bc8 <itrunc>:
// Truncate inode (discard contents).
// Caller must hold ip->lock.
void
itrunc(struct inode *ip)
{
80003bc8: 7179 addi sp,sp,-48
80003bca: f406 sd ra,40(sp)
80003bcc: f022 sd s0,32(sp)
80003bce: ec26 sd s1,24(sp)
80003bd0: e84a sd s2,16(sp)
80003bd2: e44e sd s3,8(sp)
80003bd4: e052 sd s4,0(sp)
80003bd6: 1800 addi s0,sp,48
80003bd8: 89aa mv s3,a0
int i, j;
struct buf *bp;
uint *a;
for(i = 0; i < NDIRECT; i++){
80003bda: 05050493 addi s1,a0,80
80003bde: 08050913 addi s2,a0,128
80003be2: a021 j 80003bea <itrunc+0x22>
80003be4: 0491 addi s1,s1,4
80003be6: 01248d63 beq s1,s2,80003c00 <itrunc+0x38>
if(ip->addrs[i]){
80003bea: 408c lw a1,0(s1)
80003bec: dde5 beqz a1,80003be4 <itrunc+0x1c>
bfree(ip->dev, ip->addrs[i]);
80003bee: 0009a503 lw a0,0(s3)
80003bf2: 00000097 auipc ra,0x0
80003bf6: 90a080e7 jalr -1782(ra) # 800034fc <bfree>
ip->addrs[i] = 0;
80003bfa: 0004a023 sw zero,0(s1)
80003bfe: b7dd j 80003be4 <itrunc+0x1c>
}
}
if(ip->addrs[NDIRECT]){
80003c00: 0809a583 lw a1,128(s3)
80003c04: e185 bnez a1,80003c24 <itrunc+0x5c>
brelse(bp);
bfree(ip->dev, ip->addrs[NDIRECT]);
ip->addrs[NDIRECT] = 0;
}
ip->size = 0;
80003c06: 0409a623 sw zero,76(s3)
iupdate(ip);
80003c0a: 854e mv a0,s3
80003c0c: 00000097 auipc ra,0x0
80003c10: de4080e7 jalr -540(ra) # 800039f0 <iupdate>
}
80003c14: 70a2 ld ra,40(sp)
80003c16: 7402 ld s0,32(sp)
80003c18: 64e2 ld s1,24(sp)
80003c1a: 6942 ld s2,16(sp)
80003c1c: 69a2 ld s3,8(sp)
80003c1e: 6a02 ld s4,0(sp)
80003c20: 6145 addi sp,sp,48
80003c22: 8082 ret
bp = bread(ip->dev, ip->addrs[NDIRECT]);
80003c24: 0009a503 lw a0,0(s3)
80003c28: fffff097 auipc ra,0xfffff
80003c2c: 68e080e7 jalr 1678(ra) # 800032b6 <bread>
80003c30: 8a2a mv s4,a0
for(j = 0; j < NINDIRECT; j++){
80003c32: 05850493 addi s1,a0,88
80003c36: 45850913 addi s2,a0,1112
80003c3a: a021 j 80003c42 <itrunc+0x7a>
80003c3c: 0491 addi s1,s1,4
80003c3e: 01248b63 beq s1,s2,80003c54 <itrunc+0x8c>
if(a[j])
80003c42: 408c lw a1,0(s1)
80003c44: dde5 beqz a1,80003c3c <itrunc+0x74>
bfree(ip->dev, a[j]);
80003c46: 0009a503 lw a0,0(s3)
80003c4a: 00000097 auipc ra,0x0
80003c4e: 8b2080e7 jalr -1870(ra) # 800034fc <bfree>
80003c52: b7ed j 80003c3c <itrunc+0x74>
brelse(bp);
80003c54: 8552 mv a0,s4
80003c56: fffff097 auipc ra,0xfffff
80003c5a: 790080e7 jalr 1936(ra) # 800033e6 <brelse>
bfree(ip->dev, ip->addrs[NDIRECT]);
80003c5e: 0809a583 lw a1,128(s3)
80003c62: 0009a503 lw a0,0(s3)
80003c66: 00000097 auipc ra,0x0
80003c6a: 896080e7 jalr -1898(ra) # 800034fc <bfree>
ip->addrs[NDIRECT] = 0;
80003c6e: 0809a023 sw zero,128(s3)
80003c72: bf51 j 80003c06 <itrunc+0x3e>
0000000080003c74 <iput>:
{
80003c74: 1101 addi sp,sp,-32
80003c76: ec06 sd ra,24(sp)
80003c78: e822 sd s0,16(sp)
80003c7a: e426 sd s1,8(sp)
80003c7c: e04a sd s2,0(sp)
80003c7e: 1000 addi s0,sp,32
80003c80: 84aa mv s1,a0
acquire(&itable.lock);
80003c82: 0001d517 auipc a0,0x1d
80003c86: 94650513 addi a0,a0,-1722 # 800205c8 <itable>
80003c8a: ffffd097 auipc ra,0xffffd
80003c8e: f38080e7 jalr -200(ra) # 80000bc2 <acquire>
if(ip->ref == 1 && ip->valid && ip->nlink == 0){
80003c92: 4498 lw a4,8(s1)
80003c94: 4785 li a5,1
80003c96: 02f70363 beq a4,a5,80003cbc <iput+0x48>
ip->ref--;
80003c9a: 449c lw a5,8(s1)
80003c9c: 37fd addiw a5,a5,-1
80003c9e: c49c sw a5,8(s1)
release(&itable.lock);
80003ca0: 0001d517 auipc a0,0x1d
80003ca4: 92850513 addi a0,a0,-1752 # 800205c8 <itable>
80003ca8: ffffd097 auipc ra,0xffffd
80003cac: fce080e7 jalr -50(ra) # 80000c76 <release>
}
80003cb0: 60e2 ld ra,24(sp)
80003cb2: 6442 ld s0,16(sp)
80003cb4: 64a2 ld s1,8(sp)
80003cb6: 6902 ld s2,0(sp)
80003cb8: 6105 addi sp,sp,32
80003cba: 8082 ret
if(ip->ref == 1 && ip->valid && ip->nlink == 0){
80003cbc: 40bc lw a5,64(s1)
80003cbe: dff1 beqz a5,80003c9a <iput+0x26>
80003cc0: 04a49783 lh a5,74(s1)
80003cc4: fbf9 bnez a5,80003c9a <iput+0x26>
acquiresleep(&ip->lock);
80003cc6: 01048913 addi s2,s1,16
80003cca: 854a mv a0,s2
80003ccc: 00001097 auipc ra,0x1
80003cd0: abc080e7 jalr -1348(ra) # 80004788 <acquiresleep>
release(&itable.lock);
80003cd4: 0001d517 auipc a0,0x1d
80003cd8: 8f450513 addi a0,a0,-1804 # 800205c8 <itable>
80003cdc: ffffd097 auipc ra,0xffffd
80003ce0: f9a080e7 jalr -102(ra) # 80000c76 <release>
itrunc(ip);
80003ce4: 8526 mv a0,s1
80003ce6: 00000097 auipc ra,0x0
80003cea: ee2080e7 jalr -286(ra) # 80003bc8 <itrunc>
ip->type = 0;
80003cee: 04049223 sh zero,68(s1)
iupdate(ip);
80003cf2: 8526 mv a0,s1
80003cf4: 00000097 auipc ra,0x0
80003cf8: cfc080e7 jalr -772(ra) # 800039f0 <iupdate>
ip->valid = 0;
80003cfc: 0404a023 sw zero,64(s1)
releasesleep(&ip->lock);
80003d00: 854a mv a0,s2
80003d02: 00001097 auipc ra,0x1
80003d06: adc080e7 jalr -1316(ra) # 800047de <releasesleep>
acquire(&itable.lock);
80003d0a: 0001d517 auipc a0,0x1d
80003d0e: 8be50513 addi a0,a0,-1858 # 800205c8 <itable>
80003d12: ffffd097 auipc ra,0xffffd
80003d16: eb0080e7 jalr -336(ra) # 80000bc2 <acquire>
80003d1a: b741 j 80003c9a <iput+0x26>
0000000080003d1c <iunlockput>:
{
80003d1c: 1101 addi sp,sp,-32
80003d1e: ec06 sd ra,24(sp)
80003d20: e822 sd s0,16(sp)
80003d22: e426 sd s1,8(sp)
80003d24: 1000 addi s0,sp,32
80003d26: 84aa mv s1,a0
iunlock(ip);
80003d28: 00000097 auipc ra,0x0
80003d2c: e54080e7 jalr -428(ra) # 80003b7c <iunlock>
iput(ip);
80003d30: 8526 mv a0,s1
80003d32: 00000097 auipc ra,0x0
80003d36: f42080e7 jalr -190(ra) # 80003c74 <iput>
}
80003d3a: 60e2 ld ra,24(sp)
80003d3c: 6442 ld s0,16(sp)
80003d3e: 64a2 ld s1,8(sp)
80003d40: 6105 addi sp,sp,32
80003d42: 8082 ret
0000000080003d44 <stati>:
// Copy stat information from inode.
// Caller must hold ip->lock.
void
stati(struct inode *ip, struct stat *st)
{
80003d44: 1141 addi sp,sp,-16
80003d46: e422 sd s0,8(sp)
80003d48: 0800 addi s0,sp,16
st->dev = ip->dev;
80003d4a: 411c lw a5,0(a0)
80003d4c: c19c sw a5,0(a1)
st->ino = ip->inum;
80003d4e: 415c lw a5,4(a0)
80003d50: c1dc sw a5,4(a1)
st->type = ip->type;
80003d52: 04451783 lh a5,68(a0)
80003d56: 00f59423 sh a5,8(a1)
st->nlink = ip->nlink;
80003d5a: 04a51783 lh a5,74(a0)
80003d5e: 00f59523 sh a5,10(a1)
st->size = ip->size;
80003d62: 04c56783 lwu a5,76(a0)
80003d66: e99c sd a5,16(a1)
}
80003d68: 6422 ld s0,8(sp)
80003d6a: 0141 addi sp,sp,16
80003d6c: 8082 ret
0000000080003d6e <readi>:
readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
{
uint tot, m;
struct buf *bp;
if(off > ip->size || off + n < off)
80003d6e: 457c lw a5,76(a0)
80003d70: 0ed7e963 bltu a5,a3,80003e62 <readi+0xf4>
{
80003d74: 7159 addi sp,sp,-112
80003d76: f486 sd ra,104(sp)
80003d78: f0a2 sd s0,96(sp)
80003d7a: eca6 sd s1,88(sp)
80003d7c: e8ca sd s2,80(sp)
80003d7e: e4ce sd s3,72(sp)
80003d80: e0d2 sd s4,64(sp)
80003d82: fc56 sd s5,56(sp)
80003d84: f85a sd s6,48(sp)
80003d86: f45e sd s7,40(sp)
80003d88: f062 sd s8,32(sp)
80003d8a: ec66 sd s9,24(sp)
80003d8c: e86a sd s10,16(sp)
80003d8e: e46e sd s11,8(sp)
80003d90: 1880 addi s0,sp,112
80003d92: 8baa mv s7,a0
80003d94: 8c2e mv s8,a1
80003d96: 8ab2 mv s5,a2
80003d98: 84b6 mv s1,a3
80003d9a: 8b3a mv s6,a4
if(off > ip->size || off + n < off)
80003d9c: 9f35 addw a4,a4,a3
return 0;
80003d9e: 4501 li a0,0
if(off > ip->size || off + n < off)
80003da0: 0ad76063 bltu a4,a3,80003e40 <readi+0xd2>
if(off + n > ip->size)
80003da4: 00e7f463 bgeu a5,a4,80003dac <readi+0x3e>
n = ip->size - off;
80003da8: 40d78b3b subw s6,a5,a3
for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
80003dac: 0a0b0963 beqz s6,80003e5e <readi+0xf0>
80003db0: 4981 li s3,0
bp = bread(ip->dev, bmap(ip, off/BSIZE));
m = min(n - tot, BSIZE - off%BSIZE);
80003db2: 40000d13 li s10,1024
if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) {
80003db6: 5cfd li s9,-1
80003db8: a82d j 80003df2 <readi+0x84>
80003dba: 020a1d93 slli s11,s4,0x20
80003dbe: 020ddd93 srli s11,s11,0x20
80003dc2: 05890793 addi a5,s2,88
80003dc6: 86ee mv a3,s11
80003dc8: 963e add a2,a2,a5
80003dca: 85d6 mv a1,s5
80003dcc: 8562 mv a0,s8
80003dce: fffff097 auipc ra,0xfffff
80003dd2: 8d4080e7 jalr -1836(ra) # 800026a2 <either_copyout>
80003dd6: 05950d63 beq a0,s9,80003e30 <readi+0xc2>
brelse(bp);
tot = -1;
break;
}
brelse(bp);
80003dda: 854a mv a0,s2
80003ddc: fffff097 auipc ra,0xfffff
80003de0: 60a080e7 jalr 1546(ra) # 800033e6 <brelse>
for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
80003de4: 013a09bb addw s3,s4,s3
80003de8: 009a04bb addw s1,s4,s1
80003dec: 9aee add s5,s5,s11
80003dee: 0569f763 bgeu s3,s6,80003e3c <readi+0xce>
bp = bread(ip->dev, bmap(ip, off/BSIZE));
80003df2: 000ba903 lw s2,0(s7)
80003df6: 00a4d59b srliw a1,s1,0xa
80003dfa: 855e mv a0,s7
80003dfc: 00000097 auipc ra,0x0
80003e00: 8ae080e7 jalr -1874(ra) # 800036aa <bmap>
80003e04: 0005059b sext.w a1,a0
80003e08: 854a mv a0,s2
80003e0a: fffff097 auipc ra,0xfffff
80003e0e: 4ac080e7 jalr 1196(ra) # 800032b6 <bread>
80003e12: 892a mv s2,a0
m = min(n - tot, BSIZE - off%BSIZE);
80003e14: 3ff4f613 andi a2,s1,1023
80003e18: 40cd07bb subw a5,s10,a2
80003e1c: 413b073b subw a4,s6,s3
80003e20: 8a3e mv s4,a5
80003e22: 2781 sext.w a5,a5
80003e24: 0007069b sext.w a3,a4
80003e28: f8f6f9e3 bgeu a3,a5,80003dba <readi+0x4c>
80003e2c: 8a3a mv s4,a4
80003e2e: b771 j 80003dba <readi+0x4c>
brelse(bp);
80003e30: 854a mv a0,s2
80003e32: fffff097 auipc ra,0xfffff
80003e36: 5b4080e7 jalr 1460(ra) # 800033e6 <brelse>
tot = -1;
80003e3a: 59fd li s3,-1
}
return tot;
80003e3c: 0009851b sext.w a0,s3
}
80003e40: 70a6 ld ra,104(sp)
80003e42: 7406 ld s0,96(sp)
80003e44: 64e6 ld s1,88(sp)
80003e46: 6946 ld s2,80(sp)
80003e48: 69a6 ld s3,72(sp)
80003e4a: 6a06 ld s4,64(sp)
80003e4c: 7ae2 ld s5,56(sp)
80003e4e: 7b42 ld s6,48(sp)
80003e50: 7ba2 ld s7,40(sp)
80003e52: 7c02 ld s8,32(sp)
80003e54: 6ce2 ld s9,24(sp)
80003e56: 6d42 ld s10,16(sp)
80003e58: 6da2 ld s11,8(sp)
80003e5a: 6165 addi sp,sp,112
80003e5c: 8082 ret
for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
80003e5e: 89da mv s3,s6
80003e60: bff1 j 80003e3c <readi+0xce>
return 0;
80003e62: 4501 li a0,0
}
80003e64: 8082 ret
0000000080003e66 <writei>:
writei(struct inode *ip, int user_src, uint64 src, uint off, uint n)
{
uint tot, m;
struct buf *bp;
if(off > ip->size || off + n < off)
80003e66: 457c lw a5,76(a0)
80003e68: 10d7e863 bltu a5,a3,80003f78 <writei+0x112>
{
80003e6c: 7159 addi sp,sp,-112
80003e6e: f486 sd ra,104(sp)
80003e70: f0a2 sd s0,96(sp)
80003e72: eca6 sd s1,88(sp)
80003e74: e8ca sd s2,80(sp)
80003e76: e4ce sd s3,72(sp)
80003e78: e0d2 sd s4,64(sp)
80003e7a: fc56 sd s5,56(sp)
80003e7c: f85a sd s6,48(sp)
80003e7e: f45e sd s7,40(sp)
80003e80: f062 sd s8,32(sp)
80003e82: ec66 sd s9,24(sp)
80003e84: e86a sd s10,16(sp)
80003e86: e46e sd s11,8(sp)
80003e88: 1880 addi s0,sp,112
80003e8a: 8b2a mv s6,a0
80003e8c: 8c2e mv s8,a1
80003e8e: 8ab2 mv s5,a2
80003e90: 8936 mv s2,a3
80003e92: 8bba mv s7,a4
if(off > ip->size || off + n < off)
80003e94: 00e687bb addw a5,a3,a4
80003e98: 0ed7e263 bltu a5,a3,80003f7c <writei+0x116>
return -1;
if(off + n > MAXFILE*BSIZE)
80003e9c: 00043737 lui a4,0x43
80003ea0: 0ef76063 bltu a4,a5,80003f80 <writei+0x11a>
return -1;
for(tot=0; tot<n; tot+=m, off+=m, src+=m){
80003ea4: 0c0b8863 beqz s7,80003f74 <writei+0x10e>
80003ea8: 4a01 li s4,0
bp = bread(ip->dev, bmap(ip, off/BSIZE));
m = min(n - tot, BSIZE - off%BSIZE);
80003eaa: 40000d13 li s10,1024
if(either_copyin(bp->data + (off % BSIZE), user_src, src, m) == -1) {
80003eae: 5cfd li s9,-1
80003eb0: a091 j 80003ef4 <writei+0x8e>
80003eb2: 02099d93 slli s11,s3,0x20
80003eb6: 020ddd93 srli s11,s11,0x20
80003eba: 05848793 addi a5,s1,88
80003ebe: 86ee mv a3,s11
80003ec0: 8656 mv a2,s5
80003ec2: 85e2 mv a1,s8
80003ec4: 953e add a0,a0,a5
80003ec6: fffff097 auipc ra,0xfffff
80003eca: 832080e7 jalr -1998(ra) # 800026f8 <either_copyin>
80003ece: 07950263 beq a0,s9,80003f32 <writei+0xcc>
brelse(bp);
break;
}
log_write(bp);
80003ed2: 8526 mv a0,s1
80003ed4: 00000097 auipc ra,0x0
80003ed8: 794080e7 jalr 1940(ra) # 80004668 <log_write>
brelse(bp);
80003edc: 8526 mv a0,s1
80003ede: fffff097 auipc ra,0xfffff
80003ee2: 508080e7 jalr 1288(ra) # 800033e6 <brelse>
for(tot=0; tot<n; tot+=m, off+=m, src+=m){
80003ee6: 01498a3b addw s4,s3,s4
80003eea: 0129893b addw s2,s3,s2
80003eee: 9aee add s5,s5,s11
80003ef0: 057a7663 bgeu s4,s7,80003f3c <writei+0xd6>
bp = bread(ip->dev, bmap(ip, off/BSIZE));
80003ef4: 000b2483 lw s1,0(s6)
80003ef8: 00a9559b srliw a1,s2,0xa
80003efc: 855a mv a0,s6
80003efe: fffff097 auipc ra,0xfffff
80003f02: 7ac080e7 jalr 1964(ra) # 800036aa <bmap>
80003f06: 0005059b sext.w a1,a0
80003f0a: 8526 mv a0,s1
80003f0c: fffff097 auipc ra,0xfffff
80003f10: 3aa080e7 jalr 938(ra) # 800032b6 <bread>
80003f14: 84aa mv s1,a0
m = min(n - tot, BSIZE - off%BSIZE);
80003f16: 3ff97513 andi a0,s2,1023
80003f1a: 40ad07bb subw a5,s10,a0
80003f1e: 414b873b subw a4,s7,s4
80003f22: 89be mv s3,a5
80003f24: 2781 sext.w a5,a5
80003f26: 0007069b sext.w a3,a4
80003f2a: f8f6f4e3 bgeu a3,a5,80003eb2 <writei+0x4c>
80003f2e: 89ba mv s3,a4
80003f30: b749 j 80003eb2 <writei+0x4c>
brelse(bp);
80003f32: 8526 mv a0,s1
80003f34: fffff097 auipc ra,0xfffff
80003f38: 4b2080e7 jalr 1202(ra) # 800033e6 <brelse>
}
if(off > ip->size)
80003f3c: 04cb2783 lw a5,76(s6)
80003f40: 0127f463 bgeu a5,s2,80003f48 <writei+0xe2>
ip->size = off;
80003f44: 052b2623 sw s2,76(s6)
// write the i-node back to disk even if the size didn't change
// because the loop above might have called bmap() and added a new
// block to ip->addrs[].
iupdate(ip);
80003f48: 855a mv a0,s6
80003f4a: 00000097 auipc ra,0x0
80003f4e: aa6080e7 jalr -1370(ra) # 800039f0 <iupdate>
return tot;
80003f52: 000a051b sext.w a0,s4
}
80003f56: 70a6 ld ra,104(sp)
80003f58: 7406 ld s0,96(sp)
80003f5a: 64e6 ld s1,88(sp)
80003f5c: 6946 ld s2,80(sp)
80003f5e: 69a6 ld s3,72(sp)
80003f60: 6a06 ld s4,64(sp)
80003f62: 7ae2 ld s5,56(sp)
80003f64: 7b42 ld s6,48(sp)
80003f66: 7ba2 ld s7,40(sp)
80003f68: 7c02 ld s8,32(sp)
80003f6a: 6ce2 ld s9,24(sp)
80003f6c: 6d42 ld s10,16(sp)
80003f6e: 6da2 ld s11,8(sp)
80003f70: 6165 addi sp,sp,112
80003f72: 8082 ret
for(tot=0; tot<n; tot+=m, off+=m, src+=m){
80003f74: 8a5e mv s4,s7
80003f76: bfc9 j 80003f48 <writei+0xe2>
return -1;
80003f78: 557d li a0,-1
}
80003f7a: 8082 ret
return -1;
80003f7c: 557d li a0,-1
80003f7e: bfe1 j 80003f56 <writei+0xf0>
return -1;
80003f80: 557d li a0,-1
80003f82: bfd1 j 80003f56 <writei+0xf0>
0000000080003f84 <namecmp>:
// Directories
int
namecmp(const char *s, const char *t)
{
80003f84: 1141 addi sp,sp,-16
80003f86: e406 sd ra,8(sp)
80003f88: e022 sd s0,0(sp)
80003f8a: 0800 addi s0,sp,16
return strncmp(s, t, DIRSIZ);
80003f8c: 4639 li a2,14
80003f8e: ffffd097 auipc ra,0xffffd
80003f92: e08080e7 jalr -504(ra) # 80000d96 <strncmp>
}
80003f96: 60a2 ld ra,8(sp)
80003f98: 6402 ld s0,0(sp)
80003f9a: 0141 addi sp,sp,16
80003f9c: 8082 ret
0000000080003f9e <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)
{
80003f9e: 7139 addi sp,sp,-64
80003fa0: fc06 sd ra,56(sp)
80003fa2: f822 sd s0,48(sp)
80003fa4: f426 sd s1,40(sp)
80003fa6: f04a sd s2,32(sp)
80003fa8: ec4e sd s3,24(sp)
80003faa: e852 sd s4,16(sp)
80003fac: 0080 addi s0,sp,64
uint off, inum;
struct dirent de;
if(dp->type != T_DIR)
80003fae: 04451703 lh a4,68(a0)
80003fb2: 4785 li a5,1
80003fb4: 00f71a63 bne a4,a5,80003fc8 <dirlookup+0x2a>
80003fb8: 892a mv s2,a0
80003fba: 89ae mv s3,a1
80003fbc: 8a32 mv s4,a2
panic("dirlookup not DIR");
for(off = 0; off < dp->size; off += sizeof(de)){
80003fbe: 457c lw a5,76(a0)
80003fc0: 4481 li s1,0
inum = de.inum;
return iget(dp->dev, inum);
}
}
return 0;
80003fc2: 4501 li a0,0
for(off = 0; off < dp->size; off += sizeof(de)){
80003fc4: e79d bnez a5,80003ff2 <dirlookup+0x54>
80003fc6: a8a5 j 8000403e <dirlookup+0xa0>
panic("dirlookup not DIR");
80003fc8: 00004517 auipc a0,0x4
80003fcc: 74050513 addi a0,a0,1856 # 80008708 <syscalls+0x1b8>
80003fd0: ffffc097 auipc ra,0xffffc
80003fd4: 55a080e7 jalr 1370(ra) # 8000052a <panic>
panic("dirlookup read");
80003fd8: 00004517 auipc a0,0x4
80003fdc: 74850513 addi a0,a0,1864 # 80008720 <syscalls+0x1d0>
80003fe0: ffffc097 auipc ra,0xffffc
80003fe4: 54a080e7 jalr 1354(ra) # 8000052a <panic>
for(off = 0; off < dp->size; off += sizeof(de)){
80003fe8: 24c1 addiw s1,s1,16
80003fea: 04c92783 lw a5,76(s2)
80003fee: 04f4f763 bgeu s1,a5,8000403c <dirlookup+0x9e>
if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
80003ff2: 4741 li a4,16
80003ff4: 86a6 mv a3,s1
80003ff6: fc040613 addi a2,s0,-64
80003ffa: 4581 li a1,0
80003ffc: 854a mv a0,s2
80003ffe: 00000097 auipc ra,0x0
80004002: d70080e7 jalr -656(ra) # 80003d6e <readi>
80004006: 47c1 li a5,16
80004008: fcf518e3 bne a0,a5,80003fd8 <dirlookup+0x3a>
if(de.inum == 0)
8000400c: fc045783 lhu a5,-64(s0)
80004010: dfe1 beqz a5,80003fe8 <dirlookup+0x4a>
if(namecmp(name, de.name) == 0){
80004012: fc240593 addi a1,s0,-62
80004016: 854e mv a0,s3
80004018: 00000097 auipc ra,0x0
8000401c: f6c080e7 jalr -148(ra) # 80003f84 <namecmp>
80004020: f561 bnez a0,80003fe8 <dirlookup+0x4a>
if(poff)
80004022: 000a0463 beqz s4,8000402a <dirlookup+0x8c>
*poff = off;
80004026: 009a2023 sw s1,0(s4)
return iget(dp->dev, inum);
8000402a: fc045583 lhu a1,-64(s0)
8000402e: 00092503 lw a0,0(s2)
80004032: fffff097 auipc ra,0xfffff
80004036: 754080e7 jalr 1876(ra) # 80003786 <iget>
8000403a: a011 j 8000403e <dirlookup+0xa0>
return 0;
8000403c: 4501 li a0,0
}
8000403e: 70e2 ld ra,56(sp)
80004040: 7442 ld s0,48(sp)
80004042: 74a2 ld s1,40(sp)
80004044: 7902 ld s2,32(sp)
80004046: 69e2 ld s3,24(sp)
80004048: 6a42 ld s4,16(sp)
8000404a: 6121 addi sp,sp,64
8000404c: 8082 ret
000000008000404e <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)
{
8000404e: 711d addi sp,sp,-96
80004050: ec86 sd ra,88(sp)
80004052: e8a2 sd s0,80(sp)
80004054: e4a6 sd s1,72(sp)
80004056: e0ca sd s2,64(sp)
80004058: fc4e sd s3,56(sp)
8000405a: f852 sd s4,48(sp)
8000405c: f456 sd s5,40(sp)
8000405e: f05a sd s6,32(sp)
80004060: ec5e sd s7,24(sp)
80004062: e862 sd s8,16(sp)
80004064: e466 sd s9,8(sp)
80004066: 1080 addi s0,sp,96
80004068: 84aa mv s1,a0
8000406a: 8aae mv s5,a1
8000406c: 8a32 mv s4,a2
struct inode *ip, *next;
if(*path == '/')
8000406e: 00054703 lbu a4,0(a0)
80004072: 02f00793 li a5,47
80004076: 02f70363 beq a4,a5,8000409c <namex+0x4e>
ip = iget(ROOTDEV, ROOTINO);
else
ip = idup(myproc()->cwd);
8000407a: ffffe097 auipc ra,0xffffe
8000407e: 904080e7 jalr -1788(ra) # 8000197e <myproc>
80004082: 18853503 ld a0,392(a0)
80004086: 00000097 auipc ra,0x0
8000408a: 9f6080e7 jalr -1546(ra) # 80003a7c <idup>
8000408e: 89aa mv s3,a0
while(*path == '/')
80004090: 02f00913 li s2,47
len = path - s;
80004094: 4b01 li s6,0
if(len >= DIRSIZ)
80004096: 4c35 li s8,13
while((path = skipelem(path, name)) != 0){
ilock(ip);
if(ip->type != T_DIR){
80004098: 4b85 li s7,1
8000409a: a865 j 80004152 <namex+0x104>
ip = iget(ROOTDEV, ROOTINO);
8000409c: 4585 li a1,1
8000409e: 4505 li a0,1
800040a0: fffff097 auipc ra,0xfffff
800040a4: 6e6080e7 jalr 1766(ra) # 80003786 <iget>
800040a8: 89aa mv s3,a0
800040aa: b7dd j 80004090 <namex+0x42>
iunlockput(ip);
800040ac: 854e mv a0,s3
800040ae: 00000097 auipc ra,0x0
800040b2: c6e080e7 jalr -914(ra) # 80003d1c <iunlockput>
return 0;
800040b6: 4981 li s3,0
if(nameiparent){
iput(ip);
return 0;
}
return ip;
}
800040b8: 854e mv a0,s3
800040ba: 60e6 ld ra,88(sp)
800040bc: 6446 ld s0,80(sp)
800040be: 64a6 ld s1,72(sp)
800040c0: 6906 ld s2,64(sp)
800040c2: 79e2 ld s3,56(sp)
800040c4: 7a42 ld s4,48(sp)
800040c6: 7aa2 ld s5,40(sp)
800040c8: 7b02 ld s6,32(sp)
800040ca: 6be2 ld s7,24(sp)
800040cc: 6c42 ld s8,16(sp)
800040ce: 6ca2 ld s9,8(sp)
800040d0: 6125 addi sp,sp,96
800040d2: 8082 ret
iunlock(ip);
800040d4: 854e mv a0,s3
800040d6: 00000097 auipc ra,0x0
800040da: aa6080e7 jalr -1370(ra) # 80003b7c <iunlock>
return ip;
800040de: bfe9 j 800040b8 <namex+0x6a>
iunlockput(ip);
800040e0: 854e mv a0,s3
800040e2: 00000097 auipc ra,0x0
800040e6: c3a080e7 jalr -966(ra) # 80003d1c <iunlockput>
return 0;
800040ea: 89e6 mv s3,s9
800040ec: b7f1 j 800040b8 <namex+0x6a>
len = path - s;
800040ee: 40b48633 sub a2,s1,a1
800040f2: 00060c9b sext.w s9,a2
if(len >= DIRSIZ)
800040f6: 099c5463 bge s8,s9,8000417e <namex+0x130>
memmove(name, s, DIRSIZ);
800040fa: 4639 li a2,14
800040fc: 8552 mv a0,s4
800040fe: ffffd097 auipc ra,0xffffd
80004102: c1c080e7 jalr -996(ra) # 80000d1a <memmove>
while(*path == '/')
80004106: 0004c783 lbu a5,0(s1)
8000410a: 01279763 bne a5,s2,80004118 <namex+0xca>
path++;
8000410e: 0485 addi s1,s1,1
while(*path == '/')
80004110: 0004c783 lbu a5,0(s1)
80004114: ff278de3 beq a5,s2,8000410e <namex+0xc0>
ilock(ip);
80004118: 854e mv a0,s3
8000411a: 00000097 auipc ra,0x0
8000411e: 9a0080e7 jalr -1632(ra) # 80003aba <ilock>
if(ip->type != T_DIR){
80004122: 04499783 lh a5,68(s3)
80004126: f97793e3 bne a5,s7,800040ac <namex+0x5e>
if(nameiparent && *path == '\0'){
8000412a: 000a8563 beqz s5,80004134 <namex+0xe6>
8000412e: 0004c783 lbu a5,0(s1)
80004132: d3cd beqz a5,800040d4 <namex+0x86>
if((next = dirlookup(ip, name, 0)) == 0){
80004134: 865a mv a2,s6
80004136: 85d2 mv a1,s4
80004138: 854e mv a0,s3
8000413a: 00000097 auipc ra,0x0
8000413e: e64080e7 jalr -412(ra) # 80003f9e <dirlookup>
80004142: 8caa mv s9,a0
80004144: dd51 beqz a0,800040e0 <namex+0x92>
iunlockput(ip);
80004146: 854e mv a0,s3
80004148: 00000097 auipc ra,0x0
8000414c: bd4080e7 jalr -1068(ra) # 80003d1c <iunlockput>
ip = next;
80004150: 89e6 mv s3,s9
while(*path == '/')
80004152: 0004c783 lbu a5,0(s1)
80004156: 05279763 bne a5,s2,800041a4 <namex+0x156>
path++;
8000415a: 0485 addi s1,s1,1
while(*path == '/')
8000415c: 0004c783 lbu a5,0(s1)
80004160: ff278de3 beq a5,s2,8000415a <namex+0x10c>
if(*path == 0)
80004164: c79d beqz a5,80004192 <namex+0x144>
path++;
80004166: 85a6 mv a1,s1
len = path - s;
80004168: 8cda mv s9,s6
8000416a: 865a mv a2,s6
while(*path != '/' && *path != 0)
8000416c: 01278963 beq a5,s2,8000417e <namex+0x130>
80004170: dfbd beqz a5,800040ee <namex+0xa0>
path++;
80004172: 0485 addi s1,s1,1
while(*path != '/' && *path != 0)
80004174: 0004c783 lbu a5,0(s1)
80004178: ff279ce3 bne a5,s2,80004170 <namex+0x122>
8000417c: bf8d j 800040ee <namex+0xa0>
memmove(name, s, len);
8000417e: 2601 sext.w a2,a2
80004180: 8552 mv a0,s4
80004182: ffffd097 auipc ra,0xffffd
80004186: b98080e7 jalr -1128(ra) # 80000d1a <memmove>
name[len] = 0;
8000418a: 9cd2 add s9,s9,s4
8000418c: 000c8023 sb zero,0(s9) # 2000 <_entry-0x7fffe000>
80004190: bf9d j 80004106 <namex+0xb8>
if(nameiparent){
80004192: f20a83e3 beqz s5,800040b8 <namex+0x6a>
iput(ip);
80004196: 854e mv a0,s3
80004198: 00000097 auipc ra,0x0
8000419c: adc080e7 jalr -1316(ra) # 80003c74 <iput>
return 0;
800041a0: 4981 li s3,0
800041a2: bf19 j 800040b8 <namex+0x6a>
if(*path == 0)
800041a4: d7fd beqz a5,80004192 <namex+0x144>
while(*path != '/' && *path != 0)
800041a6: 0004c783 lbu a5,0(s1)
800041aa: 85a6 mv a1,s1
800041ac: b7d1 j 80004170 <namex+0x122>
00000000800041ae <dirlink>:
{
800041ae: 7139 addi sp,sp,-64
800041b0: fc06 sd ra,56(sp)
800041b2: f822 sd s0,48(sp)
800041b4: f426 sd s1,40(sp)
800041b6: f04a sd s2,32(sp)
800041b8: ec4e sd s3,24(sp)
800041ba: e852 sd s4,16(sp)
800041bc: 0080 addi s0,sp,64
800041be: 892a mv s2,a0
800041c0: 8a2e mv s4,a1
800041c2: 89b2 mv s3,a2
if((ip = dirlookup(dp, name, 0)) != 0){
800041c4: 4601 li a2,0
800041c6: 00000097 auipc ra,0x0
800041ca: dd8080e7 jalr -552(ra) # 80003f9e <dirlookup>
800041ce: e93d bnez a0,80004244 <dirlink+0x96>
for(off = 0; off < dp->size; off += sizeof(de)){
800041d0: 04c92483 lw s1,76(s2)
800041d4: c49d beqz s1,80004202 <dirlink+0x54>
800041d6: 4481 li s1,0
if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
800041d8: 4741 li a4,16
800041da: 86a6 mv a3,s1
800041dc: fc040613 addi a2,s0,-64
800041e0: 4581 li a1,0
800041e2: 854a mv a0,s2
800041e4: 00000097 auipc ra,0x0
800041e8: b8a080e7 jalr -1142(ra) # 80003d6e <readi>
800041ec: 47c1 li a5,16
800041ee: 06f51163 bne a0,a5,80004250 <dirlink+0xa2>
if(de.inum == 0)
800041f2: fc045783 lhu a5,-64(s0)
800041f6: c791 beqz a5,80004202 <dirlink+0x54>
for(off = 0; off < dp->size; off += sizeof(de)){
800041f8: 24c1 addiw s1,s1,16
800041fa: 04c92783 lw a5,76(s2)
800041fe: fcf4ede3 bltu s1,a5,800041d8 <dirlink+0x2a>
strncpy(de.name, name, DIRSIZ);
80004202: 4639 li a2,14
80004204: 85d2 mv a1,s4
80004206: fc240513 addi a0,s0,-62
8000420a: ffffd097 auipc ra,0xffffd
8000420e: bc8080e7 jalr -1080(ra) # 80000dd2 <strncpy>
de.inum = inum;
80004212: fd341023 sh s3,-64(s0)
if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
80004216: 4741 li a4,16
80004218: 86a6 mv a3,s1
8000421a: fc040613 addi a2,s0,-64
8000421e: 4581 li a1,0
80004220: 854a mv a0,s2
80004222: 00000097 auipc ra,0x0
80004226: c44080e7 jalr -956(ra) # 80003e66 <writei>
8000422a: 872a mv a4,a0
8000422c: 47c1 li a5,16
return 0;
8000422e: 4501 li a0,0
if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
80004230: 02f71863 bne a4,a5,80004260 <dirlink+0xb2>
}
80004234: 70e2 ld ra,56(sp)
80004236: 7442 ld s0,48(sp)
80004238: 74a2 ld s1,40(sp)
8000423a: 7902 ld s2,32(sp)
8000423c: 69e2 ld s3,24(sp)
8000423e: 6a42 ld s4,16(sp)
80004240: 6121 addi sp,sp,64
80004242: 8082 ret
iput(ip);
80004244: 00000097 auipc ra,0x0
80004248: a30080e7 jalr -1488(ra) # 80003c74 <iput>
return -1;
8000424c: 557d li a0,-1
8000424e: b7dd j 80004234 <dirlink+0x86>
panic("dirlink read");
80004250: 00004517 auipc a0,0x4
80004254: 4e050513 addi a0,a0,1248 # 80008730 <syscalls+0x1e0>
80004258: ffffc097 auipc ra,0xffffc
8000425c: 2d2080e7 jalr 722(ra) # 8000052a <panic>
panic("dirlink");
80004260: 00004517 auipc a0,0x4
80004264: 5d850513 addi a0,a0,1496 # 80008838 <syscalls+0x2e8>
80004268: ffffc097 auipc ra,0xffffc
8000426c: 2c2080e7 jalr 706(ra) # 8000052a <panic>
0000000080004270 <namei>:
struct inode*
namei(char *path)
{
80004270: 1101 addi sp,sp,-32
80004272: ec06 sd ra,24(sp)
80004274: e822 sd s0,16(sp)
80004276: 1000 addi s0,sp,32
char name[DIRSIZ];
return namex(path, 0, name);
80004278: fe040613 addi a2,s0,-32
8000427c: 4581 li a1,0
8000427e: 00000097 auipc ra,0x0
80004282: dd0080e7 jalr -560(ra) # 8000404e <namex>
}
80004286: 60e2 ld ra,24(sp)
80004288: 6442 ld s0,16(sp)
8000428a: 6105 addi sp,sp,32
8000428c: 8082 ret
000000008000428e <nameiparent>:
struct inode*
nameiparent(char *path, char *name)
{
8000428e: 1141 addi sp,sp,-16
80004290: e406 sd ra,8(sp)
80004292: e022 sd s0,0(sp)
80004294: 0800 addi s0,sp,16
80004296: 862e mv a2,a1
return namex(path, 1, name);
80004298: 4585 li a1,1
8000429a: 00000097 auipc ra,0x0
8000429e: db4080e7 jalr -588(ra) # 8000404e <namex>
}
800042a2: 60a2 ld ra,8(sp)
800042a4: 6402 ld s0,0(sp)
800042a6: 0141 addi sp,sp,16
800042a8: 8082 ret
00000000800042aa <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)
{
800042aa: 1101 addi sp,sp,-32
800042ac: ec06 sd ra,24(sp)
800042ae: e822 sd s0,16(sp)
800042b0: e426 sd s1,8(sp)
800042b2: e04a sd s2,0(sp)
800042b4: 1000 addi s0,sp,32
struct buf *buf = bread(log.dev, log.start);
800042b6: 0001e917 auipc s2,0x1e
800042ba: dba90913 addi s2,s2,-582 # 80022070 <log>
800042be: 01892583 lw a1,24(s2)
800042c2: 02892503 lw a0,40(s2)
800042c6: fffff097 auipc ra,0xfffff
800042ca: ff0080e7 jalr -16(ra) # 800032b6 <bread>
800042ce: 84aa mv s1,a0
struct logheader *hb = (struct logheader *) (buf->data);
int i;
hb->n = log.lh.n;
800042d0: 02c92683 lw a3,44(s2)
800042d4: cd34 sw a3,88(a0)
for (i = 0; i < log.lh.n; i++) {
800042d6: 02d05863 blez a3,80004306 <write_head+0x5c>
800042da: 0001e797 auipc a5,0x1e
800042de: dc678793 addi a5,a5,-570 # 800220a0 <log+0x30>
800042e2: 05c50713 addi a4,a0,92
800042e6: 36fd addiw a3,a3,-1
800042e8: 02069613 slli a2,a3,0x20
800042ec: 01e65693 srli a3,a2,0x1e
800042f0: 0001e617 auipc a2,0x1e
800042f4: db460613 addi a2,a2,-588 # 800220a4 <log+0x34>
800042f8: 96b2 add a3,a3,a2
hb->block[i] = log.lh.block[i];
800042fa: 4390 lw a2,0(a5)
800042fc: c310 sw a2,0(a4)
for (i = 0; i < log.lh.n; i++) {
800042fe: 0791 addi a5,a5,4
80004300: 0711 addi a4,a4,4
80004302: fed79ce3 bne a5,a3,800042fa <write_head+0x50>
}
bwrite(buf);
80004306: 8526 mv a0,s1
80004308: fffff097 auipc ra,0xfffff
8000430c: 0a0080e7 jalr 160(ra) # 800033a8 <bwrite>
brelse(buf);
80004310: 8526 mv a0,s1
80004312: fffff097 auipc ra,0xfffff
80004316: 0d4080e7 jalr 212(ra) # 800033e6 <brelse>
}
8000431a: 60e2 ld ra,24(sp)
8000431c: 6442 ld s0,16(sp)
8000431e: 64a2 ld s1,8(sp)
80004320: 6902 ld s2,0(sp)
80004322: 6105 addi sp,sp,32
80004324: 8082 ret
0000000080004326 <install_trans>:
for (tail = 0; tail < log.lh.n; tail++) {
80004326: 0001e797 auipc a5,0x1e
8000432a: d767a783 lw a5,-650(a5) # 8002209c <log+0x2c>
8000432e: 0af05d63 blez a5,800043e8 <install_trans+0xc2>
{
80004332: 7139 addi sp,sp,-64
80004334: fc06 sd ra,56(sp)
80004336: f822 sd s0,48(sp)
80004338: f426 sd s1,40(sp)
8000433a: f04a sd s2,32(sp)
8000433c: ec4e sd s3,24(sp)
8000433e: e852 sd s4,16(sp)
80004340: e456 sd s5,8(sp)
80004342: e05a sd s6,0(sp)
80004344: 0080 addi s0,sp,64
80004346: 8b2a mv s6,a0
80004348: 0001ea97 auipc s5,0x1e
8000434c: d58a8a93 addi s5,s5,-680 # 800220a0 <log+0x30>
for (tail = 0; tail < log.lh.n; tail++) {
80004350: 4a01 li s4,0
struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
80004352: 0001e997 auipc s3,0x1e
80004356: d1e98993 addi s3,s3,-738 # 80022070 <log>
8000435a: a00d j 8000437c <install_trans+0x56>
brelse(lbuf);
8000435c: 854a mv a0,s2
8000435e: fffff097 auipc ra,0xfffff
80004362: 088080e7 jalr 136(ra) # 800033e6 <brelse>
brelse(dbuf);
80004366: 8526 mv a0,s1
80004368: fffff097 auipc ra,0xfffff
8000436c: 07e080e7 jalr 126(ra) # 800033e6 <brelse>
for (tail = 0; tail < log.lh.n; tail++) {
80004370: 2a05 addiw s4,s4,1
80004372: 0a91 addi s5,s5,4
80004374: 02c9a783 lw a5,44(s3)
80004378: 04fa5e63 bge s4,a5,800043d4 <install_trans+0xae>
struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
8000437c: 0189a583 lw a1,24(s3)
80004380: 014585bb addw a1,a1,s4
80004384: 2585 addiw a1,a1,1
80004386: 0289a503 lw a0,40(s3)
8000438a: fffff097 auipc ra,0xfffff
8000438e: f2c080e7 jalr -212(ra) # 800032b6 <bread>
80004392: 892a mv s2,a0
struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
80004394: 000aa583 lw a1,0(s5)
80004398: 0289a503 lw a0,40(s3)
8000439c: fffff097 auipc ra,0xfffff
800043a0: f1a080e7 jalr -230(ra) # 800032b6 <bread>
800043a4: 84aa mv s1,a0
memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst
800043a6: 40000613 li a2,1024
800043aa: 05890593 addi a1,s2,88
800043ae: 05850513 addi a0,a0,88
800043b2: ffffd097 auipc ra,0xffffd
800043b6: 968080e7 jalr -1688(ra) # 80000d1a <memmove>
bwrite(dbuf); // write dst to disk
800043ba: 8526 mv a0,s1
800043bc: fffff097 auipc ra,0xfffff
800043c0: fec080e7 jalr -20(ra) # 800033a8 <bwrite>
if(recovering == 0)
800043c4: f80b1ce3 bnez s6,8000435c <install_trans+0x36>
bunpin(dbuf);
800043c8: 8526 mv a0,s1
800043ca: fffff097 auipc ra,0xfffff
800043ce: 0f6080e7 jalr 246(ra) # 800034c0 <bunpin>
800043d2: b769 j 8000435c <install_trans+0x36>
}
800043d4: 70e2 ld ra,56(sp)
800043d6: 7442 ld s0,48(sp)
800043d8: 74a2 ld s1,40(sp)
800043da: 7902 ld s2,32(sp)
800043dc: 69e2 ld s3,24(sp)
800043de: 6a42 ld s4,16(sp)
800043e0: 6aa2 ld s5,8(sp)
800043e2: 6b02 ld s6,0(sp)
800043e4: 6121 addi sp,sp,64
800043e6: 8082 ret
800043e8: 8082 ret
00000000800043ea <initlog>:
{
800043ea: 7179 addi sp,sp,-48
800043ec: f406 sd ra,40(sp)
800043ee: f022 sd s0,32(sp)
800043f0: ec26 sd s1,24(sp)
800043f2: e84a sd s2,16(sp)
800043f4: e44e sd s3,8(sp)
800043f6: 1800 addi s0,sp,48
800043f8: 892a mv s2,a0
800043fa: 89ae mv s3,a1
initlock(&log.lock, "log");
800043fc: 0001e497 auipc s1,0x1e
80004400: c7448493 addi s1,s1,-908 # 80022070 <log>
80004404: 00004597 auipc a1,0x4
80004408: 33c58593 addi a1,a1,828 # 80008740 <syscalls+0x1f0>
8000440c: 8526 mv a0,s1
8000440e: ffffc097 auipc ra,0xffffc
80004412: 724080e7 jalr 1828(ra) # 80000b32 <initlock>
log.start = sb->logstart;
80004416: 0149a583 lw a1,20(s3)
8000441a: cc8c sw a1,24(s1)
log.size = sb->nlog;
8000441c: 0109a783 lw a5,16(s3)
80004420: ccdc sw a5,28(s1)
log.dev = dev;
80004422: 0324a423 sw s2,40(s1)
struct buf *buf = bread(log.dev, log.start);
80004426: 854a mv a0,s2
80004428: fffff097 auipc ra,0xfffff
8000442c: e8e080e7 jalr -370(ra) # 800032b6 <bread>
log.lh.n = lh->n;
80004430: 4d34 lw a3,88(a0)
80004432: d4d4 sw a3,44(s1)
for (i = 0; i < log.lh.n; i++) {
80004434: 02d05663 blez a3,80004460 <initlog+0x76>
80004438: 05c50793 addi a5,a0,92
8000443c: 0001e717 auipc a4,0x1e
80004440: c6470713 addi a4,a4,-924 # 800220a0 <log+0x30>
80004444: 36fd addiw a3,a3,-1
80004446: 02069613 slli a2,a3,0x20
8000444a: 01e65693 srli a3,a2,0x1e
8000444e: 06050613 addi a2,a0,96
80004452: 96b2 add a3,a3,a2
log.lh.block[i] = lh->block[i];
80004454: 4390 lw a2,0(a5)
80004456: c310 sw a2,0(a4)
for (i = 0; i < log.lh.n; i++) {
80004458: 0791 addi a5,a5,4
8000445a: 0711 addi a4,a4,4
8000445c: fed79ce3 bne a5,a3,80004454 <initlog+0x6a>
brelse(buf);
80004460: fffff097 auipc ra,0xfffff
80004464: f86080e7 jalr -122(ra) # 800033e6 <brelse>
static void
recover_from_log(void)
{
read_head();
install_trans(1); // if committed, copy from log to disk
80004468: 4505 li a0,1
8000446a: 00000097 auipc ra,0x0
8000446e: ebc080e7 jalr -324(ra) # 80004326 <install_trans>
log.lh.n = 0;
80004472: 0001e797 auipc a5,0x1e
80004476: c207a523 sw zero,-982(a5) # 8002209c <log+0x2c>
write_head(); // clear the log
8000447a: 00000097 auipc ra,0x0
8000447e: e30080e7 jalr -464(ra) # 800042aa <write_head>
}
80004482: 70a2 ld ra,40(sp)
80004484: 7402 ld s0,32(sp)
80004486: 64e2 ld s1,24(sp)
80004488: 6942 ld s2,16(sp)
8000448a: 69a2 ld s3,8(sp)
8000448c: 6145 addi sp,sp,48
8000448e: 8082 ret
0000000080004490 <begin_op>:
}
// called at the start of each FS system call.
void
begin_op(void)
{
80004490: 1101 addi sp,sp,-32
80004492: ec06 sd ra,24(sp)
80004494: e822 sd s0,16(sp)
80004496: e426 sd s1,8(sp)
80004498: e04a sd s2,0(sp)
8000449a: 1000 addi s0,sp,32
acquire(&log.lock);
8000449c: 0001e517 auipc a0,0x1e
800044a0: bd450513 addi a0,a0,-1068 # 80022070 <log>
800044a4: ffffc097 auipc ra,0xffffc
800044a8: 71e080e7 jalr 1822(ra) # 80000bc2 <acquire>
while(1){
if(log.committing){
800044ac: 0001e497 auipc s1,0x1e
800044b0: bc448493 addi s1,s1,-1084 # 80022070 <log>
sleep(&log, &log.lock);
} else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
800044b4: 4979 li s2,30
800044b6: a039 j 800044c4 <begin_op+0x34>
sleep(&log, &log.lock);
800044b8: 85a6 mv a1,s1
800044ba: 8526 mv a0,s1
800044bc: ffffe097 auipc ra,0xffffe
800044c0: c38080e7 jalr -968(ra) # 800020f4 <sleep>
if(log.committing){
800044c4: 50dc lw a5,36(s1)
800044c6: fbed bnez a5,800044b8 <begin_op+0x28>
} else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
800044c8: 509c lw a5,32(s1)
800044ca: 0017871b addiw a4,a5,1
800044ce: 0007069b sext.w a3,a4
800044d2: 0027179b slliw a5,a4,0x2
800044d6: 9fb9 addw a5,a5,a4
800044d8: 0017979b slliw a5,a5,0x1
800044dc: 54d8 lw a4,44(s1)
800044de: 9fb9 addw a5,a5,a4
800044e0: 00f95963 bge s2,a5,800044f2 <begin_op+0x62>
// this op might exhaust log space; wait for commit.
sleep(&log, &log.lock);
800044e4: 85a6 mv a1,s1
800044e6: 8526 mv a0,s1
800044e8: ffffe097 auipc ra,0xffffe
800044ec: c0c080e7 jalr -1012(ra) # 800020f4 <sleep>
800044f0: bfd1 j 800044c4 <begin_op+0x34>
} else {
log.outstanding += 1;
800044f2: 0001e517 auipc a0,0x1e
800044f6: b7e50513 addi a0,a0,-1154 # 80022070 <log>
800044fa: d114 sw a3,32(a0)
release(&log.lock);
800044fc: ffffc097 auipc ra,0xffffc
80004500: 77a080e7 jalr 1914(ra) # 80000c76 <release>
break;
}
}
}
80004504: 60e2 ld ra,24(sp)
80004506: 6442 ld s0,16(sp)
80004508: 64a2 ld s1,8(sp)
8000450a: 6902 ld s2,0(sp)
8000450c: 6105 addi sp,sp,32
8000450e: 8082 ret
0000000080004510 <end_op>:
// called at the end of each FS system call.
// commits if this was the last outstanding operation.
void
end_op(void)
{
80004510: 7139 addi sp,sp,-64
80004512: fc06 sd ra,56(sp)
80004514: f822 sd s0,48(sp)
80004516: f426 sd s1,40(sp)
80004518: f04a sd s2,32(sp)
8000451a: ec4e sd s3,24(sp)
8000451c: e852 sd s4,16(sp)
8000451e: e456 sd s5,8(sp)
80004520: 0080 addi s0,sp,64
int do_commit = 0;
acquire(&log.lock);
80004522: 0001e497 auipc s1,0x1e
80004526: b4e48493 addi s1,s1,-1202 # 80022070 <log>
8000452a: 8526 mv a0,s1
8000452c: ffffc097 auipc ra,0xffffc
80004530: 696080e7 jalr 1686(ra) # 80000bc2 <acquire>
log.outstanding -= 1;
80004534: 509c lw a5,32(s1)
80004536: 37fd addiw a5,a5,-1
80004538: 0007891b sext.w s2,a5
8000453c: d09c sw a5,32(s1)
if(log.committing)
8000453e: 50dc lw a5,36(s1)
80004540: e7b9 bnez a5,8000458e <end_op+0x7e>
panic("log.committing");
if(log.outstanding == 0){
80004542: 04091e63 bnez s2,8000459e <end_op+0x8e>
do_commit = 1;
log.committing = 1;
80004546: 0001e497 auipc s1,0x1e
8000454a: b2a48493 addi s1,s1,-1238 # 80022070 <log>
8000454e: 4785 li a5,1
80004550: d0dc sw a5,36(s1)
// begin_op() may be waiting for log space,
// and decrementing log.outstanding has decreased
// the amount of reserved space.
wakeup(&log);
}
release(&log.lock);
80004552: 8526 mv a0,s1
80004554: ffffc097 auipc ra,0xffffc
80004558: 722080e7 jalr 1826(ra) # 80000c76 <release>
}
static void
commit()
{
if (log.lh.n > 0) {
8000455c: 54dc lw a5,44(s1)
8000455e: 06f04763 bgtz a5,800045cc <end_op+0xbc>
acquire(&log.lock);
80004562: 0001e497 auipc s1,0x1e
80004566: b0e48493 addi s1,s1,-1266 # 80022070 <log>
8000456a: 8526 mv a0,s1
8000456c: ffffc097 auipc ra,0xffffc
80004570: 656080e7 jalr 1622(ra) # 80000bc2 <acquire>
log.committing = 0;
80004574: 0204a223 sw zero,36(s1)
wakeup(&log);
80004578: 8526 mv a0,s1
8000457a: ffffe097 auipc ra,0xffffe
8000457e: dee080e7 jalr -530(ra) # 80002368 <wakeup>
release(&log.lock);
80004582: 8526 mv a0,s1
80004584: ffffc097 auipc ra,0xffffc
80004588: 6f2080e7 jalr 1778(ra) # 80000c76 <release>
}
8000458c: a03d j 800045ba <end_op+0xaa>
panic("log.committing");
8000458e: 00004517 auipc a0,0x4
80004592: 1ba50513 addi a0,a0,442 # 80008748 <syscalls+0x1f8>
80004596: ffffc097 auipc ra,0xffffc
8000459a: f94080e7 jalr -108(ra) # 8000052a <panic>
wakeup(&log);
8000459e: 0001e497 auipc s1,0x1e
800045a2: ad248493 addi s1,s1,-1326 # 80022070 <log>
800045a6: 8526 mv a0,s1
800045a8: ffffe097 auipc ra,0xffffe
800045ac: dc0080e7 jalr -576(ra) # 80002368 <wakeup>
release(&log.lock);
800045b0: 8526 mv a0,s1
800045b2: ffffc097 auipc ra,0xffffc
800045b6: 6c4080e7 jalr 1732(ra) # 80000c76 <release>
}
800045ba: 70e2 ld ra,56(sp)
800045bc: 7442 ld s0,48(sp)
800045be: 74a2 ld s1,40(sp)
800045c0: 7902 ld s2,32(sp)
800045c2: 69e2 ld s3,24(sp)
800045c4: 6a42 ld s4,16(sp)
800045c6: 6aa2 ld s5,8(sp)
800045c8: 6121 addi sp,sp,64
800045ca: 8082 ret
for (tail = 0; tail < log.lh.n; tail++) {
800045cc: 0001ea97 auipc s5,0x1e
800045d0: ad4a8a93 addi s5,s5,-1324 # 800220a0 <log+0x30>
struct buf *to = bread(log.dev, log.start+tail+1); // log block
800045d4: 0001ea17 auipc s4,0x1e
800045d8: a9ca0a13 addi s4,s4,-1380 # 80022070 <log>
800045dc: 018a2583 lw a1,24(s4)
800045e0: 012585bb addw a1,a1,s2
800045e4: 2585 addiw a1,a1,1
800045e6: 028a2503 lw a0,40(s4)
800045ea: fffff097 auipc ra,0xfffff
800045ee: ccc080e7 jalr -820(ra) # 800032b6 <bread>
800045f2: 84aa mv s1,a0
struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block
800045f4: 000aa583 lw a1,0(s5)
800045f8: 028a2503 lw a0,40(s4)
800045fc: fffff097 auipc ra,0xfffff
80004600: cba080e7 jalr -838(ra) # 800032b6 <bread>
80004604: 89aa mv s3,a0
memmove(to->data, from->data, BSIZE);
80004606: 40000613 li a2,1024
8000460a: 05850593 addi a1,a0,88
8000460e: 05848513 addi a0,s1,88
80004612: ffffc097 auipc ra,0xffffc
80004616: 708080e7 jalr 1800(ra) # 80000d1a <memmove>
bwrite(to); // write the log
8000461a: 8526 mv a0,s1
8000461c: fffff097 auipc ra,0xfffff
80004620: d8c080e7 jalr -628(ra) # 800033a8 <bwrite>
brelse(from);
80004624: 854e mv a0,s3
80004626: fffff097 auipc ra,0xfffff
8000462a: dc0080e7 jalr -576(ra) # 800033e6 <brelse>
brelse(to);
8000462e: 8526 mv a0,s1
80004630: fffff097 auipc ra,0xfffff
80004634: db6080e7 jalr -586(ra) # 800033e6 <brelse>
for (tail = 0; tail < log.lh.n; tail++) {
80004638: 2905 addiw s2,s2,1
8000463a: 0a91 addi s5,s5,4
8000463c: 02ca2783 lw a5,44(s4)
80004640: f8f94ee3 blt s2,a5,800045dc <end_op+0xcc>
write_log(); // Write modified blocks from cache to log
write_head(); // Write header to disk -- the real commit
80004644: 00000097 auipc ra,0x0
80004648: c66080e7 jalr -922(ra) # 800042aa <write_head>
install_trans(0); // Now install writes to home locations
8000464c: 4501 li a0,0
8000464e: 00000097 auipc ra,0x0
80004652: cd8080e7 jalr -808(ra) # 80004326 <install_trans>
log.lh.n = 0;
80004656: 0001e797 auipc a5,0x1e
8000465a: a407a323 sw zero,-1466(a5) # 8002209c <log+0x2c>
write_head(); // Erase the transaction from the log
8000465e: 00000097 auipc ra,0x0
80004662: c4c080e7 jalr -948(ra) # 800042aa <write_head>
80004666: bdf5 j 80004562 <end_op+0x52>
0000000080004668 <log_write>:
// modify bp->data[]
// log_write(bp)
// brelse(bp)
void
log_write(struct buf *b)
{
80004668: 1101 addi sp,sp,-32
8000466a: ec06 sd ra,24(sp)
8000466c: e822 sd s0,16(sp)
8000466e: e426 sd s1,8(sp)
80004670: e04a sd s2,0(sp)
80004672: 1000 addi s0,sp,32
80004674: 84aa mv s1,a0
int i;
acquire(&log.lock);
80004676: 0001e917 auipc s2,0x1e
8000467a: 9fa90913 addi s2,s2,-1542 # 80022070 <log>
8000467e: 854a mv a0,s2
80004680: ffffc097 auipc ra,0xffffc
80004684: 542080e7 jalr 1346(ra) # 80000bc2 <acquire>
if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1)
80004688: 02c92603 lw a2,44(s2)
8000468c: 47f5 li a5,29
8000468e: 06c7c563 blt a5,a2,800046f8 <log_write+0x90>
80004692: 0001e797 auipc a5,0x1e
80004696: 9fa7a783 lw a5,-1542(a5) # 8002208c <log+0x1c>
8000469a: 37fd addiw a5,a5,-1
8000469c: 04f65e63 bge a2,a5,800046f8 <log_write+0x90>
panic("too big a transaction");
if (log.outstanding < 1)
800046a0: 0001e797 auipc a5,0x1e
800046a4: 9f07a783 lw a5,-1552(a5) # 80022090 <log+0x20>
800046a8: 06f05063 blez a5,80004708 <log_write+0xa0>
panic("log_write outside of trans");
for (i = 0; i < log.lh.n; i++) {
800046ac: 4781 li a5,0
800046ae: 06c05563 blez a2,80004718 <log_write+0xb0>
if (log.lh.block[i] == b->blockno) // log absorbtion
800046b2: 44cc lw a1,12(s1)
800046b4: 0001e717 auipc a4,0x1e
800046b8: 9ec70713 addi a4,a4,-1556 # 800220a0 <log+0x30>
for (i = 0; i < log.lh.n; i++) {
800046bc: 4781 li a5,0
if (log.lh.block[i] == b->blockno) // log absorbtion
800046be: 4314 lw a3,0(a4)
800046c0: 04b68c63 beq a3,a1,80004718 <log_write+0xb0>
for (i = 0; i < log.lh.n; i++) {
800046c4: 2785 addiw a5,a5,1
800046c6: 0711 addi a4,a4,4
800046c8: fef61be3 bne a2,a5,800046be <log_write+0x56>
break;
}
log.lh.block[i] = b->blockno;
800046cc: 0621 addi a2,a2,8
800046ce: 060a slli a2,a2,0x2
800046d0: 0001e797 auipc a5,0x1e
800046d4: 9a078793 addi a5,a5,-1632 # 80022070 <log>
800046d8: 963e add a2,a2,a5
800046da: 44dc lw a5,12(s1)
800046dc: ca1c sw a5,16(a2)
if (i == log.lh.n) { // Add new block to log?
bpin(b);
800046de: 8526 mv a0,s1
800046e0: fffff097 auipc ra,0xfffff
800046e4: da4080e7 jalr -604(ra) # 80003484 <bpin>
log.lh.n++;
800046e8: 0001e717 auipc a4,0x1e
800046ec: 98870713 addi a4,a4,-1656 # 80022070 <log>
800046f0: 575c lw a5,44(a4)
800046f2: 2785 addiw a5,a5,1
800046f4: d75c sw a5,44(a4)
800046f6: a835 j 80004732 <log_write+0xca>
panic("too big a transaction");
800046f8: 00004517 auipc a0,0x4
800046fc: 06050513 addi a0,a0,96 # 80008758 <syscalls+0x208>
80004700: ffffc097 auipc ra,0xffffc
80004704: e2a080e7 jalr -470(ra) # 8000052a <panic>
panic("log_write outside of trans");
80004708: 00004517 auipc a0,0x4
8000470c: 06850513 addi a0,a0,104 # 80008770 <syscalls+0x220>
80004710: ffffc097 auipc ra,0xffffc
80004714: e1a080e7 jalr -486(ra) # 8000052a <panic>
log.lh.block[i] = b->blockno;
80004718: 00878713 addi a4,a5,8
8000471c: 00271693 slli a3,a4,0x2
80004720: 0001e717 auipc a4,0x1e
80004724: 95070713 addi a4,a4,-1712 # 80022070 <log>
80004728: 9736 add a4,a4,a3
8000472a: 44d4 lw a3,12(s1)
8000472c: cb14 sw a3,16(a4)
if (i == log.lh.n) { // Add new block to log?
8000472e: faf608e3 beq a2,a5,800046de <log_write+0x76>
}
release(&log.lock);
80004732: 0001e517 auipc a0,0x1e
80004736: 93e50513 addi a0,a0,-1730 # 80022070 <log>
8000473a: ffffc097 auipc ra,0xffffc
8000473e: 53c080e7 jalr 1340(ra) # 80000c76 <release>
}
80004742: 60e2 ld ra,24(sp)
80004744: 6442 ld s0,16(sp)
80004746: 64a2 ld s1,8(sp)
80004748: 6902 ld s2,0(sp)
8000474a: 6105 addi sp,sp,32
8000474c: 8082 ret
000000008000474e <initsleeplock>:
#include "proc.h"
#include "sleeplock.h"
void
initsleeplock(struct sleeplock *lk, char *name)
{
8000474e: 1101 addi sp,sp,-32
80004750: ec06 sd ra,24(sp)
80004752: e822 sd s0,16(sp)
80004754: e426 sd s1,8(sp)
80004756: e04a sd s2,0(sp)
80004758: 1000 addi s0,sp,32
8000475a: 84aa mv s1,a0
8000475c: 892e mv s2,a1
initlock(&lk->lk, "sleep lock");
8000475e: 00004597 auipc a1,0x4
80004762: 03258593 addi a1,a1,50 # 80008790 <syscalls+0x240>
80004766: 0521 addi a0,a0,8
80004768: ffffc097 auipc ra,0xffffc
8000476c: 3ca080e7 jalr 970(ra) # 80000b32 <initlock>
lk->name = name;
80004770: 0324b023 sd s2,32(s1)
lk->locked = 0;
80004774: 0004a023 sw zero,0(s1)
lk->pid = 0;
80004778: 0204a423 sw zero,40(s1)
}
8000477c: 60e2 ld ra,24(sp)
8000477e: 6442 ld s0,16(sp)
80004780: 64a2 ld s1,8(sp)
80004782: 6902 ld s2,0(sp)
80004784: 6105 addi sp,sp,32
80004786: 8082 ret
0000000080004788 <acquiresleep>:
void
acquiresleep(struct sleeplock *lk)
{
80004788: 1101 addi sp,sp,-32
8000478a: ec06 sd ra,24(sp)
8000478c: e822 sd s0,16(sp)
8000478e: e426 sd s1,8(sp)
80004790: e04a sd s2,0(sp)
80004792: 1000 addi s0,sp,32
80004794: 84aa mv s1,a0
acquire(&lk->lk);
80004796: 00850913 addi s2,a0,8
8000479a: 854a mv a0,s2
8000479c: ffffc097 auipc ra,0xffffc
800047a0: 426080e7 jalr 1062(ra) # 80000bc2 <acquire>
while (lk->locked) {
800047a4: 409c lw a5,0(s1)
800047a6: cb89 beqz a5,800047b8 <acquiresleep+0x30>
sleep(lk, &lk->lk);
800047a8: 85ca mv a1,s2
800047aa: 8526 mv a0,s1
800047ac: ffffe097 auipc ra,0xffffe
800047b0: 948080e7 jalr -1720(ra) # 800020f4 <sleep>
while (lk->locked) {
800047b4: 409c lw a5,0(s1)
800047b6: fbed bnez a5,800047a8 <acquiresleep+0x20>
}
lk->locked = 1;
800047b8: 4785 li a5,1
800047ba: c09c sw a5,0(s1)
lk->pid = myproc()->pid;
800047bc: ffffd097 auipc ra,0xffffd
800047c0: 1c2080e7 jalr 450(ra) # 8000197e <myproc>
800047c4: 591c lw a5,48(a0)
800047c6: d49c sw a5,40(s1)
release(&lk->lk);
800047c8: 854a mv a0,s2
800047ca: ffffc097 auipc ra,0xffffc
800047ce: 4ac080e7 jalr 1196(ra) # 80000c76 <release>
}
800047d2: 60e2 ld ra,24(sp)
800047d4: 6442 ld s0,16(sp)
800047d6: 64a2 ld s1,8(sp)
800047d8: 6902 ld s2,0(sp)
800047da: 6105 addi sp,sp,32
800047dc: 8082 ret
00000000800047de <releasesleep>:
void
releasesleep(struct sleeplock *lk)
{
800047de: 1101 addi sp,sp,-32
800047e0: ec06 sd ra,24(sp)
800047e2: e822 sd s0,16(sp)
800047e4: e426 sd s1,8(sp)
800047e6: e04a sd s2,0(sp)
800047e8: 1000 addi s0,sp,32
800047ea: 84aa mv s1,a0
acquire(&lk->lk);
800047ec: 00850913 addi s2,a0,8
800047f0: 854a mv a0,s2
800047f2: ffffc097 auipc ra,0xffffc
800047f6: 3d0080e7 jalr 976(ra) # 80000bc2 <acquire>
lk->locked = 0;
800047fa: 0004a023 sw zero,0(s1)
lk->pid = 0;
800047fe: 0204a423 sw zero,40(s1)
wakeup(lk);
80004802: 8526 mv a0,s1
80004804: ffffe097 auipc ra,0xffffe
80004808: b64080e7 jalr -1180(ra) # 80002368 <wakeup>
release(&lk->lk);
8000480c: 854a mv a0,s2
8000480e: ffffc097 auipc ra,0xffffc
80004812: 468080e7 jalr 1128(ra) # 80000c76 <release>
}
80004816: 60e2 ld ra,24(sp)
80004818: 6442 ld s0,16(sp)
8000481a: 64a2 ld s1,8(sp)
8000481c: 6902 ld s2,0(sp)
8000481e: 6105 addi sp,sp,32
80004820: 8082 ret
0000000080004822 <holdingsleep>:
int
holdingsleep(struct sleeplock *lk)
{
80004822: 7179 addi sp,sp,-48
80004824: f406 sd ra,40(sp)
80004826: f022 sd s0,32(sp)
80004828: ec26 sd s1,24(sp)
8000482a: e84a sd s2,16(sp)
8000482c: e44e sd s3,8(sp)
8000482e: 1800 addi s0,sp,48
80004830: 84aa mv s1,a0
int r;
acquire(&lk->lk);
80004832: 00850913 addi s2,a0,8
80004836: 854a mv a0,s2
80004838: ffffc097 auipc ra,0xffffc
8000483c: 38a080e7 jalr 906(ra) # 80000bc2 <acquire>
r = lk->locked && (lk->pid == myproc()->pid);
80004840: 409c lw a5,0(s1)
80004842: ef99 bnez a5,80004860 <holdingsleep+0x3e>
80004844: 4481 li s1,0
release(&lk->lk);
80004846: 854a mv a0,s2
80004848: ffffc097 auipc ra,0xffffc
8000484c: 42e080e7 jalr 1070(ra) # 80000c76 <release>
return r;
}
80004850: 8526 mv a0,s1
80004852: 70a2 ld ra,40(sp)
80004854: 7402 ld s0,32(sp)
80004856: 64e2 ld s1,24(sp)
80004858: 6942 ld s2,16(sp)
8000485a: 69a2 ld s3,8(sp)
8000485c: 6145 addi sp,sp,48
8000485e: 8082 ret
r = lk->locked && (lk->pid == myproc()->pid);
80004860: 0284a983 lw s3,40(s1)
80004864: ffffd097 auipc ra,0xffffd
80004868: 11a080e7 jalr 282(ra) # 8000197e <myproc>
8000486c: 5904 lw s1,48(a0)
8000486e: 413484b3 sub s1,s1,s3
80004872: 0014b493 seqz s1,s1
80004876: bfc1 j 80004846 <holdingsleep+0x24>
0000000080004878 <fileinit>:
struct file file[NFILE];
} ftable;
void
fileinit(void)
{
80004878: 1141 addi sp,sp,-16
8000487a: e406 sd ra,8(sp)
8000487c: e022 sd s0,0(sp)
8000487e: 0800 addi s0,sp,16
initlock(&ftable.lock, "ftable");
80004880: 00004597 auipc a1,0x4
80004884: f2058593 addi a1,a1,-224 # 800087a0 <syscalls+0x250>
80004888: 0001e517 auipc a0,0x1e
8000488c: 93050513 addi a0,a0,-1744 # 800221b8 <ftable>
80004890: ffffc097 auipc ra,0xffffc
80004894: 2a2080e7 jalr 674(ra) # 80000b32 <initlock>
}
80004898: 60a2 ld ra,8(sp)
8000489a: 6402 ld s0,0(sp)
8000489c: 0141 addi sp,sp,16
8000489e: 8082 ret
00000000800048a0 <filealloc>:
// Allocate a file structure.
struct file*
filealloc(void)
{
800048a0: 1101 addi sp,sp,-32
800048a2: ec06 sd ra,24(sp)
800048a4: e822 sd s0,16(sp)
800048a6: e426 sd s1,8(sp)
800048a8: 1000 addi s0,sp,32
struct file *f;
acquire(&ftable.lock);
800048aa: 0001e517 auipc a0,0x1e
800048ae: 90e50513 addi a0,a0,-1778 # 800221b8 <ftable>
800048b2: ffffc097 auipc ra,0xffffc
800048b6: 310080e7 jalr 784(ra) # 80000bc2 <acquire>
for(f = ftable.file; f < ftable.file + NFILE; f++){
800048ba: 0001e497 auipc s1,0x1e
800048be: 91648493 addi s1,s1,-1770 # 800221d0 <ftable+0x18>
800048c2: 0001f717 auipc a4,0x1f
800048c6: 8ae70713 addi a4,a4,-1874 # 80023170 <ftable+0xfb8>
if(f->ref == 0){
800048ca: 40dc lw a5,4(s1)
800048cc: cf99 beqz a5,800048ea <filealloc+0x4a>
for(f = ftable.file; f < ftable.file + NFILE; f++){
800048ce: 02848493 addi s1,s1,40
800048d2: fee49ce3 bne s1,a4,800048ca <filealloc+0x2a>
f->ref = 1;
release(&ftable.lock);
return f;
}
}
release(&ftable.lock);
800048d6: 0001e517 auipc a0,0x1e
800048da: 8e250513 addi a0,a0,-1822 # 800221b8 <ftable>
800048de: ffffc097 auipc ra,0xffffc
800048e2: 398080e7 jalr 920(ra) # 80000c76 <release>
return 0;
800048e6: 4481 li s1,0
800048e8: a819 j 800048fe <filealloc+0x5e>
f->ref = 1;
800048ea: 4785 li a5,1
800048ec: c0dc sw a5,4(s1)
release(&ftable.lock);
800048ee: 0001e517 auipc a0,0x1e
800048f2: 8ca50513 addi a0,a0,-1846 # 800221b8 <ftable>
800048f6: ffffc097 auipc ra,0xffffc
800048fa: 380080e7 jalr 896(ra) # 80000c76 <release>
}
800048fe: 8526 mv a0,s1
80004900: 60e2 ld ra,24(sp)
80004902: 6442 ld s0,16(sp)
80004904: 64a2 ld s1,8(sp)
80004906: 6105 addi sp,sp,32
80004908: 8082 ret
000000008000490a <filedup>:
// Increment ref count for file f.
struct file*
filedup(struct file *f)
{
8000490a: 1101 addi sp,sp,-32
8000490c: ec06 sd ra,24(sp)
8000490e: e822 sd s0,16(sp)
80004910: e426 sd s1,8(sp)
80004912: 1000 addi s0,sp,32
80004914: 84aa mv s1,a0
acquire(&ftable.lock);
80004916: 0001e517 auipc a0,0x1e
8000491a: 8a250513 addi a0,a0,-1886 # 800221b8 <ftable>
8000491e: ffffc097 auipc ra,0xffffc
80004922: 2a4080e7 jalr 676(ra) # 80000bc2 <acquire>
if(f->ref < 1)
80004926: 40dc lw a5,4(s1)
80004928: 02f05263 blez a5,8000494c <filedup+0x42>
panic("filedup");
f->ref++;
8000492c: 2785 addiw a5,a5,1
8000492e: c0dc sw a5,4(s1)
release(&ftable.lock);
80004930: 0001e517 auipc a0,0x1e
80004934: 88850513 addi a0,a0,-1912 # 800221b8 <ftable>
80004938: ffffc097 auipc ra,0xffffc
8000493c: 33e080e7 jalr 830(ra) # 80000c76 <release>
return f;
}
80004940: 8526 mv a0,s1
80004942: 60e2 ld ra,24(sp)
80004944: 6442 ld s0,16(sp)
80004946: 64a2 ld s1,8(sp)
80004948: 6105 addi sp,sp,32
8000494a: 8082 ret
panic("filedup");
8000494c: 00004517 auipc a0,0x4
80004950: e5c50513 addi a0,a0,-420 # 800087a8 <syscalls+0x258>
80004954: ffffc097 auipc ra,0xffffc
80004958: bd6080e7 jalr -1066(ra) # 8000052a <panic>
000000008000495c <fileclose>:
// Close file f. (Decrement ref count, close when reaches 0.)
void
fileclose(struct file *f)
{
8000495c: 7139 addi sp,sp,-64
8000495e: fc06 sd ra,56(sp)
80004960: f822 sd s0,48(sp)
80004962: f426 sd s1,40(sp)
80004964: f04a sd s2,32(sp)
80004966: ec4e sd s3,24(sp)
80004968: e852 sd s4,16(sp)
8000496a: e456 sd s5,8(sp)
8000496c: 0080 addi s0,sp,64
8000496e: 84aa mv s1,a0
struct file ff;
acquire(&ftable.lock);
80004970: 0001e517 auipc a0,0x1e
80004974: 84850513 addi a0,a0,-1976 # 800221b8 <ftable>
80004978: ffffc097 auipc ra,0xffffc
8000497c: 24a080e7 jalr 586(ra) # 80000bc2 <acquire>
if(f->ref < 1)
80004980: 40dc lw a5,4(s1)
80004982: 06f05163 blez a5,800049e4 <fileclose+0x88>
panic("fileclose");
if(--f->ref > 0){
80004986: 37fd addiw a5,a5,-1
80004988: 0007871b sext.w a4,a5
8000498c: c0dc sw a5,4(s1)
8000498e: 06e04363 bgtz a4,800049f4 <fileclose+0x98>
release(&ftable.lock);
return;
}
ff = *f;
80004992: 0004a903 lw s2,0(s1)
80004996: 0094ca83 lbu s5,9(s1)
8000499a: 0104ba03 ld s4,16(s1)
8000499e: 0184b983 ld s3,24(s1)
f->ref = 0;
800049a2: 0004a223 sw zero,4(s1)
f->type = FD_NONE;
800049a6: 0004a023 sw zero,0(s1)
release(&ftable.lock);
800049aa: 0001e517 auipc a0,0x1e
800049ae: 80e50513 addi a0,a0,-2034 # 800221b8 <ftable>
800049b2: ffffc097 auipc ra,0xffffc
800049b6: 2c4080e7 jalr 708(ra) # 80000c76 <release>
if(ff.type == FD_PIPE){
800049ba: 4785 li a5,1
800049bc: 04f90d63 beq s2,a5,80004a16 <fileclose+0xba>
pipeclose(ff.pipe, ff.writable);
} else if(ff.type == FD_INODE || ff.type == FD_DEVICE){
800049c0: 3979 addiw s2,s2,-2
800049c2: 4785 li a5,1
800049c4: 0527e063 bltu a5,s2,80004a04 <fileclose+0xa8>
begin_op();
800049c8: 00000097 auipc ra,0x0
800049cc: ac8080e7 jalr -1336(ra) # 80004490 <begin_op>
iput(ff.ip);
800049d0: 854e mv a0,s3
800049d2: fffff097 auipc ra,0xfffff
800049d6: 2a2080e7 jalr 674(ra) # 80003c74 <iput>
end_op();
800049da: 00000097 auipc ra,0x0
800049de: b36080e7 jalr -1226(ra) # 80004510 <end_op>
800049e2: a00d j 80004a04 <fileclose+0xa8>
panic("fileclose");
800049e4: 00004517 auipc a0,0x4
800049e8: dcc50513 addi a0,a0,-564 # 800087b0 <syscalls+0x260>
800049ec: ffffc097 auipc ra,0xffffc
800049f0: b3e080e7 jalr -1218(ra) # 8000052a <panic>
release(&ftable.lock);
800049f4: 0001d517 auipc a0,0x1d
800049f8: 7c450513 addi a0,a0,1988 # 800221b8 <ftable>
800049fc: ffffc097 auipc ra,0xffffc
80004a00: 27a080e7 jalr 634(ra) # 80000c76 <release>
}
}
80004a04: 70e2 ld ra,56(sp)
80004a06: 7442 ld s0,48(sp)
80004a08: 74a2 ld s1,40(sp)
80004a0a: 7902 ld s2,32(sp)
80004a0c: 69e2 ld s3,24(sp)
80004a0e: 6a42 ld s4,16(sp)
80004a10: 6aa2 ld s5,8(sp)
80004a12: 6121 addi sp,sp,64
80004a14: 8082 ret
pipeclose(ff.pipe, ff.writable);
80004a16: 85d6 mv a1,s5
80004a18: 8552 mv a0,s4
80004a1a: 00000097 auipc ra,0x0
80004a1e: 34c080e7 jalr 844(ra) # 80004d66 <pipeclose>
80004a22: b7cd j 80004a04 <fileclose+0xa8>
0000000080004a24 <filestat>:
// Get metadata about file f.
// addr is a user virtual address, pointing to a struct stat.
int
filestat(struct file *f, uint64 addr)
{
80004a24: 715d addi sp,sp,-80
80004a26: e486 sd ra,72(sp)
80004a28: e0a2 sd s0,64(sp)
80004a2a: fc26 sd s1,56(sp)
80004a2c: f84a sd s2,48(sp)
80004a2e: f44e sd s3,40(sp)
80004a30: 0880 addi s0,sp,80
80004a32: 84aa mv s1,a0
80004a34: 89ae mv s3,a1
struct proc *p = myproc();
80004a36: ffffd097 auipc ra,0xffffd
80004a3a: f48080e7 jalr -184(ra) # 8000197e <myproc>
struct stat st;
if(f->type == FD_INODE || f->type == FD_DEVICE){
80004a3e: 409c lw a5,0(s1)
80004a40: 37f9 addiw a5,a5,-2
80004a42: 4705 li a4,1
80004a44: 04f76763 bltu a4,a5,80004a92 <filestat+0x6e>
80004a48: 892a mv s2,a0
ilock(f->ip);
80004a4a: 6c88 ld a0,24(s1)
80004a4c: fffff097 auipc ra,0xfffff
80004a50: 06e080e7 jalr 110(ra) # 80003aba <ilock>
stati(f->ip, &st);
80004a54: fb840593 addi a1,s0,-72
80004a58: 6c88 ld a0,24(s1)
80004a5a: fffff097 auipc ra,0xfffff
80004a5e: 2ea080e7 jalr 746(ra) # 80003d44 <stati>
iunlock(f->ip);
80004a62: 6c88 ld a0,24(s1)
80004a64: fffff097 auipc ra,0xfffff
80004a68: 118080e7 jalr 280(ra) # 80003b7c <iunlock>
if(copyout(p->pagetable, addr, (char *)&st, sizeof(st)) < 0)
80004a6c: 46e1 li a3,24
80004a6e: fb840613 addi a2,s0,-72
80004a72: 85ce mv a1,s3
80004a74: 08893503 ld a0,136(s2)
80004a78: ffffd097 auipc ra,0xffffd
80004a7c: bc6080e7 jalr -1082(ra) # 8000163e <copyout>
80004a80: 41f5551b sraiw a0,a0,0x1f
return -1;
return 0;
}
return -1;
}
80004a84: 60a6 ld ra,72(sp)
80004a86: 6406 ld s0,64(sp)
80004a88: 74e2 ld s1,56(sp)
80004a8a: 7942 ld s2,48(sp)
80004a8c: 79a2 ld s3,40(sp)
80004a8e: 6161 addi sp,sp,80
80004a90: 8082 ret
return -1;
80004a92: 557d li a0,-1
80004a94: bfc5 j 80004a84 <filestat+0x60>
0000000080004a96 <fileread>:
// Read from file f.
// addr is a user virtual address.
int
fileread(struct file *f, uint64 addr, int n)
{
80004a96: 7179 addi sp,sp,-48
80004a98: f406 sd ra,40(sp)
80004a9a: f022 sd s0,32(sp)
80004a9c: ec26 sd s1,24(sp)
80004a9e: e84a sd s2,16(sp)
80004aa0: e44e sd s3,8(sp)
80004aa2: 1800 addi s0,sp,48
int r = 0;
if(f->readable == 0)
80004aa4: 00854783 lbu a5,8(a0)
80004aa8: c3d5 beqz a5,80004b4c <fileread+0xb6>
80004aaa: 84aa mv s1,a0
80004aac: 89ae mv s3,a1
80004aae: 8932 mv s2,a2
return -1;
if(f->type == FD_PIPE){
80004ab0: 411c lw a5,0(a0)
80004ab2: 4705 li a4,1
80004ab4: 04e78963 beq a5,a4,80004b06 <fileread+0x70>
r = piperead(f->pipe, addr, n);
} else if(f->type == FD_DEVICE){
80004ab8: 470d li a4,3
80004aba: 04e78d63 beq a5,a4,80004b14 <fileread+0x7e>
if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
return -1;
r = devsw[f->major].read(1, addr, n);
} else if(f->type == FD_INODE){
80004abe: 4709 li a4,2
80004ac0: 06e79e63 bne a5,a4,80004b3c <fileread+0xa6>
ilock(f->ip);
80004ac4: 6d08 ld a0,24(a0)
80004ac6: fffff097 auipc ra,0xfffff
80004aca: ff4080e7 jalr -12(ra) # 80003aba <ilock>
if((r = readi(f->ip, 1, addr, f->off, n)) > 0)
80004ace: 874a mv a4,s2
80004ad0: 5094 lw a3,32(s1)
80004ad2: 864e mv a2,s3
80004ad4: 4585 li a1,1
80004ad6: 6c88 ld a0,24(s1)
80004ad8: fffff097 auipc ra,0xfffff
80004adc: 296080e7 jalr 662(ra) # 80003d6e <readi>
80004ae0: 892a mv s2,a0
80004ae2: 00a05563 blez a0,80004aec <fileread+0x56>
f->off += r;
80004ae6: 509c lw a5,32(s1)
80004ae8: 9fa9 addw a5,a5,a0
80004aea: d09c sw a5,32(s1)
iunlock(f->ip);
80004aec: 6c88 ld a0,24(s1)
80004aee: fffff097 auipc ra,0xfffff
80004af2: 08e080e7 jalr 142(ra) # 80003b7c <iunlock>
} else {
panic("fileread");
}
return r;
}
80004af6: 854a mv a0,s2
80004af8: 70a2 ld ra,40(sp)
80004afa: 7402 ld s0,32(sp)
80004afc: 64e2 ld s1,24(sp)
80004afe: 6942 ld s2,16(sp)
80004b00: 69a2 ld s3,8(sp)
80004b02: 6145 addi sp,sp,48
80004b04: 8082 ret
r = piperead(f->pipe, addr, n);
80004b06: 6908 ld a0,16(a0)
80004b08: 00000097 auipc ra,0x0
80004b0c: 3c0080e7 jalr 960(ra) # 80004ec8 <piperead>
80004b10: 892a mv s2,a0
80004b12: b7d5 j 80004af6 <fileread+0x60>
if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
80004b14: 02451783 lh a5,36(a0)
80004b18: 03079693 slli a3,a5,0x30
80004b1c: 92c1 srli a3,a3,0x30
80004b1e: 4725 li a4,9
80004b20: 02d76863 bltu a4,a3,80004b50 <fileread+0xba>
80004b24: 0792 slli a5,a5,0x4
80004b26: 0001d717 auipc a4,0x1d
80004b2a: 5f270713 addi a4,a4,1522 # 80022118 <devsw>
80004b2e: 97ba add a5,a5,a4
80004b30: 639c ld a5,0(a5)
80004b32: c38d beqz a5,80004b54 <fileread+0xbe>
r = devsw[f->major].read(1, addr, n);
80004b34: 4505 li a0,1
80004b36: 9782 jalr a5
80004b38: 892a mv s2,a0
80004b3a: bf75 j 80004af6 <fileread+0x60>
panic("fileread");
80004b3c: 00004517 auipc a0,0x4
80004b40: c8450513 addi a0,a0,-892 # 800087c0 <syscalls+0x270>
80004b44: ffffc097 auipc ra,0xffffc
80004b48: 9e6080e7 jalr -1562(ra) # 8000052a <panic>
return -1;
80004b4c: 597d li s2,-1
80004b4e: b765 j 80004af6 <fileread+0x60>
return -1;
80004b50: 597d li s2,-1
80004b52: b755 j 80004af6 <fileread+0x60>
80004b54: 597d li s2,-1
80004b56: b745 j 80004af6 <fileread+0x60>
0000000080004b58 <filewrite>:
// Write to file f.
// addr is a user virtual address.
int
filewrite(struct file *f, uint64 addr, int n)
{
80004b58: 715d addi sp,sp,-80
80004b5a: e486 sd ra,72(sp)
80004b5c: e0a2 sd s0,64(sp)
80004b5e: fc26 sd s1,56(sp)
80004b60: f84a sd s2,48(sp)
80004b62: f44e sd s3,40(sp)
80004b64: f052 sd s4,32(sp)
80004b66: ec56 sd s5,24(sp)
80004b68: e85a sd s6,16(sp)
80004b6a: e45e sd s7,8(sp)
80004b6c: e062 sd s8,0(sp)
80004b6e: 0880 addi s0,sp,80
int r, ret = 0;
if(f->writable == 0)
80004b70: 00954783 lbu a5,9(a0)
80004b74: 10078663 beqz a5,80004c80 <filewrite+0x128>
80004b78: 892a mv s2,a0
80004b7a: 8aae mv s5,a1
80004b7c: 8a32 mv s4,a2
return -1;
if(f->type == FD_PIPE){
80004b7e: 411c lw a5,0(a0)
80004b80: 4705 li a4,1
80004b82: 02e78263 beq a5,a4,80004ba6 <filewrite+0x4e>
ret = pipewrite(f->pipe, addr, n);
} else if(f->type == FD_DEVICE){
80004b86: 470d li a4,3
80004b88: 02e78663 beq a5,a4,80004bb4 <filewrite+0x5c>
if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
return -1;
ret = devsw[f->major].write(1, addr, n);
} else if(f->type == FD_INODE){
80004b8c: 4709 li a4,2
80004b8e: 0ee79163 bne a5,a4,80004c70 <filewrite+0x118>
// 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 = ((MAXOPBLOCKS-1-1-2) / 2) * BSIZE;
int i = 0;
while(i < n){
80004b92: 0ac05d63 blez a2,80004c4c <filewrite+0xf4>
int i = 0;
80004b96: 4981 li s3,0
80004b98: 6b05 lui s6,0x1
80004b9a: c00b0b13 addi s6,s6,-1024 # c00 <_entry-0x7ffff400>
80004b9e: 6b85 lui s7,0x1
80004ba0: c00b8b9b addiw s7,s7,-1024
80004ba4: a861 j 80004c3c <filewrite+0xe4>
ret = pipewrite(f->pipe, addr, n);
80004ba6: 6908 ld a0,16(a0)
80004ba8: 00000097 auipc ra,0x0
80004bac: 22e080e7 jalr 558(ra) # 80004dd6 <pipewrite>
80004bb0: 8a2a mv s4,a0
80004bb2: a045 j 80004c52 <filewrite+0xfa>
if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
80004bb4: 02451783 lh a5,36(a0)
80004bb8: 03079693 slli a3,a5,0x30
80004bbc: 92c1 srli a3,a3,0x30
80004bbe: 4725 li a4,9
80004bc0: 0cd76263 bltu a4,a3,80004c84 <filewrite+0x12c>
80004bc4: 0792 slli a5,a5,0x4
80004bc6: 0001d717 auipc a4,0x1d
80004bca: 55270713 addi a4,a4,1362 # 80022118 <devsw>
80004bce: 97ba add a5,a5,a4
80004bd0: 679c ld a5,8(a5)
80004bd2: cbdd beqz a5,80004c88 <filewrite+0x130>
ret = devsw[f->major].write(1, addr, n);
80004bd4: 4505 li a0,1
80004bd6: 9782 jalr a5
80004bd8: 8a2a mv s4,a0
80004bda: a8a5 j 80004c52 <filewrite+0xfa>
80004bdc: 00048c1b sext.w s8,s1
int n1 = n - i;
if(n1 > max)
n1 = max;
begin_op();
80004be0: 00000097 auipc ra,0x0
80004be4: 8b0080e7 jalr -1872(ra) # 80004490 <begin_op>
ilock(f->ip);
80004be8: 01893503 ld a0,24(s2)
80004bec: fffff097 auipc ra,0xfffff
80004bf0: ece080e7 jalr -306(ra) # 80003aba <ilock>
if ((r = writei(f->ip, 1, addr + i, f->off, n1)) > 0)
80004bf4: 8762 mv a4,s8
80004bf6: 02092683 lw a3,32(s2)
80004bfa: 01598633 add a2,s3,s5
80004bfe: 4585 li a1,1
80004c00: 01893503 ld a0,24(s2)
80004c04: fffff097 auipc ra,0xfffff
80004c08: 262080e7 jalr 610(ra) # 80003e66 <writei>
80004c0c: 84aa mv s1,a0
80004c0e: 00a05763 blez a0,80004c1c <filewrite+0xc4>
f->off += r;
80004c12: 02092783 lw a5,32(s2)
80004c16: 9fa9 addw a5,a5,a0
80004c18: 02f92023 sw a5,32(s2)
iunlock(f->ip);
80004c1c: 01893503 ld a0,24(s2)
80004c20: fffff097 auipc ra,0xfffff
80004c24: f5c080e7 jalr -164(ra) # 80003b7c <iunlock>
end_op();
80004c28: 00000097 auipc ra,0x0
80004c2c: 8e8080e7 jalr -1816(ra) # 80004510 <end_op>
if(r != n1){
80004c30: 009c1f63 bne s8,s1,80004c4e <filewrite+0xf6>
// error from writei
break;
}
i += r;
80004c34: 013489bb addw s3,s1,s3
while(i < n){
80004c38: 0149db63 bge s3,s4,80004c4e <filewrite+0xf6>
int n1 = n - i;
80004c3c: 413a07bb subw a5,s4,s3
if(n1 > max)
80004c40: 84be mv s1,a5
80004c42: 2781 sext.w a5,a5
80004c44: f8fb5ce3 bge s6,a5,80004bdc <filewrite+0x84>
80004c48: 84de mv s1,s7
80004c4a: bf49 j 80004bdc <filewrite+0x84>
int i = 0;
80004c4c: 4981 li s3,0
}
ret = (i == n ? n : -1);
80004c4e: 013a1f63 bne s4,s3,80004c6c <filewrite+0x114>
} else {
panic("filewrite");
}
return ret;
}
80004c52: 8552 mv a0,s4
80004c54: 60a6 ld ra,72(sp)
80004c56: 6406 ld s0,64(sp)
80004c58: 74e2 ld s1,56(sp)
80004c5a: 7942 ld s2,48(sp)
80004c5c: 79a2 ld s3,40(sp)
80004c5e: 7a02 ld s4,32(sp)
80004c60: 6ae2 ld s5,24(sp)
80004c62: 6b42 ld s6,16(sp)
80004c64: 6ba2 ld s7,8(sp)
80004c66: 6c02 ld s8,0(sp)
80004c68: 6161 addi sp,sp,80
80004c6a: 8082 ret
ret = (i == n ? n : -1);
80004c6c: 5a7d li s4,-1
80004c6e: b7d5 j 80004c52 <filewrite+0xfa>
panic("filewrite");
80004c70: 00004517 auipc a0,0x4
80004c74: b6050513 addi a0,a0,-1184 # 800087d0 <syscalls+0x280>
80004c78: ffffc097 auipc ra,0xffffc
80004c7c: 8b2080e7 jalr -1870(ra) # 8000052a <panic>
return -1;
80004c80: 5a7d li s4,-1
80004c82: bfc1 j 80004c52 <filewrite+0xfa>
return -1;
80004c84: 5a7d li s4,-1
80004c86: b7f1 j 80004c52 <filewrite+0xfa>
80004c88: 5a7d li s4,-1
80004c8a: b7e1 j 80004c52 <filewrite+0xfa>
0000000080004c8c <pipealloc>:
int writeopen; // write fd is still open
};
int
pipealloc(struct file **f0, struct file **f1)
{
80004c8c: 7179 addi sp,sp,-48
80004c8e: f406 sd ra,40(sp)
80004c90: f022 sd s0,32(sp)
80004c92: ec26 sd s1,24(sp)
80004c94: e84a sd s2,16(sp)
80004c96: e44e sd s3,8(sp)
80004c98: e052 sd s4,0(sp)
80004c9a: 1800 addi s0,sp,48
80004c9c: 84aa mv s1,a0
80004c9e: 8a2e mv s4,a1
struct pipe *pi;
pi = 0;
*f0 = *f1 = 0;
80004ca0: 0005b023 sd zero,0(a1)
80004ca4: 00053023 sd zero,0(a0)
if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0)
80004ca8: 00000097 auipc ra,0x0
80004cac: bf8080e7 jalr -1032(ra) # 800048a0 <filealloc>
80004cb0: e088 sd a0,0(s1)
80004cb2: c551 beqz a0,80004d3e <pipealloc+0xb2>
80004cb4: 00000097 auipc ra,0x0
80004cb8: bec080e7 jalr -1044(ra) # 800048a0 <filealloc>
80004cbc: 00aa3023 sd a0,0(s4)
80004cc0: c92d beqz a0,80004d32 <pipealloc+0xa6>
goto bad;
if((pi = (struct pipe*)kalloc()) == 0)
80004cc2: ffffc097 auipc ra,0xffffc
80004cc6: e10080e7 jalr -496(ra) # 80000ad2 <kalloc>
80004cca: 892a mv s2,a0
80004ccc: c125 beqz a0,80004d2c <pipealloc+0xa0>
goto bad;
pi->readopen = 1;
80004cce: 4985 li s3,1
80004cd0: 23352023 sw s3,544(a0)
pi->writeopen = 1;
80004cd4: 23352223 sw s3,548(a0)
pi->nwrite = 0;
80004cd8: 20052e23 sw zero,540(a0)
pi->nread = 0;
80004cdc: 20052c23 sw zero,536(a0)
initlock(&pi->lock, "pipe");
80004ce0: 00003597 auipc a1,0x3
80004ce4: 7a858593 addi a1,a1,1960 # 80008488 <states.0+0x1e0>
80004ce8: ffffc097 auipc ra,0xffffc
80004cec: e4a080e7 jalr -438(ra) # 80000b32 <initlock>
(*f0)->type = FD_PIPE;
80004cf0: 609c ld a5,0(s1)
80004cf2: 0137a023 sw s3,0(a5)
(*f0)->readable = 1;
80004cf6: 609c ld a5,0(s1)
80004cf8: 01378423 sb s3,8(a5)
(*f0)->writable = 0;
80004cfc: 609c ld a5,0(s1)
80004cfe: 000784a3 sb zero,9(a5)
(*f0)->pipe = pi;
80004d02: 609c ld a5,0(s1)
80004d04: 0127b823 sd s2,16(a5)
(*f1)->type = FD_PIPE;
80004d08: 000a3783 ld a5,0(s4)
80004d0c: 0137a023 sw s3,0(a5)
(*f1)->readable = 0;
80004d10: 000a3783 ld a5,0(s4)
80004d14: 00078423 sb zero,8(a5)
(*f1)->writable = 1;
80004d18: 000a3783 ld a5,0(s4)
80004d1c: 013784a3 sb s3,9(a5)
(*f1)->pipe = pi;
80004d20: 000a3783 ld a5,0(s4)
80004d24: 0127b823 sd s2,16(a5)
return 0;
80004d28: 4501 li a0,0
80004d2a: a025 j 80004d52 <pipealloc+0xc6>
bad:
if(pi)
kfree((char*)pi);
if(*f0)
80004d2c: 6088 ld a0,0(s1)
80004d2e: e501 bnez a0,80004d36 <pipealloc+0xaa>
80004d30: a039 j 80004d3e <pipealloc+0xb2>
80004d32: 6088 ld a0,0(s1)
80004d34: c51d beqz a0,80004d62 <pipealloc+0xd6>
fileclose(*f0);
80004d36: 00000097 auipc ra,0x0
80004d3a: c26080e7 jalr -986(ra) # 8000495c <fileclose>
if(*f1)
80004d3e: 000a3783 ld a5,0(s4)
fileclose(*f1);
return -1;
80004d42: 557d li a0,-1
if(*f1)
80004d44: c799 beqz a5,80004d52 <pipealloc+0xc6>
fileclose(*f1);
80004d46: 853e mv a0,a5
80004d48: 00000097 auipc ra,0x0
80004d4c: c14080e7 jalr -1004(ra) # 8000495c <fileclose>
return -1;
80004d50: 557d li a0,-1
}
80004d52: 70a2 ld ra,40(sp)
80004d54: 7402 ld s0,32(sp)
80004d56: 64e2 ld s1,24(sp)
80004d58: 6942 ld s2,16(sp)
80004d5a: 69a2 ld s3,8(sp)
80004d5c: 6a02 ld s4,0(sp)
80004d5e: 6145 addi sp,sp,48
80004d60: 8082 ret
return -1;
80004d62: 557d li a0,-1
80004d64: b7fd j 80004d52 <pipealloc+0xc6>
0000000080004d66 <pipeclose>:
void
pipeclose(struct pipe *pi, int writable)
{
80004d66: 1101 addi sp,sp,-32
80004d68: ec06 sd ra,24(sp)
80004d6a: e822 sd s0,16(sp)
80004d6c: e426 sd s1,8(sp)
80004d6e: e04a sd s2,0(sp)
80004d70: 1000 addi s0,sp,32
80004d72: 84aa mv s1,a0
80004d74: 892e mv s2,a1
acquire(&pi->lock);
80004d76: ffffc097 auipc ra,0xffffc
80004d7a: e4c080e7 jalr -436(ra) # 80000bc2 <acquire>
if(writable){
80004d7e: 02090d63 beqz s2,80004db8 <pipeclose+0x52>
pi->writeopen = 0;
80004d82: 2204a223 sw zero,548(s1)
wakeup(&pi->nread);
80004d86: 21848513 addi a0,s1,536
80004d8a: ffffd097 auipc ra,0xffffd
80004d8e: 5de080e7 jalr 1502(ra) # 80002368 <wakeup>
} else {
pi->readopen = 0;
wakeup(&pi->nwrite);
}
if(pi->readopen == 0 && pi->writeopen == 0){
80004d92: 2204b783 ld a5,544(s1)
80004d96: eb95 bnez a5,80004dca <pipeclose+0x64>
release(&pi->lock);
80004d98: 8526 mv a0,s1
80004d9a: ffffc097 auipc ra,0xffffc
80004d9e: edc080e7 jalr -292(ra) # 80000c76 <release>
kfree((char*)pi);
80004da2: 8526 mv a0,s1
80004da4: ffffc097 auipc ra,0xffffc
80004da8: c32080e7 jalr -974(ra) # 800009d6 <kfree>
} else
release(&pi->lock);
}
80004dac: 60e2 ld ra,24(sp)
80004dae: 6442 ld s0,16(sp)
80004db0: 64a2 ld s1,8(sp)
80004db2: 6902 ld s2,0(sp)
80004db4: 6105 addi sp,sp,32
80004db6: 8082 ret
pi->readopen = 0;
80004db8: 2204a023 sw zero,544(s1)
wakeup(&pi->nwrite);
80004dbc: 21c48513 addi a0,s1,540
80004dc0: ffffd097 auipc ra,0xffffd
80004dc4: 5a8080e7 jalr 1448(ra) # 80002368 <wakeup>
80004dc8: b7e9 j 80004d92 <pipeclose+0x2c>
release(&pi->lock);
80004dca: 8526 mv a0,s1
80004dcc: ffffc097 auipc ra,0xffffc
80004dd0: eaa080e7 jalr -342(ra) # 80000c76 <release>
}
80004dd4: bfe1 j 80004dac <pipeclose+0x46>
0000000080004dd6 <pipewrite>:
int
pipewrite(struct pipe *pi, uint64 addr, int n)
{
80004dd6: 711d addi sp,sp,-96
80004dd8: ec86 sd ra,88(sp)
80004dda: e8a2 sd s0,80(sp)
80004ddc: e4a6 sd s1,72(sp)
80004dde: e0ca sd s2,64(sp)
80004de0: fc4e sd s3,56(sp)
80004de2: f852 sd s4,48(sp)
80004de4: f456 sd s5,40(sp)
80004de6: f05a sd s6,32(sp)
80004de8: ec5e sd s7,24(sp)
80004dea: e862 sd s8,16(sp)
80004dec: 1080 addi s0,sp,96
80004dee: 84aa mv s1,a0
80004df0: 8aae mv s5,a1
80004df2: 8a32 mv s4,a2
int i = 0;
struct proc *pr = myproc();
80004df4: ffffd097 auipc ra,0xffffd
80004df8: b8a080e7 jalr -1142(ra) # 8000197e <myproc>
80004dfc: 89aa mv s3,a0
acquire(&pi->lock);
80004dfe: 8526 mv a0,s1
80004e00: ffffc097 auipc ra,0xffffc
80004e04: dc2080e7 jalr -574(ra) # 80000bc2 <acquire>
while(i < n){
80004e08: 0b405363 blez s4,80004eae <pipewrite+0xd8>
int i = 0;
80004e0c: 4901 li s2,0
if(pi->nwrite == pi->nread + PIPESIZE){ //DOC: pipewrite-full
wakeup(&pi->nread);
sleep(&pi->nwrite, &pi->lock);
} else {
char ch;
if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
80004e0e: 5b7d li s6,-1
wakeup(&pi->nread);
80004e10: 21848c13 addi s8,s1,536
sleep(&pi->nwrite, &pi->lock);
80004e14: 21c48b93 addi s7,s1,540
80004e18: a089 j 80004e5a <pipewrite+0x84>
release(&pi->lock);
80004e1a: 8526 mv a0,s1
80004e1c: ffffc097 auipc ra,0xffffc
80004e20: e5a080e7 jalr -422(ra) # 80000c76 <release>
return -1;
80004e24: 597d li s2,-1
}
wakeup(&pi->nread);
release(&pi->lock);
return i;
}
80004e26: 854a mv a0,s2
80004e28: 60e6 ld ra,88(sp)
80004e2a: 6446 ld s0,80(sp)
80004e2c: 64a6 ld s1,72(sp)
80004e2e: 6906 ld s2,64(sp)
80004e30: 79e2 ld s3,56(sp)
80004e32: 7a42 ld s4,48(sp)
80004e34: 7aa2 ld s5,40(sp)
80004e36: 7b02 ld s6,32(sp)
80004e38: 6be2 ld s7,24(sp)
80004e3a: 6c42 ld s8,16(sp)
80004e3c: 6125 addi sp,sp,96
80004e3e: 8082 ret
wakeup(&pi->nread);
80004e40: 8562 mv a0,s8
80004e42: ffffd097 auipc ra,0xffffd
80004e46: 526080e7 jalr 1318(ra) # 80002368 <wakeup>
sleep(&pi->nwrite, &pi->lock);
80004e4a: 85a6 mv a1,s1
80004e4c: 855e mv a0,s7
80004e4e: ffffd097 auipc ra,0xffffd
80004e52: 2a6080e7 jalr 678(ra) # 800020f4 <sleep>
while(i < n){
80004e56: 05495d63 bge s2,s4,80004eb0 <pipewrite+0xda>
if(pi->readopen == 0 || pr->killed){
80004e5a: 2204a783 lw a5,544(s1)
80004e5e: dfd5 beqz a5,80004e1a <pipewrite+0x44>
80004e60: 0289a783 lw a5,40(s3)
80004e64: fbdd bnez a5,80004e1a <pipewrite+0x44>
if(pi->nwrite == pi->nread + PIPESIZE){ //DOC: pipewrite-full
80004e66: 2184a783 lw a5,536(s1)
80004e6a: 21c4a703 lw a4,540(s1)
80004e6e: 2007879b addiw a5,a5,512
80004e72: fcf707e3 beq a4,a5,80004e40 <pipewrite+0x6a>
if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
80004e76: 4685 li a3,1
80004e78: 01590633 add a2,s2,s5
80004e7c: faf40593 addi a1,s0,-81
80004e80: 0889b503 ld a0,136(s3)
80004e84: ffffd097 auipc ra,0xffffd
80004e88: 846080e7 jalr -1978(ra) # 800016ca <copyin>
80004e8c: 03650263 beq a0,s6,80004eb0 <pipewrite+0xda>
pi->data[pi->nwrite++ % PIPESIZE] = ch;
80004e90: 21c4a783 lw a5,540(s1)
80004e94: 0017871b addiw a4,a5,1
80004e98: 20e4ae23 sw a4,540(s1)
80004e9c: 1ff7f793 andi a5,a5,511
80004ea0: 97a6 add a5,a5,s1
80004ea2: faf44703 lbu a4,-81(s0)
80004ea6: 00e78c23 sb a4,24(a5)
i++;
80004eaa: 2905 addiw s2,s2,1
80004eac: b76d j 80004e56 <pipewrite+0x80>
int i = 0;
80004eae: 4901 li s2,0
wakeup(&pi->nread);
80004eb0: 21848513 addi a0,s1,536
80004eb4: ffffd097 auipc ra,0xffffd
80004eb8: 4b4080e7 jalr 1204(ra) # 80002368 <wakeup>
release(&pi->lock);
80004ebc: 8526 mv a0,s1
80004ebe: ffffc097 auipc ra,0xffffc
80004ec2: db8080e7 jalr -584(ra) # 80000c76 <release>
return i;
80004ec6: b785 j 80004e26 <pipewrite+0x50>
0000000080004ec8 <piperead>:
int
piperead(struct pipe *pi, uint64 addr, int n)
{
80004ec8: 715d addi sp,sp,-80
80004eca: e486 sd ra,72(sp)
80004ecc: e0a2 sd s0,64(sp)
80004ece: fc26 sd s1,56(sp)
80004ed0: f84a sd s2,48(sp)
80004ed2: f44e sd s3,40(sp)
80004ed4: f052 sd s4,32(sp)
80004ed6: ec56 sd s5,24(sp)
80004ed8: e85a sd s6,16(sp)
80004eda: 0880 addi s0,sp,80
80004edc: 84aa mv s1,a0
80004ede: 892e mv s2,a1
80004ee0: 8ab2 mv s5,a2
int i;
struct proc *pr = myproc();
80004ee2: ffffd097 auipc ra,0xffffd
80004ee6: a9c080e7 jalr -1380(ra) # 8000197e <myproc>
80004eea: 8a2a mv s4,a0
char ch;
acquire(&pi->lock);
80004eec: 8526 mv a0,s1
80004eee: ffffc097 auipc ra,0xffffc
80004ef2: cd4080e7 jalr -812(ra) # 80000bc2 <acquire>
while(pi->nread == pi->nwrite && pi->writeopen){ //DOC: pipe-empty
80004ef6: 2184a703 lw a4,536(s1)
80004efa: 21c4a783 lw a5,540(s1)
if(pr->killed){
release(&pi->lock);
return -1;
}
sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
80004efe: 21848993 addi s3,s1,536
while(pi->nread == pi->nwrite && pi->writeopen){ //DOC: pipe-empty
80004f02: 02f71463 bne a4,a5,80004f2a <piperead+0x62>
80004f06: 2244a783 lw a5,548(s1)
80004f0a: c385 beqz a5,80004f2a <piperead+0x62>
if(pr->killed){
80004f0c: 028a2783 lw a5,40(s4)
80004f10: ebc1 bnez a5,80004fa0 <piperead+0xd8>
sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
80004f12: 85a6 mv a1,s1
80004f14: 854e mv a0,s3
80004f16: ffffd097 auipc ra,0xffffd
80004f1a: 1de080e7 jalr 478(ra) # 800020f4 <sleep>
while(pi->nread == pi->nwrite && pi->writeopen){ //DOC: pipe-empty
80004f1e: 2184a703 lw a4,536(s1)
80004f22: 21c4a783 lw a5,540(s1)
80004f26: fef700e3 beq a4,a5,80004f06 <piperead+0x3e>
}
for(i = 0; i < n; i++){ //DOC: piperead-copy
80004f2a: 4981 li s3,0
if(pi->nread == pi->nwrite)
break;
ch = pi->data[pi->nread++ % PIPESIZE];
if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
80004f2c: 5b7d li s6,-1
for(i = 0; i < n; i++){ //DOC: piperead-copy
80004f2e: 05505363 blez s5,80004f74 <piperead+0xac>
if(pi->nread == pi->nwrite)
80004f32: 2184a783 lw a5,536(s1)
80004f36: 21c4a703 lw a4,540(s1)
80004f3a: 02f70d63 beq a4,a5,80004f74 <piperead+0xac>
ch = pi->data[pi->nread++ % PIPESIZE];
80004f3e: 0017871b addiw a4,a5,1
80004f42: 20e4ac23 sw a4,536(s1)
80004f46: 1ff7f793 andi a5,a5,511
80004f4a: 97a6 add a5,a5,s1
80004f4c: 0187c783 lbu a5,24(a5)
80004f50: faf40fa3 sb a5,-65(s0)
if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
80004f54: 4685 li a3,1
80004f56: fbf40613 addi a2,s0,-65
80004f5a: 85ca mv a1,s2
80004f5c: 088a3503 ld a0,136(s4)
80004f60: ffffc097 auipc ra,0xffffc
80004f64: 6de080e7 jalr 1758(ra) # 8000163e <copyout>
80004f68: 01650663 beq a0,s6,80004f74 <piperead+0xac>
for(i = 0; i < n; i++){ //DOC: piperead-copy
80004f6c: 2985 addiw s3,s3,1
80004f6e: 0905 addi s2,s2,1
80004f70: fd3a91e3 bne s5,s3,80004f32 <piperead+0x6a>
break;
}
wakeup(&pi->nwrite); //DOC: piperead-wakeup
80004f74: 21c48513 addi a0,s1,540
80004f78: ffffd097 auipc ra,0xffffd
80004f7c: 3f0080e7 jalr 1008(ra) # 80002368 <wakeup>
release(&pi->lock);
80004f80: 8526 mv a0,s1
80004f82: ffffc097 auipc ra,0xffffc
80004f86: cf4080e7 jalr -780(ra) # 80000c76 <release>
return i;
}
80004f8a: 854e mv a0,s3
80004f8c: 60a6 ld ra,72(sp)
80004f8e: 6406 ld s0,64(sp)
80004f90: 74e2 ld s1,56(sp)
80004f92: 7942 ld s2,48(sp)
80004f94: 79a2 ld s3,40(sp)
80004f96: 7a02 ld s4,32(sp)
80004f98: 6ae2 ld s5,24(sp)
80004f9a: 6b42 ld s6,16(sp)
80004f9c: 6161 addi sp,sp,80
80004f9e: 8082 ret
release(&pi->lock);
80004fa0: 8526 mv a0,s1
80004fa2: ffffc097 auipc ra,0xffffc
80004fa6: cd4080e7 jalr -812(ra) # 80000c76 <release>
return -1;
80004faa: 59fd li s3,-1
80004fac: bff9 j 80004f8a <piperead+0xc2>
0000000080004fae <exec>:
static int loadseg(pde_t *pgdir, uint64 addr, struct inode *ip, uint offset, uint sz);
int
exec(char *path, char **argv)
{
80004fae: de010113 addi sp,sp,-544
80004fb2: 20113c23 sd ra,536(sp)
80004fb6: 20813823 sd s0,528(sp)
80004fba: 20913423 sd s1,520(sp)
80004fbe: 21213023 sd s2,512(sp)
80004fc2: ffce sd s3,504(sp)
80004fc4: fbd2 sd s4,496(sp)
80004fc6: f7d6 sd s5,488(sp)
80004fc8: f3da sd s6,480(sp)
80004fca: efde sd s7,472(sp)
80004fcc: ebe2 sd s8,464(sp)
80004fce: e7e6 sd s9,456(sp)
80004fd0: e3ea sd s10,448(sp)
80004fd2: ff6e sd s11,440(sp)
80004fd4: 1400 addi s0,sp,544
80004fd6: 892a mv s2,a0
80004fd8: dea43423 sd a0,-536(s0)
80004fdc: deb43823 sd a1,-528(s0)
uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
struct elfhdr elf;
struct inode *ip;
struct proghdr ph;
pagetable_t pagetable = 0, oldpagetable;
struct proc *p = myproc();
80004fe0: ffffd097 auipc ra,0xffffd
80004fe4: 99e080e7 jalr -1634(ra) # 8000197e <myproc>
80004fe8: 84aa mv s1,a0
begin_op();
80004fea: fffff097 auipc ra,0xfffff
80004fee: 4a6080e7 jalr 1190(ra) # 80004490 <begin_op>
if((ip = namei(path)) == 0){
80004ff2: 854a mv a0,s2
80004ff4: fffff097 auipc ra,0xfffff
80004ff8: 27c080e7 jalr 636(ra) # 80004270 <namei>
80004ffc: c93d beqz a0,80005072 <exec+0xc4>
80004ffe: 8aaa mv s5,a0
end_op();
return -1;
}
ilock(ip);
80005000: fffff097 auipc ra,0xfffff
80005004: aba080e7 jalr -1350(ra) # 80003aba <ilock>
// Check ELF header
if(readi(ip, 0, (uint64)&elf, 0, sizeof(elf)) != sizeof(elf))
80005008: 04000713 li a4,64
8000500c: 4681 li a3,0
8000500e: e4840613 addi a2,s0,-440
80005012: 4581 li a1,0
80005014: 8556 mv a0,s5
80005016: fffff097 auipc ra,0xfffff
8000501a: d58080e7 jalr -680(ra) # 80003d6e <readi>
8000501e: 04000793 li a5,64
80005022: 00f51a63 bne a0,a5,80005036 <exec+0x88>
goto bad;
if(elf.magic != ELF_MAGIC)
80005026: e4842703 lw a4,-440(s0)
8000502a: 464c47b7 lui a5,0x464c4
8000502e: 57f78793 addi a5,a5,1407 # 464c457f <_entry-0x39b3ba81>
80005032: 04f70663 beq a4,a5,8000507e <exec+0xd0>
bad:
if(pagetable)
proc_freepagetable(pagetable, sz);
if(ip){
iunlockput(ip);
80005036: 8556 mv a0,s5
80005038: fffff097 auipc ra,0xfffff
8000503c: ce4080e7 jalr -796(ra) # 80003d1c <iunlockput>
end_op();
80005040: fffff097 auipc ra,0xfffff
80005044: 4d0080e7 jalr 1232(ra) # 80004510 <end_op>
}
return -1;
80005048: 557d li a0,-1
}
8000504a: 21813083 ld ra,536(sp)
8000504e: 21013403 ld s0,528(sp)
80005052: 20813483 ld s1,520(sp)
80005056: 20013903 ld s2,512(sp)
8000505a: 79fe ld s3,504(sp)
8000505c: 7a5e ld s4,496(sp)
8000505e: 7abe ld s5,488(sp)
80005060: 7b1e ld s6,480(sp)
80005062: 6bfe ld s7,472(sp)
80005064: 6c5e ld s8,464(sp)
80005066: 6cbe ld s9,456(sp)
80005068: 6d1e ld s10,448(sp)
8000506a: 7dfa ld s11,440(sp)
8000506c: 22010113 addi sp,sp,544
80005070: 8082 ret
end_op();
80005072: fffff097 auipc ra,0xfffff
80005076: 49e080e7 jalr 1182(ra) # 80004510 <end_op>
return -1;
8000507a: 557d li a0,-1
8000507c: b7f9 j 8000504a <exec+0x9c>
if((pagetable = proc_pagetable(p)) == 0)
8000507e: 8526 mv a0,s1
80005080: ffffd097 auipc ra,0xffffd
80005084: 9c2080e7 jalr -1598(ra) # 80001a42 <proc_pagetable>
80005088: 8b2a mv s6,a0
8000508a: d555 beqz a0,80005036 <exec+0x88>
for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
8000508c: e6842783 lw a5,-408(s0)
80005090: e8045703 lhu a4,-384(s0)
80005094: c735 beqz a4,80005100 <exec+0x152>
uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
80005096: 4481 li s1,0
for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
80005098: e0043423 sd zero,-504(s0)
if(ph.vaddr % PGSIZE != 0)
8000509c: 6a05 lui s4,0x1
8000509e: fffa0713 addi a4,s4,-1 # fff <_entry-0x7ffff001>
800050a2: dee43023 sd a4,-544(s0)
uint64 pa;
if((va % PGSIZE) != 0)
panic("loadseg: va must be page aligned");
for(i = 0; i < sz; i += PGSIZE){
800050a6: 6d85 lui s11,0x1
800050a8: 7d7d lui s10,0xfffff
800050aa: ac1d j 800052e0 <exec+0x332>
pa = walkaddr(pagetable, va + i);
if(pa == 0)
panic("loadseg: address should exist");
800050ac: 00003517 auipc a0,0x3
800050b0: 73450513 addi a0,a0,1844 # 800087e0 <syscalls+0x290>
800050b4: ffffb097 auipc ra,0xffffb
800050b8: 476080e7 jalr 1142(ra) # 8000052a <panic>
if(sz - i < PGSIZE)
n = sz - i;
else
n = PGSIZE;
if(readi(ip, 0, (uint64)pa, offset+i, n) != n)
800050bc: 874a mv a4,s2
800050be: 009c86bb addw a3,s9,s1
800050c2: 4581 li a1,0
800050c4: 8556 mv a0,s5
800050c6: fffff097 auipc ra,0xfffff
800050ca: ca8080e7 jalr -856(ra) # 80003d6e <readi>
800050ce: 2501 sext.w a0,a0
800050d0: 1aa91863 bne s2,a0,80005280 <exec+0x2d2>
for(i = 0; i < sz; i += PGSIZE){
800050d4: 009d84bb addw s1,s11,s1
800050d8: 013d09bb addw s3,s10,s3
800050dc: 1f74f263 bgeu s1,s7,800052c0 <exec+0x312>
pa = walkaddr(pagetable, va + i);
800050e0: 02049593 slli a1,s1,0x20
800050e4: 9181 srli a1,a1,0x20
800050e6: 95e2 add a1,a1,s8
800050e8: 855a mv a0,s6
800050ea: ffffc097 auipc ra,0xffffc
800050ee: f62080e7 jalr -158(ra) # 8000104c <walkaddr>
800050f2: 862a mv a2,a0
if(pa == 0)
800050f4: dd45 beqz a0,800050ac <exec+0xfe>
n = PGSIZE;
800050f6: 8952 mv s2,s4
if(sz - i < PGSIZE)
800050f8: fd49f2e3 bgeu s3,s4,800050bc <exec+0x10e>
n = sz - i;
800050fc: 894e mv s2,s3
800050fe: bf7d j 800050bc <exec+0x10e>
uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
80005100: 4481 li s1,0
iunlockput(ip);
80005102: 8556 mv a0,s5
80005104: fffff097 auipc ra,0xfffff
80005108: c18080e7 jalr -1000(ra) # 80003d1c <iunlockput>
end_op();
8000510c: fffff097 auipc ra,0xfffff
80005110: 404080e7 jalr 1028(ra) # 80004510 <end_op>
p = myproc();
80005114: ffffd097 auipc ra,0xffffd
80005118: 86a080e7 jalr -1942(ra) # 8000197e <myproc>
8000511c: 8baa mv s7,a0
uint64 oldsz = p->sz;
8000511e: 08053d03 ld s10,128(a0)
sz = PGROUNDUP(sz);
80005122: 6785 lui a5,0x1
80005124: 17fd addi a5,a5,-1
80005126: 94be add s1,s1,a5
80005128: 77fd lui a5,0xfffff
8000512a: 8fe5 and a5,a5,s1
8000512c: def43c23 sd a5,-520(s0)
if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
80005130: 6609 lui a2,0x2
80005132: 963e add a2,a2,a5
80005134: 85be mv a1,a5
80005136: 855a mv a0,s6
80005138: ffffc097 auipc ra,0xffffc
8000513c: 2b6080e7 jalr 694(ra) # 800013ee <uvmalloc>
80005140: 8c2a mv s8,a0
ip = 0;
80005142: 4a81 li s5,0
if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
80005144: 12050e63 beqz a0,80005280 <exec+0x2d2>
uvmclear(pagetable, sz-2*PGSIZE);
80005148: 75f9 lui a1,0xffffe
8000514a: 95aa add a1,a1,a0
8000514c: 855a mv a0,s6
8000514e: ffffc097 auipc ra,0xffffc
80005152: 4be080e7 jalr 1214(ra) # 8000160c <uvmclear>
stackbase = sp - PGSIZE;
80005156: 7afd lui s5,0xfffff
80005158: 9ae2 add s5,s5,s8
for(argc = 0; argv[argc]; argc++) {
8000515a: df043783 ld a5,-528(s0)
8000515e: 6388 ld a0,0(a5)
80005160: c925 beqz a0,800051d0 <exec+0x222>
80005162: e8840993 addi s3,s0,-376
80005166: f8840c93 addi s9,s0,-120
sp = sz;
8000516a: 8962 mv s2,s8
for(argc = 0; argv[argc]; argc++) {
8000516c: 4481 li s1,0
sp -= strlen(argv[argc]) + 1;
8000516e: ffffc097 auipc ra,0xffffc
80005172: cd4080e7 jalr -812(ra) # 80000e42 <strlen>
80005176: 0015079b addiw a5,a0,1
8000517a: 40f90933 sub s2,s2,a5
sp -= sp % 16; // riscv sp must be 16-byte aligned
8000517e: ff097913 andi s2,s2,-16
if(sp < stackbase)
80005182: 13596363 bltu s2,s5,800052a8 <exec+0x2fa>
if(copyout(pagetable, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
80005186: df043d83 ld s11,-528(s0)
8000518a: 000dba03 ld s4,0(s11) # 1000 <_entry-0x7ffff000>
8000518e: 8552 mv a0,s4
80005190: ffffc097 auipc ra,0xffffc
80005194: cb2080e7 jalr -846(ra) # 80000e42 <strlen>
80005198: 0015069b addiw a3,a0,1
8000519c: 8652 mv a2,s4
8000519e: 85ca mv a1,s2
800051a0: 855a mv a0,s6
800051a2: ffffc097 auipc ra,0xffffc
800051a6: 49c080e7 jalr 1180(ra) # 8000163e <copyout>
800051aa: 10054363 bltz a0,800052b0 <exec+0x302>
ustack[argc] = sp;
800051ae: 0129b023 sd s2,0(s3)
for(argc = 0; argv[argc]; argc++) {
800051b2: 0485 addi s1,s1,1
800051b4: 008d8793 addi a5,s11,8
800051b8: def43823 sd a5,-528(s0)
800051bc: 008db503 ld a0,8(s11)
800051c0: c911 beqz a0,800051d4 <exec+0x226>
if(argc >= MAXARG)
800051c2: 09a1 addi s3,s3,8
800051c4: fb3c95e3 bne s9,s3,8000516e <exec+0x1c0>
sz = sz1;
800051c8: df843c23 sd s8,-520(s0)
ip = 0;
800051cc: 4a81 li s5,0
800051ce: a84d j 80005280 <exec+0x2d2>
sp = sz;
800051d0: 8962 mv s2,s8
for(argc = 0; argv[argc]; argc++) {
800051d2: 4481 li s1,0
ustack[argc] = 0;
800051d4: 00349793 slli a5,s1,0x3
800051d8: f9040713 addi a4,s0,-112
800051dc: 97ba add a5,a5,a4
800051de: ee07bc23 sd zero,-264(a5) # ffffffffffffeef8 <end+0xffffffff7ffd7ef8>
sp -= (argc+1) * sizeof(uint64);
800051e2: 00148693 addi a3,s1,1
800051e6: 068e slli a3,a3,0x3
800051e8: 40d90933 sub s2,s2,a3
sp -= sp % 16;
800051ec: ff097913 andi s2,s2,-16
if(sp < stackbase)
800051f0: 01597663 bgeu s2,s5,800051fc <exec+0x24e>
sz = sz1;
800051f4: df843c23 sd s8,-520(s0)
ip = 0;
800051f8: 4a81 li s5,0
800051fa: a059 j 80005280 <exec+0x2d2>
if(copyout(pagetable, sp, (char *)ustack, (argc+1)*sizeof(uint64)) < 0)
800051fc: e8840613 addi a2,s0,-376
80005200: 85ca mv a1,s2
80005202: 855a mv a0,s6
80005204: ffffc097 auipc ra,0xffffc
80005208: 43a080e7 jalr 1082(ra) # 8000163e <copyout>
8000520c: 0a054663 bltz a0,800052b8 <exec+0x30a>
p->trapframe->a1 = sp;
80005210: 090bb783 ld a5,144(s7) # 1090 <_entry-0x7fffef70>
80005214: 0727bc23 sd s2,120(a5)
for(last=s=path; *s; s++)
80005218: de843783 ld a5,-536(s0)
8000521c: 0007c703 lbu a4,0(a5)
80005220: cf11 beqz a4,8000523c <exec+0x28e>
80005222: 0785 addi a5,a5,1
if(*s == '/')
80005224: 02f00693 li a3,47
80005228: a039 j 80005236 <exec+0x288>
last = s+1;
8000522a: def43423 sd a5,-536(s0)
for(last=s=path; *s; s++)
8000522e: 0785 addi a5,a5,1
80005230: fff7c703 lbu a4,-1(a5)
80005234: c701 beqz a4,8000523c <exec+0x28e>
if(*s == '/')
80005236: fed71ce3 bne a4,a3,8000522e <exec+0x280>
8000523a: bfc5 j 8000522a <exec+0x27c>
safestrcpy(p->name, last, sizeof(p->name));
8000523c: 4641 li a2,16
8000523e: de843583 ld a1,-536(s0)
80005242: 190b8513 addi a0,s7,400
80005246: ffffc097 auipc ra,0xffffc
8000524a: bca080e7 jalr -1078(ra) # 80000e10 <safestrcpy>
oldpagetable = p->pagetable;
8000524e: 088bb503 ld a0,136(s7)
p->pagetable = pagetable;
80005252: 096bb423 sd s6,136(s7)
p->sz = sz;
80005256: 098bb023 sd s8,128(s7)
p->trapframe->epc = elf.entry; // initial program counter = main
8000525a: 090bb783 ld a5,144(s7)
8000525e: e6043703 ld a4,-416(s0)
80005262: ef98 sd a4,24(a5)
p->trapframe->sp = sp; // initial stack pointer
80005264: 090bb783 ld a5,144(s7)
80005268: 0327b823 sd s2,48(a5)
proc_freepagetable(oldpagetable, oldsz);
8000526c: 85ea mv a1,s10
8000526e: ffffd097 auipc ra,0xffffd
80005272: 870080e7 jalr -1936(ra) # 80001ade <proc_freepagetable>
return argc; // this ends up in a0, the first argument to main(argc, argv)
80005276: 0004851b sext.w a0,s1
8000527a: bbc1 j 8000504a <exec+0x9c>
8000527c: de943c23 sd s1,-520(s0)
proc_freepagetable(pagetable, sz);
80005280: df843583 ld a1,-520(s0)
80005284: 855a mv a0,s6
80005286: ffffd097 auipc ra,0xffffd
8000528a: 858080e7 jalr -1960(ra) # 80001ade <proc_freepagetable>
if(ip){
8000528e: da0a94e3 bnez s5,80005036 <exec+0x88>
return -1;
80005292: 557d li a0,-1
80005294: bb5d j 8000504a <exec+0x9c>
80005296: de943c23 sd s1,-520(s0)
8000529a: b7dd j 80005280 <exec+0x2d2>
8000529c: de943c23 sd s1,-520(s0)
800052a0: b7c5 j 80005280 <exec+0x2d2>
800052a2: de943c23 sd s1,-520(s0)
800052a6: bfe9 j 80005280 <exec+0x2d2>
sz = sz1;
800052a8: df843c23 sd s8,-520(s0)
ip = 0;
800052ac: 4a81 li s5,0
800052ae: bfc9 j 80005280 <exec+0x2d2>
sz = sz1;
800052b0: df843c23 sd s8,-520(s0)
ip = 0;
800052b4: 4a81 li s5,0
800052b6: b7e9 j 80005280 <exec+0x2d2>
sz = sz1;
800052b8: df843c23 sd s8,-520(s0)
ip = 0;
800052bc: 4a81 li s5,0
800052be: b7c9 j 80005280 <exec+0x2d2>
if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
800052c0: df843483 ld s1,-520(s0)
for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
800052c4: e0843783 ld a5,-504(s0)
800052c8: 0017869b addiw a3,a5,1
800052cc: e0d43423 sd a3,-504(s0)
800052d0: e0043783 ld a5,-512(s0)
800052d4: 0387879b addiw a5,a5,56
800052d8: e8045703 lhu a4,-384(s0)
800052dc: e2e6d3e3 bge a3,a4,80005102 <exec+0x154>
if(readi(ip, 0, (uint64)&ph, off, sizeof(ph)) != sizeof(ph))
800052e0: 2781 sext.w a5,a5
800052e2: e0f43023 sd a5,-512(s0)
800052e6: 03800713 li a4,56
800052ea: 86be mv a3,a5
800052ec: e1040613 addi a2,s0,-496
800052f0: 4581 li a1,0
800052f2: 8556 mv a0,s5
800052f4: fffff097 auipc ra,0xfffff
800052f8: a7a080e7 jalr -1414(ra) # 80003d6e <readi>
800052fc: 03800793 li a5,56
80005300: f6f51ee3 bne a0,a5,8000527c <exec+0x2ce>
if(ph.type != ELF_PROG_LOAD)
80005304: e1042783 lw a5,-496(s0)
80005308: 4705 li a4,1
8000530a: fae79de3 bne a5,a4,800052c4 <exec+0x316>
if(ph.memsz < ph.filesz)
8000530e: e3843603 ld a2,-456(s0)
80005312: e3043783 ld a5,-464(s0)
80005316: f8f660e3 bltu a2,a5,80005296 <exec+0x2e8>
if(ph.vaddr + ph.memsz < ph.vaddr)
8000531a: e2043783 ld a5,-480(s0)
8000531e: 963e add a2,a2,a5
80005320: f6f66ee3 bltu a2,a5,8000529c <exec+0x2ee>
if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
80005324: 85a6 mv a1,s1
80005326: 855a mv a0,s6
80005328: ffffc097 auipc ra,0xffffc
8000532c: 0c6080e7 jalr 198(ra) # 800013ee <uvmalloc>
80005330: dea43c23 sd a0,-520(s0)
80005334: d53d beqz a0,800052a2 <exec+0x2f4>
if(ph.vaddr % PGSIZE != 0)
80005336: e2043c03 ld s8,-480(s0)
8000533a: de043783 ld a5,-544(s0)
8000533e: 00fc77b3 and a5,s8,a5
80005342: ff9d bnez a5,80005280 <exec+0x2d2>
if(loadseg(pagetable, ph.vaddr, ip, ph.off, ph.filesz) < 0)
80005344: e1842c83 lw s9,-488(s0)
80005348: e3042b83 lw s7,-464(s0)
for(i = 0; i < sz; i += PGSIZE){
8000534c: f60b8ae3 beqz s7,800052c0 <exec+0x312>
80005350: 89de mv s3,s7
80005352: 4481 li s1,0
80005354: b371 j 800050e0 <exec+0x132>
0000000080005356 <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)
{
80005356: 7179 addi sp,sp,-48
80005358: f406 sd ra,40(sp)
8000535a: f022 sd s0,32(sp)
8000535c: ec26 sd s1,24(sp)
8000535e: e84a sd s2,16(sp)
80005360: 1800 addi s0,sp,48
80005362: 892e mv s2,a1
80005364: 84b2 mv s1,a2
int fd;
struct file *f;
if(argint(n, &fd) < 0)
80005366: fdc40593 addi a1,s0,-36
8000536a: ffffe097 auipc ra,0xffffe
8000536e: a5c080e7 jalr -1444(ra) # 80002dc6 <argint>
80005372: 04054063 bltz a0,800053b2 <argfd+0x5c>
return -1;
if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
80005376: fdc42703 lw a4,-36(s0)
8000537a: 47bd li a5,15
8000537c: 02e7ed63 bltu a5,a4,800053b6 <argfd+0x60>
80005380: ffffc097 auipc ra,0xffffc
80005384: 5fe080e7 jalr 1534(ra) # 8000197e <myproc>
80005388: fdc42703 lw a4,-36(s0)
8000538c: 02070793 addi a5,a4,32
80005390: 078e slli a5,a5,0x3
80005392: 953e add a0,a0,a5
80005394: 651c ld a5,8(a0)
80005396: c395 beqz a5,800053ba <argfd+0x64>
return -1;
if(pfd)
80005398: 00090463 beqz s2,800053a0 <argfd+0x4a>
*pfd = fd;
8000539c: 00e92023 sw a4,0(s2)
if(pf)
*pf = f;
return 0;
800053a0: 4501 li a0,0
if(pf)
800053a2: c091 beqz s1,800053a6 <argfd+0x50>
*pf = f;
800053a4: e09c sd a5,0(s1)
}
800053a6: 70a2 ld ra,40(sp)
800053a8: 7402 ld s0,32(sp)
800053aa: 64e2 ld s1,24(sp)
800053ac: 6942 ld s2,16(sp)
800053ae: 6145 addi sp,sp,48
800053b0: 8082 ret
return -1;
800053b2: 557d li a0,-1
800053b4: bfcd j 800053a6 <argfd+0x50>
return -1;
800053b6: 557d li a0,-1
800053b8: b7fd j 800053a6 <argfd+0x50>
800053ba: 557d li a0,-1
800053bc: b7ed j 800053a6 <argfd+0x50>
00000000800053be <fdalloc>:
// Allocate a file descriptor for the given file.
// Takes over file reference from caller on success.
static int
fdalloc(struct file *f)
{
800053be: 1101 addi sp,sp,-32
800053c0: ec06 sd ra,24(sp)
800053c2: e822 sd s0,16(sp)
800053c4: e426 sd s1,8(sp)
800053c6: 1000 addi s0,sp,32
800053c8: 84aa mv s1,a0
int fd;
struct proc *p = myproc();
800053ca: ffffc097 auipc ra,0xffffc
800053ce: 5b4080e7 jalr 1460(ra) # 8000197e <myproc>
800053d2: 862a mv a2,a0
for(fd = 0; fd < NOFILE; fd++){
800053d4: 10850793 addi a5,a0,264
800053d8: 4501 li a0,0
800053da: 46c1 li a3,16
if(p->ofile[fd] == 0){
800053dc: 6398 ld a4,0(a5)
800053de: cb19 beqz a4,800053f4 <fdalloc+0x36>
for(fd = 0; fd < NOFILE; fd++){
800053e0: 2505 addiw a0,a0,1
800053e2: 07a1 addi a5,a5,8
800053e4: fed51ce3 bne a0,a3,800053dc <fdalloc+0x1e>
p->ofile[fd] = f;
return fd;
}
}
return -1;
800053e8: 557d li a0,-1
}
800053ea: 60e2 ld ra,24(sp)
800053ec: 6442 ld s0,16(sp)
800053ee: 64a2 ld s1,8(sp)
800053f0: 6105 addi sp,sp,32
800053f2: 8082 ret
p->ofile[fd] = f;
800053f4: 02050793 addi a5,a0,32
800053f8: 078e slli a5,a5,0x3
800053fa: 963e add a2,a2,a5
800053fc: e604 sd s1,8(a2)
return fd;
800053fe: b7f5 j 800053ea <fdalloc+0x2c>
0000000080005400 <create>:
return -1;
}
static struct inode*
create(char *path, short type, short major, short minor)
{
80005400: 715d addi sp,sp,-80
80005402: e486 sd ra,72(sp)
80005404: e0a2 sd s0,64(sp)
80005406: fc26 sd s1,56(sp)
80005408: f84a sd s2,48(sp)
8000540a: f44e sd s3,40(sp)
8000540c: f052 sd s4,32(sp)
8000540e: ec56 sd s5,24(sp)
80005410: 0880 addi s0,sp,80
80005412: 89ae mv s3,a1
80005414: 8ab2 mv s5,a2
80005416: 8a36 mv s4,a3
struct inode *ip, *dp;
char name[DIRSIZ];
if((dp = nameiparent(path, name)) == 0)
80005418: fb040593 addi a1,s0,-80
8000541c: fffff097 auipc ra,0xfffff
80005420: e72080e7 jalr -398(ra) # 8000428e <nameiparent>
80005424: 892a mv s2,a0
80005426: 12050e63 beqz a0,80005562 <create+0x162>
return 0;
ilock(dp);
8000542a: ffffe097 auipc ra,0xffffe
8000542e: 690080e7 jalr 1680(ra) # 80003aba <ilock>
if((ip = dirlookup(dp, name, 0)) != 0){
80005432: 4601 li a2,0
80005434: fb040593 addi a1,s0,-80
80005438: 854a mv a0,s2
8000543a: fffff097 auipc ra,0xfffff
8000543e: b64080e7 jalr -1180(ra) # 80003f9e <dirlookup>
80005442: 84aa mv s1,a0
80005444: c921 beqz a0,80005494 <create+0x94>
iunlockput(dp);
80005446: 854a mv a0,s2
80005448: fffff097 auipc ra,0xfffff
8000544c: 8d4080e7 jalr -1836(ra) # 80003d1c <iunlockput>
ilock(ip);
80005450: 8526 mv a0,s1
80005452: ffffe097 auipc ra,0xffffe
80005456: 668080e7 jalr 1640(ra) # 80003aba <ilock>
if(type == T_FILE && (ip->type == T_FILE || ip->type == T_DEVICE))
8000545a: 2981 sext.w s3,s3
8000545c: 4789 li a5,2
8000545e: 02f99463 bne s3,a5,80005486 <create+0x86>
80005462: 0444d783 lhu a5,68(s1)
80005466: 37f9 addiw a5,a5,-2
80005468: 17c2 slli a5,a5,0x30
8000546a: 93c1 srli a5,a5,0x30
8000546c: 4705 li a4,1
8000546e: 00f76c63 bltu a4,a5,80005486 <create+0x86>
panic("create: dirlink");
iunlockput(dp);
return ip;
}
80005472: 8526 mv a0,s1
80005474: 60a6 ld ra,72(sp)
80005476: 6406 ld s0,64(sp)
80005478: 74e2 ld s1,56(sp)
8000547a: 7942 ld s2,48(sp)
8000547c: 79a2 ld s3,40(sp)
8000547e: 7a02 ld s4,32(sp)
80005480: 6ae2 ld s5,24(sp)
80005482: 6161 addi sp,sp,80
80005484: 8082 ret
iunlockput(ip);
80005486: 8526 mv a0,s1
80005488: fffff097 auipc ra,0xfffff
8000548c: 894080e7 jalr -1900(ra) # 80003d1c <iunlockput>
return 0;
80005490: 4481 li s1,0
80005492: b7c5 j 80005472 <create+0x72>
if((ip = ialloc(dp->dev, type)) == 0)
80005494: 85ce mv a1,s3
80005496: 00092503 lw a0,0(s2)
8000549a: ffffe097 auipc ra,0xffffe
8000549e: 488080e7 jalr 1160(ra) # 80003922 <ialloc>
800054a2: 84aa mv s1,a0
800054a4: c521 beqz a0,800054ec <create+0xec>
ilock(ip);
800054a6: ffffe097 auipc ra,0xffffe
800054aa: 614080e7 jalr 1556(ra) # 80003aba <ilock>
ip->major = major;
800054ae: 05549323 sh s5,70(s1)
ip->minor = minor;
800054b2: 05449423 sh s4,72(s1)
ip->nlink = 1;
800054b6: 4a05 li s4,1
800054b8: 05449523 sh s4,74(s1)
iupdate(ip);
800054bc: 8526 mv a0,s1
800054be: ffffe097 auipc ra,0xffffe
800054c2: 532080e7 jalr 1330(ra) # 800039f0 <iupdate>
if(type == T_DIR){ // Create . and .. entries.
800054c6: 2981 sext.w s3,s3
800054c8: 03498a63 beq s3,s4,800054fc <create+0xfc>
if(dirlink(dp, name, ip->inum) < 0)
800054cc: 40d0 lw a2,4(s1)
800054ce: fb040593 addi a1,s0,-80
800054d2: 854a mv a0,s2
800054d4: fffff097 auipc ra,0xfffff
800054d8: cda080e7 jalr -806(ra) # 800041ae <dirlink>
800054dc: 06054b63 bltz a0,80005552 <create+0x152>
iunlockput(dp);
800054e0: 854a mv a0,s2
800054e2: fffff097 auipc ra,0xfffff
800054e6: 83a080e7 jalr -1990(ra) # 80003d1c <iunlockput>
return ip;
800054ea: b761 j 80005472 <create+0x72>
panic("create: ialloc");
800054ec: 00003517 auipc a0,0x3
800054f0: 31450513 addi a0,a0,788 # 80008800 <syscalls+0x2b0>
800054f4: ffffb097 auipc ra,0xffffb
800054f8: 036080e7 jalr 54(ra) # 8000052a <panic>
dp->nlink++; // for ".."
800054fc: 04a95783 lhu a5,74(s2)
80005500: 2785 addiw a5,a5,1
80005502: 04f91523 sh a5,74(s2)
iupdate(dp);
80005506: 854a mv a0,s2
80005508: ffffe097 auipc ra,0xffffe
8000550c: 4e8080e7 jalr 1256(ra) # 800039f0 <iupdate>
if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
80005510: 40d0 lw a2,4(s1)
80005512: 00003597 auipc a1,0x3
80005516: 2fe58593 addi a1,a1,766 # 80008810 <syscalls+0x2c0>
8000551a: 8526 mv a0,s1
8000551c: fffff097 auipc ra,0xfffff
80005520: c92080e7 jalr -878(ra) # 800041ae <dirlink>
80005524: 00054f63 bltz a0,80005542 <create+0x142>
80005528: 00492603 lw a2,4(s2)
8000552c: 00003597 auipc a1,0x3
80005530: 2ec58593 addi a1,a1,748 # 80008818 <syscalls+0x2c8>
80005534: 8526 mv a0,s1
80005536: fffff097 auipc ra,0xfffff
8000553a: c78080e7 jalr -904(ra) # 800041ae <dirlink>
8000553e: f80557e3 bgez a0,800054cc <create+0xcc>
panic("create dots");
80005542: 00003517 auipc a0,0x3
80005546: 2de50513 addi a0,a0,734 # 80008820 <syscalls+0x2d0>
8000554a: ffffb097 auipc ra,0xffffb
8000554e: fe0080e7 jalr -32(ra) # 8000052a <panic>
panic("create: dirlink");
80005552: 00003517 auipc a0,0x3
80005556: 2de50513 addi a0,a0,734 # 80008830 <syscalls+0x2e0>
8000555a: ffffb097 auipc ra,0xffffb
8000555e: fd0080e7 jalr -48(ra) # 8000052a <panic>
return 0;
80005562: 84aa mv s1,a0
80005564: b739 j 80005472 <create+0x72>
0000000080005566 <sys_dup>:
{
80005566: 7179 addi sp,sp,-48
80005568: f406 sd ra,40(sp)
8000556a: f022 sd s0,32(sp)
8000556c: ec26 sd s1,24(sp)
8000556e: 1800 addi s0,sp,48
if(argfd(0, 0, &f) < 0)
80005570: fd840613 addi a2,s0,-40
80005574: 4581 li a1,0
80005576: 4501 li a0,0
80005578: 00000097 auipc ra,0x0
8000557c: dde080e7 jalr -546(ra) # 80005356 <argfd>
return -1;
80005580: 57fd li a5,-1
if(argfd(0, 0, &f) < 0)
80005582: 02054363 bltz a0,800055a8 <sys_dup+0x42>
if((fd=fdalloc(f)) < 0)
80005586: fd843503 ld a0,-40(s0)
8000558a: 00000097 auipc ra,0x0
8000558e: e34080e7 jalr -460(ra) # 800053be <fdalloc>
80005592: 84aa mv s1,a0
return -1;
80005594: 57fd li a5,-1
if((fd=fdalloc(f)) < 0)
80005596: 00054963 bltz a0,800055a8 <sys_dup+0x42>
filedup(f);
8000559a: fd843503 ld a0,-40(s0)
8000559e: fffff097 auipc ra,0xfffff
800055a2: 36c080e7 jalr 876(ra) # 8000490a <filedup>
return fd;
800055a6: 87a6 mv a5,s1
}
800055a8: 853e mv a0,a5
800055aa: 70a2 ld ra,40(sp)
800055ac: 7402 ld s0,32(sp)
800055ae: 64e2 ld s1,24(sp)
800055b0: 6145 addi sp,sp,48
800055b2: 8082 ret
00000000800055b4 <sys_read>:
{
800055b4: 7179 addi sp,sp,-48
800055b6: f406 sd ra,40(sp)
800055b8: f022 sd s0,32(sp)
800055ba: 1800 addi s0,sp,48
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
800055bc: fe840613 addi a2,s0,-24
800055c0: 4581 li a1,0
800055c2: 4501 li a0,0
800055c4: 00000097 auipc ra,0x0
800055c8: d92080e7 jalr -622(ra) # 80005356 <argfd>
return -1;
800055cc: 57fd li a5,-1
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
800055ce: 04054163 bltz a0,80005610 <sys_read+0x5c>
800055d2: fe440593 addi a1,s0,-28
800055d6: 4509 li a0,2
800055d8: ffffd097 auipc ra,0xffffd
800055dc: 7ee080e7 jalr 2030(ra) # 80002dc6 <argint>
return -1;
800055e0: 57fd li a5,-1
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
800055e2: 02054763 bltz a0,80005610 <sys_read+0x5c>
800055e6: fd840593 addi a1,s0,-40
800055ea: 4505 li a0,1
800055ec: ffffd097 auipc ra,0xffffd
800055f0: 7fc080e7 jalr 2044(ra) # 80002de8 <argaddr>
return -1;
800055f4: 57fd li a5,-1
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
800055f6: 00054d63 bltz a0,80005610 <sys_read+0x5c>
return fileread(f, p, n);
800055fa: fe442603 lw a2,-28(s0)
800055fe: fd843583 ld a1,-40(s0)
80005602: fe843503 ld a0,-24(s0)
80005606: fffff097 auipc ra,0xfffff
8000560a: 490080e7 jalr 1168(ra) # 80004a96 <fileread>
8000560e: 87aa mv a5,a0
}
80005610: 853e mv a0,a5
80005612: 70a2 ld ra,40(sp)
80005614: 7402 ld s0,32(sp)
80005616: 6145 addi sp,sp,48
80005618: 8082 ret
000000008000561a <sys_write>:
{
8000561a: 7179 addi sp,sp,-48
8000561c: f406 sd ra,40(sp)
8000561e: f022 sd s0,32(sp)
80005620: 1800 addi s0,sp,48
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
80005622: fe840613 addi a2,s0,-24
80005626: 4581 li a1,0
80005628: 4501 li a0,0
8000562a: 00000097 auipc ra,0x0
8000562e: d2c080e7 jalr -724(ra) # 80005356 <argfd>
return -1;
80005632: 57fd li a5,-1
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
80005634: 04054163 bltz a0,80005676 <sys_write+0x5c>
80005638: fe440593 addi a1,s0,-28
8000563c: 4509 li a0,2
8000563e: ffffd097 auipc ra,0xffffd
80005642: 788080e7 jalr 1928(ra) # 80002dc6 <argint>
return -1;
80005646: 57fd li a5,-1
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
80005648: 02054763 bltz a0,80005676 <sys_write+0x5c>
8000564c: fd840593 addi a1,s0,-40
80005650: 4505 li a0,1
80005652: ffffd097 auipc ra,0xffffd
80005656: 796080e7 jalr 1942(ra) # 80002de8 <argaddr>
return -1;
8000565a: 57fd li a5,-1
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
8000565c: 00054d63 bltz a0,80005676 <sys_write+0x5c>
return filewrite(f, p, n);
80005660: fe442603 lw a2,-28(s0)
80005664: fd843583 ld a1,-40(s0)
80005668: fe843503 ld a0,-24(s0)
8000566c: fffff097 auipc ra,0xfffff
80005670: 4ec080e7 jalr 1260(ra) # 80004b58 <filewrite>
80005674: 87aa mv a5,a0
}
80005676: 853e mv a0,a5
80005678: 70a2 ld ra,40(sp)
8000567a: 7402 ld s0,32(sp)
8000567c: 6145 addi sp,sp,48
8000567e: 8082 ret
0000000080005680 <sys_close>:
{
80005680: 1101 addi sp,sp,-32
80005682: ec06 sd ra,24(sp)
80005684: e822 sd s0,16(sp)
80005686: 1000 addi s0,sp,32
if(argfd(0, &fd, &f) < 0)
80005688: fe040613 addi a2,s0,-32
8000568c: fec40593 addi a1,s0,-20
80005690: 4501 li a0,0
80005692: 00000097 auipc ra,0x0
80005696: cc4080e7 jalr -828(ra) # 80005356 <argfd>
return -1;
8000569a: 57fd li a5,-1
if(argfd(0, &fd, &f) < 0)
8000569c: 02054563 bltz a0,800056c6 <sys_close+0x46>
myproc()->ofile[fd] = 0;
800056a0: ffffc097 auipc ra,0xffffc
800056a4: 2de080e7 jalr 734(ra) # 8000197e <myproc>
800056a8: fec42783 lw a5,-20(s0)
800056ac: 02078793 addi a5,a5,32
800056b0: 078e slli a5,a5,0x3
800056b2: 97aa add a5,a5,a0
800056b4: 0007b423 sd zero,8(a5)
fileclose(f);
800056b8: fe043503 ld a0,-32(s0)
800056bc: fffff097 auipc ra,0xfffff
800056c0: 2a0080e7 jalr 672(ra) # 8000495c <fileclose>
return 0;
800056c4: 4781 li a5,0
}
800056c6: 853e mv a0,a5
800056c8: 60e2 ld ra,24(sp)
800056ca: 6442 ld s0,16(sp)
800056cc: 6105 addi sp,sp,32
800056ce: 8082 ret
00000000800056d0 <sys_fstat>:
{
800056d0: 1101 addi sp,sp,-32
800056d2: ec06 sd ra,24(sp)
800056d4: e822 sd s0,16(sp)
800056d6: 1000 addi s0,sp,32
if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
800056d8: fe840613 addi a2,s0,-24
800056dc: 4581 li a1,0
800056de: 4501 li a0,0
800056e0: 00000097 auipc ra,0x0
800056e4: c76080e7 jalr -906(ra) # 80005356 <argfd>
return -1;
800056e8: 57fd li a5,-1
if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
800056ea: 02054563 bltz a0,80005714 <sys_fstat+0x44>
800056ee: fe040593 addi a1,s0,-32
800056f2: 4505 li a0,1
800056f4: ffffd097 auipc ra,0xffffd
800056f8: 6f4080e7 jalr 1780(ra) # 80002de8 <argaddr>
return -1;
800056fc: 57fd li a5,-1
if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
800056fe: 00054b63 bltz a0,80005714 <sys_fstat+0x44>
return filestat(f, st);
80005702: fe043583 ld a1,-32(s0)
80005706: fe843503 ld a0,-24(s0)
8000570a: fffff097 auipc ra,0xfffff
8000570e: 31a080e7 jalr 794(ra) # 80004a24 <filestat>
80005712: 87aa mv a5,a0
}
80005714: 853e mv a0,a5
80005716: 60e2 ld ra,24(sp)
80005718: 6442 ld s0,16(sp)
8000571a: 6105 addi sp,sp,32
8000571c: 8082 ret
000000008000571e <sys_link>:
{
8000571e: 7169 addi sp,sp,-304
80005720: f606 sd ra,296(sp)
80005722: f222 sd s0,288(sp)
80005724: ee26 sd s1,280(sp)
80005726: ea4a sd s2,272(sp)
80005728: 1a00 addi s0,sp,304
if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
8000572a: 08000613 li a2,128
8000572e: ed040593 addi a1,s0,-304
80005732: 4501 li a0,0
80005734: ffffd097 auipc ra,0xffffd
80005738: 6d6080e7 jalr 1750(ra) # 80002e0a <argstr>
return -1;
8000573c: 57fd li a5,-1
if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
8000573e: 10054e63 bltz a0,8000585a <sys_link+0x13c>
80005742: 08000613 li a2,128
80005746: f5040593 addi a1,s0,-176
8000574a: 4505 li a0,1
8000574c: ffffd097 auipc ra,0xffffd
80005750: 6be080e7 jalr 1726(ra) # 80002e0a <argstr>
return -1;
80005754: 57fd li a5,-1
if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
80005756: 10054263 bltz a0,8000585a <sys_link+0x13c>
begin_op();
8000575a: fffff097 auipc ra,0xfffff
8000575e: d36080e7 jalr -714(ra) # 80004490 <begin_op>
if((ip = namei(old)) == 0){
80005762: ed040513 addi a0,s0,-304
80005766: fffff097 auipc ra,0xfffff
8000576a: b0a080e7 jalr -1270(ra) # 80004270 <namei>
8000576e: 84aa mv s1,a0
80005770: c551 beqz a0,800057fc <sys_link+0xde>
ilock(ip);
80005772: ffffe097 auipc ra,0xffffe
80005776: 348080e7 jalr 840(ra) # 80003aba <ilock>
if(ip->type == T_DIR){
8000577a: 04449703 lh a4,68(s1)
8000577e: 4785 li a5,1
80005780: 08f70463 beq a4,a5,80005808 <sys_link+0xea>
ip->nlink++;
80005784: 04a4d783 lhu a5,74(s1)
80005788: 2785 addiw a5,a5,1
8000578a: 04f49523 sh a5,74(s1)
iupdate(ip);
8000578e: 8526 mv a0,s1
80005790: ffffe097 auipc ra,0xffffe
80005794: 260080e7 jalr 608(ra) # 800039f0 <iupdate>
iunlock(ip);
80005798: 8526 mv a0,s1
8000579a: ffffe097 auipc ra,0xffffe
8000579e: 3e2080e7 jalr 994(ra) # 80003b7c <iunlock>
if((dp = nameiparent(new, name)) == 0)
800057a2: fd040593 addi a1,s0,-48
800057a6: f5040513 addi a0,s0,-176
800057aa: fffff097 auipc ra,0xfffff
800057ae: ae4080e7 jalr -1308(ra) # 8000428e <nameiparent>
800057b2: 892a mv s2,a0
800057b4: c935 beqz a0,80005828 <sys_link+0x10a>
ilock(dp);
800057b6: ffffe097 auipc ra,0xffffe
800057ba: 304080e7 jalr 772(ra) # 80003aba <ilock>
if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
800057be: 00092703 lw a4,0(s2)
800057c2: 409c lw a5,0(s1)
800057c4: 04f71d63 bne a4,a5,8000581e <sys_link+0x100>
800057c8: 40d0 lw a2,4(s1)
800057ca: fd040593 addi a1,s0,-48
800057ce: 854a mv a0,s2
800057d0: fffff097 auipc ra,0xfffff
800057d4: 9de080e7 jalr -1570(ra) # 800041ae <dirlink>
800057d8: 04054363 bltz a0,8000581e <sys_link+0x100>
iunlockput(dp);
800057dc: 854a mv a0,s2
800057de: ffffe097 auipc ra,0xffffe
800057e2: 53e080e7 jalr 1342(ra) # 80003d1c <iunlockput>
iput(ip);
800057e6: 8526 mv a0,s1
800057e8: ffffe097 auipc ra,0xffffe
800057ec: 48c080e7 jalr 1164(ra) # 80003c74 <iput>
end_op();
800057f0: fffff097 auipc ra,0xfffff
800057f4: d20080e7 jalr -736(ra) # 80004510 <end_op>
return 0;
800057f8: 4781 li a5,0
800057fa: a085 j 8000585a <sys_link+0x13c>
end_op();
800057fc: fffff097 auipc ra,0xfffff
80005800: d14080e7 jalr -748(ra) # 80004510 <end_op>
return -1;
80005804: 57fd li a5,-1
80005806: a891 j 8000585a <sys_link+0x13c>
iunlockput(ip);
80005808: 8526 mv a0,s1
8000580a: ffffe097 auipc ra,0xffffe
8000580e: 512080e7 jalr 1298(ra) # 80003d1c <iunlockput>
end_op();
80005812: fffff097 auipc ra,0xfffff
80005816: cfe080e7 jalr -770(ra) # 80004510 <end_op>
return -1;
8000581a: 57fd li a5,-1
8000581c: a83d j 8000585a <sys_link+0x13c>
iunlockput(dp);
8000581e: 854a mv a0,s2
80005820: ffffe097 auipc ra,0xffffe
80005824: 4fc080e7 jalr 1276(ra) # 80003d1c <iunlockput>
ilock(ip);
80005828: 8526 mv a0,s1
8000582a: ffffe097 auipc ra,0xffffe
8000582e: 290080e7 jalr 656(ra) # 80003aba <ilock>
ip->nlink--;
80005832: 04a4d783 lhu a5,74(s1)
80005836: 37fd addiw a5,a5,-1
80005838: 04f49523 sh a5,74(s1)
iupdate(ip);
8000583c: 8526 mv a0,s1
8000583e: ffffe097 auipc ra,0xffffe
80005842: 1b2080e7 jalr 434(ra) # 800039f0 <iupdate>
iunlockput(ip);
80005846: 8526 mv a0,s1
80005848: ffffe097 auipc ra,0xffffe
8000584c: 4d4080e7 jalr 1236(ra) # 80003d1c <iunlockput>
end_op();
80005850: fffff097 auipc ra,0xfffff
80005854: cc0080e7 jalr -832(ra) # 80004510 <end_op>
return -1;
80005858: 57fd li a5,-1
}
8000585a: 853e mv a0,a5
8000585c: 70b2 ld ra,296(sp)
8000585e: 7412 ld s0,288(sp)
80005860: 64f2 ld s1,280(sp)
80005862: 6952 ld s2,272(sp)
80005864: 6155 addi sp,sp,304
80005866: 8082 ret
0000000080005868 <sys_unlink>:
{
80005868: 7151 addi sp,sp,-240
8000586a: f586 sd ra,232(sp)
8000586c: f1a2 sd s0,224(sp)
8000586e: eda6 sd s1,216(sp)
80005870: e9ca sd s2,208(sp)
80005872: e5ce sd s3,200(sp)
80005874: 1980 addi s0,sp,240
if(argstr(0, path, MAXPATH) < 0)
80005876: 08000613 li a2,128
8000587a: f3040593 addi a1,s0,-208
8000587e: 4501 li a0,0
80005880: ffffd097 auipc ra,0xffffd
80005884: 58a080e7 jalr 1418(ra) # 80002e0a <argstr>
80005888: 18054163 bltz a0,80005a0a <sys_unlink+0x1a2>
begin_op();
8000588c: fffff097 auipc ra,0xfffff
80005890: c04080e7 jalr -1020(ra) # 80004490 <begin_op>
if((dp = nameiparent(path, name)) == 0){
80005894: fb040593 addi a1,s0,-80
80005898: f3040513 addi a0,s0,-208
8000589c: fffff097 auipc ra,0xfffff
800058a0: 9f2080e7 jalr -1550(ra) # 8000428e <nameiparent>
800058a4: 84aa mv s1,a0
800058a6: c979 beqz a0,8000597c <sys_unlink+0x114>
ilock(dp);
800058a8: ffffe097 auipc ra,0xffffe
800058ac: 212080e7 jalr 530(ra) # 80003aba <ilock>
if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0)
800058b0: 00003597 auipc a1,0x3
800058b4: f6058593 addi a1,a1,-160 # 80008810 <syscalls+0x2c0>
800058b8: fb040513 addi a0,s0,-80
800058bc: ffffe097 auipc ra,0xffffe
800058c0: 6c8080e7 jalr 1736(ra) # 80003f84 <namecmp>
800058c4: 14050a63 beqz a0,80005a18 <sys_unlink+0x1b0>
800058c8: 00003597 auipc a1,0x3
800058cc: f5058593 addi a1,a1,-176 # 80008818 <syscalls+0x2c8>
800058d0: fb040513 addi a0,s0,-80
800058d4: ffffe097 auipc ra,0xffffe
800058d8: 6b0080e7 jalr 1712(ra) # 80003f84 <namecmp>
800058dc: 12050e63 beqz a0,80005a18 <sys_unlink+0x1b0>
if((ip = dirlookup(dp, name, &off)) == 0)
800058e0: f2c40613 addi a2,s0,-212
800058e4: fb040593 addi a1,s0,-80
800058e8: 8526 mv a0,s1
800058ea: ffffe097 auipc ra,0xffffe
800058ee: 6b4080e7 jalr 1716(ra) # 80003f9e <dirlookup>
800058f2: 892a mv s2,a0
800058f4: 12050263 beqz a0,80005a18 <sys_unlink+0x1b0>
ilock(ip);
800058f8: ffffe097 auipc ra,0xffffe
800058fc: 1c2080e7 jalr 450(ra) # 80003aba <ilock>
if(ip->nlink < 1)
80005900: 04a91783 lh a5,74(s2)
80005904: 08f05263 blez a5,80005988 <sys_unlink+0x120>
if(ip->type == T_DIR && !isdirempty(ip)){
80005908: 04491703 lh a4,68(s2)
8000590c: 4785 li a5,1
8000590e: 08f70563 beq a4,a5,80005998 <sys_unlink+0x130>
memset(&de, 0, sizeof(de));
80005912: 4641 li a2,16
80005914: 4581 li a1,0
80005916: fc040513 addi a0,s0,-64
8000591a: ffffb097 auipc ra,0xffffb
8000591e: 3a4080e7 jalr 932(ra) # 80000cbe <memset>
if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
80005922: 4741 li a4,16
80005924: f2c42683 lw a3,-212(s0)
80005928: fc040613 addi a2,s0,-64
8000592c: 4581 li a1,0
8000592e: 8526 mv a0,s1
80005930: ffffe097 auipc ra,0xffffe
80005934: 536080e7 jalr 1334(ra) # 80003e66 <writei>
80005938: 47c1 li a5,16
8000593a: 0af51563 bne a0,a5,800059e4 <sys_unlink+0x17c>
if(ip->type == T_DIR){
8000593e: 04491703 lh a4,68(s2)
80005942: 4785 li a5,1
80005944: 0af70863 beq a4,a5,800059f4 <sys_unlink+0x18c>
iunlockput(dp);
80005948: 8526 mv a0,s1
8000594a: ffffe097 auipc ra,0xffffe
8000594e: 3d2080e7 jalr 978(ra) # 80003d1c <iunlockput>
ip->nlink--;
80005952: 04a95783 lhu a5,74(s2)
80005956: 37fd addiw a5,a5,-1
80005958: 04f91523 sh a5,74(s2)
iupdate(ip);
8000595c: 854a mv a0,s2
8000595e: ffffe097 auipc ra,0xffffe
80005962: 092080e7 jalr 146(ra) # 800039f0 <iupdate>
iunlockput(ip);
80005966: 854a mv a0,s2
80005968: ffffe097 auipc ra,0xffffe
8000596c: 3b4080e7 jalr 948(ra) # 80003d1c <iunlockput>
end_op();
80005970: fffff097 auipc ra,0xfffff
80005974: ba0080e7 jalr -1120(ra) # 80004510 <end_op>
return 0;
80005978: 4501 li a0,0
8000597a: a84d j 80005a2c <sys_unlink+0x1c4>
end_op();
8000597c: fffff097 auipc ra,0xfffff
80005980: b94080e7 jalr -1132(ra) # 80004510 <end_op>
return -1;
80005984: 557d li a0,-1
80005986: a05d j 80005a2c <sys_unlink+0x1c4>
panic("unlink: nlink < 1");
80005988: 00003517 auipc a0,0x3
8000598c: eb850513 addi a0,a0,-328 # 80008840 <syscalls+0x2f0>
80005990: ffffb097 auipc ra,0xffffb
80005994: b9a080e7 jalr -1126(ra) # 8000052a <panic>
for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
80005998: 04c92703 lw a4,76(s2)
8000599c: 02000793 li a5,32
800059a0: f6e7f9e3 bgeu a5,a4,80005912 <sys_unlink+0xaa>
800059a4: 02000993 li s3,32
if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
800059a8: 4741 li a4,16
800059aa: 86ce mv a3,s3
800059ac: f1840613 addi a2,s0,-232
800059b0: 4581 li a1,0
800059b2: 854a mv a0,s2
800059b4: ffffe097 auipc ra,0xffffe
800059b8: 3ba080e7 jalr 954(ra) # 80003d6e <readi>
800059bc: 47c1 li a5,16
800059be: 00f51b63 bne a0,a5,800059d4 <sys_unlink+0x16c>
if(de.inum != 0)
800059c2: f1845783 lhu a5,-232(s0)
800059c6: e7a1 bnez a5,80005a0e <sys_unlink+0x1a6>
for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
800059c8: 29c1 addiw s3,s3,16
800059ca: 04c92783 lw a5,76(s2)
800059ce: fcf9ede3 bltu s3,a5,800059a8 <sys_unlink+0x140>
800059d2: b781 j 80005912 <sys_unlink+0xaa>
panic("isdirempty: readi");
800059d4: 00003517 auipc a0,0x3
800059d8: e8450513 addi a0,a0,-380 # 80008858 <syscalls+0x308>
800059dc: ffffb097 auipc ra,0xffffb
800059e0: b4e080e7 jalr -1202(ra) # 8000052a <panic>
panic("unlink: writei");
800059e4: 00003517 auipc a0,0x3
800059e8: e8c50513 addi a0,a0,-372 # 80008870 <syscalls+0x320>
800059ec: ffffb097 auipc ra,0xffffb
800059f0: b3e080e7 jalr -1218(ra) # 8000052a <panic>
dp->nlink--;
800059f4: 04a4d783 lhu a5,74(s1)
800059f8: 37fd addiw a5,a5,-1
800059fa: 04f49523 sh a5,74(s1)
iupdate(dp);
800059fe: 8526 mv a0,s1
80005a00: ffffe097 auipc ra,0xffffe
80005a04: ff0080e7 jalr -16(ra) # 800039f0 <iupdate>
80005a08: b781 j 80005948 <sys_unlink+0xe0>
return -1;
80005a0a: 557d li a0,-1
80005a0c: a005 j 80005a2c <sys_unlink+0x1c4>
iunlockput(ip);
80005a0e: 854a mv a0,s2
80005a10: ffffe097 auipc ra,0xffffe
80005a14: 30c080e7 jalr 780(ra) # 80003d1c <iunlockput>
iunlockput(dp);
80005a18: 8526 mv a0,s1
80005a1a: ffffe097 auipc ra,0xffffe
80005a1e: 302080e7 jalr 770(ra) # 80003d1c <iunlockput>
end_op();
80005a22: fffff097 auipc ra,0xfffff
80005a26: aee080e7 jalr -1298(ra) # 80004510 <end_op>
return -1;
80005a2a: 557d li a0,-1
}
80005a2c: 70ae ld ra,232(sp)
80005a2e: 740e ld s0,224(sp)
80005a30: 64ee ld s1,216(sp)
80005a32: 694e ld s2,208(sp)
80005a34: 69ae ld s3,200(sp)
80005a36: 616d addi sp,sp,240
80005a38: 8082 ret
0000000080005a3a <sys_open>:
uint64
sys_open(void)
{
80005a3a: 7131 addi sp,sp,-192
80005a3c: fd06 sd ra,184(sp)
80005a3e: f922 sd s0,176(sp)
80005a40: f526 sd s1,168(sp)
80005a42: f14a sd s2,160(sp)
80005a44: ed4e sd s3,152(sp)
80005a46: 0180 addi s0,sp,192
int fd, omode;
struct file *f;
struct inode *ip;
int n;
if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
80005a48: 08000613 li a2,128
80005a4c: f5040593 addi a1,s0,-176
80005a50: 4501 li a0,0
80005a52: ffffd097 auipc ra,0xffffd
80005a56: 3b8080e7 jalr 952(ra) # 80002e0a <argstr>
return -1;
80005a5a: 54fd li s1,-1
if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
80005a5c: 0c054163 bltz a0,80005b1e <sys_open+0xe4>
80005a60: f4c40593 addi a1,s0,-180
80005a64: 4505 li a0,1
80005a66: ffffd097 auipc ra,0xffffd
80005a6a: 360080e7 jalr 864(ra) # 80002dc6 <argint>
80005a6e: 0a054863 bltz a0,80005b1e <sys_open+0xe4>
begin_op();
80005a72: fffff097 auipc ra,0xfffff
80005a76: a1e080e7 jalr -1506(ra) # 80004490 <begin_op>
if(omode & O_CREATE){
80005a7a: f4c42783 lw a5,-180(s0)
80005a7e: 2007f793 andi a5,a5,512
80005a82: cbdd beqz a5,80005b38 <sys_open+0xfe>
ip = create(path, T_FILE, 0, 0);
80005a84: 4681 li a3,0
80005a86: 4601 li a2,0
80005a88: 4589 li a1,2
80005a8a: f5040513 addi a0,s0,-176
80005a8e: 00000097 auipc ra,0x0
80005a92: 972080e7 jalr -1678(ra) # 80005400 <create>
80005a96: 892a mv s2,a0
if(ip == 0){
80005a98: c959 beqz a0,80005b2e <sys_open+0xf4>
end_op();
return -1;
}
}
if(ip->type == T_DEVICE && (ip->major < 0 || ip->major >= NDEV)){
80005a9a: 04491703 lh a4,68(s2)
80005a9e: 478d li a5,3
80005aa0: 00f71763 bne a4,a5,80005aae <sys_open+0x74>
80005aa4: 04695703 lhu a4,70(s2)
80005aa8: 47a5 li a5,9
80005aaa: 0ce7ec63 bltu a5,a4,80005b82 <sys_open+0x148>
iunlockput(ip);
end_op();
return -1;
}
if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
80005aae: fffff097 auipc ra,0xfffff
80005ab2: df2080e7 jalr -526(ra) # 800048a0 <filealloc>
80005ab6: 89aa mv s3,a0
80005ab8: 10050263 beqz a0,80005bbc <sys_open+0x182>
80005abc: 00000097 auipc ra,0x0
80005ac0: 902080e7 jalr -1790(ra) # 800053be <fdalloc>
80005ac4: 84aa mv s1,a0
80005ac6: 0e054663 bltz a0,80005bb2 <sys_open+0x178>
iunlockput(ip);
end_op();
return -1;
}
if(ip->type == T_DEVICE){
80005aca: 04491703 lh a4,68(s2)
80005ace: 478d li a5,3
80005ad0: 0cf70463 beq a4,a5,80005b98 <sys_open+0x15e>
f->type = FD_DEVICE;
f->major = ip->major;
} else {
f->type = FD_INODE;
80005ad4: 4789 li a5,2
80005ad6: 00f9a023 sw a5,0(s3)
f->off = 0;
80005ada: 0209a023 sw zero,32(s3)
}
f->ip = ip;
80005ade: 0129bc23 sd s2,24(s3)
f->readable = !(omode & O_WRONLY);
80005ae2: f4c42783 lw a5,-180(s0)
80005ae6: 0017c713 xori a4,a5,1
80005aea: 8b05 andi a4,a4,1
80005aec: 00e98423 sb a4,8(s3)
f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
80005af0: 0037f713 andi a4,a5,3
80005af4: 00e03733 snez a4,a4
80005af8: 00e984a3 sb a4,9(s3)
if((omode & O_TRUNC) && ip->type == T_FILE){
80005afc: 4007f793 andi a5,a5,1024
80005b00: c791 beqz a5,80005b0c <sys_open+0xd2>
80005b02: 04491703 lh a4,68(s2)
80005b06: 4789 li a5,2
80005b08: 08f70f63 beq a4,a5,80005ba6 <sys_open+0x16c>
itrunc(ip);
}
iunlock(ip);
80005b0c: 854a mv a0,s2
80005b0e: ffffe097 auipc ra,0xffffe
80005b12: 06e080e7 jalr 110(ra) # 80003b7c <iunlock>
end_op();
80005b16: fffff097 auipc ra,0xfffff
80005b1a: 9fa080e7 jalr -1542(ra) # 80004510 <end_op>
return fd;
}
80005b1e: 8526 mv a0,s1
80005b20: 70ea ld ra,184(sp)
80005b22: 744a ld s0,176(sp)
80005b24: 74aa ld s1,168(sp)
80005b26: 790a ld s2,160(sp)
80005b28: 69ea ld s3,152(sp)
80005b2a: 6129 addi sp,sp,192
80005b2c: 8082 ret
end_op();
80005b2e: fffff097 auipc ra,0xfffff
80005b32: 9e2080e7 jalr -1566(ra) # 80004510 <end_op>
return -1;
80005b36: b7e5 j 80005b1e <sys_open+0xe4>
if((ip = namei(path)) == 0){
80005b38: f5040513 addi a0,s0,-176
80005b3c: ffffe097 auipc ra,0xffffe
80005b40: 734080e7 jalr 1844(ra) # 80004270 <namei>
80005b44: 892a mv s2,a0
80005b46: c905 beqz a0,80005b76 <sys_open+0x13c>
ilock(ip);
80005b48: ffffe097 auipc ra,0xffffe
80005b4c: f72080e7 jalr -142(ra) # 80003aba <ilock>
if(ip->type == T_DIR && omode != O_RDONLY){
80005b50: 04491703 lh a4,68(s2)
80005b54: 4785 li a5,1
80005b56: f4f712e3 bne a4,a5,80005a9a <sys_open+0x60>
80005b5a: f4c42783 lw a5,-180(s0)
80005b5e: dba1 beqz a5,80005aae <sys_open+0x74>
iunlockput(ip);
80005b60: 854a mv a0,s2
80005b62: ffffe097 auipc ra,0xffffe
80005b66: 1ba080e7 jalr 442(ra) # 80003d1c <iunlockput>
end_op();
80005b6a: fffff097 auipc ra,0xfffff
80005b6e: 9a6080e7 jalr -1626(ra) # 80004510 <end_op>
return -1;
80005b72: 54fd li s1,-1
80005b74: b76d j 80005b1e <sys_open+0xe4>
end_op();
80005b76: fffff097 auipc ra,0xfffff
80005b7a: 99a080e7 jalr -1638(ra) # 80004510 <end_op>
return -1;
80005b7e: 54fd li s1,-1
80005b80: bf79 j 80005b1e <sys_open+0xe4>
iunlockput(ip);
80005b82: 854a mv a0,s2
80005b84: ffffe097 auipc ra,0xffffe
80005b88: 198080e7 jalr 408(ra) # 80003d1c <iunlockput>
end_op();
80005b8c: fffff097 auipc ra,0xfffff
80005b90: 984080e7 jalr -1660(ra) # 80004510 <end_op>
return -1;
80005b94: 54fd li s1,-1
80005b96: b761 j 80005b1e <sys_open+0xe4>
f->type = FD_DEVICE;
80005b98: 00f9a023 sw a5,0(s3)
f->major = ip->major;
80005b9c: 04691783 lh a5,70(s2)
80005ba0: 02f99223 sh a5,36(s3)
80005ba4: bf2d j 80005ade <sys_open+0xa4>
itrunc(ip);
80005ba6: 854a mv a0,s2
80005ba8: ffffe097 auipc ra,0xffffe
80005bac: 020080e7 jalr 32(ra) # 80003bc8 <itrunc>
80005bb0: bfb1 j 80005b0c <sys_open+0xd2>
fileclose(f);
80005bb2: 854e mv a0,s3
80005bb4: fffff097 auipc ra,0xfffff
80005bb8: da8080e7 jalr -600(ra) # 8000495c <fileclose>
iunlockput(ip);
80005bbc: 854a mv a0,s2
80005bbe: ffffe097 auipc ra,0xffffe
80005bc2: 15e080e7 jalr 350(ra) # 80003d1c <iunlockput>
end_op();
80005bc6: fffff097 auipc ra,0xfffff
80005bca: 94a080e7 jalr -1718(ra) # 80004510 <end_op>
return -1;
80005bce: 54fd li s1,-1
80005bd0: b7b9 j 80005b1e <sys_open+0xe4>
0000000080005bd2 <sys_mkdir>:
uint64
sys_mkdir(void)
{
80005bd2: 7175 addi sp,sp,-144
80005bd4: e506 sd ra,136(sp)
80005bd6: e122 sd s0,128(sp)
80005bd8: 0900 addi s0,sp,144
char path[MAXPATH];
struct inode *ip;
begin_op();
80005bda: fffff097 auipc ra,0xfffff
80005bde: 8b6080e7 jalr -1866(ra) # 80004490 <begin_op>
if(argstr(0, path, MAXPATH) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){
80005be2: 08000613 li a2,128
80005be6: f7040593 addi a1,s0,-144
80005bea: 4501 li a0,0
80005bec: ffffd097 auipc ra,0xffffd
80005bf0: 21e080e7 jalr 542(ra) # 80002e0a <argstr>
80005bf4: 02054963 bltz a0,80005c26 <sys_mkdir+0x54>
80005bf8: 4681 li a3,0
80005bfa: 4601 li a2,0
80005bfc: 4585 li a1,1
80005bfe: f7040513 addi a0,s0,-144
80005c02: fffff097 auipc ra,0xfffff
80005c06: 7fe080e7 jalr 2046(ra) # 80005400 <create>
80005c0a: cd11 beqz a0,80005c26 <sys_mkdir+0x54>
end_op();
return -1;
}
iunlockput(ip);
80005c0c: ffffe097 auipc ra,0xffffe
80005c10: 110080e7 jalr 272(ra) # 80003d1c <iunlockput>
end_op();
80005c14: fffff097 auipc ra,0xfffff
80005c18: 8fc080e7 jalr -1796(ra) # 80004510 <end_op>
return 0;
80005c1c: 4501 li a0,0
}
80005c1e: 60aa ld ra,136(sp)
80005c20: 640a ld s0,128(sp)
80005c22: 6149 addi sp,sp,144
80005c24: 8082 ret
end_op();
80005c26: fffff097 auipc ra,0xfffff
80005c2a: 8ea080e7 jalr -1814(ra) # 80004510 <end_op>
return -1;
80005c2e: 557d li a0,-1
80005c30: b7fd j 80005c1e <sys_mkdir+0x4c>
0000000080005c32 <sys_mknod>:
uint64
sys_mknod(void)
{
80005c32: 7135 addi sp,sp,-160
80005c34: ed06 sd ra,152(sp)
80005c36: e922 sd s0,144(sp)
80005c38: 1100 addi s0,sp,160
struct inode *ip;
char path[MAXPATH];
int major, minor;
begin_op();
80005c3a: fffff097 auipc ra,0xfffff
80005c3e: 856080e7 jalr -1962(ra) # 80004490 <begin_op>
if((argstr(0, path, MAXPATH)) < 0 ||
80005c42: 08000613 li a2,128
80005c46: f7040593 addi a1,s0,-144
80005c4a: 4501 li a0,0
80005c4c: ffffd097 auipc ra,0xffffd
80005c50: 1be080e7 jalr 446(ra) # 80002e0a <argstr>
80005c54: 04054a63 bltz a0,80005ca8 <sys_mknod+0x76>
argint(1, &major) < 0 ||
80005c58: f6c40593 addi a1,s0,-148
80005c5c: 4505 li a0,1
80005c5e: ffffd097 auipc ra,0xffffd
80005c62: 168080e7 jalr 360(ra) # 80002dc6 <argint>
if((argstr(0, path, MAXPATH)) < 0 ||
80005c66: 04054163 bltz a0,80005ca8 <sys_mknod+0x76>
argint(2, &minor) < 0 ||
80005c6a: f6840593 addi a1,s0,-152
80005c6e: 4509 li a0,2
80005c70: ffffd097 auipc ra,0xffffd
80005c74: 156080e7 jalr 342(ra) # 80002dc6 <argint>
argint(1, &major) < 0 ||
80005c78: 02054863 bltz a0,80005ca8 <sys_mknod+0x76>
(ip = create(path, T_DEVICE, major, minor)) == 0){
80005c7c: f6841683 lh a3,-152(s0)
80005c80: f6c41603 lh a2,-148(s0)
80005c84: 458d li a1,3
80005c86: f7040513 addi a0,s0,-144
80005c8a: fffff097 auipc ra,0xfffff
80005c8e: 776080e7 jalr 1910(ra) # 80005400 <create>
argint(2, &minor) < 0 ||
80005c92: c919 beqz a0,80005ca8 <sys_mknod+0x76>
end_op();
return -1;
}
iunlockput(ip);
80005c94: ffffe097 auipc ra,0xffffe
80005c98: 088080e7 jalr 136(ra) # 80003d1c <iunlockput>
end_op();
80005c9c: fffff097 auipc ra,0xfffff
80005ca0: 874080e7 jalr -1932(ra) # 80004510 <end_op>
return 0;
80005ca4: 4501 li a0,0
80005ca6: a031 j 80005cb2 <sys_mknod+0x80>
end_op();
80005ca8: fffff097 auipc ra,0xfffff
80005cac: 868080e7 jalr -1944(ra) # 80004510 <end_op>
return -1;
80005cb0: 557d li a0,-1
}
80005cb2: 60ea ld ra,152(sp)
80005cb4: 644a ld s0,144(sp)
80005cb6: 610d addi sp,sp,160
80005cb8: 8082 ret
0000000080005cba <sys_chdir>:
uint64
sys_chdir(void)
{
80005cba: 7135 addi sp,sp,-160
80005cbc: ed06 sd ra,152(sp)
80005cbe: e922 sd s0,144(sp)
80005cc0: e526 sd s1,136(sp)
80005cc2: e14a sd s2,128(sp)
80005cc4: 1100 addi s0,sp,160
char path[MAXPATH];
struct inode *ip;
struct proc *p = myproc();
80005cc6: ffffc097 auipc ra,0xffffc
80005cca: cb8080e7 jalr -840(ra) # 8000197e <myproc>
80005cce: 892a mv s2,a0
begin_op();
80005cd0: ffffe097 auipc ra,0xffffe
80005cd4: 7c0080e7 jalr 1984(ra) # 80004490 <begin_op>
if(argstr(0, path, MAXPATH) < 0 || (ip = namei(path)) == 0){
80005cd8: 08000613 li a2,128
80005cdc: f6040593 addi a1,s0,-160
80005ce0: 4501 li a0,0
80005ce2: ffffd097 auipc ra,0xffffd
80005ce6: 128080e7 jalr 296(ra) # 80002e0a <argstr>
80005cea: 04054b63 bltz a0,80005d40 <sys_chdir+0x86>
80005cee: f6040513 addi a0,s0,-160
80005cf2: ffffe097 auipc ra,0xffffe
80005cf6: 57e080e7 jalr 1406(ra) # 80004270 <namei>
80005cfa: 84aa mv s1,a0
80005cfc: c131 beqz a0,80005d40 <sys_chdir+0x86>
end_op();
return -1;
}
ilock(ip);
80005cfe: ffffe097 auipc ra,0xffffe
80005d02: dbc080e7 jalr -580(ra) # 80003aba <ilock>
if(ip->type != T_DIR){
80005d06: 04449703 lh a4,68(s1)
80005d0a: 4785 li a5,1
80005d0c: 04f71063 bne a4,a5,80005d4c <sys_chdir+0x92>
iunlockput(ip);
end_op();
return -1;
}
iunlock(ip);
80005d10: 8526 mv a0,s1
80005d12: ffffe097 auipc ra,0xffffe
80005d16: e6a080e7 jalr -406(ra) # 80003b7c <iunlock>
iput(p->cwd);
80005d1a: 18893503 ld a0,392(s2)
80005d1e: ffffe097 auipc ra,0xffffe
80005d22: f56080e7 jalr -170(ra) # 80003c74 <iput>
end_op();
80005d26: ffffe097 auipc ra,0xffffe
80005d2a: 7ea080e7 jalr 2026(ra) # 80004510 <end_op>
p->cwd = ip;
80005d2e: 18993423 sd s1,392(s2)
return 0;
80005d32: 4501 li a0,0
}
80005d34: 60ea ld ra,152(sp)
80005d36: 644a ld s0,144(sp)
80005d38: 64aa ld s1,136(sp)
80005d3a: 690a ld s2,128(sp)
80005d3c: 610d addi sp,sp,160
80005d3e: 8082 ret
end_op();
80005d40: ffffe097 auipc ra,0xffffe
80005d44: 7d0080e7 jalr 2000(ra) # 80004510 <end_op>
return -1;
80005d48: 557d li a0,-1
80005d4a: b7ed j 80005d34 <sys_chdir+0x7a>
iunlockput(ip);
80005d4c: 8526 mv a0,s1
80005d4e: ffffe097 auipc ra,0xffffe
80005d52: fce080e7 jalr -50(ra) # 80003d1c <iunlockput>
end_op();
80005d56: ffffe097 auipc ra,0xffffe
80005d5a: 7ba080e7 jalr 1978(ra) # 80004510 <end_op>
return -1;
80005d5e: 557d li a0,-1
80005d60: bfd1 j 80005d34 <sys_chdir+0x7a>
0000000080005d62 <sys_exec>:
uint64
sys_exec(void)
{
80005d62: 7145 addi sp,sp,-464
80005d64: e786 sd ra,456(sp)
80005d66: e3a2 sd s0,448(sp)
80005d68: ff26 sd s1,440(sp)
80005d6a: fb4a sd s2,432(sp)
80005d6c: f74e sd s3,424(sp)
80005d6e: f352 sd s4,416(sp)
80005d70: ef56 sd s5,408(sp)
80005d72: 0b80 addi s0,sp,464
char path[MAXPATH], *argv[MAXARG];
int i;
uint64 uargv, uarg;
if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
80005d74: 08000613 li a2,128
80005d78: f4040593 addi a1,s0,-192
80005d7c: 4501 li a0,0
80005d7e: ffffd097 auipc ra,0xffffd
80005d82: 08c080e7 jalr 140(ra) # 80002e0a <argstr>
return -1;
80005d86: 597d li s2,-1
if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
80005d88: 0c054a63 bltz a0,80005e5c <sys_exec+0xfa>
80005d8c: e3840593 addi a1,s0,-456
80005d90: 4505 li a0,1
80005d92: ffffd097 auipc ra,0xffffd
80005d96: 056080e7 jalr 86(ra) # 80002de8 <argaddr>
80005d9a: 0c054163 bltz a0,80005e5c <sys_exec+0xfa>
}
memset(argv, 0, sizeof(argv));
80005d9e: 10000613 li a2,256
80005da2: 4581 li a1,0
80005da4: e4040513 addi a0,s0,-448
80005da8: ffffb097 auipc ra,0xffffb
80005dac: f16080e7 jalr -234(ra) # 80000cbe <memset>
for(i=0;; i++){
if(i >= NELEM(argv)){
80005db0: e4040493 addi s1,s0,-448
memset(argv, 0, sizeof(argv));
80005db4: 89a6 mv s3,s1
80005db6: 4901 li s2,0
if(i >= NELEM(argv)){
80005db8: 02000a13 li s4,32
80005dbc: 00090a9b sext.w s5,s2
goto bad;
}
if(fetchaddr(uargv+sizeof(uint64)*i, (uint64*)&uarg) < 0){
80005dc0: 00391793 slli a5,s2,0x3
80005dc4: e3040593 addi a1,s0,-464
80005dc8: e3843503 ld a0,-456(s0)
80005dcc: 953e add a0,a0,a5
80005dce: ffffd097 auipc ra,0xffffd
80005dd2: f5e080e7 jalr -162(ra) # 80002d2c <fetchaddr>
80005dd6: 02054a63 bltz a0,80005e0a <sys_exec+0xa8>
goto bad;
}
if(uarg == 0){
80005dda: e3043783 ld a5,-464(s0)
80005dde: c3b9 beqz a5,80005e24 <sys_exec+0xc2>
argv[i] = 0;
break;
}
argv[i] = kalloc();
80005de0: ffffb097 auipc ra,0xffffb
80005de4: cf2080e7 jalr -782(ra) # 80000ad2 <kalloc>
80005de8: 85aa mv a1,a0
80005dea: 00a9b023 sd a0,0(s3)
if(argv[i] == 0)
80005dee: cd11 beqz a0,80005e0a <sys_exec+0xa8>
goto bad;
if(fetchstr(uarg, argv[i], PGSIZE) < 0)
80005df0: 6605 lui a2,0x1
80005df2: e3043503 ld a0,-464(s0)
80005df6: ffffd097 auipc ra,0xffffd
80005dfa: f88080e7 jalr -120(ra) # 80002d7e <fetchstr>
80005dfe: 00054663 bltz a0,80005e0a <sys_exec+0xa8>
if(i >= NELEM(argv)){
80005e02: 0905 addi s2,s2,1
80005e04: 09a1 addi s3,s3,8
80005e06: fb491be3 bne s2,s4,80005dbc <sys_exec+0x5a>
kfree(argv[i]);
return ret;
bad:
for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
80005e0a: 10048913 addi s2,s1,256
80005e0e: 6088 ld a0,0(s1)
80005e10: c529 beqz a0,80005e5a <sys_exec+0xf8>
kfree(argv[i]);
80005e12: ffffb097 auipc ra,0xffffb
80005e16: bc4080e7 jalr -1084(ra) # 800009d6 <kfree>
for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
80005e1a: 04a1 addi s1,s1,8
80005e1c: ff2499e3 bne s1,s2,80005e0e <sys_exec+0xac>
return -1;
80005e20: 597d li s2,-1
80005e22: a82d j 80005e5c <sys_exec+0xfa>
argv[i] = 0;
80005e24: 0a8e slli s5,s5,0x3
80005e26: fc040793 addi a5,s0,-64
80005e2a: 9abe add s5,s5,a5
80005e2c: e80ab023 sd zero,-384(s5) # ffffffffffffee80 <end+0xffffffff7ffd7e80>
int ret = exec(path, argv);
80005e30: e4040593 addi a1,s0,-448
80005e34: f4040513 addi a0,s0,-192
80005e38: fffff097 auipc ra,0xfffff
80005e3c: 176080e7 jalr 374(ra) # 80004fae <exec>
80005e40: 892a mv s2,a0
for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
80005e42: 10048993 addi s3,s1,256
80005e46: 6088 ld a0,0(s1)
80005e48: c911 beqz a0,80005e5c <sys_exec+0xfa>
kfree(argv[i]);
80005e4a: ffffb097 auipc ra,0xffffb
80005e4e: b8c080e7 jalr -1140(ra) # 800009d6 <kfree>
for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
80005e52: 04a1 addi s1,s1,8
80005e54: ff3499e3 bne s1,s3,80005e46 <sys_exec+0xe4>
80005e58: a011 j 80005e5c <sys_exec+0xfa>
return -1;
80005e5a: 597d li s2,-1
}
80005e5c: 854a mv a0,s2
80005e5e: 60be ld ra,456(sp)
80005e60: 641e ld s0,448(sp)
80005e62: 74fa ld s1,440(sp)
80005e64: 795a ld s2,432(sp)
80005e66: 79ba ld s3,424(sp)
80005e68: 7a1a ld s4,416(sp)
80005e6a: 6afa ld s5,408(sp)
80005e6c: 6179 addi sp,sp,464
80005e6e: 8082 ret
0000000080005e70 <sys_pipe>:
uint64
sys_pipe(void)
{
80005e70: 7139 addi sp,sp,-64
80005e72: fc06 sd ra,56(sp)
80005e74: f822 sd s0,48(sp)
80005e76: f426 sd s1,40(sp)
80005e78: 0080 addi s0,sp,64
uint64 fdarray; // user pointer to array of two integers
struct file *rf, *wf;
int fd0, fd1;
struct proc *p = myproc();
80005e7a: ffffc097 auipc ra,0xffffc
80005e7e: b04080e7 jalr -1276(ra) # 8000197e <myproc>
80005e82: 84aa mv s1,a0
if(argaddr(0, &fdarray) < 0)
80005e84: fd840593 addi a1,s0,-40
80005e88: 4501 li a0,0
80005e8a: ffffd097 auipc ra,0xffffd
80005e8e: f5e080e7 jalr -162(ra) # 80002de8 <argaddr>
return -1;
80005e92: 57fd li a5,-1
if(argaddr(0, &fdarray) < 0)
80005e94: 0e054263 bltz a0,80005f78 <sys_pipe+0x108>
if(pipealloc(&rf, &wf) < 0)
80005e98: fc840593 addi a1,s0,-56
80005e9c: fd040513 addi a0,s0,-48
80005ea0: fffff097 auipc ra,0xfffff
80005ea4: dec080e7 jalr -532(ra) # 80004c8c <pipealloc>
return -1;
80005ea8: 57fd li a5,-1
if(pipealloc(&rf, &wf) < 0)
80005eaa: 0c054763 bltz a0,80005f78 <sys_pipe+0x108>
fd0 = -1;
80005eae: fcf42223 sw a5,-60(s0)
if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
80005eb2: fd043503 ld a0,-48(s0)
80005eb6: fffff097 auipc ra,0xfffff
80005eba: 508080e7 jalr 1288(ra) # 800053be <fdalloc>
80005ebe: fca42223 sw a0,-60(s0)
80005ec2: 08054e63 bltz a0,80005f5e <sys_pipe+0xee>
80005ec6: fc843503 ld a0,-56(s0)
80005eca: fffff097 auipc ra,0xfffff
80005ece: 4f4080e7 jalr 1268(ra) # 800053be <fdalloc>
80005ed2: fca42023 sw a0,-64(s0)
80005ed6: 06054a63 bltz a0,80005f4a <sys_pipe+0xda>
p->ofile[fd0] = 0;
fileclose(rf);
fileclose(wf);
return -1;
}
if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
80005eda: 4691 li a3,4
80005edc: fc440613 addi a2,s0,-60
80005ee0: fd843583 ld a1,-40(s0)
80005ee4: 64c8 ld a0,136(s1)
80005ee6: ffffb097 auipc ra,0xffffb
80005eea: 758080e7 jalr 1880(ra) # 8000163e <copyout>
80005eee: 02054063 bltz a0,80005f0e <sys_pipe+0x9e>
copyout(p->pagetable, fdarray+sizeof(fd0), (char *)&fd1, sizeof(fd1)) < 0){
80005ef2: 4691 li a3,4
80005ef4: fc040613 addi a2,s0,-64
80005ef8: fd843583 ld a1,-40(s0)
80005efc: 0591 addi a1,a1,4
80005efe: 64c8 ld a0,136(s1)
80005f00: ffffb097 auipc ra,0xffffb
80005f04: 73e080e7 jalr 1854(ra) # 8000163e <copyout>
p->ofile[fd1] = 0;
fileclose(rf);
fileclose(wf);
return -1;
}
return 0;
80005f08: 4781 li a5,0
if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
80005f0a: 06055763 bgez a0,80005f78 <sys_pipe+0x108>
p->ofile[fd0] = 0;
80005f0e: fc442783 lw a5,-60(s0)
80005f12: 02078793 addi a5,a5,32
80005f16: 078e slli a5,a5,0x3
80005f18: 97a6 add a5,a5,s1
80005f1a: 0007b423 sd zero,8(a5)
p->ofile[fd1] = 0;
80005f1e: fc042503 lw a0,-64(s0)
80005f22: 02050513 addi a0,a0,32
80005f26: 050e slli a0,a0,0x3
80005f28: 9526 add a0,a0,s1
80005f2a: 00053423 sd zero,8(a0)
fileclose(rf);
80005f2e: fd043503 ld a0,-48(s0)
80005f32: fffff097 auipc ra,0xfffff
80005f36: a2a080e7 jalr -1494(ra) # 8000495c <fileclose>
fileclose(wf);
80005f3a: fc843503 ld a0,-56(s0)
80005f3e: fffff097 auipc ra,0xfffff
80005f42: a1e080e7 jalr -1506(ra) # 8000495c <fileclose>
return -1;
80005f46: 57fd li a5,-1
80005f48: a805 j 80005f78 <sys_pipe+0x108>
if(fd0 >= 0)
80005f4a: fc442783 lw a5,-60(s0)
80005f4e: 0007c863 bltz a5,80005f5e <sys_pipe+0xee>
p->ofile[fd0] = 0;
80005f52: 02078513 addi a0,a5,32
80005f56: 050e slli a0,a0,0x3
80005f58: 9526 add a0,a0,s1
80005f5a: 00053423 sd zero,8(a0)
fileclose(rf);
80005f5e: fd043503 ld a0,-48(s0)
80005f62: fffff097 auipc ra,0xfffff
80005f66: 9fa080e7 jalr -1542(ra) # 8000495c <fileclose>
fileclose(wf);
80005f6a: fc843503 ld a0,-56(s0)
80005f6e: fffff097 auipc ra,0xfffff
80005f72: 9ee080e7 jalr -1554(ra) # 8000495c <fileclose>
return -1;
80005f76: 57fd li a5,-1
}
80005f78: 853e mv a0,a5
80005f7a: 70e2 ld ra,56(sp)
80005f7c: 7442 ld s0,48(sp)
80005f7e: 74a2 ld s1,40(sp)
80005f80: 6121 addi sp,sp,64
80005f82: 8082 ret
...
0000000080005f90 <kernelvec>:
80005f90: 7111 addi sp,sp,-256
80005f92: e006 sd ra,0(sp)
80005f94: e40a sd sp,8(sp)
80005f96: e80e sd gp,16(sp)
80005f98: ec12 sd tp,24(sp)
80005f9a: f016 sd t0,32(sp)
80005f9c: f41a sd t1,40(sp)
80005f9e: f81e sd t2,48(sp)
80005fa0: fc22 sd s0,56(sp)
80005fa2: e0a6 sd s1,64(sp)
80005fa4: e4aa sd a0,72(sp)
80005fa6: e8ae sd a1,80(sp)
80005fa8: ecb2 sd a2,88(sp)
80005faa: f0b6 sd a3,96(sp)
80005fac: f4ba sd a4,104(sp)
80005fae: f8be sd a5,112(sp)
80005fb0: fcc2 sd a6,120(sp)
80005fb2: e146 sd a7,128(sp)
80005fb4: e54a sd s2,136(sp)
80005fb6: e94e sd s3,144(sp)
80005fb8: ed52 sd s4,152(sp)
80005fba: f156 sd s5,160(sp)
80005fbc: f55a sd s6,168(sp)
80005fbe: f95e sd s7,176(sp)
80005fc0: fd62 sd s8,184(sp)
80005fc2: e1e6 sd s9,192(sp)
80005fc4: e5ea sd s10,200(sp)
80005fc6: e9ee sd s11,208(sp)
80005fc8: edf2 sd t3,216(sp)
80005fca: f1f6 sd t4,224(sp)
80005fcc: f5fa sd t5,232(sp)
80005fce: f9fe sd t6,240(sp)
80005fd0: c1bfc0ef jal ra,80002bea <kerneltrap>
80005fd4: 6082 ld ra,0(sp)
80005fd6: 6122 ld sp,8(sp)
80005fd8: 61c2 ld gp,16(sp)
80005fda: 7282 ld t0,32(sp)
80005fdc: 7322 ld t1,40(sp)
80005fde: 73c2 ld t2,48(sp)
80005fe0: 7462 ld s0,56(sp)
80005fe2: 6486 ld s1,64(sp)
80005fe4: 6526 ld a0,72(sp)
80005fe6: 65c6 ld a1,80(sp)
80005fe8: 6666 ld a2,88(sp)
80005fea: 7686 ld a3,96(sp)
80005fec: 7726 ld a4,104(sp)
80005fee: 77c6 ld a5,112(sp)
80005ff0: 7866 ld a6,120(sp)
80005ff2: 688a ld a7,128(sp)
80005ff4: 692a ld s2,136(sp)
80005ff6: 69ca ld s3,144(sp)
80005ff8: 6a6a ld s4,152(sp)
80005ffa: 7a8a ld s5,160(sp)
80005ffc: 7b2a ld s6,168(sp)
80005ffe: 7bca ld s7,176(sp)
80006000: 7c6a ld s8,184(sp)
80006002: 6c8e ld s9,192(sp)
80006004: 6d2e ld s10,200(sp)
80006006: 6dce ld s11,208(sp)
80006008: 6e6e ld t3,216(sp)
8000600a: 7e8e ld t4,224(sp)
8000600c: 7f2e ld t5,232(sp)
8000600e: 7fce ld t6,240(sp)
80006010: 6111 addi sp,sp,256
80006012: 10200073 sret
80006016: 00000013 nop
8000601a: 00000013 nop
8000601e: 0001 nop
0000000080006020 <timervec>:
80006020: 34051573 csrrw a0,mscratch,a0
80006024: e10c sd a1,0(a0)
80006026: e510 sd a2,8(a0)
80006028: e914 sd a3,16(a0)
8000602a: 6d0c ld a1,24(a0)
8000602c: 7110 ld a2,32(a0)
8000602e: 6194 ld a3,0(a1)
80006030: 96b2 add a3,a3,a2
80006032: e194 sd a3,0(a1)
80006034: 4589 li a1,2
80006036: 14459073 csrw sip,a1
8000603a: 6914 ld a3,16(a0)
8000603c: 6510 ld a2,8(a0)
8000603e: 610c ld a1,0(a0)
80006040: 34051573 csrrw a0,mscratch,a0
80006044: 30200073 mret
...
000000008000604a <plicinit>:
// the riscv Platform Level Interrupt Controller (PLIC).
//
void
plicinit(void)
{
8000604a: 1141 addi sp,sp,-16
8000604c: e422 sd s0,8(sp)
8000604e: 0800 addi s0,sp,16
// set desired IRQ priorities non-zero (otherwise disabled).
*(uint32*)(PLIC + UART0_IRQ*4) = 1;
80006050: 0c0007b7 lui a5,0xc000
80006054: 4705 li a4,1
80006056: d798 sw a4,40(a5)
*(uint32*)(PLIC + VIRTIO0_IRQ*4) = 1;
80006058: c3d8 sw a4,4(a5)
}
8000605a: 6422 ld s0,8(sp)
8000605c: 0141 addi sp,sp,16
8000605e: 8082 ret
0000000080006060 <plicinithart>:
void
plicinithart(void)
{
80006060: 1141 addi sp,sp,-16
80006062: e406 sd ra,8(sp)
80006064: e022 sd s0,0(sp)
80006066: 0800 addi s0,sp,16
int hart = cpuid();
80006068: ffffc097 auipc ra,0xffffc
8000606c: 8ea080e7 jalr -1814(ra) # 80001952 <cpuid>
// set uart's enable bit for this hart's S-mode.
*(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ);
80006070: 0085171b slliw a4,a0,0x8
80006074: 0c0027b7 lui a5,0xc002
80006078: 97ba add a5,a5,a4
8000607a: 40200713 li a4,1026
8000607e: 08e7a023 sw a4,128(a5) # c002080 <_entry-0x73ffdf80>
// set this hart's S-mode priority threshold to 0.
*(uint32*)PLIC_SPRIORITY(hart) = 0;
80006082: 00d5151b slliw a0,a0,0xd
80006086: 0c2017b7 lui a5,0xc201
8000608a: 953e add a0,a0,a5
8000608c: 00052023 sw zero,0(a0)
}
80006090: 60a2 ld ra,8(sp)
80006092: 6402 ld s0,0(sp)
80006094: 0141 addi sp,sp,16
80006096: 8082 ret
0000000080006098 <plic_claim>:
// ask the PLIC what interrupt we should serve.
int
plic_claim(void)
{
80006098: 1141 addi sp,sp,-16
8000609a: e406 sd ra,8(sp)
8000609c: e022 sd s0,0(sp)
8000609e: 0800 addi s0,sp,16
int hart = cpuid();
800060a0: ffffc097 auipc ra,0xffffc
800060a4: 8b2080e7 jalr -1870(ra) # 80001952 <cpuid>
int irq = *(uint32*)PLIC_SCLAIM(hart);
800060a8: 00d5179b slliw a5,a0,0xd
800060ac: 0c201537 lui a0,0xc201
800060b0: 953e add a0,a0,a5
return irq;
}
800060b2: 4148 lw a0,4(a0)
800060b4: 60a2 ld ra,8(sp)
800060b6: 6402 ld s0,0(sp)
800060b8: 0141 addi sp,sp,16
800060ba: 8082 ret
00000000800060bc <plic_complete>:
// tell the PLIC we've served this IRQ.
void
plic_complete(int irq)
{
800060bc: 1101 addi sp,sp,-32
800060be: ec06 sd ra,24(sp)
800060c0: e822 sd s0,16(sp)
800060c2: e426 sd s1,8(sp)
800060c4: 1000 addi s0,sp,32
800060c6: 84aa mv s1,a0
int hart = cpuid();
800060c8: ffffc097 auipc ra,0xffffc
800060cc: 88a080e7 jalr -1910(ra) # 80001952 <cpuid>
*(uint32*)PLIC_SCLAIM(hart) = irq;
800060d0: 00d5151b slliw a0,a0,0xd
800060d4: 0c2017b7 lui a5,0xc201
800060d8: 97aa add a5,a5,a0
800060da: c3c4 sw s1,4(a5)
}
800060dc: 60e2 ld ra,24(sp)
800060de: 6442 ld s0,16(sp)
800060e0: 64a2 ld s1,8(sp)
800060e2: 6105 addi sp,sp,32
800060e4: 8082 ret
00000000800060e6 <free_desc>:
}
// mark a descriptor as free.
static void
free_desc(int i)
{
800060e6: 1141 addi sp,sp,-16
800060e8: e406 sd ra,8(sp)
800060ea: e022 sd s0,0(sp)
800060ec: 0800 addi s0,sp,16
if(i >= NUM)
800060ee: 479d li a5,7
800060f0: 06a7c963 blt a5,a0,80006162 <free_desc+0x7c>
panic("free_desc 1");
if(disk.free[i])
800060f4: 0001e797 auipc a5,0x1e
800060f8: f0c78793 addi a5,a5,-244 # 80024000 <disk>
800060fc: 00a78733 add a4,a5,a0
80006100: 6789 lui a5,0x2
80006102: 97ba add a5,a5,a4
80006104: 0187c783 lbu a5,24(a5) # 2018 <_entry-0x7fffdfe8>
80006108: e7ad bnez a5,80006172 <free_desc+0x8c>
panic("free_desc 2");
disk.desc[i].addr = 0;
8000610a: 00451793 slli a5,a0,0x4
8000610e: 00020717 auipc a4,0x20
80006112: ef270713 addi a4,a4,-270 # 80026000 <disk+0x2000>
80006116: 6314 ld a3,0(a4)
80006118: 96be add a3,a3,a5
8000611a: 0006b023 sd zero,0(a3)
disk.desc[i].len = 0;
8000611e: 6314 ld a3,0(a4)
80006120: 96be add a3,a3,a5
80006122: 0006a423 sw zero,8(a3)
disk.desc[i].flags = 0;
80006126: 6314 ld a3,0(a4)
80006128: 96be add a3,a3,a5
8000612a: 00069623 sh zero,12(a3)
disk.desc[i].next = 0;
8000612e: 6318 ld a4,0(a4)
80006130: 97ba add a5,a5,a4
80006132: 00079723 sh zero,14(a5)
disk.free[i] = 1;
80006136: 0001e797 auipc a5,0x1e
8000613a: eca78793 addi a5,a5,-310 # 80024000 <disk>
8000613e: 97aa add a5,a5,a0
80006140: 6509 lui a0,0x2
80006142: 953e add a0,a0,a5
80006144: 4785 li a5,1
80006146: 00f50c23 sb a5,24(a0) # 2018 <_entry-0x7fffdfe8>
wakeup(&disk.free[0]);
8000614a: 00020517 auipc a0,0x20
8000614e: ece50513 addi a0,a0,-306 # 80026018 <disk+0x2018>
80006152: ffffc097 auipc ra,0xffffc
80006156: 216080e7 jalr 534(ra) # 80002368 <wakeup>
}
8000615a: 60a2 ld ra,8(sp)
8000615c: 6402 ld s0,0(sp)
8000615e: 0141 addi sp,sp,16
80006160: 8082 ret
panic("free_desc 1");
80006162: 00002517 auipc a0,0x2
80006166: 71e50513 addi a0,a0,1822 # 80008880 <syscalls+0x330>
8000616a: ffffa097 auipc ra,0xffffa
8000616e: 3c0080e7 jalr 960(ra) # 8000052a <panic>
panic("free_desc 2");
80006172: 00002517 auipc a0,0x2
80006176: 71e50513 addi a0,a0,1822 # 80008890 <syscalls+0x340>
8000617a: ffffa097 auipc ra,0xffffa
8000617e: 3b0080e7 jalr 944(ra) # 8000052a <panic>
0000000080006182 <virtio_disk_init>:
{
80006182: 1101 addi sp,sp,-32
80006184: ec06 sd ra,24(sp)
80006186: e822 sd s0,16(sp)
80006188: e426 sd s1,8(sp)
8000618a: 1000 addi s0,sp,32
initlock(&disk.vdisk_lock, "virtio_disk");
8000618c: 00002597 auipc a1,0x2
80006190: 71458593 addi a1,a1,1812 # 800088a0 <syscalls+0x350>
80006194: 00020517 auipc a0,0x20
80006198: f9450513 addi a0,a0,-108 # 80026128 <disk+0x2128>
8000619c: ffffb097 auipc ra,0xffffb
800061a0: 996080e7 jalr -1642(ra) # 80000b32 <initlock>
if(*R(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
800061a4: 100017b7 lui a5,0x10001
800061a8: 4398 lw a4,0(a5)
800061aa: 2701 sext.w a4,a4
800061ac: 747277b7 lui a5,0x74727
800061b0: 97678793 addi a5,a5,-1674 # 74726976 <_entry-0xb8d968a>
800061b4: 0ef71163 bne a4,a5,80006296 <virtio_disk_init+0x114>
*R(VIRTIO_MMIO_VERSION) != 1 ||
800061b8: 100017b7 lui a5,0x10001
800061bc: 43dc lw a5,4(a5)
800061be: 2781 sext.w a5,a5
if(*R(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
800061c0: 4705 li a4,1
800061c2: 0ce79a63 bne a5,a4,80006296 <virtio_disk_init+0x114>
*R(VIRTIO_MMIO_DEVICE_ID) != 2 ||
800061c6: 100017b7 lui a5,0x10001
800061ca: 479c lw a5,8(a5)
800061cc: 2781 sext.w a5,a5
*R(VIRTIO_MMIO_VERSION) != 1 ||
800061ce: 4709 li a4,2
800061d0: 0ce79363 bne a5,a4,80006296 <virtio_disk_init+0x114>
*R(VIRTIO_MMIO_VENDOR_ID) != 0x554d4551){
800061d4: 100017b7 lui a5,0x10001
800061d8: 47d8 lw a4,12(a5)
800061da: 2701 sext.w a4,a4
*R(VIRTIO_MMIO_DEVICE_ID) != 2 ||
800061dc: 554d47b7 lui a5,0x554d4
800061e0: 55178793 addi a5,a5,1361 # 554d4551 <_entry-0x2ab2baaf>
800061e4: 0af71963 bne a4,a5,80006296 <virtio_disk_init+0x114>
*R(VIRTIO_MMIO_STATUS) = status;
800061e8: 100017b7 lui a5,0x10001
800061ec: 4705 li a4,1
800061ee: dbb8 sw a4,112(a5)
*R(VIRTIO_MMIO_STATUS) = status;
800061f0: 470d li a4,3
800061f2: dbb8 sw a4,112(a5)
uint64 features = *R(VIRTIO_MMIO_DEVICE_FEATURES);
800061f4: 4b94 lw a3,16(a5)
features &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC);
800061f6: c7ffe737 lui a4,0xc7ffe
800061fa: 75f70713 addi a4,a4,1887 # ffffffffc7ffe75f <end+0xffffffff47fd775f>
800061fe: 8f75 and a4,a4,a3
*R(VIRTIO_MMIO_DRIVER_FEATURES) = features;
80006200: 2701 sext.w a4,a4
80006202: d398 sw a4,32(a5)
*R(VIRTIO_MMIO_STATUS) = status;
80006204: 472d li a4,11
80006206: dbb8 sw a4,112(a5)
*R(VIRTIO_MMIO_STATUS) = status;
80006208: 473d li a4,15
8000620a: dbb8 sw a4,112(a5)
*R(VIRTIO_MMIO_GUEST_PAGE_SIZE) = PGSIZE;
8000620c: 6705 lui a4,0x1
8000620e: d798 sw a4,40(a5)
*R(VIRTIO_MMIO_QUEUE_SEL) = 0;
80006210: 0207a823 sw zero,48(a5) # 10001030 <_entry-0x6fffefd0>
uint32 max = *R(VIRTIO_MMIO_QUEUE_NUM_MAX);
80006214: 5bdc lw a5,52(a5)
80006216: 2781 sext.w a5,a5
if(max == 0)
80006218: c7d9 beqz a5,800062a6 <virtio_disk_init+0x124>
if(max < NUM)
8000621a: 471d li a4,7
8000621c: 08f77d63 bgeu a4,a5,800062b6 <virtio_disk_init+0x134>
*R(VIRTIO_MMIO_QUEUE_NUM) = NUM;
80006220: 100014b7 lui s1,0x10001
80006224: 47a1 li a5,8
80006226: dc9c sw a5,56(s1)
memset(disk.pages, 0, sizeof(disk.pages));
80006228: 6609 lui a2,0x2
8000622a: 4581 li a1,0
8000622c: 0001e517 auipc a0,0x1e
80006230: dd450513 addi a0,a0,-556 # 80024000 <disk>
80006234: ffffb097 auipc ra,0xffffb
80006238: a8a080e7 jalr -1398(ra) # 80000cbe <memset>
*R(VIRTIO_MMIO_QUEUE_PFN) = ((uint64)disk.pages) >> PGSHIFT;
8000623c: 0001e717 auipc a4,0x1e
80006240: dc470713 addi a4,a4,-572 # 80024000 <disk>
80006244: 00c75793 srli a5,a4,0xc
80006248: 2781 sext.w a5,a5
8000624a: c0bc sw a5,64(s1)
disk.desc = (struct virtq_desc *) disk.pages;
8000624c: 00020797 auipc a5,0x20
80006250: db478793 addi a5,a5,-588 # 80026000 <disk+0x2000>
80006254: e398 sd a4,0(a5)
disk.avail = (struct virtq_avail *)(disk.pages + NUM*sizeof(struct virtq_desc));
80006256: 0001e717 auipc a4,0x1e
8000625a: e2a70713 addi a4,a4,-470 # 80024080 <disk+0x80>
8000625e: e798 sd a4,8(a5)
disk.used = (struct virtq_used *) (disk.pages + PGSIZE);
80006260: 0001f717 auipc a4,0x1f
80006264: da070713 addi a4,a4,-608 # 80025000 <disk+0x1000>
80006268: eb98 sd a4,16(a5)
disk.free[i] = 1;
8000626a: 4705 li a4,1
8000626c: 00e78c23 sb a4,24(a5)
80006270: 00e78ca3 sb a4,25(a5)
80006274: 00e78d23 sb a4,26(a5)
80006278: 00e78da3 sb a4,27(a5)
8000627c: 00e78e23 sb a4,28(a5)
80006280: 00e78ea3 sb a4,29(a5)
80006284: 00e78f23 sb a4,30(a5)
80006288: 00e78fa3 sb a4,31(a5)
}
8000628c: 60e2 ld ra,24(sp)
8000628e: 6442 ld s0,16(sp)
80006290: 64a2 ld s1,8(sp)
80006292: 6105 addi sp,sp,32
80006294: 8082 ret
panic("could not find virtio disk");
80006296: 00002517 auipc a0,0x2
8000629a: 61a50513 addi a0,a0,1562 # 800088b0 <syscalls+0x360>
8000629e: ffffa097 auipc ra,0xffffa
800062a2: 28c080e7 jalr 652(ra) # 8000052a <panic>
panic("virtio disk has no queue 0");
800062a6: 00002517 auipc a0,0x2
800062aa: 62a50513 addi a0,a0,1578 # 800088d0 <syscalls+0x380>
800062ae: ffffa097 auipc ra,0xffffa
800062b2: 27c080e7 jalr 636(ra) # 8000052a <panic>
panic("virtio disk max queue too short");
800062b6: 00002517 auipc a0,0x2
800062ba: 63a50513 addi a0,a0,1594 # 800088f0 <syscalls+0x3a0>
800062be: ffffa097 auipc ra,0xffffa
800062c2: 26c080e7 jalr 620(ra) # 8000052a <panic>
00000000800062c6 <virtio_disk_rw>:
return 0;
}
void
virtio_disk_rw(struct buf *b, int write)
{
800062c6: 7119 addi sp,sp,-128
800062c8: fc86 sd ra,120(sp)
800062ca: f8a2 sd s0,112(sp)
800062cc: f4a6 sd s1,104(sp)
800062ce: f0ca sd s2,96(sp)
800062d0: ecce sd s3,88(sp)
800062d2: e8d2 sd s4,80(sp)
800062d4: e4d6 sd s5,72(sp)
800062d6: e0da sd s6,64(sp)
800062d8: fc5e sd s7,56(sp)
800062da: f862 sd s8,48(sp)
800062dc: f466 sd s9,40(sp)
800062de: f06a sd s10,32(sp)
800062e0: ec6e sd s11,24(sp)
800062e2: 0100 addi s0,sp,128
800062e4: 8aaa mv s5,a0
800062e6: 8d2e mv s10,a1
uint64 sector = b->blockno * (BSIZE / 512);
800062e8: 00c52c83 lw s9,12(a0)
800062ec: 001c9c9b slliw s9,s9,0x1
800062f0: 1c82 slli s9,s9,0x20
800062f2: 020cdc93 srli s9,s9,0x20
acquire(&disk.vdisk_lock);
800062f6: 00020517 auipc a0,0x20
800062fa: e3250513 addi a0,a0,-462 # 80026128 <disk+0x2128>
800062fe: ffffb097 auipc ra,0xffffb
80006302: 8c4080e7 jalr -1852(ra) # 80000bc2 <acquire>
for(int i = 0; i < 3; i++){
80006306: 4981 li s3,0
for(int i = 0; i < NUM; i++){
80006308: 44a1 li s1,8
disk.free[i] = 0;
8000630a: 0001ec17 auipc s8,0x1e
8000630e: cf6c0c13 addi s8,s8,-778 # 80024000 <disk>
80006312: 6b89 lui s7,0x2
for(int i = 0; i < 3; i++){
80006314: 4b0d li s6,3
80006316: a0ad j 80006380 <virtio_disk_rw+0xba>
disk.free[i] = 0;
80006318: 00fc0733 add a4,s8,a5
8000631c: 975e add a4,a4,s7
8000631e: 00070c23 sb zero,24(a4)
idx[i] = alloc_desc();
80006322: c19c sw a5,0(a1)
if(idx[i] < 0){
80006324: 0207c563 bltz a5,8000634e <virtio_disk_rw+0x88>
for(int i = 0; i < 3; i++){
80006328: 2905 addiw s2,s2,1
8000632a: 0611 addi a2,a2,4
8000632c: 19690d63 beq s2,s6,800064c6 <virtio_disk_rw+0x200>
idx[i] = alloc_desc();
80006330: 85b2 mv a1,a2
for(int i = 0; i < NUM; i++){
80006332: 00020717 auipc a4,0x20
80006336: ce670713 addi a4,a4,-794 # 80026018 <disk+0x2018>
8000633a: 87ce mv a5,s3
if(disk.free[i]){
8000633c: 00074683 lbu a3,0(a4)
80006340: fee1 bnez a3,80006318 <virtio_disk_rw+0x52>
for(int i = 0; i < NUM; i++){
80006342: 2785 addiw a5,a5,1
80006344: 0705 addi a4,a4,1
80006346: fe979be3 bne a5,s1,8000633c <virtio_disk_rw+0x76>
idx[i] = alloc_desc();
8000634a: 57fd li a5,-1
8000634c: c19c sw a5,0(a1)
for(int j = 0; j < i; j++)
8000634e: 01205d63 blez s2,80006368 <virtio_disk_rw+0xa2>
80006352: 8dce mv s11,s3
free_desc(idx[j]);
80006354: 000a2503 lw a0,0(s4)
80006358: 00000097 auipc ra,0x0
8000635c: d8e080e7 jalr -626(ra) # 800060e6 <free_desc>
for(int j = 0; j < i; j++)
80006360: 2d85 addiw s11,s11,1
80006362: 0a11 addi s4,s4,4
80006364: ffb918e3 bne s2,s11,80006354 <virtio_disk_rw+0x8e>
int idx[3];
while(1){
if(alloc3_desc(idx) == 0) {
break;
}
sleep(&disk.free[0], &disk.vdisk_lock);
80006368: 00020597 auipc a1,0x20
8000636c: dc058593 addi a1,a1,-576 # 80026128 <disk+0x2128>
80006370: 00020517 auipc a0,0x20
80006374: ca850513 addi a0,a0,-856 # 80026018 <disk+0x2018>
80006378: ffffc097 auipc ra,0xffffc
8000637c: d7c080e7 jalr -644(ra) # 800020f4 <sleep>
for(int i = 0; i < 3; i++){
80006380: f8040a13 addi s4,s0,-128
{
80006384: 8652 mv a2,s4
for(int i = 0; i < 3; i++){
80006386: 894e mv s2,s3
80006388: b765 j 80006330 <virtio_disk_rw+0x6a>
disk.desc[idx[0]].next = idx[1];
disk.desc[idx[1]].addr = (uint64) b->data;
disk.desc[idx[1]].len = BSIZE;
if(write)
disk.desc[idx[1]].flags = 0; // device reads b->data
8000638a: 00020697 auipc a3,0x20
8000638e: c766b683 ld a3,-906(a3) # 80026000 <disk+0x2000>
80006392: 96ba add a3,a3,a4
80006394: 00069623 sh zero,12(a3)
else
disk.desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
disk.desc[idx[1]].flags |= VRING_DESC_F_NEXT;
80006398: 0001e817 auipc a6,0x1e
8000639c: c6880813 addi a6,a6,-920 # 80024000 <disk>
800063a0: 00020697 auipc a3,0x20
800063a4: c6068693 addi a3,a3,-928 # 80026000 <disk+0x2000>
800063a8: 6290 ld a2,0(a3)
800063aa: 963a add a2,a2,a4
800063ac: 00c65583 lhu a1,12(a2) # 200c <_entry-0x7fffdff4>
800063b0: 0015e593 ori a1,a1,1
800063b4: 00b61623 sh a1,12(a2)
disk.desc[idx[1]].next = idx[2];
800063b8: f8842603 lw a2,-120(s0)
800063bc: 628c ld a1,0(a3)
800063be: 972e add a4,a4,a1
800063c0: 00c71723 sh a2,14(a4)
disk.info[idx[0]].status = 0xff; // device writes 0 on success
800063c4: 20050593 addi a1,a0,512
800063c8: 0592 slli a1,a1,0x4
800063ca: 95c2 add a1,a1,a6
800063cc: 577d li a4,-1
800063ce: 02e58823 sb a4,48(a1)
disk.desc[idx[2]].addr = (uint64) &disk.info[idx[0]].status;
800063d2: 00461713 slli a4,a2,0x4
800063d6: 6290 ld a2,0(a3)
800063d8: 963a add a2,a2,a4
800063da: 03078793 addi a5,a5,48
800063de: 97c2 add a5,a5,a6
800063e0: e21c sd a5,0(a2)
disk.desc[idx[2]].len = 1;
800063e2: 629c ld a5,0(a3)
800063e4: 97ba add a5,a5,a4
800063e6: 4605 li a2,1
800063e8: c790 sw a2,8(a5)
disk.desc[idx[2]].flags = VRING_DESC_F_WRITE; // device writes the status
800063ea: 629c ld a5,0(a3)
800063ec: 97ba add a5,a5,a4
800063ee: 4809 li a6,2
800063f0: 01079623 sh a6,12(a5)
disk.desc[idx[2]].next = 0;
800063f4: 629c ld a5,0(a3)
800063f6: 973e add a4,a4,a5
800063f8: 00071723 sh zero,14(a4)
// record struct buf for virtio_disk_intr().
b->disk = 1;
800063fc: 00caa223 sw a2,4(s5)
disk.info[idx[0]].b = b;
80006400: 0355b423 sd s5,40(a1)
// tell the device the first index in our chain of descriptors.
disk.avail->ring[disk.avail->idx % NUM] = idx[0];
80006404: 6698 ld a4,8(a3)
80006406: 00275783 lhu a5,2(a4)
8000640a: 8b9d andi a5,a5,7
8000640c: 0786 slli a5,a5,0x1
8000640e: 97ba add a5,a5,a4
80006410: 00a79223 sh a0,4(a5)
__sync_synchronize();
80006414: 0ff0000f fence
// tell the device another avail ring entry is available.
disk.avail->idx += 1; // not % NUM ...
80006418: 6698 ld a4,8(a3)
8000641a: 00275783 lhu a5,2(a4)
8000641e: 2785 addiw a5,a5,1
80006420: 00f71123 sh a5,2(a4)
__sync_synchronize();
80006424: 0ff0000f fence
*R(VIRTIO_MMIO_QUEUE_NOTIFY) = 0; // value is queue number
80006428: 100017b7 lui a5,0x10001
8000642c: 0407a823 sw zero,80(a5) # 10001050 <_entry-0x6fffefb0>
// Wait for virtio_disk_intr() to say request has finished.
while(b->disk == 1) {
80006430: 004aa783 lw a5,4(s5)
80006434: 02c79163 bne a5,a2,80006456 <virtio_disk_rw+0x190>
sleep(b, &disk.vdisk_lock);
80006438: 00020917 auipc s2,0x20
8000643c: cf090913 addi s2,s2,-784 # 80026128 <disk+0x2128>
while(b->disk == 1) {
80006440: 4485 li s1,1
sleep(b, &disk.vdisk_lock);
80006442: 85ca mv a1,s2
80006444: 8556 mv a0,s5
80006446: ffffc097 auipc ra,0xffffc
8000644a: cae080e7 jalr -850(ra) # 800020f4 <sleep>
while(b->disk == 1) {
8000644e: 004aa783 lw a5,4(s5)
80006452: fe9788e3 beq a5,s1,80006442 <virtio_disk_rw+0x17c>
}
disk.info[idx[0]].b = 0;
80006456: f8042903 lw s2,-128(s0)
8000645a: 20090793 addi a5,s2,512
8000645e: 00479713 slli a4,a5,0x4
80006462: 0001e797 auipc a5,0x1e
80006466: b9e78793 addi a5,a5,-1122 # 80024000 <disk>
8000646a: 97ba add a5,a5,a4
8000646c: 0207b423 sd zero,40(a5)
int flag = disk.desc[i].flags;
80006470: 00020997 auipc s3,0x20
80006474: b9098993 addi s3,s3,-1136 # 80026000 <disk+0x2000>
80006478: 00491713 slli a4,s2,0x4
8000647c: 0009b783 ld a5,0(s3)
80006480: 97ba add a5,a5,a4
80006482: 00c7d483 lhu s1,12(a5)
int nxt = disk.desc[i].next;
80006486: 854a mv a0,s2
80006488: 00e7d903 lhu s2,14(a5)
free_desc(i);
8000648c: 00000097 auipc ra,0x0
80006490: c5a080e7 jalr -934(ra) # 800060e6 <free_desc>
if(flag & VRING_DESC_F_NEXT)
80006494: 8885 andi s1,s1,1
80006496: f0ed bnez s1,80006478 <virtio_disk_rw+0x1b2>
free_chain(idx[0]);
release(&disk.vdisk_lock);
80006498: 00020517 auipc a0,0x20
8000649c: c9050513 addi a0,a0,-880 # 80026128 <disk+0x2128>
800064a0: ffffa097 auipc ra,0xffffa
800064a4: 7d6080e7 jalr 2006(ra) # 80000c76 <release>
}
800064a8: 70e6 ld ra,120(sp)
800064aa: 7446 ld s0,112(sp)
800064ac: 74a6 ld s1,104(sp)
800064ae: 7906 ld s2,96(sp)
800064b0: 69e6 ld s3,88(sp)
800064b2: 6a46 ld s4,80(sp)
800064b4: 6aa6 ld s5,72(sp)
800064b6: 6b06 ld s6,64(sp)
800064b8: 7be2 ld s7,56(sp)
800064ba: 7c42 ld s8,48(sp)
800064bc: 7ca2 ld s9,40(sp)
800064be: 7d02 ld s10,32(sp)
800064c0: 6de2 ld s11,24(sp)
800064c2: 6109 addi sp,sp,128
800064c4: 8082 ret
struct virtio_blk_req *buf0 = &disk.ops[idx[0]];
800064c6: f8042503 lw a0,-128(s0)
800064ca: 20050793 addi a5,a0,512
800064ce: 0792 slli a5,a5,0x4
if(write)
800064d0: 0001e817 auipc a6,0x1e
800064d4: b3080813 addi a6,a6,-1232 # 80024000 <disk>
800064d8: 00f80733 add a4,a6,a5
800064dc: 01a036b3 snez a3,s10
800064e0: 0ad72423 sw a3,168(a4)
buf0->reserved = 0;
800064e4: 0a072623 sw zero,172(a4)
buf0->sector = sector;
800064e8: 0b973823 sd s9,176(a4)
disk.desc[idx[0]].addr = (uint64) buf0;
800064ec: 7679 lui a2,0xffffe
800064ee: 963e add a2,a2,a5
800064f0: 00020697 auipc a3,0x20
800064f4: b1068693 addi a3,a3,-1264 # 80026000 <disk+0x2000>
800064f8: 6298 ld a4,0(a3)
800064fa: 9732 add a4,a4,a2
struct virtio_blk_req *buf0 = &disk.ops[idx[0]];
800064fc: 0a878593 addi a1,a5,168
80006500: 95c2 add a1,a1,a6
disk.desc[idx[0]].addr = (uint64) buf0;
80006502: e30c sd a1,0(a4)
disk.desc[idx[0]].len = sizeof(struct virtio_blk_req);
80006504: 6298 ld a4,0(a3)
80006506: 9732 add a4,a4,a2
80006508: 45c1 li a1,16
8000650a: c70c sw a1,8(a4)
disk.desc[idx[0]].flags = VRING_DESC_F_NEXT;
8000650c: 6298 ld a4,0(a3)
8000650e: 9732 add a4,a4,a2
80006510: 4585 li a1,1
80006512: 00b71623 sh a1,12(a4)
disk.desc[idx[0]].next = idx[1];
80006516: f8442703 lw a4,-124(s0)
8000651a: 628c ld a1,0(a3)
8000651c: 962e add a2,a2,a1
8000651e: 00e61723 sh a4,14(a2) # ffffffffffffe00e <end+0xffffffff7ffd700e>
disk.desc[idx[1]].addr = (uint64) b->data;
80006522: 0712 slli a4,a4,0x4
80006524: 6290 ld a2,0(a3)
80006526: 963a add a2,a2,a4
80006528: 058a8593 addi a1,s5,88
8000652c: e20c sd a1,0(a2)
disk.desc[idx[1]].len = BSIZE;
8000652e: 6294 ld a3,0(a3)
80006530: 96ba add a3,a3,a4
80006532: 40000613 li a2,1024
80006536: c690 sw a2,8(a3)
if(write)
80006538: e40d19e3 bnez s10,8000638a <virtio_disk_rw+0xc4>
disk.desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
8000653c: 00020697 auipc a3,0x20
80006540: ac46b683 ld a3,-1340(a3) # 80026000 <disk+0x2000>
80006544: 96ba add a3,a3,a4
80006546: 4609 li a2,2
80006548: 00c69623 sh a2,12(a3)
8000654c: b5b1 j 80006398 <virtio_disk_rw+0xd2>
000000008000654e <virtio_disk_intr>:
void
virtio_disk_intr()
{
8000654e: 1101 addi sp,sp,-32
80006550: ec06 sd ra,24(sp)
80006552: e822 sd s0,16(sp)
80006554: e426 sd s1,8(sp)
80006556: e04a sd s2,0(sp)
80006558: 1000 addi s0,sp,32
acquire(&disk.vdisk_lock);
8000655a: 00020517 auipc a0,0x20
8000655e: bce50513 addi a0,a0,-1074 # 80026128 <disk+0x2128>
80006562: ffffa097 auipc ra,0xffffa
80006566: 660080e7 jalr 1632(ra) # 80000bc2 <acquire>
// we've seen this interrupt, which the following line does.
// this may race with the device writing new entries to
// the "used" ring, in which case we may process the new
// completion entries in this interrupt, and have nothing to do
// in the next interrupt, which is harmless.
*R(VIRTIO_MMIO_INTERRUPT_ACK) = *R(VIRTIO_MMIO_INTERRUPT_STATUS) & 0x3;
8000656a: 10001737 lui a4,0x10001
8000656e: 533c lw a5,96(a4)
80006570: 8b8d andi a5,a5,3
80006572: d37c sw a5,100(a4)
__sync_synchronize();
80006574: 0ff0000f fence
// the device increments disk.used->idx when it
// adds an entry to the used ring.
while(disk.used_idx != disk.used->idx){
80006578: 00020797 auipc a5,0x20
8000657c: a8878793 addi a5,a5,-1400 # 80026000 <disk+0x2000>
80006580: 6b94 ld a3,16(a5)
80006582: 0207d703 lhu a4,32(a5)
80006586: 0026d783 lhu a5,2(a3)
8000658a: 06f70163 beq a4,a5,800065ec <virtio_disk_intr+0x9e>
__sync_synchronize();
int id = disk.used->ring[disk.used_idx % NUM].id;
8000658e: 0001e917 auipc s2,0x1e
80006592: a7290913 addi s2,s2,-1422 # 80024000 <disk>
80006596: 00020497 auipc s1,0x20
8000659a: a6a48493 addi s1,s1,-1430 # 80026000 <disk+0x2000>
__sync_synchronize();
8000659e: 0ff0000f fence
int id = disk.used->ring[disk.used_idx % NUM].id;
800065a2: 6898 ld a4,16(s1)
800065a4: 0204d783 lhu a5,32(s1)
800065a8: 8b9d andi a5,a5,7
800065aa: 078e slli a5,a5,0x3
800065ac: 97ba add a5,a5,a4
800065ae: 43dc lw a5,4(a5)
if(disk.info[id].status != 0)
800065b0: 20078713 addi a4,a5,512
800065b4: 0712 slli a4,a4,0x4
800065b6: 974a add a4,a4,s2
800065b8: 03074703 lbu a4,48(a4) # 10001030 <_entry-0x6fffefd0>
800065bc: e731 bnez a4,80006608 <virtio_disk_intr+0xba>
panic("virtio_disk_intr status");
struct buf *b = disk.info[id].b;
800065be: 20078793 addi a5,a5,512
800065c2: 0792 slli a5,a5,0x4
800065c4: 97ca add a5,a5,s2
800065c6: 7788 ld a0,40(a5)
b->disk = 0; // disk is done with buf
800065c8: 00052223 sw zero,4(a0)
wakeup(b);
800065cc: ffffc097 auipc ra,0xffffc
800065d0: d9c080e7 jalr -612(ra) # 80002368 <wakeup>
disk.used_idx += 1;
800065d4: 0204d783 lhu a5,32(s1)
800065d8: 2785 addiw a5,a5,1
800065da: 17c2 slli a5,a5,0x30
800065dc: 93c1 srli a5,a5,0x30
800065de: 02f49023 sh a5,32(s1)
while(disk.used_idx != disk.used->idx){
800065e2: 6898 ld a4,16(s1)
800065e4: 00275703 lhu a4,2(a4)
800065e8: faf71be3 bne a4,a5,8000659e <virtio_disk_intr+0x50>
}
release(&disk.vdisk_lock);
800065ec: 00020517 auipc a0,0x20
800065f0: b3c50513 addi a0,a0,-1220 # 80026128 <disk+0x2128>
800065f4: ffffa097 auipc ra,0xffffa
800065f8: 682080e7 jalr 1666(ra) # 80000c76 <release>
}
800065fc: 60e2 ld ra,24(sp)
800065fe: 6442 ld s0,16(sp)
80006600: 64a2 ld s1,8(sp)
80006602: 6902 ld s2,0(sp)
80006604: 6105 addi sp,sp,32
80006606: 8082 ret
panic("virtio_disk_intr status");
80006608: 00002517 auipc a0,0x2
8000660c: 30850513 addi a0,a0,776 # 80008910 <syscalls+0x3c0>
80006610: ffffa097 auipc ra,0xffffa
80006614: f1a080e7 jalr -230(ra) # 8000052a <panic>
...
0000000080007000 <_trampoline>:
80007000: 14051573 csrrw a0,sscratch,a0
80007004: 02153423 sd ra,40(a0)
80007008: 02253823 sd sp,48(a0)
8000700c: 02353c23 sd gp,56(a0)
80007010: 04453023 sd tp,64(a0)
80007014: 04553423 sd t0,72(a0)
80007018: 04653823 sd t1,80(a0)
8000701c: 04753c23 sd t2,88(a0)
80007020: f120 sd s0,96(a0)
80007022: f524 sd s1,104(a0)
80007024: fd2c sd a1,120(a0)
80007026: e150 sd a2,128(a0)
80007028: e554 sd a3,136(a0)
8000702a: e958 sd a4,144(a0)
8000702c: ed5c sd a5,152(a0)
8000702e: 0b053023 sd a6,160(a0)
80007032: 0b153423 sd a7,168(a0)
80007036: 0b253823 sd s2,176(a0)
8000703a: 0b353c23 sd s3,184(a0)
8000703e: 0d453023 sd s4,192(a0)
80007042: 0d553423 sd s5,200(a0)
80007046: 0d653823 sd s6,208(a0)
8000704a: 0d753c23 sd s7,216(a0)
8000704e: 0f853023 sd s8,224(a0)
80007052: 0f953423 sd s9,232(a0)
80007056: 0fa53823 sd s10,240(a0)
8000705a: 0fb53c23 sd s11,248(a0)
8000705e: 11c53023 sd t3,256(a0)
80007062: 11d53423 sd t4,264(a0)
80007066: 11e53823 sd t5,272(a0)
8000706a: 11f53c23 sd t6,280(a0)
8000706e: 140022f3 csrr t0,sscratch
80007072: 06553823 sd t0,112(a0)
80007076: 00853103 ld sp,8(a0)
8000707a: 02053203 ld tp,32(a0)
8000707e: 01053283 ld t0,16(a0)
80007082: 00053303 ld t1,0(a0)
80007086: 18031073 csrw satp,t1
8000708a: 12000073 sfence.vma
8000708e: 8282 jr t0
0000000080007090 <userret>:
80007090: 18059073 csrw satp,a1
80007094: 12000073 sfence.vma
80007098: 07053283 ld t0,112(a0)
8000709c: 14029073 csrw sscratch,t0
800070a0: 02853083 ld ra,40(a0)
800070a4: 03053103 ld sp,48(a0)
800070a8: 03853183 ld gp,56(a0)
800070ac: 04053203 ld tp,64(a0)
800070b0: 04853283 ld t0,72(a0)
800070b4: 05053303 ld t1,80(a0)
800070b8: 05853383 ld t2,88(a0)
800070bc: 7120 ld s0,96(a0)
800070be: 7524 ld s1,104(a0)
800070c0: 7d2c ld a1,120(a0)
800070c2: 6150 ld a2,128(a0)
800070c4: 6554 ld a3,136(a0)
800070c6: 6958 ld a4,144(a0)
800070c8: 6d5c ld a5,152(a0)
800070ca: 0a053803 ld a6,160(a0)
800070ce: 0a853883 ld a7,168(a0)
800070d2: 0b053903 ld s2,176(a0)
800070d6: 0b853983 ld s3,184(a0)
800070da: 0c053a03 ld s4,192(a0)
800070de: 0c853a83 ld s5,200(a0)
800070e2: 0d053b03 ld s6,208(a0)
800070e6: 0d853b83 ld s7,216(a0)
800070ea: 0e053c03 ld s8,224(a0)
800070ee: 0e853c83 ld s9,232(a0)
800070f2: 0f053d03 ld s10,240(a0)
800070f6: 0f853d83 ld s11,248(a0)
800070fa: 10053e03 ld t3,256(a0)
800070fe: 10853e83 ld t4,264(a0)
80007102: 11053f03 ld t5,272(a0)
80007106: 11853f83 ld t6,280(a0)
8000710a: 14051573 csrrw a0,sscratch,a0
8000710e: 10200073 sret
...
| 42.083796 | 105 | 0.518761 |
6e771e3fdc03b9ee15f08bf8d9959a9eef3d8b2a | 1,372 | asm | Assembly | Laburi/Lab4/8-divide/divide.asm | DanBrezeanu/IOCLA | 1a22cc2949afc72818289f47288e32004f633fd1 | [
"MIT"
] | 2 | 2019-11-18T15:56:21.000Z | 2020-01-18T01:22:37.000Z | Laburi/Lab4/8-divide/divide.asm | zatbogdan99/IOCLA | 3d499ad18624f571e6c49ff891649a05ac9908e4 | [
"MIT"
] | null | null | null | Laburi/Lab4/8-divide/divide.asm | zatbogdan99/IOCLA | 3d499ad18624f571e6c49ff891649a05ac9908e4 | [
"MIT"
] | null | null | null | %include "io.inc"
; https://en.wikibooks.org/wiki/X86_Assembly/Arithmetic
section .data
string_quotient db "Quotient: ", 0
string_remainder db "Remainder: ", 0
dividend1 db 91
divisor1 db 27
dividend2 dd 67254
divisor2 dw 1349
dividend3 dq 690941487
divisor3 dd 87621
section .text
global CMAIN
CMAIN:
mov ebp, esp; for correct debugging
push ebp
mov ebp, esp
xor eax, eax
mov al, byte [dividend1]
mov bl, byte [divisor1]
div bl
PRINT_STRING string_quotient
PRINT_UDEC 1, AL
NEWLINE
PRINT_STRING string_remainder
PRINT_UDEC 1, AH
NEWLINE
; TODO: Calculate quotient and remainder for 67254 / 1349.
xor eax, eax
xor ebx, ebx
mov edx, dword [dividend2 + 2]
mov ax, word [dividend2]
add bx, word [divisor2]
div bx
PRINT_STRING string_quotient
PRINT_UDEC 2, AX
NEWLINE
PRINT_STRING string_remainder
PRINT_UDEC 2, DX
NEWLINE
; TODO: Calculate quotient and remainder for 69094148 / 87621.
xor eax, eax
xor ebx, ebx
xor edx, edx
mov edx, dword [dividend3 + 4]
mov eax, dword [dividend3]
add ebx, dword [divisor3]
div ebx
PRINT_STRING string_quotient
PRINT_UDEC 4, EAX
NEWLINE
PRINT_STRING string_remainder
PRINT_UDEC 4, EDX
NEWLINE
leave
ret
| 19.323944 | 66 | 0.650875 |
fa8b12e0c0e374e94aa0e3109325d39bd9c53016 | 483 | asm | Assembly | programs/oeis/034/A034834.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/034/A034834.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/034/A034834.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A034834: One seventh of sept-factorial numbers.
; 1,14,294,8232,288120,12101040,592950960,33205253760,2091930986880,146435169081600,11275508019283200,947142673619788800,86189983299400780800,8446618363341276518400,886894928150834034432000,99332231952893411856384000,11820535602394316010909696000,1489387485901683817374621696000,198088535624923947710824685568000,27732394987489352679515455979520000
add $0,1
mov $1,2
lpb $0
sub $0,1
add $2,7
mul $1,$2
lpe
div $1,14
mov $0,$1
| 37.153846 | 348 | 0.846791 |
e61d109ba6f17701578b15df78324491ead29566 | 9,727 | asm | Assembly | src/arch/ia32/boot/floppy/boot.asm | zhengruohuang/toddler | 0d7bde9aaf1fab8fed5f37973eeda9eaa100bd7a | [
"BSD-2-Clause"
] | 80 | 2016-03-27T04:26:57.000Z | 2021-12-24T08:27:55.000Z | src/arch/ia32/boot/floppy/boot.asm | zhengruohuang/toddler | 0d7bde9aaf1fab8fed5f37973eeda9eaa100bd7a | [
"BSD-2-Clause"
] | 1 | 2016-12-08T18:08:20.000Z | 2018-02-23T02:51:35.000Z | src/arch/ia32/boot/floppy/boot.asm | zhengruohuang/toddler | 0d7bde9aaf1fab8fed5f37973eeda9eaa100bd7a | [
"BSD-2-Clause"
] | 11 | 2017-05-09T01:42:07.000Z | 2020-02-13T13:56:36.000Z | ;==============================================================================;
; ;
; Floppy Boot Sector for Toddler on IA32 ;
; ;
;==============================================================================;
;===============================================================================
; Include
;===============================================================================
%include "./common/include/memlayout.inc"
;===============================================================================
;===============================================================================
; Constants
;===============================================================================
CEntry equ BootEntry + 512
;===============================================================================
;===============================================================================
; Entry point
;===============================================================================
; Load position
org BootEntry
Entry:
jmp 0 : Initialize
;===============================================================================
;===============================================================================
; Initialization
;===============================================================================
Initialize:
; Registers for segments
mov ax, cs
mov ds, ax
mov es, ax
mov ss, ax
mov sp, BootStackTop
; Start
jmp Start
;===============================================================================
;===============================================================================
; Strings
;===============================================================================
WelcomeMessage db "Welcome to Toddler!", 0
LoadMessage db "Loading boot program ...", 0
ErrorMessage db "Unable to boot Toddler!", 0
DoneMessage db " Done!", 0
;===============================================================================
;===============================================================================
; Start Booting
;===============================================================================
Start:
; Clear the screen
mov ax, 0600h ; ah = 6, al = 0h
mov bx, 0700h ; Backcolor: Black, Forecolor: White (BL = 07h)
mov cx, 0 ; (Left, Top): (0, 0)
mov dx, 184fh ; (Right, Bottom): (25, 80)
int 10h ; Call int 10h to clear the screen
; Set the position of the cursor
mov ah, 02h
mov bh, 00h
mov dx, 0000h
int 10h
; Show welcome message
mov dx, WelcomeMessage
call ShowText
call NewLine
call NewLine
; Load boot program: floppy sector 1 to 15
mov dx, LoadMessage
call ShowText
mov ax, 1
mov cx, 15
xor ebx, ebx
mov es, bx
mov bx, CEntry
call ReadFile
; Call the start function in C
.CallFunctionInC:
mov dx, DoneMessage
call ShowText
call NewLine
mov ebx, CEntry
jmp ebx
; Should never arrive here
Error:
mov dx, ErrorMessage
call ShowText
call NewLine
; Stop
Stop:
jmp $
;===============================================================================
;===============================================================================
; Functions
;-------------------------------------------------------------------------------
; void print_char(char c in al)
;-------------------------------------------------------------------------------
; Draw a charactor on the screen.
; c: The charactor to draw.
; This param is passed by
; the register al.
;-------------------------------------------------------------------------------
PrintChar:
; Save register values
push ax
push bx
push cx
push dx
; Draw the char on screen
mov ah, 0eh
mov bh, 0
int 10h
; Restore register values
pop dx
pop cx
pop bx
pop ax
; Return
ret
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; void print_string(char *s in dx)
;-------------------------------------------------------------------------------
; Draw some text on the screen.
; s: The text to draw.
; This param is passed by
; the register DX.
;-------------------------------------------------------------------------------
ShowText:
; Save register values
push ax ; Save the value of the registers
push bp
; Copy
mov bp, dx ; Copy the pointer of the string from dx to bp
; Draw a char
.Draw:
cmp byte [bp], 0h ; Compare whether we reaches the end of the string
jz .DrawFinished ; If the drawing is finished, jump to .DrawFinished
mov al, [bp] ; Else, set the char to paint
call PrintChar ; Call print_char
; Move to the next char
inc bp ; Make the pointer point to the next char
jmp .Draw ; Loop
; Finish the drawing (restore register values)
.DrawFinished:
pop bp ; Restore the value of registers
pop ax
; Return
ret
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; void new_line()
;-------------------------------------------------------------------------------
; Move the cursor to the next line.
;-------------------------------------------------------------------------------
NewLine:
push ax ; Save the value of the registers
push bx
push cx
push dx
mov ax, 0300h ; Get the current cursor position
mov bx, 0000h ; Set the page number to 0
int 10h ; Call the BIOS to get the position of the cursor
mov ax, 0200h ; Set the position of the cursor
add dx, 100h ; Increase the value of dh, which means the line number
mov dl, 0h ; Set the cursor to the first column
int 10h ; Call the BIOS to set the position of the cursor
pop dx ; Restore the value of the registers
pop cx
pop bx
pop ax
ret
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; void read_file(int16 sec_num in ax, int16 sec_count in cx,
; void *buffer in es:bx)
;-------------------------------------------------------------------------------
; sec_num: Starting sector,
; sec_count: Sector count
; buffer: Where to load (es:bx = seg : offset)
;-------------------------------------------------------------------------------
ReadFile:
push eax
push ebx
push ecx
.ReadAndPrintDot:
call ReadSector
inc ax
add ebx, 512
.PrintDot:
push ax
mov al, '.'
call PrintChar
pop ax
loop .ReadAndPrintDot
pop ecx
pop ebx
pop eax
ret
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; void read_sector(int16 sec_num in ax, int16 load_to in es:bx)
;-------------------------------------------------------------------------------
; Read a sector to a specific position.
; sec_num: The number of the sector that you want to read.
; This param is passed through register AX.
; load_to: The address that the content of the sector will be stored.
; This parameter is passed through register ES:BX.
;-------------------------------------------------------------------------------
ReadSector:
push ax
push cx
push dx
; Calculate cylinder, sector, and head by LBA
push bx ; Save bx
mov bl, 18 ; bl is divisor
div bl ; y is in al, z is in ah
inc ah ; z ++
mov cl, ah ; cl <- Starting Sector Number
mov dh, al ; dh <- y
shr al, 1 ; y >> 1 (which means y/BPB_NumHeads, BPB_NumHeads=2)
mov ch, al ; ch <- Cylinder Number
and dh, 1 ; dh & 1 = Header Number
pop bx ; Restore bx
.KeepRead:
mov dl, 0 ; The device number that you wish to read (0 means A:\ in DOS)
mov ah, 2 ; Set the function number
mov al, 1 ; Load only onew sector
int 13h ; Call the BIOS to read a sector
jc .KeepRead ; If there are errors, CF will be set to 1,
; we will continue reading until it errors are corrected
pop dx
pop cx
pop ax
ret
;-------------------------------------------------------------------------------
;===============================================================================
;===============================================================================
; End of Boot Sector: Magic Number
;===============================================================================
times 510 - ($ - $$) db 0 ; Fill the rest sapce, in order to make the file size 512B
dw 0xaa55 ; Magic number
;===============================================================================
| 33.311644 | 94 | 0.338953 |
3336fdf50616c52664ba25c36aa936d9a19d3a1b | 1,330 | asm | Assembly | tp_01_07/bootld.asm | mjFer/TDIII-UTN-FRBA-TPS-2014 | 1b57b52fa8233c78297b0e5471d1c82e4c85451b | [
"MIT"
] | 2 | 2020-04-01T14:45:17.000Z | 2020-04-01T14:45:23.000Z | tp_01_10/bootld.asm | mjFer/TDIII-UTN-FRBA-TPS-2014 | 1b57b52fa8233c78297b0e5471d1c82e4c85451b | [
"MIT"
] | null | null | null | tp_01_10/bootld.asm | mjFer/TDIII-UTN-FRBA-TPS-2014 | 1b57b52fa8233c78297b0e5471d1c82e4c85451b | [
"MIT"
] | null | null | null | [ORG 0x7C00];BIOS loads bootsector here
%ifndef KERNEL_MEMORY
%error "Kernel start address not defined"
;kernel_memory must be 16 byte aligned
%endif
%ifndef KERNEL_SIZE_SECTORS
%error "Kernel size (in sectors) not defined"
%endif
[BITS 16] ;for real mode; 16-bit instructions
cli ;clear interrupts
;-----------------------------------------------------------
; INITIALIZATION PROCEDURES
mov ah, 02h ; load int 13h function (read sector)
mov al,KERNEL_SIZE_SECTORS ; load how many sectors will be read
mov cx, 02h ; starting from track 0, sector 2
mov dh, 0 ; load head = 0
mov dl, 0 ; drive 0 (A:)
mov ebx, KERNEL_MEMORY ; load linear destination address at ebx
shr ebx,4 ; shift right ebx (result at BX will be the segment)
mov es,bx ; load destination segment
mov bx, 0 ; load 0 offset
int 13h ; read disk
;---------------------------------------------------------------------------
jc error ; if carry is set, int 13h didn't work
jmp (KERNEL_MEMORY>>4):0 ; jmp to the kernel code
error:
hlt
times 510-($-$$) db 0 ;fill the space till 510
;with zeroes
dw 0xAA55 ;boot sector identifier
| 33.25 | 86 | 0.536842 |
48129b573878b0e156796d9e9c9ebf9a2c67197a | 5,175 | asm | Assembly | Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2877.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 9 | 2020-08-13T19:41:58.000Z | 2022-03-30T12:22:51.000Z | Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2877.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 1 | 2021-04-29T06:29:35.000Z | 2021-05-13T21:02:30.000Z | Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48.log_21829_2877.asm | ljhsiun2/medusa | 67d769b8a2fb42c538f10287abaf0e6dbb463f0c | [
"MIT"
] | 3 | 2020-07-14T17:07:07.000Z | 2022-03-21T01:12:22.000Z | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %r8
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0xb03e, %rsi
nop
nop
nop
sub $13010, %r14
movb (%rsi), %r11b
nop
nop
nop
nop
nop
cmp %r12, %r12
lea addresses_UC_ht+0x1ab9e, %rsi
lea addresses_WC_ht+0x983e, %rdi
nop
nop
nop
nop
xor $28649, %r11
mov $33, %rcx
rep movsl
nop
nop
nop
nop
inc %rsi
lea addresses_A_ht+0x1e20a, %rcx
nop
nop
nop
nop
and %r8, %r8
mov $0x6162636465666768, %rdi
movq %rdi, %xmm0
vmovups %ymm0, (%rcx)
nop
nop
nop
nop
nop
cmp $56863, %rdi
lea addresses_A_ht+0x7f3a, %rcx
nop
nop
nop
dec %r11
movw $0x6162, (%rcx)
nop
and %rsi, %rsi
lea addresses_WT_ht+0x5626, %rdi
nop
dec %r14
mov $0x6162636465666768, %r8
movq %r8, %xmm0
and $0xffffffffffffffc0, %rdi
vmovntdq %ymm0, (%rdi)
nop
dec %r14
pop %rsi
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r9
push %rax
push %rbp
push %rcx
// Faulty Load
lea addresses_PSE+0x1e83e, %rcx
add %r13, %r13
movups (%rcx), %xmm4
vpextrq $0, %xmm4, %rbp
lea oracles, %rax
and $0xff, %rbp
shlq $12, %rbp
mov (%rax,%rbp,1), %rbp
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 2, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 2, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 32, 'same': True, 'NT': True}}
{'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
*/
| 43.855932 | 2,999 | 0.662029 |
f4042925428a01434693d307f17d98b6fe6e89b4 | 360 | asm | Assembly | libsrc/_DEVELOPMENT/math/float/am9511/lam32/c/sdcc/___mulsint2slong_callee.asm | dikdom/z88dk | 40c55771062b0ea9bb2f0d5b73e2f754fc12b6b0 | [
"ClArtistic"
] | null | null | null | libsrc/_DEVELOPMENT/math/float/am9511/lam32/c/sdcc/___mulsint2slong_callee.asm | dikdom/z88dk | 40c55771062b0ea9bb2f0d5b73e2f754fc12b6b0 | [
"ClArtistic"
] | 2 | 2022-03-20T22:17:35.000Z | 2022-03-24T16:10:00.000Z | libsrc/_DEVELOPMENT/math/float/am9511/lam32/c/sdcc/___mulsint2slong_callee.asm | jorgegv/z88dk | 127130cf11f9ff268ba53e308138b12d2b9be90a | [
"ClArtistic"
] | null | null | null |
SECTION code_clib
SECTION code_fp_am9511
PUBLIC ___mulsint2slong_callee
EXTERN cam32_sdcc___mulsint2slong_callee
; multiply two signed 16-bit multiplicands into a 32-bit product
;
; enter : stack = multiplicand (16-bit), multiplicand (16-bit), ret
;
; exit : dehl = product
defc ___mulsint2slong_callee = cam32_sdcc___mulsint2slong_callee
| 22.5 | 70 | 0.775 |
5e38835a5ba7af324087ebc5de51a5ba335c61f7 | 648 | asm | Assembly | programs/oeis/062/A062813.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/062/A062813.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/062/A062813.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A062813: a(n) = Sum_{i=0..n-1} i*n^i.
; 0,2,21,228,2930,44790,800667,16434824,381367044,9876543210,282458553905,8842413667692,300771807240918,11046255305880158,435659737878916215,18364758544493064720,824008854613343261192,39210261334551566857170,1972313422155189164466189,104567135734072022160664820,5827980550840017565077671610,340653664490377789692799452102,20837326537038308910317109288851,1331214537196502869015340298036888,88663644327703473714387251271141900
add $0,1
mov $2,$0
lpb $0
mov $3,$2
mul $3,$2
mov $4,$0
cmp $4,0
add $0,$4
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
add $1,$3
mul $1,$2
lpe
mov $0,$1
| 30.857143 | 425 | 0.773148 |
847ac0f7f08c456a34c90f3efdaaeb16705e78cc | 758 | asm | Assembly | oeis/089/A089591.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/089/A089591.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/089/A089591.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A089591: "Lazy binary" representation of n. Also called redundant binary representation of n.
; Submitted by Christian Krause
; 0,1,10,11,20,101,110,111,120,201,210,1011,1020,1101,1110,1111,1120,1201,1210,2011,2020,2101,2110,10111,10120,10201,10210,11011,11020,11101,11110,11111,11120,11201,11210,12011,12020,12101,12110,20111,20120,20201,20210,21011,21020,21101,21110,101111,101120,101201,101210,102011,102020,102101,102110,110111,110120,110201,110210,111011,111020,111101,111110,111111,111120,111201,111210,112011,112020,112101,112110,120111,120120,120201,120210,121011,121020,121101,121110,201111,201120,201201,201210,202011
seq $0,137951 ; Redundant binary representation (A089591) of n interpreted as ternary number.
seq $0,7089 ; Numbers in base 3.
| 108.285714 | 501 | 0.811346 |
48990294b2a42d687455beeac86db8f06b68e07c | 823 | asm | Assembly | oeis/141/A141916.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/141/A141916.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/141/A141916.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A141916: Primes congruent to 12 mod 23.
; Submitted by Christian Krause
; 127,173,311,449,541,587,863,1093,1231,1277,1553,1783,2243,2381,2473,2657,2749,2887,3163,3209,3301,3347,3623,3761,3853,4129,4451,4957,5003,5233,5279,5417,5647,5693,5923,6199,6337,6521,6659,7027,7211,7349,7487,7717,7901,7993,8039,8269,8821,8867,9281,9419,9511,9649,9787,9833,10247,10477,10753,10799,10891,10937,11213,11351,11443,11489,11719,11903,12041,12409,12547,12823,13007,13099,13421,13513,13697,13789,14249,14341,14387,14479,14939,15031,15077,15307,15583,15629,15767,15859,16273,16319,16411
mov $1,1
mov $2,$0
add $2,2
pow $2,2
lpb $2
add $1,33
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,13
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,1
lpe
mov $0,$1
add $0,34
| 35.782609 | 496 | 0.727825 |
7684881b545729528f9be62ad3f5f3500106e938 | 188 | asm | Assembly | PRG/objects/Unused13.asm | narfman0/smb3_pp1 | 38a58adafff67a403591e38875e9fae943a5fe76 | [
"Unlicense"
] | null | null | null | PRG/objects/Unused13.asm | narfman0/smb3_pp1 | 38a58adafff67a403591e38875e9fae943a5fe76 | [
"Unlicense"
] | null | null | null | PRG/objects/Unused13.asm | narfman0/smb3_pp1 | 38a58adafff67a403591e38875e9fae943a5fe76 | [
"Unlicense"
] | null | null | null | .byte $01 ; Unknown purpose
.byte OBJ_REDTROOPA, $1D, $16
.byte OBJ_FLYINGREDPARATROOPA, $29, $17
.byte OBJ_REDTROOPA, $37, $14
.byte OBJ_REDTROOPA, $38, $19
.byte $FF ; Terminator
| 23.5 | 40 | 0.691489 |
4b8c22e1fafa6475cb20cacda78f4de11f513e8a | 3,369 | asm | Assembly | programs/oeis/140/A140162.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/140/A140162.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/140/A140162.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | ; A140162: a(1)=1, a(n) = a(n-1) + n^5 if n odd, a(n) = a(n-1) + n^0 if n is even.
; 1,2,245,246,3371,3372,20179,20180,79229,79230,240281,240282,611575,611576,1370951,1370952,2790809,2790810,5266909,5266910,9351011,9351012,15787355,15787356,25552981,25552982,39901889,39901890,60413039,60413040,89042191,89042192,128177585,128177586,180699461,180699462,250043419,250043420,340267619,340267620,456123821,456123822,603132265,603132266,787660391,787660392,1017005399,1017005400,1299480649,1299480650,1644505901,1644505902,2062701395,2062701396,2565985771,2565985772,3167677829,3167677830,3882602129,3882602130,4727198431,4727198432,5719634975,5719634976,6879925601,6879925602,8230050709,8230050710,9794082059,9794082060,11598311411,11598311412,13671383005,13671383006,16044429881,16044429882,18751214039,18751214040,21828270439,21828270440,25315054841,25315054842,29254095485,29254095486,33691148611,33691148612,38675357819,38675357820,44259417269,44259417270,50499738721,50499738722,57456622415,57456622416,65194431791,65194431792,73781772049,73781772050,83291672549,83291672550,93801773051,93801773052,105394513795,105394513796,118157329421,118157329422,132182846729,132182846730,147569086279,147569086280,164419667831,164419667832,182844019625,182844019626,202957591501,202957591502,224882071859,224882071860,248745608459,248745608460,274683033061,274683033062,302836089905,302836089906,333353668031,333353668032,366392037439,366392037440,402115089089,402115089090,440694578741,440694578742,482310374635,482310374636,527150709011,527150709012,575412433469,575412433470,627301278169,627301278170,683032114871,683032114872,742829223815,742829223816,806926564441,806926564442,875568049949,875568049950,949007825699,949007825700,1027510551451,1027510551452,1111351687445,1111351687446,1200817784321,1200817784322,1296206776879,1296206776880,1397828281679,1397828281680,1506003898481,1506003898482,1621067515525,1621067515526,1743365618651,1743365618652,1873257604259,1873257604260,2011116096109,2011116096110,2157327265961,2157327265962,2312291158055,2312291158056,2476422017431,2476422017432,2650148622089,2650148622090,2833914618989,2833914618990,3028178863891,3028178863892,3233415765035,3233415765036,3450115630661,3450115630662,3678785020369,3678785020370,3919947100319,3919947100320,4174142002271,4174142002272,4441927186465,4441927186466,4723877808341,4723877808342,5020587089099,5020587089100,5332666690099,5332666690100,5660747091101,5660747091102,6005477972345,6005477972346,6367528600471,6367528600472,6747588218279,6747588218280,7146366438329,7146366438330,7564593640381,7564593640382,8003021372675,8003021372676,8462422757051,8462422757052,8943592897909,8943592897910,9447349295009,9447349295010,9974532260111,9974532260112,10526005337455,10526005337456,11102655728081,11102655728082,11705394717989,11705394717990,12335158110139,12335158110140,12992906660291,12992906660292,13679626516685,13679626516686,14396329663561,14396329663562,15144054368519,15144054368520,15923865633719,15923865633720,16736855650921,16736855650922,17584144260365,17584144260366,18466879413491,18466879413492,19386237639499,19386237639500,20343424515749,20343424515750
mov $2,$0
add $2,1
mov $5,$0
lpb $2,1
mov $0,$5
sub $2,1
sub $0,$2
mov $4,$0
gcd $0,2
mov $3,5
gcd $6,1
add $4,$6
lpb $0,1
gcd $4,$0
pow $0,7
sub $0,1
lpe
pow $4,$3
add $1,$4
lpe
| 140.375 | 3,069 | 0.876521 |
a879226f41ab376efc2d4b25d75820854c5c13d0 | 3,497 | asm | Assembly | boot/ipl.asm | uchan-nos/bitnos | fe8e08448db418e07417d0d31d72b801ebf3078b | [
"Zlib"
] | null | null | null | boot/ipl.asm | uchan-nos/bitnos | fe8e08448db418e07417d0d31d72b801ebf3078b | [
"Zlib"
] | null | null | null | boot/ipl.asm | uchan-nos/bitnos | fe8e08448db418e07417d0d31d72b801ebf3078b | [
"Zlib"
] | null | null | null |
READ_SEC equ 0x7e00
TEMP equ 0x7e04
org 0x7c00
JMP entry
DB 0x90
DB "BITNOS " ; ブートセクタの名前を自由に書いてよい(8バイト)
DW 512 ; 1セクタの大きさ(512にしなければいけない)
DB 1 ; クラスタの大きさ(1セクタにしなければいけない)
DW 1 ; FATがどこから始まるか(普通は1セクタ目からにする)
DB 2 ; FATの個数(2にしなければいけない)
DW 224 ; ルートディレクトリ領域の大きさ(普通は224エントリにする)
DW 2880 ; このドライブの大きさ(2880セクタにしなければいけない)
DB 0xf0 ; メディアのタイプ(0xf0にしなければいけない)
DW 9 ; FAT領域の長さ(9セクタにしなければいけない)
DW 18 ; 1トラックにいくつのセクタがあるか(18にしなければいけない)
DW 2 ; ヘッドの数(2にしなければいけない)
DD 0 ; パーティションを使ってないのでここは必ず0
DD 2880 ; このドライブ大きさをもう一度書く
DB 0,0,0x29 ; よくわからないけどこの値にしておくといいらしい
DD 0xffffffff ; たぶんボリュームシリアル番号
DB "BITNOS BOOT" ; ディスクの名前(11バイト)
DB "FAT12 " ; フォーマットの名前(8バイト)
TIMES 18 DB 0 ; とりあえず18バイトあけておく
; プログラム本体
entry:
mov ax, 0
mov ss, ax
mov sp, 0x7c00 ; 0x7c00以前は空いている
mov ds, ax
mov es, ax
mov si, mesg
call puts
; ルートディレクトリエントリを使いたいため
; とりあえず20セクタ以上読み込む
; シリンダ0をすべて読む
mov ax, 0x0820
mov es, ax ; save at 0x8200 of memory
mov ch, 0 ; cylinder 0
mov dh, 0 ; head 0
mov cl, 2 ; sector 2
mov di, 35
call fd_read
; 0x2600からルートディレクトリエントリ
; calculate file size of BOOT.SYS
mov ax, [0xa600 + 28] ; low 16 bits of file size
shr ax, 9 ; sectors of file (low 7 bits)
mov dx, [0xa600 + 30] ; high 16 bits of file size
shl dx, 7 ; sectors of file (high 9 bits)
or ax, dx
inc ax ; sectors of file
;add ax, 21 ; sectors to read
mov di, ax ; save the number
;cmp di, 36 ; 36sectors have already been read
mov ax, di
add ax, 33
mov word [0x0f00], ax
mov word [0x0f02], 0
cmp di, 3
jbe boot_program
;sub di, 36
sub di, 3
; read file from disk
mov ax, 0x0c80
mov es, ax ; save at 0xc800 of memory
mov ch, 1 ; cylinder 1
mov dh, 0 ; head 0
mov cl, 1 ; sector 1
call fd_read
boot_program:
mov si, mesg_ok
call puts
mov si, mesg2
call puts
jmp 0xc200 ; jump to boot.sys
fd_read:
fd_read_loop:
mov si, 0 ; reset fail counter
fd_read_retry:
mov ah, 0x02 ; read mode
mov al, 1 ; read 1 sector
mov dl, 0x00 ; drive A
mov bx, 0
int 0x13 ; read disk C-ch H-dh S-cl
; and save at ES:BX
jnc fd_read_next ; if no error then jump
inc si ; increment fail counter
cmp si, 5
jae fd_read_error ; if fail counter >= 5 then jump
mov ah, 0x00
mov dl, 0x00 ; drive A
int 0x13 ; reset drive
jc fd_read_retry_error
jmp fd_read_retry
fd_read_next:
dec di
cmp di, 0
je fd_end
mov ax, es
add ax, 0x20
mov es, ax
inc cl
cmp cl, 18
jbe fd_read_loop
mov cl, 1
inc dh
cmp dh,1
jbe fd_read_loop
mov dh, 0
inc ch
jmp fd_read_loop
fd_read_error:
fd_read_retry_error:
mov si, mesg_fail
call puts
jmp fin
fd_end:
ret
; 0x8000 + 0x4200 = 0xc200
fin:
hlt
jmp fin
puts:
mov al, [si]
inc si
cmp al, 0x00
je puts_end
mov ah, 0x0e
mov bh, 0
mov bl, 0
int 0x10
jmp puts
puts_end:
ret
sethex4: ; ax : integer to convert
; di : destination
add di, 3
mov cx, 4
sethex4_l3:
mov bx, ax
and bx, 0x000f
cmp bx, 10
jae sethex4_l1
add bx, '0'
jmp sethex4_l2
sethex4_l1:
add bx, 'A' - 10
sethex4_l2:
mov [di], bl
shr ax, 4
dec di
dec cx
cmp cx, 0
ja sethex4_l3
ret
mesg:
db "loading boot file ", 0x00
mesg2:
db "booting operating system", 0x0a, 0x00
mesg_fail:
db "[FAILED]", 0x0a, 0x00
mesg_ok:
db "[ OK ]", 0x0a, 0x00
times 0x1fe - ($ - $$) db 0
db 0x55, 0xaa
| 18.405263 | 53 | 0.637403 |
6601d89c860a3d04da7daccb97722858a7bc4946 | 304 | asm | Assembly | programs/oeis/176/A176222.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/176/A176222.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | programs/oeis/176/A176222.asm | karttu/loda | 9c3b0fc57b810302220c044a9d17db733c76a598 | [
"Apache-2.0"
] | null | null | null | ; A176222: a(n) = (n^2-3*n+1+(-1)^n)/2.
; 0,3,5,10,14,21,27,36,44,55,65,78,90,105,119,136,152,171,189,210,230,253,275,300,324,351,377,406,434,465,495,528,560,595,629,666,702,741,779,820,860,903,945,990,1034,1081,1127,1176,1224,1275,1325,1378,1430
mov $1,$0
mod $0,2
add $1,2
bin $1,2
add $1,$0
sub $1,1
| 30.4 | 206 | 0.654605 |
0246b1393b5b7cb314ff6bfc2b073cba8ac5d112 | 8,452 | asm | Assembly | src/main.asm | nrkn/lo-a-rad-dragon | da66827ee8244955a8adb9576e023c4708c7f83d | [
"MIT"
] | null | null | null | src/main.asm | nrkn/lo-a-rad-dragon | da66827ee8244955a8adb9576e023c4708c7f83d | [
"MIT"
] | null | null | null | src/main.asm | nrkn/lo-a-rad-dragon | da66827ee8244955a8adb9576e023c4708c7f83d | [
"MIT"
] | null | null | null | processor 6502
include "vcs.h"
include "macro.h"
; ------------------------------------------------------------------------------
; Setup variables
; ------------------------------------------------------------------------------
seg.u Variables
org $80
PlayerX byte
PlayerY byte
OldX byte
OldY byte
Random byte
; ------------------------------------------------------------------------------
; Setup consts
; ------------------------------------------------------------------------------
PLAYER_HEIGHT = 8
SWORD_HEIGHT = 8
SHIELD_HEIGHT = 8
BEER_HEIGHT = 8
HEAL_HEIGHT = 8
WEAPON_Y = 20
ARMOR_Y = 30
INN_Y = 40
HEALER_Y = 50
; ------------------------------------------------------------------------------
; Setup rom
; ------------------------------------------------------------------------------
seg code
org $f000 ; define the code origin at $f000 - start of the ROM
Start:
CLEAN_START
; ------------------------------------------------------------------------------
; Init Variables
; ------------------------------------------------------------------------------
lda #50
sta PlayerX
sta PlayerY
; ------------------------------------------------------------------------------
; Render
; ------------------------------------------------------------------------------
StartFrame:
; ------------------------------------------------------------------------------
; Init VSYNC and VBLANK
; ------------------------------------------------------------------------------
lda #2
sta VBLANK
sta VSYNC
repeat 3
sta WSYNC
repend
lda #0
sta VSYNC ; turn off VSYNC
; ------------------------------------------------------------------------------
; Calculations run before VBLANK
; ------------------------------------------------------------------------------
lda PlayerX
ldy #0
jsr SetObjectXPos ; set player0 x position
sta WSYNC
sta HMOVE ; apply the horizontal offets we just set
; ------------------------------------------------------------------------------
; 37 lines of VBLANK minus 2 used above
; ------------------------------------------------------------------------------
ldx #35
LoopVBlank:
sta WSYNC
dex
bne LoopVBlank
lda #0
sta VBLANK ; turn off VBLANK
; ------------------------------------------------------------------------------
; 192 visible scanlines
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; 2-line kernel
; ------------------------------------------------------------------------------
lda #$c6 ; background
sta COLUBK
ldx #96 ; scanline counter
.EachLine:
.IsPlayer:
txa
sec ; always set carry before sub
sbc PlayerY
cmp PLAYER_HEIGHT
bcc .DrawPlayer
lda #0 ; if not draw empty row from sprite
.DrawPlayer:
tay
lda PlayerSprite,Y
sta GRP0
lda PlayerColors,Y
sta COLUP0
sta WSYNC
.IsHealerHut:
txa
sec
sbc HEALER_Y
cmp HEAL_HEIGHT
bcc .DrawHealerHut
jmp .IsInnHut
.DrawHealerHut:
tay
lda HealSprite,Y
sta GRP1
lda HealColors,Y
sta COLUP1
jmp .DrawHutsDone
.IsInnHut:
txa
sec
sbc INN_Y
cmp BEER_HEIGHT
bcc .DrawInnHut
jmp .IsWeaponHut
.DrawInnHut:
tay
lda BeerSprite,Y
sta GRP1
lda BeerColors,Y
sta COLUP1
jmp .DrawHutsDone
.IsWeaponHut:
txa
sec
sbc WEAPON_Y
cmp SWORD_HEIGHT
bcc .DrawWeaponHut
jmp .IsArmorHut
.DrawWeaponHut:
tay
lda SwordSprite,Y
sta GRP1
lda SwordColors,Y
sta COLUP1
jmp .DrawHutsDone
.IsArmorHut:
txa
sec
sbc ARMOR_Y
cmp SHIELD_HEIGHT
bcc .DrawArmorHut
lda #0
.DrawArmorHut:
tay
lda ShieldSprite,Y
sta GRP1
lda ShieldColors,Y
sta COLUP1
.DrawHutsDone
sta WSYNC
dex
bne .EachLine
; ------------------------------------------------------------------------------
; Overscan
; ------------------------------------------------------------------------------
lda #2
sta VBLANK
ldx #30
LoopOverscan:
sta WSYNC
dex
bne LoopOverscan
lda #0
sta VBLANK
; ------------------------------------------------------------------------------
; Input handler
; ------------------------------------------------------------------------------
CheckP0Up:
lda #%00010000
bit SWCHA ; compare to joy
bne CheckP0Down
inc PlayerY
CheckP0Down:
lda #%00100000
bit SWCHA
bne CheckP0Left
dec PlayerY
CheckP0Left:
lda #%01000000
bit SWCHA
bne CheckP0Right
dec PlayerX
CheckP0Right:
lda #%10000000
bit SWCHA
bne EndInputCheck
inc PlayerX
EndInputCheck:
; ------------------------------------------------------------------------------
; Check collisions
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; Next frame
; ------------------------------------------------------------------------------
jmp StartFrame
; ------------------------------------------------------------------------------
; Subroutines
; ------------------------------------------------------------------------------
; Horizontal Positioning
; A is the desired x coordinate
; Y is the object type
; 0 = player0, 1 = player1, 2 = missile0, 3 = missile1, 4 = ball
; ------------------------------------------------------------------------------
SetObjectXPos subroutine
sta WSYNC ; start new scanline
sec ; ensure carry flag
.Div15Loop
sbc #15 ; sub 15 from desired X to get coarse location
bcs .Div15Loop ; loop until carry is clear
eor #7 ; put in range -8 to 7
repeat 4 ; shift left 4 times, only want top 4 bits
asl
repend
sta HMP0,Y ; store the fine offset
sta RESP0,Y ; store the coarse offset
rts
; ------------------------------------------------------------------------------
; Random using Linear-Feedback Shift Register
; - Generate random number using LFSR
; ------------------------------------------------------------------------------
SetRandom subroutine
lda Random
asl
eor Random
asl
eor Random
asl
asl
eor Random
asl
rol Random ; ok we have LFSR random
rts
; ------------------------------------------------------------------------------
; ROM Data
; ------------------------------------------------------------------------------
; Bitmaps and colors
; ------------------------------------------------------------------------------
PlayerSprite:
.byte #%00000000
.byte #%01001000
.byte #%11111100
.byte #%01111000
.byte #%10000000
.byte #%10101000
.byte #%10000000
.byte #%01111000
SwordSprite:
.byte #%00000000
.byte #%00010000
.byte #%00111000
.byte #%00010000
.byte #%00010000
.byte #%00010000
.byte #%00010000
.byte #%00010000
ShieldSprite:
.byte #%00000000
.byte #%00111000
.byte #%01111100
.byte #%01111100
.byte #%01111100
.byte #%01111100
.byte #%01010100
.byte #%00000000
BeerSprite:
.byte #%00000000
.byte #%11111000
.byte #%10101100
.byte #%10101010
.byte #%10101010
.byte #%10101010
.byte #%11111100
.byte #%11111000
HealSprite:
.byte #%00000000
.byte #%00110000
.byte #%00110000
.byte #%11111100
.byte #%11111100
.byte #%00110000
.byte #%00110000
.byte #%00000000
PlayerColors:
.byte $00
.byte $96
.byte $96
.byte $1c
.byte $1c
.byte $1c
.byte $1c
.byte $1c
SwordColors:
.byte $00
.byte $06
.byte $0a
.byte $0e
.byte $0e
.byte $0e
.byte $0e
.byte $0e
ShieldColors:
.byte $00
.byte $06
.byte $08
.byte $08
.byte $08
.byte $08
.byte $0a
.byte $00
BeerColors:
.byte $00
.byte $1e
.byte $1e
.byte $1e
.byte $1f
.byte $1f
.byte $1f
.byte $0e
HealColors:
.byte $00
.byte $36
.byte $36
.byte $36
.byte $38
.byte $38
.byte $38
.byte $00
; ------------------------------------------------------------------------------
; Fill ROM to exactly 4kb
; ------------------------------------------------------------------------------
org $fffc
.word Start ; tell atari where to start when we reset
.word Start ; interupt at $fffe - unused by vcs but makes 4kb
| 21.343434 | 80 | 0.401088 |
edaa2e1d04430e4925161541e8b7fb79d29f1984 | 1,923 | asm | Assembly | Modul 3/latih15.asm | hyuwah/fu-praktikum-smd | a06fe109a42aa96e75f9a425a0905d6bfbfdfc7e | [
"MIT"
] | null | null | null | Modul 3/latih15.asm | hyuwah/fu-praktikum-smd | a06fe109a42aa96e75f9a425a0905d6bfbfdfc7e | [
"MIT"
] | null | null | null | Modul 3/latih15.asm | hyuwah/fu-praktikum-smd | a06fe109a42aa96e75f9a425a0905d6bfbfdfc7e | [
"MIT"
] | null | null | null | ;--------------------------------------------------------------------
; Praktikum SMD 2015
; M.Wahyudin (140310120031)
;
; Name : LATIH15.ASM
; Desc : Menampilkan karakter A ke display matriks 7x5
; Input : -
; Output: Display matriks 7x5
;--------------------------------------------------------------------
cseg at 0
mulai:
mov P1,#1Eh ; mengaktifkan kolom ke-1
mov a,#0 ; pilih baris ke- 1
call ambilbaris ; mengambil data baris ke-1
mov p2,a ; menyalakan baris-1 ke port-2
call tunda ; tahan tampilan
mov p2,#0 ; padamkan baris ke 1
mov P1,#1Dh ; mengaktifkan kolom ke-2
mov a,#0 ; pilih baris ke- 2
call ambilbaris ; mengambil data baris ke-2
mov p2,a ; menyalakan baris-2 ke port-2
call tunda ; tahan tampilan
mov p2,#0 ; padamkan baris ke 2
mov P1,#1Bh ; mengaktifkan kolom ke-3
mov a,#0 ; pilih baris ke- 3
call ambilbaris ; mengambil data baris ke-3
mov p2,a ; menyalakan baris-3 ke port-2
call tunda ; tahan tampilan
mov p2,#0 ; padamkan baris ke 3
mov P1,#17h ; mengaktifkan kolom ke-4
mov a,#0 ; pilih baris ke-4
call ambilbaris ; mengambil data baris ke-4
mov p2,a ; menyalakan baris-4 ke port-2
call tunda ; tahan tampilan
mov p2,#0 ; padamkan baris ke 4
mov P1,#0Fh ; mengaktifkan kolom ke-5
mov a,#0 ; pilih baris ke- 5
call ambilbaris ; mengambil data baris ke-5
mov p2,a ; menyalakan baris-5 ke port-2
call tunda ; tahan tampilan
mov p2,#0 ; padamkan baris ke 5
tunda: mov r7,#0
djnz r7, $
ret
ambilbaris:
inc a
movc a, @a+pc
ret
db 7ch, 12h, 11h, 12h, 7ch
end
| 32.59322 | 69 | 0.5039 |
f47cfb1b9c920f7d5fdf95046d4b8794322cf644 | 219 | asm | Assembly | libsrc/_DEVELOPMENT/adt/w_array/c/sccz80/w_array_at_callee.asm | teknoplop/z88dk | bb03fbfd6b2ab0f397a1358559089f9cd3706485 | [
"ClArtistic"
] | 8 | 2017-01-18T12:02:17.000Z | 2021-06-12T09:40:28.000Z | libsrc/_DEVELOPMENT/adt/w_array/c/sccz80/w_array_at_callee.asm | teknoplop/z88dk | bb03fbfd6b2ab0f397a1358559089f9cd3706485 | [
"ClArtistic"
] | 1 | 2017-03-06T07:41:56.000Z | 2017-03-06T07:41:56.000Z | libsrc/_DEVELOPMENT/adt/w_array/c/sccz80/w_array_at_callee.asm | teknoplop/z88dk | bb03fbfd6b2ab0f397a1358559089f9cd3706485 | [
"ClArtistic"
] | 3 | 2017-03-07T03:19:40.000Z | 2021-09-15T17:59:19.000Z |
; void *w_array_at(w_array_t *a, size_t idx)
SECTION code_clib
SECTION code_adt_w_array
PUBLIC w_array_at_callee
EXTERN asm_w_array_at
w_array_at_callee:
pop hl
pop bc
ex (sp),hl
jp asm_w_array_at
| 12.166667 | 44 | 0.748858 |
e0a959b483aa9ff004eec802e808e7b2c99a42a2 | 3,938 | asm | Assembly | serial_rom/src/main.asm | zer0x64/nsec2022-gband | 7f831b1af83c7f766f139dfce14776b654ee8d9a | [
"Apache-2.0",
"MIT"
] | null | null | null | serial_rom/src/main.asm | zer0x64/nsec2022-gband | 7f831b1af83c7f766f139dfce14776b654ee8d9a | [
"Apache-2.0",
"MIT"
] | null | null | null | serial_rom/src/main.asm | zer0x64/nsec2022-gband | 7f831b1af83c7f766f139dfce14776b654ee8d9a | [
"Apache-2.0",
"MIT"
] | null | null | null | ; ------------------------------
; This simple test rom will send a counter through
; the serial port
;
; One machine will be initiated as P1 and
; the other as P2 using Start and Select
;
; P1 will have an even counter, and P2
; an odd counter
;
; The 2 players send each other their counter
; increment, and send back the counter they received
; ------------------------------
include "hardware.inc"
; ------------------------------
; RAM variables
; ------------------------------
def PAD equ _RAM ; Current state of the joypad
def LOCAL_COUNTER equ _RAM+1 ; Local player counter
def RECEIVED_COUNTER equ _RAM+2 ; Received counter for debugging
def COMPARE_RESULT equ _RAM+3 ; Comparison result, if zero then it's equal
; ------------------------------
; Main executable code
; ------------------------------
section "Main", rom0[$0100]
nop
jp main
ds $150 - @, 0 ; Make room for the header
main:
di
ld sp, $ffff
ld hl, rSB
.wait_input:
call read_joypad
ld a, [PAD]
and PADF_START
jr nz, .p1
ld a, [PAD]
and PADF_SELECT
jr nz, .p2
call delay
jr .wait_input
.p1:
; Init the counter
ld a, 0
ld [LOCAL_COUNTER], a
:
; Send P1 counter
ld a, [LOCAL_COUNTER]
call sio_master_transfer
call sio_wait_transfer
; Read P2 counter, increment and send back
ld a, [hl]
add 2
call sio_slave_transfer
call sio_wait_transfer
; Get returned counter
ld a, [hl]
ld [RECEIVED_COUNTER], a
ld b, a
; Increment P1 Counter
ld a, [LOCAL_COUNTER]
add 2
ld [LOCAL_COUNTER], a
; Compare for fun (not much that can be done without display)
sub b
ld [COMPARE_RESULT], a
; Loop
ld bc, 2
ld de, 40000
call big_delay
jr :-
.p2:
; Init the counter
ld a, 1
ld [LOCAL_COUNTER], a
:
; Receive P1 counter, add and send back
ld a, [LOCAL_COUNTER]
call sio_slave_transfer
call sio_wait_transfer
ld a, [hl]
add 2
call sio_master_transfer
call sio_wait_transfer
; Increment P2 Counter
ld a, [LOCAL_COUNTER]
add 2
ld [LOCAL_COUNTER], a
; Retrieve counter returned by P1
ld a, [hl]
ld [RECEIVED_COUNTER], a
ld b, a
; Compare for fun (not much that can be done without display)
sub b
ld [COMPARE_RESULT], a
; Loop
ld bc, 2
ld de, 40000
call big_delay
jr :-
; ------------------------------
; Get pressed buttons on the joypad
;
; Stores the result in `PAD`
; ------------------------------
read_joypad:
push bc
ld a, P1F_GET_DPAD
ld [rP1], a
; Read the state of the dpad, with bouncing protection
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
and $0F
swap a
ld b, a
ld a, P1F_GET_BTN
ld [rP1], a
; Read the state of the buttons, with bouncing protection
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
and $0F
or b
cpl
ld [PAD], a
pop bc
ret
; ------------------------------
; Wait for 60000+15 cycles (~1.4ms)
; ------------------------------
delay:
push de
ld de, 6000
:
dec de
ld a, d
or e
jr z, :+
nop
jr :-
:
pop de
ret
; ------------------------------
; Wait for about (de*10) * bc cycles
;
; Inputs:
; - de: Nb cycles per iteration
; - bc: Nb iterations
; ------------------------------
big_delay:
.iter:
dec bc
ld a, b
or c
jr z, .end
.loop:
dec de
ld a, d
or e
jr z, .iter
nop
jr .loop
.end
ret
;;;
; .loop:
; ld a, [SIOTYPE]
; or a
; jr nz, .start
; call read_joypad
; ld a, [PAD]
; and PADF_START
; jp z, .skip
; call init_sio_master
; .run:
; call read_joypad
; ld a, [PAD]
; ld [TD], a
; ld a, [SIOTYPE]
; cp MASTER_MODE
; call z, init_sio_master
; .skip:
; ld a, [RD]
; ;???
; .done:
; call delay
; jr .loop
;; .slave:
;; jr .done
;; .master:
;; ld a, [PAD]
;; ld [rSB], a
;; ld a, SCF_START | SCF_SOURCE
;; ld [rSC], a
;; jr .done
;;;
; ld a, [PAD]
; ld [rSB], a
; Temp write a newline for log
; ld a, 10
; ld [rSB], a
; ld a, SCF_START | SCF_SOURCE
; ld [rSC], a
;; ld a, [PAD]
;; and PADF_SELECT
;; jr nz, .slave
;; ld a, [PAD]
;; and PADF_START
;; jr z, .master
| 14.639405 | 74 | 0.583037 |
faaeffe39f977b0356c6a81618af36759b2d00f0 | 60 | asm | Assembly | gfx/pokemon/wigglytuff/anim_idle.asm | Dev727/ancientplatinum | 8b212a1728cc32a95743e1538b9eaa0827d013a7 | [
"blessing"
] | 28 | 2019-11-08T07:19:00.000Z | 2021-12-20T10:17:54.000Z | gfx/pokemon/wigglytuff/anim_idle.asm | Dev727/ancientplatinum | 8b212a1728cc32a95743e1538b9eaa0827d013a7 | [
"blessing"
] | 13 | 2020-01-11T17:00:40.000Z | 2021-09-14T01:27:38.000Z | gfx/pokemon/wigglytuff/anim_idle.asm | Dev727/ancientplatinum | 8b212a1728cc32a95743e1538b9eaa0827d013a7 | [
"blessing"
] | 22 | 2020-05-28T17:31:38.000Z | 2022-03-07T20:49:35.000Z | setrepeat 3
frame 0, 06
frame 3, 06
dorepeat 1
endanim
| 10 | 12 | 0.7 |
b4da887dfdcf0e78d06fe075c148281038b8d053 | 666 | asm | Assembly | 4/4-6.asm | userElaina/MicrocomputerLab | 75ea8b0e6ad098df66db859a84c1cc8b27ef9c92 | [
"MIT"
] | null | null | null | 4/4-6.asm | userElaina/MicrocomputerLab | 75ea8b0e6ad098df66db859a84c1cc8b27ef9c92 | [
"MIT"
] | null | null | null | 4/4-6.asm | userElaina/MicrocomputerLab | 75ea8b0e6ad098df66db859a84c1cc8b27ef9c92 | [
"MIT"
] | null | null | null | DATA SEGMENT
COURSE1 DB 70H,88H,92H,90H,99H
DB 67H,77H,88H,76H,69H
DB 74H,87H,77H,74H,70H
DB 99H,97H,94H,98H,96H
NUM1 DW 5 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI,COURSE1
LEA DI, NUM1
SUB SI,5
MOV CL,5
AA1: MOV BX,SI
SUB AX,AX
MOV CH,4
AA2: ADD BX,5
ADD AL,[BX]
DAA
ADC AH,0
DEC CH
JNZ AA2
MOV [DI],AX
INC SI
ADD DI,2
DEC CL
JNZ AA1
MOV AH,4CH
INT 21H
CODE ENDS
END START | 20.181818 | 31 | 0.459459 |
a4386d903072c88946950d2de8f33b836c5f27bd | 712 | asm | Assembly | oeis/007/A007060.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/007/A007060.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/007/A007060.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A007060: Number of ways n couples can sit in a row without any spouses next to each other.
; Submitted by Christian Krause
; 1,0,8,240,13824,1263360,168422400,30865121280,7445355724800,2287168006717440,871804170613555200,403779880746418176000,223346806774106790297600,145427383048755178635264000,110105698060190464791596236800,95914116314126658718742347776000,95252504853751428295192341381120000,106977665004458872351891798703996928000,134908446971559170911616981792886620160000,189827621887738294039110864381425655742464000,296336150984268508640798606247349210620887040000
mov $3,1
lpb $0
mul $3,$0
sub $0,1
add $3,$2
mul $3,$0
mul $3,2
mov $2,$3
add $3,$1
mov $1,$2
mul $3,2
lpe
mov $0,$3
| 39.555556 | 450 | 0.824438 |
891c7968543d902c1bfbbd2d7ef4cc49ce7494ef | 3,550 | asm | Assembly | programs/oeis/008/A008513.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | 1 | 2021-03-15T11:38:20.000Z | 2021-03-15T11:38:20.000Z | programs/oeis/008/A008513.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | programs/oeis/008/A008513.asm | jmorken/loda | 99c09d2641e858b074f6344a352d13bc55601571 | [
"Apache-2.0"
] | null | null | null | ; A008513: Number of points on surface of 6-dimensional cube.
; 0,64,728,4032,14896,42560,102024,215488,413792,737856,1240120,1985984,3055248,4543552,6563816,9247680,12746944,17235008,22908312,29987776,38720240,49379904,62269768,77723072,96104736,117812800,143279864,172974528,207402832,247109696,292680360,344741824,403964288,471062592,546797656,631977920,727460784,834154048,953017352,1085063616,1231360480,1393031744,1571258808,1767282112,1982402576,2217983040,2475449704,2756293568,3062071872,3394409536,3755000600,4145609664,4568073328,5024301632,5516279496,6046068160,6615806624,7227713088,7884086392,8587307456,9339840720,10144235584,11003127848,11919241152,12895388416,13934473280,15039491544,16213532608,17459780912,18781517376,20182120840,21665069504,23233942368,24892420672,26644289336,28493438400,30443864464,32499672128,34665075432,36944399296,39342080960,41862671424,44510836888,47291360192,50209142256,53269203520,56476685384,59836851648,63355089952,67036913216,70887961080,74914001344,79120931408,83514779712,88101707176,92888008640,97880114304,103084591168,108508144472,114157619136,120040001200,126162419264,132532145928,139156599232,146043344096,153200093760,160634711224,168355210688,176369758992,184686677056,193314441320,202261685184,211537200448,221149938752,231109013016,241423698880,252103436144,263157830208,274596653512,286429846976,298667521440,311319959104,324397614968,337911118272,351871273936,366289064000,381175649064,396542369728,412400748032,428762488896,445639481560,463043801024,480987709488,499483657792,518544286856,538182429120,558411109984,579243549248,600693162552,622773562816,645498561680,668882170944,692938604008,717682277312,743127811776,769290034240,796183978904,823824888768,852228217072,881409628736,911385001800,942170428864,973782218528,1006236896832,1039551208696,1073742119360,1108826815824,1144822708288,1181747431592,1219618846656,1258455041920,1298274334784,1339095273048,1380936636352,1423817437616,1467756924480,1512774580744,1558890127808,1606123526112,1654494976576,1704024922040,1754734048704,1806643287568,1859773815872,1914147058536,1969784689600,2026708633664,2084941067328,2144504420632,2205421378496,2267714882160,2331408130624,2396524582088,2463087955392,2531122231456,2600651654720,2671700734584,2744294246848,2818457235152,2894215012416,2971593162280,3050617540544,3131314276608,3213709774912,3297830716376,3383704059840,3471357043504,3560817186368,3652112289672,3745270438336,3840320002400,3937289638464,4036208291128,4137105194432,4240009873296,4344952144960,4451962120424,4561070205888,4672307104192,4785703816256,4901291642520,5019102184384,5139167345648,5261519333952,5386190662216,5513214150080,5642622925344,5774450425408,5908730398712,6045496906176,6184784322640,6326627338304,6471060960168,6618120513472,6767841643136,6920260315200,7075412818264,7233335764928,7394066093232,7557641068096,7724098282760,7893475660224,8065811454688,8241144252992,8419512976056,8600956880320,8785515559184,8973228944448,9164137307752,9358281262016,9555701762880,9756440110144,9960537949208,10168037272512,10378980420976,10593410085440,10811369308104,11032901483968,11258050362272,11486860047936
mov $2,12
mov $5,$0
mov $6,$0
lpb $2
add $1,$5
sub $2,1
lpe
mov $3,$6
lpb $3
sub $3,1
add $4,$5
lpe
mov $3,$6
mov $5,$4
mov $4,0
lpb $3
sub $3,1
add $4,$5
lpe
mov $2,40
mov $5,$4
lpb $2
add $1,$5
sub $2,1
lpe
mov $3,$6
mov $4,0
lpb $3
sub $3,1
add $4,$5
lpe
mov $3,$6
mov $5,$4
mov $4,0
lpb $3
sub $3,1
add $4,$5
lpe
mov $2,12
mov $5,$4
lpb $2
add $1,$5
sub $2,1
lpe
| 73.958333 | 3,091 | 0.870423 |
cf26cb6fb8759f3a0e1ac33b4b41e40c4d39f637 | 1,938 | asm | Assembly | basic/src/constants.asm | paulscottrobson/eris | cf102530334ed86360deb20f0e41af1e10f5d584 | [
"MIT"
] | 13 | 2020-03-31T08:21:22.000Z | 2021-07-28T20:03:29.000Z | basic/src/constants.asm | paulscottrobson/eris | cf102530334ed86360deb20f0e41af1e10f5d584 | [
"MIT"
] | 37 | 2020-03-31T06:35:37.000Z | 2020-09-17T08:56:48.000Z | basic/src/constants.asm | paulscottrobson/eris | cf102530334ed86360deb20f0e41af1e10f5d584 | [
"MIT"
] | 5 | 2020-05-10T10:23:06.000Z | 2022-01-14T02:21:02.000Z | ; *****************************************************************************
; *****************************************************************************
;
; Name: constants.asm
; Purpose: Basic Constants
; Created: 3rd March 2020
; Reviewed: 16th March 2020
; Author: Paul Robson (paul@robsons.org.uk)
;
; *****************************************************************************
; *****************************************************************************
;
; Memory allocate for CPU stack
;
cpuStackSize = 256
;
; Size of return stack for CALL, REPEAT etc.
;
returnStackSize = 256
;
; Size of local variable stack
;
localStackSize = 512
;
; Max size of string
;
maxStringSize = 255
;
; Extra space allocated concreting strings, so that they can be expanded in words
;
extraStringAlloc = 8
;
; Variable hash table size. hashTableSize = 2^hashTablePower
;
hashTableSize = 16
hashTablePower = 4
;
; Evaluation stack depth and size
;
stackSize = 32
stackElementSize = 3
;
; Offsets to evaluation stack elements on 1st and 2nd levels
;
esValue1 = 0
esType1 = 1
esReference1 = 2
esValue2 = 0+stackElementSize
esType2 = 1+stackElementSize
esReference2 = 2+stackElementSize
;
; Words required to store the stack position (line address, code address)
;
stackPosSize = 2
;
; Indent spaces per level when listing structures.
;
indentStep = 2
;
; Event timers
;
evtCount = 8 ; supported # event timers
evtRecSize = 4 ; words per record
;
evtCode = 0 ; BASIC code address (0 if timer not in use)
evtTime = 1 ; time when event fires
evtRate = 2 ; number of centiseconds between events.
evtRepeatCount = 3 ; repeat count, 0 = run indefinitely
;
; Colour schemes for listing
;
theme_line = 2 ; green lines
theme_keyword = 6 ; cyan keywords
theme_ident = 3 ; yellow identifiers
theme_const = 3 ; yellow integers
theme_string = 7 ; white strings
theme_punc = 2 ; green punctuation
| 23.634146 | 82 | 0.598555 |
e713219270662910c209168a7e4a5644f908855c | 214 | asm | Assembly | libsrc/_DEVELOPMENT/input/zx/c/sdcc_iy/in_mouse_amx_wheel_delta.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 640 | 2017-01-14T23:33:45.000Z | 2022-03-30T11:28:42.000Z | libsrc/_DEVELOPMENT/input/zx/c/sdcc_iy/in_mouse_amx_wheel_delta.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 1,600 | 2017-01-15T16:12:02.000Z | 2022-03-31T12:11:12.000Z | libsrc/_DEVELOPMENT/input/zx/c/sdcc_iy/in_mouse_amx_wheel_delta.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 215 | 2017-01-17T10:43:03.000Z | 2022-03-23T17:25:02.000Z |
; int16_t in_mouse_amx_wheel_delta(void)
SECTION code_clib
SECTION code_input
PUBLIC _in_mouse_amx_wheel_delta
EXTERN asm_in_mouse_amx_wheel_delta
defc _in_mouse_amx_wheel_delta = asm_in_mouse_amx_wheel_delta
| 17.833333 | 61 | 0.88785 |
046a42877f253a721d34f6fa1bab9f194966a581 | 1,355 | asm | Assembly | programs/oeis/157/A157762.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 22 | 2018-02-06T19:19:31.000Z | 2022-01-17T21:53:31.000Z | programs/oeis/157/A157762.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 41 | 2021-02-22T19:00:34.000Z | 2021-08-28T10:47:47.000Z | programs/oeis/157/A157762.asm | neoneye/loda | afe9559fb53ee12e3040da54bd6aa47283e0d9ec | [
"Apache-2.0"
] | 5 | 2021-02-24T21:14:16.000Z | 2021-08-09T19:48:05.000Z | ; A157762: a(n) = 15780962*n^2 - 5618000*n + 500001.
; 10662963,52387849,125674659,230523393,366934051,534906633,734441139,965537569,1228195923,1522416201,1848198403,2205542529,2594448579,3014916553,3466946451,3950538273,4465692019,5012407689,5590685283,6200524801,6841926243,7514889609,8219414899,8955502113,9723151251,10522362313,11353135299,12215470209,13109367043,14034825801,14991846483,15980429089,17000573619,18052280073,19135548451,20250378753,21396770979,22574725129,23784241203,25025319201,26297959123,27602160969,28937924739,30305250433,31704138051,33134587593,34596599059,36090172449,37615307763,39172005001,40760264163,42380085249,44031468259,45714413193,47428920051,49174988833,50952619539,52761812169,54602566723,56474883201,58378761603,60314201929,62281204179,64279768353,66309894451,68371582473,70464832419,72589644289,74746018083,76933953801,79153451443,81404511009,83687132499,86001315913,88347061251,90724368513,93133237699,95573668809,98045661843,100549216801,103084333683,105651012489,108249253219,110879055873,113540420451,116233346953,118957835379,121713885729,124501498003,127320672201,130171408323,133053706369,135967566339,138912988233,141889972051,144898517793,147938625459,151010295049,154113526563,157248320001
seq $0,157761 ; a(n) = 297754*n - 53000.
pow $0,2
sub $0,59904520514
div $0,31561924
mul $0,5618
add $0,10662963
| 135.5 | 1,187 | 0.881919 |
ca1fa46091737249c0ebbb085974a541f393ec9b | 806 | asm | Assembly | oeis/142/A142117.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 11 | 2021-08-22T19:44:55.000Z | 2022-03-20T16:47:57.000Z | oeis/142/A142117.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 9 | 2021-08-29T13:15:54.000Z | 2022-03-09T19:52:31.000Z | oeis/142/A142117.asm | neoneye/loda-programs | 84790877f8e6c2e821b183d2e334d612045d29c0 | [
"Apache-2.0"
] | 3 | 2021-08-22T20:56:47.000Z | 2021-09-29T06:26:12.000Z | ; A142117: Primes congruent to 8 mod 37.
; Submitted by Jon Maiga
; 193,563,859,1229,1303,1451,1747,2339,2857,3079,3301,3449,3671,3967,4337,5003,5077,5521,5669,5743,6113,6779,7001,7297,7741,7963,8111,8629,8999,9221,9739,9887,10331,10627,11071,11959,12107,12329,13217,13291,13513,13883,14327,14401,14549,14771,15289,15511,15733,15881,16103,16547,16843,17509,17657,18397,19211,19433,19507,20173,20543,21061,21283,21727,22171,22541,23059,23873,24169,24317,24391,25057,26759,26833,26981,27277,27647,27943,28387,28979,29201,29423,29867,30089,30829,30977,31051,31643,32309
mov $2,$0
add $2,6
pow $2,2
mov $4,7
lpb $2
mov $3,$4
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $1,$0
max $1,0
cmp $1,$0
mul $2,$1
sub $2,1
add $4,37
lpe
mov $0,$4
add $0,1
| 36.636364 | 500 | 0.734491 |
68b71dab81f835047bf9bd920a7d2186dc1833bc | 3,022 | asm | Assembly | libsrc/graphics/z88/window.asm | grancier/z180 | e83f35e36c9b4d1457e40585019430e901c86ed9 | [
"ClArtistic"
] | null | null | null | libsrc/graphics/z88/window.asm | grancier/z180 | e83f35e36c9b4d1457e40585019430e901c86ed9 | [
"ClArtistic"
] | null | null | null | libsrc/graphics/z88/window.asm | grancier/z180 | e83f35e36c9b4d1457e40585019430e901c86ed9 | [
"ClArtistic"
] | 1 | 2019-12-03T23:57:48.000Z | 2019-12-03T23:57:48.000Z | ;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Stubs Written by D Morris - 30/9/98
;
;
; $Id: window.asm,v 1.3 2016/05/17 21:43:06 dom Exp $
;
; This function will open a window of any type (graphics/text)
; on the Z88 screen, graphics flag states gfx or text
;
;Usage: window(struct *windst)
;
;These are offset by 32 as per usual on a z88.
;
;struct window {
; char windnumber;
; char x;
; char y;
; char width;
; char depth;
; char type;
; char graphics; 0=text, 1=graphics
;} ;
INCLUDE "graphics/grafix.inc" ; Contains fn defs
INCLUDE "stdio.def"
INCLUDE "map.def"
INCLUDE "screen.def"
SECTION code_clib
PUBLIC window
PUBLIC _window
EXTERN base_graphics
PUBLIC gfx_bank
EXTERN z88_map_segment
.window
._window
pop bc
pop hl
push hl
push bc
push ix ;save ix
push hl
pop ix
;ix is address of struct..
ld a,(ix+graph)
and a
jr nz,opengfx
ld hl,initwind
call_oz(gn_sop)
push ix
pop hl
call_oz(gn_sop)
ld hl,0 ;All good, return NULL
pop ix
ret
.opengfx
ld l,(ix+wind_w)
ld h,0
ld a,l
and a
ld a,(ix+windnum) ;window number
ld bc,mp_def ;define map based on pipedream
jr z,opengfx1
ld bc,mp_gra ;user width
.opengfx1
call_oz(os_map) ;opened the window
ld hl,1
jr c,opengfx_exit ;error, return TRUE
;Now get the address of the map
ld b,0
ld hl,0 ; dummy address
ld a,sc_hr0
call_oz(os_sci) ; get base address of map area (hires0)
push bc
push hl
call_oz(os_sci) ; (and re-write original address)
pop hl
pop bc
;Page in the map page so it's always there..errkk!
ld a,b
ld (gfx_bank),a
ld a,h
and 63 ;mask to bank
or z88_map_segment ;mask to segment map_seg
ld h,a
ld (base_graphics),hl
ld hl,0 ;NULL=good
.opengfx_exit
pop ix
ret
SECTION rodata_clib
.initwind defb 1,'7','#',0
SECTION bss_clib
.gfx_bank defb 0 ;Bank that this is in
| 26.508772 | 79 | 0.433157 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.