Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The first program (Prog03a.asm) will involve a modification of the AddSub.asm th

ID: 3889156 • Letter: T

Question

The first program (Prog03a.asm) will involve a modification of the AddSub.asm that is posted. You will first move 4000h to a 16 bit register, and then 1000h and 1500h to two other 16 bit registers. Then subtract the second register content from the first register content, putting the result back into the first register. Then you will subtract the third register from the first register, putting the result back into the first register. Before the moves, 0 out the corresponding 32 bits registers from which you are going to use the 16 bit segments.

Each move line of code should have a comment that shows the base 10 equivalent of the content of the register.

Each subtraction line of code should have a comment that shows the hex content of the first 16 bit register and its corresponding base 10 value. The hex values of the first 16 bit register should be read from the registers display in Visual Studio as the program is stepped through the subtract statements.

The second program (Prog03b.asm) will involve some data declarations:

var01 is a BYTE with magnitude 2 less that the maximum possible BYTE value.

var02 is an SBYTE with a magniture 2 more than the minimum (most negative) SBYTE value.

            (This means +2 added to the minimum sbyte).

var03 is a WORD that is 5 less than the maximum possible WORD value.

var04 is an SWORD wil magnitude 100 more than the minimum (most negative) SWORD value.

var05 is an SDWORD with magnitude 100 more than the more than the minimum (most  

                       negative) SDWORD value.

All magnitudes should be expressed as (possibly signed) base 10 numbers. The first set of slides has a table that should be helpful.

In the .code portion of the second program, first 0 out the eax register. Then program a series of move statements that move var01 through var05 into appropriately sized segments of eax. Each move statement line should have a comment giving the hex value for the register value changed in the statement. Read this hex value from the registers display in Visual Studio as the program is stepped through the move statements.

Explanation / Answer

mov     ax, @data               ; Initialize data section

       mov     ds, ax

       mov     ax, a                      ; Load number1 in ax

       mov     bx, b                     ; Load number2 in bx

       sub      ax, bx                    ; subtract numbers. Result in ax

       mov     ch, 04h                  ; Count of digits to be displayed

       mov     cl, 04h          ; Count to roll by 4 bits

       mov     bx, ax                    ; Result in reg bx

l2:    rol       bx, cl                     ; roll bl so that msb comes to lsb

       mov     dl, bl                     ; load dl with data to be displayed

       and      dl, 0fH          ; get only lsb

       cmp     dl, 09                    ; check if digit is 0-9 or letter A-F

       jbe       l4

       add      dl, 07                    ; if letter add 37H else only add 30H

l4:    add      dl, 30H

       mov     ah, 02                    ; Function 2 under INT 21H (Display character)

       int       21H

       dec      ch                         ; Decrement Count

       jnz       l2

       mov     ah, 4cH                  ; Terminate Program

       int       21H

       end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote