Created
February 28, 2017 14:35
-
-
Save thejoeejoee/a30f83b325ec93ee1759025302c93b8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%include "rw32-2017.inc" | |
section .data | |
a dw -5;5 | |
b dw -2;2 | |
c dw 10;10 | |
d dw 0 | |
section .text | |
main: | |
mov ebp, esp; for correct debugging | |
;mov edx, 0 | |
;mov eax, 0 | |
;mov bl, -3200 | |
;mov al, 4 | |
;imul bl; vysledek po provedeni teto instrukce bude v registrech EDX:EAX tzn. EDX:EAX=EBX*EAX | |
;xor dx, dx ;vynuluje registr edx, protoze delenec bude pouze v registru eax | |
;mov ax, 20 ; delenec v eax | |
;mov bx, 3; delitel | |
;div bx; celociselny vysledek se ulozi do registru AX a zbytek po deleni do registru DX | |
; d = (4*a + 100*b) / c | |
mov ax, [a] | |
mov bx, word 4 | |
imul bx ; a * 4 | |
add [d], ax ; d += a * 4 | |
mov ax, [b] | |
mov bx, word 100 | |
imul bx ; b * 100 | |
add [d], ax ; d += b * 100 | |
mov ax, [d] | |
cwd | |
mov bx, [c] | |
idiv bx ; d /= c | |
mov [d], ax | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment