# Problem with moving register into variable

Page 1 of 1

## 0 Replies - 796 Views - Last Post: 02 June 2017 - 04:18 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=404388&amp;s=101ee05086dbafcd42d9f4092fb4fe33&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 preciousaang

Reputation: 0
• 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