files
Table/modules/DISPLAY.ASM
Mikhail Frolov b3981d174a Table: All editor code files have been added from the flash drive.
The start date of development is September 12, 2024.
2025-03-30 22:56:32 +05:00

195 lines
4.3 KiB
NASM

;
; Тестовый модуль для вывода на "дисплей"
format MS COFF
public @EXPORT as 'EXPORTS'
include "macros.inc"
;include "proc32.inc"
include "modules_api.inc"
struct MODULE_CONTEXT
display_buff dd ?
rb 64 - 4
namespace rb 64
cmdline rb 64
ends
section 'Doczom' code readable align 16
; Public functions
; IN: [esp + 4] = imports
; [esp + 8] -> cmdline
; [esp + 12] -> namespace
; OUT: eax - pdata
init:
push esi edi ebx ebp
; load table_lib.obj
;int3
; table_exports_t
mov ecx, sizeof.table_exports_t/4
mov edi, IMPORT_DATA
mov esi, [esp + 4*4 + 4]
rep movsd
; alloc context
mcall 68, 12, sizeof.MODULE_CONTEXT
test eax, eax
jz .err_mem
mov ebp, eax
; find display_d demon
mcall 68, 22, SHARED_NAME, 16*2, 1
test eax, eax
jnz @f ; error open display
mcall 68, 13, ebp
xor eax, eax
jmp .err_mem
@@:
mov [ebp + MODULE_CONTEXT.display_buff], eax
; copy namespace
mov esi, [esp + 4*4 + 12]
lea edi, [ebp + MODULE_CONTEXT.namespace]
@@:
movsb
cmp byte[edi - 1], 0
jnz @b
; copy cmdline
mov dword[ebp + MODULE_CONTEXT.cmdline],0
cmp dword[esp + 4*4 + 8], 0
jz .exit
mov esi, [esp + 4*4 + 8]
lea edi, [ebp + MODULE_CONTEXT.cmdline]
@@:
movsb
cmp byte[edi - 1], 0
jnz @b
lea esi, [ebp + MODULE_CONTEXT.cmdline]
mov edi, [ebp + MODULE_CONTEXT.display_buff]
mov eax, ' '
mov ecx, 8
rep stosd
mov edi, [ebp + MODULE_CONTEXT.display_buff]
xor ecx, ecx
@@:
cmp byte[esi], 0
je @f
movsb
jmp @b
@@:
.exit:
mov eax, ebp
.err_mem:
pop ebp ebx edi esi
ret 12
; IN: [esp + 4] = pdata
close:
push ebx
; free context
mcall 68, 13, [esp + 4 + 4]
pop ebx
ret 4
; IN: [esp + 4] = pdata
; OUT: eax = import_formula_t*
formulas:
;int3
mov eax, formulas_list
ret 4
; IN: [esp + 4] = pdata
; OUT: eax = import_format_t*
formats:
;int3
mov eax, formats_list
ret 4
; IN: [esp + 4] = pdata
; [esp + 8] = id output
; [esp + 12] = ptr array is inputs
; OUT: eax = error code: 0 - good
; -1 - unknow error
display_out_num:
ret 12
; IN: [esp + 4] = pdata
; [esp + 8] = id output
; [esp + 12] = ptr array is inputs
; OUT: eax = error code: 0 - good
; -1 - unknow error
display_out_str:
ret 12
; IN: [esp + 4] = pdata
; [esp + 8] = path to file
; [esp + 12] = table_dom*
; [esp + 16] = ptr params
; OUT: eax = error code: 0 - good
; -1 - unknow error
fdload:
; load file
; generate new table_dom
ret 16
; IN: [esp + 4] = pdata
; [esp + 8] = path to file
; [esp + 12] = table_dom*
; [esp + 16] = ptr params
; OUT: eax = error code: 0 - good
; -1 - unknow error
fdsave:
; function not supported
or eax, -1
ret 16
; Private functions
section '.data' data readable writable align 16
@EXPORT:
export \
init, 'tmodule_init',\
close, 'tmodule_close',\
formulas, 'tmodule_formulas',\
formats, 'tmodule_formats'
align 16
formulas_list:
dd display_out_num, .name_display_out_num
dd display_out_str, .name_display_out_str
dd 0, 0
.name_display_out_num:
db 'DisplayOutNum$d$d',0
.name_display_out_str:
db 'DisplayOutStr$d$s',0
align 16
; fd- format display
formats_list:
dd fdload, fdsave, fdassocc, 0
dd 0, 0, 0, 0
fdassocc:
dd .end - .start
.start:
db 'DTMODULE',0
.end:
db 0
; <header>
; a1 = header
; c1 = namespace.DisplayOutStr($a$1)
; a2 = input value
; c2 = namespace.DisplayOutNum($a$2)
;
SHARED_NAME: db 'DISPLAY_16_2_D',0
IMPORT_DATA table_exports_t