Another question about my programming class, well actually a few. To begin with the program has already been written and the code can be found below.
Question #1:
Now, in the instructions it explicitly states that the program can be done in protected mode or real-address mode. I'm fairly certain that Windows runs in protected mode and as such this means I have done the exercises in such a manner. If I wanted to, how would one change which mode the program executes in? Am I correct in saying windows operates in protected mode?
Question #2:
I have written a few comments in the assembly code below is the one stating how the first 16-bits of the register have been filled correct?
Question #3:
Lastly the instruction call for inclusion of the Listing file and Map file in the final submission, I cannot locate these files.
TITLE Subtracting Three Integers
; This program takes three integers in hexidecimal and then subtract the 2nd and 3rd from the first.
INCLUDE Irvine32.inc
.code
main PROC
mov ax,0109h ;stores integer 265 in ax(16-bit register)
mov bx,0041h ;stores integer 65 in bx(16-bit register)
mov cx,0064h ;stores integer 100 in cx(16-bit register)
sub ax,bx
sub ax,cx
call DumpRegs
comment !
The dump regs returns the value of EAX=763B0064 BAX=7FFD0041 CAX=00000064
because EAX EBX and ECX are 32-bit registers they fill the first 16-bits with
unallocated data from other programs
!
exit
main ENDP
END main
1- The main difference between real and protected mode is that in real mode, any program can access any memory location, and in protected mode, programs can only access certain memory locations that are laid out for them. The issues with real mode are obvious- any program on your computer could watch your every move. As this is a huge security issue, real mode became obsolete, and now almost all modern operating systems run in protected mode.
Your program can run in either mode, as it does not access any out-of-bounds memory locations. All of the code is laid out in memory and stays within the limits. General purpose registers are not in memory, so you are safe there also.
2- You are correct. Watch out, though- if ax
is signed, then the value 265
is too large for a 16-bit register.
3- A "map" file is a file that shows how the segments are laid out in your code. It also can show symbols and their virtual addresses. A "linker" file demonstrates command locations, values, and their relation to the individual opcodes that you put in. Both of these can be generated with your compiler.