Initial commit
This commit is contained in:
commit
da0206b640
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build/*
|
||||
!build/.empty
|
||||
64
.vscode/isu.code-snippets
vendored
Normal file
64
.vscode/isu.code-snippets
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
||||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
||||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
||||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
||||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
||||
// Placeholders with the same ids are connected.
|
||||
// Example:
|
||||
// "Print to console": {
|
||||
// "scope": "javascript,typescript",
|
||||
// "prefix": "log",
|
||||
// "body": [
|
||||
// "console.log('$1');",
|
||||
// "$2"
|
||||
// ],
|
||||
// "description": "Log output to console"
|
||||
// }
|
||||
"ISU code snippet":{
|
||||
"prefix": "isu",
|
||||
"body": [
|
||||
"%include \"rw32-2022.inc\"\n",
|
||||
|
||||
"section .data\n",
|
||||
|
||||
"\t${1:; data}\n\n",
|
||||
|
||||
"section .text\n",
|
||||
|
||||
"CMAIN:",
|
||||
"\tpush ebp",
|
||||
"\tmov ebp,esp\n",
|
||||
"\t${3:sub esp,${4:local variables space}}\n",
|
||||
|
||||
"\t${5:; code}\n",
|
||||
|
||||
"\txor eax,eax",
|
||||
"\tmov esp,ebp",
|
||||
"\tpop ebp",
|
||||
"\tret",
|
||||
],
|
||||
"description": "File template for the ISU"
|
||||
},
|
||||
"ASM Function Body Snippet":{
|
||||
"prefix": "fun",
|
||||
"body": [
|
||||
"${1:function}:",
|
||||
"\tpush ebp",
|
||||
"\tmov ebp,esp",
|
||||
"\t${2:sub esp,${3:N bytes (for the local variables)}}\n",
|
||||
|
||||
"\t${4:; code of the function}\n",
|
||||
|
||||
"\tmov esp,ebp",
|
||||
"\tpop ebp",
|
||||
"\tret\n",
|
||||
],
|
||||
"description": "Template of the ASM function"
|
||||
},
|
||||
"ASM String Snippet":{
|
||||
"prefix": "str",
|
||||
"body": [ "${1:sName} db \"${2:string}\",0" ],
|
||||
"description": "Template of the ASM string definition"
|
||||
},
|
||||
}
|
||||
52
.vscode/launch.json
vendored
Normal file
52
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C/C++ (debug launch)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/${fileBasenameNoExtension}",
|
||||
"preLaunchTask": "LD-link",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Set Disassembly Flavor to Intel",
|
||||
"text": "-gdb-set disassembly-flavor intel",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ASM (debug launch)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/${fileBasenameNoExtension}.exe",
|
||||
"miDebuggerPath": "${workspaceFolder}/bin/gdb/bin/gdb.exe",
|
||||
"linux": {
|
||||
"program": "${workspaceFolder}/build/${fileBasenameNoExtension}",
|
||||
"miDebuggerPath": "gdb",
|
||||
"name": "ASM (debug launch)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch"
|
||||
},
|
||||
"preLaunchTask": "LD-link",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{ "text": "set disassembly-flavor intel" },
|
||||
{ "text": "-enable-pretty-printing" }
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
119
.vscode/tasks.json
vendored
Normal file
119
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "NASM-Compile",
|
||||
"command": "${workspaceFolder}/bin/nasm.exe",
|
||||
"args": [
|
||||
"-felf32",
|
||||
"-F", "dwarf",
|
||||
"-g",
|
||||
"-i", "${workspaceFolder}",
|
||||
"-o", "${workspaceFolder}/build/${fileBasenameNoExtension}.obj",
|
||||
"${file}"
|
||||
],
|
||||
"linux": {
|
||||
"command": "nasm",
|
||||
"args": [
|
||||
"-felf32",
|
||||
"-F", "dwarf",
|
||||
"-g",
|
||||
"-i", "${workspaceFolder}",
|
||||
"-o", "${workspaceFolder}/build/${fileBasenameNoExtension}.o",
|
||||
"${file}"
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"presentation": {
|
||||
"focus": true,
|
||||
"reveal": "silent",
|
||||
"revealProblems": "onProblem",
|
||||
"panel": "shared",
|
||||
},
|
||||
"problemMatcher": {
|
||||
"owner": "asm",
|
||||
"fileLocation": ["autodetect", "${workspaceFolder}"],
|
||||
"pattern": {
|
||||
"regexp": "^(.*):(\\d+):\\s+(warning|error|fatal):\\s+(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"severity": 3,
|
||||
"message": 4
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "LD-link",
|
||||
"command": "${workspaceFolder}/bin/ld/ld.exe",
|
||||
"args": [
|
||||
"-g",
|
||||
"-o", "${workspaceFolder}/build/${fileBasenameNoExtension}.exe",
|
||||
"-estart",
|
||||
"${workspaceFolder}/build/${fileBasenameNoExtension}.obj",
|
||||
"${workspaceFolder}/bin/ld/libmsvcrt.a",
|
||||
"${workspaceFolder}/bin/ld/libkernel32.a"
|
||||
],
|
||||
"linux": {
|
||||
"command": "gcc",
|
||||
"args": [
|
||||
"-m32",
|
||||
"-g",
|
||||
"-o", "${workspaceFolder}/build/${fileBasenameNoExtension}",
|
||||
"${workspaceFolder}/build/${fileBasenameNoExtension}.o"
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"dependsOn": [ "NASM-Compile" ],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": {
|
||||
"owner": "asm",
|
||||
"fileLocation": ["autodetect", "${workspaceFolder}"],
|
||||
"pattern": {
|
||||
"regexp": "^(.*):(\\d+):\\s+(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"message": 3
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"focus": true,
|
||||
"panel": "shared",
|
||||
"reveal": "silent",
|
||||
"revealProblems": "onProblem",
|
||||
"close": false,
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "gcc",
|
||||
"command": "gcc",
|
||||
"args": [
|
||||
"-g", "-m32", "-Og", "-O0",
|
||||
"-o", "${workspaceFolder}/build/${fileBasenameNoExtension}",
|
||||
"${workspaceFolder}/${fileBasename}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"group": "build",
|
||||
"problemMatcher": {
|
||||
"pattern": {
|
||||
"regexp": "error"
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"focus": true,
|
||||
"panel": "shared",
|
||||
"reveal": "silent",
|
||||
"revealProblems": "onProblem",
|
||||
"close": false,
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
0
build/.empty
Normal file
0
build/.empty
Normal file
39
cv.asm
Normal file
39
cv.asm
Normal file
@ -0,0 +1,39 @@
|
||||
%include "rw32-2022.inc"
|
||||
|
||||
segment .data
|
||||
|
||||
arr1 dt 1.0, -4.1, 1.1, 5.0
|
||||
|
||||
segment .text
|
||||
;float fn(const float *pArr, unsigned long N)
|
||||
THU-10: doplnit
|
||||
fn:
|
||||
enter 0,0
|
||||
mov esi,[ebp+8]
|
||||
mov ecx,[ebp+12]
|
||||
fldz
|
||||
.cykl:
|
||||
fld tword [esi]
|
||||
faddp st1,st0
|
||||
add esi,10
|
||||
loop .cykl
|
||||
leave
|
||||
fnop
|
||||
ret
|
||||
|
||||
CMAIN:
|
||||
sub esp,4
|
||||
fstcw [esp]
|
||||
and dword [esp],0xFFFFFFF0
|
||||
fldcw [esp]
|
||||
add esp,4
|
||||
push 4
|
||||
push arr1
|
||||
call fn
|
||||
add esp,8
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ret
|
||||
47
cv2.asm
Normal file
47
cv2.asm
Normal file
@ -0,0 +1,47 @@
|
||||
%include "rw32-2022.inc"
|
||||
|
||||
segment .data
|
||||
|
||||
arr1 dt 1.0, -4.1, 1.1, -5.0
|
||||
|
||||
segment .text
|
||||
|
||||
;cdecl float * getSorted(const long double *pArr, unsigned int N)
|
||||
|
||||
getSorted:
|
||||
enter 0,0
|
||||
|
||||
|
||||
leave
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;for(unsigned int i = 0; i < N ; i++)
|
||||
; for(unsigned int j = i + 1; j < N; j++)
|
||||
; if (newArr[i] > newArr[j]) SWAP newArr[i],newArr[j]
|
||||
CMAIN:
|
||||
|
||||
push 4
|
||||
push arr1
|
||||
call getSorted
|
||||
add esp,8
|
||||
|
||||
mov esi,eax
|
||||
mov ecx,4
|
||||
call WriteArrayFloat
|
||||
ret
|
||||
17
helloworld.asm
Normal file
17
helloworld.asm
Normal file
@ -0,0 +1,17 @@
|
||||
%include "rw32-2022.inc"
|
||||
|
||||
section .data
|
||||
sMessage db "Hello World!",EOL,0
|
||||
|
||||
section .text
|
||||
CMAIN:
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
|
||||
mov esi,sMessage ; ukazka volani funkce, ktera napise "Hello World!"
|
||||
call WriteString
|
||||
|
||||
; zde muzete psat vas kod
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
1375
rw32-2022.inc
Normal file
1375
rw32-2022.inc
Normal file
File diff suppressed because it is too large
Load Diff
221
t11.asm
Normal file
221
t11.asm
Normal file
@ -0,0 +1,221 @@
|
||||
%include 'rw32-2022.inc'
|
||||
|
||||
section .data
|
||||
; 1 + 4 + 2 + 2 + 2 + 4 + 4= 19
|
||||
currentTest dd 0
|
||||
TEST_REC_SIZE EQU 19
|
||||
testCount dd 11
|
||||
tests:
|
||||
t1 db 10
|
||||
dd 20
|
||||
dw 10
|
||||
dw 7
|
||||
dw 7
|
||||
dd 0
|
||||
dd 0
|
||||
t2 db 0
|
||||
dd 0
|
||||
dw 0
|
||||
dw 0
|
||||
dw 0
|
||||
dd 0
|
||||
dd 0
|
||||
t3 db 0xFF
|
||||
dd 0x0000FFFF
|
||||
dw 0xFFFF
|
||||
dw 0xFFFF
|
||||
dw 0xFFFF
|
||||
dd 0
|
||||
dd 0
|
||||
t4 db 0x80
|
||||
dd 0x00008000
|
||||
dw 0x8000
|
||||
dw 0x8000
|
||||
dw 0x8000
|
||||
dd 0
|
||||
dd 0
|
||||
t5 db 0x7F
|
||||
dd 0x00007FFF
|
||||
dw 0x7FFF
|
||||
dw 0x7FFF
|
||||
dw 0x7FFF
|
||||
dd 0
|
||||
dd 0
|
||||
t6 db 0x7F
|
||||
dd 0x7FFFFFFF
|
||||
dw 0x7FFF
|
||||
dw 0x7FFF
|
||||
dw 0x7FFF
|
||||
dd 0
|
||||
dd 0
|
||||
t7 db 0x80
|
||||
dd 0x80000000
|
||||
dw 0x8000
|
||||
dw 0x8000
|
||||
dw 0x8000
|
||||
dd 0
|
||||
dd 0
|
||||
t8 db 0xFF
|
||||
dd 0xFFFFFFFF
|
||||
dw 0xFFFF
|
||||
dw 0xFFFF
|
||||
dw 0xFFFF
|
||||
dd 0
|
||||
dd 0
|
||||
t9 db 10
|
||||
dd 20
|
||||
dw 10
|
||||
dw 7
|
||||
dw 7
|
||||
dd 0xFFFFFFFF
|
||||
dd 0xFFFFFFFF
|
||||
t10 db 10
|
||||
dd 20
|
||||
dw 10
|
||||
dw 7
|
||||
dw 7
|
||||
dd 0x7FFFFFFF
|
||||
dd 0x7FFFFFFF
|
||||
t11 db 10
|
||||
dd 20
|
||||
dw 10
|
||||
dw 7
|
||||
dw 7
|
||||
dd 0x80000000
|
||||
dd 0x80000000
|
||||
|
||||
a db 0
|
||||
b dd 0
|
||||
c dw 0
|
||||
d dw 0
|
||||
e dw 0
|
||||
q dd 0
|
||||
r dd 0
|
||||
|
||||
section .text
|
||||
PRINT_ABCDE:
|
||||
mov al,'('
|
||||
call WriteChar
|
||||
mov al,[a]
|
||||
call WriteUInt8
|
||||
mov al,','
|
||||
call WriteChar
|
||||
mov eax,[b]
|
||||
call WriteUInt32
|
||||
mov al,','
|
||||
call WriteChar
|
||||
mov ax,[c]
|
||||
call WriteUInt16
|
||||
mov al,','
|
||||
call WriteChar
|
||||
mov ax,[d]
|
||||
call WriteUInt16
|
||||
mov al,','
|
||||
call WriteChar
|
||||
mov ax,[e]
|
||||
call WriteUInt16
|
||||
mov al,')'
|
||||
call WriteChar
|
||||
mov al,'='
|
||||
call WriteChar
|
||||
ret
|
||||
|
||||
CMAIN:
|
||||
enter 0,0
|
||||
pushad
|
||||
pushfd
|
||||
|
||||
mov eax,3
|
||||
jmp .skip_pars
|
||||
mov eax,[ebp+8] ; argc
|
||||
cmp eax,2
|
||||
jb exit
|
||||
|
||||
mov esi,[ebp+12] ; argv
|
||||
mov edi,[esi] ; argv[0]
|
||||
CEXTERN atoi
|
||||
push dword [esi+4]
|
||||
call atoi
|
||||
add esp,4
|
||||
cmp eax,1
|
||||
jb exit
|
||||
cmp eax,[testCount]
|
||||
ja exit
|
||||
|
||||
mov ebx,-1
|
||||
mov ecx,-1
|
||||
mov edx,-1
|
||||
mov esi,-1
|
||||
mov edi,-1
|
||||
mov ebp,-1
|
||||
.skip_pars:
|
||||
imul eax,eax,TEST_REC_SIZE
|
||||
lea esi,[tests + eax - TEST_REC_SIZE]
|
||||
mov [currentTest],esi
|
||||
mov edi,a
|
||||
mov ecx,TEST_REC_SIZE
|
||||
cld
|
||||
rep movsb
|
||||
|
||||
call PRINT_ABCDE
|
||||
|
||||
mov dword [q],0xABABABAB
|
||||
mov dword [r],0xBABABABA
|
||||
mov eax,[currentTest + 11]
|
||||
mov edx,[currentTest + 15]
|
||||
mov esi,0
|
||||
call task12
|
||||
mov esi,q
|
||||
mov ecx,2
|
||||
call WriteArrayUInt32
|
||||
|
||||
exit:
|
||||
popfd
|
||||
popad
|
||||
leave
|
||||
xor eax,eax
|
||||
ret
|
||||
user_test_code_begin:
|
||||
task12:
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
xor edx, edx
|
||||
xor ecx, ecx
|
||||
mov al, byte [a]
|
||||
cbw
|
||||
cwde
|
||||
imul dword [b]
|
||||
mov ebx, eax
|
||||
xor eax, eax
|
||||
mov ax, word [c]
|
||||
cwde
|
||||
add eax, ebx
|
||||
add eax, 32
|
||||
mov ecx,eax
|
||||
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
xor edx, edx
|
||||
mov ax, 5
|
||||
mov bx, word [d]
|
||||
imul bx
|
||||
shl edx, 16
|
||||
mov dx, ax
|
||||
mov eax, edx
|
||||
mov ebx, eax
|
||||
xor eax, eax
|
||||
mov ax, word [e]
|
||||
cwde
|
||||
add eax, ebx
|
||||
mov ebx, 1256
|
||||
add eax, ebx
|
||||
|
||||
xchg eax, ecx
|
||||
cdq
|
||||
idiv ecx
|
||||
mov [q], eax
|
||||
mov [r], edx
|
||||
ret
|
||||
|
||||
user_test_code_end:
|
||||
ret
|
||||
5
test.c
Normal file
5
test.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
void main()
|
||||
{
|
||||
printf("Test %d, test %f\n", 1, 1.0);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user