Передача аргументов функции в JavaScript аналогична передаче параметров по значению указателя в C:
/*
The following C program demonstrates how arguments
to JavaScript functions are passed in a way analogous
to pass-by-pointer-value in C. The original JavaScript
test case by @Shog9 follows with the translation of
the code into C. This should make things clear to
those transitioning from C to JavaScript.
function changeStuff(num, obj1, obj2)
{
num = num * 10;
obj1.item = "changed";
obj2 = {item: "changed"};
}
var num = 10;
var obj1 = {item: "unchanged"};
var obj2 = {item: "unchanged"};
changeStuff(num, obj1, obj2);
console.log(num);
console.log(obj1.item);
console.log(obj2.item);
This produces the output:
10
changed
unchanged
*/
#include <stdio.h>
#include <stdlib.h>
struct obj {
char *item;
};
void changeStuff(int *num, struct obj *obj1, struct obj *obj2)
{
// make pointer point to a new memory location
// holding the new integer value
int *old_num = num;
num = malloc(sizeof(int));
*num = *old_num * 10;
// make property of structure pointed to by pointer
// point to the new value
obj1->item = "changed";
// make pointer point to a new memory location
// holding the new structure value
obj2 = malloc(sizeof(struct obj));
obj2->item = "changed";
free(num); // end of scope
free(obj2); // end of scope
}
int num = 10;
struct obj obj1 = { "unchanged" };
struct obj obj2 = { "unchanged" };
int main()
{
// pass pointers by value: the pointers
// will be copied into the argument list
// of the called function and the copied
// pointers will point to the same values
// as the original pointers
changeStuff(&num, &obj1, &obj2);
printf("%d\n", num);
puts(obj1.item);
puts(obj2.item);
return 0;
}
На машине «DOS» просмотрите Программный прерывание 0x33 . Команда AH = 0x03 возвращает кнопку мыши, нажатую в регистре CX (вместе с координатами мыши и другой информацией, в других регистрах).
Если доступно, конечно, намного проще пользователю Windows API для этой цели , как указано в ответе Маджи.
Если вы создаете программу DOS, которая работает под окнами, вы можете использовать программное прерывание 0x33, функцию 3, которое возвращает статус кнопки в регистре BL:
mov ax,0x3 int 0x33 test bl,1 jnz left_button_pressed test bl,2 jnz right_button_pressed
Подробнее здесь http://www.ctyme.com/intr/rb-5959.htm
Если вы создаете собственное приложение Windows, вы можете протестировать нажатия кнопок, проверив стандартные сообщения мыши (WM_LBUTTONDOWN / UP, WM_RBUTTONDOWN / UP, WM_MBUTTONDOWN / UP) переданы вашему зарегистрированному WndProc для главного окна, созданного вашей программой.
Объявление функции для WndProc - «LRESULT CALLBACK WindowProc ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); "тип сообщения передается в uMsg, поэтому вы должны проверить DWORD в [esp + 12] и сравнить его с идентификатором сообщения, который хотите обработать.