+1 (315) 557-6473 

Perform Operations On Different Data Sizes (Using Irvine Library In Windows) Assembly Language, X86 Assembly Assignment Solution.


Instructions

Objective
Write an Assembly language assignment program to perform operations on different data sizes (using Irvine library in Windows), x86 Assembly.

Requirements and Specifications

Assembly language with operations on different data sizes Assembly language
Screenshots of output
Assembly language with operations on different data sizes Assembly language 1
Source Code
INCLUDE Irvine32.inc
.data
bNum01 byte 64
bNum02 byte 32
bNum03 byte 16
bSum byte ?
bDiff byte ?
bResult byte ?
wNum01 word 64
wNum02 word 32
wNum03 word 16
wSum word ?
wDiff word ?
wResult word ?
dwNum01 dword 64
dwNum02 dword 32
dwNum03 dword 16
dwSum dword ?
dwDiff dword ?
dwResult dword ?
dwTotal dword ?
.code
main PROC
    movzx eax, BYTE PTR[bNum01] ; load first byte value
    movzx ebx, BYTE PTR[bNum02] ; load second byte value
    add eax, ebx ; add the two numbers
    movzx ebx, BYTE PTR[bNum03] ; load third byte value
    add eax, ebx ; add the three numbers
    mov [bSum], al ; save result
    movzx eax, WORD PTR[wNum01] ; load first word value
    movzx ebx, WORD PTR[wNum02] ; load second word value
    add eax, ebx ; add the two numbers
    movzx ebx, WORD PTR[wNum03] ; load third word value
    add eax, ebx ; add the three numbers
    mov [wSum], ax ; save result
    mov eax, [dwNum01] ; load first dword value
    add eax, [dwNum02] ; add second dword value
    add eax, [dwNum03] ; add third dword value
    mov [dwSum], eax ; save result
    movzx eax, BYTE PTR[bNum02] ; load second byte value
    movzx ebx, BYTE PTR[bNum03] ; load third byte value
    add eax, ebx ; add the two numbers
    movzx ebx, BYTE PTR[bNum01] ; load first byte value
    sub eax, ebx ; subtract the first from the sum of the first
    mov [bDiff], al ; save result
    movzx eax, WORD PTR[wNum02] ; load second word value
    movzx ebx, WORD PTR[wNum03] ; load third word value
    add eax, ebx ; add the two numbers
    movzx ebx, WORD PTR[wNum01] ; load first word value
    sub eax, ebx ; subtract the first from the sum of the first
    mov [wDiff], ax ; save result
    mov eax, [dwNum02] ; load second dword value
    add eax, [dwNum03] ; add third word value
    sub eax, [dwNum01] ; subtract first word value from sum
    mov [dwDiff], eax ; save result
    movzx eax, BYTE PTR [bSum] ; load byte sum
    movzx ebx, BYTE PTR [bDiff] ; load byte difference
    add eax, ebx ; load sum and difference
    mov [bResult], al ; save result
    movzx eax, WORD PTR [wSum] ; load word sum
    movzx ebx, WORD PTR [wDiff] ; load word difference
    add eax, ebx ; load sum and difference
    mov [wResult], ax ; save result
    mov eax, [dwSum] ; load dword sum
    add eax, [dwDiff] ; add dword difference
    mov [dwResult], eax ; save result
    ; Dump variables
    mov esi, OFFSET bSum ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE BYTE ; byte format
    call DumpMem
    mov esi, OFFSET bDiff ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE BYTE ; byte format
    call DumpMem
    mov esi, OFFSET bResult ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE BYTE ; byte format
    call DumpMem
    mov esi, OFFSET wSum ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE WORD ; byte format
    call DumpMem
    mov esi, OFFSET wDiff ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE WORD ; byte format
    call DumpMem
    mov esi, OFFSET wResult ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE WORD ; byte format
    call DumpMem
    mov esi, OFFSET dwSum ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE DWORD ; byte format
    call DumpMem
    mov esi, OFFSET dwDiff ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE DWORD ; byte format
    call DumpMem
    mov esi, OFFSET dwResult ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE DWORD ; byte format
    call DumpMem
    movzx eax, BYTE PTR [bSum] ; load byte sum
    movzx ebx, WORD PTR [wSum] ; load word sum
    add eax, ebx ; add byte and word sums
    add eax, [dwSum] ; add dword sum
    mov [dwTotal], eax ; save result
    ; Dump total
    mov esi, OFFSET dwtotal ; starting OFFSET
    mov ecx, 1 ; number of units
    mov ebx, TYPE DWORD ; byte format
    call DumpMem
    call CrLf ; jump to new line
    call WaitMsg ; pause the screen until a key is pressed
    exit ; Terminate the program
main ENDP
END main