- 1
https://github.com/pustladi/MS-DOS-v.1.1
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−2
https://github.com/pustladi/MS-DOS-v.1.1
давайте обсуждать сырцуы доса
−1
format pe gui 5.0
include 'win32ax.inc'
_title db 'stackvar',0
_class db '#32770',0
entry $
sub esp,32
mov esi,esp
xor edi,edi
mov ecx,$80000000
mov eax,WS_VISIBLE+WS_OVERLAPPEDWINDOW
invoke CreateWindowEx,edi,_class,edi,eax,ecx,ecx,ecx,ecx,edi,edi,edi,edi
mov ebx,eax
invoke SetWindowLong,ebx,GWL_WNDPROC,wnd_proc
mov [esi],eax
invoke SetWindowLong,ebx,GWL_USERDATA,esi
invoke SendMessage,ebx,WM_INITDIALOG,edi,edi
sub esp,32
mov ebx,esp
msg_loop:
invoke GetMessage,ebx,edi,edi,edi
cmp eax,1
jb app_exit
jne msg_loop
invoke DispatchMessage,ebx
jmp msg_loop
wnd_proc:
mov eax,[esp+8]
cmp eax,WM_INITDIALOG
je app_init
cmp eax,WM_CLOSE
je app_exit
mov eax,[esp+4]
invoke GetWindowLong,eax,GWL_USERDATA
pop edx
push dword [eax]
push edx
jmp [CallWindowProc]
app_init:
mov eax,[esp+4]
invoke SendMessage,eax,WM_SETTEXT,0,_title
xor eax,eax
ret
app_exit:
invoke ExitProcess,edi
data import
library\
kernel32,'kernel32.dll',\
user32,'user32.dll'
include 'api\kernel32.inc'
include 'api\user32.inc'
end data
Извращениям нет предела!
Переменные будем хранить в стэке)
−3
format pe gui 5.0
include 'win32ax.inc'
_title db '1Kbyte window',0
_class db '#32770',0
old_wndproc dd 0
entry $
xor edi,edi
mov ecx,$80000000
mov esi,$400000
mov eax,WS_VISIBLE+WS_OVERLAPPEDWINDOW
invoke CreateWindowEx,edi,_class,edi,eax,ecx,ecx,ecx,ecx,edi,edi,edi,edi
mov ebx,eax
invoke SetWindowLong,ebx,GWL_WNDPROC,wnd_proc
mov [old_wndproc],eax
invoke SendMessage,ebx,WM_INITDIALOG,edi,edi
sub esp,32
mov ebx,esp
msg_loop:
invoke GetMessage,ebx,edi,edi,edi
cmp eax,1
jb app_exit
jne msg_loop
invoke DispatchMessage,ebx
jmp msg_loop
wnd_proc:
mov eax,[esp+8]
cmp eax,WM_INITDIALOG
je app_init
cmp eax,WM_CLOSE
je app_exit
pop eax
push [old_wndproc]
push eax
jmp [CallWindowProc]
app_init:
mov eax,[esp+4]
invoke SendMessage,eax,WM_SETTEXT,0,_title
xor eax,eax
ret
app_exit:
invoke ExitProcess,edi
data import
library\
kernel32,'kernel32.dll',\
user32,'user32.dll'
include 'api\kernel32.inc'
include 'api\user32.inc'
end data
Приветствуем!
Вот это говнокод однако?
...
0
format pe console 5.0
entry start
include 'win32ax.inc'
SLEEP=1000
section '.data' data readable
_hello db 'Hello "https://www.govnokod.ru/"!',13,10,0
_conout db 'CONOUT$',0
align 8
_conoutnt du '\??\CONOUT$',0
section '.data?' data readable writeable
bytes_write dd ?
houtput dd ?
length dd ?
section '.text' code readable executable
start:
call _novice
invoke Sleep,SLEEP
call _advanced
invoke Sleep,SLEEP
call _psycho
invoke Sleep,SLEEP
invoke ExitProcess,0
_novice:
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov [houtput],eax
invoke lstrlen,_hello
mov [length],eax
invoke WriteConsole,[houtput],_hello,[length],bytes_write,0
ret
_advanced:
invoke CreateFileA,_conout,GENERIC_WRITE,0,0,OPEN_EXISTING,0,0
mov [houtput],eax
invoke lstrlen,_hello
mov [length],eax
invoke WriteFile,[houtput],_hello,[length],bytes_write,0
invoke CloseHandle,[houtput]
ret
_psycho:
push ebx
sub esp,40
mov ebx,esp
mov word[ebx+24],22
mov word[ebx+26],24
mov dword[ebx+28],_conoutnt
mov dword[ebx+0],24
mov dword[ebx+4],0
lea eax,[ebx+24]
mov dword[ebx+8],eax
mov dword[ebx+12],$00000040
mov dword[ebx+16],0
mov dword[ebx+20],0
lea eax,[ebx+32]
invoke NtCreateFile,houtput,$40100080,ebx,eax,0,0,0,1,$60,0,0
invoke lstrlen,_hello
mov [length],eax
lea eax,[ebx+32]
invoke NtWriteFile,[houtput],0,0,0,eax,_hello,[length],0,0
invoke NtClose,[houtput]
add esp,40
pop ebx
ret
section '.import' data import readable
library\
ntdll,'ntdll.dll',\
kernel32,'kernel32.dll'
import ntdll,\
NtClose,'NtClose',\
NtCreateFile,'NtCreateFile',\
NtWriteFile,'NtWriteFile'
include 'api\kernel32.inc'
section '.reloc' fixups data readable discardable
Интересно какой из методов (_novice, _advanced, _psycho) вывода в консоль является говнокодом?
−101
жопаembler — гниль
−2
execute = 0
i = 100
while i < $
load a byte from i
if a = 0xc3
execute = i
i = $
else
i = i + 1
end if
end while
if execute = 0
display "ret not found", 13, 10
execute = $
ret
end if
Прежде чем объявлять подпрограмму, тсарь пройдётся по уже собранному коду в поисках нужных ему байт.
+2
https://www.researchgate.net/publication/325358150_cQASM_v10_Towards_a_Common_Quantum_Assembly_Language
cQASM v1.0: Towards a Common Quantum Assembly Language
The quantum assembly language (QASM) is a popular intermediate representation used in many quantum compilation and simulation tools to describe quantum circuits. Currently, multiple different dialects of QASM are used in different quantum computing tools. This makes the interaction between those tools tedious and time-consuming due to the need for translators between theses different syntaxes. Beside requiring a multitude of translators, the translation process exposes the constant risk of loosing information due to the potential incompatibilities between the different dialects. Moreover, several tools introduce details of specific target hardware or qubit technologies within the QASM syntax and prevent porting the code to other hardwares. In this paper, we propose a common QASM syntax definition, named cQASM, which aims to abstract away qubit technology details and guarantee the interoperability between all the quantum compilation and simulation tools supporting this standard. Our vision is to enable an extensive quantum computing toolbox shared by all the quantum computing community.
Вот это я понимаю, а то вон там мелкософт какие-то говношарпы придумывает очередные:
https://docs.microsoft.com/en-us/quantum/language/?view=qsharp-preview
+2
/*
x86-64 clang (trunk) -O3
https://godbolt.org/z/t8NDGG
#include <inttypes.h>
uint32_t saturation_add(uint32_t a, uint32_t b)
{
const uint64_t tmp = (uint64_t)a + b;
if (tmp > UINT32_MAX)
{
return UINT32_MAX;
}
return tmp;
}
*/
saturation_add:
mov edx, esi
mov eax, edi
add edi, esi
add rax, rdx
mov edx, 4294967295
cmp rax, rdx
mov eax, -1 // ЗАЧЕМ???
cmovbe eax, edi
ret
https://en.wikipedia.org/wiki/Saturation_arithmetic
Почему компиляторы до сих пор такое говно
0
DEF "PARSE", 0, PARSE
MOV SI, [VAR_TO_IN]
MOV CX, [VAR_NTIB]
SUB CX, SI
ADD SI, [VAR_TIB]
SUB BP, 2
MOV [BP], SI
REPNE SCASB
SUB CX, [VAR_NTIB]
NOT CX
MOV [VAR_TO_IN], CX
MOV AX, SI
SUB AX, [BP]
DEC AX
RET
СУКА! УЖЕ В КОТОРЫЙ РАЗ ЗАБЫВАЮ, ЧТО У SCAS ИСПОЛЬЗУЕТСЯ DI, А НЕ SI.
+1
MOV CX,4 ;All devices are 4 letters
REPE CMPSB ;Check for name in list
JZ IOCHK ;If first 3 letters OK, check for the rest
ADD SI,CX ;Point to next device name
Вроде не обсуждали код MS-DOS
https://github.com/Microsoft/MS-DOS