Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Моргает светодиодами 6 раз
- ; 30 June 2024
- ;**************************** ******************
- .org 5h
- ld A, 7
- ld (0053h), A
- ld BC, (0053h)
- L_01:
- dec A
- OUT (C), A
- cp 0
- jp NZ, L_01
- ; Пример вызова функции, которая суммирует 2 аргумента
- ; 12 December 2023
- ;**************************** The main program.
- .org 4h
- LD H, 5
- LD L, 2
- LD SP, 00ffh
- push HL
- LD HL, 65535
- call foo
- xor A
- inc B
- dec c
- .end
- ;- - - - - - - - - - - - - - int add(int, int);
- .org 50h
- foo: pop DE
- pop BC
- LD A, C
- ADD A, B
- push DE
- ret
- .end
- format PE console
- entry start
- include 'win32ax.inc'
- include 'api\kernel32.inc'
- ;------------------------------------------------ Создание переменных:
- section '.data' data readable writeable
- n dd 99 ; Переменная n (4 байта)
- sz_Hello db 'Hello world ! n = %d', 10, 10, 0
- ;------------------------------------------------ Код программы:
- section '.code' code readable executable
- start: mov eax, 0 ; 65536
- mov ax, 21
- mov bx, 36
- push ax
- push bx
- call foo_1
- L_03 : cinvoke printf, <"eax = %3d ", 10, 0>, eax
- L_04 : cinvoke scanf, <"%d", 10, 0>, n
- invoke ExitProcess, 0
- ;------------------------------------------------ Подключение библиотек:
- section '.idata' import data readable
- library kernel32, 'kernel32.dll',\
- msvcrt, 'msvcrt.dll'
- import msvcrt,\
- printf, 'printf',\
- scanf, 'scanf'
- ;/////////////////////////////////////////////////
- foo_1: pop ecx
- pop ax
- pop bx
- add ax, bx
- push ecx
- ret
- ; Старая версия (устаревшая
- ;**************************** **************************** ****************************
- .org 4h
- LD C, 5
- LD B, 2
- LD SP, 0099h
- push BC
- LD BC, 0
- call L_2
- LD (00A7h), A
- LD bc,(00A7h)
- L_1: OUT (C), A
- inc A
- cp 33h ; = 51
- JP NZ, L_1
- LD A, C
- LD (0001h), A
- ;**************************** procedure
- .org 50h
- L_2: pop DE
- pop BC
- LD A, C
- ADD A, B
- push DE
- ret
- .end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement