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

Assembly Language Display Project: What code should be written in order to displ

ID: 3876050 • Letter: A

Question

Assembly Language Display Project: What code should be written in order to display this subtraction equation:
4 - 9 = -5
in command prompt?
PLEASE NOTE:
We are working in 32-bit and haven't been taught .data yet. I'll include a picture of an example of coding we've been given to learn so far. Thank you in advance!

Fifth-ASM-Notepad File Edit Format View Help MOV DL, AL SUB DL, 30H CMP DL, 10 CWindow ONS Location Location: SUB DL, 10 MOV CL, DL MOV DL, 31H Microsoft Copyright MOV AH, 6 INT 21H D DL 49608 MOV AH, 6 Wa MOV AX, 4c00H INT 21H MOV AH, 6 INT 21H MOV AX, 4co0H INT 21H Mcrosoft Copyright end mair 612 25 19 031 End of Medium 26 1A 032 Substitute 27 18033 Escape 28 1C 034 File Separator 29 1D035 Group Separator 30 1E 036 Record Separator 11F 37 dn

Explanation / Answer

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

.model small  

.data  

a db 0AH                                                              

b db 04H  

.code  

      mov      ax, @data      ; Initialize data section  

      mov      ds, ax  

      mov      al, a          ; Load number1 in al  

      mov      bl, b          ; Load number2 in bl  

      sub      al, bl         ; subtract numbers and result in al  

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

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

      mov      bh, al         ; Result in reg bh  

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

      mov      dl, bh         ; 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         ;   

l4:     add      dl, 30H  

      mov      ah, 02         ;

      int      21H  

      dec      ch             ;

      jnz      l2  

      mov      ah, 4cH        ;

      int      21H  

      end

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

.model small  

.data  

a db 0AH                                                              

b db 04H  

.code  

      mov      ax, @data      ; Initialize data section  

      mov      ds, ax  

      mov      al, a          ; Load number1 in al  

      mov      bl, b          ; Load number2 in bl  

      sub      al, bl         ; subtract numbers and result in al  

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

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

      mov      bh, al         ; Result in reg bh  

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

      mov      dl, bh         ; 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         ;   

l4:     add      dl, 30H  

      mov      ah, 02         ;

      int      21H  

      dec      ch             ;

      jnz      l2  

      mov      ah, 4cH        ;

      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