section .data
; Define the width and height of the image
width db 100
height db 100
; Define the starting x and y position of the line
x_start db 50
y_start db 50
; Define the angle and length of the line
angle dd 3.14159265358979 / 4
length dd 50
section .bss
; Reserve space for the image buffer
image_buffer resb width * height * 3
section .text
; The main function
global _start
_start:
; Load the angle and length into the x87 FPU
fld angle
fsin
fstp [sin_result]
fld angle
fcos
fstp [cos_result]
; Calculate the end position of the line
mov eax, [length]
fild eax
fmul dword [sin_result]
fistp [y_end]
mov eax, [length]
fild eax
fmul dword [cos_result]
fistp [x_end]
; Add the starting position to the end position to get the final end position
add [x_end], [x_start]
add [y_end], [y_start]
; Calculate the delta x and y
mov eax, [x_end]
sub eax, [x_start]
mov [delta_x], eax
mov eax, [y_end]
sub eax, [y_start]
mov [delta_y], eax
; Calculate the address of the starting pixel
mov ebx, image_buffer
add ebx, y_start * width * 3
add ebx, x_start * 3
; Draw the line
mov eax, [delta_x]
mov edx, [delta_y]
cmp eax, 0
jge .x_positive
neg eax
.x_positive:
cmp edx, 0
jge
Quote
Assume we have a drug test that tests for cannabis use. Now, this test has a 90% True Positive rate, that is, 90% of the time, it will detect a cannabis user. It also has an 80% True Negative rate, that is, 80% of the time it will confirm that a person has NOT used Cannabis. Unfortunately, it also generates 20% False Positives. Given that 5% of all people tested are cannabis users, what is the probability that a person who tests positive for cannabis using this test is truly a cannabis user? I'll give you a hint to get started, the first branch of your tree should be the cannabis users.
// KickSwitch -64 //-mem32 -32 -64 -run -dll (No Switch mean -mem32)
// KickEnd
uses Console
uses MinWin
uses Dialogs
%CREATE_NEW 1
%CREATE_ALWAYS 2
%OPEN_EXISTING 3
%OPEN_ALWAYS 4
%TRUNCATE_EXISTING 5
%FILE_FLAG_OVERLAPPED 0x40000000
%INFINITE 0xFFFFFFFF
%FORMAT_MESSAGE_FROM_SYSTEM 0X1000
%FORMAT_MESSAGE_ALLOCATE_BUFFER 0X100
%ERROR_IO_PENDING 997
%FILE_BEGIN 0
%FILE_CURRENT 1
%FILE_END 2
'struct OVERLAPPED{ // 32bit, 64bit
' sys internal // 4 bytes, 8 bytes (dword pointer)
' sys internalhigh // 4 bytes, 8 bytes (dword pointer)
' union{ // 8 bytes, 8 bytes
' struct{ // dummyStructName 8 bytes
' dword offset // 4 bytes, 4 bytes (dword)
' dword offsetHigh // 4 bytes, 4 bytes (dword)
' }
' sys pointer // 4 bytes, 8 bytes <- 4 bytes in 32bit but the 8 bytes union will pad it (void pointer)
' } //
' sys hevent // 4 bytes, 8 bytes (handle)
'}
struct OVERLAPPED{ 'simplified
sys Internal
sys InternalHigh
dword Offset
dword OffsetHigh
sys hEvent
}
'_____________________________________________________________________________
SetConsoleTitle "overlapped structure"
long BitNess = sizeof(sys) * 8
printl "bitness = " BitNess "bit"
printl
dword WrittenCount = 0
string sFileName = "overlapped.txt"
string sFileData = "filedata"
overlapped overlapp
overlapp.offset = 8
'overlapp.hevent = CreateEvent(BYVAL 0, %FALSE, %FALSE, "") '"someEvent")
sys hFile = CreateFile(sFileName, %GENERIC_READ OR %GENERIC_WRITE, %FILE_SHARE_READ, 0,
%OPEN_ALWAYS, %FILE_ATTRIBUTE_NORMAL | %FILE_FLAG_OVERLAPPED, 0)
If hFile <> %INVALID_HANDLE_VALUE
if WriteFile(hFile, sFileData, LEN(sFileData), @WrittenCount, @overlapp) = 0 'nzok
GetOverlappedResult(hFile, @overlapp, @WrittenCount, %true) 'nzok
endif
CloseHandle(hFile)
printl "WrittenCount " str(WrittenCount)
end if
'WaitForSingleObject(overlapp.hevent, %INFINITE) '2000) '%INFINITE)
printl
printl "check the file " chr(34) sFileName chr(34)
printl
printl "any key to end"
waitkey
end
'_____________________________________________________________________________
'
// KickSwitch -64 //-mem32 -32 -64 -run -dll (No Switch mean -mem32)
// KickEnd
// C++ typedef struct _OVERLAPPED {
// C++ ULONG_PTR Internal;
// C++ ULONG_PTR InternalHigh;
// C++ union {
// C++ struct {
// C++ DWORD Offset;
// C++ DWORD OffsetHigh;
// C++ } DUMMYSTRUCTNAME;
// C++ PVOID Pointer;
// C++ } DUMMYUNIONNAME;
// C++ HANDLE hEvent;
// C++ } OVERLAPPED, *LPOVERLAPPED;
struct OVERLAPPED{ // 32bit, 64bit
dword *internal // 4 bytes, 8 bytes (dword pointer)
dword *internalhigh // 4 bytes, 8 bytes (dword pointer)
union{ // 8 bytes, 8 bytes
struct{ // dummyStructName 8 bytes
dword offset // 4 bytes, 4 bytes (dword)
dword offsetHigh // 4 bytes, 4 bytes (dword)
}
void *pointer // 4 bytes, 8 bytes <- 4 bytes in 32bit but the 8 bytes union will pad it (void pointer)
} //
sys hevent // 4 bytes, 8 bytes (handle)
}
include once "D:\Dev\Oxygen\o2\inc\console.inc"
'_____________________________________________________________________________
SetConsoleTitle "overlapped structure"
long BitNess = sizeof(sys) * 8
printl
printl "in 32bit overlapped = 20 bytes"
printl "in 64bit overlapped = 32 bytes"
printl
printl "overlapped size = " sizeof(OVERLAPPED) " bytes"
printl "bitness = " BitNess "bit"
printl
overlapped ov
@ov.internal = 10
printl "ov.internal = " @ov.internal
@ov.internalhigh = 20
printl "ov.internalhigh = " @ov.internalhigh
@ov.pointer = 30
printl "ov.pointer = " @ov.pointer
ov.offset = 31
printl "ov.offset = " ov.offset
ov.offsetHigh = 32
printl "ov.offsetHigh = " ov.offsetHigh
ov.hevent = 40
printl "ov.hevent = " ov.hevent
printl
printl "any key to end"
waitkey
end
'_____________________________________________________________________________
'
// KickSwitch -64 //-mem32 -32 -64 -run -dll (No Switch mean -mem32)
// KickEnd
// C++ typedef struct _OVERLAPPED {
// C++ ULONG_PTR Internal;
// C++ ULONG_PTR InternalHigh;
// C++ union {
// C++ struct {
// C++ DWORD Offset;
// C++ DWORD OffsetHigh;
// C++ } DUMMYSTRUCTNAME;
// C++ PVOID Pointer;
// C++ } DUMMYUNIONNAME;
// C++ HANDLE hEvent;
// C++ } OVERLAPPED, *LPOVERLAPPED;
struct OVERLAPPED{ // 32bit, 64bit
sys internal // 4 bytes, 8 bytes (dword pointer)
sys internalhigh // 4 bytes, 8 bytes (dword pointer)
union{ // 8 bytes, 8 bytes
struct{ // dummyStructName 8 bytes
dword offset // 4 bytes, 4 bytes (dword)
dword offsetHigh // 4 bytes, 4 bytes (dword)
}
sys pointer // 4 bytes, 8 bytes <- 4 bytes in 32bit but the 8 bytes union will pad it (void pointer)
} //
sys hevent // 4 bytes, 8 bytes (handle)
}
include once "D:\Dev\Oxygen\o2\inc\console.inc"
'_____________________________________________________________________________
SetConsoleTitle "overlapped structure"
long BitNess = sizeof(sys) * 8
printl
printl "in 32bit overlapped = 20 bytes"
printl "in 64bit overlapped = 32 bytes"
printl
printl "overlapped size = " sizeof(OVERLAPPED) " bytes"
printl "bitness = " BitNess "bit"
printl
overlapped ov
ov.internal = 10
printl "ov.internal = " ov.internal
ov.internalhigh = 20
printl "ov.internalhigh = " ov.internalhigh
ov.pointer = 30
printl "ov.pointer = " ov.pointer
ov.offset = 31
printl "ov.offset = " ov.offset
ov.offsetHigh = 32
printl "ov.offsetHigh = " ov.offsetHigh
ov.hevent = 40
printl "ov.hevent = " ov.hevent
printl
printl "any key to end"
waitkey
end
'_____________________________________________________________________________
'
Page created in 0.322 seconds with 14 queries.