Está en la página 1de 4

Laboratorio 1

Alumno: Laura Ochoa Víctor

Ejercicio 01:
A. inc eax, 1  mov eax, 1
B. add ebx, ecx
C. add dog, cat
B. idiv 3
E. sub 2, number  sub eax, number
F. imul eax  imul number

Ejercicio 02:
A. product = 3 ∗ number;
mov eax, 3
imul number
mov product, eax

B. result = number / amount;


mov eax, number
mov ebx, amount
idiv eax
mov result, ebx

C. answer = number / 2;
mov eax, number
mov ebx, 2
idiv ebx
mov answer, eax

D. difference = 4 - number;
mov eax,number
sub eax,4
mov difference, eax
Ejercicio 03:
A. x = x ∗ y + z
.Section .Data
X dword
Y dword
Z dword

B. a = b - c / 3;
a dword
b dword
c dword
valor dword 3

C. total = num1 / num2 - (num3 ∗ num4);


Total dword
Num1 dword
Num2 dword
Num3 dword
Num4 dword

Ejercicio 04:
A. --i;
mov eax, i
des eax

B. j = ++k - m;
v = -w + x * y - z++
mov ebx, m
neg ebx
mov j, eax
des z

C. z = - (x + y);
mov ebx,x
add ebx, y
neg ebx
mov z, eax

D. a = ++b - c++;
mov eax, b
inc eax
mov ebx, c
inc ebx
sub ebx
mov a, ebx
Ejercicio 05:
#include <stdio.h>
int main(){
int number;
printf("\n%s","Enter an integer: ");
scanf("%d",&number);
number=7-number*3;
printf("\n%s%d\n\n","The integer is: ",number);
return 0;
}

.386
.model flat, c
.stack 100h
printf PROTO arg1:Ptr Byte, printlist:VARARG
scanf PROTO arg2:Ptr Sdword, inputlist: VARARG
.data
in1fmt byte "%d",0
msg1fmt byte 0Ah,"%s",0
msg1 byte "Ingrese el Numero: ",0
long val sdword ?

.code
main proc
INVOKE printf, ADDR msg1fmt, ADDR msg1
INVOKE scanf, ADDR in1fmt, ADDR long
; Resultado = 7-val*3
mov eax, 7
mov ebx, val
imul ebx, 3
sub eax, ebx
mov Resultado ,eax
ret
main endp
end
Ejercicio 06:
.386
.model flat, c
.stack 100h
printf PROTO arg1:Ptr Byte, printlist:VARARG
scanf PROTO arg2:Ptr Sdword, inputlist:VARARG
.data
in1fmt byte "%d",0
msg1fmt byte 0Ah,"%s",0
msg2fmt byte "%s",0
msg3fmt byte 0Ah,"%s%d",0Ah,0Ah,0
msg1 byte "Ingrese el Numero en volts: ",0
msg2 byte " Ingrese el Numero en ohms: ",0
msg3 byte "El Resultado es: ",0
volts sdword ? ; number of volts
ohms sdword ? ; number of ohms
amperes sdword ? ; number of amperes
.code
main proc
INVOKE printf, ADDR msg1fmt, ADDR msg1
INVOKE scanf, ADDR in1fmt, ADDR volts
INVOKE printf, ADDR msg2fmt, ADDR msg2
INVOKE scanf, ADDR in1fmt, ADDR ohms
; amperes = volts/ohms
mov eax,volts ; load volts into eax
cdq ; extend the sign bit
idiv ohms ; divide eax by ohms
mov amperes,eax ; store eax in amperes
INVOKE printf, ADDR msg3fmt, ADDR msg3, amperes
ret
main endp
end

También podría gustarte