r/transprogrammer • u/EggyTheEgghog '); DROP TABLE genders; -- • Aug 31 '21
Abolish compilation!
334
Upvotes
r/transprogrammer • u/EggyTheEgghog '); DROP TABLE genders; -- • Aug 31 '21
41
u/RollerSkatingHoop Aug 31 '21
I mean, that's hex
5
u/EggyTheEgghog '); DROP TABLE genders; -- Sep 02 '21
In case you're wondering, the code is an 8086/8088 code for MS-DOS which prints out "TRANS RIGHTS!\r\n".
The instructions (and their explanations) are as follows:
MS-DOS uses 0x21 interrupt to store some of its functions, which can be accessed individually by setting ah to a specific value and then executing 'int 0x21'. The ones I'm going to use are printing a string to the screen (ah = 0x09) and exiting the program (ah = 0x4c).
B4 09 - mov ah, 0x09
The function which prints a string to the screen requires the address of the beginning of the string to be stored in ds:dx. I'm aiming to make my code position independent, and since I'm storing my string next to the code, and the address to the currently executed instruction is stored at cs:ip, that's what I can set ds:dx to, and then add a specific offset (which I calculated to be 0x0b) to dx so that it points to the string.
0E - push cs
1F - push ds
The call instruction uses a 16-bit offset provided by the parameter added to the IP register to calculate the address to jump to. I'm using an offset 0x0000 to make the call instruction safely jump to the next instruction and store the address to the next instruction in stack. How convenient!
E8 00 00 - call <ip>
5A - pull dx
83 C2 0B - add dx, 0x0b
CD 21 - int 0x21
The function that makes the program exit requires a return code stored in al. Of course, I'm going to use return code 0 to indicate success.
B8 00 4C - mov ax, 0x4c00
CD 21 - int 0x21
Exiting the program is necessary so that the string isn't executed as code.
Oh, and the string needs to be terminated by the dollar sign, that why it's the last character. It doesn't actually get printed to the screen.
14
u/Andykolski black Aug 31 '21 edited Aug 31 '21
What architecture is the machine code for? I tried my hand at disassembling it and had limited success. My best guess is that it prints the string "!TRANS RIGHTS!" based purely on that the string is embedded in the middle of the code.
Here is the results of running
hexdump -Con it if anyone would find that useful00000000 b4 09 0e 1f e8 00 00 5a 83 c2 0b cd 21 b8 00 4c |.......Z....!..L|00000010 cd 21 54 52 41 4e 53 20 52 49 47 48 54 53 21 0d |.!TRANS RIGHTS!.|00000020 0a 24 |.$|1
u/Mwarw Mar 06 '22
are non-binary people.... text-people