mickym2005 How do I cheat?
Reputation: 0
Joined: 13 Oct 2007 Posts: 8
|
Posted: Mon Mar 16, 2009 11:32 am Post subject: Assembly Help |
|
|
I'm still learning about Assembly language and I don't understand how to output an answer.
similar to the problem I'm using.
int Year=2004, R2D2; R2D2 is memory
Year++
R2D2=36 + Year - 2000 + (Year * 3 )% 7
Output R2D2
i have to translate that into Assembly and then output it.
| Quote: |
.model small
.stack 100h
.data
message db "Hello, world!" ,0dh,0ah, '$'
Year dw 2004
R2D2 dw ?
.code
main proc
mov ax,@data
mov ds, ax
; mult year by 3 (ax: 177F) x
mov dx,Year
inc dx
mov ax,3
mul dx
; (year * 3) % 7 (cx: 2) x
mov bx,7
idiv bx
mov cx,dx
; Add 36 + year (bx: 7F9) x
mov ax,36
mov bx,year
inc bx
add bx,ax
; sub 2000 from (36 + year) (Dx) (= 29)
mov ax,2000
sub bx,ax
; 36+year-2000+(year * 3) % 7 (BX 2B)
add bx,cx
; R2D2 (A: 2B)
mov R2D2, bx
mov ax,4C00h
int 21h
main endp
end main
|
the Answer i get is 2B, but I'm not sure how to output it.
any help is appreciated.
|
|