Can someone explain me the code written for sms32v50 assembly

362 views Asked by At

Hello i have exercise to do a clock which will be counting from 1 to 59 in loop without ending. Can someone answer me to couple questions ?

  1. Why there are such numbers after DB? Is it ASCII or what?
  2. Why to BL we adding 03 ?

If someone can explain me line after line code. Thanks do much.

Language: sms32v50 assembler

    JMP start
    DB FA ; 0
    DB 0A ; 1
    DB B6 ; 2
    DB 9E ; 3
    DB 4E ; 4
    DB DC ; 5
    DB FC ; 6
    DB 8A ; 7
    DB FE ; 8
    DB DE ; 9
start:
    MOV DL, 00 
start1:
    MOV [90], DL
    MOV BL, [90]
    MOD BL, 0A
    ADD BL, 03
    MOV AL, [BL]
    INC AL
    OUT 02
    MOV BL, [90]
    DIV BL, 0A
    ADD BL, 03
    MOV AL, [BL]
    OUT 02
    NOP
    NOP
    NOP
    INC DL
    CMP DL, 3C
    JNZ koniec
    MOV DL, 00
    JMP start1
koniec:
    JMP start1
    END

I couldn't find the answer.

1

There are 1 answers

3
Sep Roland On

All the numbers in your code are expressed as hexadecimal. Normally this would require either a "0x" prefix or an "h" suffix.
eg. CMP DL, 3C would have to be written as CMP DL, 0x3C or CMP DL, 3Ch.

The code has numerous errors based on the tag:

  • MOD BL, 0A There's no such mod instruction for x86-16.

  • MOV AL, [BL] You can't use a byte register for addressing memory.

  • OUT 02 Outputting needs to specify the size.

  • DIV BL, 0A No dividing by an immediate available.

Why there are such numbers after DB? Is it ASCII or what?

No ASCII, I am pretty sure these numbers are bitvectors that would enable to visualize the decimal digits as if on a digital clock (with 7 segments).
The bits correspond to the segments as follows:

  <--7-->
 |       |
|6|     |1|
 |       |
  <--2-->
 |       |
|5|     |3|
 |       |
  <--4-->

Why to BL we adding 03 ?

Who knows in a code with this many errors, but again I am almost sure the 03 is a typo for 30 which would add 48 in decimal to convert from [0,9] into ["0","9"].

EDIT: It's code for a sms32v50 simulator

The above mentioned errors become void!
After having read the help page provided by Michael Petch, I now better understand where that 'adding 03' comes from: it's the address in memory where the table with the bitvectors is stored.
Code like

ADD BL, 03
MOV AL, [BL]

is equivalent to

MOV AL, [3 + BL]

The INC AL is added to the bitvector so as to output to the rightmost digit. Without setting bit 0, output goes to the leftmost digit.

ADD BL, 03 could still be an error knowing that JMP start has but a 2-byte encoding! We would have to see the program in action to know for sure. It could relate to the task description ("a clock which will be counting from 1 to 59") because the program currently starts from 0 in the DL register...