Skip to content

Instantly share code, notes, and snippets.

@ShawnHuang
Created April 27, 2016 14:27
Show Gist options
  • Save ShawnHuang/ed6d086051f3a0828ab0ac11406fb4fa to your computer and use it in GitHub Desktop.
Save ShawnHuang/ed6d086051f3a0828ab0ac11406fb4fa to your computer and use it in GitHub Desktop.
test
1. offset vs addr ?
"有同學說他 invoke 也可以用 offset"
我的想法:
array 的位址一開始就配置在 data segment,位址是固定的,所以可以用 offset 來取值
var1 是執行時期才配置出來的記憶體空間,所以要透過 addr 來計算位址。
INCLUDE irvine32.inc
.stack 4096
findNum proto num: PTR dword
find proto num:PTR dword
.data
array dword 2,3,4
.code
main proc
; it's fine here.
invoke findNum, offset array
call WaitMsg
exit
main endp
findNum proc num:PTR dword
LOCAL var1:dword
mov var1, 1
; error if we pass `offset var1` to procedure
invoke find, addr var1
ret
findNum endp
find proc num:PTR dword
ret
find endp
end main
2. procedure 參數的 ptr 可加或可不加?(這題我是聽轉述,聽起來意思是這樣子)
我的想法:
sdword的大小是 32 bit,剛好是位址的大小,所以不加 PTR 程式不會出錯
但是全部型別改成 byte ,程式就會編譯錯誤
INCLUDE irvine32.inc
.stack 4096
findNum proto num:PTR sdword
find proto num:sdword
.data
array sdword 2,3,4
.code
main proc
invoke findNum, addr array
invoke find, addr array
call WaitMsg
exit
main endp
findNum proc num: PTR sdword
mov eax, num
mov ebx, -1
mov ebx, [eax]
mov ebx, [eax+4]
ret
findNum endp
find proc num:sdword
mov ebx, -1
mov ebx, num
mov ebx, [eax]
mov ebx, [eax+4]
ret
find endp
end main
3. sdword vs dword 在那些地方有差異?
我自己執行了下面程式碼
兩次 cmp 的結果都相同
OV = 0 UP = 0 EI = 1 PL = 1 ZR = 0 AC = 0 PE = 1 CY = 0
但是
有號數會用對應的指令 jg
無號數會用對應的指令 ja
但是硬調換好像也是可以?這邊我不確定!
.data
array sdword -1,3,4
array2 dword -1,3,4
.code
main proc
mov eax, [array]
mov ebx, [array+4]
cmp eax, ebx
jg L1
mov eax, [array2]
mov ebx, [array2+4]
cmp eax, ebx
ja L1
call WaitMsg
main endp
4. ret vs ret 8
為什麼實驗課的程式不用 ret 8
我的想法:
直接看反組譯結果,組譯過程中有把 ret 轉成 ret 8
FindLargest proc, aPtr:PTR SDWORD, arraySize:DWORD
...
ret
find endp
@ShawnHuang
Copy link
Author

==7513== Conditional jump or move depends on uninitialised value(s)
==7513== at 0x456A7E: tld::Clustering::cluster(float_, int_) (Clustering.cpp:174)
==7513== by 0x4568AE: tld::Clustering::clusterConfidentIndices() (Clustering.cpp:115)
==7513== by 0x453FB4: tld::DetectorCascade::detect(cv::Mat const&, fast_detection_str_, bool) (DetectorCascade.cpp:449)
==7513== by 0x44B9A9: tld::TLD::processImage(cv::Mat const&) (TLD.cpp:248)
==7513== by 0x44B82E: tld::TLD::process(cv::Mat const&) (TLD.cpp:213)
==7513== by 0x4472A8: Main::doWork() (Main.cpp:78)
==7513== by 0x4454D8: main (OpenTLD.cpp:58)
==7513==
==7513== Conditional jump or move depends on uninitialised value(s)
==7513== at 0x455924: tld::EnsembleClassifier::calcFernFeaturePatch(unsigned char const_, int, int) (EnsembleClassifier.cpp:217)
==7513== by 0x45598F: tld::EnsembleClassifier::calcFeatureVectorPatch(unsigned char const_, int, int_) (EnsembleClassifier.cpp:230)
==7513== by 0x44CBE6: tld::TLD::learn() (TLD.cpp:539)
==7513== by 0x44B9C1: tld::TLD::processImage(cv::Mat const&) (TLD.cpp:254)
==7513== by 0x44B82E: tld::TLD::process(cv::Mat const&) (TLD.cpp:213)
==7513== by 0x4472A8: Main::doWork() (Main.cpp:78)
==7513== by 0x4454D8: main (OpenTLD.cpp:58)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment