0 Replies - 796 Views - Last Post: 02 June 2017 - 04:18 PM Rate Topic: -----

#1 preciousaang  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-May 17

Problem with moving register into variable

Posted 02 June 2017 - 04:18 PM

I was given an assigment to rewite the fortran program below in asm. I can't seem to get the value in the al register into the "sum" variable.

program fortran
integer :: a, b, c, d, sum, avg
character(len=10) :: matno, surname
matno = "Matno"
surname = "Surname"
print *, matno
print *, surname
a = 15
print *, "a = ", a
b = 24
print *, "b = ", b
c = 6
print *, "c = ", c
d = 18
print *, "d = ", d
sum = 0
sum = a + b + c + d
print *, "sum of a, b, c, d = ", sum
a = sum + b
print *, "a = ", a
b = a * c
print *, "b = ", b
c = b - a
print *, "c = ", c
d = a + c
print *, "d = ", d
avg = sum/4
end

Here's My Code:

.model fortran
.data
surname db "Surname$"
matno db 13, 10, "MatNo$"
a db 15
b db 24
c db 6
d db 18
sum db 0
avg db ?
.code
mov ax, @data
mov ds, ax
lea dx, surname
mov ah, 09h
int 21h
lea dx, matno
mov ah, 09h
int 21h
mov ax, 00
mov al, a
add al, b
add al, c
add al, d
mov bl, al
mov sum, bl
end

Is This A Good Question/Topic? 0
  • +

Page 1 of 1