This is my assignment:
make sure you installed MASM correctly and that you can run/debug your simple assembly language.
Run the following calculations using MASM and assign the result to the same or different registers. Share a screenshot showing the content of the register.
B- Use memory locations with different sizes: byte, word, double word, quad word, save the calculated values in the memory locations. Take a screen shot with of the memory using at least two different sizes for the same values and submit in the same word document.
- 4 + 5 * 2
- 12 −1
- −5 + 2
- (4 + 2) * 6
- 16 / 5
- − ( 3 + 4 ) * ( 6 − 1 ) − 35
- − 3 + 4 * 6 − 1
- 25 MOD 3
Submit a copy of your code and a screenshot of the registers after each operation, or if you saved the result in different registers, just use one screenshot, and screenshots for the memory with at least two different data size.
This is the MASM code:
; Declare data segment
DATA SEGMENT
num1 DW 4
num2 DW 5
num3 DW 2
num4 DW 1
num5 DW -5
num6 DW 2
num7 DW 6
num8 DW 3
num9 DW 4
num10 DW 16
num11 DW 5
num12 DW 3
num13 DW 6
num14 DW 1
num15 DW 35
DATA ENDS
; Declare code segment
CODE SEGMENT
MAIN PROC
; Calculate 4 + 5 * 2 and store in num4
mov ax, num1
add ax, num2
mov bx, num3
mul bx
mov num4, ax
; Calculate 12 - 1 and store in num11
mov ax, num10
sub ax, num11
mov num11, ax
; Calculate -5 + 2 and store in num6
mov ax, num5
add ax, num6
mov num6, ax
; Calculate (4 + 2) * 6 and store in num7
mov ax, num1
add ax, num3
mov bx, num7
mul bx
mov num7, ax
; Calculate 16 / 5 and store in num11
mov ax, num10
cwd
mov bx, num11
div bx
mov num11, ax
; Calculate -(3 + 4) * (6 - 1) - 35 and store in num14
mov ax, num12
add ax, num9
neg ax
mov bx, num13
sub bx, num14
mul bx
sub ax, num15
mov num14, ax
; Calculate -3 + 4 * 6 - 1 and store in num6
mov ax, num5
neg ax
mov bx, num3
mul bx
add ax, num1
sub ax, num14
mov num6, ax
; Calculate 25 MOD 3 and store in num9
mov ax, num8
mov bx, num11
cwd
div bx
mov ax, num8
mov bx, num11
mul bx
sub ax, num8
mov num9, ax
; Exit program
mov ax, 4c00h
int 21h
MAIN ENDP
CODE ENDS
END MAIN
And this are the errors I get when I run this in cmd:
Assembling: LabW6.asm
LabW6.asm(25) : error A2074:cannot access label through segment registers
LabW6.asm(26) : error A2074:cannot access label through segment registers
LabW6.asm(27) : error A2074:cannot access label through segment registers
LabW6.asm(29) : error A2074:cannot access label through segment registers
LabW6.asm(32) : error A2074:cannot access label through segment registers
LabW6.asm(33) : error A2074:cannot access label through segment registers
.....
(and a great many more of this same error, with different line numbers)
.......
LabW6.asm(91) : warning A4023:with /coff switch, leading underscore required for start address :