0% found this document useful (0 votes)
12 views

Lab 04

The document outlines 10 programming exercises involving arrays, registers, encoding strings, and 2D arrays. The exercises include initializing an array of bytes, storing register values in other registers, transferring and storing bit strings, calculating values from bit strings, counting even array elements, swapping array elements, encoding a string using XOR, traversing a 2D array and summing rows, and printing register values in hex, binary, and decimal formats.

Uploaded by

Tô Duy Vượng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lab 04

The document outlines 10 programming exercises involving arrays, registers, encoding strings, and 2D arrays. The exercises include initializing an array of bytes, storing register values in other registers, transferring and storing bit strings, calculating values from bit strings, counting even array elements, swapping array elements, encoding a string using XOR, traversing a 2D array and summing rows, and printing register values in hex, binary, and decimal formats.

Uploaded by

Tô Duy Vượng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab 04: Programming exercises

1. Initialize an array of bytes:


1. 0x10, 0x20, 0x30, . . . 0x90, 0x190, 0x180, 0x170, … 0x100
2. Store AX and DX in EBX following the rule:
e.g. AX = 0x1234, DX = 0x5678 then EBX = 0x78563412
3. Transfer an 8-bit string into AL
e.g. Bit string ‘1001 1101’ will be stored in AL as 1001 1101
4. Store value of AL in a bit string
e.g. AL = 1100 1010 then the bit string is ‘1100 1010’
5. Calculate the decimal value of a bit string
e.g. ‘0110 0011’ → 99
6. Count the number of even elements in an array of 8-bit values.
7. Swap elements of an array of 8-bit values in the following way:
Original memory area:

0x25 0x99 0xDF 0x56 0x00 0x7E 0x1D

Memory area after swapping:

0x1D 0x7E 0x00 0x56 0xDF 0x99 0x25

8. Encode a string:
Choose your own 1-byte KEY value.
Encode a string by XORing each character with KEY, print out the enciphered string
9. Traverse a 2-dimensional array
Declare an initialized 2-D array of bytes. Compute the sum of each row and store the results in an
array of 16-bit words.
10. Print out:
a) The value of dl register in hex:
e.g: mov dl, 15 → 0F
b) The value of dl register in binary
e.g: mov dl, 49 → 0011 0000
c) The value of dx register in decimal
e.g: mov dx, 1234 → 1234

You might also like