School Commit Init
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
bits 32 ; assembling for the 32 bits architecture
|
||||
|
||||
; declare the EntryPoint (a label defining the very first instruction of the program)
|
||||
global start
|
||||
|
||||
; declare external functions needed by our program
|
||||
extern exit ; tell nasm that exit exists even if we won't be defining it
|
||||
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
|
||||
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
|
||||
|
||||
; our data is declared here (the variables needed by our program)
|
||||
segment data use32 class=data
|
||||
a db 12h
|
||||
b dw 74A1h
|
||||
c dd 243F2149h
|
||||
d dq 768AC79B8296E852h
|
||||
|
||||
; our code starts here
|
||||
segment code use32 class=code
|
||||
start:
|
||||
mov AL,[a] ;AL=a
|
||||
cbw
|
||||
cwde ;EAX=a
|
||||
mov EBX,EAX ;EBX=a
|
||||
mov AX,[b] ;AX=b
|
||||
cwde ;EAX=b
|
||||
add EAX,[c] ;EAX=c+b
|
||||
add EAX,EBX ;EAX=c+b+a
|
||||
cdq ;EDX:EAX=c+b+a
|
||||
mov EBX,[d]
|
||||
mov ECX,[d+4] ;ECX:EBX=d
|
||||
add EBX,[d]
|
||||
adc ECX,[d+4] ;ECX:EBX=d+d
|
||||
sub EAX,EBX
|
||||
sbb EDX,ECX ;EDX:EAX=(c+b+a)-(d+d)
|
||||
; exit(0)
|
||||
push dword 0 ; push the parameter for exit onto the stack
|
||||
call [exit] ; call exit to terminate the program
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
bits 32 ; assembling for the 32 bits architecture
|
||||
|
||||
; declare the EntryPoint (a label defining the very first instruction of the program)
|
||||
global start
|
||||
|
||||
; declare external functions needed by our program
|
||||
extern exit ; tell nasm that exit exists even if we won't be defining it
|
||||
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
|
||||
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
|
||||
|
||||
; our data is declared here (the variables needed by our program)
|
||||
segment data use32 class=data
|
||||
a db 12h
|
||||
b dw 74A1h
|
||||
c dd 243F2149h
|
||||
d dq 768AC79B8296E852h
|
||||
|
||||
; our code starts here
|
||||
segment code use32 class=code
|
||||
start:
|
||||
mov AL,[a] ;AL=a
|
||||
cbw
|
||||
cwde
|
||||
cdq ;EDX:EAX=a
|
||||
mov EBX,[d]
|
||||
mov ECX,[d+4] ;ECX:EBX=d
|
||||
sub EBX,EAX
|
||||
sbb ECX,EDX ;ECX:EBX=d-a
|
||||
sub EAX,[c] ;EAX=a-c
|
||||
cdq
|
||||
sub EBX,EAX
|
||||
sbb ECX,EDX ;ECX:EBX=(d-a)-(a-c)
|
||||
sub EBX,[d]
|
||||
sbb ECX,[d+4] ;ECX:EBX=(d-a)-(a-c)-d
|
||||
|
||||
; exit(0)
|
||||
push dword 0 ; push the parameter for exit onto the stack
|
||||
call [exit] ; call exit to terminate the program
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
bits 32 ; assembling for the 32 bits architecture
|
||||
|
||||
; declare the EntryPoint (a label defining the very first instruction of the program)
|
||||
global start
|
||||
|
||||
; declare external functions needed by our program
|
||||
extern exit ; tell nasm that exit exists even if we won't be defining it
|
||||
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
|
||||
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
|
||||
|
||||
; our data is declared here (the variables needed by our program)
|
||||
segment data use32 class=data
|
||||
a db 12h
|
||||
b dw 74A1h
|
||||
c dd 243F2149h
|
||||
d dq 768AC79B8296E852h
|
||||
|
||||
; our code starts here
|
||||
segment code use32 class=code
|
||||
start:
|
||||
mov EBX,0 ;EBX=0
|
||||
mov BL,[a] ;EBX=a
|
||||
mov EDX,[d+4] ;
|
||||
mov EAX,[d] ;EDX:EAX=d
|
||||
add EAX,EBX
|
||||
adc EDX,0 ;EDX:EAX=a+d
|
||||
mov EBX,[c]
|
||||
mov ECX,0 ;ECX:EBX=c
|
||||
sub EBX,EAX
|
||||
sbb ECX,EDX ;ECX:EBX=c-(a+d)
|
||||
push EBX
|
||||
push ECX
|
||||
mov EDX,[d+4]
|
||||
mov EAX,[d] ;EDX:EAX=d
|
||||
mov ECX,0
|
||||
mov CX,[b] ;ECX=b
|
||||
add EAX,ECX
|
||||
adc EDX,0 ;EDX:EAX=b+d
|
||||
pop ECX
|
||||
pop EBX ;ECX:EBX=c-(a+d)
|
||||
add EAX,EBX
|
||||
adc EDX,ECX ;EDX:EAX=c-(a+d)+(b+d)
|
||||
|
||||
; exit(0)
|
||||
push dword 0 ; push the parameter for exit onto the stack
|
||||
call [exit] ; call exit to terminate the program
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
bits 32 ; assembling for the 32 bits architecture
|
||||
|
||||
; declare the EntryPoint (a label defining the very first instruction of the program)
|
||||
global start
|
||||
|
||||
; declare external functions needed by our program
|
||||
extern exit ; tell nasm that exit exists even if we won't be defining it
|
||||
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
|
||||
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
|
||||
|
||||
; our data is declared here (the variables needed by our program)
|
||||
segment data use32 class=data
|
||||
a db 12h
|
||||
b dw 74A1h
|
||||
c dd 243F2149h
|
||||
d dq 768AC79B8296E852h
|
||||
|
||||
; our code starts here
|
||||
segment code use32 class=code
|
||||
start:
|
||||
; ...
|
||||
mov EAX,0
|
||||
mov EBX,0
|
||||
mov AL,[a] ;EAX=a
|
||||
mov BX,[b] ;EBX=b
|
||||
add EBX,EAX ;EBX=b+a
|
||||
mov ECX,[c] ;ECX=c
|
||||
sub ECX,EAX ;ECX=c-a
|
||||
sub ECX,EBX ;ECX=c-a-(b+a)
|
||||
add ECX,[c] ;ECX=c-a-(b+a)+c
|
||||
|
||||
|
||||
; exit(0)
|
||||
push dword 0 ; push the parameter for exit onto the stack
|
||||
call [exit] ; call exit to terminate the program
|
||||
@@ -0,0 +1,39 @@
|
||||
bits 32 ; assembling for the 32 bits architecture
|
||||
|
||||
; declare the EntryPoint (a label defining the very first instruction of the program)
|
||||
global start
|
||||
|
||||
; declare external functions needed by our program
|
||||
extern exit ; tell nasm that exit exists even if we won't be defining it
|
||||
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
|
||||
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
|
||||
|
||||
; our data is declared here (the variables needed by our program)
|
||||
segment data use32 class=data
|
||||
a db 12h
|
||||
b dd 7483AB72h
|
||||
c dq 768AC79B8296E852h
|
||||
|
||||
; our code starts here
|
||||
segment code use32 class=code
|
||||
start:
|
||||
mov AL,[a] ;AL=a
|
||||
imul byte [a] ;AX=a*a
|
||||
cwde ;EAX=a*a
|
||||
sub EAX,[b] ;EAX=a*a-b
|
||||
add EAX,7 ;EAX=a*a-b+7
|
||||
push EAX
|
||||
mov AL,[a] ;AL=a
|
||||
cbw
|
||||
cwde ;EAX=a
|
||||
add EAX,2 ;EAX=2+a
|
||||
mov EBX,EAX ;EBX=2+a
|
||||
pop EAX ;EAX=a*a-b+7
|
||||
cdq ;EDX:EAX=a*a-b+7
|
||||
idiv EBX ;EAX=(a*a-b+7)/(2+a)
|
||||
cdq ;EDX:EAX=(a*a-b+7)/(2+a)
|
||||
add EAX,[c]
|
||||
adc EDX,[c+4] ;EDX:EAX=c+(a*a-b+7)/(2+a)
|
||||
; exit(0)
|
||||
push dword 0 ; push the parameter for exit onto the stack
|
||||
call [exit] ; call exit to terminate the program
|
||||
@@ -0,0 +1,58 @@
|
||||
bits 32 ; assembling for the 32 bits architecture
|
||||
|
||||
; declare the EntryPoint (a label defining the very first instruction of the program)
|
||||
global start
|
||||
|
||||
; declare external functions needed by our program
|
||||
extern exit ; tell nasm that exit exists even if we won't be defining it
|
||||
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
|
||||
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
|
||||
|
||||
; our data is declared here (the variables needed by our program)
|
||||
segment data use32 class=data
|
||||
a dw 7293h
|
||||
b db 0A8h
|
||||
c dw 0B749h
|
||||
d db 4Bh
|
||||
e dd 7483AB72h
|
||||
x dq 768AC79Bh
|
||||
|
||||
; our code starts here
|
||||
segment code use32 class=code
|
||||
start:
|
||||
mov EAX,[x]
|
||||
mov EDX,[x+4] ;EDX:EAX=x
|
||||
mov EBX,2 ;EBX=2
|
||||
idiv EBX ;EAX=x/2
|
||||
push EAX
|
||||
mov AL,[b] ;AL=b
|
||||
cbw ;AX=b
|
||||
mov BX,AX ;BX=b
|
||||
pop EAX
|
||||
add BX,[a] ;BX=a+b
|
||||
mov ECX,EAX ;ECX=x/2
|
||||
mov AX,100 ;AX=100
|
||||
imul BX ;EAX=100*(a+b)
|
||||
add ECX,EAX ;ECX=x/2+100*(a+b)
|
||||
mov AX,3 ;AX=3
|
||||
cwd ;DX:AX=3
|
||||
push AX
|
||||
mov AL,[d] ;AL=d
|
||||
cbw ;AX=d
|
||||
mov BX,AX ;BX=d
|
||||
pop AX
|
||||
add BX,[c] ;BX=c+d
|
||||
idiv BX ;AX=3/(c+d)
|
||||
cwde
|
||||
sub ECX,EAX ;ECX=x/2+100*(a+b)-3/(c+d)
|
||||
mov EAX,ECX
|
||||
cdq
|
||||
mov EBX,EDX
|
||||
mov EAX,[e] ;EAX=e
|
||||
imul dword [e] ;EDX:EAX=e*e
|
||||
add EAX,ECX
|
||||
adc EDX,EBX ;EDX:EAX=x/2+100*(a+b)-3/(c+d)+e*e
|
||||
|
||||
; exit(0)
|
||||
push dword 0 ; push the parameter for exit onto the stack
|
||||
call [exit] ; call exit to terminate the program
|
||||
@@ -0,0 +1,37 @@
|
||||
bits 32 ; assembling for the 32 bits architecture
|
||||
|
||||
; declare the EntryPoint (a label defining the very first instruction of the program)
|
||||
global start
|
||||
|
||||
; declare external functions needed by our program
|
||||
extern exit ; tell nasm that exit exists even if we won't be defining it
|
||||
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
|
||||
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
|
||||
|
||||
; our data is declared here (the variables needed by our program)
|
||||
segment data use32 class=data
|
||||
a db 12h
|
||||
b dd 7483AB72h
|
||||
c dq 768AC79B8296E852h
|
||||
|
||||
; our code starts here
|
||||
segment code use32 class=code
|
||||
start:
|
||||
mov AL,[a] ;AL=a
|
||||
mul byte [a] ;AX=a*a
|
||||
mov BX,AX
|
||||
mov EAX,0
|
||||
mov AX,BX ;EAX=a*a
|
||||
sub EAX,[b] ;EAX=a*a-b
|
||||
add EAX,7 ;EAX=a*a-b+7
|
||||
mov EDX,0 ;EDX:EAX=a*a-b+7
|
||||
mov EBX,0 ;EBX=0
|
||||
mov BL,[a] ;EBX=a
|
||||
add EBX,2 ;EBX=2+a
|
||||
div EBX ;EAX=(a*a-b+7)/(2+a)
|
||||
mov EDX,0 ;EDX:EAX=(a*a-b+7)/(2+a)
|
||||
add EAX,[c]
|
||||
adc EDX,[c+4] ;EDX:EAX=c+(a*a-b+7)/(2+a)
|
||||
; exit(0)
|
||||
push dword 0 ; push the parameter for exit onto the stack
|
||||
call [exit] ; call exit to terminate the program
|
||||
@@ -0,0 +1,50 @@
|
||||
bits 32 ; assembling for the 32 bits architecture
|
||||
|
||||
; declare the EntryPoint (a label defining the very first instruction of the program)
|
||||
global start
|
||||
|
||||
; declare external functions needed by our program
|
||||
extern exit ; tell nasm that exit exists even if we won't be defining it
|
||||
import exit msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
|
||||
; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
|
||||
|
||||
; our data is declared here (the variables needed by our program)
|
||||
segment data use32 class=data
|
||||
a dw 7293h
|
||||
b db 0A8h
|
||||
c dw 0B749h
|
||||
d db 4Bh
|
||||
e dd 7483AB72h
|
||||
x dq 768AC79Bh
|
||||
|
||||
; our code starts here
|
||||
segment code use32 class=code
|
||||
start:
|
||||
mov EAX,[x]
|
||||
mov EDX,[x+4] ;EDX:EAX=x
|
||||
mov EBX,2 ;EBX=2
|
||||
div EBX ;EAX=x/2
|
||||
mov BX,0
|
||||
mov BL,[b] ;BX=b
|
||||
add BX,[a] ;BX=a+b
|
||||
mov ECX,EAX ;ECX=x/2
|
||||
mov AX,100 ;AX=100
|
||||
mul BX ;EAX=100*(a+b)
|
||||
add ECX,EAX ;ECX=x/2+100*(a+b)
|
||||
mov AX,3 ;AX=3
|
||||
mov DX,0 ;DX:AX=3
|
||||
mov BX,0 ;BX=0
|
||||
mov BL,[d] ;BX=d
|
||||
add BX,[c] ;BX=c+d
|
||||
div BX ;AX=3/(c+d)
|
||||
mov EBX,0
|
||||
mov BX,AX ;EBX=3/(c+d)
|
||||
sub ECX,EBX ;ECX=x/2+100*(a+b)-3/(c+d)
|
||||
mov EAX,[e] ;EAX=e
|
||||
mul dword [e] ;EDX:EAX=e*e
|
||||
add EAX,ECX
|
||||
adc EDX,0 ;EDX:EAX=x/2+100*(a+b)-3/(c+d)+e*e
|
||||
|
||||
; exit(0)
|
||||
push dword 0 ; push the parameter for exit onto the stack
|
||||
call [exit] ; call exit to terminate the program
|
||||
Reference in New Issue
Block a user