Question: . 3 8 6 include Irvine 3 2 . inc . data ; Date value in AX register ( e . g . , 0

.386
include Irvine32.inc
.data
; Date value in AX register (e.g.,0x00241503 for December 3,2004)
dateValue dw 0024,12,03
.code
FATDate proc
; Extract day, month, and year from dateValue
;YEAR
mov cx, dateValue
shr cx,0 ; Shift right to get year
mov dx, cx ; Store year in DX register
add dx,1980
; MONTH (bits 4 & 5)
mov cx, dateValue
and cx,00000110b ; Mask to isolate month bits (4 & 5 position)
shr cx,4 ; Shift right by 4 to position month (bits 0 & 1)
mov bl, cl ; Store month in BL register
; DAY (bits 0 & 1)
mov cx, dateValue
and cx,00000011b ; Mask to isolate day bits (0 & 1 position)
mov bh, cl ; Store day in AL register
ret
FATDate endp
main proc
lea ax, dateValue
;mov ds, ax
; Call the FATDate procedure
call FATDate
; Display day
movzx eax, bl ; Day to EAX (zero-extended to clear upper bits)
call WriteDec
call Crlf
; Display month
movzx eax, bh ; Month to EAX (zero-extended to clear upper bits)
call WriteDec
call Crlf
; Display year
movzx eax, dx ; Year to EAX (zero-extended to clear upper bits)
call WriteDec
call Crlf
invoke ExitProcess, 0
main endp
end main
DisplayNumber proc
; Display a 16-bit number (year)
push ax
push bx
push cx
push dx
mov bx,10
xor cx, cx
DisplayLoop:
div bx
add dl,'0'
push dx
inc cx
test ax, ax
jnz DisplayLoop
PrintLoop:
pop dx
mov ah,2
int 21h
loop PrintLoop
pop dx
pop cx
pop bx
pop ax
ret
DisplayNumber endp
main endp
end main
The year outputs correctly, but the month and day dont, why is this? Please note this is x86 Windows, using the Irvine32 library

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!