text stringlengths 1 1.05M |
|---|
; A113828: a(n) = Sum[2^(A047260(i)-1), {i,1,n}].
; 1,9,25,57,121,633,1657,3705,7801,40569,106105,237177,499321,2596473,6790777,15179385,31956601,166174329,434609785,971480697,2045222521,10635157113,27815026297,62174764665,130894241401,680650055289
mov $4,$0
add $4,1
mov $5,$0
lpb $4
mov $0,$5
sub $4,1
sub $0,$4
mov $6,$0
lpb $0
trn $0,4
mov $2,1
add $6,$3
add $6,1
lpe
add $2,1
pow $2,$6
add $1,$2
mov $3,1
lpe
|
; CALLER linkage for function pointers
XLIB strstrip
LIB strstrip_callee
XREF ASMDISP_STRSTRIP_CALLEE
.strstrip
pop bc
pop de
pop hl
push hl
push de
push bc
jp strstrip_callee + ASMDISP_STRSTRIP_CALLEE
|
DATA SEGMENT
GRADE DB 85,73,92,81,96
DB 100,86,95,77,80
DB 56,71,69,80,68
DB 83,78,69,90,84
AVEBUF DB 5 DUP(?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV BX,OFFSET GRADE
MOV DI,OFFSET AVEBUF
MOV SI,BX
MOV CX,5
A1: MOV BX,SI
SUB BX,5
PUSH CX
MOV AL,0
MOV CX,4
A2: ADD BX,5
ADD AL,[BX]
LOOP A2
MOV AH,0
MOV DL,4
DIV DL
MOV [DI],AL
INC SI
INC DI
POP CX
LOOP A1
MOV AH,4CH
INT 21H
CODE ENDS
END START |
* ---------------------------------------------------------------------------
* PSGlib
* ------------
* Converted to 6809 from:
* PSGlib - Programmable Sound Generator audio library - by sverx
* https://github.com/sverx/PSGlib
*
* Typical workflow:
* 1) You (or a friend of yours) track one or more module(s) and SFX(s) using either Mod2PSG2 or DefleMask (or whatever you prefer as long as it supports exporting in VGM format).
* 2) Optional, but warmly suggested: optimize your VGM(s) using Maxim's VGMTool
* 3) Convert the VGM to PSG file(s) using the vgm2psg tool.
* 4) Optional, suggested: compress the PSG file(s) using the psgcomp tool. The psgdecomp tool can be used to verify that the compression was right.
* 5) include the library and 'incbin' the PSG file(s) to your Z80 ASM source.
* 6) call PSGInit once somewhere near the beginning of your code.
* 7) Set up a steady interrupt (vertical blanking for instance) so to call PSGFrame and PSGSFXFrame at a constant pace (very important!). The two calls are separated so you can eventually switch banks when done processing background music and need to process SFX.
* 8) Start/stop tunes when needed using PSGPlay and PSGStop calls, start/stop SFXs when needed using PSGSFXPlay and PSGSFXStop calls.
* - Looping SFXs are supported too: fire them using a PSGSFXPlayLoop call, cancel their loop using a PSGSFXCancelLoop call.
* - Tunes can be set to run just once instead of endlessly using PSGPlayNoRepeat call, or set a playing tune to have no more loops using PSGCancelLoop call at any time.
* - To check if a tune is still playing use PSGGetStatus call, to check if a SFX is still playing use PSGSFXGetStatus call.
*
* PSGlib functions reference
* ==========================
*
* engine initializer function
* ---------------------------
*
* **PSGInit**: initializes the PSG engine
* - no required parameters
* - no return values
* - destroys A
*
* functions for music
* -------------------
*
* **PSGFrame**: processes a music frame
* - no required parameters
* - no return values
* - destroys A,B,X
*
* **PSGPlay** / **PSGPlayNoRepeat**: starts a tune (playing it repeatedly or only once)
* - *needs* the address of the PSG to start playing in X
* - no return values
* - destroys A
*
* **PSGStop**: stops (pauses) the music (leaving the SFX on, if one is playing)
* - no required parameters
* - no return values
* - destroys A
*
* **PSGResume**: resume the previously stopped music
* - no required parameters
* - no return values
* - destroys A
*
* **PSGCancelLoop**: sets the currently looping music to no more loops after the current
* - no required parameters
* - no return values
* - destroys A
*
* **PSGGetStatus**: gets the current status of music into register A
* - no required parameters
* - *returns* `PSG_PLAYING` in register A the engine is playing music, `PSG_STOPPED` otherwise.
*
* functions for SFX
* -----------------
*
* **PSGSFXFrame**: processes a SFX frame
* - no required parameters
* - no return values
* - destroys A,B,Y
*
* **PSGSFXPlay** / **PSGSFXPlayLoop**: starts a SFX (playing it once or repeatedly)
* - *needs* the address of the SFX to start playing in X
* - *needs* a mask indicating which channels to be used by the SFX in B. The only possible values are `SFX_CHANNEL2`,`SFX_CHANNEL3` and `SFX_CHANNELS2AND3`.
* - destroys A
*
* **PSGSFXStop**: stops the SFX (leaving the music on, if music is playing)
* - no required parameters
* - no return values
* - destroys A
*
* **PSGSFXCancelLoop**: sets the currently looping SFX to no more loops after the current
* - no required parameters
* - no return values
* - destroys A
*
* **PSGSFXGetStatus**: gets the current status of SFX into register A
* - no required parameters
* - *returns* `PSG_PLAYING` in register A if the engine is playing a SFX, `PSG_STOPPED` otherwise.
*
* functions for music volume and hardware channels handling
* ---------------------------------------------------------
*
* **PSGSetMusicVolumeAttenuation**: sets the volume attenuation for the music
* - *needs* the volume attenuation value in A (valid value are 0-15 where 0 means no attenuation and 15 is complete silence)
* - no return values
* - destroys A
*
* **PSGSilenceChannels**: sets all hardware channels to volume ZERO (useful if you need to pause all audio)
* - no required parameters
* - no return values
* - destroys A
*
* **PSGRestoreVolumes**: resets silenced hardware channels to previous volume
* - no required parameters
* - no return values
* - destroys A
*
* ---------------------------------------------------------------------------
PSG_STOPPED equ 0
PSG_PLAYING equ 1
PSGDataPort equ $E7FF
PSGLatch equ $80
PSGData equ $40
PSGChannel0 equ $00
PSGChannel1 equ $20
PSGChannel2 equ $40
PSGChannel3 equ $60
PSGVolumeData equ $10
PSGWait equ $38
PSGSubString equ $08
PSGLoop equ $01
PSGEnd equ $00
SFX_CHANNEL2 equ $01
SFX_CHANNEL3 equ $02
SFX_CHANNELS2AND3 equ SFX_CHANNEL2|SFX_CHANNEL3
* ************************************************************************************
* initializes the PSG 'engine'
* destroys A
PSGInit
lda #PSG_STOPPED ; ld a,PSG_STOPPED
sta PSGMusicStatus ; set music status to PSG_STOPPED
sta PSGSFXStatus ; set SFX status to PSG_STOPPED
sta PSGChannel2SFX ; set channel 2 SFX to PSG_STOPPED
sta PSGChannel3SFX ; set channel 3 SFX to PSG_STOPPED
sta PSGMusicVolumeAttenuation ; volume attenuation = none
rts
* ************************************************************************************
* receives in X the address of the PSG to start playing
* destroys A
PSGPlayNoRepeat
lda #0 ; We don't want the song to loop
bra PSGPlay1
PSGPlay
lda #1 ; the song can loop when finished
PSGPlay1
sta PSGLoopFlag
bsr PSGStop ; if there's a tune already playing, we should stop it!
lda ,x
sta PSGMusicPage
ldx 1,x
stx PSGMusicStart ; store the begin point of music
stx PSGMusicPointer ; set music pointer to begin of music
stx PSGMusicLoopPoint ; looppointer points to begin too
lda #0
sta PSGMusicSkipFrames ; reset the skip frames
sta PSGMusicSubstringLen ; reset the substring len (for compression)
lda #PSGLatch|PSGChannel0|PSGVolumeData|$0F ; latch channel 0, volume=0xF (silent)
sta PSGMusicLastLatch ; reset last latch to chn 0 volume 0
lda #PSG_PLAYING
sta PSGMusicStatus ; set status to PSG_PLAYING
rts
* ************************************************************************************
* stops the music (leaving the SFX on, if it's playing)
* destroys A
PSGStop
lda PSGMusicStatus ; if it's already stopped, leave
beq PSGStop_end
lda #PSGLatch|PSGChannel0|PSGVolumeData|$0F ; latch channel 0, volume=0xF (silent)
sta PSGDataPort
lda #PSGLatch|PSGChannel1|PSGVolumeData|$0F ; latch channel 1, volume=0xF (silent)
sta PSGDataPort
lda PSGChannel2SFX
bne PSGStop2
lda #PSGLatch|PSGChannel2|PSGVolumeData|$0F ; latch channel 2, volume=0xF (silent)
sta PSGDataPort
PSGStop2
lda PSGChannel3SFX
bne PSGStop3
lda #PSGLatch|PSGChannel3|PSGVolumeData|$0F ; latch channel 3, volume=0xF (silent)
sta PSGDataPort
PSGStop3
lda #PSG_STOPPED ; ld a,PSG_STOPPED
sta PSGMusicStatus ; set status to PSG_STOPPED
PSGStop_end
rts
* ************************************************************************************
* resume a previously stopped music
* destroys A
PSGResume
lda PSGMusicStatus ; if it's already playing, leave
bne PSGResume_end
lda PSGChan0Volume ; restore channel 0 volume
ora #PSGLatch|PSGChannel0|PSGVolumeData
sta PSGDataPort
lda PSGChan1Volume ; restore channel 1 volume
ora #PSGLatch|PSGChannel1|PSGVolumeData
sta PSGDataPort
lda PSGChannel2SFX
bne PSGResume1
lda PSGChan2LowTone ; restore channel 2 frequency
ora #PSGLatch|PSGChannel2
sta PSGDataPort
lda PSGChan2HighTone
sta PSGDataPort
lda PSGChan2Volume ; restore channel 2 volume
ora #PSGLatch|PSGChannel2|PSGVolumeData
sta PSGDataPort
PSGResume1
lda PSGChannel3SFX
bne PSGResume2
lda PSGChan3LowTone ; restore channel 3 frequency
ora #PSGLatch|PSGChannel3
sta PSGDataPort
lda PSGChan3Volume ; restore channel 3 volume
ora #PSGLatch|PSGChannel2|PSGVolumeData
sta PSGDataPort
PSGResume2
lda #PSG_PLAYING
sta PSGMusicStatus ; set status to PSG_PLAYING
PSGResume_end
rts
* ************************************************************************************
* sets the currently looping music to no more loops after the current
* destroys A
PSGCancelLoop
clr PSGLoopFlag
rts
* ************************************************************************************
* gets the current status of music into register A
PSGGetStatus
lda PSGMusicStatus
rts
* ************************************************************************************
* receives in A the volume attenuation for the music (0-15)
* destroys A
PSGSetMusicVolumeAttenuation
sta PSGMusicVolumeAttenuation
lda PSGMusicStatus ; if tune is not playing, leave
beq PSGSetMusicVolumeAttenuation_end
lda PSGChan0Volume
anda #$0F
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGSetMusicVolumeAttenuation1 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
PSGSetMusicVolumeAttenuation1
ora #PSGLatch|PSGChannel0|PSGVolumeData
sta PSGDataPort ; output the byte
lda PSGChan1Volume
anda #$0F
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGSetMusicVolumeAttenuation2 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
PSGSetMusicVolumeAttenuation2
ora #PSGLatch|PSGChannel1|PSGVolumeData
sta PSGDataPort ; output the byte
lda PSGChannel2SFX ; channel 2 busy with SFX?
bne _restore_channel3 ; if so, skip channel 2
lda PSGChan2Volume
anda #$0F
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGSetMusicVolumeAttenuation3 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
PSGSetMusicVolumeAttenuation3
ora #PSGLatch|PSGChannel2|PSGVolumeData
sta PSGDataPort
_restore_channel3
lda PSGChannel3SFX ; channel 3 busy with SFX?
bne PSGSetMusicVolumeAttenuation_end ; if so, we're done
lda PSGChan3Volume
anda #$0F
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGSetMusicVolumeAttenuation4 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
PSGSetMusicVolumeAttenuation4
ora #PSGLatch|PSGChannel3|PSGVolumeData
sta PSGDataPort
PSGSetMusicVolumeAttenuation_end
rts
* ************************************************************************************
* sets all PSG channels to volume ZERO (useful if you need to pause music)
* destroys A
PSGSilenceChannels
lda #PSGLatch|PSGChannel0|PSGVolumeData|$0F ; latch channel 0, volume=0xF (silent)
sta PSGDataPort
lda #PSGLatch|PSGChannel1|PSGVolumeData|$0F ; latch channel 1, volume=0xF (silent)
sta PSGDataPort
lda #PSGLatch|PSGChannel2|PSGVolumeData|$0F ; latch channel 2, volume=0xF (silent)
sta PSGDataPort
lda #PSGLatch|PSGChannel3|PSGVolumeData|$0F ; latch channel 3, volume=0xF (silent)
sta PSGDataPort
rts
* ************************************************************************************
* resets all PSG channels to previous volume
* destroys A
PSGRestoreVolumes
lda PSGMusicStatus ; check if tune is playing
beq _chkchn2 ; if not, skip chn0 and chn1
lda PSGChan0Volume
anda #$0F
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGRestoreVolumes1 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
PSGRestoreVolumes1
ora #PSGLatch|PSGChannel0|PSGVolumeData
sta PSGDataPort ; output the byte
lda PSGChan1Volume
anda #$0F
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGRestoreVolumes2 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
PSGRestoreVolumes2
ora #PSGLatch|PSGChannel1|PSGVolumeData
sta PSGDataPort ; output the byte
_chkchn2
lda PSGChannel2SFX ; channel 2 busy with SFX?
bne _restoreSFX2
lda PSGMusicStatus ; check if tune is playing
beq _chkchn3 ; if not, skip chn2
lda PSGChan2Volume
anda #$0F
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGRestoreVolumes3 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
bra PSGRestoreVolumes3
_restoreSFX2
lda PSGSFXChan2Volume
anda $0F
PSGRestoreVolumes3
ora #PSGLatch|PSGChannel2|PSGVolumeData
sta PSGDataPort ; output the byte
_chkchn3
lda PSGChannel3SFX ; channel 3 busy with SFX?
bne _restoreSFX3
lda PSGMusicStatus ; check if tune is playing
beq _restoreSFX2_end ; if not, we've done
lda PSGChan3Volume
anda #$0F
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGRestoreVolumes4 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
bra PSGRestoreVolumes4
_restoreSFX3
lda PSGSFXChan3Volume
anda #$0F
PSGRestoreVolumes4
ora #PSGLatch|PSGChannel3|PSGVolumeData
sta PSGDataPort ; output the byte
_restoreSFX2_end
rts
* ************************************************************************************
* receives in X the address of the SFX PSG to start
* receives in B the mask that indicates which channel(s) the SFX will use
* destroys A
PSGSFXPlayLoop
lda #1 ; SFX _IS_ a looping one
bra PSGSFXPlay1
PSGSFXPlay
lda #0 ; SFX is _NOT_ a looping one
PSGSFXPlay1
sta PSGSFXLoopFlag
bsr PSGSFXStop ; if there's a SFX already playing, we should stop it!
lda ,x
sta PSGSFXPage
ldx 1,x
stx PSGSFXStart ; store begin of SFX
stx PSGSFXPointer ; set the pointer to begin of SFX
stx PSGSFXLoopPoint ; looppointer points to begin too
lda #0
sta PSGSFXSkipFrames ; reset the skip frames
sta PSGSFXSubstringLen ; reset the substring len
bitb #SFX_CHANNEL2 ; channel 2 needed?
beq PSGSFXPlay2
lda #PSG_PLAYING
sta PSGChannel2SFX
PSGSFXPlay2
bitb #SFX_CHANNEL3 ; channel 3 needed?
beq PSGSFXPlay3
lda #PSG_PLAYING
sta PSGChannel3SFX
PSGSFXPlay3
sta PSGSFXStatus ; set status to PSG_PLAYING
lda PSGChan3LowTone ; test if channel 3 uses the frequency of channel 2
anda #SFX_CHANNELS2AND3
cmpa #SFX_CHANNELS2AND3
bne PSGSFXPlayLoop_end ; if channel 3 doesn't use the frequency of channel 2 we're done
lda #PSG_PLAYING
sta PSGChannel3SFX ; otherwise mark channel 3 as occupied by the SFX
lda #PSGLatch|PSGChannel3|PSGVolumeData|$0F ; and silence channel 3
sta PSGDataPort
PSGSFXPlayLoop_end
rts
* ************************************************************************************
* stops the SFX (leaving the music on, if it's playing)
* destroys A
PSGSFXStop
lda PSGSFXStatus ; check status
beq PSGSFXStop_end ; no SFX playing, leave
lda PSGChannel2SFX ; channel 2 playing?
beq PSGSFXStop1
lda #PSGLatch|PSGChannel2|PSGVolumeData|$0F ; latch channel 2, volume=0xF (silent)
sta PSGDataPort
PSGSFXStop1
lda PSGChannel3SFX ; channel 3 playing?
beq PSGSFXStop2
lda #PSGLatch|PSGChannel3|PSGVolumeData|$0F ; latch channel 3, volume=0xf (silent)
sta PSGDataPort
PSGSFXStop2
lda PSGMusicStatus ; check if a tune is playing
beq _skipRestore ; if it's not playing, skip restoring PSG values
lda PSGChannel2SFX ; channel 2 playing?
beq _skip_chn2
lda PSGChan2LowTone
anda #$0F ; use only low 4 bits of byte
ora #PSGLatch|PSGChannel2 ; latch channel 2, low part of tone
sta PSGDataPort
lda PSGChan2HighTone ; high part of tone (latched channel 2, tone)
anda #$3F ; use only low 6 bits of byte
sta PSGDataPort
lda PSGChan2Volume ; restore music' channel 2 volume
anda #$0F ; use only low 4 bits of byte
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGSFXStop3 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
PSGSFXStop3
ora #PSGLatch|PSGChannel2|PSGVolumeData
sta PSGDataPort ; output the byte
_skip_chn2
lda PSGChannel3SFX ; channel 3 playing?
beq _skip_chn3
lda PSGChan3LowTone
anda $07 ; use only low 3 bits of byte
ora #PSGLatch|PSGChannel3 ; latch channel 3, low part of tone (no high part)
sta PSGDataPort
lda PSGChan3Volume ; restore music' channel 3 volume
anda #$0F ; use only low 4 bits of byte
adda PSGMusicVolumeAttenuation
cmpa #$10 ; check overflow
bcs PSGSFXStop4 ; if it's <=15 then ok
lda #$0F ; else, reset to 15
PSGSFXStop4
ora #PSGLatch|PSGChannel3|PSGVolumeData
sta PSGDataPort ; output the byte
_skip_chn3
lda #PSG_STOPPED ; ld a,PSG_STOPPED
_skipRestore
sta PSGChannel2SFX
sta PSGChannel3SFX
sta PSGSFXStatus ; set status to PSG_STOPPED
PSGSFXStop_end
rts
* ************************************************************************************
* sets the currently looping SFX to no more loops after the current
* destroys A
PSGSFXCancelLoop
clr PSGSFXLoopFlag
rts
* ************************************************************************************
* gets the current SFX status into register A
PSGSFXGetStatus
lda PSGSFXStatus
rts
* ************************************************************************************
* processes a music frame
* destroys A,B,X
PSGFrame
lda PSGMusicStatus ; check if we have got to play a tune
bne PSGFrame_continue
rts
PSGFrame_continue
lda PSGMusicPage
_SetCartPageA
lda PSGMusicSkipFrames ; check if we havve got to skip frames
bne _skipFrame
ldx PSGMusicPointer ; read current address
_intLoop
ldb ,x+ ; load PSG byte (in B)
lda PSGMusicSubstringLen ; read substring len
beq _continue ; check if it is 0 (we are not in a substring)
deca ; decrease len
sta PSGMusicSubstringLen ; save len
bne _continue
ldx PSGMusicSubstringRetAddr ; substring is over, retrieve return address
_continue
cmpb #PSGLatch ; is it a latch?
bcs _noLatch ; if < $80 then it is NOT a latch
stb PSGMusicLastLatch ; it is a latch - save it in "LastLatch"
bitb #4 ; test if it is a volume
bne _latch_Volume ; jump if volume data
bitb #6 ; test if the latch it is for channels 0-1 or for 2-3
beq _send2PSG ; send data to PSG if it is for channels 0-1
bitb #5 ; test if tone it is for channel 2 or 3
beq _ifchn2 ; jump if channel 2
stb PSGChan3LowTone ; save tone LOW data
lda PSGChannel3SFX ; channel 3 free?
bne _intLoop
lda PSGChan3LowTone
anda #3 ; test if channel 3 is set to use the frequency of channel 2
cmpa #3
bne _send2PSG ; if channel 3 does not use frequency of channel 2 jump
lda PSGSFXStatus ; test if an SFX is playing
beq _send2PSG ; if no SFX is playing jump
sta PSGChannel3SFX ; otherwise mark channel 3 as occupied
lda #PSGLatch|PSGChannel3|PSGVolumeData|$0F ; and silence channel 3
sta PSGDataPort
bra _intLoop
_ifchn2
stb PSGChan2LowTone ; save tone LOW data
lda PSGChannel2SFX ; channel 2 free?
beq _send2PSG
bra _intLoop
_latch_Volume
bitb #6 ; test if the latch it is for channels 0-1 or for 2-3
bne _latch_Volume_23 ; volume is for channel 2 or 3
bitb #5 ; test if volume it is for channel 0 or 1
beq _ifchn0 ; jump for channel 0
stb PSGChan1Volume ; save volume data
bra _sendVolume2PSG
_ifchn0
stb PSGChan0Volume ; save volume data
bra _sendVolume2PSG
_latch_Volume_23
bitb #5 ; test if volume it is for channel 2 or 3
beq _chn2 ; jump for channel 2
stb PSGChan3Volume ; save volume data
lda PSGChannel3SFX ; channel 3 free?
beq _sendVolume2PSG
bra _intLoop
_chn2
stb PSGChan2Volume ; save volume data
lda PSGChannel2SFX ; channel 2 free?
beq _sendVolume2PSG
bra _intLoop
_send2PSG
stb PSGDataPort ; output the byte
bra _intLoop
_skipFrame
deca
sta PSGMusicSkipFrames
rts
_noLatch
cmpb #PSGData
bcs _command ; if < $40 then it is a command
* it's a data
lda PSGMusicLastLatch ; retrieve last latch
bra _output_NoLatch
_command
cmpb #PSGWait
beq _done ; no additional frames
bcs _otherCommands ; other commands?
andb #$07 ; take only the last 3 bits for skip frames
stb PSGMusicSkipFrames ; we got additional frames
_done
stx PSGMusicPointer ; save current address
rts ; frame done
_otherCommands
cmpb #PSGSubString
bcc _substring
cmpb #PSGEnd
beq _musicLoop
cmpb #PSGLoop
beq _setLoopPoint
* ***************************************************************************
* we should never get here!
* if we do, it means the PSG file is probably corrupted, so we just RET
* ***************************************************************************
rts
_sendVolume2PSG
stb _sendVolume2PSG1+1 ; save the PSG command byte
andb #$0F ; keep lower nibble
addb PSGMusicVolumeAttenuation ; add volume attenuation
cmpb #$10 ; check overflow
bcs _sendVolume2PSG1 ; if it is <=15 then ok
ldb #$0F ; else, reset to 15
_sendVolume2PSG1
lda #0 ; retrieve PSG command
stb _sendVolume2PSG2+1
anda #$F0 ; keep upper nibble
_sendVolume2PSG2
ora #0 ; set attenuated volume
sta PSGDataPort ; output the byte
jmp _intLoop
_output_NoLatch
* we got the last latch in A and the PSG data in B
* and we have to check if the value should pass to PSG or not
* note that non-latch commands can be only contain frequencies (no volumes)
* for channels 0,1,2 only (no noise)
bita #6 ; test if the latch it is for channels 0-1 or for chn 2
bne _high_part_Tone ; it is tone data for channel 2
bra _send2PSG ; otherwise, it is for chn 0 or 1 so we have done!
_setLoopPoint
stx PSGMusicLoopPoint
jmp _intLoop
_musicLoop
lda PSGLoopFlag ; looping requested?
lbeq PSGStop ; No:stop it! (tail call optimization)
ldx PSGMusicLoopPoint
jmp _intLoop
_substring
subb #PSGSubString-4 ; len is value - $08 + 4
stb PSGMusicSubstringLen ; save len
ldb ,x+ ; load substring address (offset) little-endian
lda ,x+ ; load substring address (offset) little-endian
stx PSGMusicSubstringRetAddr ; save return address
ldx PSGMusicStart
leax d,x ; make substring current
jmp _intLoop
_high_part_Tone
stb PSGChan2HighTone ; save channel 2 tone HIGH data
lda PSGChannel2SFX ; channel 2 free?
lbeq _send2PSG
jmp _intLoop
* ************************************************************************************
* processes a SFX frame
* destroys A,B,X
PSGSFXFrame
lda PSGSFXPage
_SetCartPageA
lda PSGSFXStatus ; check if we have got to play SFX
beq PSGSFXFrame_end
lda PSGSFXSkipFrames ; check if we have got to skip frames
bne _skipSFXFrame
ldx PSGSFXPointer ; read current SFX address
_intSFXLoop
ldb ,x+ ; load a byte in B
lda PSGSFXSubstringLen ; read substring len
beq _SFXcontinue ; check if it is 0 (we are not in a substring)
deca ; decrease len
sta PSGSFXSubstringLen ; save len
bne _SFXcontinue
ldx PSGSFXSubstringRetAddr ; substring over, retrieve return address
_SFXcontinue
cmpb #PSGData
bcs _SFXcommand ; if less than $40 then it is a command
bitb #4 ; check if it is a volume byte
beq _SFXoutbyte ; if not, output it
bitb #5 ; check if it is volume for channel 2 or channel 3
bne _SFXvolumechn3
stb PSGSFXChan2Volume
bra _SFXoutbyte
_SFXvolumechn3
stb PSGSFXChan3Volume
_SFXoutbyte
stb PSGDataPort ; output the byte
bra _intSFXLoop
_skipSFXFrame
deca
sta PSGSFXSkipFrames
PSGSFXFrame_end
rts
_SFXcommand
cmpb #PSGWait
beq _SFXdone ; no additional frames
bcs _SFXotherCommands ; other commands?
andb #$07 ; take only the last 3 bits for skip frames
stb PSGSFXSkipFrames ; we got additional frames to skip
_SFXdone
stx PSGSFXPointer ; save current address
rts ; frame done
_SFXotherCommands
cmpb #PSGSubString
bcc _SFXsubstring
cmpb #PSGEnd
beq _sfxLoop
cmpb #PSGLoop
beq _SFXsetLoopPoint
* ***************************************************************************
* we should never get here!
* if we do, it means the PSG SFX file is probably corrupted, so we just RET
* ***************************************************************************
rts
_SFXsetLoopPoint
stx PSGSFXLoopPoint
bra _intSFXLoop
_sfxLoop
lda PSGSFXLoopFlag ; is it a looping SFX?
lbeq PSGSFXStop ; No:stop it! (tail call optimization)
ldx PSGSFXLoopPoint
stx PSGSFXPointer
bra _intSFXLoop
_SFXsubstring
subb #PSGSubString-4 ; len is value - $08 + 4
stb PSGSFXSubstringLen ; save len
ldb ,x+ ; load substring address (offset) little-endian
lda ,x+ ; load substring address (offset) little-endian
stx PSGSFXSubstringRetAddr ; save return address
ldx PSGSFXStart
leax d,x ; make substring current
bra _intSFXLoop
* fundamental vars
PSGMusicStatus fcb $00 ; are we playing a background music?
PSGMusicPage fcb $00 ; Memory Page of Music Data
PSGMusicStart fdb $0000 ; the pointer to the beginning of music
PSGMusicPointer fdb $0000 ; the pointer to the current
PSGMusicLoopPoint fdb $0000 ; the pointer to the loop begin
PSGMusicSkipFrames fcb $00 ; the frames we need to skip
PSGLoopFlag fcb $00 ; the tune should loop or not (flag)
PSGMusicLastLatch fcb $00 ; the last PSG music latch
* decompression vars
PSGMusicSubstringLen fcb $00 ; length of the substring we are playing
PSGMusicSubstringRetAddr fdb $0000 ; return to this address when substring is over
* command buffers
PSGChan0Volume fcb $00 ; the volume for channel 0
PSGChan1Volume fcb $00 ; the volume for channel 1
PSGChan2Volume fcb $00 ; the volume for channel 2
PSGChan3Volume fcb $00 ; the volume for channel 3
PSGChan2LowTone fcb $00 ; the low tone bits for channels 2
PSGChan3LowTone fcb $00 ; the low tone bits for channels 3
PSGChan2HighTone fcb $00 ; the high tone bits for channel 2
PSGMusicVolumeAttenuation fcb $00 ; the volume attenuation applied to the tune (0-15)
* ******* SFX *************
* flags for channels 2-3 access
PSGChannel2SFX fcb $00 ; !0 means channel 2 is allocated to SFX
PSGChannel3SFX fcb $00 ; !0 means channel 3 is allocated to SFX
* command buffers for SFX
PSGSFXChan2Volume fcb $00 ; the volume for channel 2
PSGSFXChan3Volume fcb $00 ; the volume for channel 3
* fundamental vars for SFX
PSGSFXStatus fcb $00 ; are we playing a SFX?
PSGSFXPage fcb $00 ; Memory Page of SFX Data
PSGSFXStart fdb $0000 ; the pointer to the beginning of SFX
PSGSFXPointer fdb $0000 ; the pointer to the current address
PSGSFXLoopPoint fdb $0000 ; the pointer to the loop begin
PSGSFXSkipFrames fcb $00 ; the frames we need to skip
PSGSFXLoopFlag fcb $00 ; the SFX should loop or not (flag)
* decompression vars for SFX
PSGSFXSubstringLen fcb $00 ; length of the substring we are playing
PSGSFXSubstringRetAddr fdb $0000 ; return to this address when substring is over
|
//
// (C) 2005 Vojtech Janota
// (C) 2010 Zoltan Bojthe
// (C) 2014 RWTH Aachen University, Chair of Communication and Distributed Systems
//
// This library is free software, you can redistribute it
// and/or modify
// it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation;
// either version 2 of the License, or any later version.
// The library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
#include "ByteArray.h"
// Another default rule (prevents compiler from choosing base class' doPacking())
template<typename T>
void doPacking(cCommBuffer *, T& t) {
throw cRuntimeError("Parsim error: no doPacking() function for type %s or its base class (check .msg and _m.cc/h files!)",opp_typename(typeid(t)));
}
template<typename T>
void doUnpacking(cCommBuffer *, T& t) {
throw cRuntimeError("Parsim error: no doUnpacking() function for type %s or its base class (check .msg and _m.cc/h files!)",opp_typename(typeid(t)));
}
void doPacking(cCommBuffer *buffer, ByteArray &byteArray) {
size_t datasize = byteArray.getDataArraySize();
buffer->pack(datasize);
for(size_t i = 0; i < datasize; i++)
buffer->pack(byteArray.getData(i));
}
void doUnpacking(cCommBuffer *buffer, ByteArray &byteArray) {
size_t datasize;
buffer->unpack(datasize);
byteArray.setDataArraySize(datasize);
for(size_t i = 0; i < datasize; i++)
{
char val;
buffer->unpack(val);
byteArray.setData(i,val);
}
}
void ByteArray::setDataFromBuffer(const void *ptr, unsigned int length)
{
if (length != data_arraysize)
{
delete [] data_var;
data_var = length ? new char[length] : NULL;
data_arraysize = length;
}
if (length)
memcpy(data_var, ptr, length);
}
void ByteArray::setDataFromByteArray(const ByteArray& other, unsigned int srcOffs, unsigned int length)
{
ASSERT(srcOffs+length <= other.data_arraysize);
setDataFromBuffer(other.data_var+srcOffs, length);
}
void ByteArray::addDataFromBuffer(const void *ptr, unsigned int length)
{
if (0 == length)
return;
unsigned int nlength = data_arraysize + length;
char *ndata_var = new char[nlength];
if (data_arraysize)
memcpy(ndata_var, data_var, data_arraysize);
memcpy(ndata_var + data_arraysize, ptr, length);
delete [] data_var;
data_var = ndata_var;
data_arraysize = nlength;
}
unsigned int ByteArray::copyDataToBuffer(void *ptr, unsigned int length, unsigned int srcOffs) const
{
if (srcOffs >= data_arraysize)
return 0;
if (srcOffs + length > data_arraysize)
length = data_arraysize - srcOffs;
memcpy(ptr, data_var+srcOffs, length);
return length;
}
void ByteArray::assignBuffer(void *ptr, unsigned int length)
{
delete [] data_var;
data_var = (char *)ptr;
data_arraysize = length;
}
void ByteArray::truncateData(unsigned int truncleft, unsigned int truncright)
{
ASSERT(data_arraysize >= (truncleft + truncright));
if ((truncleft || truncright))
{
unsigned int nlength = data_arraysize - (truncleft + truncright);
char *ndata_var = NULL;
if (nlength)
{
ndata_var = new char[nlength];
memcpy(ndata_var, data_var+truncleft, nlength);
}
delete [] data_var;
data_var = ndata_var;
data_arraysize = nlength;
}
}
|
//general includes
#include "ros/ros.h"
#include "nav_msgs/OccupancyGrid.h"
#include "geometry_msgs/Pose.h"
#include "geometry_msgs/Quaternion.h"
#include "geometry_msgs/Point32.h"
#include "geometry_msgs/PointStamped.h"
#include "nav_msgs/Odometry.h"
#include "std_msgs/String.h"
#include <math.h>
#include <sstream>
//custom message types
#include "road_detection/LineMatch.h"
#include "road_detection/Line.h"
#include "road_detection/LineArray.h"
#include "road_detection/Road.h"
//PCL Stuff
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl_ros/point_cloud.h>
#include <sensor_msgs/point_cloud2_iterator.h>
#include <sensor_msgs/ChannelFloat32.h>
//Lidar
#include <sensor_msgs/LaserScan.h>
#include <tf/transform_listener.h>
//Services
#include "arlo_navigation/clearleftlane.h"
//dyn_recon
#include <dynamic_reconfigure/server.h>
#include <arlo_navigation/markfreespaceConfig.h>
//ft2
#include "tf2_geometry_msgs/tf2_geometry_msgs.h"
#include <tf2_ros/transform_listener.h>
#include <geometry_msgs/TransformStamped.h>
geometry_msgs::Quaternion orientation;
geometry_msgs::Point position;
//Thresholds for slam data evaluation everything between unknown thresh and known thresh gets treated as empty space
//TODO make these configurable using dyn_recon
bool middletrigger;
bool blockagetrigger=true;
ros::Publisher pub;
ros::Publisher inflationpub;
ros::Publisher linepub;
sensor_msgs::PointCloud2 constructcloud(std::vector<geometry_msgs::Point32> &points, float intensity, std::string frame, ros::Time stamp);
std::vector<geometry_msgs::Point32> navpoints;
sensor_msgs::PointCloud InflatePoints;
sensor_msgs::ChannelFloat32 RadInfo;
sensor_msgs::ChannelFloat32 MaxCost;
sensor_msgs::ChannelFloat32 MinCost;
double inflaterad;
double maxcost;
double mincost;
double clearrad,obstaclerad,inflatedist,cleardist;
void callback(arlo_navigation::markfreespaceConfig &config, uint32_t level) {
middletrigger=config.middleline;
maxcost=config.MaxCost;
mincost=config.MinCost;
inflaterad=config.LeftInflation;
clearrad=config.RightRemoval;
obstaclerad=config.ObstacleRemoval;
inflatedist=config.InflPointDistance;
cleardist=config.ClearPointDistance;
}
class Listener
{
private:
road_detection::Line Left,Right,Middle;
double lwidth,rwidth;
ros::Time obstaclstamp;
std::vector<geometry_msgs::Point32> points;
std::vector<geometry_msgs::Point32> scan;
std::vector<geometry_msgs::Point32> obstacles;
double polynomial(double x, road_detection::Line::_polynomial_type::_a_type a) {
double xp = 1;
double result = 0;
for ( int i = 0; i < a.size(); i++ ) {
result += xp * a[i];
xp *= x;
}
return result;
}
public:
std::string roadframe="base_footprint";//starting value since wee have to wait for the road detection
ros::Time roadstamp;
void roadCallback(const road_detection::RoadConstPtr& road)
{
geometry_msgs::Point32 Buffer;
Left=road->lineLeft;
Right=road->lineRight;
lwidth=road->laneWidthLeft;
rwidth=road->laneWidthRight;
roadframe=road->header.frame_id;
roadstamp=road->header.stamp;
//Transforming points of road_detection into sensor_msgs::PointCloud2 so they can be used for slam and the costmap
points.clear();
//publishing borders and middle line individual to give better flexibility
for(int i=0;i<road->lineLeft.points.size();i++)
{
Buffer.x=road->lineLeft.points[i].x;
Buffer.y=road->lineLeft.points[i].y;
points.push_back(Buffer);
}
//inflaterad=road->laneWidthRight*0.4;
for(int j=0;j<road->lineRight.points.size();j++)
{
Buffer.x=road->lineRight.points[j].x;
Buffer.y=road->lineRight.points[j].y;
points.push_back(Buffer);
}
for(int k=0;k<road->lineMiddle.points.size();k++)
{
Buffer.x=road->lineMiddle.points[k].x;
Buffer.y=road->lineMiddle.points[k].y;
//functionality to switch of middle line
if(middletrigger) points.push_back(Buffer);
}
//Line Publisher for navigation (costmap)
navpoints=points;
}
void Inflate()
{
geometry_msgs::Point32 Buffer, Old;
RadInfo.values.clear();
MaxCost.values.clear();
InflatePoints.channels.clear();
InflatePoints.points.clear();
RadInfo.name="InflationRadius";
MaxCost.name="MaxCost";
InflatePoints.header.frame_id=Left.header.frame_id;
InflatePoints.header.stamp=Left.header.stamp;
if(inflatedist==0&&Left.points.size()>0)
{
Buffer.x=Left.points.back().x;
Buffer.y=Left.points.back().y;
InflatePoints.points.push_back(Buffer);
RadInfo.values.push_back(lwidth+rwidth*inflaterad);
MaxCost.values.push_back(maxcost);
MinCost.values.push_back(mincost);
}
else{
for(int i=0;i<Left.points.size();i++)
{
Buffer.x=Left.points[i].x;
Buffer.y=Left.points[i].y;
if(i==0||sqrt(pow(Old.x-Buffer.x,2)+pow(Old.y-Buffer.y,2))>inflatedist){
InflatePoints.points.push_back(Buffer);
RadInfo.values.push_back(lwidth+rwidth*inflaterad);
MaxCost.values.push_back(maxcost);
MinCost.values.push_back(mincost);
Old=Buffer;
}
}
}
if(clearrad>0){
if(cleardist==0&&Right.points.size()>0)
{
Buffer.x=Right.points.back().x;
Buffer.y=Right.points.back().y;
InflatePoints.points.push_back(Buffer);
RadInfo.values.push_back(rwidth*clearrad);//adding points of right line so we allways have a free lane on the right even when street moves
MaxCost.values.push_back(0);
MinCost.values.push_back(0);
}
else{
for(int j=0;j<Right.points.size();j++)
{
Buffer.x=Right.points[j].x;
Buffer.y=Right.points[j].y;
if(j==0||sqrt(pow(Old.x-Buffer.x,2)+pow(Old.y-Buffer.y,2))>cleardist){
InflatePoints.points.push_back(Buffer);
RadInfo.values.push_back(rwidth*clearrad);//adding points of right line so we allways have a free lane on the right even when street moves
MaxCost.values.push_back(0);
MinCost.values.push_back(0);
Old=Buffer;
}
}
}
}
if(obstaclerad>0){
for(int j=0;j<obstacles.size();j++)
{
Buffer.x=obstacles[j].x;
Buffer.y=obstacles[j].y;
if(j==0||sqrt(pow(Old.x-Buffer.x,2)+pow(Old.y-Buffer.y,2))>obstaclerad*0.66){
InflatePoints.points.push_back(Buffer);
RadInfo.values.push_back(obstaclerad);//adding points of right line so we allways have a free lane on the right even when street moves
MaxCost.values.push_back(0);
MinCost.values.push_back(0);
Old=Buffer;
}
}
}
}
void scanCallback(const sensor_msgs::LaserScanConstPtr& Scan)
{
//generates combined pointcloud of lidar and roaddetection
scan.clear();
obstacles.clear();
geometry_msgs::Point32 scanpoint;
geometry_msgs::PointStamped tpt;
float angle;
float range;
geometry_msgs::TransformStamped transformStamped;
tf2_ros::Buffer tfBuffer;
tf2_ros::TransformListener tfListener(tfBuffer);
for(int i=0;i<Scan->ranges.size();i++)
{
angle=(i*Scan->angle_increment)+Scan->angle_min;
range=Scan->ranges.at(i);
//offset value from arlo_2stack urdf
tpt.point.x=range*cos(angle);
tpt.point.y=range*sin(angle);
tpt.point.z=0.0;
try{
//transform scanned point into the frame of the road detection then compare it with the road
transformStamped = tfBuffer.lookupTransform( roadframe,Scan->header.frame_id,Scan->header.stamp,ros::Duration(1));
tf2::doTransform(tpt,tpt, transformStamped);
scanpoint.x=tpt.point.x;
scanpoint.y=tpt.point.y;
scanpoint.z=tpt.point.z;
//pub.publish(Test);
//check whether the point is in the lane by projecting it on to the 3 roadlines and comparing their y values
//exact calculation not necessary since road makes wide curves
if(polynomial(scanpoint.x, Middle.polynomial.a)>scanpoint.y && polynomial(scanpoint.x, Right.polynomial.a)<scanpoint.y)
{
obstacles.push_back(scanpoint);
}
// else if(polynomial(scanpoint.point.x, Right.polynomial.a)<scanpoint.point.y && polynomial(scanpoint.point.x, Middle.polynomial.a)>scanpoint.point.y)
// {
// }
scan.push_back(scanpoint);
}
catch(tf2::TransformException &ex)
{
//ROS_WARN("%s", ex.what());
}
}
if(scan.size()>=points.size()){
scan.insert( scan.end(), points.begin(), points.end() );
if(scan.size()>0) pub.publish(constructcloud(scan,100,"base_footprint",roadstamp));
}
else
{
points.insert( points.end(), scan.begin(), scan.end() );
if(points.size()>0) pub.publish(constructcloud(points,100,"base_footprint",roadstamp));
}
}
bool clearleftline(arlo_navigation::clearleftlaneRequest &request,arlo_navigation::clearleftlaneResponse &response)
{
//inverting this bit switches the blockage of the left lane on and off.
//is meant to be controlled by the pose finder and can be used in escape manouvers
blockagetrigger=request.trigger;
response.result=blockagetrigger;
return true;
}
};
sensor_msgs::PointCloud2 constructcloud(std::vector<geometry_msgs::Point32> &points, float intensity, std::string frame, ros::Time stamp)
{
//Construct PointCloud2 Message with given array of points tf_frame and intensity
int Count=points.size();
// Populate message fields
const uint32_t POINT_STEP = 16;
sensor_msgs::PointCloud2 msg;
msg.header.frame_id =frame;
msg.header.stamp = stamp;
msg.fields.resize(4);
msg.fields[0].name = "x";
msg.fields[0].offset = 0;
msg.fields[0].datatype = sensor_msgs::PointField::FLOAT32;
msg.fields[0].count = 1;
msg.fields[1].name = "y";
msg.fields[1].offset = 4;
msg.fields[1].datatype = sensor_msgs::PointField::FLOAT32;
msg.fields[1].count = 1;
msg.fields[2].name = "z";
msg.fields[2].offset = 8;
msg.fields[2].datatype = sensor_msgs::PointField::FLOAT32;
msg.fields[2].count = 1;
msg.fields[3].name = "intensity";
msg.fields[3].offset = 12;
msg.fields[3].datatype = sensor_msgs::PointField::FLOAT32;
msg.fields[3].count = 1;
msg.data.resize(Count * POINT_STEP);
int i;
uint8_t *ptr = msg.data.data();
for(i=0; i<Count;i++)
{
*((float*)(ptr + 0))=points[i].x;
*((float*)(ptr + 4))=points[i].y;
*((float*)(ptr + 8))=points[i].z;
*((float*)(ptr + 12))=intensity;
ptr += POINT_STEP;
}
msg.point_step = POINT_STEP;
msg.row_step = ptr - msg.data.data();
msg.height = 1; //since data is not ordered
msg.width = msg.row_step / POINT_STEP;
msg.is_bigendian = false;
msg.is_dense = true; //maybe invalid points
msg.data.resize(msg.row_step); // Shrink to actual size
return msg;
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "markfreespace");
ros::NodeHandle n;
Listener listener;
tf::TransformListener tflistener;
tf::StampedTransform transform;
dynamic_reconfigure::Server<arlo_navigation::markfreespaceConfig> server;
dynamic_reconfigure::Server<arlo_navigation::markfreespaceConfig>::CallbackType f;
f = boost::bind(&callback, _1, _2);
server.setCallback(f);
inflationpub = n.advertise<sensor_msgs::PointCloud>("/points",1000);
pub = n.advertise<sensor_msgs::PointCloud2>("RoadPointCloud2", 1000);
linepub=n.advertise<sensor_msgs::PointCloud2>("NavPointData",1000);
//TODO maybe 3 different point clouds for each line of the track
ros::Subscriber road = n.subscribe("/roadDetection/road", 1000, &Listener::roadCallback, &listener);
ros::Subscriber scansub = n.subscribe("/scan_filtered", 1000, &Listener::scanCallback, &listener);
//ros::Subscriber map = n.subscribe("/map", 1000, &Listener::mapCallback, &listener);
//ros::Subscriber odom = n.subscribe("/odom", 1000, &Listener::odomCallback, &listener);
ros::ServiceServer clearblockage = n.advertiseService("clearblockage", &Listener::clearleftline, &listener);
//TODO configure frequency
ros::Rate rate(10);
ros::Rate inflaterate(0.25);
ros::Time oldstamp;
//copy smaller vector to larger and publish it as pointcloud2
while(n.ok()){
linepub.publish(constructcloud(navpoints,100,"base_footprint",listener.roadstamp));
if((ros::Time::now().sec-oldstamp.sec)>inflaterate.cycleTime().sec)
{
listener.Inflate();
if(InflatePoints.points.size()>0){
InflatePoints.channels.push_back(RadInfo);
InflatePoints.channels.push_back(MaxCost);
InflatePoints.channels.push_back(MinCost);
inflationpub.publish(InflatePoints);
}
oldstamp=ros::Time::now();
}
ros::spinOnce();
rate.sleep();
}
return 0;
}
|
; A039714: a(n) = n-th prime modulo 16.
; 2,3,5,7,11,13,1,3,7,13,15,5,9,11,15,5,11,13,3,7,9,15,3,9,1,5,7,11,13,1,15,3,9,11,5,7,13,3,7,13,3,5,15,1,5,7,3,15,3,5,9,15,1,11,1,7,13,15,5,9,11,5,3,7,9,13,11,1,11,13,1,7,15,5,11,15,5,13,1,9,3,5,15,1,7,11,1,9,13,15,3,15,7,11,3,7,13,9,11,13
seq $0,40 ; The prime numbers.
mod $0,16
|
/*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2020 Scientific Computing and Imaging Institute,
University of Utah.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Author: Jaume Coll-Font
Last Modification: September 6 2017
*/
#include <Core/Algorithms/Legacy/Inverse/TikhonovImpl.h>
// default lambda step. Can ve overriden if necessary (see TSVD as reference)
std::vector<double> SCIRun::Core::Algorithms::Inverse::TikhonovImpl::computeLambdaArray( double lambdaMin, double lambdaMax, int nLambda ) const
{
std::vector<double> lambdaArray(nLambda,0.0);
double lam_step = (log10(lambdaMax) - log10(lambdaMin)) / (nLambda-1);
lambdaArray[0] = lambdaMin;
for (int j = 1; j < nLambda; j++)
{
lambdaArray[j] = lambdaArray[j-1] * pow(10.0,lam_step);
}
return lambdaArray;
}
|
#include "Platform.inc"
#include "FarCalls.inc"
#include "Flash.inc"
#include "Lcd.inc"
#include "States.inc"
#include "Ui.inc"
#include "WaitButtonPressState.inc"
radix decimal
defineUiState UI_STATE_ADJUSTSETTINGS
fcall isLcdIdle
xorlw 0
btfsc STATUS, Z
returnFromUiState
loadFlashAddressOf screen
fcall putScreenFromFlash
waitForButtonPress UI_STATE_ADJUSTSETTINGS_LEFT, UI_STATE_ADJUSTSETTINGS_RIGHT, UI_STATE_ADJUSTSETTINGS_ENTER
returnFromUiState
defineUiStateInSameSection UI_STATE_ADJUSTSETTINGS_LEFT
setUiState UI_STATE_VERSION
returnFromUiState
defineUiStateInSameSection UI_STATE_ADJUSTSETTINGS_RIGHT
setUiState UI_STATE_HOME
returnFromUiState
defineUiStateInSameSection UI_STATE_ADJUSTSETTINGS_ENTER
bsf uiFlags, UI_FLAG_PREVENTSLEEP
setUiState UI_STATE_SETTINGS
returnFromUiState
screen:
da "Adjust Settings "
da " "
end
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: LBP driver
FILE: capsl2Info.asm
AUTHOR: Dave Durran
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 2/27/90 Initial revision
Dave 6/22/92 Initial 2.0 revision
DESCRIPTION:
This file contains the device information for the Canon LBP
Other Printers Supported by this resource:
$Id: capsl2Info.asm,v 1.1 97/04/18 11:51:58 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;----------------------------------------------------------------------------
; Canon LBP font set common to all LBPs.
;----------------------------------------------------------------------------
capsl2Info segment resource
; info blocks
PrinterInfo < ; ---- PrinterType -------------
< PT_RASTER,
BMF_MONO >,
; ---- PrinterConnections ------
< IC_NO_IEEE488,
CC_NO_CUSTOM,
SC_NO_SCSI,
RC_RS232C,
CC_CENTRONICS,
FC_FILE,
AC_NO_APPLETALK >,
; ---- PrinterSmarts -----------
PS_DUMB_RASTER,
;-------Custom Entry Routine-------
NULL,
;-------Custom Exit Routine-------
NULL,
; ---- Mode Info Offsets -------
offset capsl2lowRes,
offset capsl2medRes,
offset capsl2hiRes,
NULL,
offset printerFontInfo:capsl2nlq,
; ---- Font Geometry -----------
NULL,
; ---- Symbol Set list -----------
NULL,
; ---- PaperMargins ------------
< PR_MARGIN_LEFT, ; Tractor Margins
0,
PR_MARGIN_RIGHT,
0 >,
< PR_MARGIN_LEFT, ; ASF Margins
PR_MARGIN_TOP,
PR_MARGIN_RIGHT,
PR_MARGIN_BOTTOM >,
; ---- PaperInputOptions -------
< MF_MANUAL1,
TF_NO_TRACTOR,
ASF_TRAY3 >,
; ---- PaperOutputOptions ------
< OC_COPIES,
PS_REVERSE,
OD_SIMPLEX,
SO_NO_STAPLER,
OS_NO_SORTER,
OB_NO_OUTPUTBIN >,
;
612, ; paper width (points).
NULL, ; Main UI
CapslOptionsDialogBox, ; Options UI
PrintEvalSimplex ; UI eval routines.
>
;----------------------------------------------------------------------------
; Graphics modes info
;----------------------------------------------------------------------------
capsl2lowRes GraphicsProperties < LO_RES_X_RES, ; xres
LO_RES_Y_RES, ; yres
LO_RES_BAND_HEIGHT, ; band height
LO_RES_BUFF_HEIGHT, ; buffer height
LO_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_MONO, ;color format
NULL > ; color format
capsl2medRes GraphicsProperties < MED_RES_X_RES, ; xres
MED_RES_Y_RES, ; yres
MED_RES_BAND_HEIGHT, ; band height
MED_RES_BUFF_HEIGHT, ; buffer height
MED_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_MONO, ;color format
NULL > ; color format
capsl2hiRes GraphicsProperties < HI_RES_X_RES, ; xres
HI_RES_Y_RES, ; yres
HI_RES_BAND_HEIGHT, ; band height
HI_RES_BUFF_HEIGHT, ; buffer height
HI_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_MONO, ;color format
NULL > ; color format
capsl2Info ends
|
_clonetest: file format elf32-i386
Disassembly of section .text:
00000000 <child>:
int x = 0;
mutex_t lock;
void
child(void *arg_ptr)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 28 sub $0x28,%esp
int i;
for(i=0;i<100000;i++)
6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
d: eb 29 jmp 38 <child+0x38>
{
mutex_lock(&lock);
f: c7 04 24 28 0d 00 00 movl $0xd28,(%esp)
16: e8 15 09 00 00 call 930 <mutex_lock>
x++;
1b: a1 18 0d 00 00 mov 0xd18,%eax
20: 83 c0 01 add $0x1,%eax
23: a3 18 0d 00 00 mov %eax,0xd18
mutex_unlock(&lock);
28: c7 04 24 28 0d 00 00 movl $0xd28,(%esp)
2f: e8 1d 09 00 00 call 951 <mutex_unlock>
void
child(void *arg_ptr)
{
int i;
for(i=0;i<100000;i++)
34: 83 45 f4 01 addl $0x1,-0xc(%ebp)
38: 81 7d f4 9f 86 01 00 cmpl $0x1869f,-0xc(%ebp)
3f: 7e ce jle f <child+0xf>
{
mutex_lock(&lock);
x++;
mutex_unlock(&lock);
}
exit();
41: e8 62 03 00 00 call 3a8 <exit>
00000046 <main>:
}
int
main(int argc, char *argv[])
{
46: 55 push %ebp
47: 89 e5 mov %esp,%ebp
49: 83 e4 f0 and $0xfffffff0,%esp
4c: 83 ec 30 sub $0x30,%esp
printf(1, "clone test\n");
4f: c7 44 24 04 ae 09 00 movl $0x9ae,0x4(%esp)
56: 00
57: c7 04 24 01 00 00 00 movl $0x1,(%esp)
5e: e8 d5 04 00 00 call 538 <printf>
ppid = getpid();
63: e8 c0 03 00 00 call 428 <getpid>
68: a3 2c 0d 00 00 mov %eax,0xd2c
int arg1 = 10, arg2 =20;
6d: c7 44 24 14 0a 00 00 movl $0xa,0x14(%esp)
74: 00
75: c7 44 24 10 14 00 00 movl $0x14,0x10(%esp)
7c: 00
//int thread_cnt = atoi(argv[1]);
void *arg_ptr1 = &arg1;
7d: 8d 44 24 14 lea 0x14(%esp),%eax
81: 89 44 24 2c mov %eax,0x2c(%esp)
void *arg_ptr2 = &arg2;
85: 8d 44 24 10 lea 0x10(%esp),%eax
89: 89 44 24 28 mov %eax,0x28(%esp)
int c_pid = thread_create(child,arg_ptr1);
8d: 8b 44 24 2c mov 0x2c(%esp),%eax
91: 89 44 24 04 mov %eax,0x4(%esp)
95: c7 04 24 00 00 00 00 movl $0x0,(%esp)
9c: e8 be 08 00 00 call 95f <thread_create>
a1: 89 44 24 24 mov %eax,0x24(%esp)
int c_pid1 = thread_create(child,arg_ptr2);
a5: 8b 44 24 28 mov 0x28(%esp),%eax
a9: 89 44 24 04 mov %eax,0x4(%esp)
ad: c7 04 24 00 00 00 00 movl $0x0,(%esp)
b4: e8 a6 08 00 00 call 95f <thread_create>
b9: 89 44 24 20 mov %eax,0x20(%esp)
int j_pid = thread_join();
bd: e8 d3 08 00 00 call 995 <thread_join>
c2: 89 44 24 1c mov %eax,0x1c(%esp)
int j_pid1 = thread_join();
c6: e8 ca 08 00 00 call 995 <thread_join>
cb: 89 44 24 18 mov %eax,0x18(%esp)
if(j_pid == c_pid){} else{kill(ppid); exit();}
cf: 8b 44 24 1c mov 0x1c(%esp),%eax
d3: 3b 44 24 24 cmp 0x24(%esp),%eax
d7: 74 12 je eb <main+0xa5>
d9: a1 2c 0d 00 00 mov 0xd2c,%eax
de: 89 04 24 mov %eax,(%esp)
e1: e8 f2 02 00 00 call 3d8 <kill>
e6: e8 bd 02 00 00 call 3a8 <exit>
if(j_pid1 == c_pid1){} else{kill(ppid); exit();}
eb: 8b 44 24 18 mov 0x18(%esp),%eax
ef: 3b 44 24 20 cmp 0x20(%esp),%eax
f3: 74 12 je 107 <main+0xc1>
f5: a1 2c 0d 00 00 mov 0xd2c,%eax
fa: 89 04 24 mov %eax,(%esp)
fd: e8 d6 02 00 00 call 3d8 <kill>
102: e8 a1 02 00 00 call 3a8 <exit>
printf(1,"The counter: %d\n",x);
107: a1 18 0d 00 00 mov 0xd18,%eax
10c: 89 44 24 08 mov %eax,0x8(%esp)
110: c7 44 24 04 ba 09 00 movl $0x9ba,0x4(%esp)
117: 00
118: c7 04 24 01 00 00 00 movl $0x1,(%esp)
11f: e8 14 04 00 00 call 538 <printf>
printf(1, "clone test OK\n");
124: c7 44 24 04 cb 09 00 movl $0x9cb,0x4(%esp)
12b: 00
12c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
133: e8 00 04 00 00 call 538 <printf>
exit();
138: e8 6b 02 00 00 call 3a8 <exit>
13d: 66 90 xchg %ax,%ax
13f: 90 nop
00000140 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
140: 55 push %ebp
141: 89 e5 mov %esp,%ebp
143: 57 push %edi
144: 53 push %ebx
asm volatile("cld; rep stosb" :
145: 8b 4d 08 mov 0x8(%ebp),%ecx
148: 8b 55 10 mov 0x10(%ebp),%edx
14b: 8b 45 0c mov 0xc(%ebp),%eax
14e: 89 cb mov %ecx,%ebx
150: 89 df mov %ebx,%edi
152: 89 d1 mov %edx,%ecx
154: fc cld
155: f3 aa rep stos %al,%es:(%edi)
157: 89 ca mov %ecx,%edx
159: 89 fb mov %edi,%ebx
15b: 89 5d 08 mov %ebx,0x8(%ebp)
15e: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
161: 5b pop %ebx
162: 5f pop %edi
163: 5d pop %ebp
164: c3 ret
00000165 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
165: 55 push %ebp
166: 89 e5 mov %esp,%ebp
168: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
16b: 8b 45 08 mov 0x8(%ebp),%eax
16e: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
171: 90 nop
172: 8b 45 08 mov 0x8(%ebp),%eax
175: 8d 50 01 lea 0x1(%eax),%edx
178: 89 55 08 mov %edx,0x8(%ebp)
17b: 8b 55 0c mov 0xc(%ebp),%edx
17e: 8d 4a 01 lea 0x1(%edx),%ecx
181: 89 4d 0c mov %ecx,0xc(%ebp)
184: 0f b6 12 movzbl (%edx),%edx
187: 88 10 mov %dl,(%eax)
189: 0f b6 00 movzbl (%eax),%eax
18c: 84 c0 test %al,%al
18e: 75 e2 jne 172 <strcpy+0xd>
;
return os;
190: 8b 45 fc mov -0x4(%ebp),%eax
}
193: c9 leave
194: c3 ret
00000195 <strcmp>:
int
strcmp(const char *p, const char *q)
{
195: 55 push %ebp
196: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
198: eb 08 jmp 1a2 <strcmp+0xd>
p++, q++;
19a: 83 45 08 01 addl $0x1,0x8(%ebp)
19e: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1a2: 8b 45 08 mov 0x8(%ebp),%eax
1a5: 0f b6 00 movzbl (%eax),%eax
1a8: 84 c0 test %al,%al
1aa: 74 10 je 1bc <strcmp+0x27>
1ac: 8b 45 08 mov 0x8(%ebp),%eax
1af: 0f b6 10 movzbl (%eax),%edx
1b2: 8b 45 0c mov 0xc(%ebp),%eax
1b5: 0f b6 00 movzbl (%eax),%eax
1b8: 38 c2 cmp %al,%dl
1ba: 74 de je 19a <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
1bc: 8b 45 08 mov 0x8(%ebp),%eax
1bf: 0f b6 00 movzbl (%eax),%eax
1c2: 0f b6 d0 movzbl %al,%edx
1c5: 8b 45 0c mov 0xc(%ebp),%eax
1c8: 0f b6 00 movzbl (%eax),%eax
1cb: 0f b6 c0 movzbl %al,%eax
1ce: 29 c2 sub %eax,%edx
1d0: 89 d0 mov %edx,%eax
}
1d2: 5d pop %ebp
1d3: c3 ret
000001d4 <strlen>:
uint
strlen(char *s)
{
1d4: 55 push %ebp
1d5: 89 e5 mov %esp,%ebp
1d7: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
1da: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1e1: eb 04 jmp 1e7 <strlen+0x13>
1e3: 83 45 fc 01 addl $0x1,-0x4(%ebp)
1e7: 8b 55 fc mov -0x4(%ebp),%edx
1ea: 8b 45 08 mov 0x8(%ebp),%eax
1ed: 01 d0 add %edx,%eax
1ef: 0f b6 00 movzbl (%eax),%eax
1f2: 84 c0 test %al,%al
1f4: 75 ed jne 1e3 <strlen+0xf>
;
return n;
1f6: 8b 45 fc mov -0x4(%ebp),%eax
}
1f9: c9 leave
1fa: c3 ret
000001fb <memset>:
void*
memset(void *dst, int c, uint n)
{
1fb: 55 push %ebp
1fc: 89 e5 mov %esp,%ebp
1fe: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
201: 8b 45 10 mov 0x10(%ebp),%eax
204: 89 44 24 08 mov %eax,0x8(%esp)
208: 8b 45 0c mov 0xc(%ebp),%eax
20b: 89 44 24 04 mov %eax,0x4(%esp)
20f: 8b 45 08 mov 0x8(%ebp),%eax
212: 89 04 24 mov %eax,(%esp)
215: e8 26 ff ff ff call 140 <stosb>
return dst;
21a: 8b 45 08 mov 0x8(%ebp),%eax
}
21d: c9 leave
21e: c3 ret
0000021f <strchr>:
char*
strchr(const char *s, char c)
{
21f: 55 push %ebp
220: 89 e5 mov %esp,%ebp
222: 83 ec 04 sub $0x4,%esp
225: 8b 45 0c mov 0xc(%ebp),%eax
228: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
22b: eb 14 jmp 241 <strchr+0x22>
if(*s == c)
22d: 8b 45 08 mov 0x8(%ebp),%eax
230: 0f b6 00 movzbl (%eax),%eax
233: 3a 45 fc cmp -0x4(%ebp),%al
236: 75 05 jne 23d <strchr+0x1e>
return (char*)s;
238: 8b 45 08 mov 0x8(%ebp),%eax
23b: eb 13 jmp 250 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
23d: 83 45 08 01 addl $0x1,0x8(%ebp)
241: 8b 45 08 mov 0x8(%ebp),%eax
244: 0f b6 00 movzbl (%eax),%eax
247: 84 c0 test %al,%al
249: 75 e2 jne 22d <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
24b: b8 00 00 00 00 mov $0x0,%eax
}
250: c9 leave
251: c3 ret
00000252 <gets>:
char*
gets(char *buf, int max)
{
252: 55 push %ebp
253: 89 e5 mov %esp,%ebp
255: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
258: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
25f: eb 4c jmp 2ad <gets+0x5b>
cc = read(0, &c, 1);
261: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
268: 00
269: 8d 45 ef lea -0x11(%ebp),%eax
26c: 89 44 24 04 mov %eax,0x4(%esp)
270: c7 04 24 00 00 00 00 movl $0x0,(%esp)
277: e8 44 01 00 00 call 3c0 <read>
27c: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
27f: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
283: 7f 02 jg 287 <gets+0x35>
break;
285: eb 31 jmp 2b8 <gets+0x66>
buf[i++] = c;
287: 8b 45 f4 mov -0xc(%ebp),%eax
28a: 8d 50 01 lea 0x1(%eax),%edx
28d: 89 55 f4 mov %edx,-0xc(%ebp)
290: 89 c2 mov %eax,%edx
292: 8b 45 08 mov 0x8(%ebp),%eax
295: 01 c2 add %eax,%edx
297: 0f b6 45 ef movzbl -0x11(%ebp),%eax
29b: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
29d: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2a1: 3c 0a cmp $0xa,%al
2a3: 74 13 je 2b8 <gets+0x66>
2a5: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2a9: 3c 0d cmp $0xd,%al
2ab: 74 0b je 2b8 <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
2ad: 8b 45 f4 mov -0xc(%ebp),%eax
2b0: 83 c0 01 add $0x1,%eax
2b3: 3b 45 0c cmp 0xc(%ebp),%eax
2b6: 7c a9 jl 261 <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
2b8: 8b 55 f4 mov -0xc(%ebp),%edx
2bb: 8b 45 08 mov 0x8(%ebp),%eax
2be: 01 d0 add %edx,%eax
2c0: c6 00 00 movb $0x0,(%eax)
return buf;
2c3: 8b 45 08 mov 0x8(%ebp),%eax
}
2c6: c9 leave
2c7: c3 ret
000002c8 <stat>:
int
stat(char *n, struct stat *st)
{
2c8: 55 push %ebp
2c9: 89 e5 mov %esp,%ebp
2cb: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
2ce: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2d5: 00
2d6: 8b 45 08 mov 0x8(%ebp),%eax
2d9: 89 04 24 mov %eax,(%esp)
2dc: e8 07 01 00 00 call 3e8 <open>
2e1: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
2e4: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2e8: 79 07 jns 2f1 <stat+0x29>
return -1;
2ea: b8 ff ff ff ff mov $0xffffffff,%eax
2ef: eb 23 jmp 314 <stat+0x4c>
r = fstat(fd, st);
2f1: 8b 45 0c mov 0xc(%ebp),%eax
2f4: 89 44 24 04 mov %eax,0x4(%esp)
2f8: 8b 45 f4 mov -0xc(%ebp),%eax
2fb: 89 04 24 mov %eax,(%esp)
2fe: e8 fd 00 00 00 call 400 <fstat>
303: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
306: 8b 45 f4 mov -0xc(%ebp),%eax
309: 89 04 24 mov %eax,(%esp)
30c: e8 bf 00 00 00 call 3d0 <close>
return r;
311: 8b 45 f0 mov -0x10(%ebp),%eax
}
314: c9 leave
315: c3 ret
00000316 <atoi>:
int
atoi(const char *s)
{
316: 55 push %ebp
317: 89 e5 mov %esp,%ebp
319: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
31c: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
323: eb 25 jmp 34a <atoi+0x34>
n = n*10 + *s++ - '0';
325: 8b 55 fc mov -0x4(%ebp),%edx
328: 89 d0 mov %edx,%eax
32a: c1 e0 02 shl $0x2,%eax
32d: 01 d0 add %edx,%eax
32f: 01 c0 add %eax,%eax
331: 89 c1 mov %eax,%ecx
333: 8b 45 08 mov 0x8(%ebp),%eax
336: 8d 50 01 lea 0x1(%eax),%edx
339: 89 55 08 mov %edx,0x8(%ebp)
33c: 0f b6 00 movzbl (%eax),%eax
33f: 0f be c0 movsbl %al,%eax
342: 01 c8 add %ecx,%eax
344: 83 e8 30 sub $0x30,%eax
347: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
34a: 8b 45 08 mov 0x8(%ebp),%eax
34d: 0f b6 00 movzbl (%eax),%eax
350: 3c 2f cmp $0x2f,%al
352: 7e 0a jle 35e <atoi+0x48>
354: 8b 45 08 mov 0x8(%ebp),%eax
357: 0f b6 00 movzbl (%eax),%eax
35a: 3c 39 cmp $0x39,%al
35c: 7e c7 jle 325 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
35e: 8b 45 fc mov -0x4(%ebp),%eax
}
361: c9 leave
362: c3 ret
00000363 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
363: 55 push %ebp
364: 89 e5 mov %esp,%ebp
366: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
369: 8b 45 08 mov 0x8(%ebp),%eax
36c: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
36f: 8b 45 0c mov 0xc(%ebp),%eax
372: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
375: eb 17 jmp 38e <memmove+0x2b>
*dst++ = *src++;
377: 8b 45 fc mov -0x4(%ebp),%eax
37a: 8d 50 01 lea 0x1(%eax),%edx
37d: 89 55 fc mov %edx,-0x4(%ebp)
380: 8b 55 f8 mov -0x8(%ebp),%edx
383: 8d 4a 01 lea 0x1(%edx),%ecx
386: 89 4d f8 mov %ecx,-0x8(%ebp)
389: 0f b6 12 movzbl (%edx),%edx
38c: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
38e: 8b 45 10 mov 0x10(%ebp),%eax
391: 8d 50 ff lea -0x1(%eax),%edx
394: 89 55 10 mov %edx,0x10(%ebp)
397: 85 c0 test %eax,%eax
399: 7f dc jg 377 <memmove+0x14>
*dst++ = *src++;
return vdst;
39b: 8b 45 08 mov 0x8(%ebp),%eax
}
39e: c9 leave
39f: c3 ret
000003a0 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
3a0: b8 01 00 00 00 mov $0x1,%eax
3a5: cd 40 int $0x40
3a7: c3 ret
000003a8 <exit>:
SYSCALL(exit)
3a8: b8 02 00 00 00 mov $0x2,%eax
3ad: cd 40 int $0x40
3af: c3 ret
000003b0 <wait>:
SYSCALL(wait)
3b0: b8 03 00 00 00 mov $0x3,%eax
3b5: cd 40 int $0x40
3b7: c3 ret
000003b8 <pipe>:
SYSCALL(pipe)
3b8: b8 04 00 00 00 mov $0x4,%eax
3bd: cd 40 int $0x40
3bf: c3 ret
000003c0 <read>:
SYSCALL(read)
3c0: b8 05 00 00 00 mov $0x5,%eax
3c5: cd 40 int $0x40
3c7: c3 ret
000003c8 <write>:
SYSCALL(write)
3c8: b8 10 00 00 00 mov $0x10,%eax
3cd: cd 40 int $0x40
3cf: c3 ret
000003d0 <close>:
SYSCALL(close)
3d0: b8 15 00 00 00 mov $0x15,%eax
3d5: cd 40 int $0x40
3d7: c3 ret
000003d8 <kill>:
SYSCALL(kill)
3d8: b8 06 00 00 00 mov $0x6,%eax
3dd: cd 40 int $0x40
3df: c3 ret
000003e0 <exec>:
SYSCALL(exec)
3e0: b8 07 00 00 00 mov $0x7,%eax
3e5: cd 40 int $0x40
3e7: c3 ret
000003e8 <open>:
SYSCALL(open)
3e8: b8 0f 00 00 00 mov $0xf,%eax
3ed: cd 40 int $0x40
3ef: c3 ret
000003f0 <mknod>:
SYSCALL(mknod)
3f0: b8 11 00 00 00 mov $0x11,%eax
3f5: cd 40 int $0x40
3f7: c3 ret
000003f8 <unlink>:
SYSCALL(unlink)
3f8: b8 12 00 00 00 mov $0x12,%eax
3fd: cd 40 int $0x40
3ff: c3 ret
00000400 <fstat>:
SYSCALL(fstat)
400: b8 08 00 00 00 mov $0x8,%eax
405: cd 40 int $0x40
407: c3 ret
00000408 <link>:
SYSCALL(link)
408: b8 13 00 00 00 mov $0x13,%eax
40d: cd 40 int $0x40
40f: c3 ret
00000410 <mkdir>:
SYSCALL(mkdir)
410: b8 14 00 00 00 mov $0x14,%eax
415: cd 40 int $0x40
417: c3 ret
00000418 <chdir>:
SYSCALL(chdir)
418: b8 09 00 00 00 mov $0x9,%eax
41d: cd 40 int $0x40
41f: c3 ret
00000420 <dup>:
SYSCALL(dup)
420: b8 0a 00 00 00 mov $0xa,%eax
425: cd 40 int $0x40
427: c3 ret
00000428 <getpid>:
SYSCALL(getpid)
428: b8 0b 00 00 00 mov $0xb,%eax
42d: cd 40 int $0x40
42f: c3 ret
00000430 <sbrk>:
SYSCALL(sbrk)
430: b8 0c 00 00 00 mov $0xc,%eax
435: cd 40 int $0x40
437: c3 ret
00000438 <sleep>:
SYSCALL(sleep)
438: b8 0d 00 00 00 mov $0xd,%eax
43d: cd 40 int $0x40
43f: c3 ret
00000440 <uptime>:
SYSCALL(uptime)
440: b8 0e 00 00 00 mov $0xe,%eax
445: cd 40 int $0x40
447: c3 ret
00000448 <clone>:
SYSCALL(clone)
448: b8 16 00 00 00 mov $0x16,%eax
44d: cd 40 int $0x40
44f: c3 ret
00000450 <join>:
450: b8 17 00 00 00 mov $0x17,%eax
455: cd 40 int $0x40
457: c3 ret
00000458 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
458: 55 push %ebp
459: 89 e5 mov %esp,%ebp
45b: 83 ec 18 sub $0x18,%esp
45e: 8b 45 0c mov 0xc(%ebp),%eax
461: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
464: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
46b: 00
46c: 8d 45 f4 lea -0xc(%ebp),%eax
46f: 89 44 24 04 mov %eax,0x4(%esp)
473: 8b 45 08 mov 0x8(%ebp),%eax
476: 89 04 24 mov %eax,(%esp)
479: e8 4a ff ff ff call 3c8 <write>
}
47e: c9 leave
47f: c3 ret
00000480 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
480: 55 push %ebp
481: 89 e5 mov %esp,%ebp
483: 56 push %esi
484: 53 push %ebx
485: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
488: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
48f: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
493: 74 17 je 4ac <printint+0x2c>
495: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
499: 79 11 jns 4ac <printint+0x2c>
neg = 1;
49b: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
4a2: 8b 45 0c mov 0xc(%ebp),%eax
4a5: f7 d8 neg %eax
4a7: 89 45 ec mov %eax,-0x14(%ebp)
4aa: eb 06 jmp 4b2 <printint+0x32>
} else {
x = xx;
4ac: 8b 45 0c mov 0xc(%ebp),%eax
4af: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
4b2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
4b9: 8b 4d f4 mov -0xc(%ebp),%ecx
4bc: 8d 41 01 lea 0x1(%ecx),%eax
4bf: 89 45 f4 mov %eax,-0xc(%ebp)
4c2: 8b 5d 10 mov 0x10(%ebp),%ebx
4c5: 8b 45 ec mov -0x14(%ebp),%eax
4c8: ba 00 00 00 00 mov $0x0,%edx
4cd: f7 f3 div %ebx
4cf: 89 d0 mov %edx,%eax
4d1: 0f b6 80 04 0d 00 00 movzbl 0xd04(%eax),%eax
4d8: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
4dc: 8b 75 10 mov 0x10(%ebp),%esi
4df: 8b 45 ec mov -0x14(%ebp),%eax
4e2: ba 00 00 00 00 mov $0x0,%edx
4e7: f7 f6 div %esi
4e9: 89 45 ec mov %eax,-0x14(%ebp)
4ec: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
4f0: 75 c7 jne 4b9 <printint+0x39>
if(neg)
4f2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
4f6: 74 10 je 508 <printint+0x88>
buf[i++] = '-';
4f8: 8b 45 f4 mov -0xc(%ebp),%eax
4fb: 8d 50 01 lea 0x1(%eax),%edx
4fe: 89 55 f4 mov %edx,-0xc(%ebp)
501: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
506: eb 1f jmp 527 <printint+0xa7>
508: eb 1d jmp 527 <printint+0xa7>
putc(fd, buf[i]);
50a: 8d 55 dc lea -0x24(%ebp),%edx
50d: 8b 45 f4 mov -0xc(%ebp),%eax
510: 01 d0 add %edx,%eax
512: 0f b6 00 movzbl (%eax),%eax
515: 0f be c0 movsbl %al,%eax
518: 89 44 24 04 mov %eax,0x4(%esp)
51c: 8b 45 08 mov 0x8(%ebp),%eax
51f: 89 04 24 mov %eax,(%esp)
522: e8 31 ff ff ff call 458 <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
527: 83 6d f4 01 subl $0x1,-0xc(%ebp)
52b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
52f: 79 d9 jns 50a <printint+0x8a>
putc(fd, buf[i]);
}
531: 83 c4 30 add $0x30,%esp
534: 5b pop %ebx
535: 5e pop %esi
536: 5d pop %ebp
537: c3 ret
00000538 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
538: 55 push %ebp
539: 89 e5 mov %esp,%ebp
53b: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
53e: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
545: 8d 45 0c lea 0xc(%ebp),%eax
548: 83 c0 04 add $0x4,%eax
54b: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
54e: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
555: e9 7c 01 00 00 jmp 6d6 <printf+0x19e>
c = fmt[i] & 0xff;
55a: 8b 55 0c mov 0xc(%ebp),%edx
55d: 8b 45 f0 mov -0x10(%ebp),%eax
560: 01 d0 add %edx,%eax
562: 0f b6 00 movzbl (%eax),%eax
565: 0f be c0 movsbl %al,%eax
568: 25 ff 00 00 00 and $0xff,%eax
56d: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
570: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
574: 75 2c jne 5a2 <printf+0x6a>
if(c == '%'){
576: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
57a: 75 0c jne 588 <printf+0x50>
state = '%';
57c: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
583: e9 4a 01 00 00 jmp 6d2 <printf+0x19a>
} else {
putc(fd, c);
588: 8b 45 e4 mov -0x1c(%ebp),%eax
58b: 0f be c0 movsbl %al,%eax
58e: 89 44 24 04 mov %eax,0x4(%esp)
592: 8b 45 08 mov 0x8(%ebp),%eax
595: 89 04 24 mov %eax,(%esp)
598: e8 bb fe ff ff call 458 <putc>
59d: e9 30 01 00 00 jmp 6d2 <printf+0x19a>
}
} else if(state == '%'){
5a2: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
5a6: 0f 85 26 01 00 00 jne 6d2 <printf+0x19a>
if(c == 'd'){
5ac: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
5b0: 75 2d jne 5df <printf+0xa7>
printint(fd, *ap, 10, 1);
5b2: 8b 45 e8 mov -0x18(%ebp),%eax
5b5: 8b 00 mov (%eax),%eax
5b7: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
5be: 00
5bf: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
5c6: 00
5c7: 89 44 24 04 mov %eax,0x4(%esp)
5cb: 8b 45 08 mov 0x8(%ebp),%eax
5ce: 89 04 24 mov %eax,(%esp)
5d1: e8 aa fe ff ff call 480 <printint>
ap++;
5d6: 83 45 e8 04 addl $0x4,-0x18(%ebp)
5da: e9 ec 00 00 00 jmp 6cb <printf+0x193>
} else if(c == 'x' || c == 'p'){
5df: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
5e3: 74 06 je 5eb <printf+0xb3>
5e5: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
5e9: 75 2d jne 618 <printf+0xe0>
printint(fd, *ap, 16, 0);
5eb: 8b 45 e8 mov -0x18(%ebp),%eax
5ee: 8b 00 mov (%eax),%eax
5f0: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
5f7: 00
5f8: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
5ff: 00
600: 89 44 24 04 mov %eax,0x4(%esp)
604: 8b 45 08 mov 0x8(%ebp),%eax
607: 89 04 24 mov %eax,(%esp)
60a: e8 71 fe ff ff call 480 <printint>
ap++;
60f: 83 45 e8 04 addl $0x4,-0x18(%ebp)
613: e9 b3 00 00 00 jmp 6cb <printf+0x193>
} else if(c == 's'){
618: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
61c: 75 45 jne 663 <printf+0x12b>
s = (char*)*ap;
61e: 8b 45 e8 mov -0x18(%ebp),%eax
621: 8b 00 mov (%eax),%eax
623: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
626: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
62a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
62e: 75 09 jne 639 <printf+0x101>
s = "(null)";
630: c7 45 f4 da 09 00 00 movl $0x9da,-0xc(%ebp)
while(*s != 0){
637: eb 1e jmp 657 <printf+0x11f>
639: eb 1c jmp 657 <printf+0x11f>
putc(fd, *s);
63b: 8b 45 f4 mov -0xc(%ebp),%eax
63e: 0f b6 00 movzbl (%eax),%eax
641: 0f be c0 movsbl %al,%eax
644: 89 44 24 04 mov %eax,0x4(%esp)
648: 8b 45 08 mov 0x8(%ebp),%eax
64b: 89 04 24 mov %eax,(%esp)
64e: e8 05 fe ff ff call 458 <putc>
s++;
653: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
657: 8b 45 f4 mov -0xc(%ebp),%eax
65a: 0f b6 00 movzbl (%eax),%eax
65d: 84 c0 test %al,%al
65f: 75 da jne 63b <printf+0x103>
661: eb 68 jmp 6cb <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
663: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
667: 75 1d jne 686 <printf+0x14e>
putc(fd, *ap);
669: 8b 45 e8 mov -0x18(%ebp),%eax
66c: 8b 00 mov (%eax),%eax
66e: 0f be c0 movsbl %al,%eax
671: 89 44 24 04 mov %eax,0x4(%esp)
675: 8b 45 08 mov 0x8(%ebp),%eax
678: 89 04 24 mov %eax,(%esp)
67b: e8 d8 fd ff ff call 458 <putc>
ap++;
680: 83 45 e8 04 addl $0x4,-0x18(%ebp)
684: eb 45 jmp 6cb <printf+0x193>
} else if(c == '%'){
686: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
68a: 75 17 jne 6a3 <printf+0x16b>
putc(fd, c);
68c: 8b 45 e4 mov -0x1c(%ebp),%eax
68f: 0f be c0 movsbl %al,%eax
692: 89 44 24 04 mov %eax,0x4(%esp)
696: 8b 45 08 mov 0x8(%ebp),%eax
699: 89 04 24 mov %eax,(%esp)
69c: e8 b7 fd ff ff call 458 <putc>
6a1: eb 28 jmp 6cb <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
6a3: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
6aa: 00
6ab: 8b 45 08 mov 0x8(%ebp),%eax
6ae: 89 04 24 mov %eax,(%esp)
6b1: e8 a2 fd ff ff call 458 <putc>
putc(fd, c);
6b6: 8b 45 e4 mov -0x1c(%ebp),%eax
6b9: 0f be c0 movsbl %al,%eax
6bc: 89 44 24 04 mov %eax,0x4(%esp)
6c0: 8b 45 08 mov 0x8(%ebp),%eax
6c3: 89 04 24 mov %eax,(%esp)
6c6: e8 8d fd ff ff call 458 <putc>
}
state = 0;
6cb: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6d2: 83 45 f0 01 addl $0x1,-0x10(%ebp)
6d6: 8b 55 0c mov 0xc(%ebp),%edx
6d9: 8b 45 f0 mov -0x10(%ebp),%eax
6dc: 01 d0 add %edx,%eax
6de: 0f b6 00 movzbl (%eax),%eax
6e1: 84 c0 test %al,%al
6e3: 0f 85 71 fe ff ff jne 55a <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
6e9: c9 leave
6ea: c3 ret
6eb: 90 nop
000006ec <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
6ec: 55 push %ebp
6ed: 89 e5 mov %esp,%ebp
6ef: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
6f2: 8b 45 08 mov 0x8(%ebp),%eax
6f5: 83 e8 08 sub $0x8,%eax
6f8: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6fb: a1 24 0d 00 00 mov 0xd24,%eax
700: 89 45 fc mov %eax,-0x4(%ebp)
703: eb 24 jmp 729 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
705: 8b 45 fc mov -0x4(%ebp),%eax
708: 8b 00 mov (%eax),%eax
70a: 3b 45 fc cmp -0x4(%ebp),%eax
70d: 77 12 ja 721 <free+0x35>
70f: 8b 45 f8 mov -0x8(%ebp),%eax
712: 3b 45 fc cmp -0x4(%ebp),%eax
715: 77 24 ja 73b <free+0x4f>
717: 8b 45 fc mov -0x4(%ebp),%eax
71a: 8b 00 mov (%eax),%eax
71c: 3b 45 f8 cmp -0x8(%ebp),%eax
71f: 77 1a ja 73b <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
721: 8b 45 fc mov -0x4(%ebp),%eax
724: 8b 00 mov (%eax),%eax
726: 89 45 fc mov %eax,-0x4(%ebp)
729: 8b 45 f8 mov -0x8(%ebp),%eax
72c: 3b 45 fc cmp -0x4(%ebp),%eax
72f: 76 d4 jbe 705 <free+0x19>
731: 8b 45 fc mov -0x4(%ebp),%eax
734: 8b 00 mov (%eax),%eax
736: 3b 45 f8 cmp -0x8(%ebp),%eax
739: 76 ca jbe 705 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
73b: 8b 45 f8 mov -0x8(%ebp),%eax
73e: 8b 40 04 mov 0x4(%eax),%eax
741: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
748: 8b 45 f8 mov -0x8(%ebp),%eax
74b: 01 c2 add %eax,%edx
74d: 8b 45 fc mov -0x4(%ebp),%eax
750: 8b 00 mov (%eax),%eax
752: 39 c2 cmp %eax,%edx
754: 75 24 jne 77a <free+0x8e>
bp->s.size += p->s.ptr->s.size;
756: 8b 45 f8 mov -0x8(%ebp),%eax
759: 8b 50 04 mov 0x4(%eax),%edx
75c: 8b 45 fc mov -0x4(%ebp),%eax
75f: 8b 00 mov (%eax),%eax
761: 8b 40 04 mov 0x4(%eax),%eax
764: 01 c2 add %eax,%edx
766: 8b 45 f8 mov -0x8(%ebp),%eax
769: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
76c: 8b 45 fc mov -0x4(%ebp),%eax
76f: 8b 00 mov (%eax),%eax
771: 8b 10 mov (%eax),%edx
773: 8b 45 f8 mov -0x8(%ebp),%eax
776: 89 10 mov %edx,(%eax)
778: eb 0a jmp 784 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
77a: 8b 45 fc mov -0x4(%ebp),%eax
77d: 8b 10 mov (%eax),%edx
77f: 8b 45 f8 mov -0x8(%ebp),%eax
782: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
784: 8b 45 fc mov -0x4(%ebp),%eax
787: 8b 40 04 mov 0x4(%eax),%eax
78a: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
791: 8b 45 fc mov -0x4(%ebp),%eax
794: 01 d0 add %edx,%eax
796: 3b 45 f8 cmp -0x8(%ebp),%eax
799: 75 20 jne 7bb <free+0xcf>
p->s.size += bp->s.size;
79b: 8b 45 fc mov -0x4(%ebp),%eax
79e: 8b 50 04 mov 0x4(%eax),%edx
7a1: 8b 45 f8 mov -0x8(%ebp),%eax
7a4: 8b 40 04 mov 0x4(%eax),%eax
7a7: 01 c2 add %eax,%edx
7a9: 8b 45 fc mov -0x4(%ebp),%eax
7ac: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
7af: 8b 45 f8 mov -0x8(%ebp),%eax
7b2: 8b 10 mov (%eax),%edx
7b4: 8b 45 fc mov -0x4(%ebp),%eax
7b7: 89 10 mov %edx,(%eax)
7b9: eb 08 jmp 7c3 <free+0xd7>
} else
p->s.ptr = bp;
7bb: 8b 45 fc mov -0x4(%ebp),%eax
7be: 8b 55 f8 mov -0x8(%ebp),%edx
7c1: 89 10 mov %edx,(%eax)
freep = p;
7c3: 8b 45 fc mov -0x4(%ebp),%eax
7c6: a3 24 0d 00 00 mov %eax,0xd24
}
7cb: c9 leave
7cc: c3 ret
000007cd <morecore>:
static Header*
morecore(uint nu)
{
7cd: 55 push %ebp
7ce: 89 e5 mov %esp,%ebp
7d0: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
7d3: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
7da: 77 07 ja 7e3 <morecore+0x16>
nu = 4096;
7dc: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
7e3: 8b 45 08 mov 0x8(%ebp),%eax
7e6: c1 e0 03 shl $0x3,%eax
7e9: 89 04 24 mov %eax,(%esp)
7ec: e8 3f fc ff ff call 430 <sbrk>
7f1: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
7f4: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
7f8: 75 07 jne 801 <morecore+0x34>
return 0;
7fa: b8 00 00 00 00 mov $0x0,%eax
7ff: eb 22 jmp 823 <morecore+0x56>
hp = (Header*)p;
801: 8b 45 f4 mov -0xc(%ebp),%eax
804: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
807: 8b 45 f0 mov -0x10(%ebp),%eax
80a: 8b 55 08 mov 0x8(%ebp),%edx
80d: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
810: 8b 45 f0 mov -0x10(%ebp),%eax
813: 83 c0 08 add $0x8,%eax
816: 89 04 24 mov %eax,(%esp)
819: e8 ce fe ff ff call 6ec <free>
return freep;
81e: a1 24 0d 00 00 mov 0xd24,%eax
}
823: c9 leave
824: c3 ret
00000825 <malloc>:
void*
malloc(uint nbytes)
{
825: 55 push %ebp
826: 89 e5 mov %esp,%ebp
828: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
82b: 8b 45 08 mov 0x8(%ebp),%eax
82e: 83 c0 07 add $0x7,%eax
831: c1 e8 03 shr $0x3,%eax
834: 83 c0 01 add $0x1,%eax
837: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
83a: a1 24 0d 00 00 mov 0xd24,%eax
83f: 89 45 f0 mov %eax,-0x10(%ebp)
842: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
846: 75 23 jne 86b <malloc+0x46>
base.s.ptr = freep = prevp = &base;
848: c7 45 f0 1c 0d 00 00 movl $0xd1c,-0x10(%ebp)
84f: 8b 45 f0 mov -0x10(%ebp),%eax
852: a3 24 0d 00 00 mov %eax,0xd24
857: a1 24 0d 00 00 mov 0xd24,%eax
85c: a3 1c 0d 00 00 mov %eax,0xd1c
base.s.size = 0;
861: c7 05 20 0d 00 00 00 movl $0x0,0xd20
868: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
86b: 8b 45 f0 mov -0x10(%ebp),%eax
86e: 8b 00 mov (%eax),%eax
870: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
873: 8b 45 f4 mov -0xc(%ebp),%eax
876: 8b 40 04 mov 0x4(%eax),%eax
879: 3b 45 ec cmp -0x14(%ebp),%eax
87c: 72 4d jb 8cb <malloc+0xa6>
if(p->s.size == nunits)
87e: 8b 45 f4 mov -0xc(%ebp),%eax
881: 8b 40 04 mov 0x4(%eax),%eax
884: 3b 45 ec cmp -0x14(%ebp),%eax
887: 75 0c jne 895 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
889: 8b 45 f4 mov -0xc(%ebp),%eax
88c: 8b 10 mov (%eax),%edx
88e: 8b 45 f0 mov -0x10(%ebp),%eax
891: 89 10 mov %edx,(%eax)
893: eb 26 jmp 8bb <malloc+0x96>
else {
p->s.size -= nunits;
895: 8b 45 f4 mov -0xc(%ebp),%eax
898: 8b 40 04 mov 0x4(%eax),%eax
89b: 2b 45 ec sub -0x14(%ebp),%eax
89e: 89 c2 mov %eax,%edx
8a0: 8b 45 f4 mov -0xc(%ebp),%eax
8a3: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
8a6: 8b 45 f4 mov -0xc(%ebp),%eax
8a9: 8b 40 04 mov 0x4(%eax),%eax
8ac: c1 e0 03 shl $0x3,%eax
8af: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
8b2: 8b 45 f4 mov -0xc(%ebp),%eax
8b5: 8b 55 ec mov -0x14(%ebp),%edx
8b8: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
8bb: 8b 45 f0 mov -0x10(%ebp),%eax
8be: a3 24 0d 00 00 mov %eax,0xd24
return (void*)(p + 1);
8c3: 8b 45 f4 mov -0xc(%ebp),%eax
8c6: 83 c0 08 add $0x8,%eax
8c9: eb 38 jmp 903 <malloc+0xde>
}
if(p == freep)
8cb: a1 24 0d 00 00 mov 0xd24,%eax
8d0: 39 45 f4 cmp %eax,-0xc(%ebp)
8d3: 75 1b jne 8f0 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
8d5: 8b 45 ec mov -0x14(%ebp),%eax
8d8: 89 04 24 mov %eax,(%esp)
8db: e8 ed fe ff ff call 7cd <morecore>
8e0: 89 45 f4 mov %eax,-0xc(%ebp)
8e3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
8e7: 75 07 jne 8f0 <malloc+0xcb>
return 0;
8e9: b8 00 00 00 00 mov $0x0,%eax
8ee: eb 13 jmp 903 <malloc+0xde>
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){
8f0: 8b 45 f4 mov -0xc(%ebp),%eax
8f3: 89 45 f0 mov %eax,-0x10(%ebp)
8f6: 8b 45 f4 mov -0xc(%ebp),%eax
8f9: 8b 00 mov (%eax),%eax
8fb: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
8fe: e9 70 ff ff ff jmp 873 <malloc+0x4e>
}
903: c9 leave
904: c3 ret
905: 66 90 xchg %ax,%ax
907: 90 nop
00000908 <xchg>:
asm volatile("sti");
}
static inline uint
xchg(volatile uint *addr, uint newval)
{
908: 55 push %ebp
909: 89 e5 mov %esp,%ebp
90b: 83 ec 10 sub $0x10,%esp
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
90e: 8b 55 08 mov 0x8(%ebp),%edx
911: 8b 45 0c mov 0xc(%ebp),%eax
914: 8b 4d 08 mov 0x8(%ebp),%ecx
917: f0 87 02 lock xchg %eax,(%edx)
91a: 89 45 fc mov %eax,-0x4(%ebp)
"+m" (*addr), "=a" (result) :
"1" (newval) :
"cc");
return result;
91d: 8b 45 fc mov -0x4(%ebp),%eax
}
920: c9 leave
921: c3 ret
00000922 <mutex_init>:
#include "types.h"
#include "user.h"
#include "x86.h"
#include "threadlib.h"
void mutex_init(mutex_t *m) {
922: 55 push %ebp
923: 89 e5 mov %esp,%ebp
// 0 indicates that lock is available, 1 that it is held by a thread
m->flag = 0;
925: 8b 45 08 mov 0x8(%ebp),%eax
928: c7 00 00 00 00 00 movl $0x0,(%eax)
}
92e: 5d pop %ebp
92f: c3 ret
00000930 <mutex_lock>:
void mutex_lock(mutex_t *m)
{
930: 55 push %ebp
931: 89 e5 mov %esp,%ebp
933: 83 ec 08 sub $0x8,%esp
while (xchg(&m->flag, 1) == 1); // spin-wait (do nothing)
936: 90 nop
937: 8b 45 08 mov 0x8(%ebp),%eax
93a: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
941: 00
942: 89 04 24 mov %eax,(%esp)
945: e8 be ff ff ff call 908 <xchg>
94a: 83 f8 01 cmp $0x1,%eax
94d: 74 e8 je 937 <mutex_lock+0x7>
}
94f: c9 leave
950: c3 ret
00000951 <mutex_unlock>:
void mutex_unlock(mutex_t *m)
{
951: 55 push %ebp
952: 89 e5 mov %esp,%ebp
m->flag = 0;
954: 8b 45 08 mov 0x8(%ebp),%eax
957: c7 00 00 00 00 00 movl $0x0,(%eax)
}
95d: 5d pop %ebp
95e: c3 ret
0000095f <thread_create>:
if(!pid) (*start_routine)(arg);
else return pid;
}*/
int thread_create(void(*child)(void*), void *arg_ptr)
{
95f: 55 push %ebp
960: 89 e5 mov %esp,%ebp
962: 83 ec 28 sub $0x28,%esp
void *stack = malloc(4096);
965: c7 04 24 00 10 00 00 movl $0x1000,(%esp)
96c: e8 b4 fe ff ff call 825 <malloc>
971: 89 45 f4 mov %eax,-0xc(%ebp)
int clone_pid = clone(child, arg_ptr, stack);
974: 8b 45 f4 mov -0xc(%ebp),%eax
977: 89 44 24 08 mov %eax,0x8(%esp)
97b: 8b 45 0c mov 0xc(%ebp),%eax
97e: 89 44 24 04 mov %eax,0x4(%esp)
982: 8b 45 08 mov 0x8(%ebp),%eax
985: 89 04 24 mov %eax,(%esp)
988: e8 bb fa ff ff call 448 <clone>
98d: 89 45 f0 mov %eax,-0x10(%ebp)
return clone_pid;
990: 8b 45 f0 mov -0x10(%ebp),%eax
}
993: c9 leave
994: c3 ret
00000995 <thread_join>:
int thread_join(void)
{
995: 55 push %ebp
996: 89 e5 mov %esp,%ebp
998: 83 ec 28 sub $0x28,%esp
void *join_s;
int join_pid = join(&join_s);
99b: 8d 45 f0 lea -0x10(%ebp),%eax
99e: 89 04 24 mov %eax,(%esp)
9a1: e8 aa fa ff ff call 450 <join>
9a6: 89 45 f4 mov %eax,-0xc(%ebp)
return join_pid;
9a9: 8b 45 f4 mov -0xc(%ebp),%eax
9ac: c9 leave
9ad: c3 ret
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/drive/drive_service_interface.h"
namespace drive {
DriveServiceInterface::AddNewDirectoryOptions::AddNewDirectoryOptions() {
}
DriveServiceInterface::AddNewDirectoryOptions::~AddNewDirectoryOptions() {
}
DriveServiceInterface::InitiateUploadNewFileOptions::
InitiateUploadNewFileOptions() {
}
DriveServiceInterface::InitiateUploadNewFileOptions::
~InitiateUploadNewFileOptions() {
}
DriveServiceInterface::InitiateUploadExistingFileOptions::
InitiateUploadExistingFileOptions() {
}
DriveServiceInterface::InitiateUploadExistingFileOptions::
~InitiateUploadExistingFileOptions() {
}
} // namespace drive
|
BITS 32
SECTION .data
hello_str: db "I'm uninfected...",0xa
SECTION .text
global _start
_start:
mov ecx, hello_str
mov edx, 18
mov ebx, 1
mov eax, 4
int 0x80
xor eax, eax
inc eax
xor ebx, ebx
int 0x80
|
#pragma once
#include "util/vector.hpp"
#include "util/rect.hpp"
#include <string>
#include <vector>
namespace ve
{
namespace render
{
class Image final
{
public:
// The formats supported.
enum Format { RGB24, RGBA32, GRAYSCALE32, DEPTH };
// Create a blank image. Pixels are uninitializaed.
Image(Vector2i size, Format format);
// Load a PNG or JPG from a file.
Image(std::string const & filename);
// Load from an SDL Surface.
//Image(void const * sdlSurface);
// Destructor.
~Image();
// Saves the image to a file.
void save(std::string const & filename) const;
// Gets the size of the image.
Vector2i getSize() const;
// Sets the size of the image. Uninitializes the pixels.
void setSize(Vector2i size);
// Gets the format of the image.
Format getFormat() const;
// Gets the raw pixel data.
std::vector<uint8_t> getPixels() const;
// Sets the raw pixel data.
void setPixels(std::vector<uint8_t> const & pixels);
// Internal to renderer. Activates the texture in the GL slot.
void activate(unsigned int slot) const;
// Internal to renderer. Deactivates all slots equal to or greater than the GL slot. Used to clear out excess textures not needed by a material.
static void deactivateRest(unsigned int slot);
// Internal to renderer. Attaches the texture to the currently bound GL frame buffer. Keep in mind on Windows the texture will be rendered upside-down.
void attachToFrameBuffer(unsigned int attachment);
private:
void initializeGLPixels(void const * pixels);
void loadFromSDLSurface(void const * sdlSurface);
Vector2i size;
Format format;
unsigned int glId;
unsigned int glFormat;
unsigned int glType;
unsigned int glInternalFormat;
unsigned int bytesPerPixel;
};
}
} |
; A010979: Binomial coefficient C(n,26).
; 1,27,378,3654,27405,169911,906192,4272048,18156204,70607460,254186856,854992152,2707475148,8122425444,23206929840,63432274896,166509721602,421171648758,1029530696964,2438362177020,5608233007146,12551759587422,27385657281648,58343356817424,121548660036300,247959266474052,495918532948104,973469712824056,1877405874732108,3560597348629860,6646448384109072,12220888964329584,22150361247847371,39602161018878633,69886166503903470,121801604478231762,209769429934732479,357174975294274221
add $0,26
bin $0,26
|
; A188299: Positions of 1 in A188297; complement of A188298.
; 3,6,9,10,13,16,17,20,23,26,27,30,33,34,37,40,43,44,47,50,51,54,57,58,61,64,67,68,71,74,75,78,81,84,85,88,91,92,95,98,99,102,105,108,109,112,115,116,119,122,125,126,129,132,133,136,139,142,143,146,149,150,153,156,157,160,163,166,167,170,173,174,177,180,183,184,187,190,191,194,197,198,201,204,207,208,211,214,215,218,221,224,225,228,231,232,235,238,241,242,245,248,249,252,255,256,259,262,265,266,269,272,273,276,279,282,283,286,289,290,293,296,297,300,303,306,307,310,313,314,317,320,323,324,327,330,331,334,337,338,341,344,347,348,351,354,355,358,361,364,365,368,371,372,375,378,381,382,385,388,389,392,395,396,399,402,405,406,409,412,413,416,419,422,423,426,429,430,433,436,437,440,443,446,447,450,453,454,457,460,463,464,467,470,471,474,477,480,481,484,487,488,491,494,495,498,501,504,505,508,511,512,515,518,521,522,525,528,529,532,535,536,539,542,545,546,549,552,553,556,559,562,563,566,569,570,573,576,577,580,583,586,587,590,593,594,597,600,603,604
mov $5,$0
add $0,1
pow $0,2
mov $2,$0
mov $3,1
lpb $2,1
mov $1,1
add $3,1
mov $4,$2
trn $4,2
lpb $4,1
add $1,2
add $3,4
trn $4,$3
lpe
sub $2,$2
lpe
add $1,2
add $1,$5
|
;
; CPC Maths Routines
;
; August 2003 **_|warp6|_** <kbaccam /at/ free.fr>
;
; $Id: deq.asm,v 1.3 2015/01/21 10:56:29 stefano Exp $
;
INCLUDE "cpcfirm.def"
INCLUDE "cpcfp.def"
PUBLIC deq
PUBLIC deqc
EXTERN fsetup
EXTERN stkequcmp
EXTERN cmpfin
.deq call fsetup
call firmware
.deqc defw CPCFP_FLO_CMP ; comp (hl)?(de)
cp 0 ;(hl) != (de)
jp z,cmpfin
xor a
jp stkequcmp
|
; --COPYRIGHT--,BSD_EX
; Copyright (c) 2012, Texas Instruments Incorporated
; 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.
;
; * Neither the name of Texas Instruments Incorporated nor the names of
; its contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
;
; ******************************************************************************
;
; MSP430 CODE EXAMPLE DISCLAIMER
;
; MSP430 code examples are self-contained low-level programs that typically
; demonstrate a single peripheral function or device feature in a highly
; concise manner. For this the code may rely on the device's power-on default
; register values and settings such as the clock configuration and care must
; be taken when combining code from several examples to avoid potential side
; effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
; for an API functional library-approach to peripheral configuration.
;
; --/COPYRIGHT--
;******************************************************************************
; MSP430F54xA Demo - Saturation mode underflow test
;
; Description: The example illustrates a special case showing underflow.
; Underflow occurs when adding 2 negative numbers yields a positive result.
; By having the saturation mode enabled, the result if rounded off to the
; highest negative number (0x8000.0000 for 16 bit). Results can be viewed
; in the debugger window.
;
; ACLK = 32.768kHz, MCLK = SMCLK = default DCO
;
; MSP430F5438A
; -----------------
; /|\| |
; | | |
; --|RST |
; | |
; | |
;
; D. Dang
; Texas Instruments Inc.
; December 2009
; Built with CCS Version: 4.0.2
;******************************************************************************
.cdecls C,LIST,"msp430.h"
;-------------------------------------------------------------------------------
.def RESET ; Export program entry-point to
; make it known to linker.
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
.bss result_lower16,2
.bss result_upper16,2
;-------------------------------------------------------------------------------
.global _main
.text ; Assemble to Flash memory
;-------------------------------------------------------------------------------
_main
RESET mov.w #0x5C00,SP ; Initialize stackpointer
mov.w #WDTPW + WDTHOLD,&WDTCTL; Stop WDT
mov.w #MPYSAT + MPYC,&MPY32CTL0
; Saturation mode enable,
clr.w RES3
clr.w RES2
clr.w RES1 ; Pre-load first negative value
mov.w #0x8000,&RES0
mov.w #0x8000,&MACS ; Add to second negative value
mov.w #0x05,&OP2
nop ; Wait for the result to become available
nop
nop
nop
nop
mov.w &RESHI,result_upper16 ; Result_upper16 = 0x8000
mov.w &RESLO,result_lower16 ; Result_lower15 = 0x0000
bic.w #MPYSAT,&MPY32CTL0 ; Clear saturation mode
bis.w #LPM4,SR ; Enter LPM4
nop ; For debugger
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset" ; POR, ext. Reset
.short RESET
.end
|
/*
Amine Rehioui
Created: August 7th 2011
*/
#include "Shoot.h"
#include "TimeManager.h"
#include "Timer.h"
#include "Clock.h"
namespace shoot
{
//! constructor
TimeManager::TimeManager()
{
}
//! Destructor
TimeManager::~TimeManager()
{
SHOOT_WARNING(m_aTimers.empty(), "Destroying TimeManager while some Timers are still registered");
SHOOT_WARNING(m_aClocks.empty(), "Destroying TimeManager while some Clocks are still registered");
}
//! registers a timer
void TimeManager::RegisterTimer(Timer* pTimer)
{
std::vector<Timer*>::iterator it = std::find(m_aTimers.begin(), m_aTimers.end(), pTimer);
SHOOT_ASSERT(it == m_aTimers.end(), "Calling RegisterTimer twice with the same timer");
m_aTimers.push_back(pTimer);
}
//! unregisters a timer
void TimeManager::UnregisterTimer(Timer* pTimer)
{
std::vector<Timer*>::iterator it = std::find(m_aTimers.begin(), m_aTimers.end(), pTimer);
SHOOT_ASSERT(it != m_aTimers.end(), "TimeManager::UnregisterTimer: Trying to remove unexisting timer");
m_aTimers.erase(it);
}
//! registers a clock
void TimeManager::RegisterClock(Clock* pClock)
{
std::vector<Clock*>::iterator it = std::find(m_aClocks.begin(), m_aClocks.end(), pClock);
SHOOT_ASSERT(it == m_aClocks.end(), "Calling RegisterClock twice with the same Clock");
m_aClocks.push_back(pClock);
}
//! unregisters a clock
void TimeManager::UnregisterClock(Clock* pClock)
{
std::vector<Clock*>::iterator it = std::find(m_aClocks.begin(), m_aClocks.end(), pClock);
SHOOT_ASSERT(it != m_aClocks.end(), "ClockManager::UnregisterClock: Trying to remove unexisting Clock");
m_aClocks.erase(it);
}
//! updates the timers
void TimeManager::Update()
{
for(u32 i=0; i<m_aTimers.size(); ++i)
{
m_aTimers[i]->Advance(g_fDeltaTime);
}
for(u32 i=0; i<m_aClocks.size(); ++i)
{
m_aClocks[i]->Advance(g_fDeltaTime);
}
}
}
|
; A033876: Expansion of 1/(2*x) * (1/(1-4*x)^(3/2)-1).
; 3,15,70,315,1386,6006,25740,109395,461890,1939938,8112468,33801950,140408100,581690700,2404321560,9917826435,40838108850,167890003050,689232644100,2825853840810,11572544300460,47342226683700,193485622098600,790066290235950,3223470464162676,13141841123124756,53540834205323080,217987682121672540,886984361736460680,3607069737728273432,14660993127540724272,59560284580634192355,241850852539544902290,981629930895799897530,3982612862491531012836,16151707720104542440946,65479896162585982868700,265365894974690562152100,1075072087333361764616200,4354041953700115146695610,17628560105224856447596860,71353695664005371335511100,288733559198533363078579800,1168058489484975877908800100,4724147668583680217320035960,19101988399055750443946232360,77220804166395586901059237200,312100750172515497058447750350,1261141806819552416685156215700,5095012899550991763408031111428,20579856025637339279648125665768,83110957026612331706271276727140,335580090635755452549850060747320,1354749254788790530664209504498440,5468260628420209051044627454520976,22068337536124415098858675084316796,89047677777344131100657811743734440,359261320687905632371619447379894120
add $0,2
mov $1,$0
mul $0,2
bin $0,$1
mul $0,$1
div $0,4
|
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2018-2019 The FestonCoin Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/feston-config.h"
#endif
#include "addressbookpage.h"
#include "ui_addressbookpage.h"
#include "addresstablemodel.h"
#include "bitcoingui.h"
#include "csvmodelwriter.h"
#include "editaddressdialog.h"
#include "guiutil.h"
#include <QIcon>
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget* parent) : QDialog(parent),
ui(new Ui::AddressBookPage),
model(0),
mode(mode),
tab(tab)
{
ui->setupUi(this);
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
ui->newAddress->setIcon(QIcon());
ui->copyAddress->setIcon(QIcon());
ui->deleteAddress->setIcon(QIcon());
ui->exportButton->setIcon(QIcon());
#endif
switch (mode) {
case ForSelection:
switch (tab) {
case SendingTab:
setWindowTitle(tr("Choose the address to send coins to"));
break;
case ReceivingTab:
setWindowTitle(tr("Choose the address to receive coins with"));
break;
}
connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableView->setFocus();
ui->closeButton->setText(tr("C&hoose"));
ui->exportButton->hide();
break;
case ForEditing:
switch (tab) {
case SendingTab:
setWindowTitle(tr("Sending addresses"));
break;
case ReceivingTab:
setWindowTitle(tr("Receiving addresses"));
break;
}
break;
}
switch (tab) {
case SendingTab:
ui->labelExplanation->setText(tr("These are your FestonCoin addresses for sending payments. Always check the amount and the receiving address before sending coins."));
ui->deleteAddress->setVisible(true);
break;
case ReceivingTab:
ui->labelExplanation->setText(tr("These are your FestonCoin addresses for receiving payments. It is recommended to use a new receiving address for each transaction."));
ui->deleteAddress->setVisible(false);
break;
}
// Context menu actions
QAction* copyAddressAction = new QAction(tr("&Copy Address"), this);
QAction* copyLabelAction = new QAction(tr("Copy &Label"), this);
QAction* editAction = new QAction(tr("&Edit"), this);
deleteAction = new QAction(ui->deleteAddress->text(), this);
// Build context menu
contextMenu = new QMenu();
contextMenu->addAction(copyAddressAction);
contextMenu->addAction(copyLabelAction);
contextMenu->addAction(editAction);
if (tab == SendingTab)
contextMenu->addAction(deleteAction);
contextMenu->addSeparator();
// Connect signals for context menu actions
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked()));
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction()));
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked()));
connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept()));
}
AddressBookPage::~AddressBookPage()
{
delete ui;
}
void AddressBookPage::setModel(AddressTableModel* model)
{
this->model = model;
if (!model)
return;
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(model);
proxyModel->setDynamicSortFilter(true);
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
switch (tab) {
case ReceivingTab:
// Receive filter
proxyModel->setFilterRole(AddressTableModel::TypeRole);
proxyModel->setFilterFixedString(AddressTableModel::Receive);
break;
case SendingTab:
// Send filter
proxyModel->setFilterRole(AddressTableModel::TypeRole);
proxyModel->setFilterFixedString(AddressTableModel::Send);
break;
}
ui->tableView->setModel(proxyModel);
ui->tableView->sortByColumn(0, Qt::AscendingOrder);
// Set column widths
#if QT_VERSION < 0x050000
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
#else
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
#endif
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(selectionChanged()));
// Select row for newly created address
connect(model, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(selectNewAddress(QModelIndex, int, int)));
selectionChanged();
}
void AddressBookPage::on_copyAddress_clicked()
{
GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address);
}
void AddressBookPage::onCopyLabelAction()
{
GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Label);
}
void AddressBookPage::onEditAction()
{
if (!model)
return;
if (!ui->tableView->selectionModel())
return;
QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows();
if (indexes.isEmpty())
return;
EditAddressDialog dlg(
tab == SendingTab ?
EditAddressDialog::EditSendingAddress :
EditAddressDialog::EditReceivingAddress,
this);
dlg.setModel(model);
QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0));
dlg.loadRow(origIndex.row());
dlg.exec();
}
void AddressBookPage::on_newAddress_clicked()
{
if (!model)
return;
EditAddressDialog dlg(
tab == SendingTab ?
EditAddressDialog::NewSendingAddress :
EditAddressDialog::NewReceivingAddress,
this);
dlg.setModel(model);
if (dlg.exec()) {
newAddressToSelect = dlg.getAddress();
}
}
void AddressBookPage::on_deleteAddress_clicked()
{
QTableView* table = ui->tableView;
if (!table->selectionModel())
return;
QModelIndexList indexes = table->selectionModel()->selectedRows();
if (!indexes.isEmpty()) {
table->model()->removeRow(indexes.at(0).row());
}
}
void AddressBookPage::selectionChanged()
{
// Set button states based on selected tab and selection
QTableView* table = ui->tableView;
if (!table->selectionModel())
return;
if (table->selectionModel()->hasSelection()) {
switch (tab) {
case SendingTab:
// In sending tab, allow deletion of selection
ui->deleteAddress->setEnabled(true);
ui->deleteAddress->setVisible(true);
deleteAction->setEnabled(true);
break;
case ReceivingTab:
// Deleting receiving addresses, however, is not allowed
ui->deleteAddress->setEnabled(false);
ui->deleteAddress->setVisible(false);
deleteAction->setEnabled(false);
break;
}
ui->copyAddress->setEnabled(true);
} else {
ui->deleteAddress->setEnabled(false);
ui->copyAddress->setEnabled(false);
}
}
void AddressBookPage::done(int retval)
{
QTableView* table = ui->tableView;
if (!table->selectionModel() || !table->model())
return;
// Figure out which address was selected, and return it
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
foreach (QModelIndex index, indexes) {
QVariant address = table->model()->data(index);
returnValue = address.toString();
}
if (returnValue.isEmpty()) {
// If no address entry selected, return rejected
retval = Rejected;
}
QDialog::done(retval);
}
void AddressBookPage::on_exportButton_clicked()
{
// CSV is currently the only supported format
QString filename = GUIUtil::getSaveFileName(this,
tr("Export Address List"), QString(),
tr("Comma separated file (*.csv)"), NULL);
if (filename.isNull())
return;
CSVModelWriter writer(filename);
// name, column, role
writer.setModel(proxyModel);
writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole);
writer.addColumn("Address", AddressTableModel::Address, Qt::EditRole);
if (!writer.write()) {
QMessageBox::critical(this, tr("Exporting Failed"),
tr("There was an error trying to save the address list to %1. Please try again.").arg(filename));
}
}
void AddressBookPage::contextualMenu(const QPoint& point)
{
QModelIndex index = ui->tableView->indexAt(point);
if (index.isValid()) {
contextMenu->exec(QCursor::pos());
}
}
void AddressBookPage::selectNewAddress(const QModelIndex& parent, int begin, int /*end*/)
{
QModelIndex idx = proxyModel->mapFromSource(model->index(begin, AddressTableModel::Address, parent));
if (idx.isValid() && (idx.data(Qt::EditRole).toString() == newAddressToSelect)) {
// Select row of newly created address, once
ui->tableView->setFocus();
ui->tableView->selectRow(idx.row());
newAddressToSelect.clear();
}
}
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; printfield 打印蛇,包括边框
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printfield:
.scope
ldx #23 ; i代表行数,不含边框
lda #<field ; 取地址低8位
clc
adc #1
sta _ptr
lda #>field ; 取地址高8位
sta _ptr + 1
jsr _print_blk_line
;ldy #0 ; 此时y一定为0
* lda #cblk
sta (_ptr), y ; 打印左边框
lda #39
jsr _addptr
lda #cblk
sta (_ptr), y ; 打印右边框
lda #1
jsr _addptr
dex
bne -
jsr _print_blk_line
rts
_addptr:
clc
adc _ptr
bcc +
inc _ptr + 1
* sta _ptr
rts
_print_blk_line:
lda #cblk
ldy #40
dec _ptr
* sta (_ptr), y ; 打印底边
dey
bne -
rts
.scend
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/wrappers.proto
#include <google/protobuf/wrappers.pb.h>
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// This is a temporary google only hack
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
#include "third_party/protobuf/version.h"
#endif
// @@protoc_insertion_point(includes)
namespace google {
namespace protobuf {
class DoubleValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<DoubleValue>
_instance;
} _DoubleValue_default_instance_;
class FloatValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<FloatValue>
_instance;
} _FloatValue_default_instance_;
class Int64ValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<Int64Value>
_instance;
} _Int64Value_default_instance_;
class UInt64ValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<UInt64Value>
_instance;
} _UInt64Value_default_instance_;
class Int32ValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<Int32Value>
_instance;
} _Int32Value_default_instance_;
class UInt32ValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<UInt32Value>
_instance;
} _UInt32Value_default_instance_;
class BoolValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<BoolValue>
_instance;
} _BoolValue_default_instance_;
class StringValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StringValue>
_instance;
} _StringValue_default_instance_;
class BytesValueDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<BytesValue>
_instance;
} _BytesValue_default_instance_;
} // namespace protobuf
} // namespace google
namespace protobuf_google_2fprotobuf_2fwrappers_2eproto {
static void InitDefaultsDoubleValue() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_DoubleValue_default_instance_;
new (ptr) ::google::protobuf::DoubleValue();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::DoubleValue::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_DoubleValue =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsDoubleValue}, {}};
static void InitDefaultsFloatValue() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_FloatValue_default_instance_;
new (ptr) ::google::protobuf::FloatValue();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::FloatValue::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_FloatValue =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsFloatValue}, {}};
static void InitDefaultsInt64Value() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_Int64Value_default_instance_;
new (ptr) ::google::protobuf::Int64Value();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::Int64Value::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Int64Value =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsInt64Value}, {}};
static void InitDefaultsUInt64Value() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_UInt64Value_default_instance_;
new (ptr) ::google::protobuf::UInt64Value();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::UInt64Value::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_UInt64Value =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsUInt64Value}, {}};
static void InitDefaultsInt32Value() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_Int32Value_default_instance_;
new (ptr) ::google::protobuf::Int32Value();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::Int32Value::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_Int32Value =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsInt32Value}, {}};
static void InitDefaultsUInt32Value() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_UInt32Value_default_instance_;
new (ptr) ::google::protobuf::UInt32Value();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::UInt32Value::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_UInt32Value =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsUInt32Value}, {}};
static void InitDefaultsBoolValue() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_BoolValue_default_instance_;
new (ptr) ::google::protobuf::BoolValue();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::BoolValue::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_BoolValue =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsBoolValue}, {}};
static void InitDefaultsStringValue() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_StringValue_default_instance_;
new (ptr) ::google::protobuf::StringValue();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::StringValue::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_StringValue =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsStringValue}, {}};
static void InitDefaultsBytesValue() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::protobuf::_BytesValue_default_instance_;
new (ptr) ::google::protobuf::BytesValue();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::protobuf::BytesValue::InitAsDefaultInstance();
}
LIBPROTOBUF_EXPORT ::google::protobuf::internal::SCCInfo<0> scc_info_BytesValue =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsBytesValue}, {}};
void InitDefaults() {
::google::protobuf::internal::InitSCC(&scc_info_DoubleValue.base);
::google::protobuf::internal::InitSCC(&scc_info_FloatValue.base);
::google::protobuf::internal::InitSCC(&scc_info_Int64Value.base);
::google::protobuf::internal::InitSCC(&scc_info_UInt64Value.base);
::google::protobuf::internal::InitSCC(&scc_info_Int32Value.base);
::google::protobuf::internal::InitSCC(&scc_info_UInt32Value.base);
::google::protobuf::internal::InitSCC(&scc_info_BoolValue.base);
::google::protobuf::internal::InitSCC(&scc_info_StringValue.base);
::google::protobuf::internal::InitSCC(&scc_info_BytesValue.base);
}
::google::protobuf::Metadata file_level_metadata[9];
const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DoubleValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::DoubleValue, value_),
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FloatValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::FloatValue, value_),
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int64Value, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int64Value, value_),
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt64Value, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt64Value, value_),
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int32Value, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::Int32Value, value_),
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt32Value, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::UInt32Value, value_),
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BoolValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BoolValue, value_),
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::StringValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::StringValue, value_),
~0u, // no _has_bits_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BytesValue, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::protobuf::BytesValue, value_),
};
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::protobuf::DoubleValue)},
{ 6, -1, sizeof(::google::protobuf::FloatValue)},
{ 12, -1, sizeof(::google::protobuf::Int64Value)},
{ 18, -1, sizeof(::google::protobuf::UInt64Value)},
{ 24, -1, sizeof(::google::protobuf::Int32Value)},
{ 30, -1, sizeof(::google::protobuf::UInt32Value)},
{ 36, -1, sizeof(::google::protobuf::BoolValue)},
{ 42, -1, sizeof(::google::protobuf::StringValue)},
{ 48, -1, sizeof(::google::protobuf::BytesValue)},
};
static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_DoubleValue_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_FloatValue_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Int64Value_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_UInt64Value_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_Int32Value_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_UInt32Value_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_BoolValue_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_StringValue_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::protobuf::_BytesValue_default_instance_),
};
void protobuf_AssignDescriptors() {
AddDescriptors();
AssignDescriptors(
"google/protobuf/wrappers.proto", schemas, file_default_instances, TableStruct::offsets,
file_level_metadata, NULL, NULL);
}
void protobuf_AssignDescriptorsOnce() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
}
void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
protobuf_AssignDescriptorsOnce();
::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 9);
}
void AddDescriptorsImpl() {
InitDefaults();
static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
"\n\036google/protobuf/wrappers.proto\022\017google"
".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\""
"\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val"
"ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu"
"e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013"
"UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022"
"\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001"
" \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B|\n\023com"
".google.protobufB\rWrappersProtoP\001Z*githu"
"b.com/golang/protobuf/ptypes/wrappers\370\001\001"
"\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb"
"\006proto3"
};
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
descriptor, 447);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"google/protobuf/wrappers.proto", &protobuf_RegisterTypes);
}
void AddDescriptors() {
static ::google::protobuf::internal::once_flag once;
::google::protobuf::internal::call_once(once, AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at dynamic initialization time.
struct StaticDescriptorInitializer {
StaticDescriptorInitializer() {
AddDescriptors();
}
} static_descriptor_initializer;
} // namespace protobuf_google_2fprotobuf_2fwrappers_2eproto
namespace google {
namespace protobuf {
// ===================================================================
void DoubleValue::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int DoubleValue::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
DoubleValue::DoubleValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_DoubleValue.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.DoubleValue)
}
DoubleValue::DoubleValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_DoubleValue.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue)
}
DoubleValue::DoubleValue(const DoubleValue& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue)
}
void DoubleValue::SharedCtor() {
value_ = 0;
}
DoubleValue::~DoubleValue() {
// @@protoc_insertion_point(destructor:google.protobuf.DoubleValue)
SharedDtor();
}
void DoubleValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
}
void DoubleValue::ArenaDtor(void* object) {
DoubleValue* _this = reinterpret_cast< DoubleValue* >(object);
(void)_this;
}
void DoubleValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void DoubleValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* DoubleValue::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const DoubleValue& DoubleValue::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_DoubleValue.base);
return *internal_default_instance();
}
void DoubleValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.DoubleValue)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_ = 0;
_internal_metadata_.Clear();
}
bool DoubleValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.DoubleValue)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// double value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(9u /* 9 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
input, &value_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.DoubleValue)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.DoubleValue)
return false;
#undef DO_
}
void DoubleValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.DoubleValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// double value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.DoubleValue)
}
::google::protobuf::uint8* DoubleValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DoubleValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// double value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DoubleValue)
return target;
}
size_t DoubleValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DoubleValue)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// double value = 1;
if (this->value() != 0) {
total_size += 1 + 8;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void DoubleValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DoubleValue)
GOOGLE_DCHECK_NE(&from, this);
const DoubleValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const DoubleValue>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.DoubleValue)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DoubleValue)
MergeFrom(*source);
}
}
void DoubleValue::MergeFrom(const DoubleValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value() != 0) {
set_value(from.value());
}
}
void DoubleValue::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.DoubleValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void DoubleValue::CopyFrom(const DoubleValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DoubleValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool DoubleValue::IsInitialized() const {
return true;
}
void DoubleValue::Swap(DoubleValue* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
DoubleValue* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void DoubleValue::UnsafeArenaSwap(DoubleValue* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void DoubleValue::InternalSwap(DoubleValue* other) {
using std::swap;
swap(value_, other->value_);
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata DoubleValue::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void FloatValue::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int FloatValue::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
FloatValue::FloatValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_FloatValue.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.FloatValue)
}
FloatValue::FloatValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_FloatValue.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue)
}
FloatValue::FloatValue(const FloatValue& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue)
}
void FloatValue::SharedCtor() {
value_ = 0;
}
FloatValue::~FloatValue() {
// @@protoc_insertion_point(destructor:google.protobuf.FloatValue)
SharedDtor();
}
void FloatValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
}
void FloatValue::ArenaDtor(void* object) {
FloatValue* _this = reinterpret_cast< FloatValue* >(object);
(void)_this;
}
void FloatValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void FloatValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* FloatValue::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const FloatValue& FloatValue::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_FloatValue.base);
return *internal_default_instance();
}
void FloatValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.FloatValue)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_ = 0;
_internal_metadata_.Clear();
}
bool FloatValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.FloatValue)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// float value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(13u /* 13 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
input, &value_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.FloatValue)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.FloatValue)
return false;
#undef DO_
}
void FloatValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FloatValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// float value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.FloatValue)
}
::google::protobuf::uint8* FloatValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FloatValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// float value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FloatValue)
return target;
}
size_t FloatValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FloatValue)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// float value = 1;
if (this->value() != 0) {
total_size += 1 + 4;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void FloatValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FloatValue)
GOOGLE_DCHECK_NE(&from, this);
const FloatValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const FloatValue>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FloatValue)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FloatValue)
MergeFrom(*source);
}
}
void FloatValue::MergeFrom(const FloatValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value() != 0) {
set_value(from.value());
}
}
void FloatValue::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FloatValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void FloatValue::CopyFrom(const FloatValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FloatValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool FloatValue::IsInitialized() const {
return true;
}
void FloatValue::Swap(FloatValue* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
FloatValue* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void FloatValue::UnsafeArenaSwap(FloatValue* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void FloatValue::InternalSwap(FloatValue* other) {
using std::swap;
swap(value_, other->value_);
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata FloatValue::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void Int64Value::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Int64Value::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Int64Value::Int64Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_Int64Value.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Int64Value)
}
Int64Value::Int64Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_Int64Value.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value)
}
Int64Value::Int64Value(const Int64Value& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value)
}
void Int64Value::SharedCtor() {
value_ = GOOGLE_LONGLONG(0);
}
Int64Value::~Int64Value() {
// @@protoc_insertion_point(destructor:google.protobuf.Int64Value)
SharedDtor();
}
void Int64Value::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
}
void Int64Value::ArenaDtor(void* object) {
Int64Value* _this = reinterpret_cast< Int64Value* >(object);
(void)_this;
}
void Int64Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void Int64Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* Int64Value::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const Int64Value& Int64Value::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_Int64Value.base);
return *internal_default_instance();
}
void Int64Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Int64Value)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_ = GOOGLE_LONGLONG(0);
_internal_metadata_.Clear();
}
bool Int64Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Int64Value)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// int64 value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
input, &value_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.Int64Value)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.Int64Value)
return false;
#undef DO_
}
void Int64Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Int64Value)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// int64 value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.Int64Value)
}
::google::protobuf::uint8* Int64Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int64Value)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// int64 value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int64Value)
return target;
}
size_t Int64Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int64Value)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// int64 value = 1;
if (this->value() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int64Size(
this->value());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void Int64Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int64Value)
GOOGLE_DCHECK_NE(&from, this);
const Int64Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const Int64Value>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Int64Value)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int64Value)
MergeFrom(*source);
}
}
void Int64Value::MergeFrom(const Int64Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value() != 0) {
set_value(from.value());
}
}
void Int64Value::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Int64Value)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Int64Value::CopyFrom(const Int64Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int64Value)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Int64Value::IsInitialized() const {
return true;
}
void Int64Value::Swap(Int64Value* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
Int64Value* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void Int64Value::UnsafeArenaSwap(Int64Value* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void Int64Value::InternalSwap(Int64Value* other) {
using std::swap;
swap(value_, other->value_);
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata Int64Value::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void UInt64Value::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int UInt64Value::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
UInt64Value::UInt64Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_UInt64Value.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.UInt64Value)
}
UInt64Value::UInt64Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_UInt64Value.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value)
}
UInt64Value::UInt64Value(const UInt64Value& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value)
}
void UInt64Value::SharedCtor() {
value_ = GOOGLE_ULONGLONG(0);
}
UInt64Value::~UInt64Value() {
// @@protoc_insertion_point(destructor:google.protobuf.UInt64Value)
SharedDtor();
}
void UInt64Value::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
}
void UInt64Value::ArenaDtor(void* object) {
UInt64Value* _this = reinterpret_cast< UInt64Value* >(object);
(void)_this;
}
void UInt64Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void UInt64Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* UInt64Value::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const UInt64Value& UInt64Value::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_UInt64Value.base);
return *internal_default_instance();
}
void UInt64Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UInt64Value)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_ = GOOGLE_ULONGLONG(0);
_internal_metadata_.Clear();
}
bool UInt64Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UInt64Value)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// uint64 value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
input, &value_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.UInt64Value)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.UInt64Value)
return false;
#undef DO_
}
void UInt64Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.UInt64Value)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// uint64 value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.UInt64Value)
}
::google::protobuf::uint8* UInt64Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt64Value)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// uint64 value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt64Value)
return target;
}
size_t UInt64Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt64Value)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// uint64 value = 1;
if (this->value() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt64Size(
this->value());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void UInt64Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt64Value)
GOOGLE_DCHECK_NE(&from, this);
const UInt64Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const UInt64Value>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.UInt64Value)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt64Value)
MergeFrom(*source);
}
}
void UInt64Value::MergeFrom(const UInt64Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value() != 0) {
set_value(from.value());
}
}
void UInt64Value::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.UInt64Value)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void UInt64Value::CopyFrom(const UInt64Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt64Value)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool UInt64Value::IsInitialized() const {
return true;
}
void UInt64Value::Swap(UInt64Value* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
UInt64Value* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void UInt64Value::UnsafeArenaSwap(UInt64Value* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void UInt64Value::InternalSwap(UInt64Value* other) {
using std::swap;
swap(value_, other->value_);
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata UInt64Value::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void Int32Value::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Int32Value::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
Int32Value::Int32Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_Int32Value.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.Int32Value)
}
Int32Value::Int32Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_Int32Value.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value)
}
Int32Value::Int32Value(const Int32Value& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value)
}
void Int32Value::SharedCtor() {
value_ = 0;
}
Int32Value::~Int32Value() {
// @@protoc_insertion_point(destructor:google.protobuf.Int32Value)
SharedDtor();
}
void Int32Value::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
}
void Int32Value::ArenaDtor(void* object) {
Int32Value* _this = reinterpret_cast< Int32Value* >(object);
(void)_this;
}
void Int32Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void Int32Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* Int32Value::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const Int32Value& Int32Value::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_Int32Value.base);
return *internal_default_instance();
}
void Int32Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Int32Value)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_ = 0;
_internal_metadata_.Clear();
}
bool Int32Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.Int32Value)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// int32 value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
input, &value_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.Int32Value)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.Int32Value)
return false;
#undef DO_
}
void Int32Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.Int32Value)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// int32 value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.Int32Value)
}
::google::protobuf::uint8* Int32Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int32Value)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// int32 value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int32Value)
return target;
}
size_t Int32Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int32Value)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// int32 value = 1;
if (this->value() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(
this->value());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void Int32Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int32Value)
GOOGLE_DCHECK_NE(&from, this);
const Int32Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const Int32Value>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Int32Value)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int32Value)
MergeFrom(*source);
}
}
void Int32Value::MergeFrom(const Int32Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value() != 0) {
set_value(from.value());
}
}
void Int32Value::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Int32Value)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void Int32Value::CopyFrom(const Int32Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int32Value)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool Int32Value::IsInitialized() const {
return true;
}
void Int32Value::Swap(Int32Value* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
Int32Value* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void Int32Value::UnsafeArenaSwap(Int32Value* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void Int32Value::InternalSwap(Int32Value* other) {
using std::swap;
swap(value_, other->value_);
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata Int32Value::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void UInt32Value::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int UInt32Value::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
UInt32Value::UInt32Value()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_UInt32Value.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.UInt32Value)
}
UInt32Value::UInt32Value(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_UInt32Value.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value)
}
UInt32Value::UInt32Value(const UInt32Value& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value)
}
void UInt32Value::SharedCtor() {
value_ = 0u;
}
UInt32Value::~UInt32Value() {
// @@protoc_insertion_point(destructor:google.protobuf.UInt32Value)
SharedDtor();
}
void UInt32Value::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
}
void UInt32Value::ArenaDtor(void* object) {
UInt32Value* _this = reinterpret_cast< UInt32Value* >(object);
(void)_this;
}
void UInt32Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void UInt32Value::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* UInt32Value::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const UInt32Value& UInt32Value::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_UInt32Value.base);
return *internal_default_instance();
}
void UInt32Value::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.UInt32Value)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_ = 0u;
_internal_metadata_.Clear();
}
bool UInt32Value::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.UInt32Value)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// uint32 value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
input, &value_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.UInt32Value)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.UInt32Value)
return false;
#undef DO_
}
void UInt32Value::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.UInt32Value)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// uint32 value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.UInt32Value)
}
::google::protobuf::uint8* UInt32Value::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt32Value)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// uint32 value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt32Value)
return target;
}
size_t UInt32Value::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt32Value)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// uint32 value = 1;
if (this->value() != 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::UInt32Size(
this->value());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void UInt32Value::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt32Value)
GOOGLE_DCHECK_NE(&from, this);
const UInt32Value* source =
::google::protobuf::internal::DynamicCastToGenerated<const UInt32Value>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.UInt32Value)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt32Value)
MergeFrom(*source);
}
}
void UInt32Value::MergeFrom(const UInt32Value& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value() != 0) {
set_value(from.value());
}
}
void UInt32Value::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.UInt32Value)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void UInt32Value::CopyFrom(const UInt32Value& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt32Value)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool UInt32Value::IsInitialized() const {
return true;
}
void UInt32Value::Swap(UInt32Value* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
UInt32Value* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void UInt32Value::UnsafeArenaSwap(UInt32Value* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void UInt32Value::InternalSwap(UInt32Value* other) {
using std::swap;
swap(value_, other->value_);
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata UInt32Value::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void BoolValue::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int BoolValue::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
BoolValue::BoolValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_BoolValue.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.BoolValue)
}
BoolValue::BoolValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_BoolValue.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue)
}
BoolValue::BoolValue(const BoolValue& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_ = from.value_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue)
}
void BoolValue::SharedCtor() {
value_ = false;
}
BoolValue::~BoolValue() {
// @@protoc_insertion_point(destructor:google.protobuf.BoolValue)
SharedDtor();
}
void BoolValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
}
void BoolValue::ArenaDtor(void* object) {
BoolValue* _this = reinterpret_cast< BoolValue* >(object);
(void)_this;
}
void BoolValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void BoolValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* BoolValue::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const BoolValue& BoolValue::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_BoolValue.base);
return *internal_default_instance();
}
void BoolValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.BoolValue)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_ = false;
_internal_metadata_.Clear();
}
bool BoolValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.BoolValue)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// bool value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &value_)));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.BoolValue)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.BoolValue)
return false;
#undef DO_
}
void BoolValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.BoolValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// bool value = 1;
if (this->value() != 0) {
::google::protobuf::internal::WireFormatLite::WriteBool(1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.BoolValue)
}
::google::protobuf::uint8* BoolValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BoolValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// bool value = 1;
if (this->value() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BoolValue)
return target;
}
size_t BoolValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.BoolValue)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// bool value = 1;
if (this->value() != 0) {
total_size += 1 + 1;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void BoolValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BoolValue)
GOOGLE_DCHECK_NE(&from, this);
const BoolValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const BoolValue>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.BoolValue)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BoolValue)
MergeFrom(*source);
}
}
void BoolValue::MergeFrom(const BoolValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value() != 0) {
set_value(from.value());
}
}
void BoolValue::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.BoolValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void BoolValue::CopyFrom(const BoolValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BoolValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool BoolValue::IsInitialized() const {
return true;
}
void BoolValue::Swap(BoolValue* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
BoolValue* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void BoolValue::UnsafeArenaSwap(BoolValue* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void BoolValue::InternalSwap(BoolValue* other) {
using std::swap;
swap(value_, other->value_);
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata BoolValue::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void StringValue::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StringValue::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StringValue::StringValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_StringValue.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.StringValue)
}
StringValue::StringValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_StringValue.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue)
}
StringValue::StringValue(const StringValue& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.value().size() > 0) {
value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value(),
GetArenaNoVirtual());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue)
}
void StringValue::SharedCtor() {
value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
StringValue::~StringValue() {
// @@protoc_insertion_point(destructor:google.protobuf.StringValue)
SharedDtor();
}
void StringValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void StringValue::ArenaDtor(void* object) {
StringValue* _this = reinterpret_cast< StringValue* >(object);
(void)_this;
}
void StringValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void StringValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* StringValue::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const StringValue& StringValue::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_StringValue.base);
return *internal_default_instance();
}
void StringValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.StringValue)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
_internal_metadata_.Clear();
}
bool StringValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.StringValue)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// string value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_value()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->value().data(), static_cast<int>(this->value().length()),
::google::protobuf::internal::WireFormatLite::PARSE,
"google.protobuf.StringValue.value"));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.StringValue)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.StringValue)
return false;
#undef DO_
}
void StringValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.StringValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string value = 1;
if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->value().data(), static_cast<int>(this->value().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.StringValue.value");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.StringValue)
}
::google::protobuf::uint8* StringValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.StringValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string value = 1;
if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->value().data(), static_cast<int>(this->value().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.StringValue.value");
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.StringValue)
return target;
}
size_t StringValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.StringValue)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// string value = 1;
if (this->value().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->value());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StringValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.StringValue)
GOOGLE_DCHECK_NE(&from, this);
const StringValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const StringValue>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.StringValue)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.StringValue)
MergeFrom(*source);
}
}
void StringValue::MergeFrom(const StringValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value().size() > 0) {
set_value(from.value());
}
}
void StringValue::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.StringValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StringValue::CopyFrom(const StringValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.StringValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StringValue::IsInitialized() const {
return true;
}
void StringValue::Swap(StringValue* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
StringValue* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void StringValue::UnsafeArenaSwap(StringValue* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void StringValue::InternalSwap(StringValue* other) {
using std::swap;
value_.Swap(&other->value_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata StringValue::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// ===================================================================
void BytesValue::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int BytesValue::kValueFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
BytesValue::BytesValue()
: ::google::protobuf::Message(), _internal_metadata_(NULL) {
::google::protobuf::internal::InitSCC(
&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_BytesValue.base);
SharedCtor();
// @@protoc_insertion_point(constructor:google.protobuf.BytesValue)
}
BytesValue::BytesValue(::google::protobuf::Arena* arena)
: ::google::protobuf::Message(),
_internal_metadata_(arena) {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_BytesValue.base);
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue)
}
BytesValue::BytesValue(const BytesValue& from)
: ::google::protobuf::Message(),
_internal_metadata_(NULL) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
if (from.value().size() > 0) {
value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value(),
GetArenaNoVirtual());
}
// @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue)
}
void BytesValue::SharedCtor() {
value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
BytesValue::~BytesValue() {
// @@protoc_insertion_point(destructor:google.protobuf.BytesValue)
SharedDtor();
}
void BytesValue::SharedDtor() {
GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
void BytesValue::ArenaDtor(void* object) {
BytesValue* _this = reinterpret_cast< BytesValue* >(object);
(void)_this;
}
void BytesValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {
}
void BytesValue::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const ::google::protobuf::Descriptor* BytesValue::descriptor() {
::protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const BytesValue& BytesValue::default_instance() {
::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2fwrappers_2eproto::scc_info_BytesValue.base);
return *internal_default_instance();
}
void BytesValue::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.BytesValue)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());
_internal_metadata_.Clear();
}
bool BytesValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.protobuf.BytesValue)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// bytes value = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
input, this->mutable_value()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.protobuf.BytesValue)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.protobuf.BytesValue)
return false;
#undef DO_
}
void BytesValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.BytesValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// bytes value = 1;
if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
1, this->value(), output);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output);
}
// @@protoc_insertion_point(serialize_end:google.protobuf.BytesValue)
}
::google::protobuf::uint8* BytesValue::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
(void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BytesValue)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// bytes value = 1;
if (this->value().size() > 0) {
target =
::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
1, this->value(), target);
}
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BytesValue)
return target;
}
size_t BytesValue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.BytesValue)
size_t total_size = 0;
if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
(::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()));
}
// bytes value = 1;
if (this->value().size() > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::BytesSize(
this->value());
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void BytesValue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BytesValue)
GOOGLE_DCHECK_NE(&from, this);
const BytesValue* source =
::google::protobuf::internal::DynamicCastToGenerated<const BytesValue>(
&from);
if (source == NULL) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.BytesValue)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BytesValue)
MergeFrom(*source);
}
}
void BytesValue::MergeFrom(const BytesValue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.value().size() > 0) {
set_value(from.value());
}
}
void BytesValue::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.BytesValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void BytesValue::CopyFrom(const BytesValue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BytesValue)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool BytesValue::IsInitialized() const {
return true;
}
void BytesValue::Swap(BytesValue* other) {
if (other == this) return;
if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
InternalSwap(other);
} else {
BytesValue* temp = New(GetArenaNoVirtual());
temp->MergeFrom(*other);
other->CopyFrom(*this);
InternalSwap(temp);
if (GetArenaNoVirtual() == NULL) {
delete temp;
}
}
}
void BytesValue::UnsafeArenaSwap(BytesValue* other) {
if (other == this) return;
GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
InternalSwap(other);
}
void BytesValue::InternalSwap(BytesValue* other) {
using std::swap;
value_.Swap(&other->value_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
GetArenaNoVirtual());
_internal_metadata_.Swap(&other->_internal_metadata_);
}
::google::protobuf::Metadata BytesValue::GetMetadata() const {
protobuf_google_2fprotobuf_2fwrappers_2eproto::protobuf_AssignDescriptorsOnce();
return ::protobuf_google_2fprotobuf_2fwrappers_2eproto::file_level_metadata[kIndexInFileMessages];
}
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf
} // namespace google
namespace google {
namespace protobuf {
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::DoubleValue* Arena::CreateMaybeMessage< ::google::protobuf::DoubleValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::DoubleValue >(arena);
}
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::FloatValue* Arena::CreateMaybeMessage< ::google::protobuf::FloatValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::FloatValue >(arena);
}
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Int64Value* Arena::CreateMaybeMessage< ::google::protobuf::Int64Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Int64Value >(arena);
}
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UInt64Value* Arena::CreateMaybeMessage< ::google::protobuf::UInt64Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::UInt64Value >(arena);
}
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::Int32Value* Arena::CreateMaybeMessage< ::google::protobuf::Int32Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Int32Value >(arena);
}
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::UInt32Value* Arena::CreateMaybeMessage< ::google::protobuf::UInt32Value >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::UInt32Value >(arena);
}
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::BoolValue* Arena::CreateMaybeMessage< ::google::protobuf::BoolValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::BoolValue >(arena);
}
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::StringValue* Arena::CreateMaybeMessage< ::google::protobuf::StringValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::StringValue >(arena);
}
template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::protobuf::BytesValue* Arena::CreateMaybeMessage< ::google::protobuf::BytesValue >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::BytesValue >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
|
#ifndef RANDAR_DATA_BINARY_FILE_OUTPUT_HPP
#define RANDAR_DATA_BINARY_FILE_OUTPUT_HPP
#include <fstream>
#include <stdexcept>
#include <randar/Filesystem/Endian.hpp>
#include <randar/Render/Color.hpp>
namespace randar
{
class BinaryFileWriter
{
std::ofstream stream;
public:
/**
* Constructor.
*/
BinaryFileWriter(const std::string& file)
{
this->stream.open(file, std::ios::binary);
}
/**
* Writes a variable type of data to the file.
*/
template <typename T>
void write(const T& value)
{
this->stream.write(reinterpret_cast<const char*>(&value), sizeof value);
}
/**
* Writes numeric values to the file.
*/
void write(float value)
{
this->stream.write(reinterpret_cast<const char*>(&value), sizeof value);
}
/**
* Writes a string to the file, with an appended null terminator.
*/
void write(const std::string& value)
{
unsigned int length = value.size();
for (unsigned int i = 0; i < length; i++) {
this->write((char)value[i]);
}
this->write('\0');
}
/**
* Closes the file from further writing.
*/
void close()
{
this->stream.close();
}
};
}
#endif
|
; Bootstrap for the BASIC->ROM LOADER
; for the LlamaVampireDrive system
;
; This code is a payload on a BASIC program that will poke it into
; memory at 0xF800, then call USR(0) to trigger it.
;
;
; This code itself will:
; - make the LLVD calls to load "BOOT.ROM" to 0x0000...
; - swap out the ROM for RAM at (0x0000-0x8000)
; - call rst(0) / jump to 0x0000
;
;
; This code assumes a RC2014 system with:
; - NASCOM BASIC ROM at RUN
; - 6850 ACIA at IO 0x80
; - Pageable ROM module
; - 64k RAM module
; And is the precursor to loading CP/M
.include "../Common/hardware.asm"
.include "../Common/basicusr.asm"
.module LLVD_STRAP
.area .CODE (ABS)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Library options
; TMS
tmsFontBytes = 1
tmsGfxModes = 1
tmsTestText = 0
tmsTestGfx = 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; entry point
;.org 0xF800
.org ENTRYORG
usr:
ld a, #0x01
out (DigitalIO), a
; page swap to all-RAM
ld a, #1
out (Page_Toggle), a
;ld hl, #t_db0
;call Print
; send the bot file request
ld hl, #t_bootfile
call LLVD_Open0
; catch the response
ld hl, #0xC000
call LLVD_R0_16
; page swap back to ROM
ld a, #1
out (Page_Toggle), a
;ld hl, #t_db1
;call Print
ld a, #0b00000111
out (DigitalIO), a
; return to BASIC
ld a, #0x10
ld b, #0x92 ; 0x1092 -> 4242.d
jp ABPASS
t_bootfile: .asciz "ROMs/boot.bin"
t_splash: .asciz "Starting up...\n\r"
;t_db0: .asciz "RAM bankswitched!\n\r"
;t_db1: .asciz "And we're back!\n\r"
.include "../Common/toolbxlt.asm"
|
dnl Intel Pentium mpn_mul_basecase -- mpn by mpn multiplication.
dnl Copyright 1996, 1998-2000, 2002 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C P5: 14.2 cycles/crossproduct (approx)
C void mpn_mul_basecase (mp_ptr wp,
C mp_srcptr xp, mp_size_t xsize,
C mp_srcptr yp, mp_size_t ysize);
defframe(PARAM_YSIZE, 20)
defframe(PARAM_YP, 16)
defframe(PARAM_XSIZE, 12)
defframe(PARAM_XP, 8)
defframe(PARAM_WP, 4)
defframe(VAR_COUNTER, -4)
TEXT
ALIGN(8)
PROLOGUE(mpn_mul_basecase)
pushl %eax C dummy push for allocating stack slot
pushl %esi
pushl %ebp
pushl %edi
deflit(`FRAME',16)
movl PARAM_XP,%esi
movl PARAM_WP,%edi
movl PARAM_YP,%ebp
movl (%esi),%eax C load xp[0]
mull (%ebp) C multiply by yp[0]
movl %eax,(%edi) C store to wp[0]
movl PARAM_XSIZE,%ecx C xsize
decl %ecx C If xsize = 1, ysize = 1 too
jz L(done)
movl PARAM_XSIZE,%eax
pushl %ebx
FRAME_pushl()
movl %edx,%ebx
leal (%esi,%eax,4),%esi C make xp point at end
leal (%edi,%eax,4),%edi C offset wp by xsize
negl %ecx C negate j size/index for inner loop
xorl %eax,%eax C clear carry
ALIGN(8)
L(oop1): adcl $0,%ebx
movl (%esi,%ecx,4),%eax C load next limb at xp[j]
mull (%ebp)
addl %ebx,%eax
movl %eax,(%edi,%ecx,4)
incl %ecx
movl %edx,%ebx
jnz L(oop1)
adcl $0,%ebx
movl PARAM_YSIZE,%eax
movl %ebx,(%edi) C most significant limb of product
addl $4,%edi C increment wp
decl %eax
jz L(skip)
movl %eax,VAR_COUNTER C set index i to ysize
L(outer):
addl $4,%ebp C make ebp point to next y limb
movl PARAM_XSIZE,%ecx
negl %ecx
xorl %ebx,%ebx
C code at 0x61 here, close enough to aligned
L(oop2):
adcl $0,%ebx
movl (%esi,%ecx,4),%eax
mull (%ebp)
addl %ebx,%eax
movl (%edi,%ecx,4),%ebx
adcl $0,%edx
addl %eax,%ebx
movl %ebx,(%edi,%ecx,4)
incl %ecx
movl %edx,%ebx
jnz L(oop2)
adcl $0,%ebx
movl %ebx,(%edi)
addl $4,%edi
movl VAR_COUNTER,%eax
decl %eax
movl %eax,VAR_COUNTER
jnz L(outer)
L(skip):
popl %ebx
popl %edi
popl %ebp
popl %esi
addl $4,%esp
ret
L(done):
movl %edx,4(%edi) C store to wp[1]
popl %edi
popl %ebp
popl %esi
popl %eax C dummy pop for deallocating stack slot
ret
EPILOGUE()
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/storage/common/shared_key_policy.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/strings.hpp"
#include "azure/storage/common/crypt.hpp"
#include <algorithm>
#include <cctype>
namespace Azure { namespace Storage {
std::string SharedKeyPolicy::GetSignature(const Core::Http::Request& request) const
{
std::string string_to_sign;
string_to_sign += Azure::Core::Http::HttpMethodToString(request.GetMethod()) + "\n";
const auto& headers = request.GetHeaders();
for (std::string headerName :
{"Content-Encoding",
"Content-Language",
"Content-Length",
"Content-MD5",
"Content-Type",
"Date",
"If-Modified-Since",
"If-Match",
"If-None-Match",
"If-Unmodified-Since",
"Range"})
{
auto ite = headers.find(Azure::Core::Strings::ToLower(headerName));
if (ite != headers.end())
{
if (headerName == "Content-Length" && ite->second == "0")
{
// do nothing
}
else
{
string_to_sign += ite->second;
}
}
string_to_sign += "\n";
}
// canonicalized headers
const std::string prefix = "x-ms-";
std::vector<std::pair<std::string, std::string>> ordered_kv;
for (auto ite = headers.lower_bound(prefix);
ite != headers.end() && ite->first.substr(0, prefix.length()) == prefix;
++ite)
{
std::string key = Azure::Core::Strings::ToLower(ite->first);
ordered_kv.emplace_back(std::make_pair(std::move(key), ite->second));
}
std::sort(ordered_kv.begin(), ordered_kv.end());
for (const auto& p : ordered_kv)
{
string_to_sign += p.first + ":" + p.second + "\n";
}
ordered_kv.clear();
// canonicalized resource
string_to_sign += "/" + m_credential->AccountName + "/" + request.GetUrl().GetPath() + "\n";
for (const auto& query : request.GetUrl().GetQueryParameters())
{
std::string key = Azure::Core::Strings::ToLower(query.first);
ordered_kv.emplace_back(std::make_pair(
Azure::Core::Http::Url::Decode(key), Azure::Core::Http::Url::Decode(query.second)));
}
std::sort(ordered_kv.begin(), ordered_kv.end());
for (const auto& p : ordered_kv)
{
string_to_sign += p.first + ":" + p.second + "\n";
}
// remove last linebreak
string_to_sign.pop_back();
return Base64Encode(
Details::HmacSha256(string_to_sign, Base64Decode(m_credential->GetAccountKey())));
}
}} // namespace Azure::Storage
|
//
// Created by Kylian Lee on 2021/10/03.
//
#include <iostream>
using namespace std;
int sorted[10001];
int main(){
int num, tmp, cnt = 0;
scanf("%d", &num);
for (int i = 0; i < num; ++i) {
scanf("%d", &tmp);
sorted[tmp]++;
}
for (int i = 1; i <= 10000; ++i) {
if(cnt == num)
break;
if(!sorted[i])
continue;
for (int j = 0; j < sorted[i]; ++j) {
printf("%d\n", i);
cnt++;
}
}
return 0;
} |
#include <codegenvar/Scalar.h>
#include <cmath>
namespace codegenvar {
Scalar::Scalar(double d)
: state(Float)
{
val.d = d;
}
Scalar::Scalar(int i)
: state(Int)
{
val.i = i;
}
Scalar::Scalar(long int i)
: state(Int)
{
val.i = i;
}
Scalar::Scalar(long long int i)
: state(Int)
{
val.i = i;
}
long long Scalar::toInt()const
{
return state==Int ? val.i : std::llround(val.d);
}
double Scalar::toDouble()const
{
return state==Int ? val.i : val.d;
}
bool Scalar::isInt()const
{
return state == Int;
}
bool Scalar::isFloat()const
{
return state == Float;
}
}// namespace codegenvar
|
//===- Error.cxx - system_error extensions for llvm-cxxdump -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This defines a new error_category for the llvm-cxxdump tool.
//
//===----------------------------------------------------------------------===//
#include "Error.h"
#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
namespace {
// FIXME: This class is only here to support the transition to llvm::Error. It
// will be removed once this transition is complete. Clients should prefer to
// deal with the Error value directly, rather than converting to error_code.
class cxxdump_error_category : public std::error_category {
public:
const char *name() const LLVM_NOEXCEPT override { return "llvm.cxxdump"; }
std::string message(int ev) const override {
switch (static_cast<cxxdump_error>(ev)) {
case cxxdump_error::success:
return "Success";
case cxxdump_error::file_not_found:
return "No such file.";
case cxxdump_error::unrecognized_file_format:
return "Unrecognized file type.";
}
llvm_unreachable(
"An enumerator of cxxdump_error does not have a message defined.");
}
};
} // namespace
namespace llvm {
const std::error_category &cxxdump_category() {
static cxxdump_error_category o;
return o;
}
} // namespace llvm
|
; A172481: a(n) = (3*n*2^n+2^(n+4)+2*(-1)^n)/18.
; 1,2,5,11,25,55,121,263,569,1223,2617,5575,11833,25031,52793,111047,233017,487879,1019449,2126279,4427321,9204167,19107385,39612871,82021945,169636295,350457401,723284423,1491308089,3072094663,6323146297,13004206535,26724240953,54880137671,112623586873,230973796807,473400839737,969708171719,1985229327929,4062084624839,8307421187641,16981346251207,34695700254265,70857416012231,144646863031865,295157788078535,602043700186681,1227543648432583,2501999792983609,5097824578204103,10383299140881977,21141898250711495,43034396439318073,87569992754426311,178142385260432953,362289570024026567,736588739054374457,1497196676121391559,3042431748268068409,6180940288586707399,12554034161274555961,25492375490751394247,51753365317907353145,105043959308623835591,213162375962865929785,432473666616968376775,877245162616409787961,1779085983997765644743,3607363285525423427129,7313109206110631129543,14822983682340830809657,30039497904920798720455,60866056890319871643193,123306235941596291690951,249760716205105680191033,505817921054037554000327,1024228819395727495237177,2073643593366759764947399,4197659095884129078840889,8496062010069477255573959,17193611656741392706932281,34790198586687661805433287,70386347719785076394004025,142384596532389658354282951,287992995250418327841115705,582433594872114677947331015,1177762398486785400424861241,2381315214458682889910120903,4814211263887589957941038649,9731584197715628272123670983,19669491735312153256730529337,39751630150386099938427433415,80328553660295786726787616313,162307694039638747153440731591,327916561517371841706612461113,662435469910932378212686918087,1338075633574242146024297827897,2702560654653239071246443639239,5457940084315987700888583245369,11021517718650994518568558424519
add $0,1
lpb $0
mov $2,$0
sub $0,2
seq $2,196410 ; a(n) = n*2^(n-5).
add $1,$2
lpe
div $1,16
add $1,1
mov $0,$1
|
#include <iostream>
#include <string>
#include <string_view>
#include <vector>
#include <assert.h>
class encoder
{
std::string const table_enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char const padding_symbol = '=';
char const table_dec[256] =
{
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,64,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
52,53,54,55,56,57,58,59,60,61,-1,-1,-1,65,-1,-1,
-1, 0, 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,-1,-1,-1,-1,-1,
-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
};
char const invalid_char = -1;
char const padding_char = 65;
public:
std::string to_base64(std::vector<unsigned char> const & data)
{
std::string result;
result.resize((data.size() / 3 + ((data.size() % 3 > 0) ? 1 : 0)) * 4);
auto result_ptr = &result[0];
size_t i = 0;
size_t j = 0;
while (j++ < data.size() / 3)
{
unsigned int value = (data[i] << 16) | (data[i+1] << 8) | data[i+2];
i += 3;
*result_ptr++ = table_enc[(value & 0x00fc0000) >> 18];
*result_ptr++ = table_enc[(value & 0x0003f000) >> 12];
*result_ptr++ = table_enc[(value & 0x00000fc0) >> 6];
*result_ptr++ = table_enc[(value & 0x0000003f)];
};
auto rest = data.size() - i;
if (rest == 1)
{
*result_ptr++ = table_enc[(data[i] & 0x000000fc) >> 2];
*result_ptr++ = table_enc[(data[i] & 0x00000003) << 4];
*result_ptr++ = padding_symbol;
*result_ptr++ = padding_symbol;
}
else if (rest == 2)
{
unsigned int value = (data[i] << 8) | data[i + 1];
*result_ptr++ = table_enc[(value & 0x0000fc00) >> 10];
*result_ptr++ = table_enc[(value & 0x000003f0) >> 4];
*result_ptr++ = table_enc[(value & 0x0000000f) << 2];
*result_ptr++ = padding_symbol;
}
return result;
}
std::vector<unsigned char> from_base64(std::string data)
{
size_t padding = data.size() % 4;
if (padding == 0)
{
if (data[data.size() - 1] == padding_symbol) padding++;
if (data[data.size() - 2] == padding_symbol) padding++;
}
else
{
data.append(2, padding_symbol);
}
std::vector<unsigned char> result;
result.resize((data.length() / 4) * 3 - padding);
auto result_ptr = &result[0];
size_t i = 0;
size_t j = 0;
while (j++ < data.size() / 4)
{
unsigned char c1 = table_dec[static_cast<int>(data[i++])];
unsigned char c2 = table_dec[static_cast<int>(data[i++])];
unsigned char c3 = table_dec[static_cast<int>(data[i++])];
unsigned char c4 = table_dec[static_cast<int>(data[i++])];
if (c1 == invalid_char || c2 == invalid_char ||
c3 == invalid_char || c4 == invalid_char)
throw std::runtime_error("invalid base64 encoding");
if (c4 == padding_char && c3 == padding_char)
{
unsigned int value = (c1 << 6) | c2;
*result_ptr++ = (value >> 4) & 0x000000ff;
}
else if (c4 == padding_char)
{
unsigned int value = (c1 << 12) | (c2 << 6) | c3;
*result_ptr++ = (value >> 10) & 0x000000ff;
*result_ptr++ = (value >> 2) & 0x000000ff;
}
else
{
unsigned int value = (c1 << 18) | (c2 << 12) | (c3 << 6) | c4;
*result_ptr++ = (value >> 16) & 0x000000ff;
*result_ptr++ = (value >> 8) & 0x000000ff;
*result_ptr++ = value & 0x000000ff;
}
}
return result;
}
};
struct converter
{
static std::vector<unsigned char> from_string(std::string_view data)
{
std::vector<unsigned char> result;
std::copy(
std::begin(data), std::end(data),
std::back_inserter(result));
return result;
}
static std::string from_range(std::vector<unsigned char> const & data)
{
std::string result;
std::copy(
std::begin(data), std::end(data),
std::back_inserter(result));
return result;
}
};
int main()
{
std::vector<std::vector<unsigned char>> data
{
{ 's' },
{ 's','a' },
{ 's','a','m' },
{ 's','a','m','p' },
{ 's','a','m','p','l' },
{ 's','a','m','p','l','e' },
};
encoder enc;
for (auto const & v : data)
{
auto encv = enc.to_base64(v);
auto decv = enc.from_base64(encv);
assert(v == decv);
}
auto text = "cppchallenge";
auto textenc = enc.to_base64(converter::from_string(text));
auto textdec = converter::from_range(enc.from_base64(textenc));
assert(text == textdec);
}
|
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <AVSCommon/Utils/HTTP/HttpResponseCode.h>
#include <AVSCommon/Utils/HTTP2/HTTP2MimeRequestEncoder.h>
#include <AVSCommon/Utils/HTTP2/HTTP2MimeResponseDecoder.h>
#include <AVSCommon/Utils/Logger/Logger.h>
#include <AVSCommon/Utils/Metrics/DataPointCounterBuilder.h>
#include <AVSCommon/Utils/Metrics/DataPointStringBuilder.h>
#include <AVSCommon/Utils/Metrics/MetricEventBuilder.h>
#include "ACL/Transport/HTTP2Transport.h"
#include "ACL/Transport/MimeResponseSink.h"
#include "ACL/Transport/MessageRequestHandler.h"
namespace alexaClientSDK {
namespace acl {
using namespace avsCommon::avs::attachment;
using namespace avsCommon::sdkInterfaces;
using namespace avsCommon::utils::http;
using namespace avsCommon::utils::http2;
using namespace avsCommon::utils::metrics;
/// URL to send events to
const static std::string AVS_EVENT_URL_PATH_EXTENSION = "/v20160207/events";
/// Boundary for mime encoded requests
const static std::string MIME_BOUNDARY = "WhooHooZeerOoonie!";
/// Timeout for transmission of data on a given stream
static const std::chrono::seconds STREAM_PROGRESS_TIMEOUT = std::chrono::seconds(15);
/// Mime header strings for mime parts containing json payloads.
static const std::vector<std::string> JSON_MIME_PART_HEADER_LINES = {
"Content-Disposition: form-data; name=\"metadata\"",
"Content-Type: application/json"};
/// Mime Content-Disposition line before name.
static const std::string CONTENT_DISPOSITION_PREFIX = "Content-Disposition: form-data; name=\"";
/// Mime Content-Disposition line after name.
static const std::string CONTENT_DISPOSITION_SUFFIX = "\"";
/// Mime Content-Type for attchments.
static const std::string ATTACHMENT_CONTENT_TYPE = "Content-Type: application/octet-stream";
/// Prefix for the ID of message requests.
static const std::string MESSAGEREQUEST_ID_PREFIX = "AVSEvent-";
/// String to identify log entries originating from this file.
static const std::string TAG("MessageRequestHandler");
/// Prefix used to identify metrics published by this module.
static const std::string ACL_METRIC_SOURCE_PREFIX = "ACL-";
/// Metric identifier for send mime data error
static const std::string SEND_DATA_ERROR = "ERROR.SEND_DATA_ERROR";
/// Read status tag
static const std::string READ_STATUS_TAG = "READ_STATUS";
/// Read overrun error
static const std::string ERROR_READ_OVERRUN = "READ_OVERRUN";
/// Internal error
static const std::string ERROR_INTERNAL = "INTERNAL_ERROR";
/// Send completed
static const std::string SEND_COMPLETED = "SEND_COMPLETED";
/**
* Create a LogEntry using this file's TAG and the specified event string.
*
* @param The event string for this @c LogEntry.
*/
#define LX(event) alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)
/**
* Capture metric for the last send data result.
*
* @param metricRecorder The metric recorder object.
* @param count Number of errors.
* @param readStatus The read status.
*/
static void collectSendDataResultMetric(
const std::shared_ptr<MetricRecorderInterface>& metricRecorder,
int count,
const std::string& readStatus) {
recordMetric(
metricRecorder,
MetricEventBuilder{}
.setActivityName(ACL_METRIC_SOURCE_PREFIX + SEND_DATA_ERROR)
.addDataPoint(DataPointCounterBuilder{}.setName(SEND_DATA_ERROR).increment(count).build())
.addDataPoint(DataPointStringBuilder{}.setName(READ_STATUS_TAG).setValue(readStatus).build())
.build());
}
MessageRequestHandler::~MessageRequestHandler() {
reportMessageRequestAcknowledged();
reportMessageRequestFinished();
}
std::shared_ptr<MessageRequestHandler> MessageRequestHandler::create(
std::shared_ptr<ExchangeHandlerContextInterface> context,
const std::string& authToken,
std::shared_ptr<avsCommon::avs::MessageRequest> messageRequest,
std::shared_ptr<MessageConsumerInterface> messageConsumer,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> attachmentManager,
std::shared_ptr<MetricRecorderInterface> metricRecorder,
std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface> eventTracer) {
ACSDK_DEBUG7(LX(__func__).d("context", context.get()).d("messageRequest", messageRequest.get()));
if (!context) {
ACSDK_CRITICAL(LX("MessageRequestHandlerCreateFailed").d("reason", "nullHttp2Transport"));
return nullptr;
}
if (authToken.empty()) {
ACSDK_DEBUG9(LX("createFailed").d("reason", "emptyAuthToken"));
return nullptr;
}
std::shared_ptr<MessageRequestHandler> handler(
new MessageRequestHandler(context, authToken, messageRequest, std::move(metricRecorder)));
// Allow custom path extension, if provided by the sender of the MessageRequest
auto url = context->getAVSGateway();
if (messageRequest->getUriPathExtension().empty()) {
url += AVS_EVENT_URL_PATH_EXTENSION;
} else {
url += messageRequest->getUriPathExtension();
}
HTTP2RequestConfig cfg{HTTP2RequestType::POST, url, MESSAGEREQUEST_ID_PREFIX};
cfg.setRequestSource(std::make_shared<HTTP2MimeRequestEncoder>(MIME_BOUNDARY, handler));
cfg.setResponseSink(std::make_shared<HTTP2MimeResponseDecoder>(
std::make_shared<MimeResponseSink>(handler, messageConsumer, attachmentManager, cfg.getId())));
cfg.setActivityTimeout(STREAM_PROGRESS_TIMEOUT);
context->onMessageRequestSent();
auto request = context->createAndSendRequest(cfg);
if (!request) {
handler->reportMessageRequestAcknowledged();
handler->reportMessageRequestFinished();
ACSDK_ERROR(LX("MessageRequestHandlerCreateFailed").d("reason", "createAndSendRequestFailed"));
return nullptr;
}
if (eventTracer) {
eventTracer->traceEvent(messageRequest->getJsonContent());
}
return handler;
}
MessageRequestHandler::MessageRequestHandler(
std::shared_ptr<ExchangeHandlerContextInterface> context,
const std::string& authToken,
std::shared_ptr<avsCommon::avs::MessageRequest> messageRequest,
std::shared_ptr<MetricRecorderInterface> metricRecorder) :
ExchangeHandler{context, authToken},
m_messageRequest{messageRequest},
m_json{messageRequest->getJsonContent()},
m_jsonNext{m_json.c_str()},
m_countOfJsonBytesLeft{m_json.size()},
m_countOfPartsSent{0},
m_metricRecorder{metricRecorder},
m_wasMessageRequestAcknowledgeReported{false},
m_wasMessageRequestFinishedReported{false},
m_responseCode{0} {
ACSDK_DEBUG7(LX(__func__).d("context", context.get()).d("messageRequest", messageRequest.get()));
}
void MessageRequestHandler::reportMessageRequestAcknowledged() {
ACSDK_DEBUG7(LX(__func__));
if (!m_wasMessageRequestAcknowledgeReported) {
m_wasMessageRequestAcknowledgeReported = true;
m_context->onMessageRequestAcknowledged();
}
}
void MessageRequestHandler::reportMessageRequestFinished() {
ACSDK_DEBUG7(LX(__func__));
if (!m_wasMessageRequestFinishedReported) {
m_wasMessageRequestFinishedReported = true;
m_context->onMessageRequestFinished();
}
}
std::vector<std::string> MessageRequestHandler::getRequestHeaderLines() {
ACSDK_DEBUG9(LX(__func__));
m_context->onActivity();
return {m_authHeader};
}
HTTP2GetMimeHeadersResult MessageRequestHandler::getMimePartHeaderLines() {
ACSDK_DEBUG9(LX(__func__));
m_context->onActivity();
if (0 == m_countOfPartsSent) {
return HTTP2GetMimeHeadersResult(JSON_MIME_PART_HEADER_LINES);
} else if (static_cast<int>(m_countOfPartsSent) <= m_messageRequest->attachmentReadersCount()) {
m_namedReader = m_messageRequest->getAttachmentReader(m_countOfPartsSent - 1);
if (m_namedReader) {
return HTTP2GetMimeHeadersResult(
{CONTENT_DISPOSITION_PREFIX + m_namedReader->name + CONTENT_DISPOSITION_SUFFIX,
ATTACHMENT_CONTENT_TYPE});
} else {
ACSDK_ERROR(LX("getMimePartHeaderLinesFailed").d("reason", "nullReader").d("index", m_countOfPartsSent));
return HTTP2GetMimeHeadersResult::ABORT;
}
} else {
return HTTP2GetMimeHeadersResult::COMPLETE;
}
}
HTTP2SendDataResult MessageRequestHandler::onSendMimePartData(char* bytes, size_t size) {
ACSDK_DEBUG9(LX(__func__).d("size", size));
m_context->onActivity();
if (0 == m_countOfPartsSent) {
if (m_countOfJsonBytesLeft != 0) {
size_t countToCopy = (m_countOfJsonBytesLeft <= size) ? m_countOfJsonBytesLeft : size;
std::copy(m_jsonNext, m_jsonNext + countToCopy, bytes);
m_jsonNext += countToCopy;
m_countOfJsonBytesLeft -= countToCopy;
return HTTP2SendDataResult(countToCopy);
} else {
m_countOfPartsSent++;
return HTTP2SendDataResult::COMPLETE;
}
} else if (m_namedReader) {
auto readStatus = AttachmentReader::ReadStatus::OK;
auto bytesRead = m_namedReader->reader->read(bytes, size, &readStatus);
ACSDK_DEBUG9(LX("attachmentRead").d("readStatus", (int)readStatus).d("bytesRead", bytesRead));
switch (readStatus) {
// The good cases.
case AttachmentReader::ReadStatus::OK:
case AttachmentReader::ReadStatus::OK_WOULDBLOCK:
case AttachmentReader::ReadStatus::OK_TIMEDOUT:
return bytesRead != 0 ? HTTP2SendDataResult(bytesRead) : HTTP2SendDataResult::PAUSE;
case AttachmentReader::ReadStatus::OK_OVERRUN_RESET:
return HTTP2SendDataResult::ABORT;
case AttachmentReader::ReadStatus::CLOSED:
// Stream consumed. Move on to next part.
m_namedReader.reset();
m_countOfPartsSent++;
collectSendDataResultMetric(m_metricRecorder, 0, SEND_COMPLETED);
return HTTP2SendDataResult::COMPLETE;
// Handle any attachment read errors.
case AttachmentReader::ReadStatus::ERROR_OVERRUN:
collectSendDataResultMetric(m_metricRecorder, 1, ERROR_READ_OVERRUN);
// Stream failure. Abort sending the request.
return HTTP2SendDataResult::ABORT;
case AttachmentReader::ReadStatus::ERROR_INTERNAL:
collectSendDataResultMetric(m_metricRecorder, 1, ERROR_INTERNAL);
// Stream failure. Abort sending the request.
return HTTP2SendDataResult::ABORT;
case AttachmentReader::ReadStatus::ERROR_BYTES_LESS_THAN_WORD_SIZE:
return HTTP2SendDataResult::PAUSE;
}
}
ACSDK_ERROR(LX("onSendMimePartDataFailed").d("reason", "noMoreAttachments"));
return HTTP2SendDataResult::ABORT;
}
void MessageRequestHandler::onActivity() {
m_context->onActivity();
}
bool MessageRequestHandler::onReceiveResponseCode(long responseCode) {
ACSDK_DEBUG7(LX(__func__).d("responseCode", responseCode));
// TODO ACSDK-1839: Provide MessageRequestObserverInterface immediate notification of receipt of response code.
reportMessageRequestAcknowledged();
if (HTTPResponseCode::CLIENT_ERROR_FORBIDDEN == intToHTTPResponseCode(responseCode)) {
m_context->onForbidden(m_authToken);
}
m_responseCode = responseCode;
return true;
}
void MessageRequestHandler::onResponseFinished(HTTP2ResponseFinishedStatus status, const std::string& nonMimeBody) {
ACSDK_DEBUG7(LX(__func__).d("status", status).d("responseCode", m_responseCode));
if (HTTP2ResponseFinishedStatus::TIMEOUT == status) {
m_context->onMessageRequestTimeout();
}
reportMessageRequestAcknowledged();
reportMessageRequestFinished();
if ((intToHTTPResponseCode(m_responseCode) != HTTPResponseCode::SUCCESS_OK) && !nonMimeBody.empty()) {
m_messageRequest->exceptionReceived(nonMimeBody);
}
// Hash to allow use of HTTP2ResponseFinishedStatus as the key in an unordered_map.
struct statusHash {
size_t operator()(const HTTP2ResponseFinishedStatus& key) const {
return static_cast<size_t>(key);
}
};
// Mapping HTTP2ResponseFinishedStatus to a MessageRequestObserverInterface::Status. Note that no mapping is
// provided from the COMPLETE status so that the logic below falls through to map the HTTPResponseCode value
// from the completed requests to the appropriate MessageRequestObserverInterface value.
static const std::unordered_map<HTTP2ResponseFinishedStatus, MessageRequestObserverInterface::Status, statusHash>
statusToResult = {
{HTTP2ResponseFinishedStatus::INTERNAL_ERROR, MessageRequestObserverInterface::Status::INTERNAL_ERROR},
{HTTP2ResponseFinishedStatus::CANCELLED, MessageRequestObserverInterface::Status::CANCELED},
{HTTP2ResponseFinishedStatus::TIMEOUT, MessageRequestObserverInterface::Status::TIMEDOUT}};
// Map HTTPResponseCode values to MessageRequestObserverInterface::Status values.
static const std::unordered_map<long, MessageRequestObserverInterface::Status> responseToResult = {
{HTTPResponseCode::HTTP_RESPONSE_CODE_UNDEFINED, MessageRequestObserverInterface::Status::INTERNAL_ERROR},
{HTTPResponseCode::SUCCESS_OK, MessageRequestObserverInterface::Status::SUCCESS},
{HTTPResponseCode::SUCCESS_ACCEPTED, MessageRequestObserverInterface::Status::SUCCESS_ACCEPTED},
{HTTPResponseCode::SUCCESS_NO_CONTENT, MessageRequestObserverInterface::Status::SUCCESS_NO_CONTENT},
{HTTPResponseCode::CLIENT_ERROR_BAD_REQUEST, MessageRequestObserverInterface::Status::BAD_REQUEST},
{HTTPResponseCode::CLIENT_ERROR_FORBIDDEN, MessageRequestObserverInterface::Status::INVALID_AUTH},
{HTTPResponseCode::SERVER_ERROR_INTERNAL, MessageRequestObserverInterface::Status::SERVER_INTERNAL_ERROR_V2}};
auto result = MessageRequestObserverInterface::Status::INTERNAL_ERROR;
if (HTTP2ResponseFinishedStatus::COMPLETE == status) {
auto responseIterator = responseToResult.find(m_responseCode);
if (responseIterator != responseToResult.end()) {
result = responseIterator->second;
} else {
result = MessageRequestObserverInterface::Status::SERVER_OTHER_ERROR;
}
} else {
auto statusIterator = statusToResult.find(status);
if (statusIterator != statusToResult.end()) {
result = statusIterator->second;
}
}
m_messageRequest->sendCompleted(result);
}
} // namespace acl
} // namespace alexaClientSDK
|
include w2.inc
include noxport.inc
include consts.inc
include structs.inc
createSeg index2_PCODE,index2,byte,public,CODE
; DEBUGGING DECLARATIONS
ifdef DEBUG
midIndex2n equ 34 ; module ID, for native asserts
endif
; EXTERNAL FUNCTIONS
externFP <N_WCompSzSrt>
externFP <ReloadSb>
ifdef DEBUG
externFP <AssertProcForNative>
externFP <S_WCompSzSrt>
endif ;DEBUG
sBegin data
; EXTERNALS
externW mpsbps
; #ifdef DEBUG
ifdef DEBUG
externW vcComps
externW wFillBlock
; #endif /* DEBUG */
endif
sEnd data
; CODE SEGMENT _INDEX2
sBegin index2
assumes cs,index2
assumes ds,dgroup
assumes ss,dgroup
;-------------------------------------------------------------------------
; WCompRgchIndex(hpch1, cch1, hpch2, cch2)
;-------------------------------------------------------------------------
;/* W C O M P R G C H I N D E X */
;/* Routine to compare RGCH1 and RGCH2
; Return:
; 0 if rgch1 = rgch2
; negative if rgch1 < rgch2
; positive if rgch1 > rgch2
; This routine is case-insensitive
; soft hyphens are ignored in the comparison
;*/
; %%Function:WCompRgchIndex %%Owner:BRADV
;HANDNATIVE int WCompRgchIndex(hpch1, cch1, hpch2, cch2)
;char HUGE *hpch1, HUGE *hpch2;
;int cch1, cch2;
;{
; char *pch;
; char HUGE *hpchLim;
; char sz1[cchMaxEntry+2];
; char sz2[cchMaxEntry+2];
cProc N_WCompRgchIndex,<PUBLIC,FAR,ATOMIC>,<si,di>
ParmD hpch1
OFFBP_hpch1 = -4
ParmW cch1
OFFBP_cch1 = -6
ParmD hpch2
OFFBP_hpch2 = -10
ParmW cch2
OFFBP_cch2 = -12
LocalV sz1,<cchMaxEntry+2>
LocalV sz2,<cchMaxEntry+2>
cBegin
; Debug(++vcComps);
ifdef DEBUG
inc [vcComps]
endif ;DEBUG
; Assert(cch1 < cchMaxEntry);
; for (pch = sz1, hpchLim = hpch1 + cch1;
; hpch1 < hpchLim; hpch1++)
; {
; if (*hpch1 != chNonReqHyphen)
; *pch++ = *hpch1;
; }
; *pch = 0;
lea si,[sz1]
push si ;argument for WCompSzSrt
lea di,[hpch1]
call WCRI01
; Assert(cch2 < cchMaxEntry);
; for (pch = sz2, hpchLim = hpch2 + cch2;
; hpch2 < hpchLim; hpch2++)
; {
; if (*hpch2 != chNonReqHyphen)
; *pch++ = *hpch2;
; }
; *pch = 0;
lea si,[sz2]
push si ;argument for WCompSzSrt
lea di,[hpch2]
call WCRI01
; return (WCompSzSrt(sz1, sz2, fFalse /* not case sensitive */));
errnz <fFalse>
xor ax,ax
push ax
ifdef DEBUG
cCall S_WCompSzSrt,<>
else ;not DEBUG
cCall N_WCompSzSrt,<>
endif ;DEBUG
;}
cEnd
WCRI01:
; Assert(cch < cchMaxEntry);
ifdef DEBUG
errnz <OFFBP_hpch1 - OFFBP_cch1 - 2>
errnz <OFFBP_hpch2 - OFFBP_cch2 - 2>
cmp wptr [di+(OFFBP_cch1 - OFFBP_hpch1)],cchMaxEntry
jb WCRI02
push ax
push bx
push cx
push dx
mov ax,midIndex2n
mov bx,1001 ; label # for native assert
cCall AssertProcForNative, <ax, bx>
pop dx
pop cx
pop bx
pop ax
WCRI02:
endif ;DEBUG
; for (pch = sz, hpchLim = hpch + cch;
; hpch < hpchLim; hpch++)
; {
; if (*hpch != chNonReqHyphen)
; *pch++ = *hpch;
; }
mov bx,[di+2] ;get SEG_hpch
shl bx,1
mov ax,mpsbps[bx]
mov es,ax
shr ax,1
jc WCRI03
; reload sb trashes ax, cx, and dx
cCall ReloadSb,<>
ifdef DEBUG
mov ax,[wFillBlock]
mov bx,[wFillBlock]
mov cx,[wFillBlock]
mov dx,[wFillBlock]
endif ;DEBUG
WCRI03:
errnz <OFFBP_hpch1 - OFFBP_cch1 - 2>
errnz <OFFBP_hpch2 - OFFBP_cch2 - 2>
mov cx,[di+(OFFBP_cch1 - OFFBP_hpch1)]
mov di,[di] ;get OFF_hpch
mov al,chNonReqHyphen
WCRI04:
mov dx,di
repne scasb ;look for chNonReqHyphen
push cx
push di
push es
pop ds
push ss
pop es
mov cx,di
mov di,si
mov si,dx
jne WCRI05 ;if we found a chNonReqHyphen, don't copy it
dec cx
WCRI05:
sub cx,dx
rep movsb ;copy up to the chNonReqHyphen or end of rgch
mov si,di
push ds
pop es
push ss
pop ds
pop di
pop cx
or cx,cx ;more characters in rgch?
jne WCRI04 ;yes - look for more chNonReqHyphens
; *pch = 0;
mov bptr [si],0
ret
; End of WCompRgchIndex
sEnd index2
end
|
; /*****************************************************************************
; * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
; *****************************************************************************
; * Copyright 2021-2022 Marco Spedaletti (asimov@mclink.it)
; *
; * Licensed under the Apache License, Version 2.0 (the "License");
; * you may not use this file except in compliance with the License.
; * You may obtain a copy of the License at
; *
; * http://www.apache.org/licenses/LICENSE-2.0
; *
; * Unless required by applicable law or agreed to in writing, software
; * distributed under the License is distributed on an "AS IS" BASIS,
; * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; * See the License for the specific language governing permissions and
; * limitations under the License.
; *----------------------------------------------------------------------------
; * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
; * (la "Licenza"); è proibito usare questo file se non in conformità alla
; * Licenza. Una copia della Licenza è disponibile all'indirizzo:
; *
; * http://www.apache.org/licenses/LICENSE-2.0
; *
; * Se non richiesto dalla legislazione vigente o concordato per iscritto,
; * il software distribuito nei termini della Licenza è distribuito
; * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
; * implicite. Consultare la Licenza per il testo specifico che regola le
; * autorizzazioni e le limitazioni previste dalla medesima.
; ****************************************************************************/
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;* *
;* VERTICAL SCROLL ON TED *
;* *
;* by Marco Spedaletti *
;* *
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
VSCROLLT:
TXA
PHA
TYA
PHA
LDA DIRECTION
CMP #$80
BCC VSCROLLTDOWN
VSCROLLTUP:
LDA TEXTADDRESS
STA COPYOFTEXTADDRESS
LDA TEXTADDRESS+1
STA COPYOFTEXTADDRESS+1
LDA COLORMAPADDRESS
STA COPYOFCOLORMAPADDRESS
LDA COLORMAPADDRESS+1
STA COPYOFCOLORMAPADDRESS+1
CLC
LDA TEXTADDRESS
ADC #40
STA COPYOFTEXTADDRESS2
LDA TEXTADDRESS+1
ADC #0
STA COPYOFTEXTADDRESS2+1
CLC
LDA COLORMAPADDRESS
ADC #40
STA COPYOFCOLORMAPADDRESS2
LDA COLORMAPADDRESS+1
ADC #0
STA COPYOFCOLORMAPADDRESS2+1
LDX #3
LDY #0
VSCROLLTUPYSCR:
LDA (COPYOFTEXTADDRESS2),Y
STA (COPYOFTEXTADDRESS),Y
LDA (COPYOFCOLORMAPADDRESS2),Y
STA (COPYOFCOLORMAPADDRESS),Y
INY
BNE VSCROLLTUPYSCR
INC COPYOFTEXTADDRESS+1
INC COPYOFTEXTADDRESS2+1
INC COPYOFCOLORMAPADDRESS+1
INC COPYOFCOLORMAPADDRESS2+1
CPX #1
BNE VSCROLLTUPYSCRNXT
VSCROLLTUPYSCR2:
LDA (COPYOFTEXTADDRESS2),Y
STA (COPYOFTEXTADDRESS),Y
LDA (COPYOFCOLORMAPADDRESS2),Y
STA (COPYOFCOLORMAPADDRESS),Y
INY
CPY #192
BNE VSCROLLTUPYSCR2
VSCROLLTUPYSCRNXT:
DEX
BNE VSCROLLTUPYSCR
LDY #192
VSCROLLTUPREFILL:
LDA #32
STA (COPYOFTEXTADDRESS),Y
LDA #$FF
STA (COPYOFCOLORMAPADDRESS),Y
INY
CPY #232
BNE VSCROLLTUPREFILL
VSCROLLTUEND:
PLA
TAY
PLA
TAX
RTS
VSCROLLTDOWN:
LDA TEXTADDRESS
STA COPYOFTEXTADDRESS
LDA TEXTADDRESS+1
STA COPYOFTEXTADDRESS+1
LDA COLORMAPADDRESS
STA COPYOFCOLORMAPADDRESS
LDA COLORMAPADDRESS+1
STA COPYOFCOLORMAPADDRESS+1
CLC
LDA TEXTADDRESS
ADC #40
STA COPYOFTEXTADDRESS2
LDA TEXTADDRESS+1
ADC #0
STA COPYOFTEXTADDRESS2+1
CLC
LDA COLORMAPADDRESS
ADC #40
STA COPYOFCOLORMAPADDRESS2
LDA COLORMAPADDRESS+1
ADC #0
STA COPYOFCOLORMAPADDRESS2+1
INC COPYOFTEXTADDRESS+1
INC COPYOFTEXTADDRESS2+1
INC COPYOFTEXTADDRESS+1
INC COPYOFTEXTADDRESS2+1
INC COPYOFTEXTADDRESS+1
INC COPYOFTEXTADDRESS2+1
INC COPYOFCOLORMAPADDRESS+1
INC COPYOFCOLORMAPADDRESS2+1
INC COPYOFCOLORMAPADDRESS+1
INC COPYOFCOLORMAPADDRESS2+1
INC COPYOFCOLORMAPADDRESS+1
INC COPYOFCOLORMAPADDRESS2+1
LDY #232
VSCROLLTDOWNYS3:
LDA (COPYOFTEXTADDRESS),Y
STA (COPYOFTEXTADDRESS2),Y
LDA (COPYOFCOLORMAPADDRESS),Y
STA (COPYOFCOLORMAPADDRESS2),Y
DEY
CPY #255
BNE VSCROLLTDOWNYS3
DEC COPYOFTEXTADDRESS+1
DEC COPYOFTEXTADDRESS2+1
DEC COPYOFCOLORMAPADDRESS+1
DEC COPYOFCOLORMAPADDRESS2+1
LDX #3
LDY #255
VSCROLLTDOWNYS4:
LDA (COPYOFTEXTADDRESS),Y
STA (COPYOFTEXTADDRESS2),Y
LDA (COPYOFCOLORMAPADDRESS),Y
STA (COPYOFCOLORMAPADDRESS2),Y
DEY
CPY #255
BNE VSCROLLTDOWNYS4
DEC COPYOFTEXTADDRESS+1
DEC COPYOFTEXTADDRESS2+1
DEC COPYOFCOLORMAPADDRESS+1
DEC COPYOFCOLORMAPADDRESS2+1
LDY #255
DEX
BNE VSCROLLTDOWNYS4
LDA TEXTADDRESS
STA COPYOFTEXTADDRESS
LDA TEXTADDRESS+1
STA COPYOFTEXTADDRESS+1
LDA COLORMAPADDRESS
STA COPYOFCOLORMAPADDRESS
LDA COLORMAPADDRESS+1
STA COPYOFCOLORMAPADDRESS+1
LDY #0
SCROLLFILLUP:
LDA EMPTYTILE
STA (COPYOFTEXTADDRESS),Y
LDA #$FF
STA (COPYOFCOLORMAPADDRESS),Y
INY
CPY #40
BNE SCROLLFILLUP
PLA
TYA
PLA
TXA
RTS
|
/* LSOracle: A learning based Oracle for Logic Synthesis
* MIT License
* Copyright 2019 Laboratory for Nano Integrated Systems (LNIS)
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <alice/alice.hpp>
#include <mockturtle/mockturtle.hpp>
#include <stdio.h>
#include <fstream>
#include <sys/stat.h>
#include <stdlib.h>
namespace alice
{
class test_sort_fanout_command : public alice::command
{
public:
explicit test_sort_fanout_command(const environment::ptr &env)
: command(env, "Order the nodes by fanout count")
{
add_flag("--mig,-m", "Use stored MIG (AIG network is default)");
}
protected:
void execute()
{
if (is_set("mig")) {
if (!store<mockturtle::mig_network>().empty()) {
auto ntk = store<mockturtle::mig_network>().current();
mockturtle::fanout_view<mockturtle::mig_network> fanout_ntk{ntk};
// std::vector<mockturtle::mig_network::node> nodes = ntk._storage->nodes;
ntk.foreach_node([&](auto node) {
env->out() << "Node = " << node << " fanout_size = " << fanout_ntk.fanout(
node).size() << "\n";
});
// std::sort(ntk._storage->nodes.begin(), ntk._storage->nodes.end(), less_than_fanout());
// for(int i = 0; i < ntk._storage->nodes.size(); i++){
// env->out() << "Node = " << ntk._storage->nodes[i] << " fanout_size = " << fanout_ntk.fanout(ntk._storage->nodes[i]).size() << "\n";
// }
} else {
env->err() << "MIG network not stored\n";
}
} else {
if (!store<mockturtle::aig_network>().empty()) {
auto ntk = store<mockturtle::aig_network>().current();
mockturtle::fanout_view<mockturtle::aig_network> fanout_ntk{ntk};
// std::vector<mockturtle::mig_network::node> nodes = ntk._storage->nodes;
ntk.foreach_node([&](auto node) {
env->out() << "Node = " << node << " fanout_size = " << fanout_ntk.fanout(
node).size() << "\n";
});
// std::sort(ntk._storage->nodes.begin(), ntk._storage->nodes.end(), less_than_fanout());
// for(int i = 0; i < ntk._storage->nodes.size(); i++){
// env->out() << "Node = " << ntk._storage->nodes[i] << " fanout_size = " << fanout_ntk.fanout(ntk._storage->nodes[i]).size() << "\n";
// }
} else {
env->err() << "AIG network not stored\n";
}
}
}
private:
// struct less_than_fanout
// {
// inline bool operator() (const mockturtle::mig_network::node& node1, const mockturtle::mig_network::node& node2)
// {
// return (fanout_ntk.fanout(node1).size() < fanout_ntk.fanout(node2).size());
// }
// };
};
ALICE_ADD_COMMAND(test_sort_fanout, "Testing");
}
|
; A289189: Upper bound for certain restricted sumsets.
; 3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10
add $0,1
mov $1,4
lpb $0
sub $0,$1
add $1,2
lpe
div $1,2
add $1,1
mov $0,$1
|
; A047573: Numbers that are congruent to {0, 1, 2, 4, 5, 6, 7} mod 8.
; 0,1,2,4,5,6,7,8,9,10,12,13,14,15,16,17,18,20,21,22,23,24,25,26,28,29,30,31,32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,52,53,54,55,56,57,58,60,61,62,63,64,65,66,68,69,70,71,72,73,74,76,77,78,79,80,81
mul $0,8
add $0,4
div $0,7
|
; A273791: First differences of number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 931", based on the 5-celled von Neumann neighborhood.
; 4,20,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,224,232,240,248,256,264,272,280,288,296,304,312,320,328,336,344,352,360,368,376,384,392,400,408,416,424,432,440,448,456,464,472,480,488,496,504,512,520,528,536,544,552,560,568,576,584,592,600,608,616,624,632,640,648,656,664,672,680,688,696,704,712,720,728,736,744,752,760,768,776,784,792,800
mul $0,2
mov $1,$0
sub $1,1
div $0,$1
add $0,$1
add $0,2
mul $0,4
|
/// @file
/// @author David Pilger <dpilger26@gmail.com>
/// [GitHub Repository](https://github.com/dpilger26/NumCpp)
/// @version 1.2
///
/// @section License
/// Copyright 2019 David Pilger
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this
/// software and associated documentation files(the "Software"), to deal in the Software
/// without restriction, including without limitation the rights to use, copy, modify,
/// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
/// permit persons to whom the Software is furnished to do so, subject to the following
/// conditions :
///
/// The above copyright notice and this permission notice shall be included in all copies
/// or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
/// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/// PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
/// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
/// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
/// DEALINGS IN THE SOFTWARE.
///
/// @section Description
/// Special Functions
///
#pragma once
#include "NumCpp/NdArray.hpp"
#include "NumCpp/Core/StlAlgorithms.hpp"
#include "NumCpp/Core/Types.hpp"
#include "NumCpp/Functions/exp.hpp"
namespace nc
{
namespace special
{
//============================================================================
// Method Description:
/// The softmax function transforms each element of a collection by computing
/// the exponential of each element divided by the sum of the exponentials of all
/// the elements. That is, if x is a one-dimensional numpy array:
/// softmax(x) = np.exp(x)/sum(np.exp(x))
///
/// @param inArray
/// @param inAxis (Optional, default NONE)
/// @return NdArray<double>
///
template<typename T>
NdArray<double> softmax(const NdArray<T>& inArray, Axis inAxis = Axis::NONE) noexcept
{
switch (inAxis)
{
case Axis::NONE:
{
auto returnArray = exp(inArray);
returnArray /= returnArray.sum().item();
return returnArray;
}
case Axis::COL:
{
auto returnArray = exp(inArray);
auto expSums = returnArray.sum(inAxis);
for (uint32 row = 0; row < returnArray.shape().rows; ++row)
{
double rowExpSum = expSums[row];
stl_algorithms::for_each(returnArray.begin(row), returnArray.end(row),
[rowExpSum](double& value) { value /= rowExpSum; });
}
return returnArray;
}
case Axis::ROW:
{
auto returnArray = exp(inArray).transpose();
auto expSums = returnArray.sum(inAxis);
for (uint32 row = 0; row < returnArray.shape().rows; ++row)
{
double rowExpSum = expSums[row];
stl_algorithms::for_each(returnArray.begin(row), returnArray.end(row),
[rowExpSum](double& value) { value /= rowExpSum; });
}
return returnArray.transpose();
}
default:
{
// this isn't actually possible, just putting this here to get rid
// of the compiler warning.
return NdArray<double>(0);
}
}
}
}
}
|
; $Id: jentzsch2.asm 299 2008-11-10 02:17:18Z phf $
;
; Thomas Jentzsch <tjentzsch@web.de> test case for bug
; in error handling.
processor 6502
include vcs.h
ORG $f800
Start
ldz #$00 ; illegal mnemonic
bpl .error ; undefined label
org $fffc
.word Start
.word Start
|
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include "SL.h"
#include "SL_user.h"
#include "SL_kinematics.h"
#include "SL_dynamics.h"
using namespace std;
static void fillState(SL_DJstate* desiredState);
static void matlabLog(int numOfTests, int* iterations, double* tests, const std::string& subject);
/* This main is supposed to be used to test the inverse dynamics routines */
int main(int argc, char**argv)
{
if(argc < 2) {
cerr << "Please provide the number of tests to perform" << endl;
return -1;
}
int numOfTests = std::atoi(argv[1]);
double sl[numOfTests];
int iterations[numOfTests];
double t0, duration, sl_total;
sl_total = 0;
int t=0,i=0;
SL_Jstate currentState[N_ROBOT_DOFS];
SL_DJstate desiredState[N_ROBOT_DOFS];
SL_endeff endeffector[N_ROBOT_ENDEFFECTORS];
SL_Cstate basePosition;
SL_quat baseOrient;
init_kinematics();
if( ! init_dynamics() ) {
cerr << "Error in init_dynamics()" << endl;
exit(-1);
}
for(i=0; i<N_ROBOT_DOFS; i++) {
currentState[i].th = 0;
currentState[i].thd = 0;
currentState[i].thdd = 0;
desiredState[i].th = 0;
desiredState[i].thd = 0;
desiredState[i].thdd = 0;
desiredState[i].uff = 0;
desiredState[i].uex = 0;
}
// Zeroes out every end effector:
for(int e=1; e<=N_ENDEFFS; e++) {
endeffector[e].m = 0;
for(i=0; i<=N_CART; i++) {
endeffector[e].x[i] = 0;
endeffector[e].a[i] = 0;
}
}
for(i=0; i<=N_CART; i++) {
basePosition.x[i] = 0;
basePosition.xd[i] = 0;
basePosition.xdd[i] = 0;
}
baseOrient.q[_Q0_] = 1;
baseOrient.q[_Q1_] = 0;
baseOrient.q[_Q2_] = 0;
baseOrient.q[_Q3_] = 0;
// This restores the default end effector parameters (ie non zero values as opposed
// to what we did above): for some reason this makes inverse dynamics much slower (???)
//setDefaultEndeffector();
std::srand(std::time(NULL)); // initialize random number generator
/*
// Prints numerical results, for comparison
fillState(desiredState);
SL_InvDynNE(NULL, desiredState, endeffector, &basePosition, &baseOrient);
cout << "SL:" << endl
<< desiredState[rf_haa_joint].uff << endl
<< desiredState[rf_hfe_joint].uff << endl
<< desiredState[rf_kfe_joint].uff << endl
<< desiredState[lf_haa_joint].uff << endl
<< desiredState[lf_hfe_joint].uff << endl
<< desiredState[lf_kfe_joint].uff << endl
<< desiredState[rh_haa_joint].uff << endl
<< desiredState[rh_hfe_joint].uff << endl
<< desiredState[rh_kfe_joint].uff << endl
<< desiredState[lh_haa_joint].uff << endl
<< desiredState[lh_hfe_joint].uff << endl
<< desiredState[lh_kfe_joint].uff << endl
;
return 1;
//*/
int numOfIterations = 1;
for(t=0; t<numOfTests; t++) {
sl_total = 0;
numOfIterations = numOfIterations * 10;
iterations[t] = numOfIterations;
for(i=0; i<numOfIterations; i++) {
fillState(desiredState);
t0 = std::clock();
SL_InvDynNE(NULL, desiredState, endeffector, &basePosition, &baseOrient);
duration = std::clock() - t0;
sl_total += duration;
}
sl[t] = sl_total/CLOCKS_PER_SEC;
}
for(int t=0; t<numOfTests; t++) {
cout << sl[t] << endl;
}
matlabLog(numOfTests, iterations, sl, "inv_dyn");
return TRUE;
}
void fillState(SL_DJstate* desiredState) {
static const double max = 12.3;
for(int i=0; i<N_ROBOT_DOFS; i++) {
desiredState[i].th = ( ((double)std::rand()) / RAND_MAX) * max;
desiredState[i].thd = ( ((double)std::rand()) / RAND_MAX) * max;
desiredState[i].thdd = ( ((double)std::rand()) / RAND_MAX) * max;
}
}
static void matlabLog(int numOfTests, int* iterations, double* tests, const std::string& subject) {
std::string fileName = "popi_" + subject + "_speed_test_data.m";
ofstream out(fileName.c_str());
out << "popi_test.robot = 'popi';" << std::endl;
out << "popi_test.description = 'test of the speed of the calculation of: " << subject << "';" << std::endl;
out << "popi_test.software = 'SL';" << std::endl;
// Current date/time based on current system
time_t now = std::time(0);
tm* localtm = std::localtime(&now); // Convert now to tm struct for local timezone
char timeStr[64];
std::strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %X",localtm);
out << "popi_test.date = '" << timeStr << "';" << std::endl;
out << "popi_test.iterations = [";
for(int t=0; t<numOfTests; t++) {
out << " " << iterations[t];
}
out << "];" << endl;
out << "popi_test.times = [";
for(int t=0; t<numOfTests; t++) {
out << " " << tests[t];
}
out << "];" << endl;
out.close();
}
|
/*
Copyright (C) 2013-2018 Draios Inc dba Sysdig.
This file is part of sysdig.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
//
// Why isn't this parser written using antlr or some other parser generator?
// Essentially, after dealing with that stuff multiple times in the past, and fighting for a day
// to configure everything with crappy documentation and code that doesn't compile,
// I decided that I agree with this http://mortoray.com/2012/07/20/why-i-dont-use-a-parser-generator/
// and that I'm going with a manually written parser. The grammar is simple enough that it's not
// going to take more time. On the other hand I will avoid a crappy dependency that breaks my
// code at every new release, and I will have a cleaner and easier to understand code base.
//
#ifdef _WIN32
#define NOMINMAX
#endif
#include <regex>
#include <algorithm>
#include "sinsp.h"
#include "sinsp_int.h"
#include "utils.h"
#ifdef HAS_FILTERING
#include "filter.h"
#include "filterchecks.h"
#include "value_parser.h"
#ifndef _WIN32
#include "arpa/inet.h"
#endif
#ifndef _GNU_SOURCE
//
// Fallback implementation of memmem
//
void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen);
#endif
#ifdef _WIN32
#pragma comment(lib, "Ws2_32.lib")
#include <WinSock2.h>
#else
#include <netdb.h>
#endif
extern sinsp_filter_check_list g_filterlist;
///////////////////////////////////////////////////////////////////////////////
// sinsp_filter_check_list implementation
///////////////////////////////////////////////////////////////////////////////
sinsp_filter_check_list::sinsp_filter_check_list()
{
//////////////////////////////////////////////////////////////////////////////
// ADD NEW FILTER CHECK CLASSES HERE
//////////////////////////////////////////////////////////////////////////////
add_filter_check(new sinsp_filter_check_fd());
add_filter_check(new sinsp_filter_check_thread());
add_filter_check(new sinsp_filter_check_event());
add_filter_check(new sinsp_filter_check_user());
add_filter_check(new sinsp_filter_check_group());
add_filter_check(new sinsp_filter_check_syslog());
add_filter_check(new sinsp_filter_check_container());
add_filter_check(new sinsp_filter_check_utils());
add_filter_check(new sinsp_filter_check_fdlist());
#ifndef CYGWING_AGENT
add_filter_check(new sinsp_filter_check_k8s());
add_filter_check(new sinsp_filter_check_mesos());
#endif
add_filter_check(new sinsp_filter_check_tracer());
add_filter_check(new sinsp_filter_check_evtin());
}
sinsp_filter_check_list::~sinsp_filter_check_list()
{
uint32_t j;
for(j = 0; j < m_check_list.size(); j++)
{
delete m_check_list[j];
}
}
void sinsp_filter_check_list::add_filter_check(sinsp_filter_check* filter_check)
{
m_check_list.push_back(filter_check);
}
void sinsp_filter_check_list::get_all_fields(OUT vector<const filter_check_info*>* list)
{
uint32_t j;
for(j = 0; j < m_check_list.size(); j++)
{
list->push_back((const filter_check_info*)&(m_check_list[j]->m_info));
}
}
sinsp_filter_check* sinsp_filter_check_list::new_filter_check_from_fldname(const string& name,
sinsp* inspector,
bool do_exact_check)
{
uint32_t j;
for(j = 0; j < m_check_list.size(); j++)
{
m_check_list[j]->m_inspector = inspector;
int32_t fldnamelen = m_check_list[j]->parse_field_name(name.c_str(), false, true);
if(fldnamelen != -1)
{
if(do_exact_check)
{
if((int32_t)name.size() != fldnamelen)
{
goto field_not_found;
}
}
sinsp_filter_check* newchk = m_check_list[j]->allocate_new();
newchk->set_inspector(inspector);
return newchk;
}
}
field_not_found:
//
// If you are implementing a new filter check and this point is reached,
// it's very likely that you've forgotten to add your filter to the list in
// the constructor
//
return NULL;
}
sinsp_filter_check* sinsp_filter_check_list::new_filter_check_from_another(sinsp_filter_check *chk)
{
sinsp_filter_check *newchk = chk->allocate_new();
newchk->m_inspector = chk->m_inspector;
newchk->m_field_id = chk->m_field_id;
newchk->m_field = &chk->m_info.m_fields[chk->m_field_id];
newchk->m_boolop = chk->m_boolop;
newchk->m_cmpop = chk->m_cmpop;
return newchk;
}
///////////////////////////////////////////////////////////////////////////////
// type-based comparison functions
///////////////////////////////////////////////////////////////////////////////
bool flt_compare_uint64(cmpop op, uint64_t operand1, uint64_t operand2)
{
switch(op)
{
case CO_EQ:
return (operand1 == operand2);
case CO_NE:
return (operand1 != operand2);
case CO_LT:
return (operand1 < operand2);
case CO_LE:
return (operand1 <= operand2);
case CO_GT:
return (operand1 > operand2);
case CO_GE:
return (operand1 >= operand2);
case CO_CONTAINS:
throw sinsp_exception("'contains' not supported for numeric filters");
return false;
case CO_ICONTAINS:
throw sinsp_exception("'icontains' not supported for numeric filters");
return false;
case CO_STARTSWITH:
throw sinsp_exception("'startswith' not supported for numeric filters");
return false;
case CO_ENDSWITH:
throw sinsp_exception("'endswith' not supported for numeric filters");
return false;
case CO_GLOB:
throw sinsp_exception("'glob' not supported for numeric filters");
return false;
default:
throw sinsp_exception("'unknown' not supported for numeric filters");
return false;
}
}
bool flt_compare_int64(cmpop op, int64_t operand1, int64_t operand2)
{
switch(op)
{
case CO_EQ:
return (operand1 == operand2);
case CO_NE:
return (operand1 != operand2);
case CO_LT:
return (operand1 < operand2);
case CO_LE:
return (operand1 <= operand2);
case CO_GT:
return (operand1 > operand2);
case CO_GE:
return (operand1 >= operand2);
case CO_CONTAINS:
throw sinsp_exception("'contains' not supported for numeric filters");
return false;
case CO_ICONTAINS:
throw sinsp_exception("'icontains' not supported for numeric filters");
return false;
case CO_STARTSWITH:
throw sinsp_exception("'startswith' not supported for numeric filters");
return false;
case CO_ENDSWITH:
throw sinsp_exception("'endswith' not supported for numeric filters");
return false;
case CO_GLOB:
throw sinsp_exception("'glob' not supported for numeric filters");
return false;
default:
throw sinsp_exception("'unknown' not supported for numeric filters");
return false;
}
}
bool flt_compare_string(cmpop op, char* operand1, char* operand2)
{
switch(op)
{
case CO_EQ:
return (strcmp(operand1, operand2) == 0);
case CO_NE:
return (strcmp(operand1, operand2) != 0);
case CO_CONTAINS:
return (strstr(operand1, operand2) != NULL);
case CO_ICONTAINS:
#ifdef _WIN32
return (_strnicmp(operand1, operand2, strlen(operand1)) != NULL);
#else
return (strcasestr(operand1, operand2) != NULL);
#endif
case CO_STARTSWITH:
return (strncmp(operand1, operand2, strlen(operand2)) == 0);
case CO_ENDSWITH:
return (sinsp_utils::endswith(operand1, operand2));
case CO_GLOB:
return sinsp_utils::glob_match(operand2, operand1);
case CO_LT:
return (strcmp(operand1, operand2) < 0);
case CO_LE:
return (strcmp(operand1, operand2) <= 0);
case CO_GT:
return (strcmp(operand1, operand2) > 0);
case CO_GE:
return (strcmp(operand1, operand2) >= 0);
default:
ASSERT(false);
throw sinsp_exception("invalid filter operator " + std::to_string((long long) op));
return false;
}
}
bool flt_compare_buffer(cmpop op, char* operand1, char* operand2, uint32_t op1_len, uint32_t op2_len)
{
switch(op)
{
case CO_EQ:
return op1_len == op2_len && (memcmp(operand1, operand2, op1_len) == 0);
case CO_NE:
return op1_len != op2_len || (memcmp(operand1, operand2, op1_len) != 0);
case CO_CONTAINS:
return (memmem(operand1, op1_len, operand2, op2_len) != NULL);
case CO_ICONTAINS:
throw sinsp_exception("'icontains' not supported for buffer filters");
case CO_STARTSWITH:
return (memcmp(operand1, operand2, op2_len) == 0);
case CO_ENDSWITH:
return (sinsp_utils::endswith(operand1, operand2, op1_len, op2_len));
case CO_GLOB:
throw sinsp_exception("'glob' not supported for buffer filters");
case CO_LT:
throw sinsp_exception("'<' not supported for buffer filters");
case CO_LE:
throw sinsp_exception("'<=' not supported for buffer filters");
case CO_GT:
throw sinsp_exception("'>' not supported for buffer filters");
case CO_GE:
throw sinsp_exception("'>=' not supported for buffer filters");
default:
ASSERT(false);
throw sinsp_exception("invalid filter operator " + std::to_string((long long) op));
return false;
}
}
bool flt_compare_double(cmpop op, double operand1, double operand2)
{
switch(op)
{
case CO_EQ:
return (operand1 == operand2);
case CO_NE:
return (operand1 != operand2);
case CO_LT:
return (operand1 < operand2);
case CO_LE:
return (operand1 <= operand2);
case CO_GT:
return (operand1 > operand2);
case CO_GE:
return (operand1 >= operand2);
case CO_CONTAINS:
throw sinsp_exception("'contains' not supported for numeric filters");
return false;
case CO_ICONTAINS:
throw sinsp_exception("'icontains' not supported for numeric filters");
return false;
case CO_STARTSWITH:
throw sinsp_exception("'startswith' not supported for numeric filters");
return false;
case CO_ENDSWITH:
throw sinsp_exception("'endswith' not supported for numeric filters");
return false;
case CO_GLOB:
throw sinsp_exception("'glob' not supported for numeric filters");
return false;
default:
throw sinsp_exception("'unknown' not supported for numeric filters");
return false;
}
}
bool flt_compare_ipv4net(cmpop op, uint64_t operand1, ipv4net* operand2)
{
switch(op)
{
case CO_EQ:
case CO_IN:
{
return ((operand1 & operand2->m_netmask) == (operand2->m_ip & operand2->m_netmask));
}
case CO_NE:
return ((operand1 & operand2->m_netmask) != (operand2->m_ip & operand2->m_netmask));
case CO_CONTAINS:
throw sinsp_exception("'contains' not supported for numeric filters");
return false;
case CO_ICONTAINS:
throw sinsp_exception("'icontains' not supported for numeric filters");
return false;
case CO_STARTSWITH:
throw sinsp_exception("'startswith' not supported for numeric filters");
return false;
case CO_ENDSWITH:
throw sinsp_exception("'endswith' not supported for numeric filters");
return false;
case CO_GLOB:
throw sinsp_exception("'glob' not supported for numeric filters");
return false;
default:
throw sinsp_exception("comparison operator not supported for ipv4 networks");
}
}
bool flt_compare_ipv6addr(cmpop op, ipv6addr *operand1, ipv6addr *operand2)
{
switch(op)
{
case CO_EQ:
case CO_IN:
return *operand1 == *operand2;
case CO_NE:
return *operand1 != *operand2;
case CO_CONTAINS:
throw sinsp_exception("'contains' not supported for ipv6 addresses");
return false;
case CO_ICONTAINS:
throw sinsp_exception("'icontains' not supported for ipv6 addresses");
return false;
case CO_STARTSWITH:
throw sinsp_exception("'startswith' not supported for ipv6 addresses");
return false;
case CO_GLOB:
throw sinsp_exception("'glob' not supported for ipv6 addresses");
return false;
default:
throw sinsp_exception("comparison operator not supported for ipv6 addresses");
}
}
bool flt_compare_ipv6net(cmpop op, ipv6addr *operand1, ipv6addr *operand2)
{
switch(op)
{
case CO_EQ:
case CO_IN:
return operand1->in_subnet(*operand2);
case CO_NE:
return !operand1->in_subnet(*operand2);
case CO_CONTAINS:
throw sinsp_exception("'contains' not supported for ipv6 networks");
return false;
case CO_ICONTAINS:
throw sinsp_exception("'icontains' not supported for ipv6 networks");
return false;
case CO_STARTSWITH:
throw sinsp_exception("'startswith' not supported for ipv6 networks");
return false;
case CO_GLOB:
throw sinsp_exception("'glob' not supported for ipv6 networks");
return false;
default:
throw sinsp_exception("comparison operator not supported for ipv6 networks");
}
}
bool flt_compare(cmpop op, ppm_param_type type, void* operand1, void* operand2, uint32_t op1_len, uint32_t op2_len)
{
//
// sinsp_filter_check_*::compare
// already discard NULL values
//
if(op == CO_EXISTS)
{
return true;
}
switch(type)
{
case PT_INT8:
return flt_compare_int64(op, (int64_t)*(int8_t*)operand1, (int64_t)*(int8_t*)operand2);
case PT_INT16:
return flt_compare_int64(op, (int64_t)*(int16_t*)operand1, (int64_t)*(int16_t*)operand2);
case PT_INT32:
return flt_compare_int64(op, (int64_t)*(int32_t*)operand1, (int64_t)*(int32_t*)operand2);
case PT_INT64:
case PT_FD:
case PT_PID:
case PT_ERRNO:
return flt_compare_int64(op, *(int64_t*)operand1, *(int64_t*)operand2);
case PT_FLAGS8:
case PT_UINT8:
case PT_SIGTYPE:
return flt_compare_uint64(op, (uint64_t)*(uint8_t*)operand1, (uint64_t)*(uint8_t*)operand2);
case PT_FLAGS16:
case PT_UINT16:
case PT_PORT:
case PT_SYSCALLID:
return flt_compare_uint64(op, (uint64_t)*(uint16_t*)operand1, (uint64_t)*(uint16_t*)operand2);
case PT_UINT32:
case PT_FLAGS32:
case PT_MODE:
case PT_BOOL:
case PT_IPV4ADDR:
return flt_compare_uint64(op, (uint64_t)*(uint32_t*)operand1, (uint64_t)*(uint32_t*)operand2);
case PT_IPV4NET:
return flt_compare_ipv4net(op, (uint64_t)*(uint32_t*)operand1, (ipv4net*)operand2);
case PT_IPV6ADDR:
return flt_compare_ipv6addr(op, (ipv6addr *)operand1, (ipv6addr *)operand2);
case PT_IPV6NET:
return flt_compare_ipv6net(op, (ipv6addr *)operand1, (ipv6addr*)operand2);
case PT_IPADDR:
if(op1_len == sizeof(struct in_addr))
{
return flt_compare(op, PT_IPV4ADDR, operand1, operand2, op1_len, op2_len);
}
else if(op1_len == sizeof(struct in6_addr))
{
return flt_compare(op, PT_IPV6ADDR, operand1, operand2, op1_len, op2_len);
}
else
{
throw sinsp_exception("rawval_to_string called with IP address of incorrect size " + to_string(op1_len));
}
case PT_IPNET:
if(op1_len == sizeof(struct in_addr))
{
return flt_compare(op, PT_IPV4NET, operand1, operand2, op1_len, op2_len);
}
else if(op1_len == sizeof(struct in6_addr))
{
return flt_compare(op, PT_IPV6NET, operand1, operand2, op1_len, op2_len);
}
else
{
throw sinsp_exception("rawval_to_string called with IP network of incorrect size " + to_string(op1_len));
}
case PT_UINT64:
case PT_RELTIME:
case PT_ABSTIME:
return flt_compare_uint64(op, *(uint64_t*)operand1, *(uint64_t*)operand2);
case PT_CHARBUF:
return flt_compare_string(op, (char*)operand1, (char*)operand2);
case PT_BYTEBUF:
return flt_compare_buffer(op, (char*)operand1, (char*)operand2, op1_len, op2_len);
case PT_DOUBLE:
return flt_compare_double(op, *(double*)operand1, *(double*)operand2);
case PT_SOCKADDR:
case PT_SOCKTUPLE:
case PT_FDLIST:
case PT_FSPATH:
case PT_SIGSET:
default:
ASSERT(false);
return false;
}
}
bool flt_compare_avg(cmpop op,
ppm_param_type type,
void* operand1,
void* operand2,
uint32_t op1_len,
uint32_t op2_len,
uint32_t cnt1,
uint32_t cnt2)
{
int64_t i641, i642;
uint64_t u641, u642;
double d1, d2;
//
// If count = 0 we assume that the value is zero too (there are assertions to
// check that, and we just divide by 1
//
if(cnt1 == 0)
{
cnt1 = 1;
}
if(cnt2 == 0)
{
cnt2 = 1;
}
switch(type)
{
case PT_INT8:
i641 = ((int64_t)*(int8_t*)operand1) / cnt1;
i642 = ((int64_t)*(int8_t*)operand2) / cnt2;
ASSERT(cnt1 != 0 || i641 == 0);
ASSERT(cnt2 != 0 || i642 == 0);
return flt_compare_int64(op, i641, i642);
case PT_INT16:
i641 = ((int64_t)*(int16_t*)operand1) / cnt1;
i642 = ((int64_t)*(int16_t*)operand2) / cnt2;
ASSERT(cnt1 != 0 || i641 == 0);
ASSERT(cnt2 != 0 || i642 == 0);
return flt_compare_int64(op, i641, i642);
case PT_INT32:
i641 = ((int64_t)*(int32_t*)operand1) / cnt1;
i642 = ((int64_t)*(int32_t*)operand2) / cnt2;
ASSERT(cnt1 != 0 || i641 == 0);
ASSERT(cnt2 != 0 || i642 == 0);
return flt_compare_int64(op, i641, i642);
case PT_INT64:
case PT_FD:
case PT_PID:
case PT_ERRNO:
i641 = ((int64_t)*(int64_t*)operand1) / cnt1;
i642 = ((int64_t)*(int64_t*)operand2) / cnt2;
ASSERT(cnt1 != 0 || i641 == 0);
ASSERT(cnt2 != 0 || i642 == 0);
return flt_compare_int64(op, i641, i642);
case PT_FLAGS8:
case PT_UINT8:
case PT_SIGTYPE:
u641 = ((uint64_t)*(uint8_t*)operand1) / cnt1;
u642 = ((uint64_t)*(uint8_t*)operand2) / cnt2;
ASSERT(cnt1 != 0 || u641 == 0);
ASSERT(cnt2 != 0 || u642 == 0);
return flt_compare_uint64(op, u641, u642);
case PT_FLAGS16:
case PT_UINT16:
case PT_PORT:
case PT_SYSCALLID:
u641 = ((uint64_t)*(uint16_t*)operand1) / cnt1;
u642 = ((uint64_t)*(uint16_t*)operand2) / cnt2;
ASSERT(cnt1 != 0 || u641 == 0);
ASSERT(cnt2 != 0 || u642 == 0);
return flt_compare_uint64(op, u641, u642);
case PT_UINT32:
case PT_FLAGS32:
case PT_MODE:
case PT_BOOL:
case PT_IPV4ADDR:
case PT_IPV6ADDR:
// What does an average mean for ip addresses anyway?
u641 = ((uint64_t)*(uint32_t*)operand1) / cnt1;
u642 = ((uint64_t)*(uint32_t*)operand2) / cnt2;
ASSERT(cnt1 != 0 || u641 == 0);
ASSERT(cnt2 != 0 || u642 == 0);
return flt_compare_uint64(op, u641, u642);
case PT_UINT64:
case PT_RELTIME:
case PT_ABSTIME:
u641 = (*(uint64_t*)operand1) / cnt1;
u642 = (*(uint64_t*)operand2) / cnt2;
ASSERT(cnt1 != 0 || u641 == 0);
ASSERT(cnt2 != 0 || u642 == 0);
return flt_compare_uint64(op, u641, u642);
case PT_DOUBLE:
d1 = (*(double*)operand1) / cnt1;
d2 = (*(double*)operand2) / cnt2;
ASSERT(cnt1 != 0 || d1 == 0);
ASSERT(cnt2 != 0 || d2 == 0);
return flt_compare_double(op, d1, d2);
default:
ASSERT(false);
return false;
}
}
///////////////////////////////////////////////////////////////////////////////
// sinsp_filter_check implementation
///////////////////////////////////////////////////////////////////////////////
sinsp_filter_check::sinsp_filter_check()
{
m_boolop = BO_NONE;
m_cmpop = CO_NONE;
m_inspector = NULL;
m_field = NULL;
m_info.m_fields = NULL;
m_info.m_nfields = -1;
m_val_storage_len = 0;
m_aggregation = A_NONE;
m_merge_aggregation = A_NONE;
m_val_storages = vector<vector<uint8_t>> (1, vector<uint8_t>(256));
m_val_storages_min_size = (numeric_limits<uint32_t>::max)();
m_val_storages_max_size = (numeric_limits<uint32_t>::min)();
}
void sinsp_filter_check::set_inspector(sinsp* inspector)
{
m_inspector = inspector;
}
Json::Value sinsp_filter_check::rawval_to_json(uint8_t* rawval,
ppm_param_type ptype,
ppm_print_format print_format,
uint32_t len)
{
ASSERT(rawval != NULL);
switch(ptype)
{
case PT_INT8:
if(print_format == PF_DEC ||
print_format == PF_ID)
{
return *(int8_t *)rawval;
}
else if(print_format == PF_OCT ||
print_format == PF_HEX)
{
return rawval_to_string(rawval, ptype, print_format, len);
}
else
{
ASSERT(false);
return Json::nullValue;
}
case PT_INT16:
if(print_format == PF_DEC ||
print_format == PF_ID)
{
return *(int16_t *)rawval;
}
else if(print_format == PF_OCT ||
print_format == PF_HEX)
{
return rawval_to_string(rawval, ptype, print_format, len);
}
else
{
ASSERT(false);
return Json::nullValue;
}
case PT_INT32:
if(print_format == PF_DEC ||
print_format == PF_ID)
{
return *(int32_t *)rawval;
}
else if(print_format == PF_OCT ||
print_format == PF_HEX)
{
return rawval_to_string(rawval, ptype, print_format, len);
}
else
{
ASSERT(false);
return Json::nullValue;
}
case PT_INT64:
case PT_PID:
if(print_format == PF_DEC ||
print_format == PF_ID)
{
return (Json::Value::Int64)*(int64_t *)rawval;
}
else
{
return rawval_to_string(rawval, ptype, print_format, len);
}
case PT_L4PROTO: // This can be resolved in the future
case PT_UINT8:
if(print_format == PF_DEC ||
print_format == PF_ID)
{
return *(uint8_t *)rawval;
}
else if(print_format == PF_OCT ||
print_format == PF_HEX)
{
return rawval_to_string(rawval, ptype, print_format, len);
}
else
{
ASSERT(false);
return Json::nullValue;
}
case PT_PORT: // This can be resolved in the future
case PT_UINT16:
if(print_format == PF_DEC ||
print_format == PF_ID)
{
return *(uint16_t *)rawval;
}
else if(print_format == PF_OCT ||
print_format == PF_HEX)
{
return rawval_to_string(rawval, ptype, print_format, len);
}
else
{
ASSERT(false);
return Json::nullValue;
}
case PT_UINT32:
if(print_format == PF_DEC ||
print_format == PF_ID)
{
return *(uint32_t *)rawval;
}
else if(print_format == PF_OCT ||
print_format == PF_HEX)
{
return rawval_to_string(rawval, ptype, print_format, len);
}
else
{
ASSERT(false);
return Json::nullValue;
}
case PT_UINT64:
case PT_RELTIME:
case PT_ABSTIME:
if(print_format == PF_DEC ||
print_format == PF_ID)
{
return (Json::Value::UInt64)*(uint64_t *)rawval;
}
else if(
print_format == PF_10_PADDED_DEC ||
print_format == PF_OCT ||
print_format == PF_HEX)
{
return rawval_to_string(rawval, ptype, print_format, len);
}
else
{
ASSERT(false);
return Json::nullValue;
}
case PT_SOCKADDR:
case PT_SOCKFAMILY:
ASSERT(false);
return Json::nullValue;
case PT_BOOL:
return Json::Value((bool)(*(uint32_t*)rawval != 0));
case PT_CHARBUF:
case PT_FSPATH:
case PT_BYTEBUF:
case PT_IPV4ADDR:
case PT_IPV6ADDR:
case PT_IPADDR:
return rawval_to_string(rawval, ptype, print_format, len);
default:
ASSERT(false);
throw sinsp_exception("wrong event type " + to_string((long long) ptype));
}
}
char* sinsp_filter_check::rawval_to_string(uint8_t* rawval,
ppm_param_type ptype,
ppm_print_format print_format,
uint32_t len)
{
char* prfmt;
ASSERT(rawval != NULL);
switch(ptype)
{
case PT_INT8:
if(print_format == PF_OCT)
{
prfmt = (char*)"%" PRIo8;
}
else if(print_format == PF_DEC ||
print_format == PF_ID)
{
prfmt = (char*)"%" PRId8;
}
else if(print_format == PF_HEX)
{
prfmt = (char*)"%" PRIX8;
}
else
{
ASSERT(false);
return NULL;
}
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
prfmt, *(int8_t *)rawval);
return m_getpropertystr_storage;
case PT_INT16:
if(print_format == PF_OCT)
{
prfmt = (char*)"%" PRIo16;
}
else if(print_format == PF_DEC ||
print_format == PF_ID)
{
prfmt = (char*)"%" PRId16;
}
else if(print_format == PF_HEX)
{
prfmt = (char*)"%" PRIX16;
}
else
{
ASSERT(false);
return NULL;
}
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
prfmt, *(int16_t *)rawval);
return m_getpropertystr_storage;
case PT_INT32:
if(print_format == PF_OCT)
{
prfmt = (char*)"%" PRIo32;
}
else if(print_format == PF_DEC ||
print_format == PF_ID)
{
prfmt = (char*)"%" PRId32;
}
else if(print_format == PF_HEX)
{
prfmt = (char*)"%" PRIX32;
}
else
{
ASSERT(false);
return NULL;
}
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
prfmt, *(int32_t *)rawval);
return m_getpropertystr_storage;
case PT_INT64:
case PT_PID:
case PT_ERRNO:
if(print_format == PF_OCT)
{
prfmt = (char*)"%" PRIo64;
}
else if(print_format == PF_DEC ||
print_format == PF_ID)
{
prfmt = (char*)"%" PRId64;
}
else if(print_format == PF_10_PADDED_DEC)
{
prfmt = (char*)"%09" PRId64;
}
else if(print_format == PF_HEX)
{
prfmt = (char*)"%" PRIX64;
}
else
{
prfmt = (char*)"%" PRId64;
}
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
prfmt, *(int64_t *)rawval);
return m_getpropertystr_storage;
case PT_L4PROTO: // This can be resolved in the future
case PT_UINT8:
if(print_format == PF_OCT)
{
prfmt = (char*)"%" PRIo8;
}
else if(print_format == PF_DEC ||
print_format == PF_ID)
{
prfmt = (char*)"%" PRIu8;
}
else if(print_format == PF_HEX)
{
prfmt = (char*)"%" PRIu8;
}
else
{
ASSERT(false);
return NULL;
}
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
prfmt, *(uint8_t *)rawval);
return m_getpropertystr_storage;
case PT_PORT: // This can be resolved in the future
case PT_UINT16:
if(print_format == PF_OCT)
{
prfmt = (char*)"%" PRIo16;
}
else if(print_format == PF_DEC ||
print_format == PF_ID)
{
prfmt = (char*)"%" PRIu16;
}
else if(print_format == PF_HEX)
{
prfmt = (char*)"%" PRIu16;
}
else
{
ASSERT(false);
return NULL;
}
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
prfmt, *(uint16_t *)rawval);
return m_getpropertystr_storage;
case PT_UINT32:
if(print_format == PF_OCT)
{
prfmt = (char*)"%" PRIo32;
}
else if(print_format == PF_DEC ||
print_format == PF_ID)
{
prfmt = (char*)"%" PRIu32;
}
else if(print_format == PF_HEX)
{
prfmt = (char*)"%" PRIu32;
}
else
{
ASSERT(false);
return NULL;
}
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
prfmt, *(uint32_t *)rawval);
return m_getpropertystr_storage;
case PT_UINT64:
case PT_RELTIME:
case PT_ABSTIME:
if(print_format == PF_OCT)
{
prfmt = (char*)"%" PRIo64;
}
else if(print_format == PF_DEC ||
print_format == PF_ID)
{
prfmt = (char*)"%" PRIu64;
}
else if(print_format == PF_10_PADDED_DEC)
{
prfmt = (char*)"%09" PRIu64;
}
else if(print_format == PF_HEX)
{
prfmt = (char*)"%" PRIX64;
}
else
{
ASSERT(false);
return NULL;
}
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
prfmt, *(uint64_t *)rawval);
return m_getpropertystr_storage;
case PT_CHARBUF:
case PT_FSPATH:
return (char*)rawval;
case PT_BYTEBUF:
if(rawval[len] == 0)
{
return (char*)rawval;
}
else
{
ASSERT(len < 1024 * 1024);
if(len >= filter_value().size())
{
filter_value().resize(len + 1);
}
memcpy(filter_value_p(), rawval, len);
filter_value_p()[len] = 0;
return (char*)filter_value_p();
}
case PT_SOCKADDR:
ASSERT(false);
return NULL;
case PT_SOCKFAMILY:
ASSERT(false);
return NULL;
case PT_BOOL:
if(*(uint32_t*)rawval != 0)
{
return (char*)"true";
}
else
{
return (char*)"false";
}
case PT_IPV4ADDR:
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
"%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8,
rawval[0],
rawval[1],
rawval[2],
rawval[3]);
return m_getpropertystr_storage;
case PT_IPV6ADDR:
{
char address[100];
if(NULL == inet_ntop(AF_INET6, rawval, address, 100))
{
strcpy(address, "<NA>");
}
strncpy(m_getpropertystr_storage,
address,
100);
return m_getpropertystr_storage;
}
case PT_IPADDR:
if(len == sizeof(struct in_addr))
{
return rawval_to_string(rawval, PT_IPV4ADDR, print_format, len);
}
else if(len == sizeof(struct in6_addr))
{
return rawval_to_string(rawval, PT_IPV6ADDR, print_format, len);
}
else
{
throw sinsp_exception("rawval_to_string called with IP address of incorrect size " + to_string(len));
}
case PT_DOUBLE:
snprintf(m_getpropertystr_storage,
sizeof(m_getpropertystr_storage),
"%.1lf", *(double*)rawval);
return m_getpropertystr_storage;
default:
ASSERT(false);
throw sinsp_exception("wrong event type " + to_string((long long) ptype));
}
}
char* sinsp_filter_check::tostring(sinsp_evt* evt)
{
uint32_t len;
uint8_t* rawval = extract(evt, &len);
if(rawval == NULL)
{
return NULL;
}
return rawval_to_string(rawval, m_field->m_type, m_field->m_print_format, len);
}
Json::Value sinsp_filter_check::tojson(sinsp_evt* evt)
{
uint32_t len;
Json::Value jsonval = extract_as_js(evt, &len);
if(jsonval == Json::nullValue)
{
uint8_t* rawval = extract(evt, &len);
if(rawval == NULL)
{
return Json::nullValue;
}
return rawval_to_json(rawval, m_field->m_type, m_field->m_print_format, len);
}
return jsonval;
}
int32_t sinsp_filter_check::parse_field_name(const char* str, bool alloc_state, bool needed_for_filtering)
{
int32_t j;
int32_t max_fldlen = -1;
uint32_t max_flags = 0;
ASSERT(m_info.m_fields != NULL);
ASSERT(m_info.m_nfields != -1);
string val(str);
m_field_id = 0xffffffff;
for(j = 0; j < m_info.m_nfields; j++)
{
string fldname = m_info.m_fields[j].m_name;
int32_t fldlen = (uint32_t)fldname.length();
if(val.compare(0, fldlen, fldname) == 0)
{
if(fldlen > max_fldlen)
{
m_field_id = j;
m_field = &m_info.m_fields[j];
max_fldlen = fldlen;
max_flags = (m_info.m_fields[j]).m_flags;
}
}
}
if(!needed_for_filtering)
{
if(max_flags & EPF_FILTER_ONLY)
{
throw sinsp_exception(string(str) + " is filter only and cannot be used as a display field");
}
}
return max_fldlen;
}
void sinsp_filter_check::add_filter_value(const char* str, uint32_t len, uint32_t i)
{
size_t parsed_len;
if (i >= m_val_storages.size())
{
m_val_storages.push_back(vector<uint8_t>(256));
}
parsed_len = parse_filter_value(str, len, filter_value_p(i), filter_value(i).size());
// XXX/mstemm this doesn't work if someone called
// add_filter_value more than once for a given index.
filter_value_t item(filter_value_p(i), parsed_len);
m_val_storages_members.insert(item);
if(parsed_len < m_val_storages_min_size)
{
m_val_storages_min_size = parsed_len;
}
if(parsed_len > m_val_storages_max_size)
{
m_val_storages_max_size = parsed_len;
}
// If the operator is CO_PMATCH, also add the value to the paths set.
if (m_cmpop == CO_PMATCH)
{
m_val_storages_paths.add_search_path(item);
}
}
size_t sinsp_filter_check::parse_filter_value(const char* str, uint32_t len, uint8_t *storage, uint32_t storage_len)
{
size_t parsed_len;
// byte buffer, no parsing needed
if (m_field->m_type == PT_BYTEBUF)
{
if(len >= storage_len)
{
throw sinsp_exception("filter parameter too long:" + string(str));
}
memcpy(storage, str, len);
m_val_storage_len = len;
return len;
}
else
{
parsed_len = sinsp_filter_value_parser::string_to_rawval(str, len, storage, storage_len, m_field->m_type);
}
validate_filter_value(str, len);
return parsed_len;
}
const filtercheck_field_info* sinsp_filter_check::get_field_info()
{
return &m_info.m_fields[m_field_id];
}
bool sinsp_filter_check::flt_compare(cmpop op, ppm_param_type type, void* operand1, uint32_t op1_len, uint32_t op2_len)
{
if (op == CO_IN || op == CO_PMATCH)
{
// Certain filterchecks can't be done as a set
// membership test/group match. For these, just loop over the
// values and see if any value is equal.
switch(type)
{
case PT_IPV4NET:
case PT_IPV6NET:
case PT_IPNET:
case PT_SOCKADDR:
case PT_SOCKTUPLE:
case PT_FDLIST:
case PT_FSPATH:
case PT_SIGSET:
for (uint16_t i=0; i < m_val_storages.size(); i++)
{
if (::flt_compare(CO_EQ,
type,
operand1,
filter_value_p(i),
op1_len,
filter_value(i).size()))
{
return true;
}
}
return false;
break;
default:
// For raw strings, the length may not be set. So we do a strlen to find it.
if(type == PT_CHARBUF && op1_len == 0)
{
op1_len = strlen((char *) operand1);
}
filter_value_t item((uint8_t *) operand1, op1_len);
if (op == CO_IN)
{
if(op1_len >= m_val_storages_min_size &&
op1_len <= m_val_storages_max_size &&
m_val_storages_members.find(item) != m_val_storages_members.end())
{
return true;
}
}
else
{
if (m_val_storages_paths.match(item))
{
return true;
}
}
return false;
break;
}
}
else
{
return (::flt_compare(op,
type,
operand1,
filter_value_p(),
op1_len,
op2_len)
);
}
}
uint8_t* sinsp_filter_check::extract(gen_event *evt, OUT uint32_t* len, bool sanitize_strings)
{
return extract((sinsp_evt *) evt, len, sanitize_strings);
}
bool sinsp_filter_check::compare(gen_event *evt)
{
return compare((sinsp_evt *) evt);
}
bool sinsp_filter_check::compare(sinsp_evt *evt)
{
uint32_t evt_val_len=0;
bool sanitize_strings = false;
uint8_t* extracted_val = extract(evt, &evt_val_len, sanitize_strings);
if(extracted_val == NULL)
{
return false;
}
return flt_compare(m_cmpop,
m_info.m_fields[m_field_id].m_type,
extracted_val,
evt_val_len,
m_val_storage_len);
}
sinsp_filter::sinsp_filter(sinsp *inspector)
{
m_inspector = inspector;
}
sinsp_filter::~sinsp_filter()
{
}
///////////////////////////////////////////////////////////////////////////////
// sinsp_filter_compiler implementation
///////////////////////////////////////////////////////////////////////////////
sinsp_filter_compiler::sinsp_filter_compiler(sinsp* inspector, const string& fltstr, bool ttable_only)
{
m_inspector = inspector;
m_ttable_only = ttable_only;
m_scanpos = -1;
m_scansize = 0;
m_state = ST_NEED_EXPRESSION;
m_filter = new sinsp_filter(m_inspector);
m_last_boolop = BO_NONE;
m_nest_level = 0;
m_fltstr = fltstr;
}
sinsp_filter_compiler::~sinsp_filter_compiler()
{
}
bool sinsp_filter_compiler::isblank(char c)
{
if(c == ' ' || c == '\t' || c == '\n' || c == '\r')
{
return true;
}
else
{
return false;
}
}
bool sinsp_filter_compiler::is_special_char(char c)
{
if(c == '(' || c == ')' || c == '!' || c == '=' || c == '<' || c == '>')
{
return true;
}
return false;
}
bool sinsp_filter_compiler::is_bracket(char c)
{
if(c == '(' || c == ')')
{
return true;
}
return false;
}
char sinsp_filter_compiler::next()
{
while(true)
{
m_scanpos++;
if(m_scanpos >= m_scansize)
{
return 0;
}
if(!isblank(m_fltstr[m_scanpos]))
{
return m_fltstr[m_scanpos];
}
}
}
vector<char> sinsp_filter_compiler::next_operand(bool expecting_first_operand, bool in_or_pmatch_clause)
{
vector<char> res;
bool is_quoted = false;
int32_t start;
int32_t nums[2];
uint32_t num_pos;
enum ppm_escape_state
{
PES_NORMAL,
PES_SLASH,
PES_NUMBER,
PES_ERROR,
} escape_state;
//
// Skip spaces
//
if(isblank(m_fltstr[m_scanpos]))
{
next();
}
//
// If there are quotes, don't stop on blank
//
if(m_scanpos < m_scansize &&
(m_fltstr[m_scanpos] == '"' || m_fltstr[m_scanpos] == '\''))
{
is_quoted = true;
m_scanpos++;
}
//
// Mark the beginning of the word
//
start = m_scanpos;
escape_state = PES_NORMAL;
num_pos = 0;
while(m_scanpos < m_scansize && escape_state != PES_ERROR)
{
char curchar = m_fltstr[m_scanpos];
bool is_end_of_word;
if(expecting_first_operand)
{
is_end_of_word = (isblank(curchar) || is_special_char(curchar));
}
else
{
is_end_of_word = (!is_quoted && (isblank(curchar) || is_bracket(curchar) || (in_or_pmatch_clause && curchar == ','))) ||
(is_quoted && escape_state != PES_SLASH && (curchar == '"' || curchar == '\''));
}
if(is_end_of_word)
{
if(escape_state != PES_NORMAL)
{
escape_state = PES_ERROR;
break;
}
//
// End of word
//
ASSERT(m_scanpos >= start);
if(curchar == '(' || curchar == ')' || (in_or_pmatch_clause && curchar == ','))
{
m_scanpos--;
}
res.push_back('\0');
return res;
}
switch(escape_state)
{
case PES_NORMAL:
if(curchar == '\\' && !expecting_first_operand)
{
escape_state = PES_SLASH;
}
else
{
res.push_back(curchar);
}
break;
case PES_SLASH:
switch(curchar)
{
case '\\':
case '"':
escape_state = PES_NORMAL;
res.push_back(curchar);
break;
case 'x':
escape_state = PES_NUMBER;
break;
default:
escape_state = PES_NORMAL;
res.push_back('\\');
res.push_back(curchar);
break;
}
break;
case PES_NUMBER:
if(isdigit((int)curchar))
{
nums[num_pos++] = curchar - '0';
}
else if((curchar >= 'a' && curchar <= 'f') || (curchar >= 'A' && curchar <= 'F'))
{
nums[num_pos++] = tolower((int)curchar) - 'a' + 10;
}
else
{
escape_state = PES_ERROR;
}
if(num_pos == 2 && escape_state != PES_ERROR)
{
res.push_back((char)(nums[0] * 16 + nums[1]));
num_pos = 0;
escape_state = PES_NORMAL;
}
break;
default:
ASSERT(false);
escape_state = PES_ERROR;
break;
}
m_scanpos++;
}
if(escape_state == PES_ERROR)
{
throw sinsp_exception("filter error: unrecognized escape sequence at " + m_fltstr.substr(start, m_scanpos));
}
else if(is_quoted)
{
throw sinsp_exception("filter error: unclosed quotes");
}
//
// End of filter
//
res.push_back('\0');
return res;
}
bool sinsp_filter_compiler::compare_no_consume(const string& str)
{
//
// If the rest of the filter cannot contain the operand we may return
// The filter may finish with the operand itself though (e.g. "proc.name exists")
//
if(m_scanpos + (int32_t)str.size() > m_scansize)
{
return false;
}
string tstr = m_fltstr.substr(m_scanpos, str.size());
if(tstr == str)
{
return true;
}
else
{
return false;
}
}
cmpop sinsp_filter_compiler::next_comparison_operator()
{
int32_t start;
//
// Skip spaces
//
if(isblank(m_fltstr[m_scanpos]))
{
next();
}
//
// Mark the beginning of the word
//
start = m_scanpos;
if(compare_no_consume("="))
{
m_scanpos += 1;
return CO_EQ;
}
else if(compare_no_consume("!="))
{
m_scanpos += 2;
return CO_NE;
}
else if(compare_no_consume("<="))
{
m_scanpos += 2;
return CO_LE;
}
else if(compare_no_consume("<"))
{
m_scanpos += 1;
return CO_LT;
}
else if(compare_no_consume(">="))
{
m_scanpos += 2;
return CO_GE;
}
else if(compare_no_consume(">"))
{
m_scanpos += 1;
return CO_GT;
}
else if(compare_no_consume("contains"))
{
m_scanpos += 8;
return CO_CONTAINS;
}
else if(compare_no_consume("icontains"))
{
m_scanpos += 9;
return CO_ICONTAINS;
}
else if(compare_no_consume("startswith"))
{
m_scanpos += 10;
return CO_STARTSWITH;
}
else if(compare_no_consume("endswith"))
{
m_scanpos += 8;
return CO_ENDSWITH;
}
else if(compare_no_consume("glob"))
{
m_scanpos += 4;
return CO_GLOB;
}
else if(compare_no_consume("in"))
{
m_scanpos += 2;
return CO_IN;
}
else if(compare_no_consume("pmatch"))
{
m_scanpos += 6;
return CO_PMATCH;
}
else if(compare_no_consume("exists"))
{
m_scanpos += 6;
return CO_EXISTS;
}
else
{
throw sinsp_exception("filter error: unrecognized comparison operator after " + m_fltstr.substr(0, start));
}
}
void sinsp_filter_compiler::parse_check()
{
uint32_t startpos = m_scanpos;
vector<char> operand1 = next_operand(true, false);
string str_operand1 = string((char *)&operand1[0]);
sinsp_filter_check* chk = g_filterlist.new_filter_check_from_fldname(str_operand1, m_inspector, true);
boolop op = m_last_boolop;
if(chk == NULL)
{
throw sinsp_exception("filter error: unrecognized field " +
str_operand1 + " at pos " + to_string((long long) startpos));
}
if(m_ttable_only)
{
if(!(chk->get_fields()->m_flags & filter_check_info::FL_WORKS_ON_THREAD_TABLE))
{
if(str_operand1 != "evt.rawtime" &&
str_operand1 != "evt.rawtime.s" &&
str_operand1 != "evt.rawtime.ns" &&
str_operand1 != "evt.time" &&
str_operand1 != "evt.time.s" &&
str_operand1 != "evt.datetime" &&
str_operand1 != "evt.reltime")
{
throw sinsp_exception("the given filter is not supported for thread table filtering");
}
}
}
cmpop co = next_comparison_operator();
chk->m_boolop = op;
chk->m_cmpop = co;
chk->parse_field_name((char *)&operand1[0], true, true);
if(co == CO_IN || co == CO_PMATCH)
{
//
// Skip spaces
//
if(isblank(m_fltstr[m_scanpos]))
{
next();
}
if(m_fltstr[m_scanpos] != '(')
{
throw sinsp_exception("expected '(' after 'in/pmatch' operand");
}
//
// Skip '('
//
m_scanpos++;
if(chk->get_field_info()->m_type == PT_CHARBUF)
{
//
// For character buffers, we can check all
// values at once by putting them in a set and
// checking for set membership.
//
//
// Create the 'or' sequence
//
uint32_t num_values = 0;
while(true)
{
// 'in' clause aware
vector<char> operand2 = next_operand(false, true);
chk->add_filter_value((char *)&operand2[0], (uint32_t)operand2.size() - 1, num_values);
num_values++;
next();
if(m_fltstr[m_scanpos] == ')')
{
break;
}
else if(m_fltstr[m_scanpos] == ',')
{
m_scanpos++;
}
else
{
throw sinsp_exception("expected either ')' or ',' after a value inside the 'in/pmatch' clause");
}
}
m_filter->add_check(chk);
}
else if (co == CO_PMATCH)
{
// the pmatch operator can only work on charbufs
throw sinsp_exception("pmatch requires all charbuf arguments");
}
else
{
//
// In this case we need to create '(field=value1 or field=value2 ...)'
//
//
// Separate the 'or's from the
// rest of the conditions
//
m_filter->push_expression(op);
m_last_boolop = BO_NONE;
m_nest_level++;
//
// The first boolean operand will be BO_NONE
// Then we will start putting BO_ORs
//
op = BO_NONE;
//
// Create the 'or' sequence
//
while(true)
{
// 'in' clause aware
vector<char> operand2 = next_operand(false, true);
//
// Append every sinsp_filter_check creating the 'or' sequence
//
sinsp_filter_check* newchk = g_filterlist.new_filter_check_from_another(chk);
newchk->m_boolop = op;
newchk->m_cmpop = CO_EQ;
newchk->add_filter_value((char *)&operand2[0], (uint32_t)operand2.size() - 1);
m_filter->add_check(newchk);
next();
if(m_fltstr[m_scanpos] == ')')
{
break;
}
else if(m_fltstr[m_scanpos] == ',')
{
m_scanpos++;
}
else
{
throw sinsp_exception("expected either ')' or ',' after a value inside the 'in' clause");
}
//
// From now on we 'or' every newchk
//
op = BO_OR;
}
//
// Come back to the rest of the filter
//
m_filter->pop_expression();
m_nest_level--;
}
}
else
{
//
// In this case we want next() to return the very next character
// At this moment m_scanpos is already at it
// e.g. "(field exists) and ..."
//
if(co == CO_EXISTS)
{
m_scanpos--;
}
//
// Otherwise we need a value for the operand
//
else
{
vector<char> operand2 = next_operand(false, false);
chk->add_filter_value((char *)&operand2[0], (uint32_t)operand2.size() - 1);
}
m_filter->add_check(chk);
}
}
sinsp_filter* sinsp_filter_compiler::compile()
{
try
{
return compile_();
}
catch(sinsp_exception& e)
{
delete m_filter;
throw e;
}
catch(...)
{
delete m_filter;
throw sinsp_exception("error parsing the filter string");
}
}
sinsp_filter* sinsp_filter_compiler::compile_()
{
m_scansize = (uint32_t)m_fltstr.size();
while(true)
{
char a = next();
switch(a)
{
case 0:
//
// Finished parsing the filter string
//
if(m_nest_level != 0)
{
throw sinsp_exception("filter error: unexpected end of filter");
}
if(m_state != ST_EXPRESSION_DONE)
{
throw sinsp_exception("filter error: unexpected end of filter at position " + to_string((long long) m_scanpos));
}
//
// Good filter
//
return m_filter;
break;
case '(':
if(m_state != ST_NEED_EXPRESSION)
{
throw sinsp_exception("unexpected '(' after " + m_fltstr.substr(0, m_scanpos));
}
m_filter->push_expression(m_last_boolop);
m_last_boolop = BO_NONE;
m_nest_level++;
break;
case ')':
m_filter->pop_expression();
m_nest_level--;
break;
case 'o':
if(m_scanpos != 0 && m_state != ST_NEED_EXPRESSION)
{
if(next() == 'r')
{
m_last_boolop = BO_OR;
}
else
{
throw sinsp_exception("syntax error in filter at position " + to_string((long long)m_scanpos));
}
if(m_state != ST_EXPRESSION_DONE)
{
throw sinsp_exception("unexpected 'or' after " + m_fltstr.substr(0, m_scanpos));
}
m_state = ST_NEED_EXPRESSION;
}
else
{
parse_check();
m_state = ST_EXPRESSION_DONE;
}
break;
case 'a':
if(m_scanpos != 0 && m_state != ST_NEED_EXPRESSION)
{
if(next() == 'n' && next() == 'd')
{
m_last_boolop = BO_AND;
}
else
{
throw sinsp_exception("syntax error in filter at position " + to_string((long long)m_scanpos));
}
if(m_state != ST_EXPRESSION_DONE)
{
throw sinsp_exception("unexpected 'and' after " + m_fltstr.substr(0, m_scanpos));
}
m_state = ST_NEED_EXPRESSION;
}
else
{
parse_check();
m_state = ST_EXPRESSION_DONE;
}
break;
case 'n':
if(next() == 'o' && next() == 't')
{
m_last_boolop = (boolop)((uint32_t)m_last_boolop | BO_NOT);
}
else
{
throw sinsp_exception("syntax error in filter at position " + to_string((long long) m_scanpos));
}
if(m_state != ST_EXPRESSION_DONE && m_state != ST_NEED_EXPRESSION)
{
throw sinsp_exception("unexpected 'not' after " + m_fltstr.substr(0, m_scanpos));
}
m_state = ST_NEED_EXPRESSION;
break;
default:
if(m_state == ST_NEED_EXPRESSION)
{
parse_check();
m_state = ST_EXPRESSION_DONE;
}
else
{
throw sinsp_exception("syntax error in filter at position " + to_string((long long) m_scanpos));
}
break;
}
}
vector<string> components = sinsp_split(m_fltstr, ' ');
return m_filter;
}
sinsp_evttype_filter::sinsp_evttype_filter()
{
}
sinsp_evttype_filter::~sinsp_evttype_filter()
{
for(const auto &val : m_filters)
{
delete val.second->filter;
delete val.second;
}
for(auto &ruleset : m_rulesets)
{
delete ruleset;
}
m_filters.clear();
}
sinsp_evttype_filter::ruleset_filters::ruleset_filters()
{
memset(m_filter_by_evttype, 0, PPM_EVENT_MAX * sizeof(list<filter_wrapper *> *));
memset(m_filter_by_syscall, 0, PPM_SC_MAX * sizeof(list<filter_wrapper *> *));
}
sinsp_evttype_filter::ruleset_filters::~ruleset_filters()
{
for(int i = 0; i < PPM_EVENT_MAX; i++)
{
if(m_filter_by_evttype[i])
{
delete m_filter_by_evttype[i];
m_filter_by_evttype[i] = NULL;
}
}
for(int i = 0; i < PPM_SC_MAX; i++)
{
if(m_filter_by_syscall[i])
{
delete m_filter_by_syscall[i];
m_filter_by_syscall[i] = NULL;
}
}
}
void sinsp_evttype_filter::ruleset_filters::add_filter(filter_wrapper *wrap)
{
for(uint32_t etype = 0; etype < PPM_EVENT_MAX; etype++)
{
if(wrap->evttypes[etype])
{
if(!m_filter_by_evttype[etype])
{
m_filter_by_evttype[etype] = new std::list<filter_wrapper *>();
}
m_filter_by_evttype[etype]->push_back(wrap);
}
}
for(uint32_t syscall = 0; syscall < PPM_SC_MAX; syscall++)
{
if(wrap->syscalls[syscall])
{
if(!m_filter_by_syscall[syscall])
{
m_filter_by_syscall[syscall] = new std::list<filter_wrapper *>();
}
m_filter_by_syscall[syscall]->push_back(wrap);
}
}
}
void sinsp_evttype_filter::ruleset_filters::remove_filter(filter_wrapper *wrap)
{
for(uint32_t etype = 0; etype < PPM_EVENT_MAX; etype++)
{
if(wrap->evttypes[etype])
{
if(m_filter_by_evttype[etype])
{
m_filter_by_evttype[etype]->erase(std::remove(m_filter_by_evttype[etype]->begin(),
m_filter_by_evttype[etype]->end(),
wrap),
m_filter_by_evttype[etype]->end());
if(m_filter_by_evttype[etype]->size() == 0)
{
delete m_filter_by_evttype[etype];
m_filter_by_evttype[etype] = NULL;
}
}
}
}
for(uint32_t syscall = 0; syscall < PPM_SC_MAX; syscall++)
{
if(wrap->syscalls[syscall])
{
if(m_filter_by_syscall[syscall])
{
m_filter_by_syscall[syscall]->erase(std::remove(m_filter_by_syscall[syscall]->begin(),
m_filter_by_syscall[syscall]->end(),
wrap),
m_filter_by_syscall[syscall]->end());
if(m_filter_by_syscall[syscall]->size() == 0)
{
delete m_filter_by_syscall[syscall];
m_filter_by_syscall[syscall] = NULL;
}
}
}
}
}
bool sinsp_evttype_filter::ruleset_filters::run(sinsp_evt *evt)
{
list<filter_wrapper *> *filters;
uint16_t etype = evt->m_pevt->type;
if(etype == PPME_GENERIC_E || etype == PPME_GENERIC_X)
{
sinsp_evt_param *parinfo = evt->get_param(0);
ASSERT(parinfo->m_len == sizeof(uint16_t));
uint16_t evid = *(uint16_t *)parinfo->m_val;
filters = m_filter_by_syscall[evid];
}
else
{
filters = m_filter_by_evttype[etype];
}
if (!filters) {
return false;
}
for (auto &wrap : *filters)
{
if(wrap->filter->run(evt))
{
return true;
}
}
return false;
}
void sinsp_evttype_filter::ruleset_filters::evttypes_for_ruleset(std::vector<bool> &evttypes)
{
evttypes.assign(PPM_EVENT_MAX+1, false);
for(uint32_t etype = 0; etype < PPM_EVENT_MAX; etype++)
{
list<filter_wrapper *> *filters = m_filter_by_evttype[etype];
if(filters)
{
evttypes[etype] = true;
}
}
}
void sinsp_evttype_filter::ruleset_filters::syscalls_for_ruleset(std::vector<bool> &syscalls)
{
syscalls.assign(PPM_SC_MAX+1, false);
for(uint32_t evid = 0; evid < PPM_SC_MAX; evid++)
{
list<filter_wrapper *> *filters = m_filter_by_syscall[evid];
if(filters)
{
syscalls[evid] = true;
}
}
}
void sinsp_evttype_filter::add(string &name,
set<uint32_t> &evttypes,
set<uint32_t> &syscalls,
set<string> &tags,
sinsp_filter *filter)
{
filter_wrapper *wrap = new filter_wrapper();
wrap->filter = filter;
// If no evttypes or syscalls are specified, the filter is
// enabled for all evttypes/syscalls.
bool def = ((evttypes.size() == 0 && syscalls.size() == 0) ? true : false);
wrap->evttypes.assign(PPM_EVENT_MAX+1, def);
for(auto &evttype : evttypes)
{
wrap->evttypes[evttype] = true;
}
wrap->syscalls.assign(PPM_SC_MAX+1, def);
for(auto &syscall : syscalls)
{
wrap->syscalls[syscall] = true;
}
m_filters.insert(pair<string,filter_wrapper *>(name, wrap));
for(const auto &tag: tags)
{
auto it = m_filter_by_tag.lower_bound(tag);
if(it == m_filter_by_tag.end() ||
it->first != tag)
{
it = m_filter_by_tag.emplace_hint(it,
std::make_pair(tag, std::list<filter_wrapper*>()));
}
it->second.push_back(wrap);
}
}
void sinsp_evttype_filter::enable(const string &pattern, bool enabled, uint16_t ruleset)
{
regex re(pattern);
while (m_rulesets.size() < (size_t) ruleset + 1)
{
m_rulesets.push_back(new ruleset_filters());
}
for(const auto &val : m_filters)
{
if (regex_match(val.first, re))
{
if(enabled)
{
m_rulesets[ruleset]->add_filter(val.second);
}
else
{
m_rulesets[ruleset]->remove_filter(val.second);
}
}
}
}
void sinsp_evttype_filter::enable_tags(const set<string> &tags, bool enabled, uint16_t ruleset)
{
while (m_rulesets.size() < (size_t) ruleset + 1)
{
m_rulesets.push_back(new ruleset_filters());
}
for(const auto &tag : tags)
{
for(const auto &wrap : m_filter_by_tag[tag])
{
if(enabled)
{
m_rulesets[ruleset]->add_filter(wrap);
}
else
{
m_rulesets[ruleset]->remove_filter(wrap);
}
}
}
}
bool sinsp_evttype_filter::run(sinsp_evt *evt, uint16_t ruleset)
{
if(m_rulesets.size() < (size_t) ruleset + 1)
{
return false;
}
return m_rulesets[ruleset]->run(evt);
}
void sinsp_evttype_filter::evttypes_for_ruleset(std::vector<bool> &evttypes, uint16_t ruleset)
{
return m_rulesets[ruleset]->evttypes_for_ruleset(evttypes);
}
void sinsp_evttype_filter::syscalls_for_ruleset(std::vector<bool> &syscalls, uint16_t ruleset)
{
return m_rulesets[ruleset]->syscalls_for_ruleset(syscalls);
}
sinsp_filter_factory::sinsp_filter_factory(sinsp *inspector)
: m_inspector(inspector)
{
}
sinsp_filter_factory::~sinsp_filter_factory()
{
}
gen_event_filter *sinsp_filter_factory::new_filter()
{
return new sinsp_filter(m_inspector);
}
gen_event_filter_check *sinsp_filter_factory::new_filtercheck(const char *fldname)
{
return g_filterlist.new_filter_check_from_fldname(fldname,
m_inspector,
true);
}
#endif // HAS_FILTERING
|
; A200155: Number of 0..n arrays x(0..3) of 4 elements with zero 3rd differences.
; 4,9,22,41,66,107,158,219,304,403,516,661,824,1005,1226,1469,1734,2047,2386,2751,3172,3623,4104,4649,5228,5841,6526,7249,8010,8851,9734,10659,11672,12731,13836,15037,16288,17589,18994,20453,21966,23591,25274,27015,28876,30799,32784,34897,37076,39321,41702,44153,46674,49339,52078,54891,57856,60899,64020,67301,70664,74109,77722,81421,85206,89167,93218,97359,101684,106103,110616,115321,120124,125025,130126,135329,140634,146147,151766,157491,163432,169483,175644,182029,188528,195141,201986,208949
add $0,2
mov $3,$0
lpb $0
sub $0,1
add $2,$3
add $1,$2
trn $3,3
add $2,$3
lpe
mov $0,$1
|
; A184985: Nonnegative integers excluding 2.
; 0,1,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,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70
mov $1,1
bin $1,$0
cmp $1,0
add $1,$0
mov $0,$1
|
dnl Intel Pentium mpn_mul_2 -- mpn by 2-limb multiplication.
dnl Copyright 2001, 2002 Free Software Foundation, Inc.
dnl
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Lesser General Public License as
dnl published by the Free Software Foundation; either version 2.1 of the
dnl License, or (at your option) any later version.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with the GNU MP Library; see the file COPYING.LIB. If
dnl not, write to the Free Software Foundation, Inc., 51 Franklin Street,
dnl Fifth Floor, Boston, MA 02110-1301, USA. */
include(`../config.m4')
C P5: 24.0 cycles/limb
C mp_limb_t mpn_mul_2 (mp_ptr dst, mp_srcptr src, mp_size_t size,
C mp_srcptr mult);
C
C At 24 c/l this is only 2 cycles faster than a separate mul_1 and addmul_1,
C but has the advantage of making just one pass over the operands.
C
C There's not enough registers to use PARAM_MULT directly, so the multiplier
C limbs are transferred to local variables on the stack.
defframe(PARAM_MULT, 16)
defframe(PARAM_SIZE, 12)
defframe(PARAM_SRC, 8)
defframe(PARAM_DST, 4)
dnl re-use parameter space
define(VAR_MULT_LOW, `PARAM_SRC')
define(VAR_MULT_HIGH,`PARAM_DST')
TEXT
ALIGN(8)
PROLOGUE(mpn_mul_2)
deflit(`FRAME',0)
pushl %esi FRAME_pushl()
pushl %edi FRAME_pushl()
movl PARAM_SRC, %esi
movl PARAM_DST, %edi
movl PARAM_MULT, %eax
movl PARAM_SIZE, %ecx
movl 4(%eax), %edx C mult high
movl (%eax), %eax C mult low
movl %eax, VAR_MULT_LOW
movl %edx, VAR_MULT_HIGH
pushl %ebx FRAME_pushl()
pushl %ebp FRAME_pushl()
mull (%esi) C src[0] * mult[0]
movl %eax, %ebp C in case src==dst
movl (%esi), %eax C src[0]
movl %ebp, (%edi) C dst[0]
movl %edx, %ebx C initial low carry
xorl %ebp, %ebp C initial high carry
leal (%edi,%ecx,4), %edi C dst end
mull VAR_MULT_HIGH C src[0] * mult[1]
subl $2, %ecx C size-2
js L(done)
leal 8(%esi,%ecx,4), %esi C &src[size]
xorl $-1, %ecx C -(size-1)
L(top):
C eax low prod
C ebx low carry
C ecx counter, negative
C edx high prod
C esi src end
C edi dst end
C ebp high carry (0 or -1)
andl $1, %ebp C 1 or 0
addl %eax, %ebx
adcl %edx, %ebp
ASSERT(nc)
movl (%esi,%ecx,4), %eax
mull VAR_MULT_LOW
addl %eax, %ebx C low carry
movl (%esi,%ecx,4), %eax
adcl %ebp, %edx C high carry
movl %ebx, (%edi,%ecx,4)
sbbl %ebp, %ebp C new high carry, -1 or 0
movl %edx, %ebx C new low carry
mull VAR_MULT_HIGH
incl %ecx
jnz L(top)
L(done):
andl $1, %ebp C 1 or 0
addl %ebx, %eax
adcl %ebp, %edx
ASSERT(nc)
movl %eax, (%edi) C store carry low
movl %edx, %eax C return carry high
popl %ebp
popl %ebx
popl %edi
popl %esi
ret
EPILOGUE()
|
; A221462: Number of 0..7 arrays of length n with each element unequal to at least one neighbor, starting with 0
; 0,7,49,392,3087,24353,192080,1515031,11949777,94253656,743424031,5863743809,46250174880,364797430823,2877333239921,22694914695208,179005735545903,1411904551687777,11136372010635760,87837935936264759,692820155628303633,5464606640951978744,43101987576061976639,339966159519097687681,2681477029666117650240,21150102324296507365447,166821055477738375109809,1315798104614244177326792,10378334120643877867056207,81858925576806854310680993,645660817882155125244160400,5092638204212733856883889751,40168093154664222874896351057,316825119512138697122461685656,2498952488667620439981506256991,19710443257258313959727775598529,155465770221481540797964972988640,1226233494351178983303849240110183,9671894852008623668712699491691761,76286898424518618564115841122613608,601711552935690695629799784300137583
mov $1,1
lpb $0
sub $0,1
mov $2,$3
add $3,$1
mov $1,$2
mul $3,7
lpe
mov $0,-6
mov $4,$3
add $4,7
add $0,$4
sub $0,1
|
; int strncmp(const char *s1, const char *s2, size_t n)
SECTION code_string
PUBLIC _strncmp
EXTERN asm_strncmp
_strncmp:
pop af
pop de
pop hl
pop bc
push bc
push hl
push de
push af
jp asm_strncmp
|
# Si scriva un programma in linguaggio assembly MIPS che legge due stringhe da tastiera e al suo interno usa una subroutine,
# denominata SIMILITUDINE, che valuta quanti caratteri alle stesse posizioni delle due stringhe sono uguali.
# La routine riceve due parametri, "le stringhe" (cioè gli indirizzi delle stringhe), e restituisce un numero intero e lo stampa a video.
# Ad esempio:
# SIMILITUDINE ("ciao", "cielo") restituisce 2 in quanto i primi due caratteri sono identici.
# SIMILITUDINE("ciao", "salve") restituisce 0 in quanto nessun carattere alle stesse posizioni sono uguali
.text
.globl main
main:
la $a0, str1
li $a1, 255
li $v0, 8
syscall
jal STRLEN
move $t0, $v0
la $a0, str2
li $a1, 255
li $v0, 8
syscall
subi $sp, $sp, 4
sw $t0, 0($sp)
jal STRLEN
move $t1, $v0
lw $t0 0($sp)
addi $sp, $sp, 4
la $a0, str1
la $a1, str2
move $a2, $t0
move $a3, $t1
jal SIMILITUDINE
move $a0, $v0
li $v0, 1
syscall
li $v0, 10
syscall
STRLEN:
#a0 address of string
move $t0, $a0
move $t1, $a0
len_loop:
lb $t2, 0($t0)
beq $t2, $zero, len_end
addi $t0, $t0, 1
j len_loop
len_end:
sub $t3, $t0, $t1
move $v0, $t3
jr $ra
SIMILITUDINE:
# a0, a1 addresses of strings
# a2, a3 length of strings
move $t0, $a0
move $t1, $a1
move $t2, $a2
move $t3, $a3
bgt $t2, $t3, do_nothing
move $t2, $t3
do_nothing:
li $t4, 0
simil_loop:
ble $t2, $t4, simil_end
lb $t5, 0($t0)
lb $t6, 0($t1)
seq $t7, $t5, $t6
add $t8, $t8, $t7
addi $t4, $t4, 1
addi $t0, $t0, 1
addi $t1, $t1, 1
j simil_loop
simil_end:
move $v0, $t8
jr $ra
.data
str1: .space 255
str2: .space 255
|
CinnabarLabMetronomeRoom_h:
db LAB ; tileset
db CINNABAR_LAB_METRONOME_ROOM_HEIGHT, CINNABAR_LAB_METRONOME_ROOM_WIDTH ; dimensions (y, x)
dw CinnabarLabMetronomeRoom_Blocks ; blocks
dw CinnabarLabMetronomeRoom_TextPointers ; texts
dw CinnabarLabMetronomeRoom_Script ; scripts
db 0 ; connections
dw CinnabarLabMetronomeRoom_Object ; objects
|
; ===============================================================
; Dec 2013
; ===============================================================
;
; void *p_forward_list_insert_after(void *list_item, void *item)
;
; Insert item into list after the list_item, return item.
;
; ===============================================================
SECTION code_clib
SECTION code_adt_p_forward_list
PUBLIC asm_p_forward_list_insert_after
asm_p_forward_list_insert_after:
; enter : hl = void *list_item (insert after this item)
; de = void *item (item to be added to list)
;
; exit : hl = void *item
; de = void *list_item
; z flag set if item is the last item in the list
;
; uses : af, de, hl
ldi
inc bc ; undo changes to bc
ld a,(hl)
ld (de),a ; item->next = list_item->next
dec de ; de = item
ld (hl),d
dec hl ; hl = list_item
or (hl) ; z flag set if item is end of list
ld (hl),e ; list_item->next = item
ex de,hl ; hl = void *item, de = void *list_item
ret
|
// Stars array of struct
/// @file
/// Functions for performing input and output.
// Commodore 64 PRG executable file
.file [name="stars-1.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(__start)
.const LIGHT_BLUE = $e
.const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1
.const STACK_BASE = $103
.const SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER = $c
/// Color Ram
.label COLORRAM = $d800
/// Default address of screen character matrix
.label DEFAULT_SCREEN = $400
// The number of bytes on the screen
// The current cursor x-position
.label conio_cursor_x = $1f
// The current cursor y-position
.label conio_cursor_y = $20
// The current text cursor line start
.label conio_line_text = $21
// The current color cursor line start
.label conio_line_color = $23
.segment Code
__start: {
// __ma char conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// __ma char conio_cursor_y = 0
sta.z conio_cursor_y
// __ma char *conio_line_text = CONIO_SCREEN_TEXT
lda #<DEFAULT_SCREEN
sta.z conio_line_text
lda #>DEFAULT_SCREEN
sta.z conio_line_text+1
// __ma char *conio_line_color = CONIO_SCREEN_COLORS
lda #<COLORRAM
sta.z conio_line_color
lda #>COLORRAM
sta.z conio_line_color+1
// #pragma constructor_for(conio_c64_init, cputc, clrscr, cscroll)
jsr conio_c64_init
jsr main
rts
}
// Set initial cursor position
conio_c64_init: {
// Position cursor at current line
.label BASIC_CURSOR_LINE = $d6
// char line = *BASIC_CURSOR_LINE
ldx.z BASIC_CURSOR_LINE
// if(line>=CONIO_HEIGHT)
cpx #$19
bcc __b1
ldx #$19-1
__b1:
// gotoxy(0, line)
jsr gotoxy
// }
rts
}
// Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed
// void cputc(__register(A) char c)
cputc: {
.const OFFSET_STACK_C = 0
tsx
lda STACK_BASE+OFFSET_STACK_C,x
// if(c=='\n')
cmp #'\n'
beq __b1
// conio_line_text[conio_cursor_x] = c
ldy.z conio_cursor_x
sta (conio_line_text),y
// conio_line_color[conio_cursor_x] = conio_textcolor
lda #LIGHT_BLUE
sta (conio_line_color),y
// if(++conio_cursor_x==CONIO_WIDTH)
inc.z conio_cursor_x
lda #$28
cmp.z conio_cursor_x
bne __breturn
// cputln()
jsr cputln
__breturn:
// }
rts
__b1:
// cputln()
jsr cputln
rts
}
main: {
.label pStar = $1d
.label i = $18
// clrscr()
jsr clrscr
lda #<stars
sta.z pStar
lda #>stars
sta.z pStar+1
lda #0
sta.z i
__b1:
// for( char i=0;i<5;i++)
lda.z i
cmp #5
bcc __b2
// }
rts
__b2:
// printf("%p %u %u\n", pStar, pStar->star_x, pStar->star_y)
lda.z pStar
sta.z printf_uint.uvalue
lda.z pStar+1
sta.z printf_uint.uvalue+1
jsr printf_uint
// printf("%p %u %u\n", pStar, pStar->star_x, pStar->star_y)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s
sta.z printf_str.s
lda #>s
sta.z printf_str.s+1
jsr printf_str
// printf("%p %u %u\n", pStar, pStar->star_x, pStar->star_y)
ldy #0
lda (pStar),y
tax
jsr printf_uchar
// printf("%p %u %u\n", pStar, pStar->star_x, pStar->star_y)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s
sta.z printf_str.s
lda #>s
sta.z printf_str.s+1
jsr printf_str
// printf("%p %u %u\n", pStar, pStar->star_x, pStar->star_y)
ldy #1
lda (pStar),y
tax
jsr printf_uchar
// printf("%p %u %u\n", pStar, pStar->star_x, pStar->star_y)
lda #<cputc
sta.z printf_str.putc
lda #>cputc
sta.z printf_str.putc+1
lda #<s2
sta.z printf_str.s
lda #>s2
sta.z printf_str.s+1
jsr printf_str
// pStar++;
lda #4
clc
adc.z pStar
sta.z pStar
bcc !+
inc.z pStar+1
!:
// for( char i=0;i<5;i++)
inc.z i
jmp __b1
.segment Data
s: .text " "
.byte 0
s2: .text @"\n"
.byte 0
}
.segment Code
// Set the cursor to the specified position
// void gotoxy(char x, __register(X) char y)
gotoxy: {
.const x = 0
.label __5 = $1b
.label __6 = $16
.label __7 = $16
.label line_offset = $16
.label __8 = $19
.label __9 = $16
// if(y>CONIO_HEIGHT)
cpx #$19+1
bcc __b2
ldx #0
__b2:
// conio_cursor_x = x
lda #x
sta.z conio_cursor_x
// conio_cursor_y = y
stx.z conio_cursor_y
// unsigned int line_offset = (unsigned int)y*CONIO_WIDTH
txa
sta.z __7
lda #0
sta.z __7+1
lda.z __7
asl
sta.z __8
lda.z __7+1
rol
sta.z __8+1
asl.z __8
rol.z __8+1
clc
lda.z __9
adc.z __8
sta.z __9
lda.z __9+1
adc.z __8+1
sta.z __9+1
asl.z line_offset
rol.z line_offset+1
asl.z line_offset
rol.z line_offset+1
asl.z line_offset
rol.z line_offset+1
// CONIO_SCREEN_TEXT + line_offset
lda.z line_offset
clc
adc #<DEFAULT_SCREEN
sta.z __5
lda.z line_offset+1
adc #>DEFAULT_SCREEN
sta.z __5+1
// conio_line_text = CONIO_SCREEN_TEXT + line_offset
lda.z __5
sta.z conio_line_text
lda.z __5+1
sta.z conio_line_text+1
// CONIO_SCREEN_COLORS + line_offset
lda.z __6
clc
adc #<COLORRAM
sta.z __6
lda.z __6+1
adc #>COLORRAM
sta.z __6+1
// conio_line_color = CONIO_SCREEN_COLORS + line_offset
lda.z __6
sta.z conio_line_color
lda.z __6+1
sta.z conio_line_color+1
// }
rts
}
// Print a newline
cputln: {
// conio_line_text += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_text
sta.z conio_line_text
bcc !+
inc.z conio_line_text+1
!:
// conio_line_color += CONIO_WIDTH
lda #$28
clc
adc.z conio_line_color
sta.z conio_line_color
bcc !+
inc.z conio_line_color+1
!:
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y++;
inc.z conio_cursor_y
// cscroll()
jsr cscroll
// }
rts
}
// clears the screen and moves the cursor to the upper left-hand corner of the screen.
clrscr: {
.label line_text = 2
.label line_cols = 7
lda #<COLORRAM
sta.z line_cols
lda #>COLORRAM
sta.z line_cols+1
lda #<DEFAULT_SCREEN
sta.z line_text
lda #>DEFAULT_SCREEN
sta.z line_text+1
ldx #0
__b1:
// for( char l=0;l<CONIO_HEIGHT; l++ )
cpx #$19
bcc __b2
// conio_cursor_x = 0
lda #0
sta.z conio_cursor_x
// conio_cursor_y = 0
sta.z conio_cursor_y
// conio_line_text = CONIO_SCREEN_TEXT
lda #<DEFAULT_SCREEN
sta.z conio_line_text
lda #>DEFAULT_SCREEN
sta.z conio_line_text+1
// conio_line_color = CONIO_SCREEN_COLORS
lda #<COLORRAM
sta.z conio_line_color
lda #>COLORRAM
sta.z conio_line_color+1
// }
rts
__b2:
ldy #0
__b3:
// for( char c=0;c<CONIO_WIDTH; c++ )
cpy #$28
bcc __b4
// line_text += CONIO_WIDTH
lda #$28
clc
adc.z line_text
sta.z line_text
bcc !+
inc.z line_text+1
!:
// line_cols += CONIO_WIDTH
lda #$28
clc
adc.z line_cols
sta.z line_cols
bcc !+
inc.z line_cols+1
!:
// for( char l=0;l<CONIO_HEIGHT; l++ )
inx
jmp __b1
__b4:
// line_text[c] = ' '
lda #' '
sta (line_text),y
// line_cols[c] = conio_textcolor
lda #LIGHT_BLUE
sta (line_cols),y
// for( char c=0;c<CONIO_WIDTH; c++ )
iny
jmp __b3
}
// Print an unsigned int using a specific format
// void printf_uint(void (*putc)(char), __zp(2) unsigned int uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uint: {
.const format_min_length = 0
.const format_justify_left = 0
.const format_zero_padding = 0
.const format_upper_case = 0
.label putc = cputc
.label uvalue = 2
// printf_buffer.sign = format.sign_always?'+':0
// Handle any sign
lda #0
sta printf_buffer
// utoa(uvalue, printf_buffer.digits, format.radix)
// Format number into buffer
jsr utoa
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
sta.z printf_number_buffer.buffer_sign
// Print using format
lda #format_upper_case
sta.z printf_number_buffer.format_upper_case
lda #<putc
sta.z printf_number_buffer.putc
lda #>putc
sta.z printf_number_buffer.putc+1
lda #format_zero_padding
sta.z printf_number_buffer.format_zero_padding
lda #format_justify_left
sta.z printf_number_buffer.format_justify_left
ldx #format_min_length
jsr printf_number_buffer
// }
rts
}
/// Print a NUL-terminated string
// void printf_str(__zp(2) void (*putc)(char), __zp(7) const char *s)
printf_str: {
.label s = 7
.label putc = 2
__b1:
// while(c=*s++)
ldy #0
lda (s),y
inc.z s
bne !+
inc.z s+1
!:
cmp #0
bne __b2
// }
rts
__b2:
// putc(c)
pha
jsr icall1
pla
jmp __b1
icall1:
jmp (putc)
}
// Print an unsigned char using a specific format
// void printf_uchar(void (*putc)(char), __register(X) char uvalue, char format_min_length, char format_justify_left, char format_sign_always, char format_zero_padding, char format_upper_case, char format_radix)
printf_uchar: {
// printf_buffer.sign = format.sign_always?'+':0
// Handle any sign
lda #0
sta printf_buffer
// uctoa(uvalue, printf_buffer.digits, format.radix)
// Format number into buffer
jsr uctoa
// printf_number_buffer(putc, printf_buffer, format)
lda printf_buffer
sta.z printf_number_buffer.buffer_sign
// Print using format
lda #0
sta.z printf_number_buffer.format_upper_case
lda #<cputc
sta.z printf_number_buffer.putc
lda #>cputc
sta.z printf_number_buffer.putc+1
lda #0
sta.z printf_number_buffer.format_zero_padding
sta.z printf_number_buffer.format_justify_left
tax
jsr printf_number_buffer
// }
rts
}
// Scroll the entire screen if the cursor is beyond the last line
cscroll: {
// if(conio_cursor_y==CONIO_HEIGHT)
lda #$19
cmp.z conio_cursor_y
bne __breturn
// memcpy(CONIO_SCREEN_TEXT, CONIO_SCREEN_TEXT+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<DEFAULT_SCREEN
sta.z memcpy.destination
lda #>DEFAULT_SCREEN
sta.z memcpy.destination+1
lda #<DEFAULT_SCREEN+$28
sta.z memcpy.source
lda #>DEFAULT_SCREEN+$28
sta.z memcpy.source+1
jsr memcpy
// memcpy(CONIO_SCREEN_COLORS, CONIO_SCREEN_COLORS+CONIO_WIDTH, CONIO_BYTES-CONIO_WIDTH)
lda #<COLORRAM
sta.z memcpy.destination
lda #>COLORRAM
sta.z memcpy.destination+1
lda #<COLORRAM+$28
sta.z memcpy.source
lda #>COLORRAM+$28
sta.z memcpy.source+1
jsr memcpy
// memset(CONIO_SCREEN_TEXT+CONIO_BYTES-CONIO_WIDTH, ' ', CONIO_WIDTH)
ldx #' '
lda #<DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str
lda #>DEFAULT_SCREEN+$19*$28-$28
sta.z memset.str+1
jsr memset
// memset(CONIO_SCREEN_COLORS+CONIO_BYTES-CONIO_WIDTH, conio_textcolor, CONIO_WIDTH)
ldx #LIGHT_BLUE
lda #<COLORRAM+$19*$28-$28
sta.z memset.str
lda #>COLORRAM+$19*$28-$28
sta.z memset.str+1
jsr memset
// conio_line_text -= CONIO_WIDTH
sec
lda.z conio_line_text
sbc #$28
sta.z conio_line_text
lda.z conio_line_text+1
sbc #0
sta.z conio_line_text+1
// conio_line_color -= CONIO_WIDTH
sec
lda.z conio_line_color
sbc #$28
sta.z conio_line_color
lda.z conio_line_color+1
sbc #0
sta.z conio_line_color+1
// conio_cursor_y--;
dec.z conio_cursor_y
__breturn:
// }
rts
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void utoa(__zp(2) unsigned int value, __zp(7) char *buffer, char radix)
utoa: {
.const max_digits = 4
.label digit_value = 4
.label buffer = 7
.label digit = $b
.label value = 2
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
ldx #0
txa
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #max_digits-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
ldx.z value
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned int digit_value = digit_values[digit]
lda.z digit
asl
tay
lda RADIX_HEXADECIMAL_VALUES,y
sta.z digit_value
lda RADIX_HEXADECIMAL_VALUES+1,y
sta.z digit_value+1
// if (started || value >= digit_value)
cpx #0
bne __b5
cmp.z value+1
bne !+
lda.z digit_value
cmp.z value
beq __b5
!:
bcc __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// utoa_append(buffer++, value, digit_value)
jsr utoa_append
// utoa_append(buffer++, value, digit_value)
// value = utoa_append(buffer++, value, digit_value)
// value = utoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
ldx #1
jmp __b4
}
// Print the contents of the number buffer using a specific format.
// This handles minimum length, zero-filling, and left/right justification from the format
// void printf_number_buffer(__zp(2) void (*putc)(char), __zp($e) char buffer_sign, char *buffer_digits, __register(X) char format_min_length, __zp($b) char format_justify_left, char format_sign_always, __zp($a) char format_zero_padding, __zp(6) char format_upper_case, char format_radix)
printf_number_buffer: {
.label __19 = 4
.label buffer_sign = $e
.label padding = $13
.label putc = 2
.label format_zero_padding = $a
.label format_justify_left = $b
.label format_upper_case = 6
// if(format.min_length)
cpx #0
beq __b6
// strlen(buffer.digits)
jsr strlen
// strlen(buffer.digits)
// signed char len = (signed char)strlen(buffer.digits)
// There is a minimum length - work out the padding
ldy.z __19
// if(buffer.sign)
lda.z buffer_sign
beq __b13
// len++;
iny
__b13:
// padding = (signed char)format.min_length - len
txa
sty.z $ff
sec
sbc.z $ff
sta.z padding
// if(padding<0)
cmp #0
bpl __b1
__b6:
lda #0
sta.z padding
__b1:
// if(!format.justify_left && !format.zero_padding && padding)
lda.z format_justify_left
bne __b2
lda.z format_zero_padding
bne __b2
lda.z padding
cmp #0
bne __b8
jmp __b2
__b8:
// printf_padding(putc, ' ',(char)padding)
lda.z padding
sta.z printf_padding.length
lda #' '
sta.z printf_padding.pad
jsr printf_padding
__b2:
// if(buffer.sign)
lda.z buffer_sign
beq __b3
// putc(buffer.sign)
pha
jsr icall2
pla
__b3:
// if(format.zero_padding && padding)
lda.z format_zero_padding
beq __b4
lda.z padding
cmp #0
bne __b10
jmp __b4
__b10:
// printf_padding(putc, '0',(char)padding)
lda.z padding
sta.z printf_padding.length
lda #'0'
sta.z printf_padding.pad
jsr printf_padding
__b4:
// if(format.upper_case)
lda.z format_upper_case
beq __b5
// strupr(buffer.digits)
jsr strupr
__b5:
// printf_str(putc, buffer.digits)
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z printf_str.s
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z printf_str.s+1
jsr printf_str
// if(format.justify_left && !format.zero_padding && padding)
lda.z format_justify_left
beq __breturn
lda.z format_zero_padding
bne __breturn
lda.z padding
cmp #0
bne __b12
rts
__b12:
// printf_padding(putc, ' ',(char)padding)
lda.z padding
sta.z printf_padding.length
lda #' '
sta.z printf_padding.pad
jsr printf_padding
__breturn:
// }
rts
icall2:
jmp (putc)
}
// Converts unsigned number value to a string representing it in RADIX format.
// If the leading digits are zero they are not included in the string.
// - value : The number to be converted to RADIX
// - buffer : receives the string representing the number and zero-termination.
// - radix : The radix to convert the number to (from the enum RADIX)
// void uctoa(__register(X) char value, __zp(2) char *buffer, char radix)
uctoa: {
.label digit_value = 6
.label buffer = 2
.label digit = $a
.label started = $e
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z buffer+1
lda #0
sta.z started
sta.z digit
__b1:
// for( char digit=0; digit<max_digits-1; digit++ )
lda.z digit
cmp #3-1
bcc __b2
// *buffer++ = DIGITS[(char)value]
lda DIGITS,x
ldy #0
sta (buffer),y
// *buffer++ = DIGITS[(char)value];
inc.z buffer
bne !+
inc.z buffer+1
!:
// *buffer = 0
lda #0
tay
sta (buffer),y
// }
rts
__b2:
// unsigned char digit_value = digit_values[digit]
ldy.z digit
lda RADIX_DECIMAL_VALUES_CHAR,y
sta.z digit_value
// if (started || value >= digit_value)
lda.z started
bne __b5
cpx.z digit_value
bcs __b5
__b4:
// for( char digit=0; digit<max_digits-1; digit++ )
inc.z digit
jmp __b1
__b5:
// uctoa_append(buffer++, value, digit_value)
jsr uctoa_append
// uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value)
// value = uctoa_append(buffer++, value, digit_value);
inc.z buffer
bne !+
inc.z buffer+1
!:
lda #1
sta.z started
jmp __b4
}
// Copy block of memory (forwards)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
// void * memcpy(__zp($11) void *destination, __zp($f) void *source, unsigned int num)
memcpy: {
.label src_end = $14
.label dst = $11
.label src = $f
.label source = $f
.label destination = $11
// char* src_end = (char*)source+num
lda.z source
clc
adc #<$19*$28-$28
sta.z src_end
lda.z source+1
adc #>$19*$28-$28
sta.z src_end+1
__b1:
// while(src!=src_end)
lda.z src+1
cmp.z src_end+1
bne __b2
lda.z src
cmp.z src_end
bne __b2
// }
rts
__b2:
// *dst++ = *src++
ldy #0
lda (src),y
sta (dst),y
// *dst++ = *src++;
inc.z dst
bne !+
inc.z dst+1
!:
inc.z src
bne !+
inc.z src+1
!:
jmp __b1
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
// void * memset(__zp($f) void *str, __register(X) char c, unsigned int num)
memset: {
.label end = $11
.label dst = $f
.label str = $f
// char* end = (char*)str + num
lda #$28
clc
adc.z str
sta.z end
lda #0
adc.z str+1
sta.z end+1
__b2:
// for(char* dst = str; dst!=end; dst++)
lda.z dst+1
cmp.z end+1
bne __b3
lda.z dst
cmp.z end
bne __b3
// }
rts
__b3:
// *dst = c
txa
ldy #0
sta (dst),y
// for(char* dst = str; dst!=end; dst++)
inc.z dst
bne !+
inc.z dst+1
!:
jmp __b2
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __zp(2) unsigned int utoa_append(__zp(7) char *buffer, __zp(2) unsigned int value, __zp(4) unsigned int sub)
utoa_append: {
.label buffer = 7
.label value = 2
.label sub = 4
.label return = 2
ldx #0
__b1:
// while (value >= sub)
lda.z sub+1
cmp.z value+1
bne !+
lda.z sub
cmp.z value
beq __b2
!:
bcc __b2
// *buffer = DIGITS[digit]
lda DIGITS,x
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
inx
// value -= sub
lda.z value
sec
sbc.z sub
sta.z value
lda.z value+1
sbc.z sub+1
sta.z value+1
jmp __b1
}
// Computes the length of the string str up to but not including the terminating null character.
// __zp(4) unsigned int strlen(__zp(7) char *str)
strlen: {
.label len = 4
.label str = 7
.label return = 4
lda #<0
sta.z len
sta.z len+1
lda #<printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z str
lda #>printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
sta.z str+1
__b1:
// while(*str)
ldy #0
lda (str),y
cmp #0
bne __b2
// }
rts
__b2:
// len++;
inc.z len
bne !+
inc.z len+1
!:
// str++;
inc.z str
bne !+
inc.z str+1
!:
jmp __b1
}
// Print a padding char a number of times
// void printf_padding(__zp(2) void (*putc)(char), __zp($d) char pad, __zp($c) char length)
printf_padding: {
.label i = 9
.label putc = 2
.label length = $c
.label pad = $d
lda #0
sta.z i
__b1:
// for(char i=0;i<length; i++)
lda.z i
cmp.z length
bcc __b2
// }
rts
__b2:
// putc(pad)
lda.z pad
pha
jsr icall3
pla
// for(char i=0;i<length; i++)
inc.z i
jmp __b1
icall3:
jmp (putc)
}
// Converts a string to uppercase.
// char * strupr(char *str)
strupr: {
.label str = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS
.label src = 4
lda #<str
sta.z src
lda #>str
sta.z src+1
__b1:
// while(*src)
ldy #0
lda (src),y
cmp #0
bne __b2
// }
rts
__b2:
// toupper(*src)
ldy #0
lda (src),y
jsr toupper
// *src = toupper(*src)
ldy #0
sta (src),y
// src++;
inc.z src
bne !+
inc.z src+1
!:
jmp __b1
}
// Used to convert a single digit of an unsigned number value to a string representation
// Counts a single digit up from '0' as long as the value is larger than sub.
// Each time the digit is increased sub is subtracted from value.
// - buffer : pointer to the char that receives the digit
// - value : The value where the digit will be derived from
// - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased.
// (For decimal the subs used are 10000, 1000, 100, 10, 1)
// returns : the value reduced by sub * digit so that it is less than sub.
// __register(X) char uctoa_append(__zp(2) char *buffer, __register(X) char value, __zp(6) char sub)
uctoa_append: {
.label buffer = 2
.label sub = 6
ldy #0
__b1:
// while (value >= sub)
cpx.z sub
bcs __b2
// *buffer = DIGITS[digit]
lda DIGITS,y
ldy #0
sta (buffer),y
// }
rts
__b2:
// digit++;
iny
// value -= sub
txa
sec
sbc.z sub
tax
jmp __b1
}
// Convert lowercase alphabet to uppercase
// Returns uppercase equivalent to c, if such value exists, else c remains unchanged
// __register(A) char toupper(__register(A) char ch)
toupper: {
// if(ch>='a' && ch<='z')
cmp #'a'
bcc __breturn
cmp #'z'
bcc __b1
beq __b1
rts
__b1:
// return ch + ('A'-'a');
clc
adc #'A'-'a'
__breturn:
// }
rts
}
.segment Data
// The digits used for numbers
DIGITS: .text "0123456789abcdef"
// Values of decimal digits
RADIX_DECIMAL_VALUES_CHAR: .byte $64, $a
// Values of hexadecimal digits
RADIX_HEXADECIMAL_VALUES: .word $1000, $100, $10
stars: .byte $32, $32, 2, 7, $28, $46, 2, 7, $1e, $14, 2, 7, $46, $a, 2, 7, $28, $50, 2, 7
// Buffer used for stringified number being printed
printf_buffer: .fill SIZEOF_STRUCT_PRINTF_BUFFER_NUMBER, 0
|
dnl Alpha __gmpn_submul_1 -- Multiply a limb vector with a limb and
dnl subtract the result from a second limb vector.
dnl Copyright (C) 1992, 1994, 1995, 2000 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Library General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or (at your
dnl option) any later version.
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
dnl License for more details.
dnl You should have received a copy of the GNU Library General Public License
dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
dnl MA 02111-1307, USA.
include(`../config.m4')
dnl INPUT PARAMETERS
dnl res_ptr r16
dnl s1_ptr r17
dnl size r18
dnl s2_limb r19
dnl This code runs at 42 cycles/limb on EV4, 18 cycles/limb on EV5, and 7
dnl cycles/limb on EV6.
ASM_START()
PROLOGUE(mpn_submul_1)
ldq r2,0(r17) C r2 = s1_limb
addq r17,8,r17 C s1_ptr++
subq r18,1,r18 C size--
mulq r2,r19,r3 C r3 = prod_low
ldq r5,0(r16) C r5 = *res_ptr
umulh r2,r19,r0 C r0 = prod_high
beq r18,$Lend1 C jump if size was == 1
ldq r2,0(r17) C r2 = s1_limb
addq r17,8,r17 C s1_ptr++
subq r18,1,r18 C size--
subq r5,r3,r3
cmpult r5,r3,r4
stq r3,0(r16)
addq r16,8,r16 C res_ptr++
beq r18,$Lend2 C jump if size was == 2
ALIGN(8)
$Loop: mulq r2,r19,r3 C r3 = prod_low
ldq r5,0(r16) C r5 = *res_ptr
addq r4,r0,r0 C cy_limb = cy_limb + 'cy'
subq r18,1,r18 C size--
umulh r2,r19,r4 C r4 = cy_limb
ldq r2,0(r17) C r2 = s1_limb
addq r17,8,r17 C s1_ptr++
addq r3,r0,r3 C r3 = cy_limb + prod_low
cmpult r3,r0,r0 C r0 = carry from (cy_limb + prod_low)
subq r5,r3,r3
cmpult r5,r3,r5
stq r3,0(r16)
addq r16,8,r16 C res_ptr++
addq r5,r0,r0 C combine carries
bne r18,$Loop
$Lend2: mulq r2,r19,r3 C r3 = prod_low
ldq r5,0(r16) C r5 = *res_ptr
addq r4,r0,r0 C cy_limb = cy_limb + 'cy'
umulh r2,r19,r4 C r4 = cy_limb
addq r3,r0,r3 C r3 = cy_limb + prod_low
cmpult r3,r0,r0 C r0 = carry from (cy_limb + prod_low)
subq r5,r3,r3
cmpult r5,r3,r5
stq r3,0(r16)
addq r5,r0,r0 C combine carries
addq r4,r0,r0 C cy_limb = prod_high + cy
ret r31,(r26),1
$Lend1: subq r5,r3,r3
cmpult r5,r3,r5
stq r3,0(r16)
addq r0,r5,r0
ret r31,(r26),1
EPILOGUE(mpn_submul_1)
ASM_END()
|
_sh: file format elf32-i386
Disassembly of section .text:
00000000 <runcmd>:
struct cmd *parsecmd(char*);
// Execute cmd. Never returns.
void
runcmd(struct cmd *cmd)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 28 sub $0x28,%esp
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
6: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
a: 75 05 jne 11 <runcmd+0x11>
exit();
c: e8 d6 0e 00 00 call ee7 <exit>
switch(cmd->type){
11: 8b 45 08 mov 0x8(%ebp),%eax
14: 8b 00 mov (%eax),%eax
16: 83 f8 05 cmp $0x5,%eax
19: 77 09 ja 24 <runcmd+0x24>
1b: 8b 04 85 58 14 00 00 mov 0x1458(,%eax,4),%eax
22: ff e0 jmp *%eax
default:
panic("runcmd");
24: 83 ec 0c sub $0xc,%esp
27: 68 2c 14 00 00 push $0x142c
2c: e8 7d 03 00 00 call 3ae <panic>
31: 83 c4 10 add $0x10,%esp
case EXEC:
ecmd = (struct execcmd*)cmd;
34: 8b 45 08 mov 0x8(%ebp),%eax
37: 89 45 f4 mov %eax,-0xc(%ebp)
if(ecmd->argv[0] == 0)
3a: 8b 45 f4 mov -0xc(%ebp),%eax
3d: 8b 40 04 mov 0x4(%eax),%eax
40: 85 c0 test %eax,%eax
42: 75 05 jne 49 <runcmd+0x49>
exit();
44: e8 9e 0e 00 00 call ee7 <exit>
exec(ecmd->argv[0], ecmd->argv);
49: 8b 45 f4 mov -0xc(%ebp),%eax
4c: 8d 50 04 lea 0x4(%eax),%edx
4f: 8b 45 f4 mov -0xc(%ebp),%eax
52: 8b 40 04 mov 0x4(%eax),%eax
55: 83 ec 08 sub $0x8,%esp
58: 52 push %edx
59: 50 push %eax
5a: e8 c0 0e 00 00 call f1f <exec>
5f: 83 c4 10 add $0x10,%esp
printf(2, "exec %s failed\n", ecmd->argv[0]);
62: 8b 45 f4 mov -0xc(%ebp),%eax
65: 8b 40 04 mov 0x4(%eax),%eax
68: 83 ec 04 sub $0x4,%esp
6b: 50 push %eax
6c: 68 33 14 00 00 push $0x1433
71: 6a 02 push $0x2
73: e8 fe 0f 00 00 call 1076 <printf>
78: 83 c4 10 add $0x10,%esp
break;
7b: e9 c6 01 00 00 jmp 246 <runcmd+0x246>
case REDIR:
rcmd = (struct redircmd*)cmd;
80: 8b 45 08 mov 0x8(%ebp),%eax
83: 89 45 f0 mov %eax,-0x10(%ebp)
close(rcmd->fd);
86: 8b 45 f0 mov -0x10(%ebp),%eax
89: 8b 40 14 mov 0x14(%eax),%eax
8c: 83 ec 0c sub $0xc,%esp
8f: 50 push %eax
90: e8 7a 0e 00 00 call f0f <close>
95: 83 c4 10 add $0x10,%esp
if(open(rcmd->file, rcmd->mode) < 0){
98: 8b 45 f0 mov -0x10(%ebp),%eax
9b: 8b 50 10 mov 0x10(%eax),%edx
9e: 8b 45 f0 mov -0x10(%ebp),%eax
a1: 8b 40 08 mov 0x8(%eax),%eax
a4: 83 ec 08 sub $0x8,%esp
a7: 52 push %edx
a8: 50 push %eax
a9: e8 79 0e 00 00 call f27 <open>
ae: 83 c4 10 add $0x10,%esp
b1: 85 c0 test %eax,%eax
b3: 79 1e jns d3 <runcmd+0xd3>
printf(2, "open %s failed\n", rcmd->file);
b5: 8b 45 f0 mov -0x10(%ebp),%eax
b8: 8b 40 08 mov 0x8(%eax),%eax
bb: 83 ec 04 sub $0x4,%esp
be: 50 push %eax
bf: 68 43 14 00 00 push $0x1443
c4: 6a 02 push $0x2
c6: e8 ab 0f 00 00 call 1076 <printf>
cb: 83 c4 10 add $0x10,%esp
exit();
ce: e8 14 0e 00 00 call ee7 <exit>
}
runcmd(rcmd->cmd);
d3: 8b 45 f0 mov -0x10(%ebp),%eax
d6: 8b 40 04 mov 0x4(%eax),%eax
d9: 83 ec 0c sub $0xc,%esp
dc: 50 push %eax
dd: e8 1e ff ff ff call 0 <runcmd>
e2: 83 c4 10 add $0x10,%esp
break;
e5: e9 5c 01 00 00 jmp 246 <runcmd+0x246>
case LIST:
lcmd = (struct listcmd*)cmd;
ea: 8b 45 08 mov 0x8(%ebp),%eax
ed: 89 45 ec mov %eax,-0x14(%ebp)
if(fork1() == 0)
f0: e8 d9 02 00 00 call 3ce <fork1>
f5: 85 c0 test %eax,%eax
f7: 75 12 jne 10b <runcmd+0x10b>
runcmd(lcmd->left);
f9: 8b 45 ec mov -0x14(%ebp),%eax
fc: 8b 40 04 mov 0x4(%eax),%eax
ff: 83 ec 0c sub $0xc,%esp
102: 50 push %eax
103: e8 f8 fe ff ff call 0 <runcmd>
108: 83 c4 10 add $0x10,%esp
wait();
10b: e8 df 0d 00 00 call eef <wait>
runcmd(lcmd->right);
110: 8b 45 ec mov -0x14(%ebp),%eax
113: 8b 40 08 mov 0x8(%eax),%eax
116: 83 ec 0c sub $0xc,%esp
119: 50 push %eax
11a: e8 e1 fe ff ff call 0 <runcmd>
11f: 83 c4 10 add $0x10,%esp
break;
122: e9 1f 01 00 00 jmp 246 <runcmd+0x246>
case PIPE:
pcmd = (struct pipecmd*)cmd;
127: 8b 45 08 mov 0x8(%ebp),%eax
12a: 89 45 e8 mov %eax,-0x18(%ebp)
if(pipe(p) < 0)
12d: 83 ec 0c sub $0xc,%esp
130: 8d 45 dc lea -0x24(%ebp),%eax
133: 50 push %eax
134: e8 be 0d 00 00 call ef7 <pipe>
139: 83 c4 10 add $0x10,%esp
13c: 85 c0 test %eax,%eax
13e: 79 10 jns 150 <runcmd+0x150>
panic("pipe");
140: 83 ec 0c sub $0xc,%esp
143: 68 53 14 00 00 push $0x1453
148: e8 61 02 00 00 call 3ae <panic>
14d: 83 c4 10 add $0x10,%esp
if(fork1() == 0){
150: e8 79 02 00 00 call 3ce <fork1>
155: 85 c0 test %eax,%eax
157: 75 4c jne 1a5 <runcmd+0x1a5>
close(1);
159: 83 ec 0c sub $0xc,%esp
15c: 6a 01 push $0x1
15e: e8 ac 0d 00 00 call f0f <close>
163: 83 c4 10 add $0x10,%esp
dup(p[1]);
166: 8b 45 e0 mov -0x20(%ebp),%eax
169: 83 ec 0c sub $0xc,%esp
16c: 50 push %eax
16d: e8 ed 0d 00 00 call f5f <dup>
172: 83 c4 10 add $0x10,%esp
close(p[0]);
175: 8b 45 dc mov -0x24(%ebp),%eax
178: 83 ec 0c sub $0xc,%esp
17b: 50 push %eax
17c: e8 8e 0d 00 00 call f0f <close>
181: 83 c4 10 add $0x10,%esp
close(p[1]);
184: 8b 45 e0 mov -0x20(%ebp),%eax
187: 83 ec 0c sub $0xc,%esp
18a: 50 push %eax
18b: e8 7f 0d 00 00 call f0f <close>
190: 83 c4 10 add $0x10,%esp
runcmd(pcmd->left);
193: 8b 45 e8 mov -0x18(%ebp),%eax
196: 8b 40 04 mov 0x4(%eax),%eax
199: 83 ec 0c sub $0xc,%esp
19c: 50 push %eax
19d: e8 5e fe ff ff call 0 <runcmd>
1a2: 83 c4 10 add $0x10,%esp
}
if(fork1() == 0){
1a5: e8 24 02 00 00 call 3ce <fork1>
1aa: 85 c0 test %eax,%eax
1ac: 75 4c jne 1fa <runcmd+0x1fa>
close(0);
1ae: 83 ec 0c sub $0xc,%esp
1b1: 6a 00 push $0x0
1b3: e8 57 0d 00 00 call f0f <close>
1b8: 83 c4 10 add $0x10,%esp
dup(p[0]);
1bb: 8b 45 dc mov -0x24(%ebp),%eax
1be: 83 ec 0c sub $0xc,%esp
1c1: 50 push %eax
1c2: e8 98 0d 00 00 call f5f <dup>
1c7: 83 c4 10 add $0x10,%esp
close(p[0]);
1ca: 8b 45 dc mov -0x24(%ebp),%eax
1cd: 83 ec 0c sub $0xc,%esp
1d0: 50 push %eax
1d1: e8 39 0d 00 00 call f0f <close>
1d6: 83 c4 10 add $0x10,%esp
close(p[1]);
1d9: 8b 45 e0 mov -0x20(%ebp),%eax
1dc: 83 ec 0c sub $0xc,%esp
1df: 50 push %eax
1e0: e8 2a 0d 00 00 call f0f <close>
1e5: 83 c4 10 add $0x10,%esp
runcmd(pcmd->right);
1e8: 8b 45 e8 mov -0x18(%ebp),%eax
1eb: 8b 40 08 mov 0x8(%eax),%eax
1ee: 83 ec 0c sub $0xc,%esp
1f1: 50 push %eax
1f2: e8 09 fe ff ff call 0 <runcmd>
1f7: 83 c4 10 add $0x10,%esp
}
close(p[0]);
1fa: 8b 45 dc mov -0x24(%ebp),%eax
1fd: 83 ec 0c sub $0xc,%esp
200: 50 push %eax
201: e8 09 0d 00 00 call f0f <close>
206: 83 c4 10 add $0x10,%esp
close(p[1]);
209: 8b 45 e0 mov -0x20(%ebp),%eax
20c: 83 ec 0c sub $0xc,%esp
20f: 50 push %eax
210: e8 fa 0c 00 00 call f0f <close>
215: 83 c4 10 add $0x10,%esp
wait();
218: e8 d2 0c 00 00 call eef <wait>
wait();
21d: e8 cd 0c 00 00 call eef <wait>
break;
222: eb 22 jmp 246 <runcmd+0x246>
case BACK:
bcmd = (struct backcmd*)cmd;
224: 8b 45 08 mov 0x8(%ebp),%eax
227: 89 45 e4 mov %eax,-0x1c(%ebp)
if(fork1() == 0)
22a: e8 9f 01 00 00 call 3ce <fork1>
22f: 85 c0 test %eax,%eax
231: 75 12 jne 245 <runcmd+0x245>
runcmd(bcmd->cmd);
233: 8b 45 e4 mov -0x1c(%ebp),%eax
236: 8b 40 04 mov 0x4(%eax),%eax
239: 83 ec 0c sub $0xc,%esp
23c: 50 push %eax
23d: e8 be fd ff ff call 0 <runcmd>
242: 83 c4 10 add $0x10,%esp
break;
245: 90 nop
}
exit();
246: e8 9c 0c 00 00 call ee7 <exit>
0000024b <getcmd>:
}
int
getcmd(char *buf, int nbuf)
{
24b: 55 push %ebp
24c: 89 e5 mov %esp,%ebp
24e: 83 ec 08 sub $0x8,%esp
printf(2, "$ ");
251: 83 ec 08 sub $0x8,%esp
254: 68 70 14 00 00 push $0x1470
259: 6a 02 push $0x2
25b: e8 16 0e 00 00 call 1076 <printf>
260: 83 c4 10 add $0x10,%esp
memset(buf, 0, nbuf);
263: 8b 45 0c mov 0xc(%ebp),%eax
266: 83 ec 04 sub $0x4,%esp
269: 50 push %eax
26a: 6a 00 push $0x0
26c: ff 75 08 pushl 0x8(%ebp)
26f: e8 d8 0a 00 00 call d4c <memset>
274: 83 c4 10 add $0x10,%esp
gets(buf, nbuf);
277: 83 ec 08 sub $0x8,%esp
27a: ff 75 0c pushl 0xc(%ebp)
27d: ff 75 08 pushl 0x8(%ebp)
280: e8 14 0b 00 00 call d99 <gets>
285: 83 c4 10 add $0x10,%esp
if(buf[0] == 0) // EOF
288: 8b 45 08 mov 0x8(%ebp),%eax
28b: 0f b6 00 movzbl (%eax),%eax
28e: 84 c0 test %al,%al
290: 75 07 jne 299 <getcmd+0x4e>
return -1;
292: b8 ff ff ff ff mov $0xffffffff,%eax
297: eb 05 jmp 29e <getcmd+0x53>
return 0;
299: b8 00 00 00 00 mov $0x0,%eax
}
29e: c9 leave
29f: c3 ret
000002a0 <main>:
int
main(void)
{
2a0: 8d 4c 24 04 lea 0x4(%esp),%ecx
2a4: 83 e4 f0 and $0xfffffff0,%esp
2a7: ff 71 fc pushl -0x4(%ecx)
2aa: 55 push %ebp
2ab: 89 e5 mov %esp,%ebp
2ad: 51 push %ecx
2ae: 83 ec 14 sub $0x14,%esp
#ifdef RR
printf(1,"RR\n");
2b1: 83 ec 08 sub $0x8,%esp
2b4: 68 73 14 00 00 push $0x1473
2b9: 6a 01 push $0x1
2bb: e8 b6 0d 00 00 call 1076 <printf>
2c0: 83 c4 10 add $0x10,%esp
#endif
static char buf[100];
int fd;
// Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){
2c3: eb 16 jmp 2db <main+0x3b>
if(fd >= 3){
2c5: 83 7d f4 02 cmpl $0x2,-0xc(%ebp)
2c9: 7e 10 jle 2db <main+0x3b>
close(fd);
2cb: 83 ec 0c sub $0xc,%esp
2ce: ff 75 f4 pushl -0xc(%ebp)
2d1: e8 39 0c 00 00 call f0f <close>
2d6: 83 c4 10 add $0x10,%esp
break;
2d9: eb 1b jmp 2f6 <main+0x56>
#endif
static char buf[100];
int fd;
// Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){
2db: 83 ec 08 sub $0x8,%esp
2de: 6a 02 push $0x2
2e0: 68 77 14 00 00 push $0x1477
2e5: e8 3d 0c 00 00 call f27 <open>
2ea: 83 c4 10 add $0x10,%esp
2ed: 89 45 f4 mov %eax,-0xc(%ebp)
2f0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2f4: 79 cf jns 2c5 <main+0x25>
break;
}
}
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
2f6: e9 94 00 00 00 jmp 38f <main+0xef>
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
2fb: 0f b6 05 e0 19 00 00 movzbl 0x19e0,%eax
302: 3c 63 cmp $0x63,%al
304: 75 5f jne 365 <main+0xc5>
306: 0f b6 05 e1 19 00 00 movzbl 0x19e1,%eax
30d: 3c 64 cmp $0x64,%al
30f: 75 54 jne 365 <main+0xc5>
311: 0f b6 05 e2 19 00 00 movzbl 0x19e2,%eax
318: 3c 20 cmp $0x20,%al
31a: 75 49 jne 365 <main+0xc5>
// Chdir must be called by the parent, not the child.
buf[strlen(buf)-1] = 0; // chop \n
31c: 83 ec 0c sub $0xc,%esp
31f: 68 e0 19 00 00 push $0x19e0
324: e8 fc 09 00 00 call d25 <strlen>
329: 83 c4 10 add $0x10,%esp
32c: 83 e8 01 sub $0x1,%eax
32f: c6 80 e0 19 00 00 00 movb $0x0,0x19e0(%eax)
if(chdir(buf+3) < 0)
336: b8 e3 19 00 00 mov $0x19e3,%eax
33b: 83 ec 0c sub $0xc,%esp
33e: 50 push %eax
33f: e8 13 0c 00 00 call f57 <chdir>
344: 83 c4 10 add $0x10,%esp
347: 85 c0 test %eax,%eax
349: 79 44 jns 38f <main+0xef>
printf(2, "cannot cd %s\n", buf+3);
34b: b8 e3 19 00 00 mov $0x19e3,%eax
350: 83 ec 04 sub $0x4,%esp
353: 50 push %eax
354: 68 7f 14 00 00 push $0x147f
359: 6a 02 push $0x2
35b: e8 16 0d 00 00 call 1076 <printf>
360: 83 c4 10 add $0x10,%esp
continue;
363: eb 2a jmp 38f <main+0xef>
}
if(fork1() == 0)
365: e8 64 00 00 00 call 3ce <fork1>
36a: 85 c0 test %eax,%eax
36c: 75 1c jne 38a <main+0xea>
runcmd(parsecmd(buf));
36e: 83 ec 0c sub $0xc,%esp
371: 68 e0 19 00 00 push $0x19e0
376: e8 ab 03 00 00 call 726 <parsecmd>
37b: 83 c4 10 add $0x10,%esp
37e: 83 ec 0c sub $0xc,%esp
381: 50 push %eax
382: e8 79 fc ff ff call 0 <runcmd>
387: 83 c4 10 add $0x10,%esp
wait();
38a: e8 60 0b 00 00 call eef <wait>
break;
}
}
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
38f: 83 ec 08 sub $0x8,%esp
392: 6a 64 push $0x64
394: 68 e0 19 00 00 push $0x19e0
399: e8 ad fe ff ff call 24b <getcmd>
39e: 83 c4 10 add $0x10,%esp
3a1: 85 c0 test %eax,%eax
3a3: 0f 89 52 ff ff ff jns 2fb <main+0x5b>
}
if(fork1() == 0)
runcmd(parsecmd(buf));
wait();
}
exit();
3a9: e8 39 0b 00 00 call ee7 <exit>
000003ae <panic>:
}
void
panic(char *s)
{
3ae: 55 push %ebp
3af: 89 e5 mov %esp,%ebp
3b1: 83 ec 08 sub $0x8,%esp
printf(2, "%s\n", s);
3b4: 83 ec 04 sub $0x4,%esp
3b7: ff 75 08 pushl 0x8(%ebp)
3ba: 68 8d 14 00 00 push $0x148d
3bf: 6a 02 push $0x2
3c1: e8 b0 0c 00 00 call 1076 <printf>
3c6: 83 c4 10 add $0x10,%esp
exit();
3c9: e8 19 0b 00 00 call ee7 <exit>
000003ce <fork1>:
}
int
fork1(void)
{
3ce: 55 push %ebp
3cf: 89 e5 mov %esp,%ebp
3d1: 83 ec 18 sub $0x18,%esp
int pid;
pid = fork();
3d4: e8 06 0b 00 00 call edf <fork>
3d9: 89 45 f4 mov %eax,-0xc(%ebp)
if(pid == -1)
3dc: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
3e0: 75 10 jne 3f2 <fork1+0x24>
panic("fork");
3e2: 83 ec 0c sub $0xc,%esp
3e5: 68 91 14 00 00 push $0x1491
3ea: e8 bf ff ff ff call 3ae <panic>
3ef: 83 c4 10 add $0x10,%esp
return pid;
3f2: 8b 45 f4 mov -0xc(%ebp),%eax
}
3f5: c9 leave
3f6: c3 ret
000003f7 <execcmd>:
//PAGEBREAK!
// Constructors
struct cmd*
execcmd(void)
{
3f7: 55 push %ebp
3f8: 89 e5 mov %esp,%ebp
3fa: 83 ec 18 sub $0x18,%esp
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
3fd: 83 ec 0c sub $0xc,%esp
400: 6a 54 push $0x54
402: e8 42 0f 00 00 call 1349 <malloc>
407: 83 c4 10 add $0x10,%esp
40a: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
40d: 83 ec 04 sub $0x4,%esp
410: 6a 54 push $0x54
412: 6a 00 push $0x0
414: ff 75 f4 pushl -0xc(%ebp)
417: e8 30 09 00 00 call d4c <memset>
41c: 83 c4 10 add $0x10,%esp
cmd->type = EXEC;
41f: 8b 45 f4 mov -0xc(%ebp),%eax
422: c7 00 01 00 00 00 movl $0x1,(%eax)
return (struct cmd*)cmd;
428: 8b 45 f4 mov -0xc(%ebp),%eax
}
42b: c9 leave
42c: c3 ret
0000042d <redircmd>:
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
42d: 55 push %ebp
42e: 89 e5 mov %esp,%ebp
430: 83 ec 18 sub $0x18,%esp
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
433: 83 ec 0c sub $0xc,%esp
436: 6a 18 push $0x18
438: e8 0c 0f 00 00 call 1349 <malloc>
43d: 83 c4 10 add $0x10,%esp
440: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
443: 83 ec 04 sub $0x4,%esp
446: 6a 18 push $0x18
448: 6a 00 push $0x0
44a: ff 75 f4 pushl -0xc(%ebp)
44d: e8 fa 08 00 00 call d4c <memset>
452: 83 c4 10 add $0x10,%esp
cmd->type = REDIR;
455: 8b 45 f4 mov -0xc(%ebp),%eax
458: c7 00 02 00 00 00 movl $0x2,(%eax)
cmd->cmd = subcmd;
45e: 8b 45 f4 mov -0xc(%ebp),%eax
461: 8b 55 08 mov 0x8(%ebp),%edx
464: 89 50 04 mov %edx,0x4(%eax)
cmd->file = file;
467: 8b 45 f4 mov -0xc(%ebp),%eax
46a: 8b 55 0c mov 0xc(%ebp),%edx
46d: 89 50 08 mov %edx,0x8(%eax)
cmd->efile = efile;
470: 8b 45 f4 mov -0xc(%ebp),%eax
473: 8b 55 10 mov 0x10(%ebp),%edx
476: 89 50 0c mov %edx,0xc(%eax)
cmd->mode = mode;
479: 8b 45 f4 mov -0xc(%ebp),%eax
47c: 8b 55 14 mov 0x14(%ebp),%edx
47f: 89 50 10 mov %edx,0x10(%eax)
cmd->fd = fd;
482: 8b 45 f4 mov -0xc(%ebp),%eax
485: 8b 55 18 mov 0x18(%ebp),%edx
488: 89 50 14 mov %edx,0x14(%eax)
return (struct cmd*)cmd;
48b: 8b 45 f4 mov -0xc(%ebp),%eax
}
48e: c9 leave
48f: c3 ret
00000490 <pipecmd>:
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
490: 55 push %ebp
491: 89 e5 mov %esp,%ebp
493: 83 ec 18 sub $0x18,%esp
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
496: 83 ec 0c sub $0xc,%esp
499: 6a 0c push $0xc
49b: e8 a9 0e 00 00 call 1349 <malloc>
4a0: 83 c4 10 add $0x10,%esp
4a3: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
4a6: 83 ec 04 sub $0x4,%esp
4a9: 6a 0c push $0xc
4ab: 6a 00 push $0x0
4ad: ff 75 f4 pushl -0xc(%ebp)
4b0: e8 97 08 00 00 call d4c <memset>
4b5: 83 c4 10 add $0x10,%esp
cmd->type = PIPE;
4b8: 8b 45 f4 mov -0xc(%ebp),%eax
4bb: c7 00 03 00 00 00 movl $0x3,(%eax)
cmd->left = left;
4c1: 8b 45 f4 mov -0xc(%ebp),%eax
4c4: 8b 55 08 mov 0x8(%ebp),%edx
4c7: 89 50 04 mov %edx,0x4(%eax)
cmd->right = right;
4ca: 8b 45 f4 mov -0xc(%ebp),%eax
4cd: 8b 55 0c mov 0xc(%ebp),%edx
4d0: 89 50 08 mov %edx,0x8(%eax)
return (struct cmd*)cmd;
4d3: 8b 45 f4 mov -0xc(%ebp),%eax
}
4d6: c9 leave
4d7: c3 ret
000004d8 <listcmd>:
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
4d8: 55 push %ebp
4d9: 89 e5 mov %esp,%ebp
4db: 83 ec 18 sub $0x18,%esp
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
4de: 83 ec 0c sub $0xc,%esp
4e1: 6a 0c push $0xc
4e3: e8 61 0e 00 00 call 1349 <malloc>
4e8: 83 c4 10 add $0x10,%esp
4eb: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
4ee: 83 ec 04 sub $0x4,%esp
4f1: 6a 0c push $0xc
4f3: 6a 00 push $0x0
4f5: ff 75 f4 pushl -0xc(%ebp)
4f8: e8 4f 08 00 00 call d4c <memset>
4fd: 83 c4 10 add $0x10,%esp
cmd->type = LIST;
500: 8b 45 f4 mov -0xc(%ebp),%eax
503: c7 00 04 00 00 00 movl $0x4,(%eax)
cmd->left = left;
509: 8b 45 f4 mov -0xc(%ebp),%eax
50c: 8b 55 08 mov 0x8(%ebp),%edx
50f: 89 50 04 mov %edx,0x4(%eax)
cmd->right = right;
512: 8b 45 f4 mov -0xc(%ebp),%eax
515: 8b 55 0c mov 0xc(%ebp),%edx
518: 89 50 08 mov %edx,0x8(%eax)
return (struct cmd*)cmd;
51b: 8b 45 f4 mov -0xc(%ebp),%eax
}
51e: c9 leave
51f: c3 ret
00000520 <backcmd>:
struct cmd*
backcmd(struct cmd *subcmd)
{
520: 55 push %ebp
521: 89 e5 mov %esp,%ebp
523: 83 ec 18 sub $0x18,%esp
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
526: 83 ec 0c sub $0xc,%esp
529: 6a 08 push $0x8
52b: e8 19 0e 00 00 call 1349 <malloc>
530: 83 c4 10 add $0x10,%esp
533: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
536: 83 ec 04 sub $0x4,%esp
539: 6a 08 push $0x8
53b: 6a 00 push $0x0
53d: ff 75 f4 pushl -0xc(%ebp)
540: e8 07 08 00 00 call d4c <memset>
545: 83 c4 10 add $0x10,%esp
cmd->type = BACK;
548: 8b 45 f4 mov -0xc(%ebp),%eax
54b: c7 00 05 00 00 00 movl $0x5,(%eax)
cmd->cmd = subcmd;
551: 8b 45 f4 mov -0xc(%ebp),%eax
554: 8b 55 08 mov 0x8(%ebp),%edx
557: 89 50 04 mov %edx,0x4(%eax)
return (struct cmd*)cmd;
55a: 8b 45 f4 mov -0xc(%ebp),%eax
}
55d: c9 leave
55e: c3 ret
0000055f <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";
int
gettoken(char **ps, char *es, char **q, char **eq)
{
55f: 55 push %ebp
560: 89 e5 mov %esp,%ebp
562: 83 ec 18 sub $0x18,%esp
char *s;
int ret;
s = *ps;
565: 8b 45 08 mov 0x8(%ebp),%eax
568: 8b 00 mov (%eax),%eax
56a: 89 45 f4 mov %eax,-0xc(%ebp)
while(s < es && strchr(whitespace, *s))
56d: eb 04 jmp 573 <gettoken+0x14>
s++;
56f: 83 45 f4 01 addl $0x1,-0xc(%ebp)
{
char *s;
int ret;
s = *ps;
while(s < es && strchr(whitespace, *s))
573: 8b 45 f4 mov -0xc(%ebp),%eax
576: 3b 45 0c cmp 0xc(%ebp),%eax
579: 73 1e jae 599 <gettoken+0x3a>
57b: 8b 45 f4 mov -0xc(%ebp),%eax
57e: 0f b6 00 movzbl (%eax),%eax
581: 0f be c0 movsbl %al,%eax
584: 83 ec 08 sub $0x8,%esp
587: 50 push %eax
588: 68 ac 19 00 00 push $0x19ac
58d: e8 d4 07 00 00 call d66 <strchr>
592: 83 c4 10 add $0x10,%esp
595: 85 c0 test %eax,%eax
597: 75 d6 jne 56f <gettoken+0x10>
s++;
if(q)
599: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
59d: 74 08 je 5a7 <gettoken+0x48>
*q = s;
59f: 8b 45 10 mov 0x10(%ebp),%eax
5a2: 8b 55 f4 mov -0xc(%ebp),%edx
5a5: 89 10 mov %edx,(%eax)
ret = *s;
5a7: 8b 45 f4 mov -0xc(%ebp),%eax
5aa: 0f b6 00 movzbl (%eax),%eax
5ad: 0f be c0 movsbl %al,%eax
5b0: 89 45 f0 mov %eax,-0x10(%ebp)
switch(*s){
5b3: 8b 45 f4 mov -0xc(%ebp),%eax
5b6: 0f b6 00 movzbl (%eax),%eax
5b9: 0f be c0 movsbl %al,%eax
5bc: 83 f8 29 cmp $0x29,%eax
5bf: 7f 14 jg 5d5 <gettoken+0x76>
5c1: 83 f8 28 cmp $0x28,%eax
5c4: 7d 28 jge 5ee <gettoken+0x8f>
5c6: 85 c0 test %eax,%eax
5c8: 0f 84 94 00 00 00 je 662 <gettoken+0x103>
5ce: 83 f8 26 cmp $0x26,%eax
5d1: 74 1b je 5ee <gettoken+0x8f>
5d3: eb 3a jmp 60f <gettoken+0xb0>
5d5: 83 f8 3e cmp $0x3e,%eax
5d8: 74 1a je 5f4 <gettoken+0x95>
5da: 83 f8 3e cmp $0x3e,%eax
5dd: 7f 0a jg 5e9 <gettoken+0x8a>
5df: 83 e8 3b sub $0x3b,%eax
5e2: 83 f8 01 cmp $0x1,%eax
5e5: 77 28 ja 60f <gettoken+0xb0>
5e7: eb 05 jmp 5ee <gettoken+0x8f>
5e9: 83 f8 7c cmp $0x7c,%eax
5ec: 75 21 jne 60f <gettoken+0xb0>
case '(':
case ')':
case ';':
case '&':
case '<':
s++;
5ee: 83 45 f4 01 addl $0x1,-0xc(%ebp)
break;
5f2: eb 75 jmp 669 <gettoken+0x10a>
case '>':
s++;
5f4: 83 45 f4 01 addl $0x1,-0xc(%ebp)
if(*s == '>'){
5f8: 8b 45 f4 mov -0xc(%ebp),%eax
5fb: 0f b6 00 movzbl (%eax),%eax
5fe: 3c 3e cmp $0x3e,%al
600: 75 63 jne 665 <gettoken+0x106>
ret = '+';
602: c7 45 f0 2b 00 00 00 movl $0x2b,-0x10(%ebp)
s++;
609: 83 45 f4 01 addl $0x1,-0xc(%ebp)
}
break;
60d: eb 56 jmp 665 <gettoken+0x106>
default:
ret = 'a';
60f: c7 45 f0 61 00 00 00 movl $0x61,-0x10(%ebp)
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
616: eb 04 jmp 61c <gettoken+0xbd>
s++;
618: 83 45 f4 01 addl $0x1,-0xc(%ebp)
s++;
}
break;
default:
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
61c: 8b 45 f4 mov -0xc(%ebp),%eax
61f: 3b 45 0c cmp 0xc(%ebp),%eax
622: 73 44 jae 668 <gettoken+0x109>
624: 8b 45 f4 mov -0xc(%ebp),%eax
627: 0f b6 00 movzbl (%eax),%eax
62a: 0f be c0 movsbl %al,%eax
62d: 83 ec 08 sub $0x8,%esp
630: 50 push %eax
631: 68 ac 19 00 00 push $0x19ac
636: e8 2b 07 00 00 call d66 <strchr>
63b: 83 c4 10 add $0x10,%esp
63e: 85 c0 test %eax,%eax
640: 75 26 jne 668 <gettoken+0x109>
642: 8b 45 f4 mov -0xc(%ebp),%eax
645: 0f b6 00 movzbl (%eax),%eax
648: 0f be c0 movsbl %al,%eax
64b: 83 ec 08 sub $0x8,%esp
64e: 50 push %eax
64f: 68 b4 19 00 00 push $0x19b4
654: e8 0d 07 00 00 call d66 <strchr>
659: 83 c4 10 add $0x10,%esp
65c: 85 c0 test %eax,%eax
65e: 74 b8 je 618 <gettoken+0xb9>
s++;
break;
660: eb 06 jmp 668 <gettoken+0x109>
if(q)
*q = s;
ret = *s;
switch(*s){
case 0:
break;
662: 90 nop
663: eb 04 jmp 669 <gettoken+0x10a>
s++;
if(*s == '>'){
ret = '+';
s++;
}
break;
665: 90 nop
666: eb 01 jmp 669 <gettoken+0x10a>
default:
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
s++;
break;
668: 90 nop
}
if(eq)
669: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
66d: 74 0e je 67d <gettoken+0x11e>
*eq = s;
66f: 8b 45 14 mov 0x14(%ebp),%eax
672: 8b 55 f4 mov -0xc(%ebp),%edx
675: 89 10 mov %edx,(%eax)
while(s < es && strchr(whitespace, *s))
677: eb 04 jmp 67d <gettoken+0x11e>
s++;
679: 83 45 f4 01 addl $0x1,-0xc(%ebp)
break;
}
if(eq)
*eq = s;
while(s < es && strchr(whitespace, *s))
67d: 8b 45 f4 mov -0xc(%ebp),%eax
680: 3b 45 0c cmp 0xc(%ebp),%eax
683: 73 1e jae 6a3 <gettoken+0x144>
685: 8b 45 f4 mov -0xc(%ebp),%eax
688: 0f b6 00 movzbl (%eax),%eax
68b: 0f be c0 movsbl %al,%eax
68e: 83 ec 08 sub $0x8,%esp
691: 50 push %eax
692: 68 ac 19 00 00 push $0x19ac
697: e8 ca 06 00 00 call d66 <strchr>
69c: 83 c4 10 add $0x10,%esp
69f: 85 c0 test %eax,%eax
6a1: 75 d6 jne 679 <gettoken+0x11a>
s++;
*ps = s;
6a3: 8b 45 08 mov 0x8(%ebp),%eax
6a6: 8b 55 f4 mov -0xc(%ebp),%edx
6a9: 89 10 mov %edx,(%eax)
return ret;
6ab: 8b 45 f0 mov -0x10(%ebp),%eax
}
6ae: c9 leave
6af: c3 ret
000006b0 <peek>:
int
peek(char **ps, char *es, char *toks)
{
6b0: 55 push %ebp
6b1: 89 e5 mov %esp,%ebp
6b3: 83 ec 18 sub $0x18,%esp
char *s;
s = *ps;
6b6: 8b 45 08 mov 0x8(%ebp),%eax
6b9: 8b 00 mov (%eax),%eax
6bb: 89 45 f4 mov %eax,-0xc(%ebp)
while(s < es && strchr(whitespace, *s))
6be: eb 04 jmp 6c4 <peek+0x14>
s++;
6c0: 83 45 f4 01 addl $0x1,-0xc(%ebp)
peek(char **ps, char *es, char *toks)
{
char *s;
s = *ps;
while(s < es && strchr(whitespace, *s))
6c4: 8b 45 f4 mov -0xc(%ebp),%eax
6c7: 3b 45 0c cmp 0xc(%ebp),%eax
6ca: 73 1e jae 6ea <peek+0x3a>
6cc: 8b 45 f4 mov -0xc(%ebp),%eax
6cf: 0f b6 00 movzbl (%eax),%eax
6d2: 0f be c0 movsbl %al,%eax
6d5: 83 ec 08 sub $0x8,%esp
6d8: 50 push %eax
6d9: 68 ac 19 00 00 push $0x19ac
6de: e8 83 06 00 00 call d66 <strchr>
6e3: 83 c4 10 add $0x10,%esp
6e6: 85 c0 test %eax,%eax
6e8: 75 d6 jne 6c0 <peek+0x10>
s++;
*ps = s;
6ea: 8b 45 08 mov 0x8(%ebp),%eax
6ed: 8b 55 f4 mov -0xc(%ebp),%edx
6f0: 89 10 mov %edx,(%eax)
return *s && strchr(toks, *s);
6f2: 8b 45 f4 mov -0xc(%ebp),%eax
6f5: 0f b6 00 movzbl (%eax),%eax
6f8: 84 c0 test %al,%al
6fa: 74 23 je 71f <peek+0x6f>
6fc: 8b 45 f4 mov -0xc(%ebp),%eax
6ff: 0f b6 00 movzbl (%eax),%eax
702: 0f be c0 movsbl %al,%eax
705: 83 ec 08 sub $0x8,%esp
708: 50 push %eax
709: ff 75 10 pushl 0x10(%ebp)
70c: e8 55 06 00 00 call d66 <strchr>
711: 83 c4 10 add $0x10,%esp
714: 85 c0 test %eax,%eax
716: 74 07 je 71f <peek+0x6f>
718: b8 01 00 00 00 mov $0x1,%eax
71d: eb 05 jmp 724 <peek+0x74>
71f: b8 00 00 00 00 mov $0x0,%eax
}
724: c9 leave
725: c3 ret
00000726 <parsecmd>:
struct cmd *parseexec(char**, char*);
struct cmd *nulterminate(struct cmd*);
struct cmd*
parsecmd(char *s)
{
726: 55 push %ebp
727: 89 e5 mov %esp,%ebp
729: 53 push %ebx
72a: 83 ec 14 sub $0x14,%esp
char *es;
struct cmd *cmd;
es = s + strlen(s);
72d: 8b 5d 08 mov 0x8(%ebp),%ebx
730: 8b 45 08 mov 0x8(%ebp),%eax
733: 83 ec 0c sub $0xc,%esp
736: 50 push %eax
737: e8 e9 05 00 00 call d25 <strlen>
73c: 83 c4 10 add $0x10,%esp
73f: 01 d8 add %ebx,%eax
741: 89 45 f4 mov %eax,-0xc(%ebp)
cmd = parseline(&s, es);
744: 83 ec 08 sub $0x8,%esp
747: ff 75 f4 pushl -0xc(%ebp)
74a: 8d 45 08 lea 0x8(%ebp),%eax
74d: 50 push %eax
74e: e8 61 00 00 00 call 7b4 <parseline>
753: 83 c4 10 add $0x10,%esp
756: 89 45 f0 mov %eax,-0x10(%ebp)
peek(&s, es, "");
759: 83 ec 04 sub $0x4,%esp
75c: 68 96 14 00 00 push $0x1496
761: ff 75 f4 pushl -0xc(%ebp)
764: 8d 45 08 lea 0x8(%ebp),%eax
767: 50 push %eax
768: e8 43 ff ff ff call 6b0 <peek>
76d: 83 c4 10 add $0x10,%esp
if(s != es){
770: 8b 45 08 mov 0x8(%ebp),%eax
773: 3b 45 f4 cmp -0xc(%ebp),%eax
776: 74 26 je 79e <parsecmd+0x78>
printf(2, "leftovers: %s\n", s);
778: 8b 45 08 mov 0x8(%ebp),%eax
77b: 83 ec 04 sub $0x4,%esp
77e: 50 push %eax
77f: 68 97 14 00 00 push $0x1497
784: 6a 02 push $0x2
786: e8 eb 08 00 00 call 1076 <printf>
78b: 83 c4 10 add $0x10,%esp
panic("syntax");
78e: 83 ec 0c sub $0xc,%esp
791: 68 a6 14 00 00 push $0x14a6
796: e8 13 fc ff ff call 3ae <panic>
79b: 83 c4 10 add $0x10,%esp
}
nulterminate(cmd);
79e: 83 ec 0c sub $0xc,%esp
7a1: ff 75 f0 pushl -0x10(%ebp)
7a4: e8 eb 03 00 00 call b94 <nulterminate>
7a9: 83 c4 10 add $0x10,%esp
return cmd;
7ac: 8b 45 f0 mov -0x10(%ebp),%eax
}
7af: 8b 5d fc mov -0x4(%ebp),%ebx
7b2: c9 leave
7b3: c3 ret
000007b4 <parseline>:
struct cmd*
parseline(char **ps, char *es)
{
7b4: 55 push %ebp
7b5: 89 e5 mov %esp,%ebp
7b7: 83 ec 18 sub $0x18,%esp
struct cmd *cmd;
cmd = parsepipe(ps, es);
7ba: 83 ec 08 sub $0x8,%esp
7bd: ff 75 0c pushl 0xc(%ebp)
7c0: ff 75 08 pushl 0x8(%ebp)
7c3: e8 99 00 00 00 call 861 <parsepipe>
7c8: 83 c4 10 add $0x10,%esp
7cb: 89 45 f4 mov %eax,-0xc(%ebp)
while(peek(ps, es, "&")){
7ce: eb 23 jmp 7f3 <parseline+0x3f>
gettoken(ps, es, 0, 0);
7d0: 6a 00 push $0x0
7d2: 6a 00 push $0x0
7d4: ff 75 0c pushl 0xc(%ebp)
7d7: ff 75 08 pushl 0x8(%ebp)
7da: e8 80 fd ff ff call 55f <gettoken>
7df: 83 c4 10 add $0x10,%esp
cmd = backcmd(cmd);
7e2: 83 ec 0c sub $0xc,%esp
7e5: ff 75 f4 pushl -0xc(%ebp)
7e8: e8 33 fd ff ff call 520 <backcmd>
7ed: 83 c4 10 add $0x10,%esp
7f0: 89 45 f4 mov %eax,-0xc(%ebp)
parseline(char **ps, char *es)
{
struct cmd *cmd;
cmd = parsepipe(ps, es);
while(peek(ps, es, "&")){
7f3: 83 ec 04 sub $0x4,%esp
7f6: 68 ad 14 00 00 push $0x14ad
7fb: ff 75 0c pushl 0xc(%ebp)
7fe: ff 75 08 pushl 0x8(%ebp)
801: e8 aa fe ff ff call 6b0 <peek>
806: 83 c4 10 add $0x10,%esp
809: 85 c0 test %eax,%eax
80b: 75 c3 jne 7d0 <parseline+0x1c>
gettoken(ps, es, 0, 0);
cmd = backcmd(cmd);
}
if(peek(ps, es, ";")){
80d: 83 ec 04 sub $0x4,%esp
810: 68 af 14 00 00 push $0x14af
815: ff 75 0c pushl 0xc(%ebp)
818: ff 75 08 pushl 0x8(%ebp)
81b: e8 90 fe ff ff call 6b0 <peek>
820: 83 c4 10 add $0x10,%esp
823: 85 c0 test %eax,%eax
825: 74 35 je 85c <parseline+0xa8>
gettoken(ps, es, 0, 0);
827: 6a 00 push $0x0
829: 6a 00 push $0x0
82b: ff 75 0c pushl 0xc(%ebp)
82e: ff 75 08 pushl 0x8(%ebp)
831: e8 29 fd ff ff call 55f <gettoken>
836: 83 c4 10 add $0x10,%esp
cmd = listcmd(cmd, parseline(ps, es));
839: 83 ec 08 sub $0x8,%esp
83c: ff 75 0c pushl 0xc(%ebp)
83f: ff 75 08 pushl 0x8(%ebp)
842: e8 6d ff ff ff call 7b4 <parseline>
847: 83 c4 10 add $0x10,%esp
84a: 83 ec 08 sub $0x8,%esp
84d: 50 push %eax
84e: ff 75 f4 pushl -0xc(%ebp)
851: e8 82 fc ff ff call 4d8 <listcmd>
856: 83 c4 10 add $0x10,%esp
859: 89 45 f4 mov %eax,-0xc(%ebp)
}
return cmd;
85c: 8b 45 f4 mov -0xc(%ebp),%eax
}
85f: c9 leave
860: c3 ret
00000861 <parsepipe>:
struct cmd*
parsepipe(char **ps, char *es)
{
861: 55 push %ebp
862: 89 e5 mov %esp,%ebp
864: 83 ec 18 sub $0x18,%esp
struct cmd *cmd;
cmd = parseexec(ps, es);
867: 83 ec 08 sub $0x8,%esp
86a: ff 75 0c pushl 0xc(%ebp)
86d: ff 75 08 pushl 0x8(%ebp)
870: e8 ec 01 00 00 call a61 <parseexec>
875: 83 c4 10 add $0x10,%esp
878: 89 45 f4 mov %eax,-0xc(%ebp)
if(peek(ps, es, "|")){
87b: 83 ec 04 sub $0x4,%esp
87e: 68 b1 14 00 00 push $0x14b1
883: ff 75 0c pushl 0xc(%ebp)
886: ff 75 08 pushl 0x8(%ebp)
889: e8 22 fe ff ff call 6b0 <peek>
88e: 83 c4 10 add $0x10,%esp
891: 85 c0 test %eax,%eax
893: 74 35 je 8ca <parsepipe+0x69>
gettoken(ps, es, 0, 0);
895: 6a 00 push $0x0
897: 6a 00 push $0x0
899: ff 75 0c pushl 0xc(%ebp)
89c: ff 75 08 pushl 0x8(%ebp)
89f: e8 bb fc ff ff call 55f <gettoken>
8a4: 83 c4 10 add $0x10,%esp
cmd = pipecmd(cmd, parsepipe(ps, es));
8a7: 83 ec 08 sub $0x8,%esp
8aa: ff 75 0c pushl 0xc(%ebp)
8ad: ff 75 08 pushl 0x8(%ebp)
8b0: e8 ac ff ff ff call 861 <parsepipe>
8b5: 83 c4 10 add $0x10,%esp
8b8: 83 ec 08 sub $0x8,%esp
8bb: 50 push %eax
8bc: ff 75 f4 pushl -0xc(%ebp)
8bf: e8 cc fb ff ff call 490 <pipecmd>
8c4: 83 c4 10 add $0x10,%esp
8c7: 89 45 f4 mov %eax,-0xc(%ebp)
}
return cmd;
8ca: 8b 45 f4 mov -0xc(%ebp),%eax
}
8cd: c9 leave
8ce: c3 ret
000008cf <parseredirs>:
struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
8cf: 55 push %ebp
8d0: 89 e5 mov %esp,%ebp
8d2: 83 ec 18 sub $0x18,%esp
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
8d5: e9 b6 00 00 00 jmp 990 <parseredirs+0xc1>
tok = gettoken(ps, es, 0, 0);
8da: 6a 00 push $0x0
8dc: 6a 00 push $0x0
8de: ff 75 10 pushl 0x10(%ebp)
8e1: ff 75 0c pushl 0xc(%ebp)
8e4: e8 76 fc ff ff call 55f <gettoken>
8e9: 83 c4 10 add $0x10,%esp
8ec: 89 45 f4 mov %eax,-0xc(%ebp)
if(gettoken(ps, es, &q, &eq) != 'a')
8ef: 8d 45 ec lea -0x14(%ebp),%eax
8f2: 50 push %eax
8f3: 8d 45 f0 lea -0x10(%ebp),%eax
8f6: 50 push %eax
8f7: ff 75 10 pushl 0x10(%ebp)
8fa: ff 75 0c pushl 0xc(%ebp)
8fd: e8 5d fc ff ff call 55f <gettoken>
902: 83 c4 10 add $0x10,%esp
905: 83 f8 61 cmp $0x61,%eax
908: 74 10 je 91a <parseredirs+0x4b>
panic("missing file for redirection");
90a: 83 ec 0c sub $0xc,%esp
90d: 68 b3 14 00 00 push $0x14b3
912: e8 97 fa ff ff call 3ae <panic>
917: 83 c4 10 add $0x10,%esp
switch(tok){
91a: 8b 45 f4 mov -0xc(%ebp),%eax
91d: 83 f8 3c cmp $0x3c,%eax
920: 74 0c je 92e <parseredirs+0x5f>
922: 83 f8 3e cmp $0x3e,%eax
925: 74 26 je 94d <parseredirs+0x7e>
927: 83 f8 2b cmp $0x2b,%eax
92a: 74 43 je 96f <parseredirs+0xa0>
92c: eb 62 jmp 990 <parseredirs+0xc1>
case '<':
cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
92e: 8b 55 ec mov -0x14(%ebp),%edx
931: 8b 45 f0 mov -0x10(%ebp),%eax
934: 83 ec 0c sub $0xc,%esp
937: 6a 00 push $0x0
939: 6a 00 push $0x0
93b: 52 push %edx
93c: 50 push %eax
93d: ff 75 08 pushl 0x8(%ebp)
940: e8 e8 fa ff ff call 42d <redircmd>
945: 83 c4 20 add $0x20,%esp
948: 89 45 08 mov %eax,0x8(%ebp)
break;
94b: eb 43 jmp 990 <parseredirs+0xc1>
case '>':
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
94d: 8b 55 ec mov -0x14(%ebp),%edx
950: 8b 45 f0 mov -0x10(%ebp),%eax
953: 83 ec 0c sub $0xc,%esp
956: 6a 01 push $0x1
958: 68 01 02 00 00 push $0x201
95d: 52 push %edx
95e: 50 push %eax
95f: ff 75 08 pushl 0x8(%ebp)
962: e8 c6 fa ff ff call 42d <redircmd>
967: 83 c4 20 add $0x20,%esp
96a: 89 45 08 mov %eax,0x8(%ebp)
break;
96d: eb 21 jmp 990 <parseredirs+0xc1>
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
96f: 8b 55 ec mov -0x14(%ebp),%edx
972: 8b 45 f0 mov -0x10(%ebp),%eax
975: 83 ec 0c sub $0xc,%esp
978: 6a 01 push $0x1
97a: 68 01 02 00 00 push $0x201
97f: 52 push %edx
980: 50 push %eax
981: ff 75 08 pushl 0x8(%ebp)
984: e8 a4 fa ff ff call 42d <redircmd>
989: 83 c4 20 add $0x20,%esp
98c: 89 45 08 mov %eax,0x8(%ebp)
break;
98f: 90 nop
parseredirs(struct cmd *cmd, char **ps, char *es)
{
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
990: 83 ec 04 sub $0x4,%esp
993: 68 d0 14 00 00 push $0x14d0
998: ff 75 10 pushl 0x10(%ebp)
99b: ff 75 0c pushl 0xc(%ebp)
99e: e8 0d fd ff ff call 6b0 <peek>
9a3: 83 c4 10 add $0x10,%esp
9a6: 85 c0 test %eax,%eax
9a8: 0f 85 2c ff ff ff jne 8da <parseredirs+0xb>
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
break;
}
}
return cmd;
9ae: 8b 45 08 mov 0x8(%ebp),%eax
}
9b1: c9 leave
9b2: c3 ret
000009b3 <parseblock>:
struct cmd*
parseblock(char **ps, char *es)
{
9b3: 55 push %ebp
9b4: 89 e5 mov %esp,%ebp
9b6: 83 ec 18 sub $0x18,%esp
struct cmd *cmd;
if(!peek(ps, es, "("))
9b9: 83 ec 04 sub $0x4,%esp
9bc: 68 d3 14 00 00 push $0x14d3
9c1: ff 75 0c pushl 0xc(%ebp)
9c4: ff 75 08 pushl 0x8(%ebp)
9c7: e8 e4 fc ff ff call 6b0 <peek>
9cc: 83 c4 10 add $0x10,%esp
9cf: 85 c0 test %eax,%eax
9d1: 75 10 jne 9e3 <parseblock+0x30>
panic("parseblock");
9d3: 83 ec 0c sub $0xc,%esp
9d6: 68 d5 14 00 00 push $0x14d5
9db: e8 ce f9 ff ff call 3ae <panic>
9e0: 83 c4 10 add $0x10,%esp
gettoken(ps, es, 0, 0);
9e3: 6a 00 push $0x0
9e5: 6a 00 push $0x0
9e7: ff 75 0c pushl 0xc(%ebp)
9ea: ff 75 08 pushl 0x8(%ebp)
9ed: e8 6d fb ff ff call 55f <gettoken>
9f2: 83 c4 10 add $0x10,%esp
cmd = parseline(ps, es);
9f5: 83 ec 08 sub $0x8,%esp
9f8: ff 75 0c pushl 0xc(%ebp)
9fb: ff 75 08 pushl 0x8(%ebp)
9fe: e8 b1 fd ff ff call 7b4 <parseline>
a03: 83 c4 10 add $0x10,%esp
a06: 89 45 f4 mov %eax,-0xc(%ebp)
if(!peek(ps, es, ")"))
a09: 83 ec 04 sub $0x4,%esp
a0c: 68 e0 14 00 00 push $0x14e0
a11: ff 75 0c pushl 0xc(%ebp)
a14: ff 75 08 pushl 0x8(%ebp)
a17: e8 94 fc ff ff call 6b0 <peek>
a1c: 83 c4 10 add $0x10,%esp
a1f: 85 c0 test %eax,%eax
a21: 75 10 jne a33 <parseblock+0x80>
panic("syntax - missing )");
a23: 83 ec 0c sub $0xc,%esp
a26: 68 e2 14 00 00 push $0x14e2
a2b: e8 7e f9 ff ff call 3ae <panic>
a30: 83 c4 10 add $0x10,%esp
gettoken(ps, es, 0, 0);
a33: 6a 00 push $0x0
a35: 6a 00 push $0x0
a37: ff 75 0c pushl 0xc(%ebp)
a3a: ff 75 08 pushl 0x8(%ebp)
a3d: e8 1d fb ff ff call 55f <gettoken>
a42: 83 c4 10 add $0x10,%esp
cmd = parseredirs(cmd, ps, es);
a45: 83 ec 04 sub $0x4,%esp
a48: ff 75 0c pushl 0xc(%ebp)
a4b: ff 75 08 pushl 0x8(%ebp)
a4e: ff 75 f4 pushl -0xc(%ebp)
a51: e8 79 fe ff ff call 8cf <parseredirs>
a56: 83 c4 10 add $0x10,%esp
a59: 89 45 f4 mov %eax,-0xc(%ebp)
return cmd;
a5c: 8b 45 f4 mov -0xc(%ebp),%eax
}
a5f: c9 leave
a60: c3 ret
00000a61 <parseexec>:
struct cmd*
parseexec(char **ps, char *es)
{
a61: 55 push %ebp
a62: 89 e5 mov %esp,%ebp
a64: 83 ec 28 sub $0x28,%esp
char *q, *eq;
int tok, argc;
struct execcmd *cmd;
struct cmd *ret;
if(peek(ps, es, "("))
a67: 83 ec 04 sub $0x4,%esp
a6a: 68 d3 14 00 00 push $0x14d3
a6f: ff 75 0c pushl 0xc(%ebp)
a72: ff 75 08 pushl 0x8(%ebp)
a75: e8 36 fc ff ff call 6b0 <peek>
a7a: 83 c4 10 add $0x10,%esp
a7d: 85 c0 test %eax,%eax
a7f: 74 16 je a97 <parseexec+0x36>
return parseblock(ps, es);
a81: 83 ec 08 sub $0x8,%esp
a84: ff 75 0c pushl 0xc(%ebp)
a87: ff 75 08 pushl 0x8(%ebp)
a8a: e8 24 ff ff ff call 9b3 <parseblock>
a8f: 83 c4 10 add $0x10,%esp
a92: e9 fb 00 00 00 jmp b92 <parseexec+0x131>
ret = execcmd();
a97: e8 5b f9 ff ff call 3f7 <execcmd>
a9c: 89 45 f0 mov %eax,-0x10(%ebp)
cmd = (struct execcmd*)ret;
a9f: 8b 45 f0 mov -0x10(%ebp),%eax
aa2: 89 45 ec mov %eax,-0x14(%ebp)
argc = 0;
aa5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
ret = parseredirs(ret, ps, es);
aac: 83 ec 04 sub $0x4,%esp
aaf: ff 75 0c pushl 0xc(%ebp)
ab2: ff 75 08 pushl 0x8(%ebp)
ab5: ff 75 f0 pushl -0x10(%ebp)
ab8: e8 12 fe ff ff call 8cf <parseredirs>
abd: 83 c4 10 add $0x10,%esp
ac0: 89 45 f0 mov %eax,-0x10(%ebp)
while(!peek(ps, es, "|)&;")){
ac3: e9 87 00 00 00 jmp b4f <parseexec+0xee>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
ac8: 8d 45 e0 lea -0x20(%ebp),%eax
acb: 50 push %eax
acc: 8d 45 e4 lea -0x1c(%ebp),%eax
acf: 50 push %eax
ad0: ff 75 0c pushl 0xc(%ebp)
ad3: ff 75 08 pushl 0x8(%ebp)
ad6: e8 84 fa ff ff call 55f <gettoken>
adb: 83 c4 10 add $0x10,%esp
ade: 89 45 e8 mov %eax,-0x18(%ebp)
ae1: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
ae5: 0f 84 84 00 00 00 je b6f <parseexec+0x10e>
break;
if(tok != 'a')
aeb: 83 7d e8 61 cmpl $0x61,-0x18(%ebp)
aef: 74 10 je b01 <parseexec+0xa0>
panic("syntax");
af1: 83 ec 0c sub $0xc,%esp
af4: 68 a6 14 00 00 push $0x14a6
af9: e8 b0 f8 ff ff call 3ae <panic>
afe: 83 c4 10 add $0x10,%esp
cmd->argv[argc] = q;
b01: 8b 4d e4 mov -0x1c(%ebp),%ecx
b04: 8b 45 ec mov -0x14(%ebp),%eax
b07: 8b 55 f4 mov -0xc(%ebp),%edx
b0a: 89 4c 90 04 mov %ecx,0x4(%eax,%edx,4)
cmd->eargv[argc] = eq;
b0e: 8b 55 e0 mov -0x20(%ebp),%edx
b11: 8b 45 ec mov -0x14(%ebp),%eax
b14: 8b 4d f4 mov -0xc(%ebp),%ecx
b17: 83 c1 08 add $0x8,%ecx
b1a: 89 54 88 0c mov %edx,0xc(%eax,%ecx,4)
argc++;
b1e: 83 45 f4 01 addl $0x1,-0xc(%ebp)
if(argc >= MAXARGS)
b22: 83 7d f4 09 cmpl $0x9,-0xc(%ebp)
b26: 7e 10 jle b38 <parseexec+0xd7>
panic("too many args");
b28: 83 ec 0c sub $0xc,%esp
b2b: 68 f5 14 00 00 push $0x14f5
b30: e8 79 f8 ff ff call 3ae <panic>
b35: 83 c4 10 add $0x10,%esp
ret = parseredirs(ret, ps, es);
b38: 83 ec 04 sub $0x4,%esp
b3b: ff 75 0c pushl 0xc(%ebp)
b3e: ff 75 08 pushl 0x8(%ebp)
b41: ff 75 f0 pushl -0x10(%ebp)
b44: e8 86 fd ff ff call 8cf <parseredirs>
b49: 83 c4 10 add $0x10,%esp
b4c: 89 45 f0 mov %eax,-0x10(%ebp)
ret = execcmd();
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
while(!peek(ps, es, "|)&;")){
b4f: 83 ec 04 sub $0x4,%esp
b52: 68 03 15 00 00 push $0x1503
b57: ff 75 0c pushl 0xc(%ebp)
b5a: ff 75 08 pushl 0x8(%ebp)
b5d: e8 4e fb ff ff call 6b0 <peek>
b62: 83 c4 10 add $0x10,%esp
b65: 85 c0 test %eax,%eax
b67: 0f 84 5b ff ff ff je ac8 <parseexec+0x67>
b6d: eb 01 jmp b70 <parseexec+0x10f>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
break;
b6f: 90 nop
argc++;
if(argc >= MAXARGS)
panic("too many args");
ret = parseredirs(ret, ps, es);
}
cmd->argv[argc] = 0;
b70: 8b 45 ec mov -0x14(%ebp),%eax
b73: 8b 55 f4 mov -0xc(%ebp),%edx
b76: c7 44 90 04 00 00 00 movl $0x0,0x4(%eax,%edx,4)
b7d: 00
cmd->eargv[argc] = 0;
b7e: 8b 45 ec mov -0x14(%ebp),%eax
b81: 8b 55 f4 mov -0xc(%ebp),%edx
b84: 83 c2 08 add $0x8,%edx
b87: c7 44 90 0c 00 00 00 movl $0x0,0xc(%eax,%edx,4)
b8e: 00
return ret;
b8f: 8b 45 f0 mov -0x10(%ebp),%eax
}
b92: c9 leave
b93: c3 ret
00000b94 <nulterminate>:
// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
b94: 55 push %ebp
b95: 89 e5 mov %esp,%ebp
b97: 83 ec 28 sub $0x28,%esp
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
b9a: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
b9e: 75 0a jne baa <nulterminate+0x16>
return 0;
ba0: b8 00 00 00 00 mov $0x0,%eax
ba5: e9 e4 00 00 00 jmp c8e <nulterminate+0xfa>
switch(cmd->type){
baa: 8b 45 08 mov 0x8(%ebp),%eax
bad: 8b 00 mov (%eax),%eax
baf: 83 f8 05 cmp $0x5,%eax
bb2: 0f 87 d3 00 00 00 ja c8b <nulterminate+0xf7>
bb8: 8b 04 85 08 15 00 00 mov 0x1508(,%eax,4),%eax
bbf: ff e0 jmp *%eax
case EXEC:
ecmd = (struct execcmd*)cmd;
bc1: 8b 45 08 mov 0x8(%ebp),%eax
bc4: 89 45 f0 mov %eax,-0x10(%ebp)
for(i=0; ecmd->argv[i]; i++)
bc7: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
bce: eb 14 jmp be4 <nulterminate+0x50>
*ecmd->eargv[i] = 0;
bd0: 8b 45 f0 mov -0x10(%ebp),%eax
bd3: 8b 55 f4 mov -0xc(%ebp),%edx
bd6: 83 c2 08 add $0x8,%edx
bd9: 8b 44 90 0c mov 0xc(%eax,%edx,4),%eax
bdd: c6 00 00 movb $0x0,(%eax)
return 0;
switch(cmd->type){
case EXEC:
ecmd = (struct execcmd*)cmd;
for(i=0; ecmd->argv[i]; i++)
be0: 83 45 f4 01 addl $0x1,-0xc(%ebp)
be4: 8b 45 f0 mov -0x10(%ebp),%eax
be7: 8b 55 f4 mov -0xc(%ebp),%edx
bea: 8b 44 90 04 mov 0x4(%eax,%edx,4),%eax
bee: 85 c0 test %eax,%eax
bf0: 75 de jne bd0 <nulterminate+0x3c>
*ecmd->eargv[i] = 0;
break;
bf2: e9 94 00 00 00 jmp c8b <nulterminate+0xf7>
case REDIR:
rcmd = (struct redircmd*)cmd;
bf7: 8b 45 08 mov 0x8(%ebp),%eax
bfa: 89 45 ec mov %eax,-0x14(%ebp)
nulterminate(rcmd->cmd);
bfd: 8b 45 ec mov -0x14(%ebp),%eax
c00: 8b 40 04 mov 0x4(%eax),%eax
c03: 83 ec 0c sub $0xc,%esp
c06: 50 push %eax
c07: e8 88 ff ff ff call b94 <nulterminate>
c0c: 83 c4 10 add $0x10,%esp
*rcmd->efile = 0;
c0f: 8b 45 ec mov -0x14(%ebp),%eax
c12: 8b 40 0c mov 0xc(%eax),%eax
c15: c6 00 00 movb $0x0,(%eax)
break;
c18: eb 71 jmp c8b <nulterminate+0xf7>
case PIPE:
pcmd = (struct pipecmd*)cmd;
c1a: 8b 45 08 mov 0x8(%ebp),%eax
c1d: 89 45 e8 mov %eax,-0x18(%ebp)
nulterminate(pcmd->left);
c20: 8b 45 e8 mov -0x18(%ebp),%eax
c23: 8b 40 04 mov 0x4(%eax),%eax
c26: 83 ec 0c sub $0xc,%esp
c29: 50 push %eax
c2a: e8 65 ff ff ff call b94 <nulterminate>
c2f: 83 c4 10 add $0x10,%esp
nulterminate(pcmd->right);
c32: 8b 45 e8 mov -0x18(%ebp),%eax
c35: 8b 40 08 mov 0x8(%eax),%eax
c38: 83 ec 0c sub $0xc,%esp
c3b: 50 push %eax
c3c: e8 53 ff ff ff call b94 <nulterminate>
c41: 83 c4 10 add $0x10,%esp
break;
c44: eb 45 jmp c8b <nulterminate+0xf7>
case LIST:
lcmd = (struct listcmd*)cmd;
c46: 8b 45 08 mov 0x8(%ebp),%eax
c49: 89 45 e4 mov %eax,-0x1c(%ebp)
nulterminate(lcmd->left);
c4c: 8b 45 e4 mov -0x1c(%ebp),%eax
c4f: 8b 40 04 mov 0x4(%eax),%eax
c52: 83 ec 0c sub $0xc,%esp
c55: 50 push %eax
c56: e8 39 ff ff ff call b94 <nulterminate>
c5b: 83 c4 10 add $0x10,%esp
nulterminate(lcmd->right);
c5e: 8b 45 e4 mov -0x1c(%ebp),%eax
c61: 8b 40 08 mov 0x8(%eax),%eax
c64: 83 ec 0c sub $0xc,%esp
c67: 50 push %eax
c68: e8 27 ff ff ff call b94 <nulterminate>
c6d: 83 c4 10 add $0x10,%esp
break;
c70: eb 19 jmp c8b <nulterminate+0xf7>
case BACK:
bcmd = (struct backcmd*)cmd;
c72: 8b 45 08 mov 0x8(%ebp),%eax
c75: 89 45 e0 mov %eax,-0x20(%ebp)
nulterminate(bcmd->cmd);
c78: 8b 45 e0 mov -0x20(%ebp),%eax
c7b: 8b 40 04 mov 0x4(%eax),%eax
c7e: 83 ec 0c sub $0xc,%esp
c81: 50 push %eax
c82: e8 0d ff ff ff call b94 <nulterminate>
c87: 83 c4 10 add $0x10,%esp
break;
c8a: 90 nop
}
return cmd;
c8b: 8b 45 08 mov 0x8(%ebp),%eax
}
c8e: c9 leave
c8f: c3 ret
00000c90 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
c90: 55 push %ebp
c91: 89 e5 mov %esp,%ebp
c93: 57 push %edi
c94: 53 push %ebx
asm volatile("cld; rep stosb" :
c95: 8b 4d 08 mov 0x8(%ebp),%ecx
c98: 8b 55 10 mov 0x10(%ebp),%edx
c9b: 8b 45 0c mov 0xc(%ebp),%eax
c9e: 89 cb mov %ecx,%ebx
ca0: 89 df mov %ebx,%edi
ca2: 89 d1 mov %edx,%ecx
ca4: fc cld
ca5: f3 aa rep stos %al,%es:(%edi)
ca7: 89 ca mov %ecx,%edx
ca9: 89 fb mov %edi,%ebx
cab: 89 5d 08 mov %ebx,0x8(%ebp)
cae: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
cb1: 90 nop
cb2: 5b pop %ebx
cb3: 5f pop %edi
cb4: 5d pop %ebp
cb5: c3 ret
00000cb6 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
cb6: 55 push %ebp
cb7: 89 e5 mov %esp,%ebp
cb9: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
cbc: 8b 45 08 mov 0x8(%ebp),%eax
cbf: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
cc2: 90 nop
cc3: 8b 45 08 mov 0x8(%ebp),%eax
cc6: 8d 50 01 lea 0x1(%eax),%edx
cc9: 89 55 08 mov %edx,0x8(%ebp)
ccc: 8b 55 0c mov 0xc(%ebp),%edx
ccf: 8d 4a 01 lea 0x1(%edx),%ecx
cd2: 89 4d 0c mov %ecx,0xc(%ebp)
cd5: 0f b6 12 movzbl (%edx),%edx
cd8: 88 10 mov %dl,(%eax)
cda: 0f b6 00 movzbl (%eax),%eax
cdd: 84 c0 test %al,%al
cdf: 75 e2 jne cc3 <strcpy+0xd>
;
return os;
ce1: 8b 45 fc mov -0x4(%ebp),%eax
}
ce4: c9 leave
ce5: c3 ret
00000ce6 <strcmp>:
int
strcmp(const char *p, const char *q)
{
ce6: 55 push %ebp
ce7: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
ce9: eb 08 jmp cf3 <strcmp+0xd>
p++, q++;
ceb: 83 45 08 01 addl $0x1,0x8(%ebp)
cef: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
cf3: 8b 45 08 mov 0x8(%ebp),%eax
cf6: 0f b6 00 movzbl (%eax),%eax
cf9: 84 c0 test %al,%al
cfb: 74 10 je d0d <strcmp+0x27>
cfd: 8b 45 08 mov 0x8(%ebp),%eax
d00: 0f b6 10 movzbl (%eax),%edx
d03: 8b 45 0c mov 0xc(%ebp),%eax
d06: 0f b6 00 movzbl (%eax),%eax
d09: 38 c2 cmp %al,%dl
d0b: 74 de je ceb <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
d0d: 8b 45 08 mov 0x8(%ebp),%eax
d10: 0f b6 00 movzbl (%eax),%eax
d13: 0f b6 d0 movzbl %al,%edx
d16: 8b 45 0c mov 0xc(%ebp),%eax
d19: 0f b6 00 movzbl (%eax),%eax
d1c: 0f b6 c0 movzbl %al,%eax
d1f: 29 c2 sub %eax,%edx
d21: 89 d0 mov %edx,%eax
}
d23: 5d pop %ebp
d24: c3 ret
00000d25 <strlen>:
uint
strlen(char *s)
{
d25: 55 push %ebp
d26: 89 e5 mov %esp,%ebp
d28: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
d2b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
d32: eb 04 jmp d38 <strlen+0x13>
d34: 83 45 fc 01 addl $0x1,-0x4(%ebp)
d38: 8b 55 fc mov -0x4(%ebp),%edx
d3b: 8b 45 08 mov 0x8(%ebp),%eax
d3e: 01 d0 add %edx,%eax
d40: 0f b6 00 movzbl (%eax),%eax
d43: 84 c0 test %al,%al
d45: 75 ed jne d34 <strlen+0xf>
;
return n;
d47: 8b 45 fc mov -0x4(%ebp),%eax
}
d4a: c9 leave
d4b: c3 ret
00000d4c <memset>:
void*
memset(void *dst, int c, uint n)
{
d4c: 55 push %ebp
d4d: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
d4f: 8b 45 10 mov 0x10(%ebp),%eax
d52: 50 push %eax
d53: ff 75 0c pushl 0xc(%ebp)
d56: ff 75 08 pushl 0x8(%ebp)
d59: e8 32 ff ff ff call c90 <stosb>
d5e: 83 c4 0c add $0xc,%esp
return dst;
d61: 8b 45 08 mov 0x8(%ebp),%eax
}
d64: c9 leave
d65: c3 ret
00000d66 <strchr>:
char*
strchr(const char *s, char c)
{
d66: 55 push %ebp
d67: 89 e5 mov %esp,%ebp
d69: 83 ec 04 sub $0x4,%esp
d6c: 8b 45 0c mov 0xc(%ebp),%eax
d6f: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
d72: eb 14 jmp d88 <strchr+0x22>
if(*s == c)
d74: 8b 45 08 mov 0x8(%ebp),%eax
d77: 0f b6 00 movzbl (%eax),%eax
d7a: 3a 45 fc cmp -0x4(%ebp),%al
d7d: 75 05 jne d84 <strchr+0x1e>
return (char*)s;
d7f: 8b 45 08 mov 0x8(%ebp),%eax
d82: eb 13 jmp d97 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
d84: 83 45 08 01 addl $0x1,0x8(%ebp)
d88: 8b 45 08 mov 0x8(%ebp),%eax
d8b: 0f b6 00 movzbl (%eax),%eax
d8e: 84 c0 test %al,%al
d90: 75 e2 jne d74 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
d92: b8 00 00 00 00 mov $0x0,%eax
}
d97: c9 leave
d98: c3 ret
00000d99 <gets>:
char*
gets(char *buf, int max)
{
d99: 55 push %ebp
d9a: 89 e5 mov %esp,%ebp
d9c: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
d9f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
da6: eb 42 jmp dea <gets+0x51>
cc = read(0, &c, 1);
da8: 83 ec 04 sub $0x4,%esp
dab: 6a 01 push $0x1
dad: 8d 45 ef lea -0x11(%ebp),%eax
db0: 50 push %eax
db1: 6a 00 push $0x0
db3: e8 47 01 00 00 call eff <read>
db8: 83 c4 10 add $0x10,%esp
dbb: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
dbe: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
dc2: 7e 33 jle df7 <gets+0x5e>
break;
buf[i++] = c;
dc4: 8b 45 f4 mov -0xc(%ebp),%eax
dc7: 8d 50 01 lea 0x1(%eax),%edx
dca: 89 55 f4 mov %edx,-0xc(%ebp)
dcd: 89 c2 mov %eax,%edx
dcf: 8b 45 08 mov 0x8(%ebp),%eax
dd2: 01 c2 add %eax,%edx
dd4: 0f b6 45 ef movzbl -0x11(%ebp),%eax
dd8: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
dda: 0f b6 45 ef movzbl -0x11(%ebp),%eax
dde: 3c 0a cmp $0xa,%al
de0: 74 16 je df8 <gets+0x5f>
de2: 0f b6 45 ef movzbl -0x11(%ebp),%eax
de6: 3c 0d cmp $0xd,%al
de8: 74 0e je df8 <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
dea: 8b 45 f4 mov -0xc(%ebp),%eax
ded: 83 c0 01 add $0x1,%eax
df0: 3b 45 0c cmp 0xc(%ebp),%eax
df3: 7c b3 jl da8 <gets+0xf>
df5: eb 01 jmp df8 <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
df7: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
df8: 8b 55 f4 mov -0xc(%ebp),%edx
dfb: 8b 45 08 mov 0x8(%ebp),%eax
dfe: 01 d0 add %edx,%eax
e00: c6 00 00 movb $0x0,(%eax)
return buf;
e03: 8b 45 08 mov 0x8(%ebp),%eax
}
e06: c9 leave
e07: c3 ret
00000e08 <stat>:
int
stat(char *n, struct stat *st)
{
e08: 55 push %ebp
e09: 89 e5 mov %esp,%ebp
e0b: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
e0e: 83 ec 08 sub $0x8,%esp
e11: 6a 00 push $0x0
e13: ff 75 08 pushl 0x8(%ebp)
e16: e8 0c 01 00 00 call f27 <open>
e1b: 83 c4 10 add $0x10,%esp
e1e: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
e21: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
e25: 79 07 jns e2e <stat+0x26>
return -1;
e27: b8 ff ff ff ff mov $0xffffffff,%eax
e2c: eb 25 jmp e53 <stat+0x4b>
r = fstat(fd, st);
e2e: 83 ec 08 sub $0x8,%esp
e31: ff 75 0c pushl 0xc(%ebp)
e34: ff 75 f4 pushl -0xc(%ebp)
e37: e8 03 01 00 00 call f3f <fstat>
e3c: 83 c4 10 add $0x10,%esp
e3f: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
e42: 83 ec 0c sub $0xc,%esp
e45: ff 75 f4 pushl -0xc(%ebp)
e48: e8 c2 00 00 00 call f0f <close>
e4d: 83 c4 10 add $0x10,%esp
return r;
e50: 8b 45 f0 mov -0x10(%ebp),%eax
}
e53: c9 leave
e54: c3 ret
00000e55 <atoi>:
int
atoi(const char *s)
{
e55: 55 push %ebp
e56: 89 e5 mov %esp,%ebp
e58: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
e5b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
e62: eb 25 jmp e89 <atoi+0x34>
n = n*10 + *s++ - '0';
e64: 8b 55 fc mov -0x4(%ebp),%edx
e67: 89 d0 mov %edx,%eax
e69: c1 e0 02 shl $0x2,%eax
e6c: 01 d0 add %edx,%eax
e6e: 01 c0 add %eax,%eax
e70: 89 c1 mov %eax,%ecx
e72: 8b 45 08 mov 0x8(%ebp),%eax
e75: 8d 50 01 lea 0x1(%eax),%edx
e78: 89 55 08 mov %edx,0x8(%ebp)
e7b: 0f b6 00 movzbl (%eax),%eax
e7e: 0f be c0 movsbl %al,%eax
e81: 01 c8 add %ecx,%eax
e83: 83 e8 30 sub $0x30,%eax
e86: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
e89: 8b 45 08 mov 0x8(%ebp),%eax
e8c: 0f b6 00 movzbl (%eax),%eax
e8f: 3c 2f cmp $0x2f,%al
e91: 7e 0a jle e9d <atoi+0x48>
e93: 8b 45 08 mov 0x8(%ebp),%eax
e96: 0f b6 00 movzbl (%eax),%eax
e99: 3c 39 cmp $0x39,%al
e9b: 7e c7 jle e64 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
e9d: 8b 45 fc mov -0x4(%ebp),%eax
}
ea0: c9 leave
ea1: c3 ret
00000ea2 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
ea2: 55 push %ebp
ea3: 89 e5 mov %esp,%ebp
ea5: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
ea8: 8b 45 08 mov 0x8(%ebp),%eax
eab: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
eae: 8b 45 0c mov 0xc(%ebp),%eax
eb1: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
eb4: eb 17 jmp ecd <memmove+0x2b>
*dst++ = *src++;
eb6: 8b 45 fc mov -0x4(%ebp),%eax
eb9: 8d 50 01 lea 0x1(%eax),%edx
ebc: 89 55 fc mov %edx,-0x4(%ebp)
ebf: 8b 55 f8 mov -0x8(%ebp),%edx
ec2: 8d 4a 01 lea 0x1(%edx),%ecx
ec5: 89 4d f8 mov %ecx,-0x8(%ebp)
ec8: 0f b6 12 movzbl (%edx),%edx
ecb: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
ecd: 8b 45 10 mov 0x10(%ebp),%eax
ed0: 8d 50 ff lea -0x1(%eax),%edx
ed3: 89 55 10 mov %edx,0x10(%ebp)
ed6: 85 c0 test %eax,%eax
ed8: 7f dc jg eb6 <memmove+0x14>
*dst++ = *src++;
return vdst;
eda: 8b 45 08 mov 0x8(%ebp),%eax
}
edd: c9 leave
ede: c3 ret
00000edf <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
edf: b8 01 00 00 00 mov $0x1,%eax
ee4: cd 40 int $0x40
ee6: c3 ret
00000ee7 <exit>:
SYSCALL(exit)
ee7: b8 02 00 00 00 mov $0x2,%eax
eec: cd 40 int $0x40
eee: c3 ret
00000eef <wait>:
SYSCALL(wait)
eef: b8 03 00 00 00 mov $0x3,%eax
ef4: cd 40 int $0x40
ef6: c3 ret
00000ef7 <pipe>:
SYSCALL(pipe)
ef7: b8 04 00 00 00 mov $0x4,%eax
efc: cd 40 int $0x40
efe: c3 ret
00000eff <read>:
SYSCALL(read)
eff: b8 05 00 00 00 mov $0x5,%eax
f04: cd 40 int $0x40
f06: c3 ret
00000f07 <write>:
SYSCALL(write)
f07: b8 10 00 00 00 mov $0x10,%eax
f0c: cd 40 int $0x40
f0e: c3 ret
00000f0f <close>:
SYSCALL(close)
f0f: b8 15 00 00 00 mov $0x15,%eax
f14: cd 40 int $0x40
f16: c3 ret
00000f17 <kill>:
SYSCALL(kill)
f17: b8 06 00 00 00 mov $0x6,%eax
f1c: cd 40 int $0x40
f1e: c3 ret
00000f1f <exec>:
SYSCALL(exec)
f1f: b8 07 00 00 00 mov $0x7,%eax
f24: cd 40 int $0x40
f26: c3 ret
00000f27 <open>:
SYSCALL(open)
f27: b8 0f 00 00 00 mov $0xf,%eax
f2c: cd 40 int $0x40
f2e: c3 ret
00000f2f <mknod>:
SYSCALL(mknod)
f2f: b8 11 00 00 00 mov $0x11,%eax
f34: cd 40 int $0x40
f36: c3 ret
00000f37 <unlink>:
SYSCALL(unlink)
f37: b8 12 00 00 00 mov $0x12,%eax
f3c: cd 40 int $0x40
f3e: c3 ret
00000f3f <fstat>:
SYSCALL(fstat)
f3f: b8 08 00 00 00 mov $0x8,%eax
f44: cd 40 int $0x40
f46: c3 ret
00000f47 <link>:
SYSCALL(link)
f47: b8 13 00 00 00 mov $0x13,%eax
f4c: cd 40 int $0x40
f4e: c3 ret
00000f4f <mkdir>:
SYSCALL(mkdir)
f4f: b8 14 00 00 00 mov $0x14,%eax
f54: cd 40 int $0x40
f56: c3 ret
00000f57 <chdir>:
SYSCALL(chdir)
f57: b8 09 00 00 00 mov $0x9,%eax
f5c: cd 40 int $0x40
f5e: c3 ret
00000f5f <dup>:
SYSCALL(dup)
f5f: b8 0a 00 00 00 mov $0xa,%eax
f64: cd 40 int $0x40
f66: c3 ret
00000f67 <getpid>:
SYSCALL(getpid)
f67: b8 0b 00 00 00 mov $0xb,%eax
f6c: cd 40 int $0x40
f6e: c3 ret
00000f6f <sbrk>:
SYSCALL(sbrk)
f6f: b8 0c 00 00 00 mov $0xc,%eax
f74: cd 40 int $0x40
f76: c3 ret
00000f77 <sleep>:
SYSCALL(sleep)
f77: b8 0d 00 00 00 mov $0xd,%eax
f7c: cd 40 int $0x40
f7e: c3 ret
00000f7f <uptime>:
SYSCALL(uptime)
f7f: b8 0e 00 00 00 mov $0xe,%eax
f84: cd 40 int $0x40
f86: c3 ret
00000f87 <getppid>:
SYSCALL(getppid)
f87: b8 16 00 00 00 mov $0x16,%eax
f8c: cd 40 int $0x40
f8e: c3 ret
00000f8f <wait2>:
SYSCALL(wait2)
f8f: b8 18 00 00 00 mov $0x18,%eax
f94: cd 40 int $0x40
f96: c3 ret
00000f97 <nice>:
SYSCALL(nice)
f97: b8 17 00 00 00 mov $0x17,%eax
f9c: cd 40 int $0x40
f9e: c3 ret
00000f9f <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
f9f: 55 push %ebp
fa0: 89 e5 mov %esp,%ebp
fa2: 83 ec 18 sub $0x18,%esp
fa5: 8b 45 0c mov 0xc(%ebp),%eax
fa8: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
fab: 83 ec 04 sub $0x4,%esp
fae: 6a 01 push $0x1
fb0: 8d 45 f4 lea -0xc(%ebp),%eax
fb3: 50 push %eax
fb4: ff 75 08 pushl 0x8(%ebp)
fb7: e8 4b ff ff ff call f07 <write>
fbc: 83 c4 10 add $0x10,%esp
}
fbf: 90 nop
fc0: c9 leave
fc1: c3 ret
00000fc2 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
fc2: 55 push %ebp
fc3: 89 e5 mov %esp,%ebp
fc5: 53 push %ebx
fc6: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
fc9: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
fd0: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
fd4: 74 17 je fed <printint+0x2b>
fd6: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
fda: 79 11 jns fed <printint+0x2b>
neg = 1;
fdc: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
fe3: 8b 45 0c mov 0xc(%ebp),%eax
fe6: f7 d8 neg %eax
fe8: 89 45 ec mov %eax,-0x14(%ebp)
feb: eb 06 jmp ff3 <printint+0x31>
} else {
x = xx;
fed: 8b 45 0c mov 0xc(%ebp),%eax
ff0: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
ff3: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
ffa: 8b 4d f4 mov -0xc(%ebp),%ecx
ffd: 8d 41 01 lea 0x1(%ecx),%eax
1000: 89 45 f4 mov %eax,-0xc(%ebp)
1003: 8b 5d 10 mov 0x10(%ebp),%ebx
1006: 8b 45 ec mov -0x14(%ebp),%eax
1009: ba 00 00 00 00 mov $0x0,%edx
100e: f7 f3 div %ebx
1010: 89 d0 mov %edx,%eax
1012: 0f b6 80 bc 19 00 00 movzbl 0x19bc(%eax),%eax
1019: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
101d: 8b 5d 10 mov 0x10(%ebp),%ebx
1020: 8b 45 ec mov -0x14(%ebp),%eax
1023: ba 00 00 00 00 mov $0x0,%edx
1028: f7 f3 div %ebx
102a: 89 45 ec mov %eax,-0x14(%ebp)
102d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1031: 75 c7 jne ffa <printint+0x38>
if(neg)
1033: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1037: 74 2d je 1066 <printint+0xa4>
buf[i++] = '-';
1039: 8b 45 f4 mov -0xc(%ebp),%eax
103c: 8d 50 01 lea 0x1(%eax),%edx
103f: 89 55 f4 mov %edx,-0xc(%ebp)
1042: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
1047: eb 1d jmp 1066 <printint+0xa4>
putc(fd, buf[i]);
1049: 8d 55 dc lea -0x24(%ebp),%edx
104c: 8b 45 f4 mov -0xc(%ebp),%eax
104f: 01 d0 add %edx,%eax
1051: 0f b6 00 movzbl (%eax),%eax
1054: 0f be c0 movsbl %al,%eax
1057: 83 ec 08 sub $0x8,%esp
105a: 50 push %eax
105b: ff 75 08 pushl 0x8(%ebp)
105e: e8 3c ff ff ff call f9f <putc>
1063: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
1066: 83 6d f4 01 subl $0x1,-0xc(%ebp)
106a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
106e: 79 d9 jns 1049 <printint+0x87>
putc(fd, buf[i]);
}
1070: 90 nop
1071: 8b 5d fc mov -0x4(%ebp),%ebx
1074: c9 leave
1075: c3 ret
00001076 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
1076: 55 push %ebp
1077: 89 e5 mov %esp,%ebp
1079: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
107c: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
1083: 8d 45 0c lea 0xc(%ebp),%eax
1086: 83 c0 04 add $0x4,%eax
1089: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
108c: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
1093: e9 59 01 00 00 jmp 11f1 <printf+0x17b>
c = fmt[i] & 0xff;
1098: 8b 55 0c mov 0xc(%ebp),%edx
109b: 8b 45 f0 mov -0x10(%ebp),%eax
109e: 01 d0 add %edx,%eax
10a0: 0f b6 00 movzbl (%eax),%eax
10a3: 0f be c0 movsbl %al,%eax
10a6: 25 ff 00 00 00 and $0xff,%eax
10ab: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
10ae: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
10b2: 75 2c jne 10e0 <printf+0x6a>
if(c == '%'){
10b4: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
10b8: 75 0c jne 10c6 <printf+0x50>
state = '%';
10ba: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
10c1: e9 27 01 00 00 jmp 11ed <printf+0x177>
} else {
putc(fd, c);
10c6: 8b 45 e4 mov -0x1c(%ebp),%eax
10c9: 0f be c0 movsbl %al,%eax
10cc: 83 ec 08 sub $0x8,%esp
10cf: 50 push %eax
10d0: ff 75 08 pushl 0x8(%ebp)
10d3: e8 c7 fe ff ff call f9f <putc>
10d8: 83 c4 10 add $0x10,%esp
10db: e9 0d 01 00 00 jmp 11ed <printf+0x177>
}
} else if(state == '%'){
10e0: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
10e4: 0f 85 03 01 00 00 jne 11ed <printf+0x177>
if(c == 'd'){
10ea: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
10ee: 75 1e jne 110e <printf+0x98>
printint(fd, *ap, 10, 1);
10f0: 8b 45 e8 mov -0x18(%ebp),%eax
10f3: 8b 00 mov (%eax),%eax
10f5: 6a 01 push $0x1
10f7: 6a 0a push $0xa
10f9: 50 push %eax
10fa: ff 75 08 pushl 0x8(%ebp)
10fd: e8 c0 fe ff ff call fc2 <printint>
1102: 83 c4 10 add $0x10,%esp
ap++;
1105: 83 45 e8 04 addl $0x4,-0x18(%ebp)
1109: e9 d8 00 00 00 jmp 11e6 <printf+0x170>
} else if(c == 'x' || c == 'p'){
110e: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
1112: 74 06 je 111a <printf+0xa4>
1114: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
1118: 75 1e jne 1138 <printf+0xc2>
printint(fd, *ap, 16, 0);
111a: 8b 45 e8 mov -0x18(%ebp),%eax
111d: 8b 00 mov (%eax),%eax
111f: 6a 00 push $0x0
1121: 6a 10 push $0x10
1123: 50 push %eax
1124: ff 75 08 pushl 0x8(%ebp)
1127: e8 96 fe ff ff call fc2 <printint>
112c: 83 c4 10 add $0x10,%esp
ap++;
112f: 83 45 e8 04 addl $0x4,-0x18(%ebp)
1133: e9 ae 00 00 00 jmp 11e6 <printf+0x170>
} else if(c == 's'){
1138: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
113c: 75 43 jne 1181 <printf+0x10b>
s = (char*)*ap;
113e: 8b 45 e8 mov -0x18(%ebp),%eax
1141: 8b 00 mov (%eax),%eax
1143: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
1146: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
114a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
114e: 75 25 jne 1175 <printf+0xff>
s = "(null)";
1150: c7 45 f4 20 15 00 00 movl $0x1520,-0xc(%ebp)
while(*s != 0){
1157: eb 1c jmp 1175 <printf+0xff>
putc(fd, *s);
1159: 8b 45 f4 mov -0xc(%ebp),%eax
115c: 0f b6 00 movzbl (%eax),%eax
115f: 0f be c0 movsbl %al,%eax
1162: 83 ec 08 sub $0x8,%esp
1165: 50 push %eax
1166: ff 75 08 pushl 0x8(%ebp)
1169: e8 31 fe ff ff call f9f <putc>
116e: 83 c4 10 add $0x10,%esp
s++;
1171: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1175: 8b 45 f4 mov -0xc(%ebp),%eax
1178: 0f b6 00 movzbl (%eax),%eax
117b: 84 c0 test %al,%al
117d: 75 da jne 1159 <printf+0xe3>
117f: eb 65 jmp 11e6 <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
1181: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
1185: 75 1d jne 11a4 <printf+0x12e>
putc(fd, *ap);
1187: 8b 45 e8 mov -0x18(%ebp),%eax
118a: 8b 00 mov (%eax),%eax
118c: 0f be c0 movsbl %al,%eax
118f: 83 ec 08 sub $0x8,%esp
1192: 50 push %eax
1193: ff 75 08 pushl 0x8(%ebp)
1196: e8 04 fe ff ff call f9f <putc>
119b: 83 c4 10 add $0x10,%esp
ap++;
119e: 83 45 e8 04 addl $0x4,-0x18(%ebp)
11a2: eb 42 jmp 11e6 <printf+0x170>
} else if(c == '%'){
11a4: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
11a8: 75 17 jne 11c1 <printf+0x14b>
putc(fd, c);
11aa: 8b 45 e4 mov -0x1c(%ebp),%eax
11ad: 0f be c0 movsbl %al,%eax
11b0: 83 ec 08 sub $0x8,%esp
11b3: 50 push %eax
11b4: ff 75 08 pushl 0x8(%ebp)
11b7: e8 e3 fd ff ff call f9f <putc>
11bc: 83 c4 10 add $0x10,%esp
11bf: eb 25 jmp 11e6 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
11c1: 83 ec 08 sub $0x8,%esp
11c4: 6a 25 push $0x25
11c6: ff 75 08 pushl 0x8(%ebp)
11c9: e8 d1 fd ff ff call f9f <putc>
11ce: 83 c4 10 add $0x10,%esp
putc(fd, c);
11d1: 8b 45 e4 mov -0x1c(%ebp),%eax
11d4: 0f be c0 movsbl %al,%eax
11d7: 83 ec 08 sub $0x8,%esp
11da: 50 push %eax
11db: ff 75 08 pushl 0x8(%ebp)
11de: e8 bc fd ff ff call f9f <putc>
11e3: 83 c4 10 add $0x10,%esp
}
state = 0;
11e6: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
11ed: 83 45 f0 01 addl $0x1,-0x10(%ebp)
11f1: 8b 55 0c mov 0xc(%ebp),%edx
11f4: 8b 45 f0 mov -0x10(%ebp),%eax
11f7: 01 d0 add %edx,%eax
11f9: 0f b6 00 movzbl (%eax),%eax
11fc: 84 c0 test %al,%al
11fe: 0f 85 94 fe ff ff jne 1098 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
1204: 90 nop
1205: c9 leave
1206: c3 ret
00001207 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
1207: 55 push %ebp
1208: 89 e5 mov %esp,%ebp
120a: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
120d: 8b 45 08 mov 0x8(%ebp),%eax
1210: 83 e8 08 sub $0x8,%eax
1213: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1216: a1 4c 1a 00 00 mov 0x1a4c,%eax
121b: 89 45 fc mov %eax,-0x4(%ebp)
121e: eb 24 jmp 1244 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1220: 8b 45 fc mov -0x4(%ebp),%eax
1223: 8b 00 mov (%eax),%eax
1225: 3b 45 fc cmp -0x4(%ebp),%eax
1228: 77 12 ja 123c <free+0x35>
122a: 8b 45 f8 mov -0x8(%ebp),%eax
122d: 3b 45 fc cmp -0x4(%ebp),%eax
1230: 77 24 ja 1256 <free+0x4f>
1232: 8b 45 fc mov -0x4(%ebp),%eax
1235: 8b 00 mov (%eax),%eax
1237: 3b 45 f8 cmp -0x8(%ebp),%eax
123a: 77 1a ja 1256 <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
123c: 8b 45 fc mov -0x4(%ebp),%eax
123f: 8b 00 mov (%eax),%eax
1241: 89 45 fc mov %eax,-0x4(%ebp)
1244: 8b 45 f8 mov -0x8(%ebp),%eax
1247: 3b 45 fc cmp -0x4(%ebp),%eax
124a: 76 d4 jbe 1220 <free+0x19>
124c: 8b 45 fc mov -0x4(%ebp),%eax
124f: 8b 00 mov (%eax),%eax
1251: 3b 45 f8 cmp -0x8(%ebp),%eax
1254: 76 ca jbe 1220 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
1256: 8b 45 f8 mov -0x8(%ebp),%eax
1259: 8b 40 04 mov 0x4(%eax),%eax
125c: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
1263: 8b 45 f8 mov -0x8(%ebp),%eax
1266: 01 c2 add %eax,%edx
1268: 8b 45 fc mov -0x4(%ebp),%eax
126b: 8b 00 mov (%eax),%eax
126d: 39 c2 cmp %eax,%edx
126f: 75 24 jne 1295 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
1271: 8b 45 f8 mov -0x8(%ebp),%eax
1274: 8b 50 04 mov 0x4(%eax),%edx
1277: 8b 45 fc mov -0x4(%ebp),%eax
127a: 8b 00 mov (%eax),%eax
127c: 8b 40 04 mov 0x4(%eax),%eax
127f: 01 c2 add %eax,%edx
1281: 8b 45 f8 mov -0x8(%ebp),%eax
1284: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
1287: 8b 45 fc mov -0x4(%ebp),%eax
128a: 8b 00 mov (%eax),%eax
128c: 8b 10 mov (%eax),%edx
128e: 8b 45 f8 mov -0x8(%ebp),%eax
1291: 89 10 mov %edx,(%eax)
1293: eb 0a jmp 129f <free+0x98>
} else
bp->s.ptr = p->s.ptr;
1295: 8b 45 fc mov -0x4(%ebp),%eax
1298: 8b 10 mov (%eax),%edx
129a: 8b 45 f8 mov -0x8(%ebp),%eax
129d: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
129f: 8b 45 fc mov -0x4(%ebp),%eax
12a2: 8b 40 04 mov 0x4(%eax),%eax
12a5: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
12ac: 8b 45 fc mov -0x4(%ebp),%eax
12af: 01 d0 add %edx,%eax
12b1: 3b 45 f8 cmp -0x8(%ebp),%eax
12b4: 75 20 jne 12d6 <free+0xcf>
p->s.size += bp->s.size;
12b6: 8b 45 fc mov -0x4(%ebp),%eax
12b9: 8b 50 04 mov 0x4(%eax),%edx
12bc: 8b 45 f8 mov -0x8(%ebp),%eax
12bf: 8b 40 04 mov 0x4(%eax),%eax
12c2: 01 c2 add %eax,%edx
12c4: 8b 45 fc mov -0x4(%ebp),%eax
12c7: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
12ca: 8b 45 f8 mov -0x8(%ebp),%eax
12cd: 8b 10 mov (%eax),%edx
12cf: 8b 45 fc mov -0x4(%ebp),%eax
12d2: 89 10 mov %edx,(%eax)
12d4: eb 08 jmp 12de <free+0xd7>
} else
p->s.ptr = bp;
12d6: 8b 45 fc mov -0x4(%ebp),%eax
12d9: 8b 55 f8 mov -0x8(%ebp),%edx
12dc: 89 10 mov %edx,(%eax)
freep = p;
12de: 8b 45 fc mov -0x4(%ebp),%eax
12e1: a3 4c 1a 00 00 mov %eax,0x1a4c
}
12e6: 90 nop
12e7: c9 leave
12e8: c3 ret
000012e9 <morecore>:
static Header*
morecore(uint nu)
{
12e9: 55 push %ebp
12ea: 89 e5 mov %esp,%ebp
12ec: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
12ef: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
12f6: 77 07 ja 12ff <morecore+0x16>
nu = 4096;
12f8: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
12ff: 8b 45 08 mov 0x8(%ebp),%eax
1302: c1 e0 03 shl $0x3,%eax
1305: 83 ec 0c sub $0xc,%esp
1308: 50 push %eax
1309: e8 61 fc ff ff call f6f <sbrk>
130e: 83 c4 10 add $0x10,%esp
1311: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
1314: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
1318: 75 07 jne 1321 <morecore+0x38>
return 0;
131a: b8 00 00 00 00 mov $0x0,%eax
131f: eb 26 jmp 1347 <morecore+0x5e>
hp = (Header*)p;
1321: 8b 45 f4 mov -0xc(%ebp),%eax
1324: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
1327: 8b 45 f0 mov -0x10(%ebp),%eax
132a: 8b 55 08 mov 0x8(%ebp),%edx
132d: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
1330: 8b 45 f0 mov -0x10(%ebp),%eax
1333: 83 c0 08 add $0x8,%eax
1336: 83 ec 0c sub $0xc,%esp
1339: 50 push %eax
133a: e8 c8 fe ff ff call 1207 <free>
133f: 83 c4 10 add $0x10,%esp
return freep;
1342: a1 4c 1a 00 00 mov 0x1a4c,%eax
}
1347: c9 leave
1348: c3 ret
00001349 <malloc>:
void*
malloc(uint nbytes)
{
1349: 55 push %ebp
134a: 89 e5 mov %esp,%ebp
134c: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
134f: 8b 45 08 mov 0x8(%ebp),%eax
1352: 83 c0 07 add $0x7,%eax
1355: c1 e8 03 shr $0x3,%eax
1358: 83 c0 01 add $0x1,%eax
135b: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
135e: a1 4c 1a 00 00 mov 0x1a4c,%eax
1363: 89 45 f0 mov %eax,-0x10(%ebp)
1366: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
136a: 75 23 jne 138f <malloc+0x46>
base.s.ptr = freep = prevp = &base;
136c: c7 45 f0 44 1a 00 00 movl $0x1a44,-0x10(%ebp)
1373: 8b 45 f0 mov -0x10(%ebp),%eax
1376: a3 4c 1a 00 00 mov %eax,0x1a4c
137b: a1 4c 1a 00 00 mov 0x1a4c,%eax
1380: a3 44 1a 00 00 mov %eax,0x1a44
base.s.size = 0;
1385: c7 05 48 1a 00 00 00 movl $0x0,0x1a48
138c: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
138f: 8b 45 f0 mov -0x10(%ebp),%eax
1392: 8b 00 mov (%eax),%eax
1394: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
1397: 8b 45 f4 mov -0xc(%ebp),%eax
139a: 8b 40 04 mov 0x4(%eax),%eax
139d: 3b 45 ec cmp -0x14(%ebp),%eax
13a0: 72 4d jb 13ef <malloc+0xa6>
if(p->s.size == nunits)
13a2: 8b 45 f4 mov -0xc(%ebp),%eax
13a5: 8b 40 04 mov 0x4(%eax),%eax
13a8: 3b 45 ec cmp -0x14(%ebp),%eax
13ab: 75 0c jne 13b9 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
13ad: 8b 45 f4 mov -0xc(%ebp),%eax
13b0: 8b 10 mov (%eax),%edx
13b2: 8b 45 f0 mov -0x10(%ebp),%eax
13b5: 89 10 mov %edx,(%eax)
13b7: eb 26 jmp 13df <malloc+0x96>
else {
p->s.size -= nunits;
13b9: 8b 45 f4 mov -0xc(%ebp),%eax
13bc: 8b 40 04 mov 0x4(%eax),%eax
13bf: 2b 45 ec sub -0x14(%ebp),%eax
13c2: 89 c2 mov %eax,%edx
13c4: 8b 45 f4 mov -0xc(%ebp),%eax
13c7: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
13ca: 8b 45 f4 mov -0xc(%ebp),%eax
13cd: 8b 40 04 mov 0x4(%eax),%eax
13d0: c1 e0 03 shl $0x3,%eax
13d3: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
13d6: 8b 45 f4 mov -0xc(%ebp),%eax
13d9: 8b 55 ec mov -0x14(%ebp),%edx
13dc: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
13df: 8b 45 f0 mov -0x10(%ebp),%eax
13e2: a3 4c 1a 00 00 mov %eax,0x1a4c
return (void*)(p + 1);
13e7: 8b 45 f4 mov -0xc(%ebp),%eax
13ea: 83 c0 08 add $0x8,%eax
13ed: eb 3b jmp 142a <malloc+0xe1>
}
if(p == freep)
13ef: a1 4c 1a 00 00 mov 0x1a4c,%eax
13f4: 39 45 f4 cmp %eax,-0xc(%ebp)
13f7: 75 1e jne 1417 <malloc+0xce>
if((p = morecore(nunits)) == 0)
13f9: 83 ec 0c sub $0xc,%esp
13fc: ff 75 ec pushl -0x14(%ebp)
13ff: e8 e5 fe ff ff call 12e9 <morecore>
1404: 83 c4 10 add $0x10,%esp
1407: 89 45 f4 mov %eax,-0xc(%ebp)
140a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
140e: 75 07 jne 1417 <malloc+0xce>
return 0;
1410: b8 00 00 00 00 mov $0x0,%eax
1415: eb 13 jmp 142a <malloc+0xe1>
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){
1417: 8b 45 f4 mov -0xc(%ebp),%eax
141a: 89 45 f0 mov %eax,-0x10(%ebp)
141d: 8b 45 f4 mov -0xc(%ebp),%eax
1420: 8b 00 mov (%eax),%eax
1422: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
1425: e9 6d ff ff ff jmp 1397 <malloc+0x4e>
}
142a: c9 leave
142b: c3 ret
|
.org $8000
init:
lda #$ff
sta $6002
lda #$01
sta $6000
loop_l:
rol A
bcs loop_r
sta $6000
jmp loop_l
loop_r:
ror A
bcs loop_l
sta $6000
jmp loop_r
.org $fffc
word init
word $0000
|
; A076824: Let a(1)=a(2)=1, a(n)=(2^ceiling(a(n-1)/2)+1)/a(n-2).
; 1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3,1,1,3,5,3
bin $0,2
pow $0,3
mod $0,5
mul $0,2
add $0,1
|
.size 8000
.text@48
ld a, ff
ldff(45), a
jp lstatint
.text@100
jp lbegin
.data@143
80
.text@150
lbegin:
ld a, ff
ldff(45), a
ld b, 95
call lwaitly_b
ld a, 40
ldff(41), a
xor a, a
ldff(0f), a
ld a, 02
ldff(ff), a
ei
ld a, b
inc a
inc a
ldff(45), a
.text@1000
lstatint:
ld a, 50
ldff(41), a
ld a, 99
ldff(45), a
.text@10cc
xor a, a
ldff(0f), a
nop
nop
nop
nop
nop
nop
nop
nop
nop
ldff a, (0f)
and a, 07
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
/***************************************************************************
*
* Copyright (c) 2019 Chatopera.Inc, Inc. All Rights Reserved
*
**************************************************************************/
/**
* @file /Users/hain/chatopera/chatopera.io/clause/src/sep/tests/tst-sep.cpp
* @author Hai Liang Wang(hain@chatopera.com)
* @date 2019-09-04_11:07:47
* @brief
*
**/
#include "gtest/gtest.h"
#include "glog/logging.h"
#include <string>
#include "emoji.h"
#include "punctuations.h"
#include "stopwords.h"
using namespace std;
using namespace chatopera::bot::sep;
TEST(SepTest, EMOJI) {
string config("../../../../var/test/sep/emoji.utf8");
Emojis emoji;
CHECK(emoji.init(config)) << "fail to init";
EXPECT_TRUE(emoji.contains("🐱")) << "check fails.";
EXPECT_FALSE(emoji.contains("1")) << "check fails.";
}
TEST(SepTest, PUNT) {
string config("../../../../var/test/sep/punctuations.utf8");
Punctuations punt;
CHECK(punt.init(config)) << "fail to init";
EXPECT_TRUE(punt.contains(",")) << "fail to check";
}
TEST(SepTest, STOPWORDS) {
string config("../../../../var/test/sep/stopwords.utf8");
Stopwords st;
CHECK(st.init(config)) << "fail to init";
EXPECT_TRUE(st.contains("也是")) << "fail to check";
}
/* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */
|
#include "ai/world/field.h"
#include <gtest/gtest.h>
class FieldTest : public ::testing::Test
{
protected:
void SetUp() override
{
length = 9.0;
width = 6.0;
defense_length = 1.0;
defense_width = 2.0;
goal_width = 1.0;
boundary_width = 0.3;
center_circle_radius = 0.5;
field = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
}
Field field = Field(0, 0, 0, 0, 0, 0, 0);
double length;
double width;
double defense_length;
double defense_width;
double goal_width;
double boundary_width;
double center_circle_radius;
};
TEST_F(FieldTest, construct_with_parameters)
{
// The field was already constructed in the test setup, so we only need to check
// values here
EXPECT_DOUBLE_EQ(length, field.length());
EXPECT_DOUBLE_EQ(width, field.width());
EXPECT_DOUBLE_EQ(goal_width, field.goalWidth());
EXPECT_DOUBLE_EQ(center_circle_radius, field.centreCircleRadius());
EXPECT_DOUBLE_EQ(defense_width, field.defenseAreaWidth());
EXPECT_DOUBLE_EQ(defense_length, field.defenseAreaLength());
}
TEST_F(FieldTest, update_with_all_parameters)
{
Field field_to_update = Field(0, 0, 0, 0, 0, 0, 0);
field_to_update.updateDimensions(length, width, defense_length, defense_width,
goal_width, boundary_width, center_circle_radius);
EXPECT_DOUBLE_EQ(9.6, field_to_update.totalLength());
EXPECT_DOUBLE_EQ(6.6, field_to_update.totalWidth());
EXPECT_DOUBLE_EQ(0.3, field_to_update.boundaryWidth());
EXPECT_EQ(Point(-4.5, 0.0), field_to_update.friendlyGoal());
EXPECT_EQ(Point(4.5, 0.0), field_to_update.enemyGoal());
EXPECT_EQ(Point(-4.5, 0.5), field_to_update.friendlyGoalpostPos());
EXPECT_EQ(Point(-4.5, -0.5), field_to_update.friendlyGoalpostNeg());
EXPECT_EQ(Point(4.5, 0.5), field_to_update.enemyGoalpostPos());
EXPECT_EQ(Point(4.5, -0.5), field_to_update.enemyGoalpostNeg());
EXPECT_EQ(Rect(Point(-4.5, 1.0), Point(-3.5, -1.0)),
field_to_update.friendlyDefenseArea());
EXPECT_EQ(Rect(Point(4.5, 1.0), Point(3.5, -1.0)),
field_to_update.enemyDefenseArea());
EXPECT_EQ(Point(-3.5, 0.0), field_to_update.penaltyFriendly());
EXPECT_EQ(Point(3.5, 0.0), field_to_update.penaltyEnemy());
EXPECT_EQ(Point(-4.5, 3.0), field_to_update.friendlyCornerPos());
EXPECT_EQ(Point(-4.5, -3.0), field_to_update.friendlyCornerNeg());
EXPECT_EQ(Point(4.5, 3.0), field_to_update.enemyCornerPos());
EXPECT_EQ(Point(4.5, -3.0), field_to_update.enemyCornerNeg());
}
TEST_F(FieldTest, update_with_new_field)
{
Field field_to_update = Field(0, 0, 0, 0, 0, 0, 0);
field_to_update.updateDimensions(field);
EXPECT_DOUBLE_EQ(9.6, field_to_update.totalLength());
EXPECT_DOUBLE_EQ(6.6, field_to_update.totalWidth());
EXPECT_DOUBLE_EQ(0.3, field_to_update.boundaryWidth());
EXPECT_EQ(Point(-4.5, 0.0), field_to_update.friendlyGoal());
EXPECT_EQ(Point(4.5, 0.0), field_to_update.enemyGoal());
EXPECT_EQ(Point(-4.5, 0.5), field_to_update.friendlyGoalpostPos());
EXPECT_EQ(Point(-4.5, -0.5), field_to_update.friendlyGoalpostNeg());
EXPECT_EQ(Point(4.5, 0.5), field_to_update.enemyGoalpostPos());
EXPECT_EQ(Point(4.5, -0.5), field_to_update.enemyGoalpostNeg());
EXPECT_EQ(Rect(Point(-4.5, 1.0), Point(-3.5, -1.0)),
field_to_update.friendlyDefenseArea());
EXPECT_EQ(Rect(Point(4.5, 1.0), Point(3.5, -1.0)),
field_to_update.enemyDefenseArea());
EXPECT_EQ(Point(-3.5, 0.0), field_to_update.penaltyFriendly());
EXPECT_EQ(Point(3.5, 0.0), field_to_update.penaltyEnemy());
EXPECT_EQ(Point(-4.5, 3.0), field_to_update.friendlyCornerPos());
EXPECT_EQ(Point(-4.5, -3.0), field_to_update.friendlyCornerNeg());
EXPECT_EQ(Point(4.5, 3.0), field_to_update.enemyCornerPos());
EXPECT_EQ(Point(4.5, -3.0), field_to_update.enemyCornerNeg());
}
TEST_F(FieldTest, equality_operator_fields_with_different_lengths)
{
Field field_1 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
Field field_2 = Field(length / 2, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
EXPECT_NE(field_1, field_2);
}
TEST_F(FieldTest, equality_operator_fields_with_different_widths)
{
Field field_1 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
Field field_2 = Field(length, width * 2, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
EXPECT_NE(field_1, field_2);
}
TEST_F(FieldTest, equality_operator_fields_with_different_defense_length)
{
Field field_1 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
Field field_2 = Field(length, width, defense_length * 2, defense_width, goal_width,
boundary_width, center_circle_radius);
EXPECT_NE(field_1, field_2);
}
TEST_F(FieldTest, equality_operator_fields_with_different_defense_width)
{
Field field_1 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
Field field_2 = Field(length, width, defense_length, defense_width / 2, goal_width,
boundary_width, center_circle_radius);
EXPECT_NE(field_1, field_2);
}
TEST_F(FieldTest, equality_operator_fields_with_different_goal_width)
{
Field field_1 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
Field field_2 = Field(length, width, defense_length, defense_width, 0, boundary_width,
center_circle_radius);
EXPECT_NE(field_1, field_2);
}
TEST_F(FieldTest, equality_operator_fields_with_different_boundary_width)
{
Field field_1 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
Field field_2 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width * 1.1, center_circle_radius);
EXPECT_NE(field_1, field_2);
}
TEST_F(FieldTest, equality_operator_fields_with_different_center_circle_radius)
{
Field field_1 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius);
Field field_2 = Field(length, width, defense_length, defense_width, goal_width,
boundary_width, center_circle_radius * 10);
EXPECT_NE(field_1, field_2);
}
int main(int argc, char **argv)
{
std::cout << argv[0] << std::endl;
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
; A103157: Number of ways to choose 4 distinct points from an (n+1) X (n+1) X (n+1) lattice cube.
; 70,17550,635376,9691375,88201170,566685735,2829877120,11671285626,41417124750,130179173740,370215608400,968104633665,2357084537626,5396491792125,11710951848960,24246290643940,48151733324310,92140804597626,170538695998000,306294282269955,535323344285730,912659131015555,1521020778869376,2482573303218750,3974849293232350,6252036915566520,9673116652256400,14738656119688501,22138454584118250,32812673159081145,48029600424386560,69483794177187720,99419016613713126,140781151435219750,197407166771913840,274257177650997975,377697776875307890,515846055171470751,698985132543984000,940063585875439810,1255292896613145390,1664858971296894660,2193765921898311376,2872832648434043625,3739865359866495930,4841032018528362805,6232467816660833280,7982144210468016876,10172037767578093750,12900639149089218450,16285846969517676720,20468296079957600875,25615175025574066626,31924593063140938875,39630563213665621120,49008674396206965510,60382532769829907070,74131060030358559376,90696744597383946000,110594950416156329565,134424397520975975050,162878938595068490865,196760766551437541376,236995199685762154000,284647203253188971910,340939819434229990590,407274691620529323760,485254883809891490751,576710211693839039250,683725318793566725655,808670748796287914880,954237284109778469130,1123473840635933458126,1319829229913268937500,1547198122143838270800,1809971567253730502545,2113092456091364597850,2462116330198842363501,2863277976354815872000,3323564271340310399220,3850793773180896250710,4453703587530244160170,5142044071943717699376,5926681976610127537875,6819712657730578280290,7834582039222587445875,8986219039854102963840,10291179226346111890126,11767800498496326942750,13436371660043773382760,15319314778890517617040,17441382292499567908485,19829869868876190307626,22514846090594359203625,25529400088933447802880,28909908317427031645080,32696321719082146376230,36932474609291693943126,41666416667124999750000,46950769501333763748775
add $0,2
pow $0,3
bin $0,4
|
.686
.model flat,stdcall
option casemap:none
include windows.inc
include .\bnlib.inc
include .\bignum.inc
.code
bnCreatei proc initVal:SDWORD
invoke HeapAlloc,BN_HHEAP,HEAP_GENERATE_EXCEPTIONS+HEAP_ZERO_MEMORY,BN_ALLOC_BYTES
.if eax
mov edx,initVal
mov [eax].BN.dwSize,1
test edx,edx
sets byte ptr [eax].BN.bSigned
.if sign?
neg edx
.endif
mov [eax].BN.dwArray[0*4],edx
ret
.endif
mov eax,BNERR_ALLOC
call _bn_error
ret
bnCreatei endp
end
|
; (C) Fubet Tech LLP, 2022
.include "tn84def.inc" ; Define device ATtiny84A
.org 0x00 ; Starting address of program
main:
SBI DDRA, 0 ; Set PA0 as Output pin
loop:
SBI PORTA, 0 ; Make PA0 HIGH
RCALL delay ; Call delay subroutine
CBI PORTA, 0 ; Make PA0 LOW
RCALL delay ; Call delay subroutine
RJMP loop ; Repeat from loop
delay:
SER R16 ; Set R16 = 0xFF
d2:
SER R17 ; Set R17 = 0xFF
d1:
DEC R17 ; Decrement R17
BRNE d1 ; If R17 is not 0 go back to d1
DEC R16
BRNE d2 ; If R16 is not 0 go back to d2
RET ; Return from delay subroutine
|
;
; Copyright (c) 2015 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
%include "third_party/x86inc/x86inc.asm"
SECTION_RODATA
pw_11585x2: times 8 dw 23170
pd_8192: times 4 dd 8192
%macro TRANSFORM_COEFFS 2
pw_%1_%2: dw %1, %2, %1, %2, %1, %2, %1, %2
pw_%2_m%1: dw %2, -%1, %2, -%1, %2, -%1, %2, -%1
%endmacro
TRANSFORM_COEFFS 11585, 11585
TRANSFORM_COEFFS 15137, 6270
TRANSFORM_COEFFS 16069, 3196
TRANSFORM_COEFFS 9102, 13623
SECTION .text
%if ARCH_X86_64
INIT_XMM ssse3
cglobal fdct8x8, 3, 5, 13, input, output, stride
mova m8, [GLOBAL(pd_8192)]
mova m12, [GLOBAL(pw_11585x2)]
lea r3, [2 * strideq]
lea r4, [4 * strideq]
mova m0, [inputq]
mova m1, [inputq + r3]
lea inputq, [inputq + r4]
mova m2, [inputq]
mova m3, [inputq + r3]
lea inputq, [inputq + r4]
mova m4, [inputq]
mova m5, [inputq + r3]
lea inputq, [inputq + r4]
mova m6, [inputq]
mova m7, [inputq + r3]
; left shift by 2 to increase forward transformation precision
psllw m0, 2
psllw m1, 2
psllw m2, 2
psllw m3, 2
psllw m4, 2
psllw m5, 2
psllw m6, 2
psllw m7, 2
; column transform
; stage 1
paddw m10, m0, m7
psubw m0, m7
paddw m9, m1, m6
psubw m1, m6
paddw m7, m2, m5
psubw m2, m5
paddw m6, m3, m4
psubw m3, m4
; stage 2
paddw m5, m9, m7
psubw m9, m7
paddw m4, m10, m6
psubw m10, m6
paddw m7, m1, m2
psubw m1, m2
; stage 3
paddw m6, m4, m5
psubw m4, m5
pmulhrsw m1, m12
pmulhrsw m7, m12
; sin(pi / 8), cos(pi / 8)
punpcklwd m2, m10, m9
punpckhwd m10, m9
pmaddwd m5, m2, [GLOBAL(pw_15137_6270)]
pmaddwd m2, [GLOBAL(pw_6270_m15137)]
pmaddwd m9, m10, [GLOBAL(pw_15137_6270)]
pmaddwd m10, [GLOBAL(pw_6270_m15137)]
paddd m5, m8
paddd m2, m8
paddd m9, m8
paddd m10, m8
psrad m5, 14
psrad m2, 14
psrad m9, 14
psrad m10, 14
packssdw m5, m9
packssdw m2, m10
pmulhrsw m6, m12
pmulhrsw m4, m12
paddw m9, m3, m1
psubw m3, m1
paddw m10, m0, m7
psubw m0, m7
; stage 4
; sin(pi / 16), cos(pi / 16)
punpcklwd m1, m10, m9
punpckhwd m10, m9
pmaddwd m7, m1, [GLOBAL(pw_16069_3196)]
pmaddwd m1, [GLOBAL(pw_3196_m16069)]
pmaddwd m9, m10, [GLOBAL(pw_16069_3196)]
pmaddwd m10, [GLOBAL(pw_3196_m16069)]
paddd m7, m8
paddd m1, m8
paddd m9, m8
paddd m10, m8
psrad m7, 14
psrad m1, 14
psrad m9, 14
psrad m10, 14
packssdw m7, m9
packssdw m1, m10
; sin(3 * pi / 16), cos(3 * pi / 16)
punpcklwd m11, m0, m3
punpckhwd m0, m3
pmaddwd m9, m11, [GLOBAL(pw_9102_13623)]
pmaddwd m11, [GLOBAL(pw_13623_m9102)]
pmaddwd m3, m0, [GLOBAL(pw_9102_13623)]
pmaddwd m0, [GLOBAL(pw_13623_m9102)]
paddd m9, m8
paddd m11, m8
paddd m3, m8
paddd m0, m8
psrad m9, 14
psrad m11, 14
psrad m3, 14
psrad m0, 14
packssdw m9, m3
packssdw m11, m0
; transpose
; stage 1
punpcklwd m0, m6, m7
punpcklwd m3, m5, m11
punpckhwd m6, m7
punpckhwd m5, m11
punpcklwd m7, m4, m9
punpcklwd m10, m2, m1
punpckhwd m4, m9
punpckhwd m2, m1
; stage 2
punpckldq m9, m0, m3
punpckldq m1, m6, m5
punpckhdq m0, m3
punpckhdq m6, m5
punpckldq m3, m7, m10
punpckldq m5, m4, m2
punpckhdq m7, m10
punpckhdq m4, m2
; stage 3
punpcklqdq m10, m9, m3
punpckhqdq m9, m3
punpcklqdq m2, m0, m7
punpckhqdq m0, m7
punpcklqdq m3, m1, m5
punpckhqdq m1, m5
punpcklqdq m7, m6, m4
punpckhqdq m6, m4
; row transform
; stage 1
paddw m5, m10, m6
psubw m10, m6
paddw m4, m9, m7
psubw m9, m7
paddw m6, m2, m1
psubw m2, m1
paddw m7, m0, m3
psubw m0, m3
;stage 2
paddw m1, m5, m7
psubw m5, m7
paddw m3, m4, m6
psubw m4, m6
paddw m7, m9, m2
psubw m9, m2
; stage 3
punpcklwd m6, m1, m3
punpckhwd m1, m3
pmaddwd m2, m6, [GLOBAL(pw_11585_11585)]
pmaddwd m6, [GLOBAL(pw_11585_m11585)]
pmaddwd m3, m1, [GLOBAL(pw_11585_11585)]
pmaddwd m1, [GLOBAL(pw_11585_m11585)]
paddd m2, m8
paddd m6, m8
paddd m3, m8
paddd m1, m8
psrad m2, 14
psrad m6, 14
psrad m3, 14
psrad m1, 14
packssdw m2, m3
packssdw m6, m1
pmulhrsw m7, m12
pmulhrsw m9, m12
punpcklwd m3, m5, m4
punpckhwd m5, m4
pmaddwd m1, m3, [GLOBAL(pw_15137_6270)]
pmaddwd m3, [GLOBAL(pw_6270_m15137)]
pmaddwd m4, m5, [GLOBAL(pw_15137_6270)]
pmaddwd m5, [GLOBAL(pw_6270_m15137)]
paddd m1, m8
paddd m3, m8
paddd m4, m8
paddd m5, m8
psrad m1, 14
psrad m3, 14
psrad m4, 14
psrad m5, 14
packssdw m1, m4
packssdw m3, m5
paddw m4, m0, m9
psubw m0, m9
paddw m5, m10, m7
psubw m10, m7
; stage 4
punpcklwd m9, m5, m4
punpckhwd m5, m4
pmaddwd m7, m9, [GLOBAL(pw_16069_3196)]
pmaddwd m9, [GLOBAL(pw_3196_m16069)]
pmaddwd m4, m5, [GLOBAL(pw_16069_3196)]
pmaddwd m5, [GLOBAL(pw_3196_m16069)]
paddd m7, m8
paddd m9, m8
paddd m4, m8
paddd m5, m8
psrad m7, 14
psrad m9, 14
psrad m4, 14
psrad m5, 14
packssdw m7, m4
packssdw m9, m5
punpcklwd m4, m10, m0
punpckhwd m10, m0
pmaddwd m5, m4, [GLOBAL(pw_9102_13623)]
pmaddwd m4, [GLOBAL(pw_13623_m9102)]
pmaddwd m0, m10, [GLOBAL(pw_9102_13623)]
pmaddwd m10, [GLOBAL(pw_13623_m9102)]
paddd m5, m8
paddd m4, m8
paddd m0, m8
paddd m10, m8
psrad m5, 14
psrad m4, 14
psrad m0, 14
psrad m10, 14
packssdw m5, m0
packssdw m4, m10
; transpose
; stage 1
punpcklwd m0, m2, m7
punpcklwd m10, m1, m4
punpckhwd m2, m7
punpckhwd m1, m4
punpcklwd m7, m6, m5
punpcklwd m4, m3, m9
punpckhwd m6, m5
punpckhwd m3, m9
; stage 2
punpckldq m5, m0, m10
punpckldq m9, m2, m1
punpckhdq m0, m10
punpckhdq m2, m1
punpckldq m10, m7, m4
punpckldq m1, m6, m3
punpckhdq m7, m4
punpckhdq m6, m3
; stage 3
punpcklqdq m4, m5, m10
punpckhqdq m5, m10
punpcklqdq m3, m0, m7
punpckhqdq m0, m7
punpcklqdq m10, m9, m1
punpckhqdq m9, m1
punpcklqdq m7, m2, m6
punpckhqdq m2, m6
psraw m1, m4, 15
psraw m6, m5, 15
psraw m8, m3, 15
psraw m11, m0, 15
psubw m4, m1
psubw m5, m6
psubw m3, m8
psubw m0, m11
psraw m4, 1
psraw m5, 1
psraw m3, 1
psraw m0, 1
psraw m1, m10, 15
psraw m6, m9, 15
psraw m8, m7, 15
psraw m11, m2, 15
psubw m10, m1
psubw m9, m6
psubw m7, m8
psubw m2, m11
psraw m10, 1
psraw m9, 1
psraw m7, 1
psraw m2, 1
mova [outputq + 0], m4
mova [outputq + 16], m5
mova [outputq + 32], m3
mova [outputq + 48], m0
mova [outputq + 64], m10
mova [outputq + 80], m9
mova [outputq + 96], m7
mova [outputq + 112], m2
RET
%endif
|
; A287196: Binary representation of the diagonal from the origin to the corner of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 259", based on the 5-celled von Neumann neighborhood.
; Submitted by Jon Maiga
; 1,11,100,11,10000,1111,1000000,111111,100000000,11111111,10000000000,1111111111,1000000000000,111111111111,100000000000000,11111111111111,10000000000000000,1111111111111111,1000000000000000000,111111111111111111,100000000000000000000,11111111111111111111,10000000000000000000000,1111111111111111111111,1000000000000000000000000,111111111111111111111111,100000000000000000000000000,11111111111111111111111111,10000000000000000000000000000,1111111111111111111111111111,1000000000000000000000000000000
seq $0,287199 ; Decimal representation of the diagonal from the origin to the corner of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 259", based on the 5-celled von Neumann neighborhood.
seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2.
|
// In map template description.ext use:
// #include "MissionDescription\CfgSoundsContents.hpp"
class fire
{
name="fire";
sound[]={"Music\fire.ogg",db+12,1.0}; // NB, this will resolve from root
titles[]={};
};
class StrikeThunder
{
name = "StrikeThunder";
sound[] = {"@A3\sounds_f_enviroment\ambient\thunders\thunder_01.wss", db+10, 1};
titles[] = {};
};
class StrikeImpact
{
name = "StrikeImpact";
sound[] = {"\Sounds\StrikeImpact.ogg", db+45, 1};
titles[] = {};
};
class StrikeSound
{
name = "StrikeSound";
sound[] = {"\Sounds\StrikeSound.ogg", db+10, 1};
titles[] = {};
};
class EarthquakeHeavy
{
name = "EarthquakeHeavy";
sound[] = {"@A3\Sounds_F\environment\ambient\quakes\earthquake4.wss", db + 45, 1};
titles[] = {};
};
class EarthquakeMore
{
name = "EarthquakeMore";
sound[] = {"@A3\Sounds_F\environment\ambient\quakes\earthquake3.wss", db + 45, 1};
titles[] = {};
};
class EarthquakeLess
{
name = "EarthquakeLess";
sound[] = {"@A3\Sounds_F\environment\ambient\quakes\earthquake2.wss", db + 45, 1};
titles[] = {};
};
class EarthquakeLight
{
name = "EarthquakeLight";
sound[] = {"@A3\Sounds_F\environment\ambient\quakes\earthquake1.wss", db + 45, 1};
titles[] = {};
};
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; DisableCache.Asm
;
; Abstract:
;
; Set the CD bit of CR0 to 1, clear the NW bit of CR0 to 0, and flush all caches with a
; WBINVD instruction.
;
; Notes:
;
;------------------------------------------------------------------------------
.486p
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; AsmDisableCache (
; VOID
; );
;------------------------------------------------------------------------------
AsmDisableCache PROC
mov eax, cr0
bts eax, 30
btr eax, 29
mov cr0, eax
wbinvd
ret
AsmDisableCache ENDP
END
|
//BasicTest
@10
D=A
@SP
A=M
M=D
@SP
M=M+1
@LCL
D=M
@0
A=D+A
D=A
@R15
M=D
@SP
M=M-1
@SP
A=M
D=M
@R15
A=M
M=D
@21
D=A
@SP
A=M
M=D
@SP
M=M+1
@22
D=A
@SP
A=M
M=D
@SP
M=M+1
@ARG
D=M
@2
A=D+A
D=A
@R15
M=D
@SP
M=M-1
@SP
A=M
D=M
@R15
A=M
M=D
@ARG
D=M
@1
A=D+A
D=A
@R15
M=D
@SP
M=M-1
@SP
A=M
D=M
@R15
A=M
M=D
@36
D=A
@SP
A=M
M=D
@SP
M=M+1
@THIS
D=M
@6
A=D+A
D=A
@R15
M=D
@SP
M=M-1
@SP
A=M
D=M
@R15
A=M
M=D
@42
D=A
@SP
A=M
M=D
@SP
M=M+1
@45
D=A
@SP
A=M
M=D
@SP
M=M+1
@THAT
D=M
@5
A=D+A
D=A
@R15
M=D
@SP
M=M-1
@SP
A=M
D=M
@R15
A=M
M=D
@THAT
D=M
@2
A=D+A
D=A
@R15
M=D
@SP
M=M-1
@SP
A=M
D=M
@R15
A=M
M=D
@510
D=A
@SP
A=M
M=D
@SP
M=M+1
@R5
D=A
@6
A=D+A
D=A
@R15
M=D
@SP
M=M-1
@SP
A=M
D=M
@R15
A=M
M=D
@LCL
D=M
@0
A=D+A
D=M
@SP
A=M
M=D
@SP
M=M+1
@THAT
D=M
@5
A=D+A
D=M
@SP
A=M
M=D
@SP
M=M+1
@SP
M=M-1
@SP
A=M
D=M
@SP
M=M-1
@SP
A=M
D=M+D
@SP
A=M
M=D
@SP
M=M+1
@ARG
D=M
@1
A=D+A
D=M
@SP
A=M
M=D
@SP
M=M+1
@SP
M=M-1
@SP
A=M
D=M
@SP
M=M-1
@SP
A=M
D=M-D
@SP
A=M
M=D
@SP
M=M+1
@THIS
D=M
@6
A=D+A
D=M
@SP
A=M
M=D
@SP
M=M+1
@THIS
D=M
@6
A=D+A
D=M
@SP
A=M
M=D
@SP
M=M+1
@SP
M=M-1
@SP
A=M
D=M
@SP
M=M-1
@SP
A=M
D=M+D
@SP
A=M
M=D
@SP
M=M+1
@SP
M=M-1
@SP
A=M
D=M
@SP
M=M-1
@SP
A=M
D=M-D
@SP
A=M
M=D
@SP
M=M+1
@R5
D=A
@6
A=D+A
D=M
@SP
A=M
M=D
@SP
M=M+1
@SP
M=M-1
@SP
A=M
D=M
@SP
M=M-1
@SP
A=M
D=M+D
@SP
A=M
M=D
@SP
M=M+1 |
; A021697: Decimal expansion of 1/693.
; 0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1,4,4,3,0,0,1
mul $0,3
mod $0,18
mov $5,$0
lpb $0,1
mul $0,2
add $3,$5
sub $0,$3
sub $0,1
add $2,$5
mov $6,$0
lpb $3,1
lpb $0,1
mod $0,10
sub $0,1
sub $1,$4
mov $4,$2
lpe
add $0,1
mov $3,$1
lpe
lpb $0,1
sub $0,7
mov $6,$7
lpe
mov $1,$0
add $1,3
lpe
lpb $6,1
sub $1,$1
sub $6,$3
lpe
|
#include <Arduino.h>
#define LED_TOPLEFT 8
#define LED_TOPCENTER 7
#define LED_TOPRIGHT 6
#define LED_CENTER 5
#define LED_BOTLEFT 2
#define LED_BOTCENTER 3
#define LED_BOTRIGHT 4
#define BUTTON 9
long led_count = 0;
void clear_leds();
void set_leds(long led_count_i);
void setup() {
Serial.begin(9600);
Serial.println("Starting...");
pinMode(LED_TOPLEFT, OUTPUT);
pinMode(LED_TOPCENTER, OUTPUT);
pinMode(LED_TOPRIGHT, OUTPUT);
pinMode(LED_CENTER, OUTPUT);
pinMode(LED_BOTLEFT, OUTPUT);
pinMode(LED_BOTCENTER, OUTPUT);
pinMode(LED_BOTRIGHT, OUTPUT);
pinMode(BUTTON, OUTPUT);
clear_leds();
}
void loop() {
if(digitalRead(BUTTON) == HIGH){
led_count = random(1, 7);
set_leds(led_count);
delay(300);
led_count = random(1, 7);
set_leds(led_count);
delay(300);
led_count = random(1, 7);
Serial.print("Random number is: "); Serial.println(led_count);
set_leds(led_count);
delay(500);
}
}
void clear_leds(){
digitalWrite(LED_TOPLEFT, LOW);
digitalWrite(LED_TOPCENTER, LOW);
digitalWrite(LED_TOPRIGHT, LOW);
digitalWrite(LED_CENTER, LOW);
digitalWrite(LED_BOTLEFT, LOW);
digitalWrite(LED_BOTCENTER, LOW);
digitalWrite(LED_BOTRIGHT, LOW);
Serial.println("Leds cleared...");
}
void set_leds(long led_count_i){
clear_leds();
switch (led_count_i)
{
case 1:
digitalWrite(LED_CENTER, HIGH);
break;
case 2:
digitalWrite(LED_BOTLEFT, HIGH);
digitalWrite(LED_TOPRIGHT, HIGH);
break;
case 3:
digitalWrite(LED_BOTLEFT, HIGH);
digitalWrite(LED_CENTER, HIGH);
digitalWrite(LED_TOPRIGHT, HIGH);
break;
case 4:
digitalWrite(LED_BOTLEFT, HIGH);
digitalWrite(LED_BOTRIGHT, HIGH);
digitalWrite(LED_TOPLEFT, HIGH);
digitalWrite(LED_TOPRIGHT, HIGH);
break;
case 5:
digitalWrite(LED_BOTLEFT, HIGH);
digitalWrite(LED_BOTRIGHT, HIGH);
digitalWrite(LED_CENTER, HIGH);
digitalWrite(LED_TOPLEFT, HIGH);
digitalWrite(LED_TOPRIGHT, HIGH);
break;
case 6:
digitalWrite(LED_BOTLEFT, HIGH);
digitalWrite(LED_BOTCENTER, HIGH);
digitalWrite(LED_BOTRIGHT, HIGH);
digitalWrite(LED_TOPLEFT, HIGH);
digitalWrite(LED_TOPCENTER, HIGH);
digitalWrite(LED_TOPRIGHT, HIGH);
break;
default:
break;
}
} |
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "precompiled.h"
#include <functional>
#include <QGraphicsLayoutItem>
#include <QGraphicsGridLayout>
#include <QGraphicsScene>
#include <qgraphicssceneevent.h>
#include <AzCore/RTTI/TypeInfo.h>
#include <Components/Nodes/Wrapper/WrapperNodeLayoutComponent.h>
#include <Components/Nodes/NodeComponent.h>
#include <Components/Nodes/General/GeneralNodeFrameComponent.h>
#include <Components/Nodes/General/GeneralSlotLayoutComponent.h>
#include <Components/Nodes/General/GeneralNodeTitleComponent.h>
#include <Components/StylingComponent.h>
#include <GraphCanvas/Components/GeometryBus.h>
#include <GraphCanvas/Components/Slots/SlotBus.h>
#include <GraphCanvas/Editor/GraphModelBus.h>
#include <GraphCanvas/tools.h>
#include <GraphCanvas/Styling/StyleHelper.h>
namespace GraphCanvas
{
//////////////////////
// WrappedNodeLayout
//////////////////////
WrapperNodeLayoutComponent::WrappedNodeLayout::WrappedNodeLayout(WrapperNodeLayoutComponent& wrapperLayoutComponent)
: QGraphicsWidget(nullptr)
, m_wrapperLayoutComponent(wrapperLayoutComponent)
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
m_layout = new QGraphicsLinearLayout(Qt::Vertical);
setLayout(m_layout);
}
WrapperNodeLayoutComponent::WrappedNodeLayout::~WrappedNodeLayout()
{
}
void WrapperNodeLayoutComponent::WrappedNodeLayout::RefreshStyle()
{
prepareGeometryChange();
m_styleHelper.SetStyle(m_wrapperLayoutComponent.GetEntityId(), Styling::Elements::WrapperNode::NodeLayout);
qreal margin = m_styleHelper.GetAttribute(Styling::Attribute::Margin, 0.0);
setContentsMargins(margin, margin, margin, margin);
setMinimumSize(m_styleHelper.GetMinimumSize());
setMaximumSize(m_styleHelper.GetMaximumSize());
// Layout spacing
m_layout->setSpacing(m_styleHelper.GetAttribute(Styling::Attribute::Spacing, 0.0));
m_layout->invalidate();
m_layout->updateGeometry();
updateGeometry();
update();
}
void WrapperNodeLayoutComponent::WrappedNodeLayout::RefreshLayout()
{
prepareGeometryChange();
ClearLayout();
LayoutItems();
}
void WrapperNodeLayoutComponent::WrappedNodeLayout::LayoutItems()
{
if (!m_wrapperLayoutComponent.m_wrappedNodes.empty())
{
setVisible(true);
for (const AZ::EntityId& nodeId : m_wrapperLayoutComponent.m_wrappedNodes)
{
QGraphicsLayoutItem* rootLayoutItem = nullptr;
SceneMemberUIRequestBus::EventResult(rootLayoutItem, nodeId, &SceneMemberUIRequests::GetRootGraphicsLayoutItem);
if (rootLayoutItem)
{
m_layout->addItem(rootLayoutItem);
}
}
updateGeometry();
update();
}
else
{
setVisible(false);
}
}
void WrapperNodeLayoutComponent::WrappedNodeLayout::ClearLayout()
{
while (m_layout->count() > 0)
{
QGraphicsLayoutItem* layoutItem = m_layout->itemAt(m_layout->count() - 1);
m_layout->removeAt(m_layout->count() - 1);
layoutItem->setParentLayoutItem(nullptr);
}
}
////////////////////////////////////
// WrappedNodeActionGraphicsWidget
////////////////////////////////////
WrapperNodeLayoutComponent::WrappedNodeActionGraphicsWidget::WrappedNodeActionGraphicsWidget(WrapperNodeLayoutComponent& wrapperLayoutComponent)
: QGraphicsWidget(nullptr)
, m_wrapperLayoutComponent(wrapperLayoutComponent)
, m_styleState(StyleState::Empty)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setFlag(ItemIsFocusable);
setAcceptHoverEvents(true);
setAcceptDrops(true);
QGraphicsLinearLayout* paddingLayout = new QGraphicsLinearLayout(Qt::Vertical);
paddingLayout->setContentsMargins(6, 6, 6, 6);
paddingLayout->setSpacing(0);
m_displayLabel = new GraphCanvasLabel();
m_displayLabel->setZValue(1);
m_displayLabel->setFlag(ItemIsFocusable);
m_displayLabel->setFocusPolicy(Qt::StrongFocus);
m_displayLabel->setAcceptDrops(true);
m_displayLabel->setAcceptHoverEvents(true);
m_displayLabel->setAcceptedMouseButtons(Qt::MouseButton::LeftButton);
paddingLayout->addItem(m_displayLabel);
setLayout(paddingLayout);
}
void WrapperNodeLayoutComponent::WrappedNodeActionGraphicsWidget::OnAddedToScene()
{
m_displayLabel->installSceneEventFilter(this);
}
void WrapperNodeLayoutComponent::WrappedNodeActionGraphicsWidget::RefreshStyle()
{
switch (m_styleState)
{
case StyleState::Empty:
m_displayLabel->SetStyle(m_wrapperLayoutComponent.GetEntityId(), Styling::Elements::WrapperNode::ActionLabelEmptyNodes);
break;
case StyleState::HasElements:
m_displayLabel->SetStyle(m_wrapperLayoutComponent.GetEntityId(), Styling::Elements::WrapperNode::ActionLabel);
break;
}
}
void WrapperNodeLayoutComponent::WrappedNodeActionGraphicsWidget::SetActionString(const QString& displayString)
{
m_displayLabel->SetLabel(displayString.toUtf8().data());
}
void WrapperNodeLayoutComponent::WrappedNodeActionGraphicsWidget::SetStyleState(StyleState state)
{
if (m_styleState != state)
{
m_styleState = state;
RefreshStyle();
}
}
bool WrapperNodeLayoutComponent::WrappedNodeActionGraphicsWidget::sceneEventFilter(QGraphicsItem*, QEvent* event)
{
switch (event->type())
{
case QEvent::GraphicsSceneDragEnter:
{
QGraphicsSceneDragDropEvent* dragDropEvent = static_cast<QGraphicsSceneDragDropEvent*>(event);
if (m_wrapperLayoutComponent.ShouldAcceptDrop(dragDropEvent->mimeData()))
{
m_acceptDrop = true;
dragDropEvent->accept();
dragDropEvent->acceptProposedAction();
m_displayLabel->GetStyleHelper().AddSelector(Styling::States::ValidDrop);
}
else
{
m_acceptDrop = false;
m_displayLabel->GetStyleHelper().AddSelector(Styling::States::InvalidDrop);
}
m_displayLabel->update();
return true;
}
case QEvent::GraphicsSceneDragLeave:
{
event->accept();
if (m_acceptDrop)
{
m_displayLabel->GetStyleHelper().RemoveSelector(Styling::States::ValidDrop);
m_acceptDrop = false;
m_wrapperLayoutComponent.OnDragLeave();
}
else
{
m_displayLabel->GetStyleHelper().RemoveSelector(Styling::States::InvalidDrop);
}
m_displayLabel->update();
return true;
}
case QEvent::GraphicsSceneDrop:
{
if (m_acceptDrop)
{
m_displayLabel->GetStyleHelper().RemoveSelector(Styling::States::ValidDrop);
}
else
{
m_displayLabel->GetStyleHelper().RemoveSelector(Styling::States::InvalidDrop);
}
m_displayLabel->update();
break;
}
case QEvent::GraphicsSceneMousePress:
{
return true;
}
case QEvent::GraphicsSceneMouseRelease:
{
QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event);
m_wrapperLayoutComponent.OnActionWidgetClicked(mouseEvent->scenePos(), mouseEvent->screenPos());
return true;
}
default:
break;
}
return false;
}
///////////////////////////////
// WrapperNodeLayoutComponent
///////////////////////////////
void WrapperNodeLayoutComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<WrappedNodeConfiguration>()
->Version(1)
->Field("LayoutOrder", &WrappedNodeConfiguration::m_layoutOrder)
->Field("ElementOrder", &WrappedNodeConfiguration::m_elementOrdering)
;
serializeContext->Class<WrapperNodeLayoutComponent, NodeLayoutComponent>()
->Version(2)
->Field("ElementOrdering", &WrapperNodeLayoutComponent::m_elementCounter)
->Field("WrappedNodeConfigurations", &WrapperNodeLayoutComponent::m_wrappedNodeConfigurations)
;
}
}
AZ::Entity* WrapperNodeLayoutComponent::CreateWrapperNodeEntity(const char* nodeType)
{
// Create this Node's entity.
AZ::Entity* entity = NodeComponent::CreateCoreNodeEntity();
entity->CreateComponent<GeneralNodeFrameComponent>();
entity->CreateComponent<StylingComponent>(Styling::Elements::WrapperNode::Node, AZ::EntityId(), nodeType);
entity->CreateComponent<WrapperNodeLayoutComponent>();
entity->CreateComponent<GeneralNodeTitleComponent>();
entity->CreateComponent<GeneralSlotLayoutComponent>();
return entity;
}
WrapperNodeLayoutComponent::WrapperNodeLayoutComponent()
: m_elementCounter(0)
, m_wrappedNodes(WrappedNodeConfigurationComparator(&m_wrappedNodeConfigurations))
, m_title(nullptr)
, m_slots(nullptr)
, m_wrappedNodeLayout(nullptr)
{
}
WrapperNodeLayoutComponent::~WrapperNodeLayoutComponent()
{
}
void WrapperNodeLayoutComponent::Init()
{
NodeLayoutComponent::Init();
m_layout = new QGraphicsLinearLayout(Qt::Vertical);
GetLayoutAs<QGraphicsLinearLayout>()->setInstantInvalidatePropagation(true);
m_wrappedNodeLayout = aznew WrappedNodeLayout((*this));
m_wrapperNodeActionWidget = aznew WrappedNodeActionGraphicsWidget((*this));
for (auto& mapPair : m_wrappedNodeConfigurations)
{
m_wrappedNodes.insert(mapPair.first);
}
}
void WrapperNodeLayoutComponent::Activate()
{
NodeLayoutComponent::Activate();
NodeNotificationBus::MultiHandler::BusConnect(GetEntityId());
WrapperNodeRequestBus::Handler::BusConnect(GetEntityId());
}
void WrapperNodeLayoutComponent::Deactivate()
{
ClearLayout();
NodeLayoutComponent::Deactivate();
NodeNotificationBus::MultiHandler::BusDisconnect();
WrapperNodeRequestBus::Handler::BusDisconnect();
StyleNotificationBus::Handler::BusDisconnect();
}
void WrapperNodeLayoutComponent::SetActionString(const QString& actionString)
{
m_wrapperNodeActionWidget->SetActionString(actionString);
}
AZStd::vector< AZ::EntityId > WrapperNodeLayoutComponent::GetWrappedNodeIds() const
{
return AZStd::vector< AZ::EntityId >(m_wrappedNodes.begin(), m_wrappedNodes.end());
}
void WrapperNodeLayoutComponent::WrapNode(const AZ::EntityId& nodeId, const WrappedNodeConfiguration& nodeConfiguration)
{
if (m_wrappedNodeConfigurations.find(nodeId) == m_wrappedNodeConfigurations.end())
{
NodeNotificationBus::MultiHandler::BusConnect(nodeId);
NodeRequestBus::Event(nodeId, &NodeRequests::SetWrappingNode, GetEntityId());
WrapperNodeNotificationBus::Event(GetEntityId(), &WrapperNodeNotifications::OnWrappedNode, nodeId);
m_wrappedNodeConfigurations[nodeId] = nodeConfiguration;
m_wrappedNodeConfigurations[nodeId].m_elementOrdering = m_elementCounter;
++m_elementCounter;
m_wrappedNodes.insert(nodeId);
m_wrappedNodeLayout->RefreshLayout();
NodeUIRequestBus::Event(GetEntityId(), &NodeUIRequests::AdjustSize);
RefreshActionStyle();
}
}
void WrapperNodeLayoutComponent::UnwrapNode(const AZ::EntityId& nodeId)
{
auto configurationIter = m_wrappedNodeConfigurations.find(nodeId);
if (configurationIter != m_wrappedNodeConfigurations.end())
{
NodeNotificationBus::MultiHandler::BusDisconnect(nodeId);
NodeRequestBus::Event(nodeId, &NodeRequests::SetWrappingNode, AZ::EntityId());
WrapperNodeNotificationBus::Event(GetEntityId(), &WrapperNodeNotifications::OnUnwrappedNode, nodeId);
m_wrappedNodes.erase(nodeId);
m_wrappedNodeConfigurations.erase(configurationIter);
m_wrappedNodeLayout->RefreshLayout();
NodeUIRequestBus::Event(GetEntityId(), &NodeUIRequests::AdjustSize);
RefreshActionStyle();
}
}
void WrapperNodeLayoutComponent::SetWrapperType(const AZ::Crc32& wrapperType)
{
m_wrapperType = wrapperType;
}
AZ::Crc32 WrapperNodeLayoutComponent::GetWrapperType() const
{
return m_wrapperType;
}
void WrapperNodeLayoutComponent::OnNodeActivated()
{
AZ::EntityId nodeId = (*NodeNotificationBus::GetCurrentBusId());
if (nodeId == GetEntityId())
{
CreateLayout();
}
}
void WrapperNodeLayoutComponent::OnNodeAboutToSerialize(GraphSerialization& sceneSerialization)
{
AZ::EntityId nodeId = (*NodeNotificationBus::GetCurrentBusId());
if (nodeId == GetEntityId())
{
for (const AZ::EntityId& entityId : m_wrappedNodes)
{
AZ::Entity* wrappedNodeEntity = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(wrappedNodeEntity, &AZ::ComponentApplicationRequests::FindEntity, entityId);
sceneSerialization.GetGraphData().m_nodes.insert(wrappedNodeEntity);
}
}
}
void WrapperNodeLayoutComponent::OnNodeDeserialized(const AZ::EntityId& graphId, const GraphSerialization& sceneSerialization)
{
AZ::EntityId nodeId = (*NodeNotificationBus::GetCurrentBusId());
if (nodeId == GetEntityId())
{
m_elementCounter = 0;
m_wrappedNodes.clear();
WrappedNodeConfigurationMap oldConfigurations = m_wrappedNodeConfigurations;
m_wrappedNodeConfigurations.clear();
for (auto& configurationPair : oldConfigurations)
{
if (sceneSerialization.FindRemappedEntityId(configurationPair.first).IsValid())
{
m_wrappedNodeConfigurations.insert(configurationPair);
m_wrappedNodes.insert(configurationPair.first);
}
}
}
}
void WrapperNodeLayoutComponent::OnAddedToScene(const AZ::EntityId& sceneId)
{
AZ::EntityId nodeId = (*NodeNotificationBus::GetCurrentBusId());
if (nodeId == GetEntityId())
{
for (const AZ::EntityId& wrappedNodeId : m_wrappedNodes)
{
NodeNotificationBus::MultiHandler::BusConnect(wrappedNodeId);
// Test to make sure the node is activated before we signal out anything to it.
//
// We listen for when the node activates, so these calls will be handled there.
if (NodeRequestBus::FindFirstHandler(wrappedNodeId) != nullptr)
{
NodeRequestBus::Event(wrappedNodeId, &NodeRequests::SetWrappingNode, GetEntityId());
WrapperNodeNotificationBus::Event(GetEntityId(), &WrapperNodeNotifications::OnWrappedNode, wrappedNodeId);
}
}
RefreshActionStyle();
UpdateLayout();
OnStyleChanged();
// Event filtering for graphics items can only be done by items in the same scene.
// and by objects that are in a scene. So I need to wait for them to be added to the
// scene before installing my filters.
m_wrapperNodeActionWidget->OnAddedToScene();
StyleNotificationBus::Handler::BusConnect(GetEntityId());
}
else
{
NodeRequestBus::Event(nodeId, &NodeRequests::SetWrappingNode, GetEntityId());
WrapperNodeNotificationBus::Event(GetEntityId(), &WrapperNodeNotifications::OnWrappedNode, nodeId);
// Sort ick, but should work for now.
// Mostly ick because it'll redo this layout waaaay to many times.
UpdateLayout();
}
}
void WrapperNodeLayoutComponent::OnRemovedFromScene(const AZ::EntityId& sceneId)
{
AZ::EntityId nodeId = (*NodeNotificationBus::GetCurrentBusId());
if (nodeId == GetEntityId())
{
AZStd::unordered_set< AZ::EntityId > deleteNodes(m_wrappedNodes.begin(), m_wrappedNodes.end());
SceneRequestBus::Event(sceneId, &SceneRequests::Delete, deleteNodes);
}
else
{
UnwrapNode(nodeId);
}
}
void WrapperNodeLayoutComponent::OnStyleChanged()
{
m_styleHelper.SetStyle(GetEntityId());
qreal border = m_styleHelper.GetAttribute(Styling::Attribute::BorderWidth, 0.0);
qreal spacing = m_styleHelper.GetAttribute(Styling::Attribute::Spacing, 0.0);
qreal margin = m_styleHelper.GetAttribute(Styling::Attribute::Margin, 0.0);
GetLayoutAs<QGraphicsLinearLayout>()->setContentsMargins(margin + border, margin + border, margin + border, margin + border);
GetLayoutAs<QGraphicsLinearLayout>()->setSpacing(spacing);
m_wrappedNodeLayout->RefreshStyle();
m_wrapperNodeActionWidget->RefreshStyle();
RefreshDisplay();
}
void WrapperNodeLayoutComponent::RefreshActionStyle()
{
if (!m_wrappedNodes.empty())
{
m_wrapperNodeActionWidget->SetStyleState(WrappedNodeActionGraphicsWidget::StyleState::HasElements);
}
else
{
m_wrapperNodeActionWidget->SetStyleState(WrappedNodeActionGraphicsWidget::StyleState::Empty);
}
}
bool WrapperNodeLayoutComponent::ShouldAcceptDrop(const QMimeData* mimeData) const
{
AZ::EntityId sceneId;
SceneMemberRequestBus::EventResult(sceneId, GetEntityId(), &SceneMemberRequests::GetScene);
bool shouldAcceptDrop = false;
GraphModelRequestBus::EventResult(shouldAcceptDrop, sceneId, &GraphModelRequests::ShouldWrapperAcceptDrop, GetEntityId(), mimeData);
if (shouldAcceptDrop)
{
GraphModelRequestBus::Event(sceneId, &GraphModelRequests::AddWrapperDropTarget, GetEntityId());
}
return shouldAcceptDrop;
}
void WrapperNodeLayoutComponent::OnDragLeave() const
{
AZ::EntityId sceneId;
SceneMemberRequestBus::EventResult(sceneId, GetEntityId(), &SceneMemberRequests::GetScene);
GraphModelRequestBus::Event(sceneId, &GraphModelRequests::RemoveWrapperDropTarget, GetEntityId());
}
void WrapperNodeLayoutComponent::OnActionWidgetClicked(const QPointF& scenePoint, const QPoint& screenPoint) const
{
AZ::EntityId sceneId;
SceneMemberRequestBus::EventResult(sceneId, GetEntityId(), &SceneMemberRequests::GetScene);
SceneUIRequestBus::Event(sceneId, &SceneUIRequests::OnWrapperNodeActionWidgetClicked, GetEntityId(), m_wrapperNodeActionWidget->boundingRect().toRect(), scenePoint, screenPoint);
}
void WrapperNodeLayoutComponent::ClearLayout()
{
if (m_layout)
{
for (int i=m_layout->count() - 1; i >= 0; --i)
{
m_layout->removeAt(i);
}
}
}
void WrapperNodeLayoutComponent::CreateLayout()
{
ClearLayout();
if (m_title == nullptr)
{
NodeTitleRequestBus::EventResult(m_title, GetEntityId(), &NodeTitleRequests::GetGraphicsWidget);
}
if (m_slots == nullptr)
{
NodeSlotsRequestBus::EventResult(m_slots, GetEntityId(), &NodeSlotsRequests::GetGraphicsLayoutItem);
}
if (m_title)
{
GetLayoutAs<QGraphicsLinearLayout>()->addItem(m_title);
}
if (m_slots)
{
GetLayoutAs<QGraphicsLinearLayout>()->addItem(m_slots);
}
GetLayoutAs<QGraphicsLinearLayout>()->addItem(m_wrappedNodeLayout);
GetLayoutAs<QGraphicsLinearLayout>()->addItem(m_wrapperNodeActionWidget);
}
void WrapperNodeLayoutComponent::UpdateLayout()
{
m_wrappedNodeLayout->RefreshLayout();
RefreshDisplay();
}
void WrapperNodeLayoutComponent::RefreshDisplay()
{
m_layout->invalidate();
m_layout->updateGeometry();
}
} |
; Trim Trailing Characters (Trim.asm)
; Test the Trim procedure. Trim removes trailing all
; occurrences of a selected character from the end of
; a string.
INCLUDE Irvine32.inc
Str_trim PROTO,
pString:PTR BYTE, ; points to string
char:BYTE ; character to remove
Str_length PROTO,
pString:PTR BYTE ; pointer to string
ShowString PROTO,
pString:PTR BYTE
.data
; Test data:
string_1 BYTE 0 ; case 1
string_2 BYTE "#",0 ; case 2
string_3 BYTE "Hello###",0 ; case 3
string_4 BYTE "Hello",0 ; case 4
string_5 BYTE "H#",0 ; case 5
string_6 BYTE "#H",0 ; case 6
.code
main PROC
call Clrscr
INVOKE Str_trim,ADDR string_1,'#'
INVOKE ShowString,ADDR string_1
INVOKE Str_trim,ADDR string_2,'#'
INVOKE ShowString,ADDR string_2
INVOKE Str_trim,ADDR string_3,'#'
INVOKE ShowString,ADDR string_3
INVOKE Str_trim,ADDR string_4,'#'
INVOKE ShowString,ADDR string_4
INVOKE Str_trim,ADDR string_5,'#'
INVOKE ShowString,ADDR string_5
INVOKE Str_trim,ADDR string_6,'#'
INVOKE ShowString,ADDR string_6
exit
main ENDP
;-----------------------------------------------------------
ShowString PROC USES edx, pString:PTR BYTE
; Display a string surrounded by brackets.
;-----------------------------------------------------------
.data
lbracket BYTE "[",0
rbracket BYTE "]",0
.code
mov edx,OFFSET lbracket
call WriteString
mov edx,pString
call WriteString
mov edx,OFFSET rbracket
call WriteString
call Crlf
ret
ShowString ENDP
END main |
; A031380: a(n) = prime(6*n - 2).
; 7,29,53,79,107,139,173,199,239,271,311,349,383,421,457,491,541,577,613,647,683,733,769,821,857,887,941,983,1021,1061,1097,1151,1193,1231,1283,1307,1373,1429,1459,1493,1549,1583,1619,1667,1721,1759,1811,1871,1907,1973,2003,2053,2089,2137,2203,2243,2287,2339,2377,2411,2459,2531,2579,2633,2677,2707,2741,2791,2837,2887,2939,2999,3041,3089,3167,3209,3257,3313,3347,3391,3461,3511,3541,3583,3631,3677,3727,3779,3833,3881,3923,3989,4021,4079,4129,4177,4231,4271,4337,4391
mul $0,3
add $0,1
mul $0,2
seq $0,98090 ; Numbers k such that 2k-3 is prime.
sub $0,5
mul $0,2
add $0,7
|
; A167238: Number of ways to partition a 2*n X 2 grid into 4 connected equal-area regions
; 1,5,11,25,45,77,119,177,249,341,451,585,741,925,1135,1377,1649,1957,2299,2681,3101,3565,4071,4625,5225,5877,6579,7337,8149,9021,9951,10945,12001,13125,14315,15577
add $0,1
mov $1,$0
pow $1,3
add $1,$0
add $1,$0
div $1,6
mul $1,2
add $1,1
|
; Z88 Small C+ Run Time Library
; Long support functions
; "8080" mode
; Stefano - 30/4/2002
;
SECTION code_crt0_sccz80
PUBLIC l_long_cmp
EXTERN __retloc
EXTERN __retloc2
; Signed compare of dehl (stack) and dehl (registers)
;
; Entry: primary = (under two return addresses on stack)
; secondary= dehl
;
; Exit: z = numbers the same
; nz = numbers different
; c/nc = sign of difference [set if secondary > primary]
; hl = 1
;
; Code takes secondary from primary
.l_long_cmp
ex (sp),hl
ld (__retloc),hl ;first return
pop bc ;low word
pop hl ;second return value
ld (__retloc2),hl
ld hl,0
add hl,sp ;points to hl on stack
ld a,(hl)
sub c
ld c,a
inc hl
ld a,(hl)
sbc a,b
ld b,a
inc hl
ld a,(hl)
sbc a,e
ld e,a
inc hl
ld a,(hl)
sbc a,d
ld d,a
inc hl
ld sp,hl
; ATP we have done the comparision and are left with dehl = result of
; primary - secondary, if we have a carry then secondary > primary
rla ;Test sign
jp nc,l_long_cmp1
; Negative number
ld a,c
or b
or d
or e
scf
jp retloc
; Secondary was larger, return c
.l_long_cmp1
ld a,c
or b
or d
or e
scf
ccf
.retloc
; We need to preserve flags
ld hl,(__retloc2)
push hl
ld hl,(__retloc)
push hl
ld hl,1 ; Saves some mem in comparision unfunctions
ret
|
.386
.model flat,C
include dpmi32.inc
PUBLIC RmCallStruc
.data?
__WDOSXRmRegs RmCallStruc <>
end
|
;*****************************************************************************
;* x86-optimized Float DSP functions
;*
;* Copyright 2006 Loren Merritt
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* FFmpeg is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with FFmpeg; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;******************************************************************************
%include "x86util.asm"
SECTION .text
;-----------------------------------------------------------------------------
; void vector_fmul(float *dst, const float *src0, const float *src1, int len)
;-----------------------------------------------------------------------------
%macro VECTOR_FMUL 0
cglobal vector_fmul, 4,4,2, dst, src0, src1, len
lea lenq, [lend*4 - 2*mmsize]
ALIGN 16
.loop:
mova m0, [src0q + lenq]
mova m1, [src0q + lenq + mmsize]
mulps m0, m0, [src1q + lenq]
mulps m1, m1, [src1q + lenq + mmsize]
mova [dstq + lenq], m0
mova [dstq + lenq + mmsize], m1
sub lenq, 2*mmsize
jge .loop
REP_RET
%endmacro
INIT_XMM sse
VECTOR_FMUL
%if HAVE_AVX_EXTERNAL
INIT_YMM avx
VECTOR_FMUL
%endif
;------------------------------------------------------------------------------
; void ff_vector_fmac_scalar(float *dst, const float *src, float mul, int len)
;------------------------------------------------------------------------------
%macro VECTOR_FMAC_SCALAR 0
%if UNIX64
cglobal vector_fmac_scalar, 3,3,3, dst, src, len
%else
cglobal vector_fmac_scalar, 4,4,3, dst, src, mul, len
%endif
%if ARCH_X86_32
VBROADCASTSS m0, mulm
%else
%if WIN64
mova xmm0, xmm2
%endif
shufps xmm0, xmm0, 0
%if cpuflag(avx)
vinsertf128 m0, m0, xmm0, 1
%endif
%endif
lea lenq, [lend*4-2*mmsize]
.loop:
mulps m1, m0, [srcq+lenq ]
mulps m2, m0, [srcq+lenq+mmsize]
addps m1, m1, [dstq+lenq ]
addps m2, m2, [dstq+lenq+mmsize]
mova [dstq+lenq ], m1
mova [dstq+lenq+mmsize], m2
sub lenq, 2*mmsize
jge .loop
REP_RET
%endmacro
INIT_XMM sse
VECTOR_FMAC_SCALAR
%if HAVE_AVX_EXTERNAL
INIT_YMM avx
VECTOR_FMAC_SCALAR
%endif
;------------------------------------------------------------------------------
; void ff_vector_fmul_scalar(float *dst, const float *src, float mul, int len)
;------------------------------------------------------------------------------
%macro VECTOR_FMUL_SCALAR 0
%if UNIX64
cglobal vector_fmul_scalar, 3,3,2, dst, src, len
%else
cglobal vector_fmul_scalar, 4,4,3, dst, src, mul, len
%endif
%if ARCH_X86_32
movss m0, mulm
%elif WIN64
SWAP 0, 2
%endif
shufps m0, m0, 0
lea lenq, [lend*4-mmsize]
.loop:
mova m1, [srcq+lenq]
mulps m1, m0
mova [dstq+lenq], m1
sub lenq, mmsize
jge .loop
REP_RET
%endmacro
INIT_XMM sse
VECTOR_FMUL_SCALAR
;------------------------------------------------------------------------------
; void ff_vector_dmul_scalar(double *dst, const double *src, double mul,
; int len)
;------------------------------------------------------------------------------
%macro VECTOR_DMUL_SCALAR 0
%if ARCH_X86_32
cglobal vector_dmul_scalar, 3,4,3, dst, src, mul, len, lenaddr
mov lenq, lenaddrm
%elif UNIX64
cglobal vector_dmul_scalar, 3,3,3, dst, src, len
%else
cglobal vector_dmul_scalar, 4,4,3, dst, src, mul, len
%endif
%if ARCH_X86_32
VBROADCASTSD m0, mulm
%else
%if WIN64
movlhps xmm2, xmm2
%if cpuflag(avx)
vinsertf128 ymm2, ymm2, xmm2, 1
%endif
SWAP 0, 2
%else
movlhps xmm0, xmm0
%if cpuflag(avx)
vinsertf128 ymm0, ymm0, xmm0, 1
%endif
%endif
%endif
lea lenq, [lend*8-2*mmsize]
.loop:
mulpd m1, m0, [srcq+lenq ]
mulpd m2, m0, [srcq+lenq+mmsize]
mova [dstq+lenq ], m1
mova [dstq+lenq+mmsize], m2
sub lenq, 2*mmsize
jge .loop
REP_RET
%endmacro
INIT_XMM sse2
VECTOR_DMUL_SCALAR
%if HAVE_AVX_EXTERNAL
INIT_YMM avx
VECTOR_DMUL_SCALAR
%endif
|
#include "maindialog.h"
#include "ui_maindialog.h"
#include "constant.h"
#include "clientmanager.h"
#include <QWebSocketServer>
#include <QWebSocket>
#include <QCloseEvent>
#include <QMessageBox>
#include <QSystemTrayIcon>
#include <QDebug>
#include "pdf.h"
#include <QPrinter>
#include <QPrinterInfo>
#include <QPainter>
MainDialog::MainDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::MainDialog),
mServer(new QWebSocketServer("Pulas Server", QWebSocketServer::NonSecureMode, this)),
mClientManager(new ClientManager(this)),
mTray(new QSystemTrayIcon(this))
{
ui->setupUi(this);
connect(mServer, SIGNAL(newConnection()), SLOT(newConnection()));
//directly run the server
if (runServer())
ui->labelInfo->setText("is running ...");
else
ui->labelInfo->setText("is failed to run!!!");
setWindowTitle("Pulas - Javascript direct printing");
connect(ui->pushAboutQt, SIGNAL(clicked(bool)), SLOT(aboutQtClicked()));
connect(ui->pushQuit, SIGNAL(clicked(bool)), SLOT(quitClicked()));
mTray->setIcon(QIcon(":/images/icon.png"));
connect(mTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
QPixmap px(":/images/icon.png");
ui->image->setPixmap(px.scaledToHeight(150));
ui->labelVersion->setText("Version " + QApplication::applicationVersion());
}
MainDialog::~MainDialog()
{
delete ui;
}
void MainDialog::closeEvent(QCloseEvent *event)
{
this->hide();
mTray->show();
event->ignore();
}
void MainDialog::showTray()
{
mTray->show();
}
bool MainDialog::runServer()
{
return mServer->listen(QHostAddress::Any, SERVER::port);
}
void MainDialog::newConnection()
{
QWebSocket *sock = mServer->nextPendingConnection();
while(sock) {
mClientManager->addNewClient(sock);
sock = mServer->nextPendingConnection();
}
}
void MainDialog::aboutQtClicked()
{
QMessageBox::aboutQt(this);
}
void MainDialog::quitClicked()
{
qApp->exit();
}
void MainDialog::trayActivated(QSystemTrayIcon::ActivationReason reason)
{
Q_UNUSED(reason)
this->show();
}
|
#include "controller.h"
#include "../Common/named-var-set.h"
#include "worlds/world.h"
#include "config.h"
#include "parameters-numeric.h"
#include "app.h"
#include "experiment.h"
#include <algorithm>
#include <math.h>
vector<double>& Controller::evaluate(const State* s, const Action* a)
{
for (unsigned int output = 0; output < getNumOutputs(); ++output)
{
//we have to saturate the output of evaluate()
NamedVarProperties* pProperties = a->getProperties(getOutputAction(output));
m_output[output] = std::min(pProperties->getMax(), std::max(pProperties->getMin(), evaluate(s, a, output)));
}
return m_output;
}
double Controller::selectAction(const State *s, Action *a)
{
for (unsigned int output = 0; output < getNumOutputs(); ++output)
{
a->set( getOutputAction(output), evaluate(s, a, output));
}
return 1.0;
}
std::shared_ptr<Controller> Controller::getInstance(ConfigNode* pConfigNode)
{
return CHOICE<Controller>(pConfigNode, "Controller", "The specific controller to be used",
{
{"PID",CHOICE_ELEMENT_NEW<PIDController>},
{"LQR",CHOICE_ELEMENT_NEW<LQRController>},
{"Jonkman",CHOICE_ELEMENT_NEW<WindTurbineJonkmanController>},
{"Vidal",CHOICE_ELEMENT_NEW<WindTurbineVidalController>},
{"Boukhezzar",CHOICE_ELEMENT_NEW<WindTurbineBoukhezzarController>},
});
}
//LQR//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
LQRGain::LQRGain(ConfigNode* pConfigNode)
{
m_variable = STATE_VARIABLE(pConfigNode, "Variable", "The input state variable");
m_gain = DOUBLE_PARAM(pConfigNode, "Gain", "The gain applied to the input state variable", 0.1);
}
LQRController::LQRController(ConfigNode* pConfigNode)
{
m_outputAction = ACTION_VARIABLE(pConfigNode, "Output-Action", "The output action");
m_gains = MULTI_VALUE<LQRGain>(pConfigNode, "LQR-Gain", "An LQR gain on an input state variable");
for (size_t i = 0; i < m_gains.size(); ++i)
m_inputStateVariables.push_back( m_gains[i]->m_variable.get() );
m_output = vector<double> (1);
//SimionApp::get()->registerStateActionFunction("LQR", this);
}
LQRController::~LQRController(){}
double LQRController::evaluate(const State* s, const Action* a, unsigned int index)
{
//ignore index
double output= 0.0;
for (unsigned int i= 0; i<m_gains.size(); i++)
{
output+= s->get(m_gains[i]->m_variable.get())*m_gains[i]->m_gain.get();
}
// delta= -K*x
return -output;
}
unsigned int LQRController::getNumOutputs()
{
return 1;
}
const char* LQRController::getOutputAction(size_t output)
{
if (output == 0)
return m_outputAction.get();
throw std::runtime_error("LQRController. Invalid action output given.");
}
//PID//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
PIDController::PIDController(ConfigNode* pConfigNode)
{
m_outputAction= ACTION_VARIABLE(pConfigNode, "Output-Action", "The output action");
m_pKP = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "KP", "Proportional gain");
m_pKI = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "KI", "Integral gain");
m_pKD = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "KD", "Derivative gain");
m_errorVariable = STATE_VARIABLE(pConfigNode, "Input-Variable", "The input state variable");
m_intError = 0.0;
m_inputStateVariables.push_back(m_errorVariable.get());
m_output = vector<double>(1);
//SimionApp::get()->registerStateActionFunction("PID", this);
}
PIDController::~PIDController()
{}
unsigned int PIDController::getNumOutputs()
{
return 1;
}
const char* PIDController::getOutputAction(size_t output)
{
if (output == 0)
return m_outputAction.get();
throw std::runtime_error("LQRController. Invalid action output given.");
}
double PIDController::evaluate(const State* s, const Action* a, unsigned int output)
{
if (SimionApp::get()->pWorld->getEpisodeSimTime()== 0.0)
m_intError= 0.0;
double error= s->get(m_errorVariable.get());
double dError = error*SimionApp::get()->pWorld->getDT();
m_intError += error*SimionApp::get()->pWorld->getDT();
return error * m_pKP->get() + m_intError * m_pKI->get() + dError * m_pKD->get();
}
//VIDAL////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
WindTurbineVidalController::~WindTurbineVidalController()
{
}
WindTurbineVidalController::WindTurbineVidalController(ConfigNode* pConfigNode)
{
m_pA= CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "A", "A parameter of the torque controller", new ConstantValue(1.0));
m_pK_alpha = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "K_alpha", "K_alpha parameter of the torque controller", new ConstantValue(5000000));
m_pKP = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "KP", "Proportional gain of the pitch controller", new ConstantValue(1.0));
m_pKI = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "KI", "Integral gain of the pitch controller", new ConstantValue(0.0));
m_ratedPower = World::getDynamicModel()->getConstant("RatedPower")
/ World::getDynamicModel()->getConstant("ElectricalGeneratorEfficiency");
m_genElecEff = World::getDynamicModel()->getConstant("ElectricalGeneratorEfficiency");
m_inputStateVariables.push_back("omega_g");
m_inputStateVariables.push_back("E_p");
m_inputStateVariables.push_back("T_g");
m_output = vector<double>(2);
//SimionApp::get()->registerStateActionFunction("Vidal", this);
}
unsigned int WindTurbineVidalController::getNumOutputs()
{
return 2;
}
const char* WindTurbineVidalController::getOutputAction(size_t output)
{
switch (output)
{
case 0: return "beta";
case 1: return "T_g";
}
throw std::runtime_error("LQRController. Invalid action output given.");
}
//aux function used in WindTurbineVidal controller
double WindTurbineVidalController::sgn(double value)
{
if (value<0.0) return -1.0;
else if (value>0.0) return 1.0;
return 0.0;
}
double WindTurbineVidalController::evaluate(const State* s, const Action* a, unsigned int output)
{
//initialise m_lastT_g if we have to, controllers don't implement reset()
if (SimionApp::get() && SimionApp::get()->pWorld->getEpisodeSimTime() == 0)
m_lastT_g = 0.0;
//d(Tg)/dt= (-1/omega_g)*(T_g*(a*omega_g-d_omega_g)-a*P_setpoint + K_alpha*sgn(P_a-P_setpoint))
//beta= K_p*(omega_ref - omega_g) + K_i*(error_integral)
double omega_g = s->get("omega_g");
double d_omega_g = s->get("d_omega_g");
double error_P= s->get("E_p");
double e_omega_g, beta, d_T_g;
switch (output)
{
case 0:
e_omega_g = omega_g - World::getDynamicModel()->getConstant("RatedGeneratorSpeed");
beta = 0.5*m_pKP->get()*e_omega_g*(1.0 + sgn(e_omega_g))
+ m_pKI->get()*s->get("E_int_omega_g");
beta = std::min(a->getProperties("beta")->getMax(), std::max(beta, a->getProperties("beta")->getMin()));
return beta;
case 1:
if (omega_g != 0.0) d_T_g = (-1 / (omega_g*m_genElecEff))*(m_lastT_g*m_genElecEff*(m_pA->get() *omega_g + d_omega_g)
- m_pA->get()*m_ratedPower + m_pK_alpha->get()*sgn(error_P));
else d_T_g = 0.0;
d_T_g = std::min(std::max(s->getProperties("d_T_g")->getMin(), d_T_g), s->getProperties("d_T_g")->getMax());
double nextT_g = m_lastT_g + d_T_g * SimionApp::get()->pWorld->getDT();
m_lastT_g = nextT_g;
return nextT_g;
}
return 0.0;
}
//BOUKHEZZAR CONTROLLER////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
WindTurbineBoukhezzarController::~WindTurbineBoukhezzarController()
{
}
WindTurbineBoukhezzarController::WindTurbineBoukhezzarController(ConfigNode* pConfigNode)
{
m_pC_0 = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode,"C_0", "C_0 parameter", new ConstantValue(1.0) );
m_pKP = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode,"KP", "Proportional gain of the pitch controller", new ConstantValue(1.0) );
m_pKI = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode,"KI", "Integral gain of the pitch controller", new ConstantValue(0.0) );
m_J_t = World::getDynamicModel()->getConstant("TotalTurbineInertia");
m_K_t = World::getDynamicModel()->getConstant("TotalTurbineTorsionalDamping");
m_genElecEff = World::getDynamicModel()->getConstant("ElectricalGeneratorEfficiency");
m_inputStateVariables.push_back("omega_g");
m_inputStateVariables.push_back("E_p");
m_inputStateVariables.push_back("T_g");
m_output = vector<double>(2);
//SimionApp::get()->registerStateActionFunction("Boukhezzar", this);
}
unsigned int WindTurbineBoukhezzarController::getNumOutputs()
{
return 2;
}
const char* WindTurbineBoukhezzarController::getOutputAction(size_t output)
{
switch (output)
{
case 0: return "beta";
case 1: return "T_g";
}
throw std::runtime_error("LQRController. Invalid action output given.");
}
double WindTurbineBoukhezzarController::evaluate(const State *s,const Action *a, unsigned int output)
{
//initialise m_lastT_g if we have to, controllers don't implement reset()
if (SimionApp::get()->pWorld->getEpisodeSimTime() == 0)
m_lastT_g = 0.0;// SimionApp::get()->pWorld->getDynamicModel()->getConstant("RatedGeneratorTorque");
//d(Tg)/dt= (1/omega_g)*(C_0*error_P - (1/J_t)*(T_a*T_g - K_t*omega_g*T_g - T_g*T_g))
//d(beta)/dt= K_p*(omega_ref - omega_g)
//Original expression in Boukhezzar's paper:
//double d_T_g= (1.0/omega_g)*(m_pC_0.get()*error_P - (T_a*m_lastT_g - m_K_t*omega_g*m_lastT_g
// - m_lastT_g *m_lastT_g) / m_J_t );
double omega_g= s->get("omega_g");
double d_omega_g = s->get("d_omega_g");
//Boukhezzar controller without making substitution: d_T_g= (-1/omega_g)(d_omega_g*T_g+C_0*Ep)
double d_T_g = (-1.0/(omega_g*m_genElecEff))*(d_omega_g*m_lastT_g*m_genElecEff + m_pC_0->get()*s->get("E_p"));
d_T_g = std::min(std::max(s->getProperties("d_T_g")->getMin(), d_T_g), s->getProperties("d_T_g")->getMax());
double e_omega_g = omega_g - World::getDynamicModel()->getConstant("RatedGeneratorSpeed");
double desiredBeta = m_pKP->get()*e_omega_g + m_pKI->get()*s->get("E_int_omega_g");
switch (output)
{
case 0:
return desiredBeta;
case 1:
double nextT_g = m_lastT_g + d_T_g * SimionApp::get()->pWorld->getDT();
m_lastT_g = nextT_g;
return nextT_g;
}
return 0.0;
}
//JONKMAN//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
WindTurbineJonkmanController::~WindTurbineJonkmanController()
{
}
WindTurbineJonkmanController::WindTurbineJonkmanController(ConfigNode* pConfigNode)
{
//GENERATOR SPEED FILTER PARAMETERS
m_CornerFreq = DOUBLE_PARAM(pConfigNode, "CornerFreq", "Corner Freq. parameter", 1.570796);
//TORQUE CONTROLLER'S PARAMETERS
DynamicModel* pDynamicModel = SimionApp::get()->pWorld->getDynamicModel();
m_ratedGenSpeed = pDynamicModel->getConstant("RatedGeneratorSpeed");
m_ratedPower = pDynamicModel->getConstant("RatedPower")/pDynamicModel->getConstant("ElectricalGeneratorEfficiency");
m_VS_SlPc = DOUBLE_PARAM(pConfigNode, "VS_SlPc", "SIPc parameter", 10.0);
m_VS_Rgn2K = DOUBLE_PARAM(pConfigNode, "VS_Rgn2K", "Rgn2K parameter", 2.332287);
m_VS_Rgn2Sp = DOUBLE_PARAM(pConfigNode, "VS_Rgn2Sp", "Rgn2Sp parameter", 91.21091);
m_VS_CtInSp = DOUBLE_PARAM(pConfigNode, "VS_CtInSp", "CtlnSp parameter", 70.16224);
m_VS_Rgn3MP = DOUBLE_PARAM(pConfigNode, "VS_Rgn3MP", "Rgn3MP parameter", 0.01745329);
m_VS_SySp = m_ratedGenSpeed/( 1.0 + 0.01*m_VS_SlPc.get() );
m_VS_Slope15 = ( m_VS_Rgn2K.get()*m_VS_Rgn2Sp.get()*m_VS_Rgn2Sp.get() )/( m_VS_Rgn2Sp.get() - m_VS_CtInSp.get());
m_VS_Slope25 = ( m_ratedPower/m_ratedGenSpeed)/( m_ratedGenSpeed - m_VS_SySp);
if ( m_VS_Rgn2K.get()== 0.0 ) //.TRUE. if the Region 2 torque is flat, and thus, the denominator in the ELSE condition is zero
m_VS_TrGnSp = m_VS_SySp;
else //.TRUE. if the Region 2 torque is quadratic with speed
m_VS_TrGnSp = ( m_VS_Slope25 - sqrt( m_VS_Slope25*( m_VS_Slope25 - 4.0*m_VS_Rgn2K.get()*m_VS_SySp ) ) )/( 2.0*m_VS_Rgn2K.get() );
//PITCH CONTROLLER'S PARAMETERS
m_PC_KK = CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode,"PC_KK","Pitch angle were the the derivative of the...", new ConstantValue(0.1099965));
m_PC_KP= CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "PC_KP","Proportional gain of the pitch controller", new ConstantValue(0.01882681));
m_PC_KI= CHILD_OBJECT_FACTORY<NumericValue>(pConfigNode, "PC_KI","Integral gain of the pitch controller", new ConstantValue(0.008068634) );
m_PC_RefSpd= DOUBLE_PARAM(pConfigNode,"PC_RefSpd","Pitch control reference speed", 122.9096);
m_IntSpdErr= 0.0;
m_inputStateVariables.push_back("omega_g");
m_inputStateVariables.push_back("T_g");
m_inputStateVariables.push_back("beta");
m_output = vector<double>(2);
//SimionApp::get()->registerStateActionFunction("Jonkman", this);
}
unsigned int WindTurbineJonkmanController::getNumOutputs()
{
return 2;
}
const char* WindTurbineJonkmanController::getOutputAction(size_t output)
{
switch (output)
{
case 1: return "beta";
case 0: return "T_g";
}
throw std::runtime_error("LQRController. Invalid action output given.");
}
double WindTurbineJonkmanController::evaluate(const State *s,const Action *a, unsigned int output)
{
switch (output)
{
case 0:
//Filter the generator speed
double lowPassFilterAlpha, d_T_g;
if (SimionApp::get()->pWorld->getEpisodeSimTime() == 0.0)
{
m_lastT_g = 0.0;
lowPassFilterAlpha = 1.0;
m_GenSpeedF = s->get("omega_g");
m_IntSpdErr = 0.0;
}
else
lowPassFilterAlpha = exp(-SimionApp::get()->pWorld->getDT()*m_CornerFreq.get());
m_GenSpeedF = (1.0 - lowPassFilterAlpha)*s->get("omega_g") + lowPassFilterAlpha * m_GenSpeedF;
//TORQUE CONTROLLER
double DesiredGenTrq;
if ((m_GenSpeedF >= m_ratedGenSpeed) || (s->get("beta") >= m_VS_Rgn3MP.get())) //We are in region 3 - power is constant
DesiredGenTrq = m_ratedPower / m_GenSpeedF;
else if (m_GenSpeedF <= m_VS_CtInSp.get()) //We are in region 1 - torque is zero
DesiredGenTrq = 0.0;
else if (m_GenSpeedF < m_VS_Rgn2Sp.get()) //We are in region 1 1/2 - linear ramp in torque from zero to optimal
DesiredGenTrq = m_VS_Slope15 * (m_GenSpeedF - m_VS_CtInSp.get());
else if (m_GenSpeedF < m_VS_TrGnSp) //We are in region 2 - optimal torque is proportional to the square of the generator speed
DesiredGenTrq = m_VS_Rgn2K.get()*m_GenSpeedF*m_GenSpeedF;
else //We are in region 2 1/2 - simple induction generator transition region
DesiredGenTrq = m_VS_Slope25 * (m_GenSpeedF - m_VS_SySp);
DesiredGenTrq = std::min(DesiredGenTrq, s->getProperties("T_g")->getMax()); //Saturate the command using the maximum torque limit
//we limit the torque change rate
d_T_g = (DesiredGenTrq - m_lastT_g) / SimionApp::get()->pWorld->getDT();
d_T_g = std::min(std::max(s->getProperties("d_T_g")->getMin(), d_T_g), s->getProperties("d_T_g")->getMax());
m_lastT_g = m_lastT_g + d_T_g * SimionApp::get()->pWorld->getDT();
return m_lastT_g;
//we pass the desired generator torque instead of the rate
//return DesiredGenTrq;
case 1:
//PITCH CONTROLLER
double GK = 1.0 / (1.0 + s->get("beta") / m_PC_KK->get());
//Compute the current speed error and its integral w.r.t. time; saturate the
// integral term using the pitch angle limits:
double SpdErr = m_GenSpeedF - m_PC_RefSpd.get(); //Current speed error
m_IntSpdErr = m_IntSpdErr + SpdErr * SimionApp::get()->pWorld->getDT(); //Current integral of speed error w.r.t. time
//Saturate the integral term using the pitch angle limits, converted to integral speed error limits
m_IntSpdErr = std::min(std::max(m_IntSpdErr, s->getProperties("beta")->getMin() / (GK*m_PC_KI->get()))
, s->getProperties("beta")->getMax() / (GK*m_PC_KI->get()));
//Compute the pitch commands associated with the proportional and integral gains:
double PitComP = GK * m_PC_KP->get() * SpdErr; //Proportional term
double PitComI = GK * m_PC_KI->get() * m_IntSpdErr; //Integral term (saturated)
//Superimpose the individual commands to getSample the total pitch command;
// saturate the overall command using the pitch angle limits:
double PitComT = PitComP + PitComI; //Overall command (unsaturated)
PitComT = std::min(std::max(PitComT, s->getProperties("beta")->getMin())
, s->getProperties("beta")->getMax()); //Saturate the overall command using the pitch angle limits
//we pass the desired blade pitch angle to the world
return PitComT;
}
return 0.0;
} |
\ ******************************************************************************
\
\ DISC ELITE SHIP BLUEPRINTS FILE K
\
\ Elite was written by Ian Bell and David Braben and is copyright Acornsoft 1984
\
\ The code on this site has been disassembled from the version released on Ian
\ Bell's personal website at http://www.elitehomepage.org/
\
\ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes
\ in the documentation are entirely my fault
\
\ The terminology and notations used in this commentary are explained at
\ https://www.bbcelite.com/about_site/terminology_used_in_this_commentary.html
\
\ The deep dive articles referred to in this commentary can be found at
\ https://www.bbcelite.com/deep_dives
\
\ ------------------------------------------------------------------------------
\
\ This source file produces the following binary file:
\
\ * D.MOK.bin
\
\ ******************************************************************************
INCLUDE "1-source-files/main-sources/elite-header.h.asm"
GUARD &6000 \ Guard against assembling over screen memory
\ ******************************************************************************
\
\ Configuration variables
\
\ ******************************************************************************
SHIP_MISSILE = &7F00 \ The address of the missile ship blueprint
CODE% = &5600 \ The flight code loads this file at address &5600, at
LOAD% = &5600 \ label XX21
ORG CODE%
\ ******************************************************************************
\
\ Name: XX21
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprints lookup table for the D.MOK file
\ Deep dive: Ship blueprints in the disc version
\
\ ******************************************************************************
.XX21
EQUW SHIP_MISSILE \ MSL = 1 = Missile
EQUW SHIP_CORIOLIS \ SST = 2 = Coriolis space station
EQUW SHIP_ESCAPE_POD \ ESC = 3 = Escape pod
EQUW 0
EQUW SHIP_CANISTER \ OIL = 5 = Cargo canister
EQUW 0
EQUW SHIP_ASTEROID \ AST = 7 = Asteroid
EQUW SHIP_SPLINTER \ SPL = 8 = Splinter
EQUW 0
EQUW 0
EQUW SHIP_COBRA_MK_3 \ CYL = 11 = Cobra Mk III
EQUW SHIP_PYTHON \ 12 = Python
EQUW 0
EQUW 0
EQUW 0
EQUW SHIP_VIPER \ COPS = 16 = Viper
EQUW SHIP_SIDEWINDER \ SH3 = 17 = Sidewinder
EQUW 0
EQUW 0
EQUW 0
EQUW SHIP_GECKO \ 21 = Gecko
EQUW SHIP_COBRA_MK_1 \ 22 = Cobra Mk I
EQUW 0
EQUW 0
EQUW 0
EQUW 0
EQUW 0
EQUW SHIP_MORAY \ 28 = Moray
EQUW 0
EQUW 0
EQUW 0
\ ******************************************************************************
\
\ Name: E%
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprints default NEWB flags for the D.MOK file
\ Deep dive: Ship blueprints in the disc version
\ Advanced tactics with the NEWB flags
\
\ ******************************************************************************
.E%
EQUB %00000000 \ Missile
EQUB %00000000 \ Coriolis space station
EQUB %00000001 \ Escape pod Trader
EQUB 0
EQUB %00000000 \ Cargo canister
EQUB 0
EQUB %00000000 \ Asteroid
EQUB %00000000 \ Splinter
EQUB 0
EQUB 0
EQUB %10100000 \ Cobra Mk III Innocent, escape pod
EQUB %10100000 \ Python Innocent, escape pod
EQUB 0
EQUB 0
EQUB 0
EQUB %11000010 \ Viper Bounty hunter, cop, escape pod
EQUB %00001100 \ Sidewinder Hostile, pirate
EQUB 0
EQUB 0
EQUB 0
EQUB %00001100 \ Gecko Hostile, pirate
EQUB %10001100 \ Cobra Mk I Hostile, pirate, escape pod
EQUB 0
EQUB 0
EQUB 0
EQUB 0
EQUB 0
EQUB %00001100 \ Moray Hostile, pirate
EQUB 0
EQUB 0
EQUB 0
\ ******************************************************************************
\
\ Name: VERTEX
\ Type: Macro
\ Category: Drawing ships
\ Summary: Macro definition for adding vertices to ship blueprints
\ Deep dive: Ship blueprints
\
\ ------------------------------------------------------------------------------
\
\ The following macro is used to build the ship blueprints:
\
\ VERTEX x, y, z, face1, face2, face3, face4, visibility
\
\ See the deep dive on "Ship blueprints" for details of how vertices are stored
\ in the ship blueprints, and the deep dive on "Drawing ships" for information
\ on how vertices are used to draw 3D wiremesh ships.
\
\ Arguments:
\
\ x The vertex's x-coordinate
\
\ y The vertex's y-coordinate
\
\ z The vertex's z-coordinate
\
\ face1 The number of face 1 associated with this vertex
\
\ face2 The number of face 2 associated with this vertex
\
\ face3 The number of face 3 associated with this vertex
\
\ face4 The number of face 4 associated with this vertex
\
\ visibility The visibility distance, beyond which the vertex is not
\ shown
\
\ ******************************************************************************
MACRO VERTEX x, y, z, face1, face2, face3, face4, visibility
IF x < 0
s_x = 1 << 7
ELSE
s_x = 0
ENDIF
IF y < 0
s_y = 1 << 6
ELSE
s_y = 0
ENDIF
IF z < 0
s_z = 1 << 5
ELSE
s_z = 0
ENDIF
s = s_x + s_y + s_z + visibility
f1 = face1 + (face2 << 4)
f2 = face3 + (face4 << 4)
ax = ABS(x)
ay = ABS(y)
az = ABS(z)
EQUB ax, ay, az, s, f1, f2
ENDMACRO
\ ******************************************************************************
\
\ Name: EDGE
\ Type: Macro
\ Category: Drawing ships
\ Summary: Macro definition for adding edges to ship blueprints
\ Deep dive: Ship blueprints
\
\ ------------------------------------------------------------------------------
\
\ The following macro is used to build the ship blueprints:
\
\ EDGE vertex1, vertex2, face1, face2, visibility
\
\ See the deep dive on "Ship blueprints" for details of how edges are stored
\ in the ship blueprints, and the deep dive on "Drawing ships" for information
\ on how edges are used to draw 3D wiremesh ships.
\
\ Arguments:
\
\ vertex1 The number of the vertex at the start of the edge
\
\ vertex1 The number of the vertex at the end of the edge
\
\ face1 The number of face 1 associated with this edge
\
\ face2 The number of face 2 associated with this edge
\
\ visibility The visibility distance, beyond which the edge is not
\ shown
\
\ ******************************************************************************
MACRO EDGE vertex1, vertex2, face1, face2, visibility
f = face1 + (face2 << 4)
EQUB visibility, f, vertex1 << 2, vertex2 << 2
ENDMACRO
\ ******************************************************************************
\
\ Name: FACE
\ Type: Macro
\ Category: Drawing ships
\ Summary: Macro definition for adding faces to ship blueprints
\ Deep dive: Ship blueprints
\
\ ------------------------------------------------------------------------------
\
\ The following macro is used to build the ship blueprints:
\
\ FACE normal_x, normal_y, normal_z, visibility
\
\ See the deep dive on "Ship blueprints" for details of how faces are stored
\ in the ship blueprints, and the deep dive on "Drawing ships" for information
\ on how faces are used to draw 3D wiremesh ships.
\
\ Arguments:
\
\ normal_x The face normal's x-coordinate
\
\ normal_y The face normal's y-coordinate
\
\ normal_z The face normal's z-coordinate
\
\ visibility The visibility distance, beyond which the edge is always
\ shown
\
\ ******************************************************************************
MACRO FACE normal_x, normal_y, normal_z, visibility
IF normal_x < 0
s_x = 1 << 7
ELSE
s_x = 0
ENDIF
IF normal_y < 0
s_y = 1 << 6
ELSE
s_y = 0
ENDIF
IF normal_z < 0
s_z = 1 << 5
ELSE
s_z = 0
ENDIF
s = s_x + s_y + s_z + visibility
ax = ABS(normal_x)
ay = ABS(normal_y)
az = ABS(normal_z)
EQUB s, ax, ay, az
ENDMACRO
\ ******************************************************************************
\
\ Name: SHIP_CORIOLIS
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a Coriolis space station
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_CORIOLIS
EQUB 0 \ Max. canisters on demise = 0
EQUW 160 * 160 \ Targetable area = 160 * 160
EQUB LO(SHIP_CORIOLIS_EDGES - SHIP_CORIOLIS) \ Edges data offset (low)
EQUB LO(SHIP_CORIOLIS_FACES - SHIP_CORIOLIS) \ Faces data offset (low)
EQUB 85 \ Max. edge count = (85 - 1) / 4 = 21
EQUB 0 \ Gun vertex = 0
EQUB 54 \ Explosion count = 12, as (4 * n) + 6 = 54
EQUB 96 \ Number of vertices = 96 / 6 = 16
EQUB 28 \ Number of edges = 28
EQUW 0 \ Bounty = 0
EQUB 56 \ Number of faces = 56 / 4 = 14
EQUB 120 \ Visibility distance = 120
EQUB 240 \ Max. energy = 240
EQUB 0 \ Max. speed = 0
EQUB HI(SHIP_CORIOLIS_EDGES - SHIP_CORIOLIS) \ Edges data offset (high)
EQUB HI(SHIP_CORIOLIS_FACES - SHIP_CORIOLIS) \ Faces data offset (high)
EQUB 0 \ Normals are scaled by = 2^0 = 1
EQUB %00000110 \ Laser power = 0
\ Missiles = 6
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX 160, 0, 160, 0, 1, 2, 6, 31 \ Vertex 0
VERTEX 0, 160, 160, 0, 2, 3, 8, 31 \ Vertex 1
VERTEX -160, 0, 160, 0, 3, 4, 7, 31 \ Vertex 2
VERTEX 0, -160, 160, 0, 1, 4, 5, 31 \ Vertex 3
VERTEX 160, -160, 0, 1, 5, 6, 10, 31 \ Vertex 4
VERTEX 160, 160, 0, 2, 6, 8, 11, 31 \ Vertex 5
VERTEX -160, 160, 0, 3, 7, 8, 12, 31 \ Vertex 6
VERTEX -160, -160, 0, 4, 5, 7, 9, 31 \ Vertex 7
VERTEX 160, 0, -160, 6, 10, 11, 13, 31 \ Vertex 8
VERTEX 0, 160, -160, 8, 11, 12, 13, 31 \ Vertex 9
VERTEX -160, 0, -160, 7, 9, 12, 13, 31 \ Vertex 10
VERTEX 0, -160, -160, 5, 9, 10, 13, 31 \ Vertex 11
VERTEX 10, -30, 160, 0, 0, 0, 0, 30 \ Vertex 12
VERTEX 10, 30, 160, 0, 0, 0, 0, 30 \ Vertex 13
VERTEX -10, 30, 160, 0, 0, 0, 0, 30 \ Vertex 14
VERTEX -10, -30, 160, 0, 0, 0, 0, 30 \ Vertex 15
.SHIP_CORIOLIS_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 3, 0, 1, 31 \ Edge 0
EDGE 0, 1, 0, 2, 31 \ Edge 1
EDGE 1, 2, 0, 3, 31 \ Edge 2
EDGE 2, 3, 0, 4, 31 \ Edge 3
EDGE 3, 4, 1, 5, 31 \ Edge 4
EDGE 0, 4, 1, 6, 31 \ Edge 5
EDGE 0, 5, 2, 6, 31 \ Edge 6
EDGE 5, 1, 2, 8, 31 \ Edge 7
EDGE 1, 6, 3, 8, 31 \ Edge 8
EDGE 2, 6, 3, 7, 31 \ Edge 9
EDGE 2, 7, 4, 7, 31 \ Edge 10
EDGE 3, 7, 4, 5, 31 \ Edge 11
EDGE 8, 11, 10, 13, 31 \ Edge 12
EDGE 8, 9, 11, 13, 31 \ Edge 13
EDGE 9, 10, 12, 13, 31 \ Edge 14
EDGE 10, 11, 9, 13, 31 \ Edge 15
EDGE 4, 11, 5, 10, 31 \ Edge 16
EDGE 4, 8, 6, 10, 31 \ Edge 17
EDGE 5, 8, 6, 11, 31 \ Edge 18
EDGE 5, 9, 8, 11, 31 \ Edge 19
EDGE 6, 9, 8, 12, 31 \ Edge 20
EDGE 6, 10, 7, 12, 31 \ Edge 21
EDGE 7, 10, 7, 9, 31 \ Edge 22
EDGE 7, 11, 5, 9, 31 \ Edge 23
EDGE 12, 13, 0, 0, 30 \ Edge 24
EDGE 13, 14, 0, 0, 30 \ Edge 25
EDGE 14, 15, 0, 0, 30 \ Edge 26
EDGE 15, 12, 0, 0, 30 \ Edge 27
.SHIP_CORIOLIS_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 0, 0, 160, 31 \ Face 0
FACE 107, -107, 107, 31 \ Face 1
FACE 107, 107, 107, 31 \ Face 2
FACE -107, 107, 107, 31 \ Face 3
FACE -107, -107, 107, 31 \ Face 4
FACE 0, -160, 0, 31 \ Face 5
FACE 160, 0, 0, 31 \ Face 6
FACE -160, 0, 0, 31 \ Face 7
FACE 0, 160, 0, 31 \ Face 8
FACE -107, -107, -107, 31 \ Face 9
FACE 107, -107, -107, 31 \ Face 10
FACE 107, 107, -107, 31 \ Face 11
FACE -107, 107, -107, 31 \ Face 12
FACE 0, 0, -160, 31 \ Face 13
\ ******************************************************************************
\
\ Name: SHIP_ESCAPE_POD
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for an escape pod
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_ESCAPE_POD
EQUB 0 + (2 << 4) \ Max. canisters on demise = 0
\ Market item when scooped = 2 + 1 = 3 (slaves)
EQUW 16 * 16 \ Targetable area = 16 * 16
EQUB LO(SHIP_ESCAPE_POD_EDGES - SHIP_ESCAPE_POD) \ Edges data offset (low)
EQUB LO(SHIP_ESCAPE_POD_FACES - SHIP_ESCAPE_POD) \ Faces data offset (low)
EQUB 25 \ Max. edge count = (25 - 1) / 4 = 6
EQUB 0 \ Gun vertex = 0
EQUB 22 \ Explosion count = 4, as (4 * n) + 6 = 22
EQUB 24 \ Number of vertices = 24 / 6 = 4
EQUB 6 \ Number of edges = 6
EQUW 0 \ Bounty = 0
EQUB 16 \ Number of faces = 16 / 4 = 4
EQUB 8 \ Visibility distance = 8
EQUB 17 \ Max. energy = 17
EQUB 8 \ Max. speed = 8
EQUB HI(SHIP_ESCAPE_POD_EDGES - SHIP_ESCAPE_POD) \ Edges data offset (high)
EQUB HI(SHIP_ESCAPE_POD_FACES - SHIP_ESCAPE_POD) \ Faces data offset (high)
EQUB 4 \ Normals are scaled by = 2^4 = 16
EQUB %00000000 \ Laser power = 0
\ Missiles = 0
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX -7, 0, 36, 2, 1, 3, 3, 31 \ Vertex 0
VERTEX -7, -14, -12, 2, 0, 3, 3, 31 \ Vertex 1
VERTEX -7, 14, -12, 1, 0, 3, 3, 31 \ Vertex 2
VERTEX 21, 0, 0, 1, 0, 2, 2, 31 \ Vertex 3
.SHIP_ESCAPE_POD_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 1, 3, 2, 31 \ Edge 0
EDGE 1, 2, 3, 0, 31 \ Edge 1
EDGE 2, 3, 1, 0, 31 \ Edge 2
EDGE 3, 0, 2, 1, 31 \ Edge 3
EDGE 0, 2, 3, 1, 31 \ Edge 4
EDGE 3, 1, 2, 0, 31 \ Edge 5
.SHIP_ESCAPE_POD_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 52, 0, -122, 31 \ Face 0
FACE 39, 103, 30, 31 \ Face 1
FACE 39, -103, 30, 31 \ Face 2
FACE -112, 0, 0, 31 \ Face 3
\ ******************************************************************************
\
\ Name: SHIP_CANISTER
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a cargo canister
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_CANISTER
EQUB 0 \ Max. canisters on demise = 0
EQUW 20 * 20 \ Targetable area = 20 * 20
EQUB LO(SHIP_CANISTER_EDGES - SHIP_CANISTER) \ Edges data offset (low)
EQUB LO(SHIP_CANISTER_FACES - SHIP_CANISTER) \ Faces data offset (low)
EQUB 49 \ Max. edge count = (49 - 1) / 4 = 12
EQUB 0 \ Gun vertex = 0
EQUB 18 \ Explosion count = 3, as (4 * n) + 6 = 18
EQUB 60 \ Number of vertices = 60 / 6 = 10
EQUB 15 \ Number of edges = 15
EQUW 0 \ Bounty = 0
EQUB 28 \ Number of faces = 28 / 4 = 7
EQUB 12 \ Visibility distance = 12
EQUB 17 \ Max. energy = 17
EQUB 15 \ Max. speed = 15
EQUB HI(SHIP_CANISTER_EDGES - SHIP_CANISTER) \ Edges data offset (high)
EQUB HI(SHIP_CANISTER_FACES - SHIP_CANISTER) \ Faces data offset (high)
EQUB 2 \ Normals are scaled by = 2^2 = 4
EQUB %00000000 \ Laser power = 0
\ Missiles = 0
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX 24, 16, 0, 0, 1, 5, 5, 31 \ Vertex 0
VERTEX 24, 5, 15, 0, 1, 2, 2, 31 \ Vertex 1
VERTEX 24, -13, 9, 0, 2, 3, 3, 31 \ Vertex 2
VERTEX 24, -13, -9, 0, 3, 4, 4, 31 \ Vertex 3
VERTEX 24, 5, -15, 0, 4, 5, 5, 31 \ Vertex 4
VERTEX -24, 16, 0, 1, 5, 6, 6, 31 \ Vertex 5
VERTEX -24, 5, 15, 1, 2, 6, 6, 31 \ Vertex 6
VERTEX -24, -13, 9, 2, 3, 6, 6, 31 \ Vertex 7
VERTEX -24, -13, -9, 3, 4, 6, 6, 31 \ Vertex 8
VERTEX -24, 5, -15, 4, 5, 6, 6, 31 \ Vertex 9
.SHIP_CANISTER_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 1, 0, 1, 31 \ Edge 0
EDGE 1, 2, 0, 2, 31 \ Edge 1
EDGE 2, 3, 0, 3, 31 \ Edge 2
EDGE 3, 4, 0, 4, 31 \ Edge 3
EDGE 0, 4, 0, 5, 31 \ Edge 4
EDGE 0, 5, 1, 5, 31 \ Edge 5
EDGE 1, 6, 1, 2, 31 \ Edge 6
EDGE 2, 7, 2, 3, 31 \ Edge 7
EDGE 3, 8, 3, 4, 31 \ Edge 8
EDGE 4, 9, 4, 5, 31 \ Edge 9
EDGE 5, 6, 1, 6, 31 \ Edge 10
EDGE 6, 7, 2, 6, 31 \ Edge 11
EDGE 7, 8, 3, 6, 31 \ Edge 12
EDGE 8, 9, 4, 6, 31 \ Edge 13
EDGE 9, 5, 5, 6, 31 \ Edge 14
.SHIP_CANISTER_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 96, 0, 0, 31 \ Face 0
FACE 0, 41, 30, 31 \ Face 1
FACE 0, -18, 48, 31 \ Face 2
FACE 0, -51, 0, 31 \ Face 3
FACE 0, -18, -48, 31 \ Face 4
FACE 0, 41, -30, 31 \ Face 5
FACE -96, 0, 0, 31 \ Face 6
\ ******************************************************************************
\
\ Name: SHIP_ASTEROID
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for an asteroid
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_ASTEROID
EQUB 0 \ Max. canisters on demise = 0
EQUW 80 * 80 \ Targetable area = 80 * 80
EQUB LO(SHIP_ASTEROID_EDGES - SHIP_ASTEROID) \ Edges data offset (low)
EQUB LO(SHIP_ASTEROID_FACES - SHIP_ASTEROID) \ Faces data offset (low)
EQUB 65 \ Max. edge count = (65 - 1) / 4 = 16
EQUB 0 \ Gun vertex = 0
EQUB 34 \ Explosion count = 7, as (4 * n) + 6 = 34
EQUB 54 \ Number of vertices = 54 / 6 = 9
EQUB 21 \ Number of edges = 21
EQUW 5 \ Bounty = 5
EQUB 56 \ Number of faces = 56 / 4 = 14
EQUB 50 \ Visibility distance = 50
EQUB 60 \ Max. energy = 60
EQUB 30 \ Max. speed = 30
EQUB HI(SHIP_ASTEROID_EDGES - SHIP_ASTEROID) \ Edges data offset (high)
EQUB HI(SHIP_ASTEROID_FACES - SHIP_ASTEROID) \ Faces data offset (high)
EQUB 1 \ Normals are scaled by = 2^1 = 2
EQUB %00000000 \ Laser power = 0
\ Missiles = 0
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX 0, 80, 0, 15, 15, 15, 15, 31 \ Vertex 0
VERTEX -80, -10, 0, 15, 15, 15, 15, 31 \ Vertex 1
VERTEX 0, -80, 0, 15, 15, 15, 15, 31 \ Vertex 2
VERTEX 70, -40, 0, 15, 15, 15, 15, 31 \ Vertex 3
VERTEX 60, 50, 0, 5, 6, 12, 13, 31 \ Vertex 4
VERTEX 50, 0, 60, 15, 15, 15, 15, 31 \ Vertex 5
VERTEX -40, 0, 70, 0, 1, 2, 3, 31 \ Vertex 6
VERTEX 0, 30, -75, 15, 15, 15, 15, 31 \ Vertex 7
VERTEX 0, -50, -60, 8, 9, 10, 11, 31 \ Vertex 8
.SHIP_ASTEROID_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 1, 2, 7, 31 \ Edge 0
EDGE 0, 4, 6, 13, 31 \ Edge 1
EDGE 3, 4, 5, 12, 31 \ Edge 2
EDGE 2, 3, 4, 11, 31 \ Edge 3
EDGE 1, 2, 3, 10, 31 \ Edge 4
EDGE 1, 6, 2, 3, 31 \ Edge 5
EDGE 2, 6, 1, 3, 31 \ Edge 6
EDGE 2, 5, 1, 4, 31 \ Edge 7
EDGE 5, 6, 0, 1, 31 \ Edge 8
EDGE 0, 5, 0, 6, 31 \ Edge 9
EDGE 3, 5, 4, 5, 31 \ Edge 10
EDGE 0, 6, 0, 2, 31 \ Edge 11
EDGE 4, 5, 5, 6, 31 \ Edge 12
EDGE 1, 8, 8, 10, 31 \ Edge 13
EDGE 1, 7, 7, 8, 31 \ Edge 14
EDGE 0, 7, 7, 13, 31 \ Edge 15
EDGE 4, 7, 12, 13, 31 \ Edge 16
EDGE 3, 7, 9, 12, 31 \ Edge 17
EDGE 3, 8, 9, 11, 31 \ Edge 18
EDGE 2, 8, 10, 11, 31 \ Edge 19
EDGE 7, 8, 8, 9, 31 \ Edge 20
.SHIP_ASTEROID_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 9, 66, 81, 31 \ Face 0
FACE 9, -66, 81, 31 \ Face 1
FACE -72, 64, 31, 31 \ Face 2
FACE -64, -73, 47, 31 \ Face 3
FACE 45, -79, 65, 31 \ Face 4
FACE 135, 15, 35, 31 \ Face 5
FACE 38, 76, 70, 31 \ Face 6
FACE -66, 59, -39, 31 \ Face 7
FACE -67, -15, -80, 31 \ Face 8
FACE 66, -14, -75, 31 \ Face 9
FACE -70, -80, -40, 31 \ Face 10
FACE 58, -102, -51, 31 \ Face 11
FACE 81, 9, -67, 31 \ Face 12
FACE 47, 94, -63, 31 \ Face 13
\ ******************************************************************************
\
\ Name: SHIP_SPLINTER
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a splinter
\ Deep dive: Ship blueprints
\
\ ------------------------------------------------------------------------------
\
\ The ship blueprint for the splinter reuses the edges data from the escape pod,
\ so the edges data offset is negative.
\
\ ******************************************************************************
.SHIP_SPLINTER
EQUB 0 + (11 << 4) \ Max. canisters on demise = 0
\ Market item when scooped = 11 + 1 = 12 (Minerals)
EQUW 16 * 16 \ Targetable area = 16 * 16
EQUB LO(SHIP_ESCAPE_POD_EDGES - SHIP_SPLINTER) \ Edges from escape pod
EQUB LO(SHIP_SPLINTER_FACES - SHIP_SPLINTER) + 24 \ Faces data offset (low)
EQUB 25 \ Max. edge count = (25 - 1) / 4 = 6
EQUB 0 \ Gun vertex = 0
EQUB 22 \ Explosion count = 4, as (4 * n) + 6 = 22
EQUB 24 \ Number of vertices = 24 / 6 = 4
EQUB 6 \ Number of edges = 6
EQUW 0 \ Bounty = 0
EQUB 16 \ Number of faces = 16 / 4 = 4
EQUB 8 \ Visibility distance = 8
EQUB 20 \ Max. energy = 20
EQUB 10 \ Max. speed = 10
EQUB HI(SHIP_ESCAPE_POD_EDGES - SHIP_SPLINTER) \ Edges from escape pod
EQUB HI(SHIP_SPLINTER_FACES - SHIP_SPLINTER) \ Faces data offset (low)
EQUB 5 \ Normals are scaled by = 2^5 = 32
EQUB %00000000 \ Laser power = 0
\ Missiles = 0
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX -24, -25, 16, 2, 1, 3, 3, 31 \ Vertex 0
VERTEX 0, 12, -10, 2, 0, 3, 3, 31 \ Vertex 1
VERTEX 11, -6, 2, 1, 0, 3, 3, 31 \ Vertex 2
VERTEX 12, 42, 7, 1, 0, 2, 2, 31 \ Vertex 3
.SHIP_SPLINTER_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 35, 0, 4, 31 \ Face 0
FACE 3, 4, 8, 31 \ Face 1
FACE 1, 8, 12, 31 \ Face 2
FACE 18, 12, 0, 31 \ Face 3
\ ******************************************************************************
\
\ Name: SHIP_COBRA_MK_3
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a Cobra Mk III
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_COBRA_MK_3
EQUB 3 \ Max. canisters on demise = 3
EQUW 95 * 95 \ Targetable area = 95 * 95
EQUB LO(SHIP_COBRA_MK_3_EDGES - SHIP_COBRA_MK_3) \ Edges data offset (low)
EQUB LO(SHIP_COBRA_MK_3_FACES - SHIP_COBRA_MK_3) \ Faces data offset (low)
EQUB 153 \ Max. edge count = (153 - 1) / 4 = 38
EQUB 84 \ Gun vertex = 84 / 4 = 21
EQUB 42 \ Explosion count = 9, as (4 * n) + 6 = 42
EQUB 168 \ Number of vertices = 168 / 6 = 28
EQUB 38 \ Number of edges = 38
EQUW 0 \ Bounty = 0
EQUB 52 \ Number of faces = 52 / 4 = 13
EQUB 50 \ Visibility distance = 50
EQUB 150 \ Max. energy = 150
EQUB 28 \ Max. speed = 28
EQUB HI(SHIP_COBRA_MK_3_EDGES - SHIP_COBRA_MK_3) \ Edges data offset (low)
EQUB HI(SHIP_COBRA_MK_3_FACES - SHIP_COBRA_MK_3) \ Faces data offset (low)
EQUB 1 \ Normals are scaled by = 2^1 = 2
EQUB %00010011 \ Laser power = 2
\ Missiles = 3
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX 32, 0, 76, 15, 15, 15, 15, 31 \ Vertex 0
VERTEX -32, 0, 76, 15, 15, 15, 15, 31 \ Vertex 1
VERTEX 0, 26, 24, 15, 15, 15, 15, 31 \ Vertex 2
VERTEX -120, -3, -8, 3, 7, 10, 10, 31 \ Vertex 3
VERTEX 120, -3, -8, 4, 8, 12, 12, 31 \ Vertex 4
VERTEX -88, 16, -40, 15, 15, 15, 15, 31 \ Vertex 5
VERTEX 88, 16, -40, 15, 15, 15, 15, 31 \ Vertex 6
VERTEX 128, -8, -40, 8, 9, 12, 12, 31 \ Vertex 7
VERTEX -128, -8, -40, 7, 9, 10, 10, 31 \ Vertex 8
VERTEX 0, 26, -40, 5, 6, 9, 9, 31 \ Vertex 9
VERTEX -32, -24, -40, 9, 10, 11, 11, 31 \ Vertex 10
VERTEX 32, -24, -40, 9, 11, 12, 12, 31 \ Vertex 11
VERTEX -36, 8, -40, 9, 9, 9, 9, 20 \ Vertex 12
VERTEX -8, 12, -40, 9, 9, 9, 9, 20 \ Vertex 13
VERTEX 8, 12, -40, 9, 9, 9, 9, 20 \ Vertex 14
VERTEX 36, 8, -40, 9, 9, 9, 9, 20 \ Vertex 15
VERTEX 36, -12, -40, 9, 9, 9, 9, 20 \ Vertex 16
VERTEX 8, -16, -40, 9, 9, 9, 9, 20 \ Vertex 17
VERTEX -8, -16, -40, 9, 9, 9, 9, 20 \ Vertex 18
VERTEX -36, -12, -40, 9, 9, 9, 9, 20 \ Vertex 19
VERTEX 0, 0, 76, 0, 11, 11, 11, 6 \ Vertex 20
VERTEX 0, 0, 90, 0, 11, 11, 11, 31 \ Vertex 21
VERTEX -80, -6, -40, 9, 9, 9, 9, 8 \ Vertex 22
VERTEX -80, 6, -40, 9, 9, 9, 9, 8 \ Vertex 23
VERTEX -88, 0, -40, 9, 9, 9, 9, 6 \ Vertex 24
VERTEX 80, 6, -40, 9, 9, 9, 9, 8 \ Vertex 25
VERTEX 88, 0, -40, 9, 9, 9, 9, 6 \ Vertex 26
VERTEX 80, -6, -40, 9, 9, 9, 9, 8 \ Vertex 27
.SHIP_COBRA_MK_3_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 1, 0, 11, 31 \ Edge 0
EDGE 0, 4, 4, 12, 31 \ Edge 1
EDGE 1, 3, 3, 10, 31 \ Edge 2
EDGE 3, 8, 7, 10, 31 \ Edge 3
EDGE 4, 7, 8, 12, 31 \ Edge 4
EDGE 6, 7, 8, 9, 31 \ Edge 5
EDGE 6, 9, 6, 9, 31 \ Edge 6
EDGE 5, 9, 5, 9, 31 \ Edge 7
EDGE 5, 8, 7, 9, 31 \ Edge 8
EDGE 2, 5, 1, 5, 31 \ Edge 9
EDGE 2, 6, 2, 6, 31 \ Edge 10
EDGE 3, 5, 3, 7, 31 \ Edge 11
EDGE 4, 6, 4, 8, 31 \ Edge 12
EDGE 1, 2, 0, 1, 31 \ Edge 13
EDGE 0, 2, 0, 2, 31 \ Edge 14
EDGE 8, 10, 9, 10, 31 \ Edge 15
EDGE 10, 11, 9, 11, 31 \ Edge 16
EDGE 7, 11, 9, 12, 31 \ Edge 17
EDGE 1, 10, 10, 11, 31 \ Edge 18
EDGE 0, 11, 11, 12, 31 \ Edge 19
EDGE 1, 5, 1, 3, 29 \ Edge 20
EDGE 0, 6, 2, 4, 29 \ Edge 21
EDGE 20, 21, 0, 11, 6 \ Edge 22
EDGE 12, 13, 9, 9, 20 \ Edge 23
EDGE 18, 19, 9, 9, 20 \ Edge 24
EDGE 14, 15, 9, 9, 20 \ Edge 25
EDGE 16, 17, 9, 9, 20 \ Edge 26
EDGE 15, 16, 9, 9, 19 \ Edge 27
EDGE 14, 17, 9, 9, 17 \ Edge 28
EDGE 13, 18, 9, 9, 19 \ Edge 29
EDGE 12, 19, 9, 9, 19 \ Edge 30
EDGE 2, 9, 5, 6, 30 \ Edge 31
EDGE 22, 24, 9, 9, 6 \ Edge 32
EDGE 23, 24, 9, 9, 6 \ Edge 33
EDGE 22, 23, 9, 9, 8 \ Edge 34
EDGE 25, 26, 9, 9, 6 \ Edge 35
EDGE 26, 27, 9, 9, 6 \ Edge 36
EDGE 25, 27, 9, 9, 8 \ Edge 37
.SHIP_COBRA_MK_3_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 0, 62, 31, 31 \ Face 0
FACE -18, 55, 16, 31 \ Face 1
FACE 18, 55, 16, 31 \ Face 2
FACE -16, 52, 14, 31 \ Face 3
FACE 16, 52, 14, 31 \ Face 4
FACE -14, 47, 0, 31 \ Face 5
FACE 14, 47, 0, 31 \ Face 6
FACE -61, 102, 0, 31 \ Face 7
FACE 61, 102, 0, 31 \ Face 8
FACE 0, 0, -80, 31 \ Face 9
FACE -7, -42, 9, 31 \ Face 10
FACE 0, -30, 6, 31 \ Face 11
FACE 7, -42, 9, 31 \ Face 12
\ ******************************************************************************
\
\ Name: SHIP_PYTHON
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a Python
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_PYTHON
EQUB 5 \ Max. canisters on demise = 5
EQUW 80 * 80 \ Targetable area = 80 * 80
EQUB LO(SHIP_PYTHON_EDGES - SHIP_PYTHON) \ Edges data offset (low)
EQUB LO(SHIP_PYTHON_FACES - SHIP_PYTHON) \ Faces data offset (low)
EQUB 85 \ Max. edge count = (85 - 1) / 4 = 21
EQUB 0 \ Gun vertex = 0
EQUB 42 \ Explosion count = 9, as (4 * n) + 6 = 42
EQUB 66 \ Number of vertices = 66 / 6 = 11
EQUB 26 \ Number of edges = 26
EQUW 0 \ Bounty = 0
EQUB 52 \ Number of faces = 52 / 4 = 13
EQUB 40 \ Visibility distance = 40
EQUB 250 \ Max. energy = 250
EQUB 20 \ Max. speed = 20
EQUB HI(SHIP_PYTHON_EDGES - SHIP_PYTHON) \ Edges data offset (high)
EQUB HI(SHIP_PYTHON_FACES - SHIP_PYTHON) \ Faces data offset (high)
EQUB 0 \ Normals are scaled by = 2^0 = 1
EQUB %00011011 \ Laser power = 3
\ Missiles = 3
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX 0, 0, 224, 0, 1, 2, 3, 31 \ Vertex 0
VERTEX 0, 48, 48, 0, 1, 4, 5, 31 \ Vertex 1
VERTEX 96, 0, -16, 15, 15, 15, 15, 31 \ Vertex 2
VERTEX -96, 0, -16, 15, 15, 15, 15, 31 \ Vertex 3
VERTEX 0, 48, -32, 4, 5, 8, 9, 31 \ Vertex 4
VERTEX 0, 24, -112, 9, 8, 12, 12, 31 \ Vertex 5
VERTEX -48, 0, -112, 8, 11, 12, 12, 31 \ Vertex 6
VERTEX 48, 0, -112, 9, 10, 12, 12, 31 \ Vertex 7
VERTEX 0, -48, 48, 2, 3, 6, 7, 31 \ Vertex 8
VERTEX 0, -48, -32, 6, 7, 10, 11, 31 \ Vertex 9
VERTEX 0, -24, -112, 10, 11, 12, 12, 31 \ Vertex 10
.SHIP_PYTHON_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 8, 2, 3, 31 \ Edge 0
EDGE 0, 3, 0, 2, 31 \ Edge 1
EDGE 0, 2, 1, 3, 31 \ Edge 2
EDGE 0, 1, 0, 1, 31 \ Edge 3
EDGE 2, 4, 9, 5, 31 \ Edge 4
EDGE 1, 2, 1, 5, 31 \ Edge 5
EDGE 2, 8, 7, 3, 31 \ Edge 6
EDGE 1, 3, 0, 4, 31 \ Edge 7
EDGE 3, 8, 2, 6, 31 \ Edge 8
EDGE 2, 9, 7, 10, 31 \ Edge 9
EDGE 3, 4, 4, 8, 31 \ Edge 10
EDGE 3, 9, 6, 11, 31 \ Edge 11
EDGE 3, 5, 8, 8, 7 \ Edge 12
EDGE 3, 10, 11, 11, 7 \ Edge 13
EDGE 2, 5, 9, 9, 7 \ Edge 14
EDGE 2, 10, 10, 10, 7 \ Edge 15
EDGE 2, 7, 9, 10, 31 \ Edge 16
EDGE 3, 6, 8, 11, 31 \ Edge 17
EDGE 5, 6, 8, 12, 31 \ Edge 18
EDGE 5, 7, 9, 12, 31 \ Edge 19
EDGE 7, 10, 12, 10, 31 \ Edge 20
EDGE 6, 10, 11, 12, 31 \ Edge 21
EDGE 4, 5, 8, 9, 31 \ Edge 22
EDGE 9, 10, 10, 11, 31 \ Edge 23
EDGE 1, 4, 4, 5, 31 \ Edge 24
EDGE 8, 9, 6, 7, 31 \ Edge 25
.SHIP_PYTHON_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE -27, 40, 11, 31 \ Face 0
FACE 27, 40, 11, 31 \ Face 1
FACE -27, -40, 11, 31 \ Face 2
FACE 27, -40, 11, 31 \ Face 3
FACE -19, 38, 0, 31 \ Face 4
FACE 19, 38, 0, 31 \ Face 5
FACE -19, -38, 0, 31 \ Face 6
FACE 19, -38, 0, 31 \ Face 7
FACE -25, 37, -11, 31 \ Face 8
FACE 25, 37, -11, 31 \ Face 9
FACE 25, -37, -11, 31 \ Face 10
FACE -25, -37, -11, 31 \ Face 11
FACE 0, 0, -112, 31 \ Face 12
\ ******************************************************************************
\
\ Name: SHIP_VIPER
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a Viper
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_VIPER
EQUB 0 \ Max. canisters on demise = 0
EQUW 75 * 75 \ Targetable area = 75 * 75
EQUB LO(SHIP_VIPER_EDGES - SHIP_VIPER) \ Edges data offset (low)
EQUB LO(SHIP_VIPER_FACES - SHIP_VIPER) \ Faces data offset (low)
EQUB 77 \ Max. edge count = (77 - 1) / 4 = 19
EQUB 0 \ Gun vertex = 0
EQUB 42 \ Explosion count = 9, as (4 * n) + 6 = 42
EQUB 90 \ Number of vertices = 90 / 6 = 15
EQUB 20 \ Number of edges = 20
EQUW 0 \ Bounty = 0
EQUB 28 \ Number of faces = 28 / 4 = 7
EQUB 23 \ Visibility distance = 23
EQUB 100 \ Max. energy = 100
EQUB 32 \ Max. speed = 32
EQUB HI(SHIP_VIPER_EDGES - SHIP_VIPER) \ Edges data offset (high)
EQUB HI(SHIP_VIPER_FACES - SHIP_VIPER) \ Faces data offset (high)
EQUB 1 \ Normals are scaled by = 2^1 = 2
EQUB %00010001 \ Laser power = 2
\ Missiles = 1
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX 0, 0, 72, 1, 2, 3, 4, 31 \ Vertex 0
VERTEX 0, 16, 24, 0, 1, 2, 2, 30 \ Vertex 1
VERTEX 0, -16, 24, 3, 4, 5, 5, 30 \ Vertex 2
VERTEX 48, 0, -24, 2, 4, 6, 6, 31 \ Vertex 3
VERTEX -48, 0, -24, 1, 3, 6, 6, 31 \ Vertex 4
VERTEX 24, -16, -24, 4, 5, 6, 6, 30 \ Vertex 5
VERTEX -24, -16, -24, 5, 3, 6, 6, 30 \ Vertex 6
VERTEX 24, 16, -24, 0, 2, 6, 6, 31 \ Vertex 7
VERTEX -24, 16, -24, 0, 1, 6, 6, 31 \ Vertex 8
VERTEX -32, 0, -24, 6, 6, 6, 6, 19 \ Vertex 9
VERTEX 32, 0, -24, 6, 6, 6, 6, 19 \ Vertex 10
VERTEX 8, 8, -24, 6, 6, 6, 6, 19 \ Vertex 11
VERTEX -8, 8, -24, 6, 6, 6, 6, 19 \ Vertex 12
VERTEX -8, -8, -24, 6, 6, 6, 6, 18 \ Vertex 13
VERTEX 8, -8, -24, 6, 6, 6, 6, 18 \ Vertex 14
.SHIP_VIPER_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 3, 2, 4, 31 \ Edge 0
EDGE 0, 1, 1, 2, 30 \ Edge 1
EDGE 0, 2, 3, 4, 30 \ Edge 2
EDGE 0, 4, 1, 3, 31 \ Edge 3
EDGE 1, 7, 0, 2, 30 \ Edge 4
EDGE 1, 8, 0, 1, 30 \ Edge 5
EDGE 2, 5, 4, 5, 30 \ Edge 6
EDGE 2, 6, 3, 5, 30 \ Edge 7
EDGE 7, 8, 0, 6, 31 \ Edge 8
EDGE 5, 6, 5, 6, 30 \ Edge 9
EDGE 4, 8, 1, 6, 31 \ Edge 10
EDGE 4, 6, 3, 6, 30 \ Edge 11
EDGE 3, 7, 2, 6, 31 \ Edge 12
EDGE 3, 5, 6, 4, 30 \ Edge 13
EDGE 9, 12, 6, 6, 19 \ Edge 14
EDGE 9, 13, 6, 6, 18 \ Edge 15
EDGE 10, 11, 6, 6, 19 \ Edge 16
EDGE 10, 14, 6, 6, 18 \ Edge 17
EDGE 11, 14, 6, 6, 16 \ Edge 18
EDGE 12, 13, 6, 6, 16 \ Edge 19
.SHIP_VIPER_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 0, 32, 0, 31 \ Face 0
FACE -22, 33, 11, 31 \ Face 1
FACE 22, 33, 11, 31 \ Face 2
FACE -22, -33, 11, 31 \ Face 3
FACE 22, -33, 11, 31 \ Face 4
FACE 0, -32, 0, 31 \ Face 5
FACE 0, 0, -48, 31 \ Face 6
\ ******************************************************************************
\
\ Name: SHIP_SIDEWINDER
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a Sidewinder
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_SIDEWINDER
EQUB 0 \ Max. canisters on demise = 0
EQUW 65 * 65 \ Targetable area = 65 * 65
EQUB LO(SHIP_SIDEWINDER_EDGES - SHIP_SIDEWINDER) \ Edges data offset (low)
EQUB LO(SHIP_SIDEWINDER_FACES - SHIP_SIDEWINDER) \ Faces data offset (low)
EQUB 61 \ Max. edge count = (61 - 1) / 4 = 15
EQUB 0 \ Gun vertex = 0
EQUB 30 \ Explosion count = 6, as (4 * n) + 6 = 30
EQUB 60 \ Number of vertices = 60 / 6 = 10
EQUB 15 \ Number of edges = 15
EQUW 50 \ Bounty = 50
EQUB 28 \ Number of faces = 28 / 4 = 7
EQUB 20 \ Visibility distance = 20
EQUB 70 \ Max. energy = 70
EQUB 37 \ Max. speed = 37
EQUB HI(SHIP_SIDEWINDER_EDGES - SHIP_SIDEWINDER) \ Edges data offset (high)
EQUB HI(SHIP_SIDEWINDER_FACES - SHIP_SIDEWINDER) \ Faces data offset (high)
EQUB 2 \ Normals are scaled by = 2^2 = 4
EQUB %00010000 \ Laser power = 2
\ Missiles = 0
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX -32, 0, 36, 0, 1, 4, 5, 31 \ Vertex 0
VERTEX 32, 0, 36, 0, 2, 5, 6, 31 \ Vertex 1
VERTEX 64, 0, -28, 2, 3, 6, 6, 31 \ Vertex 2
VERTEX -64, 0, -28, 1, 3, 4, 4, 31 \ Vertex 3
VERTEX 0, 16, -28, 0, 1, 2, 3, 31 \ Vertex 4
VERTEX 0, -16, -28, 3, 4, 5, 6, 31 \ Vertex 5
VERTEX -12, 6, -28, 3, 3, 3, 3, 15 \ Vertex 6
VERTEX 12, 6, -28, 3, 3, 3, 3, 15 \ Vertex 7
VERTEX 12, -6, -28, 3, 3, 3, 3, 12 \ Vertex 8
VERTEX -12, -6, -28, 3, 3, 3, 3, 12 \ Vertex 9
.SHIP_SIDEWINDER_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 1, 0, 5, 31 \ Edge 0
EDGE 1, 2, 2, 6, 31 \ Edge 1
EDGE 1, 4, 0, 2, 31 \ Edge 2
EDGE 0, 4, 0, 1, 31 \ Edge 3
EDGE 0, 3, 1, 4, 31 \ Edge 4
EDGE 3, 4, 1, 3, 31 \ Edge 5
EDGE 2, 4, 2, 3, 31 \ Edge 6
EDGE 3, 5, 3, 4, 31 \ Edge 7
EDGE 2, 5, 3, 6, 31 \ Edge 8
EDGE 1, 5, 5, 6, 31 \ Edge 9
EDGE 0, 5, 4, 5, 31 \ Edge 10
EDGE 6, 7, 3, 3, 15 \ Edge 11
EDGE 7, 8, 3, 3, 12 \ Edge 12
EDGE 6, 9, 3, 3, 12 \ Edge 13
EDGE 8, 9, 3, 3, 12 \ Edge 14
.SHIP_SIDEWINDER_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 0, 32, 8, 31 \ Face 0
FACE -12, 47, 6, 31 \ Face 1
FACE 12, 47, 6, 31 \ Face 2
FACE 0, 0, -112, 31 \ Face 3
FACE -12, -47, 6, 31 \ Face 4
FACE 0, -32, 8, 31 \ Face 5
FACE 12, -47, 6, 31 \ Face 6
\ ******************************************************************************
\
\ Name: SHIP_GECKO
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a Gecko
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_GECKO
EQUB 0 \ Max. canisters on demise = 0
EQUW 99 * 99 \ Targetable area = 99 * 99
EQUB LO(SHIP_GECKO_EDGES - SHIP_GECKO) \ Edges data offset (low)
EQUB LO(SHIP_GECKO_FACES - SHIP_GECKO) \ Faces data offset (low)
EQUB 65 \ Max. edge count = (65 - 1) / 4 = 16
EQUB 0 \ Gun vertex = 0
EQUB 26 \ Explosion count = 5, as (4 * n) + 6 = 26
EQUB 72 \ Number of vertices = 72 / 6 = 12
EQUB 17 \ Number of edges = 17
EQUW 55 \ Bounty = 55
EQUB 36 \ Number of faces = 36 / 4 = 9
EQUB 18 \ Visibility distance = 18
EQUB 70 \ Max. energy = 70
EQUB 30 \ Max. speed = 30
EQUB HI(SHIP_GECKO_EDGES - SHIP_GECKO) \ Edges data offset (high)
EQUB HI(SHIP_GECKO_FACES - SHIP_GECKO) \ Faces data offset (high)
EQUB 3 \ Normals are scaled by = 2^3 = 8
EQUB %00010000 \ Laser power = 2
\ Missiles = 0
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX -10, -4, 47, 3, 0, 5, 4, 31 \ Vertex 0
VERTEX 10, -4, 47, 1, 0, 3, 2, 31 \ Vertex 1
VERTEX -16, 8, -23, 5, 0, 7, 6, 31 \ Vertex 2
VERTEX 16, 8, -23, 1, 0, 8, 7, 31 \ Vertex 3
VERTEX -66, 0, -3, 5, 4, 6, 6, 31 \ Vertex 4
VERTEX 66, 0, -3, 2, 1, 8, 8, 31 \ Vertex 5
VERTEX -20, -14, -23, 4, 3, 7, 6, 31 \ Vertex 6
VERTEX 20, -14, -23, 3, 2, 8, 7, 31 \ Vertex 7
VERTEX -8, -6, 33, 3, 3, 3, 3, 16 \ Vertex 8
VERTEX 8, -6, 33, 3, 3, 3, 3, 17 \ Vertex 9
VERTEX -8, -13, -16, 3, 3, 3, 3, 16 \ Vertex 10
VERTEX 8, -13, -16, 3, 3, 3, 3, 17 \ Vertex 11
.SHIP_GECKO_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 1, 3, 0, 31 \ Edge 0
EDGE 1, 5, 2, 1, 31 \ Edge 1
EDGE 5, 3, 8, 1, 31 \ Edge 2
EDGE 3, 2, 7, 0, 31 \ Edge 3
EDGE 2, 4, 6, 5, 31 \ Edge 4
EDGE 4, 0, 5, 4, 31 \ Edge 5
EDGE 5, 7, 8, 2, 31 \ Edge 6
EDGE 7, 6, 7, 3, 31 \ Edge 7
EDGE 6, 4, 6, 4, 31 \ Edge 8
EDGE 0, 2, 5, 0, 29 \ Edge 9
EDGE 1, 3, 1, 0, 30 \ Edge 10
EDGE 0, 6, 4, 3, 29 \ Edge 11
EDGE 1, 7, 3, 2, 30 \ Edge 12
EDGE 2, 6, 7, 6, 20 \ Edge 13
EDGE 3, 7, 8, 7, 20 \ Edge 14
EDGE 8, 10, 3, 3, 16 \ Edge 15
EDGE 9, 11, 3, 3, 17 \ Edge 16
.SHIP_GECKO_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 0, 31, 5, 31 \ Face 0
FACE 4, 45, 8, 31 \ Face 1
FACE 25, -108, 19, 31 \ Face 2
FACE 0, -84, 12, 31 \ Face 3
FACE -25, -108, 19, 31 \ Face 4
FACE -4, 45, 8, 31 \ Face 5
FACE -88, 16, -214, 31 \ Face 6
FACE 0, 0, -187, 31 \ Face 7
FACE 88, 16, -214, 31 \ Face 8
\ ******************************************************************************
\
\ Name: SHIP_COBRA_MK_1
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a Cobra Mk I
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_COBRA_MK_1
EQUB 3 \ Max. canisters on demise = 3
EQUW 99 * 99 \ Targetable area = 99 * 99
EQUB LO(SHIP_COBRA_MK_1_EDGES - SHIP_COBRA_MK_1) \ Edges data offset (low)
EQUB LO(SHIP_COBRA_MK_1_FACES - SHIP_COBRA_MK_1) \ Faces data offset (low)
EQUB 69 \ Max. edge count = (69 - 1) / 4 = 17
EQUB 40 \ Gun vertex = 40
EQUB 26 \ Explosion count = 5, as (4 * n) + 6 = 26
EQUB 66 \ Number of vertices = 66 / 6 = 11
EQUB 18 \ Number of edges = 18
EQUW 75 \ Bounty = 75
EQUB 40 \ Number of faces = 40 / 4 = 10
EQUB 19 \ Visibility distance = 19
EQUB 90 \ Max. energy = 90
EQUB 26 \ Max. speed = 26
EQUB HI(SHIP_COBRA_MK_1_EDGES - SHIP_COBRA_MK_1) \ Edges data offset (high)
EQUB HI(SHIP_COBRA_MK_1_FACES - SHIP_COBRA_MK_1) \ Faces data offset (high)
EQUB 2 \ Normals are scaled by = 2^2 = 4
EQUB %00010010 \ Laser power = 2
\ Missiles = 2
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX -18, -1, 50, 1, 0, 3, 2, 31 \ Vertex 0
VERTEX 18, -1, 50, 1, 0, 5, 4, 31 \ Vertex 1
VERTEX -66, 0, 7, 3, 2, 8, 8, 31 \ Vertex 2
VERTEX 66, 0, 7, 5, 4, 9, 9, 31 \ Vertex 3
VERTEX -32, 12, -38, 6, 2, 8, 7, 31 \ Vertex 4
VERTEX 32, 12, -38, 6, 4, 9, 7, 31 \ Vertex 5
VERTEX -54, -12, -38, 3, 1, 8, 7, 31 \ Vertex 6
VERTEX 54, -12, -38, 5, 1, 9, 7, 31 \ Vertex 7
VERTEX 0, 12, -6, 2, 0, 6, 4, 20 \ Vertex 8
VERTEX 0, -1, 50, 1, 0, 1, 1, 2 \ Vertex 9
VERTEX 0, -1, 60, 1, 0, 1, 1, 31 \ Vertex 10
.SHIP_COBRA_MK_1_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 1, 0, 1, 0, 31 \ Edge 0
EDGE 0, 2, 3, 2, 31 \ Edge 1
EDGE 2, 6, 8, 3, 31 \ Edge 2
EDGE 6, 7, 7, 1, 31 \ Edge 3
EDGE 7, 3, 9, 5, 31 \ Edge 4
EDGE 3, 1, 5, 4, 31 \ Edge 5
EDGE 2, 4, 8, 2, 31 \ Edge 6
EDGE 4, 5, 7, 6, 31 \ Edge 7
EDGE 5, 3, 9, 4, 31 \ Edge 8
EDGE 0, 8, 2, 0, 20 \ Edge 9
EDGE 8, 1, 4, 0, 20 \ Edge 10
EDGE 4, 8, 6, 2, 16 \ Edge 11
EDGE 8, 5, 6, 4, 16 \ Edge 12
EDGE 4, 6, 8, 7, 31 \ Edge 13
EDGE 5, 7, 9, 7, 31 \ Edge 14
EDGE 0, 6, 3, 1, 20 \ Edge 15
EDGE 1, 7, 5, 1, 20 \ Edge 16
EDGE 10, 9, 1, 0, 2 \ Edge 17
.SHIP_COBRA_MK_1_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 0, 41, 10, 31 \ Face 0
FACE 0, -27, 3, 31 \ Face 1
FACE -8, 46, 8, 31 \ Face 2
FACE -12, -57, 12, 31 \ Face 3
FACE 8, 46, 8, 31 \ Face 4
FACE 12, -57, 12, 31 \ Face 5
FACE 0, 49, 0, 31 \ Face 6
FACE 0, 0, -154, 31 \ Face 7
FACE -121, 111, -62, 31 \ Face 8
FACE 121, 111, -62, 31 \ Face 9
\ ******************************************************************************
\
\ Name: SHIP_MORAY
\ Type: Variable
\ Category: Drawing ships
\ Summary: Ship blueprint for a Moray
\ Deep dive: Ship blueprints
\
\ ******************************************************************************
.SHIP_MORAY
EQUB 1 \ Max. canisters on demise = 1
EQUW 30 * 30 \ Targetable area = 30 * 30
EQUB LO(SHIP_MORAY_EDGES - SHIP_MORAY) \ Edges data offset (low)
EQUB LO(SHIP_MORAY_FACES - SHIP_MORAY) \ Faces data offset (low)
EQUB 69 \ Max. edge count = (69 - 1) / 4 = 17
EQUB 0 \ Gun vertex = 0
EQUB 26 \ Explosion count = 5, as (4 * n) + 6 = 26
EQUB 84 \ Number of vertices = 84 / 6 = 14
EQUB 19 \ Number of edges = 19
EQUW 50 \ Bounty = 50
EQUB 36 \ Number of faces = 36 / 4 = 9
EQUB 40 \ Visibility distance = 40
EQUB 100 \ Max. energy = 100
EQUB 25 \ Max. speed = 25
EQUB HI(SHIP_MORAY_EDGES - SHIP_MORAY) \ Edges data offset (high)
EQUB HI(SHIP_MORAY_FACES - SHIP_MORAY) \ Faces data offset (high)
EQUB 2 \ Normals are scaled by = 2^2 = 4
EQUB %00010000 \ Laser power = 2
\ Missiles = 0
\VERTEX x, y, z, face1, face2, face3, face4, visibility
VERTEX 15, 0, 65, 2, 0, 8, 7, 31 \ Vertex 0
VERTEX -15, 0, 65, 1, 0, 7, 6, 31 \ Vertex 1
VERTEX 0, 18, -40, 15, 15, 15, 15, 17 \ Vertex 2
VERTEX -60, 0, 0, 3, 1, 6, 6, 31 \ Vertex 3
VERTEX 60, 0, 0, 5, 2, 8, 8, 31 \ Vertex 4
VERTEX 30, -27, -10, 5, 4, 8, 7, 24 \ Vertex 5
VERTEX -30, -27, -10, 4, 3, 7, 6, 24 \ Vertex 6
VERTEX -9, -4, -25, 4, 4, 4, 4, 7 \ Vertex 7
VERTEX 9, -4, -25, 4, 4, 4, 4, 7 \ Vertex 8
VERTEX 0, -18, -16, 4, 4, 4, 4, 7 \ Vertex 9
VERTEX 13, 3, 49, 0, 0, 0, 0, 5 \ Vertex 10
VERTEX 6, 0, 65, 0, 0, 0, 0, 5 \ Vertex 11
VERTEX -13, 3, 49, 0, 0, 0, 0, 5 \ Vertex 12
VERTEX -6, 0, 65, 0, 0, 0, 0, 5 \ Vertex 13
.SHIP_MORAY_EDGES
\EDGE vertex1, vertex2, face1, face2, visibility
EDGE 0, 1, 7, 0, 31 \ Edge 0
EDGE 1, 3, 6, 1, 31 \ Edge 1
EDGE 3, 6, 6, 3, 24 \ Edge 2
EDGE 5, 6, 7, 4, 24 \ Edge 3
EDGE 4, 5, 8, 5, 24 \ Edge 4
EDGE 0, 4, 8, 2, 31 \ Edge 5
EDGE 1, 6, 7, 6, 15 \ Edge 6
EDGE 0, 5, 8, 7, 15 \ Edge 7
EDGE 0, 2, 2, 0, 15 \ Edge 8
EDGE 1, 2, 1, 0, 15 \ Edge 9
EDGE 2, 3, 3, 1, 17 \ Edge 10
EDGE 2, 4, 5, 2, 17 \ Edge 11
EDGE 2, 5, 5, 4, 13 \ Edge 12
EDGE 2, 6, 4, 3, 13 \ Edge 13
EDGE 7, 8, 4, 4, 5 \ Edge 14
EDGE 7, 9, 4, 4, 7 \ Edge 15
EDGE 8, 9, 4, 4, 7 \ Edge 16
EDGE 10, 11, 0, 0, 5 \ Edge 17
EDGE 12, 13, 0, 0, 5 \ Edge 18
.SHIP_MORAY_FACES
\FACE normal_x, normal_y, normal_z, visibility
FACE 0, 43, 7, 31 \ Face 0
FACE -10, 49, 7, 31 \ Face 1
FACE 10, 49, 7, 31 \ Face 2
FACE -59, -28, -101, 24 \ Face 3
FACE 0, -52, -78, 24 \ Face 4
FACE 59, -28, -101, 24 \ Face 5
FACE -72, -99, 50, 31 \ Face 6
FACE 0, -83, 30, 31 \ Face 7
FACE 72, -99, 50, 31 \ Face 8
\ ******************************************************************************
\
\ Save D.MOK.bin
\
\ ******************************************************************************
PRINT "S.D.MOK ", ~CODE%, " ", ~P%, " ", ~LOAD%, " ", ~LOAD%
SAVE "3-assembled-output/D.MOK.bin", CODE%, CODE% + &0A00
|
%define BE(a) ( ((((a)>>24)&0xFF) << 0) + ((((a)>>16)&0xFF) << 8) + ((((a)>>8)&0xFF) << 16) + ((((a)>>0)&0xFF) << 24))
ftyp_start:
dd BE(ftyp_end - ftyp_start)
dd "ftyp"
db 0x61, 0x76, 0x69, 0x66 ; "major_brand(32)" ('avif')
db 0x00, 0x00, 0x00, 0x00 ; "minor_version(32)"
db 0x6D, 0x69, 0x66, 0x31 ; "compatible_brand(32)" ('mif1')
db 0x6D, 0x69, 0x61, 0x66 ; "compatible_brand(32)" ('miaf')
ftyp_end:
meta_start:
dd BE(meta_end - meta_start)
dd "meta"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
hdlr_start:
dd BE(hdlr_end - hdlr_start)
dd "hdlr"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x00, 0x00, 0x00 ; "pre_defined(32)"
db 0x70, 0x69, 0x63, 0x74 ; "handler_type(32)" ('pict')
db 0x00, 0x00, 0x00, 0x00 ; "reserved1(32)"
db 0x00, 0x00, 0x00, 0x00 ; "reserved2(32)"
db 0x00, 0x00, 0x00, 0x00 ; "reserved3(32)"
db 0x00 ; "name(8)"
hdlr_end:
pitm_start:
dd BE(pitm_end - pitm_start)
dd "pitm"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x02 ; "item_ID(16)"
pitm_end:
iinf_start:
dd BE(iinf_end - iinf_start)
dd "iinf"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x03 ; "entry_count(16)"
infe_start:
dd BE(infe_end - infe_start)
dd "infe"
db 0x02 ; "version(8)"
db 0x00, 0x00, 0x01 ; "flags(24)"
db 0x00, 0x01 ; "item_ID(16)"
db 0x00, 0x00 ; "item_protection_index(16)"
db 0x61, 0x76, 0x30, 0x31 ; "item_type(32)" ('av01')
db 0x00 ; "item_name(8)"
infe_end:
infe2_start:
dd BE(infe2_end - infe2_start)
dd "infe"
db 0x02 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x02 ; "item_ID(16)"
db 0x00, 0x00 ; "item_protection_index(16)"
db 0x69, 0x64, 0x65, 0x6E ; "item_type(32)" ('iden')
db 0x00 ; "item_name(8)"
infe2_end:
infe3_start:
dd BE(infe3_end - infe3_start)
dd "infe"
db 0x02 ; "version(8)"
db 0x00, 0x00, 0x01 ; "flags(24)"
db 0x00, 0x03 ; "item_ID(16)"
db 0x00, 0x00 ; "item_protection_index(16)"
db 0x61, 0x76, 0x30, 0x31 ; "item_type(32)" ('av01')
db 0x00 ; "item_name(8)"
infe3_end:
iinf_end:
iloc_start:
dd BE(iloc_end - iloc_start)
dd "iloc"
db 0x01 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x44 ; "offset_size(4)" ('D') "length_size(4)" ('D')
db 0x00 ; "base_offset_size(4)" "index_size(4)"
db 0x00, 0x03 ; "item_count(16)"
db 0x00, 0x01 ; "item_ID(16)"
db 0x00, 0x00 ; "reserved2(12)" "construction_method(4)"
db 0x00, 0x00 ; "data_reference_index(16)"
db 0x00, 0x01 ; "extent_count(16)"
dd BE(mdat_start - ftyp_start + 8) ; "extent_offset(32)"
db 0x00, 0x00, 0x00, 0x01 ; "extent_length(32)"
db 0x00, 0x02 ; "item_ID(16)"
db 0x00, 0x00 ; "reserved2(12)" "construction_method(4)"
db 0x00, 0x00 ; "data_reference_index(16)"
db 0x00, 0x01 ; "extent_count(16)"
dd BE(mdat_start - ftyp_start + 8) ; "extent_offset(32)"
db 0x00, 0x00, 0x00, 0x01 ; "extent_length(32)"
db 0x00, 0x03 ; "item_ID(16)"
db 0x00, 0x00 ; "reserved2(12)" "construction_method(4)"
db 0x00, 0x00 ; "data_reference_index(16)"
db 0x00, 0x01 ; "extent_count(16)"
dd BE(mdat_start - ftyp_start + 8) ; "extent_offset(32)"
db 0x00, 0x00, 0x00, 0x01 ; "extent_length(32)"
iloc_end:
iref_start:
dd BE(iref_end - iref_start)
dd "iref"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x00, 0x00, 0x08 ; "box_size(32)"
db 0x64, 0x69, 0x6D, 0x67 ; "box_type(32)" ('dimg')
db 0x00, 0x02 ; "from_item_ID(16)"
db 0x00, 0x01 ; "reference_count(16)"
db 0x00, 0x01 ; "to_item_ID(16)"
iref_end:
iprp_start:
dd BE(iprp_end - iprp_start)
dd "iprp"
ipco_start:
dd BE(ipco_end - ipco_start)
dd "ipco"
ispe_start:
dd BE(ispe_end - ispe_start)
dd "ispe"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x00, 0x00, 0x00 ; "image_width(32)"
db 0x00, 0x00, 0x00, 0x00 ; "image_height(32)"
ispe_end:
pixi_start:
dd BE(pixi_end - pixi_start)
dd "pixi"
pixi_end:
ipco_end:
ipma_start:
dd BE(ipma_end - ipma_start)
dd "ipma"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x00, 0x00, 0x03 ; "entry_count(32)"
db 0x00, 0x01 ; "item_ID(16)"
db 0x01 ; "association_count(8)"
db 0x81 ; "essential(1)" "property_index(7)"
db 0x00, 0x02 ; "item_ID(16)"
db 0x02 ; "association_count(8)"
db 0x81 ; "essential(1)" "property_index(7)"
db 0x82 ; "essential(1)" "property_index(7)"
db 0x00, 0x03 ; "item_ID(16)"
db 0x01 ; "association_count(8)"
db 0x81 ; "essential(1)" "property_index(7)"
ipma_end:
iprp_end:
meta_end:
mdat_start:
dd BE(mdat_end - mdat_start)
db "mdat"
db 0x00
mdat_end:
; vim: syntax=nasm
|
//
// File: ekfkdjmomglnngln_xdotc.cpp
//
// Code generated for Simulink model 'fam_force_allocation_module'.
//
// Model version : 1.1142
// Simulink Coder version : 8.11 (R2016b) 25-Aug-2016
// C/C++ source code generated on : Mon Dec 4 08:34:01 2017
//
#include "rtwtypes.h"
#include "ekfkdjmomglnngln_xdotc.h"
// Function for MATLAB Function: '<S12>/MATLAB Function'
real32_T ekfkdjmomglnngln_xdotc(int32_T n, const real32_T x[72], int32_T ix0,
const real32_T y[72], int32_T iy0)
{
real32_T d;
int32_T ix;
int32_T iy;
int32_T k;
d = 0.0F;
if (!(n < 1)) {
ix = ix0;
iy = iy0;
for (k = 1; k <= n; k++) {
d += x[(int32_T)(ix - 1)] * y[(int32_T)(iy - 1)];
ix++;
iy++;
}
}
return d;
}
//
// File trailer for generated code.
//
// [EOF]
//
|
// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "db_post_process.h" // NOLINT
#include <algorithm>
#include <utility>
void GetContourArea(std::vector<std::vector<float>> box, float unclip_ratio,
float &distance) {
int pts_num = 4;
float area = 0.0f;
float dist = 0.0f;
for (int i = 0; i < pts_num; i++) {
area += box[i][0] * box[(i + 1) % pts_num][1] -
box[i][1] * box[(i + 1) % pts_num][0];
dist += sqrtf((box[i][0] - box[(i + 1) % pts_num][0]) *
(box[i][0] - box[(i + 1) % pts_num][0]) +
(box[i][1] - box[(i + 1) % pts_num][1]) *
(box[i][1] - box[(i + 1) % pts_num][1]));
}
area = fabs(float(area / 2.0));
distance = area * unclip_ratio / dist;
}
cv::RotatedRect Unclip(std::vector<std::vector<float>> box,
float unclip_ratio) {
float distance = 1.0;
GetContourArea(box, unclip_ratio, distance);
ClipperLib::ClipperOffset offset;
ClipperLib::Path p;
p << ClipperLib::IntPoint(static_cast<int>(box[0][0]),
static_cast<int>(box[0][1]))
<< ClipperLib::IntPoint(static_cast<int>(box[1][0]),
static_cast<int>(box[1][1]))
<< ClipperLib::IntPoint(static_cast<int>(box[2][0]),
static_cast<int>(box[2][1]))
<< ClipperLib::IntPoint(static_cast<int>(box[3][0]),
static_cast<int>(box[3][1]));
offset.AddPath(p, ClipperLib::jtRound, ClipperLib::etClosedPolygon);
ClipperLib::Paths soln;
offset.Execute(soln, distance);
std::vector<cv::Point2f> points;
for (int j = 0; j < soln.size(); j++) {
for (int i = 0; i < soln[soln.size() - 1].size(); i++) {
points.emplace_back(soln[j][i].X, soln[j][i].Y);
}
}
cv::RotatedRect res = cv::minAreaRect(points);
return res;
}
std::vector<std::vector<float>> Mat2Vector(cv::Mat mat) {
std::vector<std::vector<float>> img_vec;
std::vector<float> tmp;
for (int i = 0; i < mat.rows; ++i) {
tmp.clear();
for (int j = 0; j < mat.cols; ++j) {
tmp.push_back(mat.at<float>(i, j));
}
img_vec.push_back(tmp);
}
return img_vec;
}
bool XsortFp32(std::vector<float> a, std::vector<float> b) {
if (a[0] != b[0])
return a[0] < b[0];
return false;
}
bool XsortInt(std::vector<int> a, std::vector<int> b) {
if (a[0] != b[0])
return a[0] < b[0];
return false;
}
std::vector<std::vector<int>>
OrderPointsClockwise(std::vector<std::vector<int>> pts) {
std::vector<std::vector<int>> box = pts;
std::sort(box.begin(), box.end(), XsortInt);
std::vector<std::vector<int>> leftmost = {box[0], box[1]};
std::vector<std::vector<int>> rightmost = {box[2], box[3]};
if (leftmost[0][1] > leftmost[1][1])
std::swap(leftmost[0], leftmost[1]);
if (rightmost[0][1] > rightmost[1][1])
std::swap(rightmost[0], rightmost[1]);
std::vector<std::vector<int>> rect = {leftmost[0], rightmost[0], rightmost[1],
leftmost[1]};
return rect;
}
std::vector<std::vector<float>> GetMiniBoxes(cv::RotatedRect box, float &ssid) {
ssid = std::max(box.size.width, box.size.height);
cv::Mat points;
cv::boxPoints(box, points);
auto array = Mat2Vector(points);
std::sort(array.begin(), array.end(), XsortFp32);
std::vector<float> idx1 = array[0], idx2 = array[1], idx3 = array[2],
idx4 = array[3];
if (array[3][1] <= array[2][1]) {
idx2 = array[3];
idx3 = array[2];
} else {
idx2 = array[2];
idx3 = array[3];
}
if (array[1][1] <= array[0][1]) {
idx1 = array[1];
idx4 = array[0];
} else {
idx1 = array[0];
idx4 = array[1];
}
array[0] = idx1;
array[1] = idx2;
array[2] = idx3;
array[3] = idx4;
return array;
}
float BoxScoreFast(std::vector<std::vector<float>> box_array, cv::Mat pred) {
auto array = box_array;
int width = pred.cols;
int height = pred.rows;
float box_x[4] = {array[0][0], array[1][0], array[2][0], array[3][0]};
float box_y[4] = {array[0][1], array[1][1], array[2][1], array[3][1]};
int xmin = clamp(
static_cast<int>(std::floorf(*(std::min_element(box_x, box_x + 4)))), 0,
width - 1);
int xmax =
clamp(static_cast<int>(std::ceilf(*(std::max_element(box_x, box_x + 4)))),
0, width - 1);
int ymin = clamp(
static_cast<int>(std::floorf(*(std::min_element(box_y, box_y + 4)))), 0,
height - 1);
int ymax =
clamp(static_cast<int>(std::ceilf(*(std::max_element(box_y, box_y + 4)))),
0, height - 1);
cv::Mat mask;
mask = cv::Mat::zeros(ymax - ymin + 1, xmax - xmin + 1, CV_8UC1);
cv::Point root_point[4];
root_point[0] = cv::Point(static_cast<int>(array[0][0]) - xmin,
static_cast<int>(array[0][1]) - ymin);
root_point[1] = cv::Point(static_cast<int>(array[1][0]) - xmin,
static_cast<int>(array[1][1]) - ymin);
root_point[2] = cv::Point(static_cast<int>(array[2][0]) - xmin,
static_cast<int>(array[2][1]) - ymin);
root_point[3] = cv::Point(static_cast<int>(array[3][0]) - xmin,
static_cast<int>(array[3][1]) - ymin);
const cv::Point *ppt[1] = {root_point};
int npt[] = {4};
cv::fillPoly(mask, ppt, npt, 1, cv::Scalar(1));
cv::Mat croppedImg;
pred(cv::Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1))
.copyTo(croppedImg);
auto score = cv::mean(croppedImg, mask)[0];
return score;
}
std::vector<std::vector<std::vector<int>>>
BoxesFromBitmap(const cv::Mat pred, const cv::Mat bitmap,
std::map<std::string, double> Config) {
const int min_size = 3;
const int max_candidates = 1000;
const float box_thresh = static_cast<float>(Config["det_db_box_thresh"]);
const float unclip_ratio = static_cast<float>(Config["det_db_unclip_ratio"]);
int width = bitmap.cols;
int height = bitmap.rows;
std::vector<std::vector<cv::Point>> contours;
std::vector<cv::Vec4i> hierarchy;
cv::findContours(bitmap, contours, hierarchy, cv::RETR_LIST,
cv::CHAIN_APPROX_SIMPLE);
int num_contours =
contours.size() >= max_candidates ? max_candidates : contours.size();
std::vector<std::vector<std::vector<int>>> boxes;
for (int i = 0; i < num_contours; i++) {
float ssid;
cv::RotatedRect box = cv::minAreaRect(contours[i]);
auto array = GetMiniBoxes(box, ssid);
auto box_for_unclip = array;
// end get_mini_box
if (ssid < min_size) {
continue;
}
float score;
score = BoxScoreFast(array, pred);
// end box_score_fast
if (score < box_thresh)
continue;
// start for unclip
cv::RotatedRect points = Unclip(box_for_unclip, unclip_ratio);
// end for unclip
cv::RotatedRect clipbox = points;
auto cliparray = GetMiniBoxes(clipbox, ssid);
if (ssid < min_size + 2)
continue;
int dest_width = pred.cols;
int dest_height = pred.rows;
std::vector<std::vector<int>> intcliparray;
for (int num_pt = 0; num_pt < 4; num_pt++) {
std::vector<int> a{
static_cast<int>(clamp(
roundf(cliparray[num_pt][0] / float(width) * float(dest_width)),
float(0), float(dest_width))),
static_cast<int>(clamp(
roundf(cliparray[num_pt][1] / float(height) * float(dest_height)),
float(0), float(dest_height)))};
intcliparray.push_back(a);
}
boxes.push_back(intcliparray);
} // end for
return boxes;
}
std::vector<std::vector<std::vector<int>>>
FilterTagDetRes(std::vector<std::vector<std::vector<int>>> boxes, float ratio_h,
float ratio_w, cv::Mat srcimg) {
int oriimg_h = srcimg.rows;
int oriimg_w = srcimg.cols;
std::vector<std::vector<std::vector<int>>> root_points;
for (int n = 0; n < static_cast<int>(boxes.size()); n++) {
boxes[n] = OrderPointsClockwise(boxes[n]);
for (int m = 0; m < static_cast<int>(boxes[0].size()); m++) {
boxes[n][m][0] /= ratio_w;
boxes[n][m][1] /= ratio_h;
boxes[n][m][0] =
static_cast<int>(std::min(std::max(boxes[n][m][0], 0), oriimg_w - 1));
boxes[n][m][1] =
static_cast<int>(std::min(std::max(boxes[n][m][1], 0), oriimg_h - 1));
}
}
for (int n = 0; n < boxes.size(); n++) {
int rect_width, rect_height;
rect_width =
static_cast<int>(sqrt(pow(boxes[n][0][0] - boxes[n][1][0], 2) +
pow(boxes[n][0][1] - boxes[n][1][1], 2)));
rect_height =
static_cast<int>(sqrt(pow(boxes[n][0][0] - boxes[n][3][0], 2) +
pow(boxes[n][0][1] - boxes[n][3][1], 2)));
if (rect_width <= 10 || rect_height <= 10)
continue;
root_points.push_back(boxes[n]);
}
return root_points;
}
|
#include "device.h"
device::device( QWidget *parent)//shared_ptr<ofApp> _ofAppPtr,
: QWidget(parent)
{
ui.setupUi(this);
ofSetLogLevel(OF_LOG_VERBOSE);
ofLogToConsole();
// here we create a ofapp with an ofQtWindow
// then we extract a pointer to QOpenGLWidget
// and we insert it in the layout.
// create an app and a window and initialize
// ofLoop is not used, Qt will call events
ofAppPtr = make_shared<ofApp>();
windowPtr = make_shared<ofAppQtWindow>(this->parentWidget());
ofSetupOpenGL(windowPtr, 400, 400, OF_WINDOW);
// add widget to layout
layout = ui.horizontalLayout;
layout->addWidget(windowPtr->getQWidgetPtr());
ui.widget_2->setLayout(layout);
// initialize OF must be here!
ofRunApp(windowPtr, ofAppPtr);
}
device::~device()
{
// ATTENTION HERE!!
// we must tell the ofMainLoop that this window has to close.
ofGetMainLoop()->removeWindow(windowPtr);
// ofAppPtr = nullptr; // this removes warnings on console
}
void device::on_Size_slider_sliderMoved(int value) {
ofAppPtr->radius.set(value);
}
void device::changeEvent(QEvent *e)
{
if (e->type() == QEvent::WindowStateChange) {
if (isMinimized()) {
ofLogVerbose() << "MINIMIZED";
}
else if (isMaximized()){
ofLogVerbose() << "MAXIMIZED ETC";
windowPtr->paint();
}
else {
ofLogVerbose() << "NORMA ETC";
windowPtr->paint();
}
}
e->accept();
} |
/*******************************************************************************
* Copyright 2021-2022 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#ifndef CPU_X64_RNN_JIT_UNI_LSTM_CELL_POSTGEMM_HPP
#define CPU_X64_RNN_JIT_UNI_LSTM_CELL_POSTGEMM_HPP
#include "common/utils.hpp"
#include "cpu/x64/jit_generator.hpp"
namespace dnnl {
namespace impl {
namespace cpu {
namespace x64 {
template <cpu_isa_t isa>
struct jit_uni_lstm_cell_postgemm_t {
jit_uni_lstm_cell_postgemm_t(
jit_generator *host, int tmp_id_begin, bool use_bf16_emu)
: host_(host)
, tmp_id_begin_(tmp_id_begin)
, current_tmp_id_(tmp_id_begin)
, tmp_id_end_(cpu_isa_traits<isa>::n_vregs
- (is_superset(isa, avx512_core) && use_bf16_emu ? 4 : 0)) {}
protected:
using injector_t = typename utils::conditional<isa == avx512_core,
jit_uni_eltwise_injector_f32<avx512_core>,
jit_uni_eltwise_injector_f32<isa>>::type;
using Vmm = typename cpu_isa_traits<isa>::Vmm;
const size_t vlen_ = cpu_isa_traits<isa>::vlen;
Vmm get_next_tmp_vmm() {
const Vmm vmm {current_tmp_id_++};
if (current_tmp_id_ == tmp_id_end_) reset_vmm_cnt();
return vmm;
}
void reset_vmm_cnt() { current_tmp_id_ = tmp_id_begin_; }
Xbyak::Xmm get_next_tmp_xmm() {
return Xbyak::Xmm(get_next_tmp_vmm().getIdx());
}
Vmm vmm_backup(const Vmm &vmm) {
auto tmp_vmm = vmm;
if (!this->avx2_available_) {
tmp_vmm = this->get_next_tmp_vmm();
host_->uni_vmovups(tmp_vmm, vmm);
}
return tmp_vmm;
};
Xbyak::Xmm xmm_backup(const Xbyak::Xmm &xmm) {
auto tmp_xmm = xmm;
if (!this->avx2_available_) {
tmp_xmm = this->get_next_tmp_xmm();
host_->uni_vmovss(tmp_xmm, xmm);
}
return tmp_xmm;
};
void vaddps_rhs_op_mem(
const Vmm &dst, const Vmm &lhs, const Xbyak::Address &rhs_addr) {
if (avx2_available_)
host_->uni_vaddps(dst, lhs, rhs_addr);
else {
const auto rhs = get_next_tmp_vmm();
host_->uni_vmovups(rhs, rhs_addr);
host_->uni_vaddps(dst, lhs, rhs);
}
}
void vfmadd231ps_rhs_op_mem(
const Vmm &dst, const Vmm &lhs, const Xbyak::Address &rhs_addr) {
if (avx2_available_)
host_->uni_vfmadd231ps(dst, lhs, rhs_addr);
else {
const auto tmp = get_next_tmp_vmm();
host_->uni_vmovups(tmp, rhs_addr);
const auto &rhs = lhs;
host_->uni_vfmadd231ps(dst, tmp, rhs);
}
}
void vmulps_rhs_op_mem(
const Vmm &dst, const Vmm &lhs, const Xbyak::Address &rhs_addr) {
if (avx2_available_)
host_->uni_vmulps(dst, lhs, rhs_addr);
else {
const auto rhs = get_next_tmp_vmm();
host_->uni_vmovups(rhs, rhs_addr);
host_->uni_vmulps(dst, lhs, rhs);
}
}
void vaddss_rhs_op_mem(const Xbyak::Xmm &dst, const Xbyak::Xmm &lhs,
const Xbyak::Address &rhs_addr) {
if (avx2_available_)
host_->uni_vaddss(dst, lhs, rhs_addr);
else {
const auto rhs = get_next_tmp_xmm();
host_->uni_vmovss(rhs, rhs_addr);
host_->uni_vaddss(dst, lhs, rhs);
}
}
void vfmadd231ss_rhs_op_mem(const Xbyak::Xmm &dst, const Xbyak::Xmm &lhs,
const Xbyak::Address &rhs_addr) {
if (avx2_available_)
host_->uni_vfmadd231ss(dst, lhs, rhs_addr);
else {
const auto tmp = get_next_tmp_xmm();
host_->uni_vmovss(tmp, rhs_addr);
const auto &rhs = lhs;
host_->uni_vfmadd231ss(dst, tmp, rhs);
}
}
void vmulss_rhs_op_mem(const Xbyak::Xmm &dst, const Xbyak::Xmm &lhs,
const Xbyak::Address &rhs_addr) {
if (avx2_available_)
host_->uni_vmulss(dst, lhs, rhs_addr);
else {
const auto rhs = get_next_tmp_xmm();
host_->uni_vmovss(rhs, rhs_addr);
host_->uni_vmulss(dst, lhs, rhs);
}
}
protected:
const bool avx2_available_ = is_superset(isa, avx2);
private:
jit_generator *host_;
const int tmp_id_begin_;
int current_tmp_id_;
const int tmp_id_end_;
};
} // namespace x64
} // namespace cpu
} // namespace impl
} // namespace dnnl
#endif
|
;
; Include code from halx86
; This is a cpp style symbolic link
MMTIMER equ 1
include ..\..\halmps\i386\mpclksup.asm
|
naken_util - by Michael Kohn
Joe Davisson
Web: http://www.mikekohn.net/
Email: mike@mikekohn.net
Version: October 30, 2017
Loaded hexfile E_W_ROUTINEs_32K_ver_1.0.hex from 0x00a0 to 0x0173
Type help for a list of commands.
Addr Opcode Instruction Cycles
------- ------ ---------------------------------- ------
0x00a0: 5f clrw X cycles=1
0x00a1: 3f 90 clr $90 cycles=1
0x00a3: 72 09 00 8e 16 btjf $8e, #4, $be (offset=22) cycles=2-3
0x00a8: cd 60 5f call $605f cycles=4
0x00ab: b6 90 ld A, $90 cycles=1
0x00ad: e7 00 ld ($00,X),A cycles=1
0x00af: 5c incw X cycles=1
0x00b0: 4c inc A cycles=1
0x00b1: b7 90 ld $90,A cycles=1
0x00b3: a1 21 cp A, #$21 cycles=1
0x00b5: 26 f1 jrne $a8 (offset=-15) cycles=1-2
0x00b7: a6 20 ld A, #$20 cycles=1
0x00b9: b7 88 ld $88,A cycles=1
0x00bb: 5f clrw X cycles=1
0x00bc: 3f 90 clr $90 cycles=1
0x00be: e6 00 ld A, ($00,X) cycles=1
0x00c0: a1 20 cp A, #$20 cycles=1
0x00c2: 26 07 jrne $cb (offset=7) cycles=1-2
0x00c4: 3f 8a clr $8a cycles=1
0x00c6: ae 40 00 ldw X, #$4000 cycles=2
0x00c9: 20 0c jra $d7 (offset=12) cycles=2
0x00cb: 3f 8a clr $8a cycles=1
0x00cd: ae 00 80 ldw X, #$80 cycles=2
0x00d0: 42 mul X, A cycles=4
0x00d1: 58 sllw X cycles=2
0x00d2: 58 sllw X cycles=2
0x00d3: 58 sllw X cycles=2
0x00d4: 1c 80 00 addw X, #$8000 cycles=2
0x00d7: 90 5f clrw Y cycles=1
0x00d9: cd 60 5f call $605f cycles=4
0x00dc: 9e ld A, XH cycles=1
0x00dd: b7 8b ld $8b,A cycles=1
0x00df: 9f ld A, XL cycles=1
0x00e0: b7 8c ld $8c,A cycles=1
0x00e2: a6 20 ld A, #$20 cycles=1
0x00e4: c7 50 5b ld $505b,A cycles=1
0x00e7: 43 cpl A cycles=1
0x00e8: c7 50 5c ld $505c,A cycles=1
0x00eb: 4f clr A cycles=1
0x00ec: 92 bd 00 8a ldf [$8a.e],A cycles=4
0x00f0: 5c incw X cycles=1
0x00f1: 9f ld A, XL cycles=1
0x00f2: b7 8c ld $8c,A cycles=1
0x00f4: 4f clr A cycles=1
0x00f5: 92 bd 00 8a ldf [$8a.e],A cycles=4
0x00f9: 5c incw X cycles=1
0x00fa: 9f ld A, XL cycles=1
0x00fb: b7 8c ld $8c,A cycles=1
0x00fd: 4f clr A cycles=1
0x00fe: 92 bd 00 8a ldf [$8a.e],A cycles=4
0x0102: 5c incw X cycles=1
0x0103: 9f ld A, XL cycles=1
0x0104: b7 8c ld $8c,A cycles=1
0x0106: 4f clr A cycles=1
0x0107: 92 bd 00 8a ldf [$8a.e],A cycles=4
0x010b: 72 05 50 5f fb btjf $505f, #2, $10b (offset=-5) cycles=2-3
0x0110: 90 a3 00 07 cpw Y, #$7 cycles=2
0x0114: 27 0a jreq $120 (offset=10) cycles=1-2
0x0116: 90 5c incw Y cycles=1
0x0118: 1d 00 03 subw X, #$3 cycles=2
0x011b: 1c 00 80 addw X, #$80 cycles=2
0x011e: 20 b9 jra $d9 (offset=-71) cycles=2
0x0120: b6 90 ld A, $90 cycles=1
0x0122: b1 88 cp A, $88 cycles=1
0x0124: 27 08 jreq $12e (offset=8) cycles=1-2
0x0126: 5f clrw X cycles=1
0x0127: 3c 90 inc $90 cycles=1
0x0129: b6 90 ld A, $90 cycles=1
0x012b: 97 ld XL, A cycles=1
0x012c: 20 90 jra $be (offset=-112) cycles=2
0x012e: 81 ret cycles=4
0x012f: 5f clrw X cycles=1
0x0130: 72 0d 00 8e 1a btjf $8e, #6, $14f (offset=26) cycles=2-3
0x0135: 72 00 00 94 0b btjt $94, #0, $145 (offset=11) cycles=2-3
0x013a: a6 01 ld A, #$01 cycles=1
0x013c: c7 50 5b ld $505b,A cycles=1
0x013f: 43 cpl A cycles=1
0x0140: c7 50 5c ld $505c,A cycles=1
0x0143: 20 0a jra $14f (offset=10) cycles=2
0x0145: 35 81 50 5b mov $505b, #$81 cycles=1
0x0149: 35 7e 50 5c mov $505c, #$7e cycles=1
0x014d: 3f 94 clr $94 cycles=1
0x014f: cd 60 5f call $605f cycles=4
0x0152: f6 ld A, (X) cycles=1
0x0153: 92 a7 00 8a ldf ([$8a.e],X),A cycles=4
0x0157: 72 0c 00 8e 05 btjt $8e, #6, $161 (offset=5) cycles=2-3
0x015c: 72 05 50 5f fb btjf $505f, #2, $15c (offset=-5) cycles=2-3
0x0161: 9f ld A, XL cycles=1
0x0162: b1 88 cp A, $88 cycles=1
0x0164: 27 03 jreq $169 (offset=3) cycles=1-2
0x0166: 5c incw X cycles=1
0x0167: 20 e6 jra $14f (offset=-26) cycles=2
0x0169: 72 0d 00 8e 05 btjf $8e, #6, $173 (offset=5) cycles=2-3
0x016e: 72 05 50 5f fb btjf $505f, #2, $16e (offset=-5) cycles=2-3
0x0173: 81 ret cycles=4
|
; A092534: Expansion of (1-x+x^2)*(1+x^4)/((1-x)^2*(1-x^2)).
; Submitted by Jamie Morken(s3)
; 1,1,3,4,8,10,16,20,28,34,44,52,64,74,88,100,116,130,148,164,184,202,224,244,268,290,316,340,368,394,424,452,484,514,548,580,616,650,688,724,764,802,844,884,928,970,1016,1060,1108,1154,1204,1252,1304,1354,1408,1460,1516,1570,1628,1684,1744,1802,1864,1924,1988,2050,2116,2180,2248,2314,2384,2452,2524,2594,2668,2740,2816,2890,2968,3044,3124,3202,3284,3364,3448,3530,3616,3700,3788,3874,3964,4052,4144,4234,4328,4420,4516,4610,4708,4804
mov $1,$0
div $1,2
sub $0,$1
mul $0,2
mul $1,$0
sub $0,1
trn $0,2
sub $1,$0
mov $0,$1
add $0,1
|
;
; ZX 81 specific routines
; by Stefano Bodrato, Oct 2007
;
; Copy a string to a BASIC variable
;
; int __CALLEE__ zx_setstr_callee(char variable, char *value);
;
;
; $Id: zx_setstr_callee.asm,v 1.5 2016-06-26 20:32:09 dom Exp $
;
SECTION code_clib
PUBLIC zx_setstr_callee
PUBLIC _zx_setstr_callee
PUBLIC ASMDISP_ZX_SETSTR_CALLEE
EXTERN asctozx81
zx_setstr_callee:
_zx_setstr_callee:
pop bc
pop hl
pop de
push bc
; enter : hl = char *value
; e = char variable
.asmentry
ld a,e
and 31
add 69
ld (morevar+1),a
ld (pointer+1),hl
ld hl,($4010) ; VARS
loop:
ld a,(hl)
cp 128
jr nz,morevar
jr store ; variable not found
morevar:
cp 0
jr nz,nextvar
IF FORlambda
call $1A13 ; get next variable start
call $0177 ; reclaim space (delete)
ELSE
call $09F2 ; get next variable start
call $0A60 ; reclaim space (delete)
ENDIF
store:
ld bc,0
pointer:
ld de,0 ; point to the string
push de
lenloop:
inc bc ; string length counter
inc de
ld a,(de)
and a
jr nz,lenloop
push hl
push bc
inc bc
inc bc
inc bc
IF FORlambda
call $1CB5
ELSE
call $099E ; MAKE-ROOM
ENDIF
pop bc
pop hl
ld a,(morevar+1)
ld (hl),a
inc hl
ld (hl),c
inc hl
ld (hl),b
inc hl
pop de
ex de,hl
;ldir
;-----------------------------
.outloop
call asctozx81
ld (de),a
inc hl
inc de
dec bc
ld a,b
or c
jr nz,outloop
;------------------------------
ret
nextvar:
IF FORlambda
call $1A13 ; get next variable start
ELSE
call $09F2 ;get next variable start
ENDIF
ex de,hl
jr loop
DEFC ASMDISP_ZX_SETSTR_CALLEE = asmentry - zx_setstr_callee
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r15
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x1eed2, %r13
nop
nop
nop
nop
nop
xor %r11, %r11
mov $0x6162636465666768, %rcx
movq %rcx, %xmm2
movups %xmm2, (%r13)
nop
nop
xor %rcx, %rcx
lea addresses_A_ht+0xdcd2, %rcx
nop
nop
nop
dec %r12
mov $0x6162636465666768, %r11
movq %r11, %xmm3
vmovups %ymm3, (%rcx)
nop
sub $57484, %rax
lea addresses_D_ht+0x544a, %r15
nop
nop
nop
nop
nop
xor $53851, %rax
movb $0x61, (%r15)
nop
xor %rcx, %rcx
lea addresses_normal_ht+0x6452, %r13
nop
nop
add %rbp, %rbp
mov $0x6162636465666768, %rcx
movq %rcx, %xmm1
and $0xffffffffffffffc0, %r13
movaps %xmm1, (%r13)
nop
nop
nop
nop
nop
cmp $4662, %rbp
lea addresses_normal_ht+0x110d2, %r13
clflush (%r13)
nop
and $23189, %r15
mov (%r13), %rbp
nop
lfence
lea addresses_normal_ht+0x11f1a, %rsi
lea addresses_WC_ht+0x14452, %rdi
clflush (%rsi)
nop
add %rax, %rax
mov $83, %rcx
rep movsl
nop
nop
nop
nop
sub %r11, %r11
lea addresses_UC_ht+0x9e12, %rsi
nop
nop
nop
nop
nop
add %r11, %r11
movl $0x61626364, (%rsi)
nop
nop
nop
nop
add %rdi, %rdi
lea addresses_WC_ht+0x178d2, %r11
nop
nop
nop
nop
nop
and $59539, %rax
movl $0x61626364, (%r11)
nop
nop
nop
xor %rcx, %rcx
lea addresses_UC_ht+0x87c2, %r15
nop
nop
nop
nop
nop
cmp $55128, %rcx
movb (%r15), %al
and $53396, %r15
lea addresses_WT_ht+0x16752, %rsi
lea addresses_WC_ht+0x14ebf, %rdi
nop
nop
dec %r15
mov $7, %rcx
rep movsw
xor $2364, %rcx
lea addresses_WC_ht+0x112d2, %rsi
lea addresses_UC_ht+0x12cd2, %rdi
clflush (%rsi)
nop
nop
sub %r15, %r15
mov $123, %rcx
rep movsw
nop
nop
nop
nop
nop
xor $56884, %rsi
lea addresses_normal_ht+0x1a0d6, %rcx
nop
nop
nop
nop
nop
xor $48824, %r12
movb $0x61, (%rcx)
add $4782, %r15
lea addresses_normal_ht+0x13580, %rsi
lea addresses_D_ht+0x14cd4, %rdi
nop
and %r12, %r12
mov $52, %rcx
rep movsw
cmp $12040, %r15
lea addresses_D_ht+0x7d59, %rax
nop
nop
nop
cmp $44743, %rsi
movups (%rax), %xmm3
vpextrq $1, %xmm3, %r15
nop
nop
nop
sub $559, %r15
lea addresses_WT_ht+0x7fd2, %r12
nop
nop
nop
dec %r13
movb $0x61, (%r12)
nop
xor %r15, %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r15
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %r9
// Faulty Load
mov $0x1065cb0000000cd2, %r11
nop
sub %r15, %r15
vmovups (%r11), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %r9
lea oracles, %r15
and $0xff, %r9
shlq $12, %r9
mov (%r15,%r9,1), %r9
pop %r9
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 9}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 3}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 1, 'NT': True, 'same': False, 'congruent': 2}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 5}}
{'72': 3, '44': 4134, '00': 490}
44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 00 44 44 00 44 44 44 00 44 44 44 00 44 44 44 44 44 44 44 44 00 44 44 44 00 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 00 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 00 44 00 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 00 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 00 00 44 44 44 44 44 00 44 00 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 00 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 00 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 72 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 00 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 00 00 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r8
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x5, %rsi
lea addresses_A_ht+0x9815, %rdi
nop
nop
nop
nop
and $8687, %r8
mov $112, %rcx
rep movsb
nop
nop
cmp %r9, %r9
lea addresses_WT_ht+0x11415, %r12
nop
nop
nop
nop
nop
sub $37285, %rax
mov (%r12), %r9
nop
nop
nop
xor %rax, %rax
lea addresses_D_ht+0xd095, %r9
clflush (%r9)
nop
cmp %rcx, %rcx
movl $0x61626364, (%r9)
nop
cmp %rcx, %rcx
lea addresses_WC_ht+0x5f95, %rdi
nop
add $51280, %r9
vmovups (%rdi), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %r8
nop
nop
nop
nop
nop
add $50531, %rcx
lea addresses_D_ht+0x162c5, %rsi
nop
nop
nop
nop
dec %rax
movb $0x61, (%rsi)
nop
nop
nop
nop
nop
add %rcx, %rcx
lea addresses_WC_ht+0x4165, %r8
nop
nop
nop
inc %r12
mov $0x6162636465666768, %r9
movq %r9, %xmm6
vmovups %ymm6, (%r8)
nop
nop
nop
nop
and %rdi, %rdi
lea addresses_A_ht+0xe7a1, %rsi
lea addresses_WC_ht+0x11625, %rdi
xor $44922, %r15
mov $105, %rcx
rep movsq
nop
nop
sub $64544, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r8
push %rbp
push %rbx
push %rcx
push %rsi
// Store
lea addresses_UC+0x15f0d, %rbp
nop
nop
dec %rcx
mov $0x5152535455565758, %rbx
movq %rbx, (%rbp)
nop
nop
dec %rcx
// Faulty Load
lea addresses_RW+0x1815, %r8
nop
nop
nop
nop
xor %rbp, %rbp
mov (%r8), %rcx
lea oracles, %rbx
and $0xff, %rcx
shlq $12, %rcx
mov (%rbx,%rcx,1), %rcx
pop %rsi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_RW', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC', 'same': False, 'size': 8, 'congruent': 3, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_RW', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
TITLE Appending to a File (AppendFile.asm)
; This program appends text to an existing file.
; Last update: 1/30/02
INCLUDE Irvine32.inc
.data
buffer BYTE "This text is appended to an output file.",0dh,0ah
bufSize = ($-buffer)
errMsg BYTE "Cannot open file",0dh,0ah,0
filename BYTE "output.txt",0
fileHandle DWORD ? ; handle to output file
bytesWritten DWORD ? ; number of bytes written
.code
main PROC
INVOKE CreateFile,
ADDR filename, GENERIC_WRITE, DO_NOT_SHARE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0
mov fileHandle,eax ; save file handle
.IF eax == INVALID_HANDLE_VALUE
mov edx,OFFSET errMsg ; Display error message
call WriteString
jmp QuitNow
.ENDIF
; Move the file pointer to the end of the file
INVOKE SetFilePointer,
fileHandle,0,0,FILE_END
; Append text to the file
INVOKE WriteFile,
fileHandle, ADDR buffer, bufSize,
ADDR bytesWritten, 0
INVOKE CloseHandle, fileHandle
QuitNow:
exit
main ENDP
END main |
; A138996: First differences of Frobenius numbers for 5 successive numbers A138985.
; 1,1,1,7,2,2,2,12,3,3,3,17,4,4,4,22,5,5,5,27,6,6,6,32,7,7,7,37,8,8,8,42,9,9,9,47,10,10,10,52,11,11,11,57,12,12,12,62,13,13,13,67,14,14,14,72,15,15,15,77,16,16,16,82,17,17,17,87,18,18,18,92,19,19,19,97,20,20,20,102,21,21,21,107,22,22,22,112,23,23,23,117,24,24,24,122,25,25,25,127,26,26,26,132,27,27,27,137,28,28,28,142,29,29,29,147,30,30,30,152,31,31,31,157,32,32,32,162,33,33,33,167,34,34,34,172,35,35,35,177,36,36,36,182,37,37,37,187,38,38,38,192,39,39,39,197,40,40,40,202,41,41,41,207,42,42,42,212,43,43,43,217,44,44,44,222,45,45,45,227,46,46,46,232,47,47,47,237,48,48,48,242,49,49,49,247,50,50,50,252,51,51,51,257,52,52,52,262,53,53,53,267,54,54,54,272,55,55,55,277,56,56,56,282,57,57,57,287,58,58,58,292,59,59,59,297,60,60,60,302,61,61,61,307,62,62,62,312,63,63
mov $5,$0
mov $6,2
lpb $6,1
mov $0,$5
sub $6,1
add $0,$6
sub $0,1
mov $8,$0
add $0,5
lpb $0,1
add $8,$0
mov $0,1
lpe
mov $2,$6
mov $3,2
add $3,$8
sub $8,2
mov $4,$8
div $4,8
mul $4,$3
mov $7,$4
lpb $2,1
mov $1,$7
sub $2,1
lpe
lpe
lpb $5,1
sub $1,$7
mov $5,0
lpe
div $1,2
add $1,1
|
;
; ZX80 Stdio
;
; getk() Read key status
;
; Stefano Bodrato - Dec 2011
;
;
; $Id: getk.asm,v 1.3 2015/01/19 01:33:22 pauloscustodio Exp $
;
PUBLIC getk
EXTERN zx80_decode_keys
.getk
;call restore81
;call 699 ;KSCAN on ZX91
LD HL,$FFFF
LD BC,$FEFE
IN A,(C)
OR $01
.LOOP
OR $E0
LD D,A
CPL
CP $01
SBC A,A
OR B
AND L
LD L,A
LD A,H
AND D
LD H,A
RLC B
IN A,(C)
JR C,LOOP
RRA
RL H
ld a,h
add a,2
jr c,isntchar
ld b,h
ld c,l
; ;call 1981 ; Findchr on ZX81
jp zx80_decode_keys
isntchar:
ld hl,0
ret
|
bits 16
%include "source/memory.h"
%include "source/text.h"
THEME equ DARK_BLUE << 4 | WHITE
org BOOT
boot:
jmp near start
times 3 - ($ - boot) db 0
; We set the whole BPB block to 0s because we will splice in the actual info
; from the disk image we are writing the boot sector to.
bpb:
.oemIdentifier:
times 8 db 0
.bytesPerSector:
dw 0
.sectorsPerCluster:
db 0
.reservedSectors:
dw 0
.fats:
db 0
.rootEntries:
dw 0
.totalSectors:
dw 0
.mediaDescriptorType:
db 0
.sectorsPerFat:
dw 0
.sectorsPerTrack:
dw 0
.headsPerCylinder:
dw 0
.hiddenSectors:
dd 0
.largeTotalSectors:
dd 0
.drive:
db 0
.flags:
db 0
.signature:
db 0
.volumeId:
dd 0
.volumeLabel:
times 11 db 0
.systemId:
times 8 db 0
%include "source/text.asm"
resetFloppy:
mov ah, 0
mov dl, 0
int 0x13
jc resetFloppy
ret
readSectors:
; ax = Starting sector
; cx = Number of sectors to read
; es:bx => Buffer to read to
.start:
mov di, 0x0005
.sectorLoop:
push ax
push bx
push cx
call convertLbaToChs ; convert starting sector to CHS
mov ah, 0x02 ; BIOS read sector
mov al, 0x01 ; read one sector
mov ch, byte [absoluteTrack] ; track
mov cl, byte [absoluteSector] ; sector
mov dh, byte [absoluteHead] ; head
mov dl, byte [bpb.drive] ; drive
int 0x13 ; invoke BIOS
jnc .success ; test for read error
xor ax, ax ; BIOS reset disk
int 0x13 ; invoke BIOS
dec di ; decrement error counter
pop cx
pop bx
pop ax
jnz .sectorLoop ; attempt to read again
jmp failure
.success:
pop cx
pop bx
pop ax
add bx, word [bpb.bytesPerSector] ; queue next buffer
inc ax ; queue next sector
loop .start ; read next sector
ret
print:
; ds:si points to a 0-terminated string
mov ah, 0x0e
.startLoop:
lodsb
or al, al
jz .done
int 0x10
jmp .startLoop
.done:
ret
convertChsToLba:
; ax = clustor
sub ax, 0x0002 ; zero base cluster number
xor cx, cx
mov cl, byte [bpb.sectorsPerCluster] ; convert byte to word
mul cx
add ax, word [dataSector] ; base data sector
ret
convertLbaToChs:
; ax = LBA address
; absolute sector = (logical sector / sectors per track) + 1
; absolute head = (logical sector / sectors per track) MOD number of heads
; absolute track = logical sector / (sectors per track * number of heads)
xor dx, dx ; prepare dx:ax for operation
div word [bpb.sectorsPerTrack] ; calculate
inc dl ; adjust for sector 0
mov byte [absoluteSector], dl
xor dx, dx ; prepare dx:ax for operation
div word [bpb.headsPerCylinder] ; calculate
mov byte [absoluteHead], dl
mov byte [absoluteTrack], al
ret
absoluteSector:
db 0x00
absoluteHead:
db 0x00
absoluteTrack:
db 0x00
dataSector:
dw 0x0000
cluster:
dw 0x0000
kernelFilename:
db "KERNEL "
start:
; Setup Stack
mov ax, STACK >> 4
mov ss, ax
mov sp, 0xffff
; Setup Video
mov ax, TEXT >> 4
mov es, ax
mov ah, THEME
call setColors
mov si, welcomeMessage
call print
mov si, crlfMessage
call print
loadRoot:
xor cx, cx
xor dx, dx
mov ax, 0x0020
mul word [bpb.rootEntries]
div word [bpb.bytesPerSector]
xchg ax, cx
mov al, [bpb.fats]
mul word [bpb.sectorsPerFat]
add ax, word [bpb.reservedSectors]
mov word [dataSector], ax
add word [dataSector], cx
mov bx, BOOT_FAT >> 4
mov es, bx
xor bx, bx
call readSectors
findKernel:
mov cx, word [bpb.rootEntries]
xor di, di
.loop:
push cx
mov cx, 0x000b
mov si, kernelFilename
push di
rep cmpsb
pop di
je loadFat
pop cx
add di, 0x0020
loop .loop
jmp failure
loadFat:
mov si, crlfMessage
call print
mov dx, word [di + 0x001A]
mov word [cluster], dx
xor ax, ax
mov al, byte [bpb.fats]
mul word [bpb.sectorsPerFat]
mov cx, ax
mov ax, word [bpb.reservedSectors]
xor bx, bx
call readSectors
mov si, crlfMessage
call print
mov ax, KERNEL >> 4
mov es, ax
mov bx, 0x0000
push bx
loadKernel:
mov ax, word [cluster]
pop bx
call convertChsToLba
xor cx, cx
mov cl, byte [bpb.sectorsPerCluster]
call readSectors
push bx
mov ax, word [cluster]
mov cx, ax
mov dx, ax
shr dx, 0x0001
add cx, dx
mov bx, 0x0200
add bx, cx
mov dx, word [bx]
test ax, 0x0001
jnz .oddCluster
.evenCluster:
and dx, 0x0fff
jmp .done
.oddCluster:
shr dx, 0x0004
.done:
mov word [cluster], dx
cmp dx, 0x0ff0
jb loadKernel
done:
mov si, crlfMessage
call print
push word KERNEL >> 4
push word 0x0000
retf
failure:
mov si, failureMessage
call print
mov ah, 0x00
; Wait for keypress
int 0x16
; Warm boot
int 0x19
welcomeMessage:
db "Welcome to MOS", 0x00
loadingKernelMessage:
db "Loading", 0x00
progressMessage:
db ".", 0x00
failureMessage:
db "Failed", 0x00
crlfMessage:
db 0x0d, 0x0a, 0x00
padding:
times 510 - ($ - $$) db 0
signature:
dw 0xaa55
|
SEC
OUT A
CLC
OUT A
SEI
OUT A
CLI
OUT A
LDA #$FF
ADC #$01
OUT A
CLV
OUT A
SED
OUT A
CLD
OUT A
|
SECTION code_clib
PUBLIC __krt_xor
.__krt_xor
defc NEEDxor = 1
INCLUDE "pixel_krt.inc"
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define rint(x) scanf("%d", &(x))
#define endl '\n'
typedef long long LL;
typedef pair<int,int> I2;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
string ss;
cin >> n;
ss.resize(n);
for(int i = 0; i < n; i++)
{
char c;
cin >> c;
ss[i] = c;
}
int lastr = -1;
int lastb = -1;
int rc = 0;
int bc = 0;
for(int i = 0; i < n; i++)
{
if(ss[i] == 'r')
{
rc++;
lastr = i;
}
else
{
bc++;
lastb = i;
}
}
int mint = 0;
// rb
string s = ss;
int t = 0;
int lr = lastr;
int lb = lastb;
for(int i = 0; i < n; i++)
{
if(i%2 == 0)
{
if(s[i] == 'b')
{
if(lr > i)
{
while(lr > i && s[lr] != 'r' || lr%2 == 0) lr--;
}
if(lr > i)
{
swap(s[i], s[lr]);
t++;
}
else
{
s[i] = 'r';
t++;
}
}
}
else
{
if(s[i] == 'r')
{
if(lb > i)
{
while(lb > i && s[lb] != 'b' || lb%2 == 1) lb--;
}
if(lb > i)
{
swap(s[i], s[lb]);
t++;
}
else
{
s[i] == 'b';
t++;
}
}
}
}
mint = t;
t = 0;
s = ss;
lr = lastr;
lb = lastb;
// br
for(int i = 0; i < n; i++)
{
if(i%2 == 1)
{
if(s[i] == 'b')
{
if(lr > i)
{
while(lr > i && s[lr] != 'r' || lr%2 == 1) lr--;
}
if(lr > i)
{
swap(s[i], s[lr]);
t++;
}
else
{
s[i] = 'r';
t++;
}
}
}
else
{
if(s[i] == 'r')
{
if(lb > i)
{
while(lb > i && s[lb] != 'b' || lb%2 == 0) lb--;
}
if(lb > i)
{
swap(s[i], s[lb]);
t++;
}
else
{
s[i] = 'b';
t++;
}
}
}
}
mint = min(mint, t);
cout << mint << endl;
return 0;
}
|
; A135509: Nonnegative integers c such that there are nonnegative integers a and b that satisfy a^(1/2) + b^(1/2) = c^(1/2) and a^2 + b = c.
; 0,1,25,225,1156,4225,12321,30625,67600,136161,255025,450241,756900,1221025,1901641,2873025,4227136,6076225,8555625,11826721,16080100,21538881,28462225,37149025,47941776,61230625,77457601,97121025,120780100,149059681,182655225,222337921,268960000,323460225,386869561,460317025,545035716,642369025,753777025,880843041,1025280400,1188939361,1373814225,1582050625,1815952996,2077992225,2370813481,2697244225,3060302400,3463204801,3909375625,4402455201,4946308900,5545036225,6202980081,6924736225
mov $1,$0
pow $0,3
add $0,$1
pow $0,2
div $0,4
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/tools/quic/platform/impl/quic_epoll_clock.h"
#include "net/tools/quic/test_tools/mock_epoll_server.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace net {
namespace test {
TEST(QuicEpollClockTest, ApproximateNowInUsec) {
MockEpollServer epoll_server;
QuicEpollClock clock(&epoll_server);
epoll_server.set_now_in_usec(1000000);
EXPECT_EQ(1000000,
(clock.ApproximateNow() - QuicTime::Zero()).ToMicroseconds());
EXPECT_EQ(1u, clock.WallNow().ToUNIXSeconds());
EXPECT_EQ(1000000u, clock.WallNow().ToUNIXMicroseconds());
epoll_server.AdvanceBy(5);
EXPECT_EQ(1000005,
(clock.ApproximateNow() - QuicTime::Zero()).ToMicroseconds());
EXPECT_EQ(1u, clock.WallNow().ToUNIXSeconds());
EXPECT_EQ(1000005u, clock.WallNow().ToUNIXMicroseconds());
epoll_server.AdvanceBy(10 * 1000000);
EXPECT_EQ(11u, clock.WallNow().ToUNIXSeconds());
EXPECT_EQ(11000005u, clock.WallNow().ToUNIXMicroseconds());
}
TEST(QuicEpollClockTest, NowInUsec) {
MockEpollServer epoll_server;
QuicEpollClock clock(&epoll_server);
epoll_server.set_now_in_usec(1000000);
EXPECT_EQ(1000000, (clock.Now() - QuicTime::Zero()).ToMicroseconds());
epoll_server.AdvanceBy(5);
EXPECT_EQ(1000005, (clock.Now() - QuicTime::Zero()).ToMicroseconds());
}
} // namespace test
} // namespace net
|
; ---------------------------------------------------------------------------
; Object 30 - large green glass blocks (MZ)
; ---------------------------------------------------------------------------
GlassBlock:
moveq #0,d0
move.b obRoutine(a0),d0
move.w Glass_Index(pc,d0.w),d1
jsr Glass_Index(pc,d1.w)
out_of_range Glass_Delete
bra.w DisplaySprite
; ===========================================================================
Glass_Delete:
bra.w DeleteObject
; ===========================================================================
Glass_Index: dc.w Glass_Main-Glass_Index
dc.w Glass_Block012-Glass_Index
dc.w Glass_Reflect012-Glass_Index
dc.w Glass_Block34-Glass_Index
dc.w Glass_Reflect34-Glass_Index
glass_dist: equ $32 ; distance block moves when switch is pressed
glass_parent: equ $3C ; address of parent object
Glass_Vars1: dc.b 2, 0, 0 ; routine num, y-axis dist from origin, frame num
dc.b 4, 0, 1
Glass_Vars2: dc.b 6, 0, 2
dc.b 8, 0, 1
; ===========================================================================
Glass_Main: ; Routine 0
lea (Glass_Vars1).l,a2
moveq #1,d1
move.b #$48,obHeight(a0)
cmpi.b #3,obSubtype(a0) ; is object type 0/1/2 ?
bcs.s @IsType012 ; if yes, branch
lea (Glass_Vars2).l,a2
moveq #1,d1
move.b #$38,obHeight(a0)
@IsType012:
movea.l a0,a1
bra.s @Load ; load main object
; ===========================================================================
@Repeat:
bsr.w FindNextFreeObj
bne.s @Fail
@Load:
move.b (a2)+,obRoutine(a1)
move.b #id_GlassBlock,0(a1)
move.w obX(a0),obX(a1)
move.b (a2)+,d0
ext.w d0
add.w obY(a0),d0
move.w d0,obY(a1)
move.l #Map_Glass,obMap(a1)
move.w #$C38E,obGfx(a1)
move.b #4,obRender(a1)
move.w obY(a1),$30(a1)
move.b obSubtype(a0),obSubtype(a1)
move.b #$20,obActWid(a1)
move.b #4,obPriority(a1)
move.b (a2)+,obFrame(a1)
move.l a0,glass_parent(a1)
dbf d1,@Repeat ; repeat once to load "reflection object"
move.b #$10,obActWid(a1)
move.b #3,obPriority(a1)
addq.b #8,obSubtype(a1)
andi.b #$F,obSubtype(a1)
@Fail:
move.w #$90,glass_dist(a0)
bset #4,obRender(a0)
Glass_Block012: ; Routine 2
bsr.w Glass_Types
move.w #$2B,d1
move.w #$48,d2
move.w #$49,d3
move.w obX(a0),d4
bra.w SolidObject
; ===========================================================================
Glass_Reflect012:
; Routine 4
movea.l $3C(a0),a1
move.w glass_dist(a1),glass_dist(a0)
bra.w Glass_Types
; ===========================================================================
Glass_Block34: ; Routine 6
bsr.w Glass_Types
move.w #$2B,d1
move.w #$38,d2
move.w #$39,d3
move.w obX(a0),d4
bra.w SolidObject
; ===========================================================================
Glass_Reflect34:
; Routine 8
movea.l $3C(a0),a1
move.w glass_dist(a1),glass_dist(a0)
move.w obY(a1),$30(a0)
bra.w Glass_Types
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
Glass_Types:
moveq #0,d0
move.b obSubtype(a0),d0
andi.w #7,d0
add.w d0,d0
move.w Glass_TypeIndex(pc,d0.w),d1
jmp Glass_TypeIndex(pc,d1.w)
; End of function Glass_Types
; ===========================================================================
Glass_TypeIndex:dc.w Glass_Type00-Glass_TypeIndex
dc.w Glass_Type01-Glass_TypeIndex
dc.w Glass_Type02-Glass_TypeIndex
dc.w Glass_Type03-Glass_TypeIndex
dc.w Glass_Type04-Glass_TypeIndex
; ===========================================================================
Glass_Type00:
rts
; ===========================================================================
Glass_Type01:
move.b (v_oscillate+$12).w,d0
move.w #$40,d1
bra.s loc_B514
; ===========================================================================
Glass_Type02:
move.b (v_oscillate+$12).w,d0
move.w #$40,d1
neg.w d0
add.w d1,d0
loc_B514:
btst #3,obSubtype(a0)
beq.s loc_B526
neg.w d0
add.w d1,d0
lsr.b #1,d0
addi.w #$20,d0
loc_B526:
bra.w loc_B5EE
; ===========================================================================
Glass_Type03:
btst #3,obSubtype(a0)
beq.s loc_B53E
move.b (v_oscillate+$12).w,d0
subi.w #$10,d0
bra.w loc_B5EE
; ===========================================================================
loc_B53E:
btst #3,obStatus(a0)
bne.s loc_B54E
bclr #0,$34(a0)
bra.s loc_B582
; ===========================================================================
loc_B54E:
tst.b $34(a0)
bne.s loc_B582
move.b #1,$34(a0)
bset #0,$35(a0)
beq.s loc_B582
bset #7,$34(a0)
move.w #$10,$36(a0)
move.b #$A,$38(a0)
cmpi.w #$40,glass_dist(a0)
bne.s loc_B582
move.w #$40,$36(a0)
loc_B582:
tst.b $34(a0)
bpl.s loc_B5AA
tst.b $38(a0)
beq.s loc_B594
subq.b #1,$38(a0)
bne.s loc_B5AA
loc_B594:
tst.w glass_dist(a0)
beq.s loc_B5A4
subq.w #1,glass_dist(a0)
subq.w #1,$36(a0)
bne.s loc_B5AA
loc_B5A4:
bclr #7,$34(a0)
loc_B5AA:
move.w glass_dist(a0),d0
bra.s loc_B5EE
; ===========================================================================
Glass_Type04:
btst #3,obSubtype(a0)
beq.s Glass_ChkSwitch
move.b (v_oscillate+$12).w,d0
subi.w #$10,d0
bra.s loc_B5EE
; ===========================================================================
Glass_ChkSwitch:
tst.b $34(a0)
bne.s loc_B5E0
lea (f_switch).w,a2
moveq #0,d0
move.b obSubtype(a0),d0 ; load object type number
lsr.w #4,d0 ; read only the first nybble
tst.b (a2,d0.w) ; has switch number d0 been pressed?
beq.s loc_B5EA ; if not, branch
move.b #1,$34(a0)
loc_B5E0:
tst.w glass_dist(a0)
beq.s loc_B5EA
subq.w #2,glass_dist(a0)
loc_B5EA:
move.w glass_dist(a0),d0
loc_B5EE:
move.w $30(a0),d1
sub.w d0,d1
move.w d1,obY(a0)
rts
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.