0

In this problem I need to keep track off all changes to the registers and the variables. Including MAR, MDR, EAX, EBX, and EDX. This is the code

; Description:  This program gets the age of the user and and calculates their age in dog years (age x 7).
INCLUDE Irvine32.inc

.data
age     DWORD   ?                           ; User's age (0x1000)
hi_there    BYTE    "Hi there, this is Paris",0             ; Greeting the user (0x1004)
prompt1 BYTE    "Can I have your age please?",0         ; Gets age (0x1008)
output      BYTE    "So, your age in dog years is: ",0          ; Reposts dog age (0x100C)
byebye      BYTE    "Thanks for passing by, have a great day!",0    ; Bye bye (0x1010)

.code
main PROC
; Greet the user
    mov EDX, OFFSET hi_there        ; Set up for call to WriteString and greet the user
    call    WriteString
    call    Crlf
; Gets the user's age
    mov EDX, OFFSET prompt1     ; Asks the user's age
    call    WriteString
    call    Crlf
    call    ReadInt         ; Reads the users age. Age in EAX
    call    Crlf

; Calculate the dog years and stores the dog age 
    mov EBX, 7
    mul EBX
    mov age, EAX            ; Stores the users dog age. Dog age also in EAX

; Reports the dog years and says bye
    mov EDX, OFFSET output
    call    WriteString
    mov EAX, age
    call    WriteDec
    call    Crlf
    mov EDX, OFFSET byebye
    call    WriteString
    call    Crlf
    exit                ;exit to operating system

main ENDP
END main

The steps given are in red, while the rest is what I did. To make it easier to read I highlighted anytime MAR, MDR, EAX, EBX, EDX and age changed, because everything else changed every step. My steps:

Please let me know if this is correct or not, I can't find any help on register changes on the rest of the internet

Rob
  • 14,746
  • 28
  • 47
  • 65
  • 3
    It's not entirely clear what `MAR` and `MDR` even mean in the context of x86, but `mov edx, offset foo` is just an immediate load so as such it should not change the `MAR` if `mov ebx, 7` doesn't. However `mov age, eax` should change `MAR` to `1000` because that's a memory write. – Jester Nov 05 '19 at 23:32
  • @Jester: If it really is memory-address/data registers ([which real x86 doesn't have](https://stackoverflow.com/questions/51522368/x86-registers-mbr-mdr-and-instruction-registers)), then don't forget every `call` writes a return address to ESP-4. And this table format couldn't even represent what `cmpsb` or `movsb` does, or `push [edi]` (two memory operands in one instruction; at most one of them explicit.) – Peter Cordes Nov 06 '19 at 00:44

0 Answers0